Jelajahi Sumber

Merge remote-tracking branch 'origin/dev_jzg_lipf_v20260518' into dev_jzg_lipf_v20260518

jiakai 3 bulan lalu
induk
melakukan
855aa9d68e

+ 3 - 0
commons/src/main/java/com/jzg/commons/core/base/BaseModel.java

@@ -8,12 +8,15 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.io.Serial;
 import java.io.Serializable;
 import java.time.LocalDateTime;
 
 @Data
 public class BaseModel implements Serializable {
 
+    @Serial
+    private static final long serialVersionUID = -3245252772001957985L;
     @ExcelIgnore
     @Schema(description = "是否删除")
     @TableLogic

+ 83 - 0
commons/src/main/java/com/jzg/commons/entity/account/po/SysUserAccountChangeLog.java

@@ -0,0 +1,83 @@
+package com.jzg.commons.entity.account.po;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.jzg.commons.core.base.BaseModel;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+import java.math.BigDecimal;
+
+
+/**
+ * 用户收入来源记录表
+ * 业务员账户变更记录表
+ * 记录账户中金额的每一次变更
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class SysUserAccountChangeLog extends BaseModel {
+
+    @Serial
+    private static final long serialVersionUID = 3689832570825862201L;
+    private String id;
+
+    @Schema(description = "租户代码")
+    private String systemCode;
+
+    @Schema(description = "用户序号")
+    private String  userId;
+
+    @Schema(description = "jzg_info表的序号")
+    private String jzgInfoId;
+
+    @Schema(description = "相关金额")
+    private BigDecimal amount;
+
+    @Schema(description = "操作前金额")
+    private BigDecimal amountBefore;
+
+//    在实际运行中,可能因为并发的问题,操作前的金额和操作后的金额,很难得到要给准确的值(如果非要得到金额,需要加锁,影响其他模块操作)
+//    @Schema(description = "操作后的金额")
+//    private BigDecimal amountAfter;
+
+    /**
+     * 操作类型 1 保单费用 2 保单提成 3. 提现
+     */
+    @Schema(description = "操作类型")
+    private int operType;
+
+    @TableField(exist = false)
+    private String operTypeName;
+
+    @Schema(description = "关联订单ID")
+    private String relatedOrderId;
+
+    @Schema(description = "转出银行卡的序号")
+    private String bankCardIdTo;
+
+    @Schema(description = "转出银行卡的卡号")
+    private String bankCardNoTo;
+
+    @Schema(description = "转入银行卡的序号")
+    private String bankCardIdIn;
+
+    @Schema(description = "转入银行卡的卡号")
+    private String bankCardNoIn;
+
+    @Schema(description = "备注")
+    private String remark;
+
+
+    public SysUserAccountChangeLog(){
+
+    }
+
+    public SysUserAccountChangeLog(String systemCode, String userId, String jzgInfoId){
+        this.systemCode = systemCode;
+        this.userId = userId;
+        this.jzgInfoId = jzgInfoId;
+    }
+
+}

+ 0 - 36
commons/src/main/java/com/jzg/commons/entity/account/po/SysUserAccountIncomeLog.java

@@ -1,36 +0,0 @@
-package com.jzg.commons.entity.account.po;
-
-import com.jzg.commons.core.base.BaseModel;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import java.io.Serial;
-import java.math.BigDecimal;
-
-
-/**
- * 用户收入来源记录表
- */
-@Data
-public class SysUserAccountIncomeLog extends BaseModel {
-
-    @Serial
-    private static final long serialVersionUID = 3689832570825862201L;
-    private String id;
-
-    @Schema(description = "用户id")
-    private String userId;
-
-    @Schema(description = "提现金额")
-    private BigDecimal amount;
-
-    @Schema(description = "账户余额")
-    private BigDecimal balanceAmount;
-
-    @Schema(description = "来源订单id")
-    private String orderId;
-
-    @Schema(description = "钱属性")
-    private int property;
-
-}

+ 12 - 2
tenant/insurance/quotation-commons/src/main/java/com/jzg/quotation/commons/client/OrgClient.java

@@ -2,7 +2,7 @@ package com.jzg.quotation.commons.client;
 
 import com.alibaba.fastjson.JSONObject;
 import com.jzg.commons.core.page.HttpResult;
