| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669 |
- package com.ydtech.modules.admin.service.impl;
- import cn.hutool.extra.spring.SpringUtil;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.ydtech.core.page.HttpResult;
- import com.ydtech.exception.SystemException;
- import com.ydtech.modules.admin.constants.ManagementSource;
- import com.ydtech.modules.admin.constants.MoneyAttrConstants;
- import com.ydtech.modules.admin.constants.WithdrawTypeConstants;
- import com.ydtech.modules.admin.dao.SysUserAccountMapper;
- import com.ydtech.modules.admin.dao.SysUserBankCardMapper;
- import com.ydtech.modules.admin.dao.SysUserMapper;
- import com.ydtech.modules.admin.model.SysDept;
- import com.ydtech.modules.admin.model.SysUser;
- import com.ydtech.modules.admin.model.dto.*;
- import com.ydtech.modules.admin.model.po.*;
- import com.ydtech.modules.admin.model.vo.MyIncomeAndExpensesNewPageVo;
- import com.ydtech.modules.admin.model.vo.SubOrder;
- import com.ydtech.modules.admin.model.vo.SysUserAccountVo;
- import com.ydtech.modules.admin.model.vo.SysUserBaseVO;
- import com.ydtech.modules.admin.service.*;
- import com.ydtech.modules.admin.utils.SliceUpDateUtil;
- import com.ydtech.modules.base.controller.BaseController;
- import com.ydtech.modules.fee.service.FeeDisplayService;
- import com.ydtech.modules.message.constants.MessageTypeConstants;
- import com.ydtech.modules.message.service.MessageSecretaryService;
- import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
- import com.ydtech.modules.order.entity.BasePageResult;
- import com.ydtech.modules.order.entity.InsOrders;
- import com.ydtech.modules.order.service.InsAreaCompanyService;
- import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
- import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
- import com.ydtech.modules.ttqf.entity.vo.UserWithdrawal;
- import com.ydtech.modules.ttqf.service.TtqfService;
- import org.apache.commons.lang3.ObjectUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.util.CollectionUtils;
- import java.math.BigDecimal;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * @author Administrator
- * @description 针对表【sys_user_account(用户账户表)】的数据库操作Service实现
- * @createDate 2024-03-05 11:52:30
- */
- @Service
- public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper, SysUserAccount> implements SysUserAccountService {
- @Autowired
- private SysUserAccountHistoryService sysUserAccountHistoryService;
- @Autowired
- private SysUserAccountService sysUserAccountService;
- @Autowired
- private SysAmountAuditingService sysAmountAuditingService;
- @Autowired
- private SysUserBankCardService sysUserBankCardService;
- @Autowired
- private InsAreaCompanyService insAreaCompanyService;
- @Autowired
- private InsFeeOrderNewService insFeeOrderNewService;
- @Autowired
- private MessageSecretaryService messageSecretaryService;
- @Autowired
- private InsAreaCompanyMapper insAreaCompanyMapper;
- @Autowired
- private SysUserService sysUserService;
- @Autowired
- private SysAmountAuditingHistoryService sysAmountAuditingHistoryService;
- @Autowired
- private SysUserMapper sysUserMapper;
- @Autowired
- private SysDeptService sysDeptService;
- @Autowired
- private FeeDisplayService feeDisplayService;
- @Autowired
- private SysSwitchConfigService sysSwitchConfigService;
- @Autowired
- private TtqfService ttqfService;
- @Override
- @Transactional
- public void addOrUpdate(SysUserAccount sysUserAccount) {
- //SysUserAccount newSysAccount = baseMapper.getById(sysUserAccount.getUserId());
- // 初始化
- if (sysUserAccount.getHandlingFee() == null) {
- sysUserAccount.setHandlingFee(BigDecimal.ZERO);
- }
- if (sysUserAccount.getDocumentary() == null) {
- sysUserAccount.setDocumentary(BigDecimal.ZERO);
- }
- if (sysUserAccount.getPromotion() == null) {
- sysUserAccount.setPromotion(BigDecimal.ZERO);
- }
- //添加总金额 = 手续费+跟单费+推广费
- BigDecimal sumAmount = BigDecimal.ZERO;
- sumAmount = sumAmount.add(sysUserAccount.getHandlingFee() == null ? BigDecimal.ZERO : sysUserAccount.getHandlingFee())
- .add(sysUserAccount.getDocumentary() == null ? BigDecimal.ZERO : sysUserAccount.getDocumentary())
- .add(sysUserAccount.getPromotion() == null ? BigDecimal.ZERO : sysUserAccount.getPromotion());
- // 如果用户id有值则累加 没有则 新增
- String userId = sysUserAccount.getUserId();
- SysUserAccount sysUserAccountEntity = baseMapper.getById(userId);
- //SysUserAccount newAccount = new SysUserAccount();
- if (ObjectUtils.isNotEmpty(sysUserAccountEntity)) {
- sysUserAccountEntity.setHandlingFee(sysUserAccount.getHandlingFee().add(sysUserAccountEntity.getHandlingFee()));
- sysUserAccountEntity.setDocumentary(sysUserAccount.getDocumentary().add(sysUserAccountEntity.getDocumentary()));
- sysUserAccountEntity.setPromotion(sysUserAccount.getPromotion().add(sysUserAccountEntity.getPromotion()));
- if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
- sysUserAccountEntity.setDocumentaryStatus(sysUserAccount.getDocumentaryStatus());
- }
- // add by hxl 2024-06-18 插入总金额
- sysUserAccountEntity.setSumAmount((sysUserAccountEntity.getSumAmount() == null ? BigDecimal.ZERO : sysUserAccountEntity.getSumAmount()).add(sumAmount));
- baseMapper.updateById(sysUserAccountEntity);
- } else {
- sysUserAccountEntity = new SysUserAccount();
- sysUserAccountEntity.setUserId(userId);
- sysUserAccountEntity.setDocumentary(sysUserAccount.getDocumentary());
- sysUserAccountEntity.setPromotion(sysUserAccount.getPromotion());
- sysUserAccountEntity.setHandlingFee(sysUserAccount.getHandlingFee());
- BigDecimal zero = BigDecimal.ZERO;
- sysUserAccountEntity.setHandlingAmountAccount(zero);
- sysUserAccountEntity.setHandlingAmountWithdrawal(zero);
- sysUserAccountEntity.setHandlingAmountPayment(zero);
- sysUserAccountEntity.setDocumentaryAmountAccount(zero);
- sysUserAccountEntity.setDocumentaryAmountWithdrawal(zero);
- sysUserAccountEntity.setDocumentaryAmountpayment(zero);
- sysUserAccountEntity.setPromotionAmountWithdrawal(zero);
- sysUserAccountEntity.setPromotionAmountAccount(zero);
- sysUserAccountEntity.setPromotionAmountPayment(zero);
- sysUserAccountEntity.setSumAmount(zero);
- sysUserAccountEntity.setSumAmountWithdrawal(zero);
- sysUserAccountEntity.setSumAmountAccount(zero);
- sysUserAccountEntity.setSumAmountPayment(zero);
- sysUserAccountEntity.setCreateTime(new Date());
- if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
- sysUserAccountEntity.setDocumentaryStatus(sysUserAccount.getDocumentaryStatus());
- }
- // add by hxl 2024-06-18 插入总金额
- sysUserAccountEntity.setSumAmount((sysUserAccountEntity.getSumAmount() == null ? BigDecimal.ZERO : sysUserAccountEntity.getSumAmount()).add(sumAmount));
- baseMapper.insert(sysUserAccountEntity);
- }
- StringBuilder commissionMessage = new StringBuilder();
- BigDecimal beforeAmount;
- BigDecimal afterAmount;
- if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
- //提现前的金额
- beforeAmount = sysUserAccountEntity.getSumAmount() == null ? BigDecimal.ZERO : sysUserAccountEntity.getSumAmount();
- // 判断是否是一级二级三级
- SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory();
- sysUserAccountHistory.setUserId(sysUserAccount.getUserId());
- sysUserAccountHistory.setDocumentary(Integer.valueOf(sysUserAccount.getDocumentaryStatus()));
- sysUserAccountHistory.setSuborder(sysUserAccount.getSuborderId());
- sysUserAccountHistory.setCreateTime(new Date());
- //跟单费
- if (sysUserAccount.getDocumentary() != null && sysUserAccount.getDocumentary().compareTo(BigDecimal.ZERO) != 0) {
- sysUserAccountHistory.setAmount(sysUserAccount.getDocumentary());
- sysUserAccountHistory.setProperty(MoneyAttrConstants.M_2.getCode());
- commissionMessage.append(MoneyAttrConstants.M_2.getDesc() + ":" + sysUserAccount.getDocumentary() + "元 ");
- if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
- sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getDocumentary());
- }
- sysUserAccountHistory.setBusinessSegmentsType(1);
- sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
- }
- //手续费
- if (sysUserAccount.getHandlingFee() != null && sysUserAccount.getHandlingFee().compareTo(BigDecimal.ZERO) != 0) {
- sysUserAccountHistory.setId(null);
- sysUserAccountHistory.setAmount(sysUserAccount.getHandlingFee());
- sysUserAccountHistory.setProperty(MoneyAttrConstants.M_1.getCode());
- commissionMessage.append(MoneyAttrConstants.M_1.getDesc() + ":" + sysUserAccount.getHandlingFee() + "元 ");
- if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
- sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getHandlingFee());
- }
- sysUserAccountHistory.setBusinessSegmentsType(1);
- sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
- }
- //推广费
- if (sysUserAccount.getPromotion() != null && sysUserAccount.getPromotion().compareTo(BigDecimal.ZERO) != 0) {
- sysUserAccountHistory.setId(null);
- sysUserAccountHistory.setAmount(sysUserAccount.getPromotion());
- sysUserAccountHistory.setProperty(MoneyAttrConstants.M_3.getCode());
- commissionMessage.append(MoneyAttrConstants.M_3.getDesc() + ":" + sysUserAccount.getPromotion() + "元 ");
- if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
- //提现后的金额
- afterAmount = beforeAmount.subtract(sysUserAccount.getPromotion());
- sysUserAccountHistory.setSurplusAmount(afterAmount); //改变后金额
- sysUserAccountHistory.setUserAmount(beforeAmount); //改变前金额
- }
- sysUserAccountHistory.setBusinessSegmentsType(1);
- sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
- }
- //手续费+跟单费用
- BigDecimal amount_SX_GD = BigDecimal.ZERO;
- amount_SX_GD = amount_SX_GD.add(sysUserAccount.getHandlingFee() == null ? BigDecimal.ZERO : sysUserAccount.getHandlingFee())
- .add(sysUserAccount.getDocumentary() == null ? BigDecimal.ZERO : sysUserAccount.getDocumentary());
- //历史记录表添加手续费+跟单费用 add by hxl 2024-06-18
- if (amount_SX_GD.compareTo(BigDecimal.ZERO) != 0) {
- sysUserAccountHistory.setId(null);
- sysUserAccountHistory.setAmount(amount_SX_GD);
- sysUserAccountHistory.setProperty(MoneyAttrConstants.M_4.getCode());
- if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
- afterAmount = beforeAmount.subtract(amount_SX_GD);
- sysUserAccountHistory.setSurplusAmount(afterAmount); //改变后金额
- sysUserAccountHistory.setUserAmount(beforeAmount); //改变前金额
- sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getSumAmount());
- sysUserAccountHistory.setBusinessSegmentsType(1);
- sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
- }
- }
- }
- //添加佣金消息
- messageSecretaryService.addMessage(MessageTypeConstants.M_5, sysUserAccount.getUserId(), "你有一条佣金消息," + commissionMessage.toString());
- }
- @Override
- public BasePageResult<SysUserAccount> queryByVo(SysUserAccountVo sysUserAccountVo) {
- Page<SysUserAccount> page = new Page<>(sysUserAccountVo.getPageNum(), sysUserAccountVo.getPageSize());
- Page<SysUserAccount> sysUserAccountHistoryPage = baseMapper.queryPageOrder(sysUserAccountVo, page);
- return new BasePageResult<>(sysUserAccountVo.getPageNum(), page.getSize(), sysUserAccountHistoryPage.getTotal(), page.getPages(),
- sysUserAccountHistoryPage.getRecords());
- }
- //
- @Override
- public BasePageResult<SysUserAccount> queryByVo1(SysUserAccountVo sysUserAccountVo) {
- Page<SysUserAccount> page = new Page<>(sysUserAccountVo.getPageNum(), sysUserAccountVo.getPageSize());
- Page<SysUserAccount> sysUserAccountHistoryPage = baseMapper.queryPageOrder1(sysUserAccountVo,page);
- if(sysUserAccountHistoryPage!=null){
- List<SysUserAccount> records = sysUserAccountHistoryPage.getRecords();
- List<SysUserAccount> newRecords = new ArrayList<>();
- if(records!=null && !records.isEmpty()){
- for(SysUserAccount sysUserAccount :records){
- //重新赋值总金额 - 已提现金额 支付中金额
- MySumAmountQueryDto mySumAmountQueryDto =new MySumAmountQueryDto();
- mySumAmountQueryDto.setUserId(sysUserAccount.getUserId());
- //出单员是19 且是渠道的话,给渠道团队长
- if ("21".equals(sysUserAccount.getRoleId()) && "1".equals(sysUserAccount.getManagementSource())) {
- mySumAmountQueryDto.setDeptId(sysUserAccount.getDeptId());
- }
- //如果是电销组长,将组员的数据算进来
- if ("72".equals(sysUserAccount.getRoleId()) && "3".equals(sysUserAccount.getManagementSource())) {
- mySumAmountQueryDto.setGroupFlag(true);
- }
- // 已提现金额 查询历史表中的审核状态为3的数据
- BigDecimal ysTXAmount = insFeeOrderNewService.findMyAmountYTXmount(mySumAmountQueryDto.getUserId(), "3",mySumAmountQueryDto.getGroupFlag());
- // 提现中
- BigDecimal txzTXAmount = insFeeOrderNewService.findMyAmountYTXmount(mySumAmountQueryDto.getUserId(), "2",mySumAmountQueryDto.getGroupFlag());
- // 可提现
- BigDecimal ssKTAmount = sysUserAccount.getSumAmount()==null?BigDecimal.ZERO:sysUserAccount.getSumAmount();
- //总的 = 已提现金额+ 可提现金额 + 提现中
- BigDecimal sumAmount = ysTXAmount.add(ssKTAmount).add(txzTXAmount);
- sysUserAccount.setSumAmountWithdrawal(sumAmount);
- sysUserAccount.setSumAmountAccount(ysTXAmount);
- sysUserAccount.setSumAmountPayment(txzTXAmount);
- newRecords.add(sysUserAccount);
- }
- }
- sysUserAccountHistoryPage.setRecords(newRecords);
- }
- return new BasePageResult<>(sysUserAccountVo.getPageNum(), page.getSize(), sysUserAccountHistoryPage.getTotal(), page.getPages(),
- sysUserAccountHistoryPage.getRecords());
- }
- @Override
- @Transactional
- public HttpResult<Object> inert(SysUserAccountVo sysUserAccountVo) {
- String userId = BaseController.getUser().getId();
- if (isManagement(userId) && sysSwitchConfigService.getBalanceExtractStatus()){
- // 个代走线上付款
- UserWithdrawal withdrawal = new UserWithdrawal();
- withdrawal.setUserId(userId);
- withdrawal.setAmount(sysUserAccountVo.getAmount());
- withdrawal.setBankNumber(sysUserAccountVo.getFromBankCardId());
- return ttqfService.userCashOut(withdrawal);
- }
- //add by hxl 2024-09-26 添加电销组员开关
- boolean flag = sysSwitchConfigService.dxtxDisplaySwitches();
- if(flag){
- // add by hxl 2024-09-25 电销组员无法提现
- SysUser user = sysUserService.getById(userId);
- SysUserBaseVO sysUserBaseVO = sysUserService.selectUserById(userId);
- SysDept dept = sysDeptService.getById(user.getDeptId());
- if("3".equals(sysUserBaseVO.getRoleId()) && "3".equals(dept.getManagementSource())){
- throw new SystemException("电销组员不能提现");
- }
- }
- // add by hxl 2024-09-12 =============== 添加提现用户是渠道的话,只能提现100的整数金额
- BigDecimal amount = sysUserAccountVo.getAmount();
- // judgeAmount(amount, userId); 注释掉 2024-09-18
- // add by hxl end =============================
- BigDecimal zero = BigDecimal.ZERO;
- BigDecimal beforeAmount;
- BigDecimal afterAmount;
- // 用户当前金额
- // BigDecimal amount = sysUserAccountVo.getAmount();
- SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory(); // 记录
- sysUserAccountHistory.setDocumentary(1); // 1提现
- sysUserAccountHistory.setUserId(userId);
- sysUserAccountHistory.setProperty(6);
- sysUserAccountHistory.setBusinessSegmentsType(1);
- SysAmountAuditingEntity sysAmountAuditingEntity = new SysAmountAuditingEntity();//审核记录表
- sysAmountAuditingEntity.setUserId(userId);
- sysAmountAuditingEntity.setAmount(sysUserAccountVo.getAmount());
- sysUserAccountHistory.setCreateTime(new Date());
- // SysAmountAuditingEntity judge = sysAmountAuditingService.getByUserId(userId, sysUserAccountVo.getAmountStatus());
- // if (ObjectUtils.isNotEmpty(judge)) {
- // return HttpResult.ok("有未提现审核单据, 请审核完成之后再提现");
- // }
- // 通过银行卡id 查询卡包
- String fromBankCardId = sysUserAccountVo.getFromBankCardId();
- if (fromBankCardId != null) {
- // SysUserBankCard byId = sysUserBankCardService.getById(fromBankCardId);
- SysUserBankCard byId = sysUserBankCardService.getByBankNumber(fromBankCardId, userId);
- if (byId == null) {
- throw new SystemException("该卡未绑定此账号,或输入卡号错误,或该账号尚未审核通过,请检查");
- }
- byId.setIsDefault(1);
- sysAmountAuditingEntity.setBankNumber(byId.getBankNumber());
- sysUserAccountHistory.setFromBankCard(byId.getBankNumber());
- sysUserBankCardService.updateById(byId);
- }
- if (StringUtils.isNotEmpty(userId)) {
- SysUserAccount sysUserAccount = baseMapper.getById(userId);
- //if (StringUtils.isNotEmpty(sysUserAccountVo.getAmountStatus())) {
- //sysUserAccountHistory.setProperty(Integer.valueOf(sysUserAccountVo.getAmountStatus())); //金额类型
- /**
- if ("1".equals(sysUserAccountVo.getAmountStatus())) {
- // 用户当前费用金
- beforeAmount = sysUserAccount.getHandlingFee();
- afterAmount = beforeAmount.subtract(amount);
- sysUserAccount.setHandlingFee(afterAmount);
- sysUserAccount.setHandlingAmountPayment(sysUserAccount.getHandlingAmountPayment().add(amount));
- sysUserAccount.setHandlingAmountWithdrawal(sysUserAccount.getHandlingAmountWithdrawal().add(amount));
- } else if ("2".equals(sysUserAccountVo.getAmountStatus())) {
- // 用户当前 非跟单佣金
- beforeAmount = sysUserAccount.getDocumentary();
- afterAmount = beforeAmount.subtract(amount);
- sysUserAccount.setDocumentary(afterAmount);
- sysUserAccount.setDocumentaryAmountpayment(sysUserAccount.getDocumentaryAmountpayment().add(amount));
- sysUserAccount.setDocumentaryAmountWithdrawal(sysUserAccount.getDocumentaryAmountWithdrawal().add(amount));
- } else {
- beforeAmount = sysUserAccount.getPromotion();
- afterAmount = beforeAmount.subtract(amount);
- sysUserAccount.setPromotion(afterAmount);
- sysUserAccount.setPromotionAmountPayment(sysUserAccount.getPromotionAmountPayment().add(amount));
- sysUserAccount.setPromotionAmountWithdrawal(sysUserAccount.getPromotionAmountWithdrawal().add(amount));
- }
- **/
- //提现前的金额
- beforeAmount = sysUserAccount.getSumAmount() == null ? BigDecimal.ZERO : sysUserAccount.getSumAmount();
- //提现后的金额
- afterAmount = beforeAmount.subtract(amount);
- sysUserAccount.setSumAmount(afterAmount);
- //支付中总金额 = 原先的支付金额 + 提现的金额
- sysUserAccount.setSumAmountPayment((sysUserAccount.getSumAmountPayment() == null ? BigDecimal.ZERO : sysUserAccount.getSumAmountPayment()).add(amount));
- //提现的总金额 = 原先的提现总金额 + 提现的金额
- sysUserAccount.setSumAmountWithdrawal((sysUserAccount.getSumAmountWithdrawal() == null ? BigDecimal.ZERO : sysUserAccount.getSumAmountWithdrawal().add(amount)));
- // 用户相差
- if (beforeAmount.compareTo(zero) == 0 || afterAmount.compareTo(zero) < 0) {
- return HttpResult.ok("余额不足");
- }
- sysUserAccountHistory.setAmount(amount); // 金额
- sysUserAccountHistory.setSurplusAmount(afterAmount); // 剩余金额
- sysUserAccountHistory.setUserAmount(beforeAmount); // 用户剩余金额
- sysAmountAuditingEntity.setCreateTime(new Date());
- sysAmountAuditingEntity.setAuditingStatus("2"); // 2 为待审核 3 审核通过
- // sysAmountAuditingEntity.setAmountStatus(sysUserAccountVo.getAmountStatus());
- // 新增金额记录
- sysAmountAuditingService.save(sysAmountAuditingEntity);
- sysUserAccountHistory.setAuditiingId(sysAmountAuditingEntity.getId());
- sysUserAccountService.updateById(sysUserAccount);
- sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
- // }
- // 提现审核插入轨迹表 待审核数据 和审核处理中的数据
- // Calendar calendar = Calendar.getInstance();
- Date date = new Date();
- //calendar.add(Calendar.MINUTE, 1);
- // Date afterDate = calendar.getTime();
- SysAmountAuditingHistory sysAmountAuditingHistory = new SysAmountAuditingHistory(null, sysAmountAuditingEntity.getId(), amount, userId, date, "1", "1", sysUserAccountHistory.getId());
- SysAmountAuditingHistory sysAmountAuditingHistoryTwo = new SysAmountAuditingHistory(null, sysAmountAuditingEntity.getId(), amount, userId, date, "2", "1", sysUserAccountHistory.getId());
- sysAmountAuditingHistoryService.save(sysAmountAuditingHistory);
- sysAmountAuditingHistoryService.save(sysAmountAuditingHistoryTwo);
- }
- return HttpResult.ok("提现成功,等待审核");
- }
- public boolean isManagement(String userId) {
- SysUser sysUser = SpringUtil.getBean(SysUserBankCardMapper.class).selectByIdPay(userId);
- if (ManagementSource.MS_02.getCode().equals(sysUser.getManagementSource())){
- return true;
- }
- return false;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/18 17:30
- * @Description: 提现修改为总金额
- */
- @Override
- @Transactional
- public HttpResult withdraw(SysUserAccountVo sysUserAccountVo) {
- String userId = sysUserAccountVo.getUserId();
- //add by hxl 2024-09-26 添加电销组员开关
- boolean flag = sysSwitchConfigService.dxtxDisplaySwitches();
- if(flag){
- // add by hxl 2024-09-25 电销组员无法提现
- SysUser user = sysUserService.getById(userId);
- SysUserBaseVO sysUserBaseVO = sysUserService.selectUserById(userId);
- SysDept dept = sysDeptService.getById(user.getDeptId());
- if("3".equals(sysUserBaseVO.getRoleId()) && "3".equals(dept.getManagementSource())){
- throw new SystemException("电销组员不能提现");
- }
- }
- // add by hxl 2024-09-12 =============== 添加提现用户是渠道的话,只能提现100的整数金额
- BigDecimal amount = sysUserAccountVo.getAmount();
- // judgeAmount(amount, userId); 注释掉 2024-09-18
- // add by hxl end =============================
- BigDecimal zero = BigDecimal.ZERO;
- BigDecimal beforeAmount;
- BigDecimal afterAmount;
- // 用户当前金额
- // BigDecimal amount = sysUserAccountVo.getAmount();
- SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory(); // 记录
- sysUserAccountHistory.setDocumentary(1); // 1支出
- sysUserAccountHistory.setUserId(userId);
- sysUserAccountHistory.setProperty(6); //3提现
- sysUserAccountHistory.setBusinessSegmentsType(1);
- SysAmountAuditingEntity sysAmountAuditingEntity = new SysAmountAuditingEntity();//审核记录表
- sysAmountAuditingEntity.setUserId(userId);
- sysAmountAuditingEntity.setAmount(sysUserAccountVo.getAmount());
- sysUserAccountHistory.setCreateTime(new Date());
- // SysAmountAuditingEntity judge = sysAmountAuditingService.getByUserId(userId, sysUserAccountVo.getAmountStatus());
- // if (ObjectUtils.isNotEmpty(judge)) {
- // throw new SystemException("有未提现审核单据, 请审核完成之后再提现");
- // }
- // 通过银行卡id 查询卡包
- String fromBankCardId = sysUserAccountVo.getFromBankCardId();
- SysUserBankCard byId = sysUserBankCardService.getByBankNumber(fromBankCardId, userId);
- if (byId == null) {
- throw new SystemException("该卡未绑定此账号,或输入卡号错误,或该账号尚未审核通过,请检查");
- }
- if (fromBankCardId != null && byId.getUserId().equals(userId)) {
- byId.setIsDefault(1);
- sysAmountAuditingEntity.setBankNumber(byId.getBankNumber());
- sysUserAccountHistory.setFromBankCard(byId.getBankNumber());
- sysUserBankCardService.updateById(byId);
- }
- if (StringUtils.isNotEmpty(userId)) {
- SysUserAccount sysUserAccount = baseMapper.getById(userId);
- //if (StringUtils.isNotEmpty(sysUserAccountVo.getAmountStatus())) {
- //sysUserAccountHistory.setProperty(Integer.valueOf(sysUserAccountVo.getAmountStatus())); //金额类型
- //注释掉类型提现,直接提现总金额
- /**
- if ("1".equals(sysUserAccountVo.getAmountStatus())) {
- // 用户当前费用金
- beforeAmount = sysUserAccount.getHandlingFee();
- afterAmount = beforeAmount.subtract(amount);
- sysUserAccount.setHandlingFee(afterAmount);
- sysUserAccount.setHandlingAmountPayment(sysUserAccount.getHandlingAmountPayment().add(amount));
- sysUserAccount.setHandlingAmountWithdrawal(sysUserAccount.getHandlingAmountWithdrawal().add(amount));
- } else if ("2".equals(sysUserAccountVo.getAmountStatus())) {
- // 用户当前 非跟单佣金
- beforeAmount = sysUserAccount.getDocumentary();
- afterAmount = beforeAmount.subtract(amount);
- sysUserAccount.setDocumentary(afterAmount);
- sysUserAccount.setDocumentaryAmountpayment(sysUserAccount.getDocumentaryAmountpayment().add(amount));
- sysUserAccount.setDocumentaryAmountWithdrawal(sysUserAccount.getDocumentaryAmountWithdrawal().add(amount));
- } else {
- beforeAmount = sysUserAccount.getPromotion();
- afterAmount = beforeAmount.subtract(amount);
- sysUserAccount.setPromotion(afterAmount);
- sysUserAccount.setPromotionAmountPayment(sysUserAccount.getPromotionAmountPayment().add(amount));
- sysUserAccount.setPromotionAmountWithdrawal(sysUserAccount.getPromotionAmountWithdrawal().add(amount));
- }
- **/
- //提现前的金额
- beforeAmount = sysUserAccount.getSumAmount() == null ? BigDecimal.ZERO : sysUserAccount.getSumAmount();
- //提现后的金额
- afterAmount = beforeAmount.subtract(amount);
- sysUserAccount.setSumAmount(afterAmount);
- //支付中总金额 = 原先的支付金额 + 提现的金额
- sysUserAccount.setSumAmountPayment((sysUserAccount.getSumAmountPayment() == null ? BigDecimal.ZERO : sysUserAccount.getSumAmountPayment()).add(amount));
- //提现的总金额 = 原先的提现总金额 + 提现的金额
- sysUserAccount.setSumAmountWithdrawal((sysUserAccount.getSumAmountWithdrawal() == null ? BigDecimal.ZERO : sysUserAccount.getSumAmountWithdrawal().add(amount)));
- // 用户相差
- if (beforeAmount.compareTo(zero) == 0 || afterAmount.compareTo(zero) < 0) {
- return HttpResult.error("余额不足");
- }
- sysUserAccountHistory.setAmount(amount); // 金额
- sysUserAccountHistory.setSurplusAmount(afterAmount); // 剩余金额
- sysUserAccountHistory.setUserAmount(beforeAmount); // 用户剩余金额
- sysAmountAuditingEntity.setCreateTime(new Date());
- sysAmountAuditingEntity.setAuditingStatus("2"); // 2 为待审核 3 审核通过
- sysAmountAuditingEntity.setAmountStatus(sysUserAccountVo.getAmountStatus());
- // 新增金额记录
- sysAmountAuditingService.save(sysAmountAuditingEntity);
- sysUserAccountHistory.setAuditiingId(sysAmountAuditingEntity.getId());
- sysUserAccountService.updateById(sysUserAccount);
- sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
- //}
- // 提现审核插入轨迹表 待审核数据 和审核处理中的数据
- Calendar calendar = Calendar.getInstance();
- Date date = calendar.getTime();
- calendar.add(Calendar.MINUTE, 1);
- Date afterDate = calendar.getTime();
- SysAmountAuditingHistory sysAmountAuditingHistory = new SysAmountAuditingHistory(null, sysAmountAuditingEntity.getId(), amount, userId, date, "1", "1", sysUserAccountHistory.getId());
- SysAmountAuditingHistory sysAmountAuditingHistoryTwo = new SysAmountAuditingHistory(null, sysAmountAuditingEntity.getId(), amount, userId, afterDate, "2", "1", sysUserAccountHistory.getId());
- sysAmountAuditingHistoryService.save(sysAmountAuditingHistory);
- sysAmountAuditingHistoryService.save(sysAmountAuditingHistoryTwo);
- }
- return HttpResult.ok("提现成功,等待审核");
- }
- @Override
- public SysUserAccount getSysUserAmount(String userid) {
- SysUserAccount sysUserAccount = baseMapper.getById(userid);
- return sysUserAccount;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/11 16:05
- * @Description: 注释掉实收的总金额提升查询效率
- */
- @Override
- public SysUserAccountVo getSysAllAmount(String userId) {
- SysUserAccountVo sysUserAccountVo = new SysUserAccountVo();
- SysUserAccount sysUserAccount = baseMapper.getById(userId);
- // 验证账户信息是否有值
- if (ObjectUtils.isEmpty(sysUserAccount)) {
- return sysUserAccountVo;
- }
- BeanUtils.copyProperties(sysUserAccount, sysUserAccountVo);
- BigDecimal willHalding = BigDecimal.ZERO; //预收手续费佣金
- BigDecimal willDocumentary = BigDecimal.ZERO; //预收 非跟单佣金
- BigDecimal willPromotion = BigDecimal.ZERO; //预收 推广
- //BigDecimal receivedWillHalding = BigDecimal.ZERO; //实收手续费佣金
- // BigDecimal receivedWillDocumentary = BigDecimal.ZERO; //实收非跟单佣金
- // BigDecimal receivedWillPromotion = BigDecimal.ZERO; //实收推广费
- // 预收手续费佣金
- willPromotion = this.willPromotionAll(willPromotion, userId, "1");
- // 实收手续费佣金
- //receivedWillPromotion = this.willPromotionAll(willPromotion, userId,"2");
- // add by hxl 修改sql 添加承保状态和不在审核表中的条件 begin ===============
- List<InsFeeOrderNew> willList = insFeeOrderNewService.getByUserIdAndOrderStatusAndNoCheckType(userId, "1");
- //List<InsFeeOrderNew> willListnew = insFeeOrderNewService.getByUserIdAndOrderStatusAndNoCheckType(userId,"2");
- if (!CollectionUtils.isEmpty(willList)) {
- for (InsFeeOrderNew item : willList) {
- if (ObjectUtils.isNotEmpty(item)) {
- //1.预收手续费佣金 2. 预收非跟单佣金
- willHalding = willHalding.add(this.willAmountNew(item, 1));
- willDocumentary = willDocumentary.add(this.willAmountNew(item, 2));
- }
- }
- }
- /**
- if (!CollectionUtils.isEmpty(willListnew)) {
- for (InsFeeOrderNew item : willListnew) {
- if (ObjectUtils.isNotEmpty(item)) {
- //1.实收手续费佣金 2. 实收非跟单佣金
- receivedWillHalding = willHalding.add(this.willAmountNew(item,1));
- receivedWillDocumentary = willDocumentary.add(this.willAmountNew(item,2));
- }
- }
- }
- **/
- //预收手续费佣金
- sysUserAccountVo.setWillHalding(willHalding);
- //预收非跟单佣金
- sysUserAccountVo.setWillDocumentary(willDocumentary);
- //实收手续费佣金
- //sysUserAccountVo.setReceivedWillHalding(receivedWillHalding);
- //实收非跟单佣金
- //sysUserAccountVo.setReceivedWillDocumentary(receivedWillDocumentary);
- //提现现中 手续费、非跟单、推广费
- HashMap<String, Object> params = new HashMap<>();
- params.put("auditingStatus", "2"); // 待审核
- params.put("userId", userId);
- List<SysAmountAuditingEntity> sysAmountAuditingProgressIng = sysAmountAuditingService.getProgressIng(params);
- this.judge(sysAmountAuditingProgressIng, sysUserAccountVo);
- params.clear();
- params.put("auditingStatus", "3"); // 已审核审核
- params.put("userId", userId);
- //已提现 手续费、非跟单、推广费
- List<SysAmountAuditingEntity> sysAmountAuditingApproved = sysAmountAuditingService.getProgressIng(params);
- this.judgeSysAmountAuditing(sysAmountAuditingApproved, sysUserAccountVo);
- //预收手续费佣金
- sysUserAccountVo.setWillPromotion(willPromotion);
- //实收手续费佣金
- // sysUserAccountVo.setReceivedWillPromotion(receivedWillPromotion);
- return sysUserAccountVo;
- }
- @Override
- public SysUserAccountVo getInsOrders(SysUserAccountVo sysUserAccountVo) {
- ArrayList<InsFeeOrderNew> resultList = new ArrayList<>();
- HashMap<String, Object> params = new HashMap<>();
- params.put("userId", BaseController.getUser().getId());
- //日期
- params.put("timeFiltering", sysUserAccountVo.getTimeFiltering());
- //1预收2.实收
- params.put("type", sysUserAccountVo.getSearchType());
- sysUserAccountVo.setInsFeeOrderNewList(null);
- //金额类型 1. 手续费金额 2. 跟单金额 3. 推广金额
- if ("3".equals(sysUserAccountVo.getAmountType())) {
- List<InsFeeOrderNew> sumWillAmountGeneralization = insFeeOrderNewService.getSumWillAmountGeneralizationNew(params);
- sysUserAccountVo.setInsFeeOrderNewList(sumWillAmountGeneralization);
- } else {
- List<InsFeeOrderNew> resultInsFeeOrderNew = insFeeOrderNewService.getSumWillAmountNew(params);
- if (resultInsFeeOrderNew != null && resultInsFeeOrderNew.size() > 0) {
- for (InsFeeOrderNew item : resultInsFeeOrderNew) {
- BigDecimal willPromotion = BigDecimal.ZERO;
- if ("1".equals(sysUserAccountVo.getAmountType())) {
- //手续费出口预收
- willPromotion = willPromotion.add(item.getJqExportSuperviseCostsPremiums()).add(item.getSyExportSuperviseCostsPremiums()).add(item.getNoExportSuperviseCostsPremiums());
- } else if ("2".equals(sysUserAccountVo.getAmountType())) {
- willPromotion = willPromotion.add(item.getJqExportOtherCostsPremiums()).add(item.getSyExportOtherCostsPremiums()).add(item.getNoExportOtherCostsPremiums());
- }
- item.setWillAmount(willPromotion);
- if (willPromotion.compareTo(BigDecimal.ZERO) != 0) {
- resultList.add(item);
- }
- }
- sysUserAccountVo.setInsFeeOrderNewList(resultList);
- }
- }
- return sysUserAccountVo;
- }
- private void getWillAmount(InsFeeOrderNew insFeeOrderNew) {
- if (ObjectUtils.isNotEmpty(insFeeOrderNew)) {
- //交强手续费出口比例
- BigDecimal jqExportProceduresFee =
- insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqSuperviseCostsProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- //商业手续费出口比例
- BigDecimal syExportProceduresFee =
- insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSySuperviseCostsProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- //非车手续费出口比例
- BigDecimal noExportProceduresFee =
- insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoSuperviseCostsProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- //非车出口比例
- //总机构 交强管理比例
- BigDecimal sumJqDeptProportion = insFeeOrderNew.getJqDeptProportionLevel1()
- .add(insFeeOrderNew.getJqDeptProportionLevel2())
- .add(insFeeOrderNew.getJqDeptProportionLevel3())
- .add(insFeeOrderNew.getJqDeptProportionLevel4())
- .add(insFeeOrderNew.getJqDeptProportionLevel5());
- //总机构 商业管理比例
- BigDecimal sumSyDeptProportion = insFeeOrderNew.getSyDeptProportionLevel1()
- .add(insFeeOrderNew.getSyDeptProportionLevel2())
- .add(insFeeOrderNew.getSyDeptProportionLevel3())
- .add(insFeeOrderNew.getSyDeptProportionLevel4())
- .add(insFeeOrderNew.getSyDeptProportionLevel5());
- //总机构 非车管理比例
- BigDecimal sumNoDeptProportion = insFeeOrderNew.getNoDeptProportionLevel1()
- .add(insFeeOrderNew.getNoDeptProportionLevel2())
- .add(insFeeOrderNew.getNoDeptProportionLevel3())
- .add(insFeeOrderNew.getNoDeptProportionLevel4())
- .add(insFeeOrderNew.getNoDeptProportionLevel5());
- BigDecimal noExportProceduresProportion = new BigDecimal(0);
- //总分销比例
- BigDecimal sumRetail =
- insFeeOrderNew.getFirstDetailProportion().add(insFeeOrderNew.getSecondDetailProportion()).add(insFeeOrderNew.getThirdDetailProportion());
- if (insFeeOrderNew.getNoCostsProportion().compareTo(sumNoDeptProportion.add(sumRetail)) > 0) {
- noExportProceduresProportion = insFeeOrderNew.getNoCostsProportion().subtract(sumNoDeptProportion).subtract(sumRetail);
- }
- //商业出口比例
- BigDecimal syExportProceduresProportion = new BigDecimal(0);
- if (insFeeOrderNew.getSyCostsProportion().compareTo(sumSyDeptProportion.add(sumRetail)) > 0) {
- syExportProceduresProportion = insFeeOrderNew.getSyCostsProportion().subtract(sumSyDeptProportion).subtract(sumRetail);
- }
- //交强出口比例
- BigDecimal jqExportProceduresProportion = new BigDecimal(0);
- if (insFeeOrderNew.getJqCostsProportion().compareTo(sumJqDeptProportion.add(sumRetail)) > 0) {
- jqExportProceduresProportion = insFeeOrderNew.getJqCostsProportion().subtract(sumJqDeptProportion).subtract(sumRetail);
- }
- //交强跟单出口费用
- BigDecimal jqExportOtherFee = insFeeOrderNew.getJqPremium()
- .multiply(jqExportProceduresProportion
- .subtract(insFeeOrderNew.getJqSuperviseCostsProportion()).divide(new BigDecimal(100))).setScale(2,
- BigDecimal.ROUND_DOWN);
- //商业跟单出口比例
- BigDecimal syExportOtherFee = insFeeOrderNew.getSyPremium()
- .multiply(syExportProceduresProportion
- .subtract(insFeeOrderNew.getSySuperviseCostsProportion()).divide(new BigDecimal(100))).setScale(2,
- BigDecimal.ROUND_DOWN);
- //非车跟单出口比例
- BigDecimal noExportOtherFee = insFeeOrderNew.getNoPremium()
- .multiply(noExportProceduresProportion
- .subtract(insFeeOrderNew.getNoSuperviseCostsProportion()).divide(new BigDecimal(100))).setScale(2,
- BigDecimal.ROUND_DOWN);
- if (StringUtils.isNotEmpty(insFeeOrderNew.getAmountType())) {
- if ("1".equals(insFeeOrderNew.getAmountType())) {
- //用户出口手续费
- insFeeOrderNew.setWillAmount(jqExportProceduresFee.add(syExportProceduresFee).add(noExportProceduresFee));
- }
- if ("2".equals(insFeeOrderNew.getAmountType())) {
- //用户出口跟单费
- insFeeOrderNew.setWillAmount(jqExportOtherFee.add(syExportOtherFee).add(noExportOtherFee));
- }
- }
- }
- }
- private BigDecimal getWillPromotion(InsFeeOrderNew insFeeOrderNew, BigDecimal willPromotion) {
- InsOrders InsOrders = insAreaCompanyService.selectByInFeeOrderNew(insFeeOrderNew);
- if (ObjectUtils.isNotEmpty(InsOrders)) {
- BigDecimal willFirstPremiums = ObjectUtils.defaultIfNull(InsOrders.getWillFirstPremiums(), BigDecimal.ZERO);
- // 累加保费
- willPromotion = willPromotion.add(willFirstPremiums);
- }
- return willPromotion;
- }
- private void judgeSysAmountAuditing(List<SysAmountAuditingEntity> sysAmountAuditingApproved, SysUserAccountVo sysUserAccountVo) {
- if (!CollectionUtils.isEmpty(sysAmountAuditingApproved)) {
- for (SysAmountAuditingEntity item : sysAmountAuditingApproved) {
- if ("1".equals(item.getAmountStatus())) { //手续费
- BigDecimal amount = item.getAmount();
- sysUserAccountVo.setApprovedHalding(amount);
- }
- if ("2".equals(item.getAmountStatus())) { //非跟单
- BigDecimal amount = item.getAmount();
- sysUserAccountVo.setApprovedDocumentary(amount);
- }
- if ("3".equals(item.getAmountStatus())) { //推广费
- BigDecimal amount = item.getAmount();
- sysUserAccountVo.setApprovedPromotion(amount);
- }
- }
- }
- }
- private void judge(List<SysAmountAuditingEntity> sysAmountAuditingProgressIng, SysUserAccountVo sysUserAccountVo) {
- if (!CollectionUtils.isEmpty(sysAmountAuditingProgressIng)) {
- for (SysAmountAuditingEntity item : sysAmountAuditingProgressIng) {
- if ("1".equals(item.getAmountStatus())) { //手续费
- BigDecimal amount = item.getAmount();
- sysUserAccountVo.setWithdrawalHalding(amount);
- }
- if ("2".equals(item.getAmountStatus())) { //非跟单
- BigDecimal amount = item.getAmount();
- sysUserAccountVo.setWithdrawalDocumentary(amount);
- }
- if ("3".equals(item.getAmountStatus())) { //推广费
- BigDecimal amount = item.getAmount();
- sysUserAccountVo.setWithdrawalPromotion(amount);
- }
- }
- }
- }
- private BigDecimal willPromotion(BigDecimal willPromotion, String userId) {
- InsFeeOrderNew insFeeOrderNew = new InsFeeOrderNew();
- insFeeOrderNew.setUserId(userId);
- InsOrders InsOrders = insAreaCompanyService.selectByInFeeOrderNew(insFeeOrderNew);
- if (ObjectUtils.isNotEmpty(InsOrders)) {
- BigDecimal willFirstPremiums = ObjectUtils.defaultIfNull(InsOrders.getWillFirstPremiums(), BigDecimal.ZERO);
- // 累加保费
- willPromotion = willPromotion.add(willFirstPremiums);
- }
- return willPromotion;
- }
- private void willAmount(InsFeeOrderNew insFeeOrderNew, BigDecimal willHalding, BigDecimal willDocumentary,
- SysUserAccountVo sysUserAccountVo) {
- if (ObjectUtils.isNotEmpty(insFeeOrderNew)) {
- //交强手续费
- BigDecimal jqExportProceduresFee = insFeeOrderNew.getJqExportSuperviseCostsPremiums();
- //商业手续费
- BigDecimal syExportProceduresFee = insFeeOrderNew.getSyExportSuperviseCostsPremiums();
- //非车手续费
- BigDecimal noExportProceduresFee = insFeeOrderNew.getNoExportSuperviseCostsPremiums();
- if (sysUserAccountVo.getWillHalding() == null) {
- sysUserAccountVo.setWillHalding(BigDecimal.ZERO);
- }
- sysUserAccountVo.setWillHalding(sysUserAccountVo.getWillHalding().add(jqExportProceduresFee).add(syExportProceduresFee).add(noExportProceduresFee));
- //交强跟单出口费用
- BigDecimal jqExportOtherCostsPremiums = insFeeOrderNew.getJqExportOtherCostsPremiums();
- //商业跟单出口费用
- BigDecimal syExportOtherCostsPremiums = insFeeOrderNew.getSyExportOtherCostsPremiums();
- //非车跟单出口费用
- BigDecimal noExportOtherCostsPremiums = insFeeOrderNew.getNoExportOtherCostsPremiums();
- //用户出口跟单费
- if (sysUserAccountVo.getWillDocumentary() == null) {
- sysUserAccountVo.setWillDocumentary(BigDecimal.ZERO);
- }
- sysUserAccountVo.setWillDocumentary(sysUserAccountVo.getWillDocumentary().add(jqExportOtherCostsPremiums).add(syExportOtherCostsPremiums).add(noExportOtherCostsPremiums));
- }
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/3 11:20
- * @Description: 通过类型查询预收、实收的金额
- */
- private BigDecimal willPromotionAll(BigDecimal willPromotion, String userId, String type) {
- InsFeeOrderNew insFeeOrderNew = new InsFeeOrderNew();
- insFeeOrderNew.setUserId(userId);
- InsOrders InsOrders = insAreaCompanyService.selectByInFeeOrderNewByType(insFeeOrderNew, type);
- if (ObjectUtils.isNotEmpty(InsOrders)) {
- BigDecimal willFirstPremiums = ObjectUtils.defaultIfNull(InsOrders.getWillFirstPremiums(), BigDecimal.ZERO);
- // 累加保费
- willPromotion = willPromotion.add(willFirstPremiums);
- }
- return willPromotion;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/4 11:51
- * @Description: 获取费用
- */
- private BigDecimal willAmountNew(InsFeeOrderNew insFeeOrderNew, int type) {
- BigDecimal val = BigDecimal.ZERO;
- if (ObjectUtils.isNotEmpty(insFeeOrderNew)) {
- if (type == 1) {
- // 交强手续费+商业手续费+非车手续费
- val = val.add(insFeeOrderNew.getJqExportSuperviseCostsPremiums()).add(insFeeOrderNew.getSyExportSuperviseCostsPremiums()).add(insFeeOrderNew.getNoExportSuperviseCostsPremiums());
- } else {
- // 交强跟单出口费用+商业跟单出口费用+非车跟单出口费用
- val = val.add(insFeeOrderNew.getJqExportOtherCostsPremiums()).add(insFeeOrderNew.getSyExportOtherCostsPremiums()).add(insFeeOrderNew.getNoExportOtherCostsPremiums());
- }
- }
- return val;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/3 15:16
- * @Description: 查询子订单的详细信息
- */
- @Override
- public SubOrder getSubOrderDetails(String subOrderId, String userId) {
- SubOrder subOrder = insAreaCompanyMapper.getSubOrderDetails(subOrderId);
- subOrder.setAgentName(this.getUserName(subOrder.getUserId()));
- subOrder.setAgentLevel("");
- //根据用户id查询分销等级
- InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getOne(new LambdaQueryWrapper<InsFeeOrderNew>()
- .eq(InsFeeOrderNew::getInsOrderNo, subOrder.getSubOrderId()));
- if (userId.equals(insFeeOrderNew.getFirstLevelUserId())) {
- //subOrder.setAgentName(this.getUserName(insFeeOrderNew.getFirstLevelUserId()));
- subOrder.setAgentLevel("一级分销代理");
- }
- if (userId.equals(insFeeOrderNew.getTwoLevelUserId())) {
- //subOrder.setAgentName(this.getUserName(insFeeOrderNew.getTwoLevelUserId()));
- subOrder.setAgentLevel("二级分销代理");
- }
- if (userId.equals(insFeeOrderNew.getThreeLevelUserId())) {
- //subOrder.setAgentName(this.getUserName(insFeeOrderNew.getThreeLevelUserId()));
- subOrder.setAgentLevel("三级分销代理");
- }
- return subOrder;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/3 16:34
- * @Description: 查询分销人名称
- */
- private String getUserName(String userId) {
- if (StringUtils.isNotEmpty(userId)) {
- SysUser sysUser = sysUserService.getBaseMapper().selectById(userId);
- if (ObjectUtils.isNotEmpty(sysUser)) {
- return sysUser.getName();
- }
- }
- return "";
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/19 9:04
- * @Description: 查询我的账户总金额
- */
- @Override
- public BigDecimal getUserSumAmountByUserId(String userId) {
- if (StringUtils.isBlank(userId)) {
- throw new SystemException("用户id-userId不能为空");
- }
- //通过用户id查询用户账户的总金额
- LambdaQueryWrapper<SysUserAccount> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(SysUserAccount::getUserId, userId);
- SysUserAccount sysUserAccount = sysUserAccountService.getOne(queryWrapper);
- if (sysUserAccount == null) {
- return BigDecimal.ZERO;
- }
- return sysUserAccount.getSumAmount() == null ? BigDecimal.ZERO : sysUserAccount.getSumAmount();
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/19 11:04
- * @Description: 查询预收数据明细
- */
- @Override
- public MyCollectInAdvanceAllDto findMyCollectInAdvanceByUserId(MyCollectInAdvanceQueryDto myCollectInAdvanceQueryDto) {
- if (StringUtils.isBlank(myCollectInAdvanceQueryDto.getUserId())) {
- throw new SystemException("用户id-userId不能为空");
- }
- BigDecimal sumAmount = BigDecimal.ZERO;
- //判断时间类型 1.一周内 2. 一月内 3. 三月内 4. 三月内
- HashMap<String, String> dateMap = getDateMapByType(myCollectInAdvanceQueryDto.getDateQueryType(), myCollectInAdvanceQueryDto.getStartDate(), myCollectInAdvanceQueryDto.getEndDate());
- myCollectInAdvanceQueryDto.setStartDate(dateMap.get("startDate"));
- myCollectInAdvanceQueryDto.setEndDate(dateMap.get("endDate"));
- if (myCollectInAdvanceQueryDto.getBusinessSegmentsType() == null || "".equals(myCollectInAdvanceQueryDto.getBusinessSegmentsType())) {
- myCollectInAdvanceQueryDto.setBusinessSegmentsType("1");
- }
- if (myCollectInAdvanceQueryDto.getTransactionType() == null || "".equals(myCollectInAdvanceQueryDto.getTransactionType())) {
- myCollectInAdvanceQueryDto.setTransactionType("1");
- }
- if (StringUtils.isEmpty(myCollectInAdvanceQueryDto.getAuditstatus())) {
- myCollectInAdvanceQueryDto.setAuditstatus("0");
- }
- Page<MyCollectInAdvanceDto> page = new Page<>(myCollectInAdvanceQueryDto.getPageNum(), myCollectInAdvanceQueryDto.getPageSize());
- // page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
- Page<MyCollectInAdvanceDto> orderVoPage = new Page<>();
- // 1为车险板块
- if ("1".equals(myCollectInAdvanceQueryDto.getBusinessSegmentsType())) {
- //金额类型 1. 手续费金额 +跟单金额 2. 推广金额
- if ("2".equals(myCollectInAdvanceQueryDto.getTransactionType())) {
- orderVoPage = insFeeOrderNewService.findMyCollectInAdvanceWillAmountByUserId(page, myCollectInAdvanceQueryDto);
- // Long total=insFeeOrderNewService.findMyCollectInAdvanceWillAmountByUserIdCount(myCollectInAdvanceQueryDto);
- // orderVoPage.setTotal(total);
- sumAmount = insFeeOrderNewService.findSumWillAmount(myCollectInAdvanceQueryDto);
- } else {
- orderVoPage = insFeeOrderNewService.findMyCollectInAdvanceSumByUserId(page, myCollectInAdvanceQueryDto);
- // Long total=insFeeOrderNewService.findMyCollectInAdvanceSumByUserIdCount(myCollectInAdvanceQueryDto);
- // orderVoPage.setTotal(total);
- sumAmount = insFeeOrderNewService.findSumAmount(myCollectInAdvanceQueryDto);
- }
- } else {
- //其他板块预留逻辑处理
- }
- List<MyCollectInAdvanceDto> recordsNew = new ArrayList<>();
- if (orderVoPage.getRecords() != null && !orderVoPage.getRecords().isEmpty()) {
- for (MyCollectInAdvanceDto dto : orderVoPage.getRecords()) {
- //车险的显示且收入
- if ("1".equals(dto.getBusinessSegmentsType())) {
- if ("4".equals(dto.getTransactionType())) {
- dto.setTransactionType("1");
- } else if ("3".equals(dto.getTransactionType())) {
- dto.setTransactionType("2");
- }
- }
- recordsNew.add(dto);
- }
- }
- boolean b = feeDisplayService.setWithdrawals(recordsNew);
- orderVoPage.setRecords(recordsNew);
- BasePageResult<MyCollectInAdvanceDto> myCollectInAdvanceDtoBasePageResult = new BasePageResult<>(myCollectInAdvanceQueryDto.getPageNum(), myCollectInAdvanceQueryDto.getPageSize(), orderVoPage.getTotal(),
- orderVoPage.getPages()
- , orderVoPage.getRecords());
- return new MyCollectInAdvanceAllDto(sumAmount, myCollectInAdvanceDtoBasePageResult, b);
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/19 11:57
- * @Description: 通过时间类型判断
- */
- private static HashMap<String, String> getDateMapByType(String type, String startDate, String endDate) {
- HashMap<String, String> map = new HashMap<>();
- String startDateStr = "";
- String endDateStr = "";
- if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
- startDateStr = StringUtils.isNotBlank(startDate) ? startDate + " 00:00:00" : null;
- endDateStr = StringUtils.isNotBlank(endDate) ? endDate + " 23:59:59" : null;
- } else {
- if ("0".equals(type)) {
- //全部
- startDateStr = null;
- endDateStr = null;
- } else if ("1".equals(type)) {
- // 一周内
- startDateStr = SliceUpDateUtil.getBeforeDay(new Date(), 1) + " 00:00:00";
- endDateStr = SliceUpDateUtil.getBeforeDay(new Date(), 0) + " 23:59:59";
- } else if ("2".equals(type)) {
- // 一月内
- startDateStr = SliceUpDateUtil.getBeforeDay(new Date(), 2) + " 00:00:00";
- endDateStr = SliceUpDateUtil.getBeforeDay(new Date(), 0) + " 23:59:59";
- } else if ("3".equals(type)) {
- // 三月内
- startDateStr = SliceUpDateUtil.getBeforeDay(new Date(), 3) + " 00:00:00";
- endDateStr = SliceUpDateUtil.getBeforeDay(new Date(), 0) + " 23:59:59";
- } else if ("4".equals(type)) {
- // 三月内
- startDateStr = SliceUpDateUtil.getBeforeDay(new Date(), 4) + " 00:00:00";
- endDateStr = SliceUpDateUtil.getBeforeDay(new Date(), 0) + " 23:59:59";
- } else {
- startDateStr = StringUtils.isNotBlank(startDate) ? startDate + " 00:00:00" : null;
- endDateStr = StringUtils.isNotBlank(endDate) ? endDate + " 23:59:59" : null;
- }
- }
- map.put("startDate", startDateStr);
- map.put("endDate", endDateStr);
- return map;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/19 11:04
- * @Description: 查询收支数据明细
- */
- @Override
- public MyCollectInAdvanceAllDto findIncomeAndExpensesByUserId(MyIncomeAndExpensesQueryDto myIncomeAndExpensesQueryDto) {
- if (StringUtils.isBlank(myIncomeAndExpensesQueryDto.getUserId())) {
- throw new SystemException("用户id-userId不能为空");
- }
- BigDecimal sumAmountSR = BigDecimal.ZERO;
- BigDecimal sumAmountZC = BigDecimal.ZERO;
- BasePageResult<MyCollectInAdvanceDto> myCollectInAdvanceDtoBasePageResult = new BasePageResult<MyCollectInAdvanceDto>();
- //判断时间类型 1.一周内 2. 一月内 3. 三月内 4. 三月内
- HashMap<String, String> dateMap = getDateMapByType(myIncomeAndExpensesQueryDto.getDateQueryType(), myIncomeAndExpensesQueryDto.getStartDate(), myIncomeAndExpensesQueryDto.getEndDate());
- myIncomeAndExpensesQueryDto.setStartDate(dateMap.get("startDate"));
- myIncomeAndExpensesQueryDto.setEndDate(dateMap.get("endDate"));
- Page<MyCollectInAdvanceDto> page = new Page<>(myIncomeAndExpensesQueryDto.getPageNum(), myIncomeAndExpensesQueryDto.getPageSize());
- //page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
- Page<MyCollectInAdvanceDto> orderVoPage = new Page<>();
- if ("0".equals(myIncomeAndExpensesQueryDto.getBusinessSegmentsType())) {
- myIncomeAndExpensesQueryDto.setBusinessSegmentsType(null);
- }
- if ("0".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
- myIncomeAndExpensesQueryDto.setTransactionType(null);
- }
- if ("0".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())) {
- myIncomeAndExpensesQueryDto.setIncomeAndExpensesType(null);
- }
- // 1为车险板块 1 收入时
- if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getBusinessSegmentsType()) && StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType()) && "1".equals(myIncomeAndExpensesQueryDto.getBusinessSegmentsType()) && "1".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())) {
- //判断收入类型 1 收入
- if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) && "3".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
- throw new SystemException("收入类型不能选择提现类型");
- }
- }
- if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType()) && "2".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())) {
- //判断支出类型
- if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) && !"3".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
- throw new SystemException("支出类型不能选择(手续+跟单)或者手续费、退款类型");
- }
- }
- if ((StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getBusinessSegmentsType()) && StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType()) && "2".equals(myIncomeAndExpensesQueryDto.getBusinessSegmentsType()) && "1".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType()))
- ||
- (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType()) && ("2".equals(myIncomeAndExpensesQueryDto.getBusinessSegmentsType())))) {
- //判断退款类型
- if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) && !"4".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
- throw new SystemException("退款板块只能选择退款类型");
- }
- }
- //处理 手续费+跟单、推广费类型转换
- if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) && "2".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
- myIncomeAndExpensesQueryDto.setTransactionType("3");
- } else if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) && "1".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
- myIncomeAndExpensesQueryDto.setTransactionType("4");
- } else if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) && "4".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
- myIncomeAndExpensesQueryDto.setTransactionType("5");
- } else if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) && "3".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
- myIncomeAndExpensesQueryDto.setTransactionType("6");
- }
- //处理收入和支出类型转换
- if (myIncomeAndExpensesQueryDto.getIncomeAndExpensesType() != null && "0".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())) {
- myIncomeAndExpensesQueryDto.setIncomeAndExpensesType(null);
- } else if (myIncomeAndExpensesQueryDto.getIncomeAndExpensesType() != null && "1".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())) {
- myIncomeAndExpensesQueryDto.setIncomeAndExpensesType("2");
- } else if (myIncomeAndExpensesQueryDto.getIncomeAndExpensesType() != null && "2".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())) {
- myIncomeAndExpensesQueryDto.setIncomeAndExpensesType("1");
- }
- orderVoPage = sysUserAccountHistoryService.findMyIncomeAndExpensesAmountByUserId(page, myIncomeAndExpensesQueryDto);
- // Long total=sysUserAccountHistoryService.findMyIncomeAndExpensesAmountByUserIdCount(myIncomeAndExpensesQueryDto);
- // orderVoPage.setTotal(total);
- List<MyCollectInAdvanceDto> recordsNew = new ArrayList<>();
- if (orderVoPage.getRecords() != null && orderVoPage.getRecords().size() > 0) {
- for (MyCollectInAdvanceDto dto : orderVoPage.getRecords()) {
- //车险的显示且收入
- if ("1".equals(dto.getBusinessSegmentsType()) && "2".equals(dto.getIncomeAndExpensesType())) {
- if ("4".equals(dto.getTransactionType())) {
- dto.setTransactionType("1");
- } else if ("3".equals(dto.getTransactionType())) {
- dto.setTransactionType("2");
- }
- dto.setIncomeAndExpensesType("1");
- //退款 且退款
- } else if ("2".equals(dto.getBusinessSegmentsType()) && "2".equals(dto.getIncomeAndExpensesType())) {
- dto.setIncomeAndExpensesType("1");
- dto.setTransactionType("4");
- //退款设置为空
- dto.setAuditingStatus("");
- //提现
- } else if ("6".equals(dto.getTransactionType()) && "1".equals(dto.getIncomeAndExpensesType())) {
- dto.setIncomeAndExpensesType("2");
- dto.setTransactionType("3");
- }
- recordsNew.add(dto);
- }
- }
- orderVoPage.setRecords(recordsNew);
- boolean b = feeDisplayService.setWithdrawals(recordsNew);
- myCollectInAdvanceDtoBasePageResult = new BasePageResult<>(myIncomeAndExpensesQueryDto.getPageNum(), myIncomeAndExpensesQueryDto.getPageSize(), orderVoPage.getTotal(),
- orderVoPage.getPages()
- , orderVoPage.getRecords());
- //
- sumAmountSR = sysUserAccountHistoryService.findSumAmountByUserId(myIncomeAndExpensesQueryDto.getUserId(), "2");
- sumAmountZC = sysUserAccountHistoryService.findSumAmountByUserId(myIncomeAndExpensesQueryDto.getUserId(), "1");
- return new MyCollectInAdvanceAllDto(sumAmountSR, sumAmountZC, myCollectInAdvanceDtoBasePageResult, b);
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/20 13:48
- * @Description: 提现详情
- */
- @Override
- public WithdrawalDetalsDto findDetailById(String id) {
- //id为历史表的id
- //通过历史记录表查询数据
- SysUserAccountHistory his = sysUserAccountHistoryService.getById(id);
- LambdaQueryWrapper<SysAmountAuditingHistory> lqw = new LambdaQueryWrapper<>();
- lqw.eq(SysAmountAuditingHistory::getHistoryId, id);
- lqw.orderByAsc(SysAmountAuditingHistory::getCreateTime);
- List<SysAmountAuditingHistory> listAll = sysAmountAuditingHistoryService.list(lqw);
- SysAmountAuditingEntity audi = sysAmountAuditingService.getById(his.getAuditiingId());
- WithdrawalDetalsDto withdrawalDetalsDto = new WithdrawalDetalsDto();
- if (audi != null) {
- withdrawalDetalsDto.setBankNumber(audi.getBankNumber());
- withdrawalDetalsDto.setTransactionNumber(audi.getId());
- withdrawalDetalsDto.setWithdrawalAmount(audi.getAmount());
- withdrawalDetalsDto.setBankAccount(audi.getBankAccount());
- }
- List<WithdrawalDetalsRecordDto> recordList = new ArrayList<WithdrawalDetalsRecordDto>();
- if (listAll != null && listAll.size() > 0) {
- SysAmountAuditingHistory first = listAll.get(0);
- SysAmountAuditingHistory last = listAll.get(listAll.size() - 1);
- //申请时间
- Date createTime = first.getCreateTime();
- withdrawalDetalsDto.setApplicationDate(createTime);
- String auditingStatus = last.getAuditingStatus();
- withdrawalDetalsDto.setWithdrawalStatus(auditingStatus);
- String auditingStatusName = "";
- if ("1".equals(auditingStatus)) {
- auditingStatusName = "提现申请";
- } else if ("2".equals(auditingStatus)) {
- auditingStatusName = "处理中";
- } else if ("3".equals(auditingStatus)) {
- auditingStatusName = "提现失败";
- } else if ("4".equals(auditingStatus)) {
- auditingStatusName = "提现成功";
- withdrawalDetalsDto.setPaymentDate(last.getCreateTime());
- }
- withdrawalDetalsDto.setWithdrawalStatusName(auditingStatusName);
- WithdrawalDetalsRecordDto dto1 = new WithdrawalDetalsRecordDto("1", false, "提现申请", null);
- WithdrawalDetalsRecordDto dto2 = new WithdrawalDetalsRecordDto("2", false, "处理中", null);
- WithdrawalDetalsRecordDto dto3 = null;
- WithdrawalDetalsRecordDto dto4 = new WithdrawalDetalsRecordDto("4", false, "提现成功", null);
- for (SysAmountAuditingHistory sysAmountAuditingHistory : listAll) {
- if ("1".equals(sysAmountAuditingHistory.getAuditingStatus())) {
- dto1.setProcessingStatusFlag(true);
- dto1.setProcessingDate(sysAmountAuditingHistory.getCreateTime());
- } else if ("2".equals(sysAmountAuditingHistory.getAuditingStatus())) {
- dto2.setProcessingStatusFlag(true);
- dto2.setProcessingDate(sysAmountAuditingHistory.getCreateTime());
- } else if ("3".equals(sysAmountAuditingHistory.getAuditingStatus())) {
- dto3 = new WithdrawalDetalsRecordDto("3", true, "提现失败", sysAmountAuditingHistory.getCreateTime());
- } else if ("4".equals(sysAmountAuditingHistory.getAuditingStatus())) {
- dto4.setProcessingStatusFlag(true);
- dto4.setProcessingDate(sysAmountAuditingHistory.getCreateTime());
- }
- }
- recordList.add(dto1);
- recordList.add(dto2);
- if (dto3 != null) {
- recordList.add(dto3);
- withdrawalDetalsDto.setRejectReason(audi.getRejectReason() == null ? "" : audi.getRejectReason());
- } else {
- //add by hxl 2024-07-09 添加银行回单的路径
- if (audi != null && StringUtils.isNotBlank(audi.getPicId())) {
- //add by hxl 2024-08-15 屏蔽银行回单的路径
- // InsUploadFiles insUploadFiles = insUploadFilesMapper.selectById(audi.getPicId());
- // withdrawalDetalsDto.setBankReceipt(insUploadFiles==null?"":insUploadFiles.getUrl());
- }
- recordList.add(dto4);
- }
- withdrawalDetalsDto.setRecord(recordList);
- }
- return withdrawalDetalsDto;
- }
- @Override
- public OrderDetalsDto findOrderDetailById(String subOrderId) {
- return null;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/21 18:27
- * @Description: 查看退款详情
- */
- @Override
- public RefundDetalsDto findRefundDetailById(String id) {
- //id为历史表的id
- //通过历史记录表查询数据
- SysUserAccountHistory his = sysUserAccountHistoryService.getById(id);
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String dateStr = sdf.format(his.getCreateTime());
- return new RefundDetalsDto(dateStr, his.getAmount(), his.getAuditiingId());
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/30 15:28
- * @Description: 查询车险明细
- */
- @Override
- public MyIncomeAndExpensesNewPageVo<ExportExpenditureTypeDetalsDto> findMyInsuranceByUserId(MyInsuranceQueryDto myInsuranceQueryDto) {
- Page<ExportExpenditureTypeDetalsDto> page = new Page<>(myInsuranceQueryDto.getPageNum(),
- myInsuranceQueryDto.getPageSize());
- List<String> userList = getStrings(myInsuranceQueryDto);
- //赋值开始和结束时间
- if (StringUtils.isNotBlank(myInsuranceQueryDto.getStartDate())) {
- myInsuranceQueryDto.setStartDate(myInsuranceQueryDto.getStartDate() + " 00:00:00");
- }
- if (StringUtils.isNotBlank(myInsuranceQueryDto.getEndDate())) {
- myInsuranceQueryDto.setEndDate(myInsuranceQueryDto.getEndDate() + " 23:59:59");
- }
- //如果是电销组长,统计电销组长和他组员的信息
- SysUserBaseVO sysUserBaseVO = sysUserService.selectUserById(myInsuranceQueryDto.getUserId());
- SysUser user = sysUserService.getById(myInsuranceQueryDto.getUserId());
- SysDept dept = sysDeptService.getById(user.getDeptId());
- if ("72".equals(sysUserBaseVO.getRoleId()) && "3".equals(dept.getManagementSource())) {
- userList = sysUserService.getGroupByUserId(myInsuranceQueryDto.getUserId());
- }
- Page<ExportExpenditureTypeDetalsDto> pageList = insFeeOrderNewService.findMyInsuranceByUserId(page, myInsuranceQueryDto, userList);
- boolean b = feeDisplayService.setCarInsurance(pageList.getRecords());
- return new MyIncomeAndExpensesNewPageVo<>(myInsuranceQueryDto.getPageNum(), myInsuranceQueryDto.getPageSize(), pageList.getTotal(),
- pageList.getPages()
- , pageList.getRecords(), b);
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/30 17:59
- * @Description: 获取渠道团队长管理的下级人
- */
- private List<String> getStrings(MyInsuranceQueryDto myInsuranceQueryDto) {
- //查询当前管理的代理人信息
- LambdaQueryWrapper<SysUser> lqw = new LambdaQueryWrapper<>();
- lqw.eq(SysUser::getStatus, 1);
- lqw.eq(SysUser::getOperatorCode, myInsuranceQueryDto.getUserId());
- List<SysUser> users = sysUserMapper.selectList(lqw);
- List<String> userList = new ArrayList<>();
- if (users != null && users.size() > 0) {
- for (SysUser user : users) {
- userList.add(user.getId());
- }
- }
- return userList;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/30 18:05
- * @Description: 查询推广费分页
- */
- @Override
- public BasePageResult<ExportExpenditureTypeDetalsTGDto> findMyInsuranceTGByUserId(MyInsuranceTgQueryDto myInsuranceTgQueryDto) {
- Page<ExportExpenditureTypeDetalsTGDto> page = new Page<>(myInsuranceTgQueryDto.getPageNum(),
- myInsuranceTgQueryDto.getPageSize());
- //赋值开始和结束时间
- if (StringUtils.isNotBlank(myInsuranceTgQueryDto.getStartDate())) {
- myInsuranceTgQueryDto.setStartDate(myInsuranceTgQueryDto.getStartDate() + " 00:00:00");
- }
- if (StringUtils.isNotBlank(myInsuranceTgQueryDto.getEndDate())) {
- myInsuranceTgQueryDto.setEndDate(myInsuranceTgQueryDto.getEndDate() + " 23:59:59");
- }
- //如果是电销组长,统计电销组长和他组员的信息
- SysUserBaseVO sysUserBaseVO = sysUserService.selectUserById(myInsuranceTgQueryDto.getUserId());
- SysUser user = sysUserService.getById(myInsuranceTgQueryDto.getUserId());
- SysDept dept = sysDeptService.getById(user.getDeptId());
- if ("72".equals(sysUserBaseVO.getRoleId()) && "3".equals(dept.getManagementSource())) {
- myInsuranceTgQueryDto.setGroupFlag(true);
- }
- Page<ExportExpenditureTypeDetalsTGDto> pageList = insFeeOrderNewService.findMyInsuranceTGByUserId(page, myInsuranceTgQueryDto);
- BasePageResult<ExportExpenditureTypeDetalsTGDto> result = new BasePageResult<>(myInsuranceTgQueryDto.getPageNum(), myInsuranceTgQueryDto.getPageSize(), pageList.getTotal(),
- pageList.getPages()
- , pageList.getRecords());
- return result;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/30 18:05
- * @Description: 查询车险导出数据
- */
- @Override
- public List<ExportExpenditureTypeDetalsDto> exportMyInsuranceByUserId(MyInsuranceQueryDto myInsuranceQueryDto) {
- List<String> userList = getStrings(myInsuranceQueryDto);
- //赋值开始和结束时间
- if (StringUtils.isNotBlank(myInsuranceQueryDto.getStartDate())) {
- myInsuranceQueryDto.setStartDate(myInsuranceQueryDto.getStartDate() + " 00:00:00");
- }
- if (StringUtils.isNotBlank(myInsuranceQueryDto.getEndDate())) {
- myInsuranceQueryDto.setEndDate(myInsuranceQueryDto.getEndDate() + " 23:59:59");
- }
- //如果是电销组长,统计电销组长和他组员的信息
- SysUserBaseVO sysUserBaseVO = sysUserService.selectUserById(myInsuranceQueryDto.getUserId());
- SysUser user = sysUserService.getById(myInsuranceQueryDto.getUserId());
- SysDept dept = sysDeptService.getById(user.getDeptId());
- if ("72".equals(sysUserBaseVO.getRoleId()) && "3".equals(dept.getManagementSource())) {
- userList = sysUserService.getGroupByUserId(myInsuranceQueryDto.getUserId());
- }
- return insFeeOrderNewService.exportMyInsuranceByUserId(myInsuranceQueryDto, userList);
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/30 18:05
- * @Description: 查询推广导出数据
- */
- @Override
- public List<ExportExpenditureTypeDetalsTGDto> exportMyInsuranceTGByUserId(MyInsuranceTgQueryDto myInsuranceTgQueryDto) {
- //赋值开始和结束时间
- if (StringUtils.isNotBlank(myInsuranceTgQueryDto.getStartDate())) {
- myInsuranceTgQueryDto.setStartDate(myInsuranceTgQueryDto.getStartDate() + " 00:00:00");
- }
- if (StringUtils.isNotBlank(myInsuranceTgQueryDto.getEndDate())) {
- myInsuranceTgQueryDto.setEndDate(myInsuranceTgQueryDto.getEndDate() + " 23:59:59");
- }
- return insFeeOrderNewService.exportMyInsuranceTGByUserId(myInsuranceTgQueryDto);
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/7/1 9:02
- * @Description: 查询收支明细数据
- */
- @Override
- public MyIncomeAndExpensesNewPageVo<ExportExpenditureTypeDetalsSZDto> findMyIncomeAndExpensesNewByUserId(MyCollectInAdvanceQueryNewDto myCollectInAdvanceQueryNewDto) {
- //校验数据
- myCollectInAdvanceQueryNewDto = checkData(myCollectInAdvanceQueryNewDto);
- Page<ExportExpenditureTypeDetalsSZDto> page = new Page<>(myCollectInAdvanceQueryNewDto.getPageNum(), myCollectInAdvanceQueryNewDto.getPageSize());
- //判断如果是电销组长查询组员数据
- SysUserBaseVO sysUserBaseVO = sysUserService.selectUserById(myCollectInAdvanceQueryNewDto.getUserId());
- SysUser user = sysUserService.getById(myCollectInAdvanceQueryNewDto.getUserId());
- SysDept dept = sysDeptService.getById(user.getDeptId());
- //如果是电销组长,将组员的数据算进来
- if ("72".equals(sysUserBaseVO.getRoleId()) && "3".equals(dept.getManagementSource())) {
- myCollectInAdvanceQueryNewDto.setGroupFlag(true);
- }
- Page<ExportExpenditureTypeDetalsSZDto> orderVoPage = sysUserAccountHistoryService.findMyIncomeAndExpensesAmountNewByUserId(page, myCollectInAdvanceQueryNewDto);
- List<ExportExpenditureTypeDetalsSZDto> recordsNew = new ArrayList<>();
- //格式化数据
- if (orderVoPage.getRecords() != null && orderVoPage.getRecords().size() > 0) {
- for (ExportExpenditureTypeDetalsSZDto dto : orderVoPage.getRecords()) {
- //车险的显示且收入
- if ("1".equals(dto.getBusinessSegmentsType()) && "2".equals(dto.getIncomeAndExpensesType())) {
- if ("4".equals(dto.getTransactionType())) {
- dto.setTransactionType("1");
- } else if ("3".equals(dto.getTransactionType())) {
- dto.setTransactionType("2");
- }
- dto.setIncomeAndExpensesType("1");
- //退款 且退款
- } else if ("2".equals(dto.getBusinessSegmentsType()) && "2".equals(dto.getIncomeAndExpensesType())) {
- dto.setIncomeAndExpensesType("1");
- dto.setTransactionType("4");
- //退款设置为空
- dto.setAuditingStatus("");
- //提现
- } else if ("6".equals(dto.getTransactionType()) && "1".equals(dto.getIncomeAndExpensesType())) {
- dto.setIncomeAndExpensesType("2");
- dto.setTransactionType("3");
- }
- recordsNew.add(dto);
- }
- }
- boolean b = feeDisplayService.setWithdrawalsPc(recordsNew);
- orderVoPage.setRecords(recordsNew);
- return new MyIncomeAndExpensesNewPageVo<>(myCollectInAdvanceQueryNewDto.getPageNum(), myCollectInAdvanceQueryNewDto.getPageSize(), orderVoPage.getTotal(),
- orderVoPage.getPages()
- , orderVoPage.getRecords(), b);
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/7/1 9:06
- * @Description: 校验数据
- */
- private static MyCollectInAdvanceQueryNewDto checkData(MyCollectInAdvanceQueryNewDto myCollectInAdvanceQueryNewDto) {
- if (StringUtils.isBlank(myCollectInAdvanceQueryNewDto.getUserId())) {
- throw new SystemException("用户id-userId不能为空");
- }
- //判断时间类型 1.一周内 2. 一月内 3. 三月内 4. 三月内
- HashMap<String, String> dateMap = getDateMapByType(myCollectInAdvanceQueryNewDto.getDateQueryType(), myCollectInAdvanceQueryNewDto.getStartDate(), myCollectInAdvanceQueryNewDto.getEndDate());
- myCollectInAdvanceQueryNewDto.setStartDate(dateMap.get("startDate"));
- myCollectInAdvanceQueryNewDto.setEndDate(dateMap.get("endDate"));
- if ("0".equals(myCollectInAdvanceQueryNewDto.getBusinessSegmentsType())) {
- myCollectInAdvanceQueryNewDto.setBusinessSegmentsType(null);
- }
- if ("0".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
- myCollectInAdvanceQueryNewDto.setTransactionType(null);
- }
- if ("0".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType())) {
- myCollectInAdvanceQueryNewDto.setIncomeAndExpensesType(null);
- }
- // 1为车险板块 1 收入时
- if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getBusinessSegmentsType()) && StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType()) && "1".equals(myCollectInAdvanceQueryNewDto.getBusinessSegmentsType()) && "1".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType())) {
- //判断收入类型 1 收入
- if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) && "3".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
- throw new SystemException("收入类型不能选择提现类型");
- }
- }
- if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType()) && "2".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType())) {
- //判断支出类型
- if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) && !"3".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
- throw new SystemException("支出类型不能选择(手续+跟单)或者手续费、退款类型");
- }
- }
- if ((StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getBusinessSegmentsType()) && StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType()) && "2".equals(myCollectInAdvanceQueryNewDto.getBusinessSegmentsType()) && "1".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType()))
- ||
- (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType()) && ("2".equals(myCollectInAdvanceQueryNewDto.getBusinessSegmentsType())))) {
- //判断退款类型
- if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) && !"4".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
- throw new SystemException("退款板块只能选择退款类型");
- }
- }
- //处理 手续费+跟单、推广费类型转换
- if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) && "2".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
- myCollectInAdvanceQueryNewDto.setTransactionType("3");
- } else if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) && "1".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
- myCollectInAdvanceQueryNewDto.setTransactionType("4");
- } else if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) && "4".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
- myCollectInAdvanceQueryNewDto.setTransactionType("5");
- } else if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) && "3".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
- myCollectInAdvanceQueryNewDto.setTransactionType("6");
- }
- //处理收入和支出类型转换
- if (myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType() != null && "0".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType())) {
- myCollectInAdvanceQueryNewDto.setIncomeAndExpensesType(null);
- } else if (myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType() != null && "1".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType())) {
- myCollectInAdvanceQueryNewDto.setIncomeAndExpensesType("2");
- } else if (myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType() != null && "2".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType())) {
- myCollectInAdvanceQueryNewDto.setIncomeAndExpensesType("1");
- }
- return myCollectInAdvanceQueryNewDto;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/7/1 9:03
- * @Description: 查询导出收支明细
- */
- @Override
- public List<ExportExpenditureTypeDetalsSZDto> exportMyIncomeAndExpensesNewByUserId(MyCollectInAdvanceQueryNewDto myCollectInAdvanceQueryNewDto) {
- //校验数据
- myCollectInAdvanceQueryNewDto = checkData(myCollectInAdvanceQueryNewDto);
- String userId = myCollectInAdvanceQueryNewDto.getUserId();
- //添加预收明细 如果是渠道团队长查询管理下级的出单员
- SysUserBaseVO sysUserBaseVO = sysUserService.selectUserById(userId);
- SysUser user = sysUserService.getById(userId);
- SysDept dept = sysDeptService.getById(user.getDeptId());
- //如果是电销组长,将组员的数据算进来
- if ("72".equals(sysUserBaseVO.getRoleId()) && "3".equals(dept.getManagementSource())) {
- myCollectInAdvanceQueryNewDto.setGroupFlag(true);
- }
- //查询数据
- List<ExportExpenditureTypeDetalsSZDto> list = sysUserAccountHistoryService.exportMyIncomeAndExpensesAmountNewByUserId(myCollectInAdvanceQueryNewDto);
- List<ExportExpenditureTypeDetalsSZDto> recordsNew = new ArrayList<>();
- //格式化数据
- if (list != null && list.size() > 0) {
- for (ExportExpenditureTypeDetalsSZDto dto : list) {
- //车险的显示且收入
- if ("1".equals(dto.getBusinessSegmentsType()) && "2".equals(dto.getIncomeAndExpensesType())) {
- if ("4".equals(dto.getTransactionType())) {
- dto.setTransactionType("手续费+跟单");
- } else if ("3".equals(dto.getTransactionType())) {
- dto.setTransactionType("推广");
- }
- dto.setIncomeAndExpensesType("收入");
- dto.setBusinessSegmentsType("车险");
- //退款 且退款
- } else if ("2".equals(dto.getBusinessSegmentsType()) && "2".equals(dto.getIncomeAndExpensesType())) {
- dto.setIncomeAndExpensesType("收入");
- dto.setTransactionType("退款");
- //退款设置为空
- dto.setAuditingStatus("");
- dto.setBusinessSegmentsType("退款");
- //提现
- } else if ("6".equals(dto.getTransactionType()) && "1".equals(dto.getIncomeAndExpensesType())) {
- dto.setIncomeAndExpensesType("支出");
- dto.setTransactionType("提现");
- dto.setBusinessSegmentsType("车险");
- }
- recordsNew.add(dto);
- }
- }
- return recordsNew;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/30 18:55
- * @Description: 查询页面总金额
- */
- @Override
- public MySumAmountDto findMyAmount(MySumAmountQueryDto mySumAmountQueryDto) {
- //赋值开始和结束时间
- if (StringUtils.isNotBlank(mySumAmountQueryDto.getStartDate())) {
- mySumAmountQueryDto.setStartDate(mySumAmountQueryDto.getStartDate() + " 00:00:00");
- }
- if (StringUtils.isNotBlank(mySumAmountQueryDto.getEndDate())) {
- mySumAmountQueryDto.setEndDate(mySumAmountQueryDto.getEndDate() + " 23:59:59");
- }
- String userId = mySumAmountQueryDto.getUserId();
- //添加预收明细 如果是渠道团队长查询管理下级的出单员
- SysUserBaseVO sysUserBaseVO = sysUserService.selectUserById(userId);
- SysUser user = sysUserService.getById(userId);
- SysDept dept = sysDeptService.getById(user.getDeptId());
- String deptId = "";
- //出单员是19 且是渠道的话,给渠道团队长
- if ("21".equals(sysUserBaseVO.getRoleId()) && "1".equals(dept.getManagementSource())) {
- deptId = dept.getId();
- mySumAmountQueryDto.setDeptId(deptId);
- }
- //如果是电销组长,将组员的数据算进来
- if ("72".equals(sysUserBaseVO.getRoleId()) && "3".equals(dept.getManagementSource())) {
- mySumAmountQueryDto.setGroupFlag(true);
- }
- //查询预收和实收的总金额
- mySumAmountQueryDto.setAuditstatus("0");
- BigDecimal ysAmount = insFeeOrderNewService.findMyAmountYSOrSSCXAmount(mySumAmountQueryDto);
- mySumAmountQueryDto.setAuditstatus("1");
- BigDecimal ssAmount = insFeeOrderNewService.findMyAmountYSOrSSCXAmount(mySumAmountQueryDto);
- BigDecimal ysAndSsAmount = ysAmount.add(ssAmount);
- mySumAmountQueryDto.setAuditstatus("0");
- BigDecimal ysTGAmount = insFeeOrderNewService.findMyAmountYSOrSSTGAmount(mySumAmountQueryDto);
- mySumAmountQueryDto.setAuditstatus("1");
- BigDecimal ssTGAmount = insFeeOrderNewService.findMyAmountYSOrSSTGAmount(mySumAmountQueryDto);
- BigDecimal ysAndSsTGAmount = ysTGAmount.add(ssTGAmount);
- // 已提现金额 查询历史表中的审核状态为3的数据
- BigDecimal ysTXAmount = insFeeOrderNewService.findMyAmountYTXmount(mySumAmountQueryDto.getUserId(), "3",mySumAmountQueryDto.getGroupFlag());
- // 可提现金额 查询账户的钱
- mySumAmountQueryDto.setAuditstatus("1");
- SysUserAccount sysUserAccountEntity = baseMapper.getById(mySumAmountQueryDto.getUserId());
- // 提现中
- BigDecimal txzTXAmount = insFeeOrderNewService.findMyAmountYTXmount(mySumAmountQueryDto.getUserId(), "2",mySumAmountQueryDto.getGroupFlag());
- // 可提现
- BigDecimal ssKTAmount = BigDecimal.ZERO;
- //if(mySumAmountQueryDto.getGroupFlag()){
- // ssKTAmount = baseMapper.getGroupById(mySumAmountQueryDto.getUserId());
- //}else {
- if (sysUserAccountEntity != null) {
- ssKTAmount = sysUserAccountEntity.getSumAmount() == null ? BigDecimal.ZERO : sysUserAccountEntity.getSumAmount();
- }
- //}
- //总的 = 已提现金额+ 可提现金额 + 提现中
- BigDecimal sumAmount = ysTXAmount.add(ssKTAmount).add(txzTXAmount);
- return new MySumAmountDto(ysAmount, ssAmount, ysAndSsAmount, ysTGAmount, ssTGAmount, ysAndSsTGAmount, ysTXAmount, ssKTAmount, sumAmount, txzTXAmount);
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/9/12 9:46
- * @Description: 判断渠道金额
- */
- private void judgeAmount(BigDecimal amount, String userId) {
- if (amount == null) {
- throw new SystemException("提现金额不能为空");
- } else if (amount.compareTo(BigDecimal.ZERO) <= 0) {
- throw new SystemException("提现金额不能小于0");
- }
- SysUser sysUser = sysUserMapper.selectById(userId);
- SysDept dept = sysDeptService.getById(sysUser.getDeptId());
- //渠道
- if("1".equals(dept.getManagementSource())){
- BigDecimal remainder = amount.remainder(new BigDecimal("100"));
- if(remainder.compareTo(BigDecimal.ZERO) > 0){
- throw new SystemException("提现金额必须为100的倍数");
- }
- }
- }
- }
|