From cf0ff0a221e1afdafc2b926c6faa3fbfd965632b Mon Sep 17 00:00:00 2001
From: liujie <liujie>
Date: 星期三, 16 八月 2023 19:17:31 +0800
Subject: [PATCH] update
---
driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java | 188 ++++++++++++++++++++---------------------------
1 files changed, 80 insertions(+), 108 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 0b1b322..8f82811 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
@@ -5,12 +5,9 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
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.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.model.*;
+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;
@@ -19,6 +16,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
@@ -35,6 +34,18 @@
@Autowired
private ISystemConfigService systemConfigService;
+
+ @Autowired
+ private IRechargeRecordService rechargeRecordService;
+
+ @Autowired
+ private IOrderService orderService;
+
+ @Autowired
+ private IRevenueService revenueService;
+
+ @Autowired
+ private ICompanyFundFlowService companyFundFlowService;
@@ -119,129 +130,90 @@
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 balance1 = revenueService.queryCompanyBalance();
Double backgroundBalance = driver.getBackgroundBalance();
Double balance = driver.getBalance();
- Double commission = driver.getCommission();
- double all = couponBalance + backgroundBalance + balance + commission;
- if(num1 > all){
+ double all = backgroundBalance + balance;
+ if(num1.compareTo(all) > 0){
continue;
}
double d = num1.doubleValue();
- if(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);
+ if(backgroundBalance > 0 && backgroundBalance < d){
d -= backgroundBalance;
driver.setBackgroundBalance(0D);
- }else{
+ }else if(backgroundBalance >= d){
AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
- accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
+ accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5));
accountChangeDetail.setUserType(2);
accountChangeDetail.setUserId(driver.getId());
accountChangeDetail.setType(1);
accountChangeDetail.setChangeType(8);
- accountChangeDetail.setOldData(driver.getBackgroundBalance());
- d = 0;
+ accountChangeDetail.setOldData(new BigDecimal(driver.getBalance()).add(new BigDecimal(driver.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
driver.setBackgroundBalance(driver.getBackgroundBalance() - d);
- accountChangeDetail.setNewData(driver.getBackgroundBalance());
+ accountChangeDetail.setNewData(new BigDecimal(driver.getBalance()).add(new BigDecimal(driver.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
accountChangeDetail.setExplain("收取保险费");
accountChangeDetail.setCreateTime(new Date());
this.insert(accountChangeDetail);
+ d = 0;
}
+ if(d > 0){
+ if(balance > 0 && balance >= d){
+ AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+ accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5));
+ accountChangeDetail.setUserType(2);
+ accountChangeDetail.setUserId(driver.getId());
+ accountChangeDetail.setType(1);
+ accountChangeDetail.setChangeType(8);
+ accountChangeDetail.setOldData(new BigDecimal(driver.getBalance()).add(new BigDecimal(driver.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
+ driver.setBalance(new BigDecimal(driver.getBalance()).subtract(new BigDecimal(d)).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
+ accountChangeDetail.setNewData(new BigDecimal(driver.getBalance()).add(new BigDecimal(driver.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
+ accountChangeDetail.setExplain("收取保险费");
+ accountChangeDetail.setCreateTime(new Date());
+ this.insert(accountChangeDetail);
- if(d > 0){
- if(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);
- }else{
- 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());
- d = 0;
- driver.setCouponBalance(driver.getCouponBalance() - d);
- accountChangeDetail.setNewData(driver.getCouponBalance());
- accountChangeDetail.setExplain("收取保险费");
- accountChangeDetail.setCreateTime(new Date());
- this.insert(accountChangeDetail);
- }
- }
- if(d > 0){
- if(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);
- }else{
- 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());
- d = 0;
- driver.setCommission(driver.getCommission() - d);
- accountChangeDetail.setNewData(driver.getCommission());
- accountChangeDetail.setExplain("收取保险费");
- accountChangeDetail.setCreateTime(new Date());
- this.insert(accountChangeDetail);
- }
- }
- if(d > 0){
- if(balance < d){
- continue;
- }else{
- 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());
- d = 0;
- driver.setBalance(driver.getBalance() - d);
- accountChangeDetail.setNewData(driver.getBalance());
- accountChangeDetail.setExplain("收取保险费");
- accountChangeDetail.setCreateTime(new Date());
- this.insert(accountChangeDetail);
- }
- }
+ Revenue revenue = new Revenue();
+ revenue.setType(3);
+ revenue.setUserType(4);
+ revenue.setAmount(d);
+ revenue.setCreateTime(new Date());
+ revenueService.insert(revenue);
+ List<RechargeRecord> rechargeRecords = rechargeRecordService.selectList(new EntityWrapper<RechargeRecord>().eq("type", 2).eq("userId", driver.getId()).eq("payStatus", 2).gt("surplusDividedAmount", 0).orderBy("createTime"));
+ // TODO 测试屏蔽
+// for (RechargeRecord rechargeRecord : rechargeRecords) {
+// Double surplusDividedAmount = rechargeRecord.getSurplusDividedAmount();
+// if(surplusDividedAmount.compareTo(d) >= 0){
+// ResultUtil fengzhang = orderService.fengzhang(3, null, "553021440975", null, rechargeRecord.getId(), rechargeRecord.getOrderNumber(), d, 1);
+// if(fengzhang.getCode() == 10000){
+// rechargeRecord.setSurplusDividedAmount(new BigDecimal(rechargeRecord.getSurplusDividedAmount()).subtract(new BigDecimal(d)).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
+// rechargeRecordService.updateById(rechargeRecord);
+// }
+// break;
+// }else{
+// ResultUtil fengzhang = orderService.fengzhang(3, null, "553021440975", null, rechargeRecord.getId(), rechargeRecord.getOrderNumber(), surplusDividedAmount, 1);
+// if(fengzhang.getCode() == 10000){
+// rechargeRecord.setSurplusDividedAmount(0d);
+// rechargeRecordService.updateById(rechargeRecord);
+// d = new BigDecimal(d).subtract(new BigDecimal(surplusDividedAmount)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
+// }else{
+// break;
+// }
+// }
+// }
+
+ }
+ }
driverService.updateById(driver);
+
+ CompanyFundFlow companyFundFlow = new CompanyFundFlow();
+ companyFundFlow.setType(4);
+ companyFundFlow.setObjectType(1);
+ companyFundFlow.setDriverId(driver.getId());
+ companyFundFlow.setBalance(new BigDecimal(balance1));
+ companyFundFlow.setMoney(new BigDecimal(num1));
+ companyFundFlow.setCreateTime(new Date());
+ companyFundFlowService.insert(companyFundFlow);
}
}
}
--
Gitblit v1.7.1