|
|
@@ -34,6 +34,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -55,6 +56,8 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
|
|
|
private final StoreUserService storeUserService;
|
|
|
|
|
|
+ private final StoreDictionaryMapper storeDictionaryMapper;
|
|
|
+
|
|
|
private final AliApi aliApi;
|
|
|
|
|
|
private final StoreIncomeDetailsRecordMapper storeIncomeDetailsRecordMapper;
|
|
|
@@ -65,6 +68,8 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
private final WebSocketProcess webSocketProcess;
|
|
|
private final StoreInfoMapper storeInfoMapper;
|
|
|
|
|
|
+ private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
/**
|
|
|
* 提现-提现全部-手续费一单一算
|
|
|
*
|
|
|
@@ -406,24 +411,29 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
public JSONObject noYetPayment(Integer storeId, Integer incomeType, Integer paymentType, String startTime, String endTime, int page, int size) {
|
|
|
QueryWrapper<StoreIncomeDetailsRecord> wrapper = new QueryWrapper<StoreIncomeDetailsRecord>();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- Date now = new Date();
|
|
|
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ //获取字典表冻结期字段
|
|
|
+ StoreDictionary storeDictionarie = storeDictionaryMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<StoreDictionary>()
|
|
|
+ .eq(StoreDictionary::getTypeName, "LockUpPeriod"));
|
|
|
+ int lockUpPeriod = Integer.parseInt(storeDictionarie.getDictId());
|
|
|
if (paymentType == 0) {
|
|
|
wrapper.isNull("sidr.cash_out_id");
|
|
|
- //未到账期, 当前时间-3天大于创建时间
|
|
|
- wrapper.gt("sidr.created_time", DateUtils.calcDays(new Date(), -3));
|
|
|
- Date startDate = DateUtils.calcDays(now, -3);
|
|
|
- jsonObject.put("date", df.format(startDate) + " ~ " + df.format(now));
|
|
|
+ //未到账期, 当前时间-冻结期天数大于创建时间(修改为字典表取值了)
|
|
|
+ wrapper.ge("sidr.created_time", now.minusDays(lockUpPeriod));
|
|
|
+ LocalDateTime startDate = now.minusDays(lockUpPeriod);
|
|
|
+ jsonObject.put("date", startDate.format(DATE_FORMATTER) + " ~ " + now.format(DATE_FORMATTER));
|
|
|
} else {
|
|
|
- wrapper.isNotNull("sidr.cash_out_id");
|
|
|
- //已到账期, 当前时间-4~27天大于创建时间
|
|
|
- wrapper.between("sidr.created_time", DateUtils.calcDays(new Date(), -27), DateUtils.calcDays(new Date(), -4));
|
|
|
- Date startDate = DateUtils.calcDays(now, -27);
|
|
|
- Date endDate = DateUtils.calcDays(now, -4);
|
|
|
- jsonObject.put("date", df.format(startDate) + " ~ " + df.format(endDate));
|
|
|
+ wrapper.isNull("sidr.cash_out_id");
|
|
|
+ //已到账期, 当前时间-冻结期天数大于创建时间(修改为字典表取值了)
|
|
|
+ wrapper.lt("sidr.created_time", now.minusDays(lockUpPeriod));
|
|
|
+// Date startDate = DateUtils.calcDays(now, -27);
|
|
|
+ LocalDateTime endDate = now.minusDays(lockUpPeriod);
|
|
|
+ jsonObject.put("date", "min" + " ~ " + endDate.format(DATE_FORMATTER));
|
|
|
}
|
|
|
- if(storeId!=null){
|
|
|
- wrapper.eq("sidr.store_id",storeId);
|
|
|
+ if (storeId != null) {
|
|
|
+ wrapper.eq("sidr.store_id", storeId);
|
|
|
}
|
|
|
//未绑定提现记录的
|
|
|
LocalDate startDate = LocalDate.parse(startTime);
|
|
|
@@ -464,6 +474,11 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
@Override
|
|
|
public Map<String, Object> accountBalance(Integer storeId) {
|
|
|
// TODO 可提现金额 - cashout表里的已提现和待审核的
|
|
|
+ //获取字典表冻结期字段
|
|
|
+ StoreDictionary storeDictionarie = storeDictionaryMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<StoreDictionary>()
|
|
|
+ .eq(StoreDictionary::getTypeName, "LockUpPeriod"));
|
|
|
+ int lockUpPeriod = Integer.parseInt(storeDictionarie.getDictId());
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
LambdaQueryWrapper<StoreUser> storeUserWrapper = new LambdaQueryWrapper<>();
|
|
|
storeUserWrapper.eq(StoreUser::getStoreId, storeId);
|
|
|
@@ -471,17 +486,17 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
//余额 门店用户表
|
|
|
map.put("balance", new BigDecimal(storeUser.getMoney()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP).toString());
|
|
|
LambdaQueryWrapper<StoreIncomeDetailsRecord> wrapper = new LambdaQueryWrapper<>();
|
|
|
- //当前时间-3天大于创建时间
|
|
|
- wrapper.between(StoreIncomeDetailsRecord::getCreatedTime, DateUtils.calcDays(new Date(), -27), DateUtils.calcDays(new Date(), -4))
|
|
|
+ //当前时间-冻结期天数大于创建时间
|
|
|
+ wrapper.lt(StoreIncomeDetailsRecord::getCreatedTime, DateUtils.calcDays(new Date(), -lockUpPeriod))
|
|
|
//未绑定提现记录的
|
|
|
.isNull(StoreIncomeDetailsRecord::getCashOutId)
|
|
|
.eq(StoreIncomeDetailsRecord::getStoreId, storeId);
|
|
|
List<StoreIncomeDetailsRecord> list = this.list(wrapper);
|
|
|
int cashOutMoney = 0;
|
|
|
cashOutMoney += list.stream().mapToInt(StoreIncomeDetailsRecord::getMoney).sum();
|
|
|
- List<StoreCashOutRecord> storeCashOutRecords = storeCashOutRecordMapper.selectList(new QueryWrapper<StoreCashOutRecord>().eq("store_id", storeId).in("payment_status", "1","3").eq("delete_flag", "0"));
|
|
|
+ List<StoreCashOutRecord> storeCashOutRecords = storeCashOutRecordMapper.selectList(new QueryWrapper<StoreCashOutRecord>().eq("store_id", storeId).in("payment_status", "1", "3").eq("delete_flag", "0"));
|
|
|
int totalAmount = storeCashOutRecords.stream().collect(Collectors.summingInt(StoreCashOutRecord::getMoney));
|
|
|
- //可提现金额 4~27天
|
|
|
+ //可提现金额 冻结期天数后
|
|
|
map.put("cashOutMoney", new BigDecimal(cashOutMoney).subtract(BigDecimal.valueOf(totalAmount)).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP).toString());
|
|
|
return map;
|
|
|
}
|