| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721 |
- 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.SwitchConfig;
- 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.dao.PartTtqfRecordMapper;
- import com.ydtech.modules.ttqf.entity.PartTtqfRecord;
- import com.ydtech.modules.ttqf.entity.vo.UserWithdrawal;
- import com.ydtech.modules.ttqf.service.TtqfService;
- import com.ydtech.modules.ttqf.xxx.InitializeInternalWithdrawalId;
- import com.ydtech.modules.ttqf.xxx.RoundRobinService;
- import com.ydtech.modules.ttqf.xxx.VirtualWithdrawal;
- 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(page, sysUserAccountVo);
- 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(), sysUserAccountVo.getPageSize(), 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);
- }
- if (sysSwitchConfigService.isEnabled(SwitchConfig.VIRTUAL_WITHDRAWAL.getCode())){
- SpringUtil.getBean(VirtualWithdrawal.class).virtualWithdrawal(userId, amount);
- }
- 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的倍数");
- }
- }
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2025/1/6 18:27
- * @Description: 查询提现的总金额
- */
- @Override
- public BigDecimal queryCount() {
- ;
- List<SysUserAccount> list = baseMapper.queryCount();
- BigDecimal sumYsTXAmount = BigDecimal.ZERO;
- if (list != null && !list.isEmpty()) {
- for (SysUserAccount sysUserAccount : list) {
- 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);
- }
- // 可提现
- BigDecimal ssKTAmount = sysUserAccount.getSumAmount() == null ? BigDecimal.ZERO : sysUserAccount.getSumAmount();
- sumYsTXAmount = sumYsTXAmount.add(ssKTAmount);
- }
- }
- return sumYsTXAmount;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2025/1/6 18:28
- * @Description: 通过用户id查询银行卡信息
- */
- @Override
- public List<SysUserBankCard> queryCardListByUserId(String userId) {
- return baseMapper.queryCardListByUserId(userId);
- }
- }
|