-import com.jzg.commons.entity.account.po.SysUserAccountIncomeLog;
+import com.jzg.commons.entity.account.po.SysUserAccountChangeLog;
 import com.jzg.commons.entity.agreement.dispatch.dto.PtlAgreementDispatchAfterAction;
 import com.jzg.commons.entity.agreement.dispatch.vo.PtlAgreementDispatchVo;
 import com.jzg.commons.entity.dto.CostAgreementParam;
@@ -207,5 +207,15 @@ public interface OrgClient {
      * 添加用户账户收入记录
      */
     @PostMapping(value = "/userAccount/addUserAccountIncomeLog")
-    HttpResult addUserAccountIncomeLog(@RequestBody List<SysUserAccountIncomeLog> incomeLogs);
+    HttpResult addUserAccountIncomeLog(@RequestBody List<SysUserAccountChangeLog> incomeLogs);
+
+    /**
+     * 添加用户钱包账户记录
+     *
+     * @param changeLog 用户钱包记录
+     * @author lipf
+     * @date 2026/6/8 10:17
+     */
+    @PostMapping("/addUserAccountChangeLog")
+    HttpResult<String> addUserAccountChangeLog(@RequestBody SysUserAccountChangeLog changeLog);
 }

+ 44 - 28
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeAuditServiceImpl.java

@@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.base.StateResult;
 import com.jzg.commons.core.page.HttpResult;
-import com.jzg.commons.entity.account.po.SysUserAccountIncomeLog;
+import com.jzg.commons.entity.account.po.SysUserAccountChangeLog;
 import com.jzg.commons.entity.dto.CostCalculateRespVO;
 import com.jzg.commons.entity.dto.FeeAuditParam;
 import com.jzg.commons.entity.dto.VerifyOrderParam;
@@ -28,6 +28,7 @@ import com.jzg.commons.entity.vo.*;
 import com.jzg.commons.exception.ServiceException;
 import com.jzg.commons.exception.SystemException;
 import com.jzg.commons.util.AssertionUtils;
+import com.jzg.commons.util.BigDecimalUtil;
 import com.jzg.commons.util.PDFUtil;
 import com.jzg.commons.util.StringUtils;
 import com.jzg.commons.util.idgen.IdGenerate;
@@ -46,6 +47,7 @@ import com.jzg.quotation.summary.mapper.InsOrderRightsPackageMapper;
 import com.jzg.quotation.summary.service.*;
 import com.jzg.quotation.summary.state.AuditState;
 import com.jzg.quotation.summary.state.listener.AuditStateListener;
+import io.seata.spring.annotation.GlobalTransactional;
 import lombok.RequiredArgsConstructor;
 import org.hibernate.validator.internal.util.stereotypes.Lazy;
 import org.redisson.api.RBucket;
@@ -385,10 +387,19 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
         insOrdersService.updateById(orders);
     }
 
+    /**
+     * 费用审核通过
+     *      费用审核通过后,会给业务员账号打钱
+     *
+     * @author lipf
+     * @date 2026/6/8 9:08
+     */
     @Override
