|
@@ -1,30 +1,32 @@
|
|
|
package com.jzg.quotation.summary.service.impl;
|
|
package com.jzg.quotation.summary.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.jzg.commons.core.base.BaseController;
|
|
import com.jzg.commons.core.base.BaseController;
|
|
|
import com.jzg.commons.core.base.StateResult;
|
|
import com.jzg.commons.core.base.StateResult;
|
|
|
import com.jzg.commons.core.page.HttpResult;
|
|
import com.jzg.commons.core.page.HttpResult;
|
|
|
|
|
+import com.jzg.commons.entity.account.po.SysUserAccountIncomeLog;
|
|
|
import com.jzg.commons.entity.dto.FeeAuditParam;
|
|
import com.jzg.commons.entity.dto.FeeAuditParam;
|
|
|
import com.jzg.commons.entity.dto.VerifyOrderParam;
|
|
import com.jzg.commons.entity.dto.VerifyOrderParam;
|
|
|
import com.jzg.commons.entity.orders.po.*;
|
|
import com.jzg.commons.entity.orders.po.*;
|
|
|
import com.jzg.commons.entity.orders.vo.AuditCostInfoVo;
|
|
import com.jzg.commons.entity.orders.vo.AuditCostInfoVo;
|
|
|
import com.jzg.commons.entity.orders.vo.FeeAuditVo;
|
|
import com.jzg.commons.entity.orders.vo.FeeAuditVo;
|
|
|
import com.jzg.commons.entity.po.InsFeeOrders;
|
|
import com.jzg.commons.entity.po.InsFeeOrders;
|
|
|
|
|
+import com.jzg.commons.entity.po.SysUser;
|
|
|
import com.jzg.commons.entity.po.SysUserAccount;
|
|
import com.jzg.commons.entity.po.SysUserAccount;
|
|
|
import com.jzg.commons.entity.po.SysUserJzgInfo;
|
|
import com.jzg.commons.entity.po.SysUserJzgInfo;
|
|
|
import com.jzg.commons.entity.quote.vo.aggregated.QuoteEchoVo;
|
|
import com.jzg.commons.entity.quote.vo.aggregated.QuoteEchoVo;
|
|
|
-import com.jzg.commons.entity.vo.AgreementInfoVo;
|
|
|
|
|
-import com.jzg.commons.entity.vo.AgreementVo;
|
|
|
|
|
-import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
|
|
|
|
|
-import com.jzg.commons.entity.vo.PtlAgreementCostTypeVo;
|
|
|
|
|
|
|
+import com.jzg.commons.entity.vo.*;
|
|
|
import com.jzg.commons.exception.SystemException;
|
|
import com.jzg.commons.exception.SystemException;
|
|
|
import com.jzg.commons.util.AssertionUtils;
|
|
import com.jzg.commons.util.AssertionUtils;
|
|
|
import com.jzg.commons.util.PDFUtil;
|
|
import com.jzg.commons.util.PDFUtil;
|
|
|
import com.jzg.commons.util.StringUtils;
|
|
import com.jzg.commons.util.StringUtils;
|
|
|
|
|
+import com.jzg.commons.util.idgen.IdGenerate;
|
|
|
import com.jzg.quotation.commons.client.OrgClient;
|
|
import com.jzg.quotation.commons.client.OrgClient;
|
|
|
import com.jzg.quotation.commons.client.PlatformClient;
|
|
import com.jzg.quotation.commons.client.PlatformClient;
|
|
|
import com.jzg.quotation.summary.mapper.InsFeeAuditMapper;
|
|
import com.jzg.quotation.summary.mapper.InsFeeAuditMapper;
|
|
@@ -37,6 +39,7 @@ import org.redisson.api.RBucket;
|
|
|
import org.redisson.api.RedissonClient;
|
|
import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
@@ -184,9 +187,8 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
|
|
|
AssertionUtils.isFail(true, "订单已审核!");
|
|
AssertionUtils.isFail(true, "订单已审核!");
|
|
|
}
|
|
}
|
|
|
String userName = baseController.getUserName();
|
|
String userName = baseController.getUserName();
|
|
|
- if (userName.equals(audit.getReceiveUser())) {
|
|
|
|
|
- AssertionUtils.isFail(true, "已放弃订单审核任务!");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ AssertionUtils.isFail(!userName.equals(audit.getReceiveUser()), "未领取审核任务!");
|
|
|
|
|
+// AssertionUtils.isFail(!userName.equals(audit.getReceiveUser()), "已放弃订单审核任务!");
|
|
|
|
|
|
|
|
LambdaUpdateWrapper<InsFeeAudit> wrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<InsFeeAudit> wrapper = new LambdaUpdateWrapper<>();
|
|
|
wrapper.set(InsFeeAudit::getReceiveUser,null);
|
|
wrapper.set(InsFeeAudit::getReceiveUser,null);
|
|
@@ -274,17 +276,24 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
|
|
|
if (!userName.equals(audit.getReceiveUser())) {
|
|
if (!userName.equals(audit.getReceiveUser())) {
|
|
|
AssertionUtils.isFail(true, "订单已被"+audit.getReceiveUser()+"领取返回待审核订单列表!");
|
|
AssertionUtils.isFail(true, "订单已被"+audit.getReceiveUser()+"领取返回待审核订单列表!");
|
|
|
}
|
|
}
|
|
|
|
|
+ InsFeeOrders feeOrders = null;
|
|
|
|
|
+ SysUserAccount userAccount = null,distributor1 = null,distributor2 = null,distributor3 = null;
|
|
|
if(param.getAuditStatus().equals(1)){
|
|
if(param.getAuditStatus().equals(1)){
|
|
|
|
|
+ List<SysUserAccountIncomeLog> incomeLogs = new ArrayList<>();
|
|
|
StateResult stateFailResult = auditStateListener.statusChange(AuditState.AuditStateEnum.SUCCESS_AUDIT,audit.getAuditStatus()+"");
|
|
StateResult stateFailResult = auditStateListener.statusChange(AuditState.AuditStateEnum.SUCCESS_AUDIT,audit.getAuditStatus()+"");
|
|
|
audit.setAuditStatus(stateFailResult.getCurrentState());
|
|
audit.setAuditStatus(stateFailResult.getCurrentState());
|
|
|
|
|
|
|
|
// 更新用户账户
|
|
// 更新用户账户
|
|
|
- InsFeeOrders feeOrders = feeOrdersService.getById(param.getOrderNo());
|
|
|
|
|
- HttpResult<SysUserAccount> result = orgClient.accountGet(orders.getRealQuoteUserId(), baseController.getToken());
|
|
|
|
|
|
|
+ feeOrders = feeOrdersService.getById(param.getOrderNo());
|
|
|
|
|
+ HttpResult<SysUser> sysUserResult = orgClient.getUserOnlyIdByMobile(orders.getRealQuoteUserId(), baseController.getToken());
|
|
|
|
|
+ HttpResult<SysUserAccount> result = orgClient.accountGet(sysUserResult.getData().getId(), baseController.getToken());
|
|
|
AssertionUtils.isFail(result.getCode() != 200,"获取用户账户失败!");
|
|
AssertionUtils.isFail(result.getCode() != 200,"获取用户账户失败!");
|
|
|
- SysUserAccount userAccount = result.getData();
|
|
|
|
|
|
|
+ userAccount = result.getData();
|
|
|
if(Objects.isNull(userAccount)){
|
|
if(Objects.isNull(userAccount)){
|
|
|
- userAccount.setUserId(orders.getRealQuoteUserId());
|
|
|
|
|
|
|
+ userAccount = new SysUserAccount();
|
|
|
|
|
+ // 新建账户
|
|
|
|
|
+ userAccount.setId(IdGenerate.nextId());
|
|
|
|
|
+ userAccount.setUserId(sysUserResult.getData().getId());
|
|
|
userAccount.setSumAmount(feeOrders.getTotalReceivablePremium());
|
|
userAccount.setSumAmount(feeOrders.getTotalReceivablePremium());
|
|
|
userAccount.setSumAmountUnpaid(feeOrders.getTotalReceivablePremium());
|
|
userAccount.setSumAmountUnpaid(feeOrders.getTotalReceivablePremium());
|
|
|
}else{
|
|
}else{
|
|
@@ -292,34 +301,43 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
|
|
|
userAccount.setSumAmountUnpaid(feeOrders.getTotalReceivablePremium().add(userAccount.getSumAmount()));
|
|
userAccount.setSumAmountUnpaid(feeOrders.getTotalReceivablePremium().add(userAccount.getSumAmount()));
|
|
|
}
|
|
}
|
|
|
orgClient.saveOrUpdate(userAccount, baseController.getToken());
|
|
orgClient.saveOrUpdate(userAccount, baseController.getToken());
|
|
|
|
|
+
|
|
|
|
|
+ // 进入应收表
|
|
|
|
|
+ List<String> orderNos = new ArrayList<>();
|
|
|
|
|
+ orderNos.add(audit.getOrderNo());
|
|
|
|
|
+ JSONObject requestData = new JSONObject();
|
|
|
|
|
+ requestData.put("orderNos",orderNos);
|
|
|
|
|
+ HttpResult httpResult = orgClient.addReceivable(requestData, baseController.getToken());
|
|
|
|
|
+ AssertionUtils.isFail(httpResult.getCode() == 500,"应收出错");
|
|
|
|
|
+
|
|
|
// 一级分销费用户进账
|
|
// 一级分销费用户进账
|
|
|
- if (feeOrders.getFirstDistributionFee().compareTo(BigDecimal.ZERO) > 0 && feeOrders.getFirstDistributorId() != null) {
|
|
|
|
|
|
|
+ if (feeOrders.getFirstDistributorId() != null && feeOrders.getFirstDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getFirstDistributorId());
|
|
HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getFirstDistributorId());
|
|
|
AssertionUtils.isFail(jzgInfoResult.getCode() != 200,"获取用户失败!");
|
|
AssertionUtils.isFail(jzgInfoResult.getCode() != 200,"获取用户失败!");
|
|
|
SysUserJzgInfo jzgInfo = jzgInfoResult.getData();
|
|
SysUserJzgInfo jzgInfo = jzgInfoResult.getData();
|
|
|
HttpResult<SysUserAccount> jzgAccountResult = orgClient.accountGet(jzgInfo.getUserId(), baseController.getToken());
|
|
HttpResult<SysUserAccount> jzgAccountResult = orgClient.accountGet(jzgInfo.getUserId(), baseController.getToken());
|
|
|
AssertionUtils.isFail(jzgAccountResult.getCode() != 200,"获取用户账户失败!");
|
|
AssertionUtils.isFail(jzgAccountResult.getCode() != 200,"获取用户账户失败!");
|
|
|
- SysUserAccount distributor1 = jzgAccountResult.getData();
|
|
|
|
|
|
|
+ distributor1 = jzgAccountResult.getData();
|
|
|
verifySysAccount(distributor1,jzgInfo,feeOrders);
|
|
verifySysAccount(distributor1,jzgInfo,feeOrders);
|
|
|
}
|
|
}
|
|
|
// 二级分销费用户进账
|
|
// 二级分销费用户进账
|
|
|
- if (feeOrders.getSecondDistributionFee().compareTo(BigDecimal.ZERO) > 0 && feeOrders.getSecondDistributorId() != null) {
|
|
|
|
|
|
|
+ if (feeOrders.getSecondDistributorId() != null && feeOrders.getSecondDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getSecondDistributorId());
|
|
HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getSecondDistributorId());
|
|
|
AssertionUtils.isFail(jzgInfoResult.getCode() != 200,"获取用户失败!");
|
|
AssertionUtils.isFail(jzgInfoResult.getCode() != 200,"获取用户失败!");
|
|
|
SysUserJzgInfo jzgInfo = jzgInfoResult.getData();
|
|
SysUserJzgInfo jzgInfo = jzgInfoResult.getData();
|
|
|
HttpResult<SysUserAccount> jzgAccountResult = orgClient.accountGet(jzgInfo.getUserId(), baseController.getToken());
|
|
HttpResult<SysUserAccount> jzgAccountResult = orgClient.accountGet(jzgInfo.getUserId(), baseController.getToken());
|
|
|
AssertionUtils.isFail(jzgAccountResult.getCode() != 200,"获取用户账户失败!");
|
|
AssertionUtils.isFail(jzgAccountResult.getCode() != 200,"获取用户账户失败!");
|
|
|
- SysUserAccount distributor2 = jzgAccountResult.getData();
|
|
|
|
|
|
|
+ distributor2 = jzgAccountResult.getData();
|
|
|
verifySysAccount(distributor2,jzgInfo,feeOrders);
|
|
verifySysAccount(distributor2,jzgInfo,feeOrders);
|
|
|
}
|
|
}
|
|
|
// 三级分销费用户进账
|
|
// 三级分销费用户进账
|
|
|
- if (feeOrders.getThirdDistributionFee().compareTo(BigDecimal.ZERO) > 0 && feeOrders.getThirdDistributorId() != null) {
|
|
|
|
|
|
|
+ if (feeOrders.getThirdDistributorId() != null && feeOrders.getThirdDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getThirdDistributorId());
|
|
HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getThirdDistributorId());
|
|
|
AssertionUtils.isFail(jzgInfoResult.getCode() != 200,"获取用户失败!");
|
|
AssertionUtils.isFail(jzgInfoResult.getCode() != 200,"获取用户失败!");
|
|
|
SysUserJzgInfo jzgInfo = jzgInfoResult.getData();
|
|
SysUserJzgInfo jzgInfo = jzgInfoResult.getData();
|
|
|
HttpResult<SysUserAccount> jzgAccountResult = orgClient.accountGet(jzgInfo.getUserId(), baseController.getToken());
|
|
HttpResult<SysUserAccount> jzgAccountResult = orgClient.accountGet(jzgInfo.getUserId(), baseController.getToken());
|
|
|
AssertionUtils.isFail(jzgAccountResult.getCode() != 200,"获取用户账户失败!");
|
|
AssertionUtils.isFail(jzgAccountResult.getCode() != 200,"获取用户账户失败!");
|
|
|
- SysUserAccount distributor3 = jzgAccountResult.getData();
|
|
|
|
|
|
|
+ distributor3 = jzgAccountResult.getData();
|
|
|
verifySysAccount(distributor3,jzgInfo,feeOrders);
|
|
verifySysAccount(distributor3,jzgInfo,feeOrders);
|
|
|
}
|
|
}
|
|
|
}else{
|
|
}else{
|
|
@@ -329,8 +347,76 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
|
|
|
audit.setRefuse(param.getRefuse());
|
|
audit.setRefuse(param.getRefuse());
|
|
|
audit.setIsProblem(0);
|
|
audit.setIsProblem(0);
|
|
|
this.updateById(audit);
|
|
this.updateById(audit);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 增加账户的金额记录
|
|
|
|
|
+ List<SysUserAccountIncomeLog>builderIncomeLog = this.builderIncomeLog(param.getOrderNo(),feeOrders,userAccount,distributor1,distributor2,distributor3);
|
|
|
|
|
+ HttpResult result = orgClient.addUserAccountIncomeLog(builderIncomeLog,baseController.getToken());
|
|
|
|
|
+ AssertionUtils.isFail(result.getCode() != 200,"账户记录添加失败,审核失败");
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 生成收入明细日志
|
|
|
|
|
+ * @param orderNo 订单号
|
|
|
|
|
+ * @param feeOrders 费用
|
|
|
|
|
+ * @param userAccount 分账用户
|
|
|
|
|
+ * @param distributor1 1级分销人员
|
|
|
|
|
+ * @param distributor2 2级分销人员
|
|
|
|
|
+ * @param distributor3 3级分销人员
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<SysUserAccountIncomeLog> builderIncomeLog(String orderNo,InsFeeOrders feeOrders,SysUserAccount userAccount,SysUserAccount distributor1,
|
|
|
|
|
+ SysUserAccount distributor2, SysUserAccount distributor3){
|
|
|
|
|
+ List<SysUserAccountIncomeLog> incomeLogs = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 出口费用
|
|
|
|
|
+ SysUserAccountIncomeLog exportIncomeLog = new SysUserAccountIncomeLog();
|
|
|
|
|
+ exportIncomeLog.setOrderId(orderNo);
|
|
|
|
|
+ exportIncomeLog.setUserId(userAccount.getUserId());
|
|
|
|
|
+ exportIncomeLog.setAmount(feeOrders.getJqExportPremium().add(feeOrders.getSyExportPremium()).add(feeOrders.getJyExportPremium()));
|
|
|
|
|
+ exportIncomeLog.setProperty(1);
|
|
|
|
|
+ exportIncomeLog.setBalanceAmount(userAccount.getSumAmount());
|
|
|
|
|
+
|
|
|
|
|
+ incomeLogs.add(exportIncomeLog);
|
|
|
|
|
+
|
|
|
|
|
+ // 1级分销费
|
|
|
|
|
+ if (feeOrders.getFirstDistributorId() != null && feeOrders.getFirstDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ SysUserAccountIncomeLog distributor1IncomeLog = new SysUserAccountIncomeLog();
|
|
|
|
|
+ distributor1IncomeLog.setOrderId(orderNo);
|
|
|
|
|
+ distributor1IncomeLog.setUserId(distributor1.getUserId());
|
|
|
|
|
+ distributor1IncomeLog.setAmount(feeOrders.getFirstDistributionFee());
|
|
|
|
|
+ distributor1IncomeLog.setProperty(2);
|
|
|
|
|
+ distributor1IncomeLog.setBalanceAmount(userAccount.getSumAmount());
|
|
|
|
|
+ incomeLogs.add(distributor1IncomeLog);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2级分销费
|
|
|
|
|
+ if (feeOrders.getSecondDistributorId() != null && feeOrders.getSecondDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ SysUserAccountIncomeLog distributor2IncomeLog = new SysUserAccountIncomeLog();
|
|
|
|
|
+ distributor2IncomeLog.setOrderId(orderNo);
|
|
|
|
|
+ distributor2IncomeLog.setUserId(distributor2.getUserId());
|
|
|
|
|
+ distributor2IncomeLog.setAmount(feeOrders.getFirstDistributionFee());
|
|
|
|
|
+ distributor2IncomeLog.setProperty(2);
|
|
|
|
|
+ distributor2IncomeLog.setBalanceAmount(userAccount.getSumAmount());
|
|
|
|
|
+ incomeLogs.add(distributor2IncomeLog);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 3级分销费
|
|
|
|
|
+ if (feeOrders.getThirdDistributorId() != null && feeOrders.getThirdDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ SysUserAccountIncomeLog distributor3IncomeLog = new SysUserAccountIncomeLog();
|
|
|
|
|
+ distributor3IncomeLog.setOrderId(orderNo);
|
|
|
|
|
+ distributor3IncomeLog.setUserId(distributor3.getUserId());
|
|
|
|
|
+ distributor3IncomeLog.setAmount(feeOrders.getFirstDistributionFee());
|
|
|
|
|
+ distributor3IncomeLog.setProperty(2);
|
|
|
|
|
+ distributor3IncomeLog.setBalanceAmount(userAccount.getSumAmount());
|
|
|
|
|
+ incomeLogs.add(distributor3IncomeLog);
|
|
|
|
|
+ }
|
|
|
|
|
+ return incomeLogs;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// 验证用户账户
|
|
// 验证用户账户
|
|
|
public void verifySysAccount(SysUserAccount userAccount, SysUserJzgInfo jzgInfo, InsFeeOrders feeOrders) {
|
|
public void verifySysAccount(SysUserAccount userAccount, SysUserJzgInfo jzgInfo, InsFeeOrders feeOrders) {
|
|
|
if (Objects.isNull(userAccount)) {
|
|
if (Objects.isNull(userAccount)) {
|