From 0a6f905b50a88993da05b9b3114394fb91dbc7d0 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期三, 31 五月 2023 19:05:56 +0800 Subject: [PATCH] 修改bug --- driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java | 188 +++++++++++++++------------------------------- 1 files changed, 62 insertions(+), 126 deletions(-) diff --git a/driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java b/driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java index 643520f..731fedb 100644 --- a/driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java +++ b/driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java @@ -2,6 +2,7 @@ import com.agentdriving.driver.modular.system.dao.AccountChangeDetailMapper; import com.agentdriving.driver.modular.system.model.AccountChangeDetail; +import com.agentdriving.driver.modular.system.model.Order; import com.agentdriving.driver.modular.system.util.UUIDUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; @@ -110,142 +111,77 @@ * 处理司机保险 */ @Override - public void deductionInsurance() { + public void deductionInsurance(Integer driverId) { SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 3)); if(null == systemConfig){ return; } JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); 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; - if(num1 > all){ - continue; - } + Driver driver = driverService.selectById(driverId); + Double couponBalance = driver.getCouponBalance(); + Double backgroundBalance = driver.getBackgroundBalance(); + Double balance = driver.getBalance(); + Double commission = driver.getCommission(); + double all = couponBalance + backgroundBalance + balance + commission; + if(num1.compareTo(all) > 0){ + return; + } - double d = num1.doubleValue(); - if(backgroundBalance > 0 && backgroundBalance < 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.getBackgroundBalance()); - accountChangeDetail.setNewData(0D); - accountChangeDetail.setExplain("收取保险费"); - accountChangeDetail.setCreateTime(new Date()); - this.insert(accountChangeDetail); - d -= backgroundBalance; - driver.setBackgroundBalance(0D); + double d = num1.doubleValue(); + Double old = driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission(); + if(backgroundBalance > 0 && backgroundBalance < d){ + d -= backgroundBalance; + driver.setBackgroundBalance(0D); + } + if(backgroundBalance > 0 && backgroundBalance >= d){ + driver.setBackgroundBalance(driver.getBackgroundBalance() - d); + d = 0; + } + + if(d > 0){ + if(couponBalance > 0 && couponBalance < d){ + d -= couponBalance; + driver.setCouponBalance(0D); } - if(backgroundBalance > 0 && backgroundBalance >= 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.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); - driver.setBackgroundBalance(driver.getBackgroundBalance() - d); - accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); - accountChangeDetail.setExplain("收取保险费"); - accountChangeDetail.setCreateTime(new Date()); - this.insert(accountChangeDetail); + if(couponBalance > 0 && couponBalance >= d){ + driver.setCouponBalance(driver.getCouponBalance() - d); 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.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); - driver.setCouponBalance(driver.getCouponBalance() - d); - 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(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.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); - driver.setCommission(driver.getCommission() - d); - 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(balance > 0 && balance < d){ - continue; - } - if(balance > 0 && balance >= 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.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); - driver.setBalance(driver.getBalance() - d); - accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); - accountChangeDetail.setExplain("收取保险费"); - accountChangeDetail.setCreateTime(new Date()); - this.insert(accountChangeDetail); - d = 0; - } - } - - driverService.updateById(driver); } + if(d > 0){ + if(commission > 0 && commission < d){ + d -= commission; + driver.setCommission(0D); + } + if(commission > 0 && commission >= d){ + driver.setCommission(driver.getCommission() - d); + d = 0; + } + } + if(d > 0){ + if(balance > 0 && balance < d){ + d -= commission; + driver.setBalance(0D); + return; + } + if(balance > 0 && balance >= d){ + driver.setBalance(driver.getBalance() - d); + d = 0; + } + } + + 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(old); + accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); + accountChangeDetail.setExplain("收取保险费"); + accountChangeDetail.setCreateTime(new Date()); + this.insert(accountChangeDetail); + driverService.updateById(driver); } } -- Gitblit v1.7.1