+    @GlobalTransactional(rollbackFor = Exception.class)
     public void verifyOrder(VerifyOrderParam param) {
         String systemCode = baseController.getSystemCode();
-        log.info("审核订单.systemCode=[{}], param=[{}]",systemCode, JSONUtil.toJsonStr(param));
+        String userId = baseController.getUserId();
+        log.info("订单费用审核.systemCode=[{}], param=[{}]",systemCode, JSONUtil.toJsonStr(param));
         InsFeeAudit audit = this.getById(param.getOrderNo());
         if(audit == null){
             throw new ServiceException("要审核的订单不存在");
@@ -415,8 +426,9 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
         }
         InsFeeOrders feeOrders = null;
         SysUserAccount userAccount = null;
+        String jzgInfoId = null;
         if(param.getAuditStatus().equals(1)){
-            List<SysUserAccountIncomeLog> incomeLogs = new ArrayList<>();
+            List<SysUserAccountChangeLog> incomeLogs = new ArrayList<>();
             StateResult stateFailResult = auditStateListener.statusChange(AuditState.AuditStateEnum.SUCCESS_AUDIT,audit.getAuditStatus()+"");
             audit.setAuditStatus(stateFailResult.getCurrentState());
 
@@ -435,17 +447,22 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
                 AssertionUtils.isFail(true, "权益券下发失败");
             }
             if(Objects.isNull(userAccount)){
+                log.info("订单费用审核时,检查到租户[{}]下的账号[{}]不存在",systemCode,sysUserResult.getData().getId());
                 userAccount = new SysUserAccount();
                 // 新建账户
                 userAccount.setId(IdGenerate.nextId());
                 userAccount.setUserId(sysUserResult.getData().getId());
-                userAccount.setSumAmount(feeOrders.getTotalReceivablePremium());
-                userAccount.setSumAmountUnpaid(feeOrders.getTotalReceivablePremium());
                 userAccount.setSystemCode(systemCode);
-            }else{
-                userAccount.setSumAmount(feeOrders.getTotalReceivablePremium().add(userAccount.getSumAmount()));
-                userAccount.setSumAmountUnpaid(feeOrders.getTotalReceivablePremium().add(userAccount.getSumAmount()));
             }
+            BigDecimal sumAmount = userAccount.getSumAmount();
+            BigDecimal amount = feeOrders.getTotalReceivablePremium();
+
+            SysUserAccountChangeLog changeLog = new SysUserAccountChangeLog(systemCode, userId,jzgInfoId);
+            changeLog.setAmount(amount);
+            changeLog.setAmountBefore(sumAmount);
+
+            userAccount.setSumAmount(BigDecimalUtil.add(feeOrders.getTotalReceivablePremium(),userAccount.getSumAmount()));
+            userAccount.setSumAmountUnpaid(BigDecimalUtil.add(feeOrders.getTotalReceivablePremium(), userAccount.getSumAmount()));
             orgClient.saveOrUpdate(userAccount);
             // 进入应收表
             List<String> orderNos = new ArrayList<>();
@@ -520,7 +537,7 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
         }
         // 增加账户的金额记录
         // modify by lipf, 2026年5月20日11:31:59 审核通过后,才需要 生成收入明细日志
-        List<SysUserAccountIncomeLog>builderIncomeLog = this.builderIncomeLog(feeOrders.getOrderNo(),feeOrders,userAccount,distributor1,distributor2,distributor3);
+        List<SysUserAccountChangeLog>builderIncomeLog = this.builderIncomeLog(feeOrders.getOrderNo(),feeOrders,userAccount,distributor1,distributor2,distributor3);
         HttpResult result2 = orgClient.addUserAccountIncomeLog(builderIncomeLog);
         AssertionUtils.isFail(result2.getCode() != 200,"账户记录添加失败,审核失败");
     }
@@ -643,7 +660,7 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
      * @param distributor3  3级分销人员
      * @return
      */
