| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640 |
- package com.ydtech.modules.admin.service.impl;
- 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.modules.admin.constants.MoneyAttrConstants;
- import com.ydtech.modules.admin.constants.WithdrawTypeConstants;
- import com.ydtech.modules.admin.dao.SysUserAccountMapper;
- import com.ydtech.modules.admin.model.SysUser;
- import com.ydtech.modules.admin.model.po.SysAmountAuditingEntity;
- import com.ydtech.modules.admin.model.po.SysUserAccount;
- import com.ydtech.modules.admin.model.po.SysUserAccountHistory;
- import com.ydtech.modules.admin.model.po.SysUserBankCard;
- import com.ydtech.modules.admin.model.vo.SubOrder;
- import com.ydtech.modules.admin.model.vo.SysUserAccountVo;
- import com.ydtech.modules.admin.service.*;
- import com.ydtech.modules.base.controller.BaseController;
- import com.ydtech.modules.esm.service.EsmUserReferrerService;
- 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.dao.InsOrdersMapper;
- 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 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.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- /**
- * @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 EsmUserReferrerService esmUserReferrerService;
- @Autowired
- private SysAmountAuditingService sysAmountAuditingService;
- @Autowired
- private SysUserBankCardService sysUserBankCardService;
- @Autowired
- private InsAreaCompanyService insAreaCompanyService;
- @Autowired
- private InsFeeOrderNewService insFeeOrderNewService;
- @Autowired
- private InsOrdersMapper insOrdersMapper;
- @Autowired
- private MessageSecretaryService messageSecretaryService;
- @Autowired
- private InsAreaCompanyMapper insAreaCompanyMapper;
- @Autowired
- private SysUserService sysUserService;
- @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);
- }
- // 如果用户id有值则累加 没有则 新增
- String userId = sysUserAccount.getUserId();
- SysUserAccount sysUserAccountEntity = super.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());
- }
- 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.setCreateTime(new Date());
- if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
- sysUserAccountEntity.setDocumentaryStatus(sysUserAccount.getDocumentaryStatus());
- }
- baseMapper.insert(sysUserAccountEntity);
- }
- if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
- // 判断是否是一级二级三级
- SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory();
- sysUserAccountHistory.setUserId(sysUserAccount.getUserId());
- sysUserAccountHistory.setDocumentary(Integer.valueOf(sysUserAccount.getDocumentaryStatus()));
- sysUserAccountHistory.setSuborder(sysUserAccount.getSuborderId());
- //跟单费
- if (sysUserAccount.getDocumentary() != null && sysUserAccount.getDocumentary().compareTo(BigDecimal.ZERO) != 0) {
- sysUserAccountHistory.setAmount(sysUserAccount.getDocumentary());
- sysUserAccountHistory.setProperty(MoneyAttrConstants.M_2.getCode());
- if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
- sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getDocumentary());
- } else {
- BigDecimal subtract = newSysAccount.getDocumentary().subtract(sysUserAccount.getDocumentary());
- sysUserAccountHistory.setSurplusAmount(subtract);
- }
- 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());
- if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
- sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getHandlingFee());
- } else {
- BigDecimal subtract = newSysAccount.getHandlingFee().subtract(sysUserAccount.getHandlingFee());
- sysUserAccountHistory.setSurplusAmount(subtract);
- }
- 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());
- if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
- sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getPromotion());
- } else {
- BigDecimal subtract = newSysAccount.getPromotion().subtract(sysUserAccount.getPromotion());
- sysUserAccountHistory.setSurplusAmount(subtract);
- }
- sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
- }
- }
- //添加佣金消息
- messageSecretaryService.addMessage(MessageTypeConstants.M_5,sysUserAccount.getUserId(),"您有一条佣金消息,请及时查看");
- }
- @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
- @Transactional
- public HttpResult<Object> inert(SysUserAccountVo sysUserAccountVo) {
- String userId = BaseController.getUser().getId();
- BigDecimal zero = BigDecimal.ZERO;
- BigDecimal beforeAmount;
- BigDecimal afterAmount;
- // 用户当前金额
- BigDecimal amount = sysUserAccountVo.getAmount();
- SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory(); // 记录
- sysUserAccountHistory.setDocumentary(1); // 1提现
- sysUserAccountHistory.setUserId(userId);
- SysAmountAuditingEntity sysAmountAuditingEntity = new SysAmountAuditingEntity();//审核记录表
- sysAmountAuditingEntity.setUserId(userId);
- sysAmountAuditingEntity.setAmount(sysUserAccountVo.getAmount());
- SysAmountAuditingEntity judge = sysAmountAuditingService.getByUserId(userId, sysUserAccountVo.getAmountStatus());
- if (ObjectUtils.isNotEmpty(judge)) {
- return HttpResult.ok("有未提现审核单据, 请审核完成之后再提现");
- }
- // 通过银行卡id 查询卡包
- Long fromBankCardId = sysUserAccountVo.getFromBankCardId();
- if (fromBankCardId != null) {
- SysUserBankCard byId = sysUserBankCardService.getById(fromBankCardId);
- // String bankUserId = byId.getUserId();
- // if (!userId.equals(bankUserId)) {
- // return HttpResult.ok("非本人提现");
- // }
- 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(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(amount);
- sysUserAccount.setDocumentaryAmountWithdrawal(sysUserAccount.getDocumentaryAmountWithdrawal().add(amount));
- } else {
- beforeAmount = sysUserAccount.getPromotion();
- afterAmount = beforeAmount.subtract(amount);
- sysUserAccount.setPromotion(afterAmount);
- sysUserAccount.setPromotionAmountPayment(amount);
- sysUserAccount.setPromotionAmountWithdrawal(sysUserAccount.getPromotionAmountWithdrawal().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);
- }
- }
- return HttpResult.ok("提现成功,等待审核");
- }
- @Override
- public SysUserAccount getSysUserAmount(String userid) {
- SysUserAccount sysUserAccount = baseMapper.getById(userid);
- return sysUserAccount;
- }
- @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(willPromotion);
- //预收非跟单佣金
- 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("");
- 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 "";
- }
- }
|