From 17f18c3d56a70327874aa7dda0adfa2f5e3dafce Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期三, 14 六月 2023 20:57:38 +0800 Subject: [PATCH] 代理商修改优惠券展示 --- driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java | 112 ++++++++++++++++++------------------------------------- 1 files changed, 37 insertions(+), 75 deletions(-) diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java index ad5147d..c6679c0 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java @@ -7,10 +7,10 @@ import com.supersavedriving.driver.modular.system.dao.AccountChangeDetailMapper; import com.supersavedriving.driver.modular.system.model.AccountChangeDetail; import com.supersavedriving.driver.modular.system.model.Driver; +import com.supersavedriving.driver.modular.system.model.RechargeRecord; import com.supersavedriving.driver.modular.system.model.SystemConfig; -import com.supersavedriving.driver.modular.system.service.IAccountChangeDetailService; -import com.supersavedriving.driver.modular.system.service.IDriverService; -import com.supersavedriving.driver.modular.system.service.ISystemConfigService; +import com.supersavedriving.driver.modular.system.service.*; +import com.supersavedriving.driver.modular.system.util.ResultUtil; import com.supersavedriving.driver.modular.system.util.UUIDUtil; import com.supersavedriving.driver.modular.system.warpper.BalanceDetailWarpper; import com.supersavedriving.driver.modular.system.warpper.CommissionDetailListWarpper; @@ -35,6 +35,12 @@ @Autowired private ISystemConfigService systemConfigService; + + @Autowired + private IRechargeRecordService rechargeRecordService; + + @Autowired + private IOrderService orderService; @@ -119,11 +125,9 @@ Double num1 = jsonObject.getDouble("num1"); List<Driver> drivers = driverService.selectList(new EntityWrapper<Driver>().eq("approvalStatus", 2).eq("status", 1)); for (Driver driver : drivers) { - Double couponBalance = driver.getCouponBalance(); Double backgroundBalance = driver.getBackgroundBalance(); Double balance = driver.getBalance(); - Double commission = driver.getCommission(); - double all = couponBalance + backgroundBalance + balance + commission; + double all = backgroundBalance + balance; if(num1 > all){ continue; } @@ -151,78 +155,13 @@ accountChangeDetail.setUserId(driver.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(8); - accountChangeDetail.setOldData(driver.getBackgroundBalance()); + accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); driver.setBackgroundBalance(driver.getBackgroundBalance() - d); - accountChangeDetail.setNewData(driver.getBackgroundBalance()); + accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); accountChangeDetail.setExplain("收取保险费"); accountChangeDetail.setCreateTime(new Date()); this.insert(accountChangeDetail); d = 0; - } - - if(d > 0){ - if(couponBalance > 0 && couponBalance < d){ - AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); - accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); - accountChangeDetail.setUserType(2); - accountChangeDetail.setUserId(driver.getId()); - accountChangeDetail.setType(1); - accountChangeDetail.setChangeType(8); - accountChangeDetail.setOldData(driver.getCouponBalance()); - accountChangeDetail.setNewData(0D); - accountChangeDetail.setExplain("收取保险费"); - accountChangeDetail.setCreateTime(new Date()); - this.insert(accountChangeDetail); - d -= couponBalance; - driver.setCouponBalance(0D); - } - if(couponBalance > 0 && couponBalance >= d){ - AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); - accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); - accountChangeDetail.setUserType(2); - accountChangeDetail.setUserId(driver.getId()); - accountChangeDetail.setType(1); - accountChangeDetail.setChangeType(8); - accountChangeDetail.setOldData(driver.getCouponBalance()); - driver.setCouponBalance(driver.getCouponBalance() - d); - accountChangeDetail.setNewData(driver.getCouponBalance()); - accountChangeDetail.setExplain("收取保险费"); - accountChangeDetail.setCreateTime(new Date()); - this.insert(accountChangeDetail); - d = 0; - } - } - if(d > 0){ - if(commission > 0 && commission < d){ - AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); - accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); - accountChangeDetail.setUserType(2); - accountChangeDetail.setUserId(driver.getId()); - accountChangeDetail.setType(1); - accountChangeDetail.setChangeType(8); - accountChangeDetail.setOldData(driver.getCommission()); - accountChangeDetail.setNewData(0D); - accountChangeDetail.setExplain("收取保险费"); - accountChangeDetail.setCreateTime(new Date()); - this.insert(accountChangeDetail); - d -= commission; - driver.setCommission(0D); - } - if(commission > 0 && commission >= d){ - AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); - accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); - accountChangeDetail.setUserType(2); - accountChangeDetail.setUserId(driver.getId()); - accountChangeDetail.setType(1); - accountChangeDetail.setChangeType(8); - accountChangeDetail.setOldData(driver.getCommission()); - driver.setCommission(driver.getCommission() - d); - accountChangeDetail.setNewData(driver.getCommission()); - accountChangeDetail.setExplain("收取保险费"); - accountChangeDetail.setCreateTime(new Date()); - this.insert(accountChangeDetail); - d = 0; - } } if(d > 0){ if(balance > 0 && balance < d){ @@ -235,13 +174,36 @@ accountChangeDetail.setUserId(driver.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(8); - accountChangeDetail.setOldData(driver.getBalance()); + accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); driver.setBalance(driver.getBalance() - d); - accountChangeDetail.setNewData(driver.getBalance()); + accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); accountChangeDetail.setExplain("收取保险费"); accountChangeDetail.setCreateTime(new Date()); this.insert(accountChangeDetail); d = 0; + + List<RechargeRecord> rechargeRecords = rechargeRecordService.selectList(new EntityWrapper<RechargeRecord>().eq("type", 2).eq("userId", driver.getId()).eq("payStatus", 2).gt("surplusDividedAmount", 0).orderBy("createTime")); + for (RechargeRecord rechargeRecord : rechargeRecords) { + Double surplusDividedAmount = rechargeRecord.getSurplusDividedAmount(); + if(surplusDividedAmount.compareTo(d) >= 0){ + ResultUtil fengzhang = orderService.fengzhang(3, null, "553021440975", rechargeRecord.getId().longValue(), rechargeRecord.getOrderNumber(), d, 1); + if(fengzhang.getCode() == 10000){ + rechargeRecord.setSurplusDividedAmount(rechargeRecord.getSurplusDividedAmount() - d); + rechargeRecordService.updateById(rechargeRecord); + } + break; + }else{ + ResultUtil fengzhang = orderService.fengzhang(3, null, "553021440975", rechargeRecord.getId().longValue(), rechargeRecord.getOrderNumber(), surplusDividedAmount, 1); + if(fengzhang.getCode() == 10000){ + rechargeRecord.setSurplusDividedAmount(0d); + rechargeRecordService.updateById(rechargeRecord); + d -= surplusDividedAmount; + }else{ + break; + } + } + } + } } -- Gitblit v1.7.1