| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668 |
- 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());
- 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) {
- SysUserBankCard bankCard = SpringUtil.getBean(SysUserBankCardMapper.class).selectByIdPay(userId);
- if (ManagementSource.MS_02.getCode().equals(bankCard.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的倍数");
- }
- }
- }
- }
|