|
|
@@ -68,8 +68,8 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
/**
|
|
|
* 提现-提现全部-手续费一单一算
|
|
|
*
|
|
|
- * @param storeId 门店id
|
|
|
- * @param payPassword 支付密码
|
|
|
+ * @param storeId 门店id
|
|
|
+ * @param payPassword 支付密码
|
|
|
* @param withdrawalMoney 提现金额
|
|
|
* @return 是否成功
|
|
|
*/
|
|
|
@@ -131,8 +131,8 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
}
|
|
|
return "账单未到可提现时间";
|
|
|
}*/
|
|
|
- if ( null != storeUser){
|
|
|
- if( storeUser.getMoney() >= withdrawalMoney){
|
|
|
+ if (null != storeUser) {
|
|
|
+ if (storeUser.getMoney() >= withdrawalMoney) {
|
|
|
//调用支付宝转账
|
|
|
BigDecimal decimal = new BigDecimal(withdrawalMoney);
|
|
|
BigDecimal divide = decimal.divide(new BigDecimal(100), 2, RoundingMode.DOWN);
|
|
|
@@ -140,14 +140,14 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
return R.fail("金额不能小于0.1元");
|
|
|
}
|
|
|
StoreAliPayLog pay = new StoreAliPayLog();
|
|
|
- if(StringUtils.isNotBlank(storeUser.getAlipayAccount())){
|
|
|
+ if (StringUtils.isNotBlank(storeUser.getAlipayAccount())) {
|
|
|
pay = aliApi.pay(storeUser.getName(), storeUser.getIdCard(), storeUser.getAlipayAccount(), divide.toString());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
pay = aliApi.payAccount(storeUser.getName(), storeUser.getIdCard(), null, divide.toString(), storeUser.getPhone());
|
|
|
}
|
|
|
//增加提现记录
|
|
|
StoreCashOutRecord storeCashOutRecord = new StoreCashOutRecord();
|
|
|
- if(pay.getStoreAliPayErrorLog() == null){
|
|
|
+ if (pay.getStoreAliPayErrorLog() == null) {
|
|
|
storeCashOutRecord.setStoreId(storeId);
|
|
|
storeCashOutRecord.setOrderNo(pay.getOutBizNo());
|
|
|
storeCashOutRecord.setMoney(withdrawalMoney);
|
|
|
@@ -165,7 +165,7 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
//减少账户余额
|
|
|
storeUserMapper.updateById(new StoreUser(storeUser.getId(), storeUser.getMoney() - withdrawalMoney));
|
|
|
return R.data(storeCashOutRecord);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
// 提现失败
|
|
|
storeCashOutRecord.setStoreId(storeId);
|
|
|
storeCashOutRecord.setPaymentStatus(2);
|
|
|
@@ -187,7 +187,7 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
/**
|
|
|
* 提现申请-提现全部-手续费一单一算
|
|
|
*
|
|
|
- * @param storeId 门店id
|
|
|
+ * @param storeId 门店id
|
|
|
* @return 是否成功
|
|
|
*/
|
|
|
@Transactional
|
|
|
@@ -198,10 +198,10 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
int freeze = 0;
|
|
|
//查询冻结配置
|
|
|
SystemConfigVo systemConfigVo = storeDictService.getConfig("freeze");
|
|
|
- if(systemConfigVo != null){
|
|
|
+ if (systemConfigVo != null) {
|
|
|
String freezeFlag = systemConfigVo.getConfigValue1();
|
|
|
- String freezeDay = systemConfigVo.getConfigValue2();
|
|
|
- if(StringUtils.isNotBlank(freezeFlag) && freezeFlag.equals("1") && StringUtils.isNotBlank(freezeDay)){
|
|
|
+ String freezeDay = systemConfigVo.getConfigValue2();
|
|
|
+ if (StringUtils.isNotBlank(freezeFlag) && freezeFlag.equals("1") && StringUtils.isNotBlank(freezeDay)) {
|
|
|
freeze = Integer.parseInt(freezeDay);
|
|
|
}
|
|
|
}
|
|
|
@@ -209,7 +209,7 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
//查询可用账单
|
|
|
LambdaQueryWrapper<StoreIncomeDetailsRecord> wrapper = new LambdaQueryWrapper<>();
|
|
|
//当前时间-3天大于创建时间
|
|
|
- if(freeze > 0){
|
|
|
+ if (freeze > 0) {
|
|
|
wrapper.lt(StoreIncomeDetailsRecord::getCreatedTime, DateUtils.calcDays(new Date(), -freeze));
|
|
|
}
|
|
|
//未绑定提现记录的
|
|
|
@@ -256,7 +256,7 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
public String approveCashOut(Integer cashOutId, String approveStatus, String failReason) {
|
|
|
if (cashOutId != null && cashOutId > 0 && StringUtils.isNotBlank(approveStatus)) {
|
|
|
StoreCashOutRecord storeCashOutRecord = storeCashOutRecordMapper.selectById(cashOutId);
|
|
|
- if(!(storeCashOutRecord.getPaymentStatus() == 3)){
|
|
|
+ if (!(storeCashOutRecord.getPaymentStatus() == 3)) {
|
|
|
return "付款状态异常";
|
|
|
}
|
|
|
Integer storeUserId = storeCashOutRecord.getStoreUserId();
|
|
|
@@ -264,11 +264,11 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
|
|
|
if (approveStatus.equals("0")) {
|
|
|
//同意提现通知
|
|
|
- cashOutSendNotice(storeCashOutRecord, storeUser, failReason,"1");
|
|
|
+ cashOutSendNotice(storeCashOutRecord, storeUser, failReason, "1");
|
|
|
|
|
|
//同意,开始提现
|
|
|
int money = storeCashOutRecord.getMoney();
|
|
|
- if(money > storeUser.getMoney()) {
|
|
|
+ if (money > storeUser.getMoney()) {
|
|
|
money = storeUser.getMoney();
|
|
|
}
|
|
|
BigDecimal decimal = new BigDecimal(money);
|
|
|
@@ -286,12 +286,12 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
storeCashOutRecord.setPayDate(new Date());//支付时间
|
|
|
storeCashOutRecord.setPaymentDate(new Date());//支付到账时间
|
|
|
Integer commission = storeCashOutRecord.getCommission();
|
|
|
- if(storeCashOutRecord.getCommission() == null ) {
|
|
|
+ if (storeCashOutRecord.getCommission() == null) {
|
|
|
commission = 0;
|
|
|
}
|
|
|
storeCashOutRecordMapper.updateById(storeCashOutRecord);
|
|
|
- int deductMoney = storeCashOutRecord.getMoney() - commission;
|
|
|
- if(storeUser.getMoney() < deductMoney) {
|
|
|
+ int deductMoney = storeCashOutRecord.getMoney() - commission;
|
|
|
+ if (storeUser.getMoney() < deductMoney) {
|
|
|
storeUserMapper.updateById(new StoreUser(storeUserId, 0));
|
|
|
} else {
|
|
|
storeUserMapper.updateById(new StoreUser(storeUserId, storeUser.getMoney() - storeCashOutRecord.getMoney() - commission));
|
|
|
@@ -320,7 +320,7 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
lambdaUpdateWrapper.eq(StoreIncomeDetailsRecord::getStoreId, storeCashOutRecord.getStoreId())
|
|
|
.eq(StoreIncomeDetailsRecord::getCashOutId, storeCashOutRecord.getId())
|
|
|
.set(StoreIncomeDetailsRecord::getCashOutId, "");
|
|
|
- int result = storeIncomeDetailsRecordMapper.updateByCashOutId(storeCashOutRecord.getStoreId(), storeCashOutRecord.getId());
|
|
|
+ int result = storeIncomeDetailsRecordMapper.updateByCashOutId(storeCashOutRecord.getStoreId(), storeCashOutRecord.getId());
|
|
|
|
|
|
//驳回提现申请通知
|
|
|
cashOutSendNotice(storeCashOutRecord, storeUser, failReason, "2");
|
|
|
@@ -341,16 +341,16 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject();
|
|
|
String text = "";
|
|
|
if (noticeType.equals("1")) {
|
|
|
- text = "您在"+commonDate+"申请提现"+moneyStr+"元,已审核成功,提现中,请耐心等待。";
|
|
|
+ text = "您在" + commonDate + "申请提现" + moneyStr + "元,已审核成功,提现中,请耐心等待。";
|
|
|
lifeMessage.setTitle("提现审核");
|
|
|
- } else if(noticeType.equals("2")) {
|
|
|
- text = "您在"+commonDate+"申请提现"+moneyStr+"元,审核失败。失败原因:"+failReason;
|
|
|
+ } else if (noticeType.equals("2")) {
|
|
|
+ text = "您在" + commonDate + "申请提现" + moneyStr + "元,审核失败。失败原因:" + failReason;
|
|
|
lifeMessage.setTitle("提现审核");
|
|
|
- } else if(noticeType.equals("3")){
|
|
|
- text = "您在"+commonDate+"申请提现"+moneyStr+"元,已成功到达您的支付宝账号,请注意查收。";
|
|
|
+ } else if (noticeType.equals("3")) {
|
|
|
+ text = "您在" + commonDate + "申请提现" + moneyStr + "元,已成功到达您的支付宝账号,请注意查收。";
|
|
|
lifeMessage.setTitle("提现到账");
|
|
|
- } else{
|
|
|
- text = "您在"+commonDate+"申请提现"+moneyStr+"元,到账失败,请重新申请或联系客服。";
|
|
|
+ } else {
|
|
|
+ text = "您在" + commonDate + "申请提现" + moneyStr + "元,到账失败,请重新申请或联系客服。";
|
|
|
lifeMessage.setTitle("提现到账");
|
|
|
}
|
|
|
jsonObject.put("message", text);
|
|
|
@@ -422,8 +422,8 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
Date endDate = DateUtils.calcDays(now, -4);
|
|
|
jsonObject.put("date", df.format(startDate) + " ~ " + df.format(endDate));
|
|
|
}
|
|
|
- if(storeId!=null){
|
|
|
- wrapper.eq("sidr.store_id",storeId);
|
|
|
+ if (storeId != null) {
|
|
|
+ wrapper.eq("sidr.store_id", storeId);
|
|
|
}
|
|
|
//未绑定提现记录的
|
|
|
LocalDate startDate = LocalDate.parse(startTime);
|
|
|
@@ -431,24 +431,25 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
// 创建当天的开始和结束时间点
|
|
|
LocalDateTime startOfDay = startDate.atStartOfDay();
|
|
|
LocalDateTime endOfDay = endDate.atTime(LocalTime.MAX);
|
|
|
- wrapper.between("sidr.created_time",startOfDay,endOfDay)
|
|
|
+ wrapper.between("sidr.created_time", startOfDay, endOfDay)
|
|
|
.orderByDesc("sidr.created_time");
|
|
|
- if(null != incomeType) {
|
|
|
+ if (null != incomeType) {
|
|
|
if (0 == incomeType) {
|
|
|
- wrapper.in("sidr.income_type", CouponTypeEnum.COUPON.getCode(),CouponTypeEnum.GROUP_BUY.getCode());
|
|
|
+ wrapper.in("sidr.income_type", CouponTypeEnum.COUPON.getCode(), CouponTypeEnum.GROUP_BUY.getCode());
|
|
|
} else {
|
|
|
wrapper.eq("sidr.income_type", incomeType);
|
|
|
}
|
|
|
}
|
|
|
// 计算总钱数
|
|
|
List<StoreIncomeDetailsRecordVo> list = storeIncomeDetailsRecordMapper.selectRecordList(wrapper);
|
|
|
-
|
|
|
+ StoreInfo storeInfo = storeInfoMapper.selectById(storeId);
|
|
|
for (StoreIncomeDetailsRecordVo storeIncomeDetailsRecord : list) {
|
|
|
StoreIncomeDetailsRecordVo vo = new StoreIncomeDetailsRecordVo();
|
|
|
BeanUtils.copyProperties(storeIncomeDetailsRecord, vo);
|
|
|
storeIncomeDetailsRecord.setMoneyStr(new BigDecimal(vo.getMoney()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP).toString());
|
|
|
String format = df.format(storeIncomeDetailsRecord.getCreatedTime());
|
|
|
storeIncomeDetailsRecord.setDate(format);
|
|
|
+ vo.setCommissionRate(storeInfo.getCommissionRate());
|
|
|
}
|
|
|
jsonObject.put("data", ListToPage.setPage(list, page, size));
|
|
|
jsonObject.put("money", new BigDecimal(list.stream().mapToInt(StoreIncomeDetailsRecord::getMoney).sum()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP).toString());
|
|
|
@@ -479,7 +480,7 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
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());
|
|
|
@@ -502,8 +503,8 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
//未绑定提现记录的
|
|
|
.isNull(StoreIncomeDetailsRecord::getCashOutId)
|
|
|
.eq(StoreIncomeDetailsRecord::getStoreId, storeId);
|
|
|
- if(null != incomeType && 0 == incomeType){
|
|
|
- wrapper.in(StoreIncomeDetailsRecord::getIncomeType, CouponTypeEnum.COUPON.getCode(),CouponTypeEnum.GROUP_BUY.getCode());
|
|
|
+ if (null != incomeType && 0 == incomeType) {
|
|
|
+ wrapper.in(StoreIncomeDetailsRecord::getIncomeType, CouponTypeEnum.COUPON.getCode(), CouponTypeEnum.GROUP_BUY.getCode());
|
|
|
} else {
|
|
|
wrapper.eq(StoreIncomeDetailsRecord::getIncomeType, incomeType);
|
|
|
}
|
|
|
@@ -518,6 +519,7 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
commission += storeIncomeDetailsRecord.getCommission();
|
|
|
}
|
|
|
StoreIncomeDetailsRecordVo vo = new StoreIncomeDetailsRecordVo();
|
|
|
+ vo.setCommissionRate(storeInfo.getCommissionRate());
|
|
|
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(list));
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
jsonArray.forEach(item -> {
|
|
|
@@ -547,9 +549,9 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
.eq("income.store_id", storeId)
|
|
|
.between("income.created_time", date + " 00:00:00", date + " 23:59:59")
|
|
|
.orderByDesc("income.created_time");
|
|
|
- if(null != incomeType) {
|
|
|
+ if (null != incomeType) {
|
|
|
if (0 == incomeType) {
|
|
|
- incomeWrapper.in("income_type", CouponTypeEnum.COUPON.getCode(),CouponTypeEnum.GROUP_BUY.getCode());
|
|
|
+ incomeWrapper.in("income_type", CouponTypeEnum.COUPON.getCode(), CouponTypeEnum.GROUP_BUY.getCode());
|
|
|
} else {
|
|
|
incomeWrapper.eq("income_type", incomeType);
|
|
|
}
|
|
|
@@ -560,16 +562,16 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
vo.setIncomeDetailsRecordVoList(new ArrayList<>());
|
|
|
vo.setRefundMoney(new BigDecimal(0));
|
|
|
vo.setCouponCount(0);
|
|
|
- if ( collect.containsKey("false")){
|
|
|
- vo.setIncomeDetailsRecordVoList(ListToPage.setPage(incomeDetailsRecordVoList,page,size).getRecords());
|
|
|
+ if (collect.containsKey("false")) {
|
|
|
+ vo.setIncomeDetailsRecordVoList(ListToPage.setPage(incomeDetailsRecordVoList, page, size).getRecords());
|
|
|
// ListToPage.setPage(
|
|
|
// collect.get("false")
|
|
|
// .stream()
|
|
|
// .sorted(Comparator.comparing(StoreIncomeDetailsRecordVo::getCheckTime)
|
|
|
// .reversed()).collect(Collectors.toList()), page, size).getRecords());
|
|
|
- vo.setCouponCount( collect.get("false").size() - (collect.containsKey("true") ? collect.get("true").size() : 0));
|
|
|
+ vo.setCouponCount(collect.get("false").size() - (collect.containsKey("true") ? collect.get("true").size() : 0));
|
|
|
}
|
|
|
- if( collect.containsKey("true") ){
|
|
|
+ if (collect.containsKey("true")) {
|
|
|
vo.setRefundMoney(new BigDecimal(collect.get("true").stream().mapToInt(StoreIncomeDetailsRecordVo::getMoney).sum()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP));
|
|
|
}
|
|
|
return vo;
|
|
|
@@ -580,7 +582,7 @@ public class StoreIncomeDetailsRecordServiceImpl extends ServiceImpl<StoreIncome
|
|
|
LambdaQueryWrapper<LifeUserOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
LocalDate now = LocalDate.now();
|
|
|
wrapper.eq(LifeUserOrder::getStoreId, storeId)
|
|
|
- .notIn(LifeUserOrder::getStatus, OrderStatusEnum.CANCEL.getStatus(), OrderStatusEnum.WAIT_PAY.getStatus(),OrderStatusEnum.EXPIRE.getStatus())
|
|
|
+ .notIn(LifeUserOrder::getStatus, OrderStatusEnum.CANCEL.getStatus(), OrderStatusEnum.WAIT_PAY.getStatus(), OrderStatusEnum.EXPIRE.getStatus())
|
|
|
.between(LifeUserOrder::getBuyTime, now + " 00:00:00", now + " 23:59:59");
|
|
|
return lifeUserOrderMapper.selectCount(wrapper);
|
|
|
}
|