-    private List<SysUserAccountIncomeLog> builderIncomeLog(String orderNo,
+    private List<SysUserAccountChangeLog> builderIncomeLog(String orderNo,
                                                            InsFeeOrders feeOrders,
                                                            SysUserAccount userAccount,
                                                            SysUserAccount distributor1,
@@ -651,47 +668,46 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
                                                            SysUserAccount distributor3){
         log.info("生成收入明细日志:feeOrders=[{}],userAccount=[{}],distributor1=[{}],distributor2=[{}],distributor3=[{}]",
                 JSONUtil.toJsonStr(feeOrders), JSONUtil.toJsonStr(userAccount), JSONUtil.toJsonStr(distributor1), JSONUtil.toJsonStr(distributor2), JSONUtil.toJsonStr(distributor3));
-        List<SysUserAccountIncomeLog> incomeLogs = new ArrayList<>();
+        List<SysUserAccountChangeLog> incomeLogs = new ArrayList<>();
         // 出口费用
-        SysUserAccountIncomeLog exportIncomeLog = new SysUserAccountIncomeLog();
-        exportIncomeLog.setOrderId(orderNo);
+        SysUserAccountChangeLog exportIncomeLog = new SysUserAccountChangeLog();
+        exportIncomeLog.setRelatedOrderId(orderNo);
         exportIncomeLog.setUserId(userAccount.getUserId());
         exportIncomeLog.setAmount(feeOrders.getJqExportPremium().add(feeOrders.getSyExportPremium()).add(feeOrders.getJyExportPremium()));
-        exportIncomeLog.setProperty(1);
-        exportIncomeLog.setBalanceAmount(userAccount.getSumAmount());
-
+        //exportIncomeLog.setProperty(1);
+        exportIncomeLog.setAmountBefore(userAccount.getSumAmount());
         incomeLogs.add(exportIncomeLog);
 
         // 1级分销费
         if (feeOrders.getFirstDistributorId() != null && feeOrders.getFirstDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
-            SysUserAccountIncomeLog distributor1IncomeLog = new SysUserAccountIncomeLog();
-            distributor1IncomeLog.setOrderId(orderNo);
+            SysUserAccountChangeLog distributor1IncomeLog = new SysUserAccountChangeLog();
+            distributor1IncomeLog.setRelatedOrderId(orderNo);
             distributor1IncomeLog.setUserId(distributor1.getUserId());
             distributor1IncomeLog.setAmount(feeOrders.getFirstDistributionFee());
-            distributor1IncomeLog.setProperty(2);
-            distributor1IncomeLog.setBalanceAmount(userAccount.getSumAmount());
+            //distributor1IncomeLog.setProperty(2);
+            distributor1IncomeLog.setAmountBefore(userAccount.getSumAmount());
             incomeLogs.add(distributor1IncomeLog);
         }
 
         // 2级分销费
         if (feeOrders.getSecondDistributorId() != null && feeOrders.getSecondDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
-            SysUserAccountIncomeLog distributor2IncomeLog = new SysUserAccountIncomeLog();
-            distributor2IncomeLog.setOrderId(orderNo);
+            SysUserAccountChangeLog distributor2IncomeLog = new SysUserAccountChangeLog();
+            distributor2IncomeLog.setRelatedOrderId(orderNo);
             distributor2IncomeLog.setUserId(distributor2.getUserId());
             distributor2IncomeLog.setAmount(feeOrders.getFirstDistributionFee());
-            distributor2IncomeLog.setProperty(2);
-            distributor2IncomeLog.setBalanceAmount(userAccount.getSumAmount());
+            //distributor2IncomeLog.setProperty(2);
+            distributor2IncomeLog.setAmountBefore(userAccount.getSumAmount());
             incomeLogs.add(distributor2IncomeLog);
         }
 
         // 3级分销费
         if (feeOrders.getThirdDistributorId() != null && feeOrders.getThirdDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
-            SysUserAccountIncomeLog distributor3IncomeLog = new SysUserAccountIncomeLog();
-            distributor3IncomeLog.setOrderId(orderNo);
+            SysUserAccountChangeLog distributor3IncomeLog = new SysUserAccountChangeLog();
+            distributor3IncomeLog.setRelatedOrderId(orderNo);
             distributor3IncomeLog.setUserId(distributor3.getUserId());
             distributor3IncomeLog.setAmount(feeOrders.getFirstDistributionFee());
-            distributor3IncomeLog.setProperty(2);
-            distributor3IncomeLog.setBalanceAmount(userAccount.getSumAmount());
+            //distributor3IncomeLog.setProperty(2);
+            distributor3IncomeLog.setAmountBefore(userAccount.getSumAmount());
             incomeLogs.add(distributor3IncomeLog);
         }
         return incomeLogs;

+ 27 - 2
tenant/organization/src/main/java/com/jzg/organization/controller/UserAccountController.java

@@ -4,7 +4,7 @@ package com.jzg.organization.controller;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
-import com.jzg.commons.entity.account.po.SysUserAccountIncomeLog;
+import com.jzg.commons.entity.account.po.SysUserAccountChangeLog;
 import com.jzg.commons.entity.dto.IncomeAndExpenseParam;
 import com.jzg.commons.entity.dto.SysUserAccountPageParam;
 import com.jzg.commons.entity.dto.SysUserAccountParam;
@@ -15,11 +15,13 @@ import com.jzg.organization.service.SysUserAccountIncomeLogService;
 import com.jzg.organization.service.SysUserAccountService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
+@Slf4j
 @Tag(name="用户账户接口")
 @RestController
 @RequestMapping("/userAccount")
@@ -95,8 +97,31 @@ public class UserAccountController {
 
     @Operation(summary = "添加用户钱包账户记录")
     @PostMapping("/addUserAccountIncomeLog")
-    public HttpResult addUserAccountIncomeLog(@RequestBody List<SysUserAccountIncomeLog> incomeLogs){
+    public HttpResult addUserAccountIncomeLog(@RequestBody List<SysUserAccountChangeLog> incomeLogs){
         return HttpResult.ok(sysUserAccountIncomeLogService.saveBatch(incomeLogs));
     }
 
+
+    /**
+     * 添加用户钱包账户记录
+     *
+     * @param changeLog 用户钱包记录
+     * @author lipf
+     * @date 2026/6/8 10:17
+     */
+    @Operation(summary = "添加用户钱包账户记录")
+    @PostMapping("/addUserAccountChangeLog")
+    public HttpResult<String> addUserAccountChangeLog(@RequestBody SysUserAccountChangeLog changeLog){
+        try{
+           boolean save = sysUserAccountIncomeLogService.save(changeLog);
+            if(save){
+                return HttpResult.ok("保存业务员账号明细成功");
+            }
+            return HttpResult.error();
+        }catch (Exception e){
+            log.error("保存业务员账号明细异常", e);
+            return HttpResult.error(e.getMessage());
+        }
+    }
+
 }

+ 2 - 2
tenant/organization/src/main/java/com/jzg/organization/mapper/SysUserAccountIncomeLogMapper.java

@@ -1,9 +1,9 @@
 package com.jzg.organization.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.jzg.commons.entity.account.po.SysUserAccountIncomeLog;
+import com.jzg.commons.entity.account.po.SysUserAccountChangeLog;
 import org.apache.ibatis.annotations.Mapper;
 
 @Mapper
-public interface SysUserAccountIncomeLogMapper extends BaseMapper<SysUserAccountIncomeLog> {
+public interface SysUserAccountIncomeLogMapper extends BaseMapper<SysUserAccountChangeLog> {
 }

+ 2 - 2
tenant/organization/src/main/java/com/jzg/organization/service/SysUserAccountIncomeLogService.java

@@ -1,7 +1,7 @@
 package com.jzg.organization.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.jzg.commons.entity.account.po.SysUserAccountIncomeLog;
+import com.jzg.commons.entity.account.po.SysUserAccountChangeLog;
 
 
 /**
@@ -9,6 +9,6 @@ import com.jzg.commons.entity.account.po.SysUserAccountIncomeLog;
  * @description 针对表【SysUserAccountIncomeLog】的数据库操作Service
  * @createDate 2023-11-15 11:23:28
  */
-public interface SysUserAccountIncomeLogService extends IService<SysUserAccountIncomeLog> {
+public interface SysUserAccountIncomeLogService extends IService<SysUserAccountChangeLog> {
 
 }

+ 2 - 37
tenant/organization/src/main/java/com/jzg/organization/service/impl/SysUserAccountIncomeLogServiceImpl.java

@@ -1,45 +1,10 @@
 package com.jzg.organization.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.jzg.commons.constants.RedisKeyConstants;
-import com.jzg.commons.core.base.BaseController;
-import com.jzg.commons.core.base.HistoryDataService;
-import com.jzg.commons.core.base.StateResult;
-import com.jzg.commons.core.page.HttpResult;
-import com.jzg.commons.entity.account.po.SysUserAccountIncomeLog;
-import com.jzg.commons.entity.dto.SysUserInfoParam;
-import com.jzg.commons.entity.dto.SysUserJzgInfoBankCardDto;
-import com.jzg.commons.entity.dto.SysUserJzgInfoDto;
-import com.jzg.commons.entity.enums.MessageCodeEnum;
-import com.jzg.commons.entity.po.*;
-import com.jzg.commons.entity.user.vo.SysTennatVo;
-import com.jzg.commons.entity.vo.*;
-import com.jzg.commons.exception.SystemException;
-import com.jzg.commons.exception.ValidateException;
-import com.jzg.commons.util.MinioUtils;
-import com.jzg.commons.util.PasswordUtils;
-import com.jzg.commons.util.StringUtils;
-import com.jzg.commons.util.idgen.IdGenerate;
-import com.jzg.organization.consumer.templete.UserMessageTemplate;
+import com.jzg.commons.entity.account.po.SysUserAccountChangeLog;
 import com.jzg.organization.mapper.*;
 import com.jzg.organization.service.*;
-import com.jzg.organization.state.UserState;
-import com.jzg.organization.state.listener.UserStateListener;
-import jakarta.annotation.Resource;
-import lombok.Setter;
-import org.redisson.api.RedissonClient;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.ObjectUtils;
-
-import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * @author Administrator
@@ -47,7 +12,7 @@ import java.util.stream.Collectors;
  * @createDate 2023-11-15 11:23:28
  */
 @Service
-public class SysUserAccountIncomeLogServiceImpl extends ServiceImpl<SysUserAccountIncomeLogMapper, SysUserAccountIncomeLog> implements SysUserAccountIncomeLogService{
+public class SysUserAccountIncomeLogServiceImpl extends ServiceImpl<SysUserAccountIncomeLogMapper, SysUserAccountChangeLog> implements SysUserAccountIncomeLogService{
 
 }