From 8e9440ea0a09fc6d9cea1c205904c51ccbf62a2a Mon Sep 17 00:00:00 2001 From: liujie <liujie> Date: 星期一, 24 七月 2023 15:07:53 +0800 Subject: [PATCH] 超省2.0 --- driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 221 insertions(+), 0 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 acdb51d..c33aa86 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 @@ -1,12 +1,26 @@ package com.supersavedriving.driver.modular.system.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +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.util.UUIDUtil; +import com.supersavedriving.driver.modular.system.warpper.BalanceDetailWarpper; +import com.supersavedriving.driver.modular.system.warpper.CommissionDetailListWarpper; +import com.supersavedriving.driver.modular.system.warpper.CommissionDetailWarpper; +import com.supersavedriving.driver.modular.system.warpper.IntegralIncomeAndExpensesWarpper; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; +import java.util.List; /** * 账户变动 @@ -15,6 +29,15 @@ */ @Service public class AccountChangeDetailServiceImpl extends ServiceImpl<AccountChangeDetailMapper, AccountChangeDetail> implements IAccountChangeDetailService { + + @Autowired + private IDriverService driverService; + + @Autowired + private ISystemConfigService systemConfigService; + + + /** @@ -27,4 +50,202 @@ accountChangeDetail.setCreateTime(new Date()); this.baseMapper.insert(accountChangeDetail); } + + + /** + * 获取积分收支明细 + * @param driverId + * @param type + * @param pageNum + * @param pageSize + * @return + * @throws Exception + */ + @Override + public List<IntegralIncomeAndExpensesWarpper> queryDriverIntegralIncomeAndExpenses(Integer driverId, Integer type, Integer pageNum, Integer pageSize) throws Exception { + pageNum = (pageNum - 1) * pageSize; + return this.baseMapper.queryDriverIntegralIncomeAndExpenses(driverId, type, pageNum, pageSize); + } + + + /** + * 获取佣金明细列表 + * @param driverId + * @param time + * @param pageNum + * @param pageSize + * @return + * @throws Exception + */ + @Override + public CommissionDetailListWarpper queryCommissionDetail(Integer driverId, String time, Integer pageNum, Integer pageSize) throws Exception { + pageNum = (pageNum - 1) * pageSize; + List<CommissionDetailWarpper> commissionDetailWarppers = this.baseMapper.queryCommissionDetail(driverId, time, pageNum, pageSize); + Double aDouble = this.baseMapper.queryCommissionDetailTotal(driverId, time); + CommissionDetailListWarpper commissionDetailListWarpper = new CommissionDetailListWarpper(); + commissionDetailListWarpper.setList(commissionDetailWarppers); + commissionDetailListWarpper.setTotal(aDouble); + return commissionDetailListWarpper; + } + + /** + * 获取账户余额明细 + * @param driverId + * @param time + * @param type + * @param pageNum + * @param pageSize + * @return + * @throws Exception + */ + @Override + public List<BalanceDetailWarpper> queryBalanceDetail(Integer driverId, String time, Integer type, Integer pageNum, Integer pageSize) throws Exception { + pageNum = (pageNum - 1) * pageSize; + List<BalanceDetailWarpper> balanceDetailWarppers = this.baseMapper.queryBalanceDetail(driverId, time, type, pageNum, pageSize); + return balanceDetailWarppers; + } + + + /** + * 处理司机保险 + */ + @Override + public void deductionInsurance() { + 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; + } + + 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); + } + 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); + 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); + } + } } -- Gitblit v1.7.1