소스 검색

修改跟单费和手续费的在历史表中生成的错误数据
修改查询报错问题以及其他问题

hxl13994548489 2 년 전
부모
커밋
116c258cbc

+ 30 - 14
src/main/java/com/ydtech/modules/admin/service/impl/SysUserAccountServiceImpl.java

@@ -129,6 +129,10 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
             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());
@@ -176,25 +180,25 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
                 sysUserAccountHistory.setProperty(MoneyAttrConstants.M_3.getCode());
                 commissionMessage.append(MoneyAttrConstants.M_3.getDesc() + ":" + sysUserAccount.getPromotion() + "元    ");
                 if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入  相加
-                    sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getPromotion());
+                    sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getSumAmount());
                 }
                 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(sysUserAccount.getDocumentary() != null && sysUserAccount.getDocumentary().compareTo(BigDecimal.ZERO) != 0  ||  sysUserAccount.getPromotion() != null && sysUserAccount.getPromotion().compareTo(BigDecimal.ZERO) != 0 ){
-                BigDecimal sum = (sysUserAccount.getDocumentary()==null?BigDecimal.ZERO:sysUserAccount.getDocumentary())
-                        .add(sysUserAccount.getPromotion()==null?BigDecimal.ZERO:sysUserAccount.getPromotion());
+            if(amount_SX_GD.compareTo(BigDecimal.ZERO) != 0){
                 sysUserAccountHistory.setId(null);
-                sysUserAccountHistory.setAmount(sum);
+                sysUserAccountHistory.setAmount(amount_SX_GD);
                 sysUserAccountHistory.setProperty(MoneyAttrConstants.M_4.getCode());
                 if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入  相加
-                    sysUserAccountHistory.setSurplusAmount(sum);
+                    sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getSumAmount());
                     sysUserAccountHistory.setBusinessSegmentsType(1);
                     sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
                 }
-
             }
         }
         //添加佣金消息
@@ -337,8 +341,10 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
 //       用户当前金额
         BigDecimal amount = sysUserAccountVo.getAmount();
         SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory();  // 记录
-        sysUserAccountHistory.setDocumentary(1);  // 1提现
+        sysUserAccountHistory.setDocumentary(1);  // 1支出
         sysUserAccountHistory.setUserId(userId);
+        sysUserAccountHistory.setProperty(3); //3提现
+        sysUserAccountHistory.setBusinessSegmentsType(1);
         SysAmountAuditingEntity sysAmountAuditingEntity = new SysAmountAuditingEntity();//审核记录表
         sysAmountAuditingEntity.setUserId(userId);
         sysAmountAuditingEntity.setAmount(sysUserAccountVo.getAmount());
@@ -364,8 +370,8 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
             SysUserAccount sysUserAccount = baseMapper.getById(userId);
 
 
-            if (StringUtils.isNotEmpty(sysUserAccountVo.getAmountStatus())) {
-                sysUserAccountHistory.setProperty(Integer.valueOf(sysUserAccountVo.getAmountStatus()));   //金额类型
+            //if (StringUtils.isNotEmpty(sysUserAccountVo.getAmountStatus())) {
+                //sysUserAccountHistory.setProperty(Integer.valueOf(sysUserAccountVo.getAmountStatus()));   //金额类型
                 //注释掉类型提现,直接提现总金额
                 /**
                  if ("1".equals(sysUserAccountVo.getAmountStatus())) {
@@ -391,14 +397,14 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
                  }
                  **/
                 //提现前的金额
-                beforeAmount = sysUserAccount.getSumAmount();
+                beforeAmount = sysUserAccount.getSumAmount()==null?BigDecimal.ZERO:sysUserAccount.getSumAmount();
                 //提现后的金额
                 afterAmount = beforeAmount.subtract(amount);
                 sysUserAccount.setSumAmount(afterAmount);
                 //支付中总金额 = 原先的支付金额 + 提现的金额
-                sysUserAccount.setSumAmountPayment(sysUserAccount.getSumAmountPayment().add(amount));
+                sysUserAccount.setSumAmountPayment((sysUserAccount.getSumAmountPayment()==null?BigDecimal.ZERO:sysUserAccount.getSumAmountPayment()).add(amount));
                 //提现的总金额 = 原先的提现总金额 + 提现的金额
-                sysUserAccount.setSumAmountWithdrawal(sysUserAccount.getSumAmountWithdrawal().add(amount));
+                sysUserAccount.setSumAmountWithdrawal((sysUserAccount.getSumAmountWithdrawal()==null?BigDecimal.ZERO:sysUserAccount.getSumAmountWithdrawal().add(amount)));
 
                 //              用户相差
                 if (beforeAmount.compareTo(zero) == 0 || afterAmount.compareTo(zero) < 0) {
@@ -415,7 +421,17 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
                 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("提现成功,等待审核");

+ 3 - 5
src/main/java/com/ydtech/modules/fnc/service/impl/InsFeeAuditServiceImpl.java

@@ -166,15 +166,13 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
                 BigDecimal totalOtherPremiumAmount = new BigDecimal(0);
                 totalOtherPremiumAmount =
                         totalOtherPremiumAmount.add(insFeeOrderNew.getJqExportOtherCostsPremiums()).add(insFeeOrderNew.getSyExportOtherCostsPremiums()).add(insFeeOrderNew.getNoExportOtherCostsPremiums());
-
-
                 //用戶
+                //算佣金
+                this.countUserAmount(insFeeOrderNew, insAreaCompany.getId());
                 sysUserAccount.setHandlingFee(totalPremiumAmount);
                 sysUserAccount.setDocumentary(totalOtherPremiumAmount);
-                //算佣金
-                this.countUserAmount(insFeeOrderNew, orderNo);
                 sysUserAccount.setDocumentaryStatus("2");  // 收入
-                sysUserAccount.setSuborderId(orderNo);  // 订单Id
+                sysUserAccount.setSuborderId(insAreaCompany.getId());  // 订单Id
                 sysUserAccountService.addOrUpdate(sysUserAccount);
                 if (insFeeOrderNew.getDistributionStatus() !=null) {
                     createInsFeeOrderNewDistribution(insFeeOrderNew, insAreaCompany, order, order.getUserid(),BigDecimal.ZERO, BigDecimal.ZERO, "0");

+ 14 - 6
src/main/resources/mapper/modules/admin/SysUserAccountMapper.xml

@@ -22,7 +22,11 @@
             <result property="promotionAmountWithdrawal" column="promotion_amount_withdrawal" jdbcType="DECIMAL"/>
             <result property="promotionAmountAccount" column="promotion_amount_account" jdbcType="DECIMAL"/>
             <result property="promotionAmountPayment" column="promotion_amount_payment" jdbcType="DECIMAL"/>
-            <collection property="sysUserAccountCardList" ofType="com.ydtech.modules.admin.model.po.SysUserBankCard"
+            <result property="sumAmount" column="sum_amount" jdbcType="DECIMAL"/>
+            <result property="sumAmountWithdrawal" column="sum_amount_withdrawal" jdbcType="DECIMAL"/>
+            <result property="sumAmountAccount" column="sum_amount_account" jdbcType="DECIMAL"/>
+            <result property="sumAmountPayment" column="sum_amount_payment" jdbcType="DECIMAL"/>
+        <collection property="sysUserAccountCardList" ofType="com.ydtech.modules.admin.model.po.SysUserBankCard"
                     resultMap="sysUserAccountCardList"/>
     </resultMap>
 
@@ -85,10 +89,10 @@
             a.promotion_amount_withdrawal as "promotionAmountWithdrawal",
             a.promotion_amount_account as "promotionAmountAccount",
             a.promotion_amount_payment as "promotionAmountPayment",
-            a.sum_amount  as "sumAmount",
-            a.sum_amount_withdrawal  as "sumAmountWithdrawal",
-            a.sum_amount_account  as  "sumAmountAccount",
-            a.sum_amount_payment  as  "sumAmountPayment"
+            ifnull(a.sum_amount,0)  as "sumAmount",
+            ifnull(a.sum_amount_withdrawal,0)  as "sumAmountWithdrawal",
+            ifnull(a.sum_amount_account,0) as  "sumAmountAccount",
+            ifnull(a.sum_amount_payment,0)  as  "sumAmountPayment"
         from  sys_user_account a
         <where>
             <if test="userId != null and userId != ''">
@@ -118,7 +122,11 @@
         sd.name  as  deptName,
         c.bank_number,
         c.bank_account,
-        c.bank_address
+        c.bank_address,
+        a.sum_amount,
+        a.sum_amount_withdrawal,
+        a.sum_amount_account,
+        a.sum_amount_payment
         from
         sys_user_account a
         left join   sys_user  b  on  a.user_id  = b.id

+ 14 - 14
src/main/resources/mapper/modules/ins/InsFeeOrderNewMapper.xml

@@ -571,7 +571,7 @@
                 AND a.first_level_user_id = #{myCollectInAdvanceQueryDto.userId}
             </if>
             <if test="myCollectInAdvanceQueryDto.startDate!= null  and  myCollectInAdvanceQueryDto.startDate  !='' and myCollectInAdvanceQueryDto.endDate!= null  and  myCollectInAdvanceQueryDto.endDate  !=''">
-                AND iac.signing_time  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
+                AND iac.createtime  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
             </if>
         </where>
         UNION
@@ -592,7 +592,7 @@
                 AND a.three_level_user_id = #{myCollectInAdvanceQueryDto.userId}
             </if>
             <if test="myCollectInAdvanceQueryDto.startDate!= null  and  myCollectInAdvanceQueryDto.startDate  !='' and myCollectInAdvanceQueryDto.endDate!= null  and  myCollectInAdvanceQueryDto.endDate  !=''">
-                AND iac.signing_time  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
+                AND iac.createtime  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
             </if>
         </where>
         UNION
@@ -610,10 +610,10 @@
             iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="myCollectInAdvanceQueryDto.userId!=null and  myCollectInAdvanceQueryDto.userId!= ''">
-                AND a.two_level_user_id = #{userId}
+                AND a.two_level_user_id = #{myCollectInAdvanceQueryDto.userId}
             </if>
             <if test="myCollectInAdvanceQueryDto.startDate!= null  and  myCollectInAdvanceQueryDto.startDate  !='' and myCollectInAdvanceQueryDto.endDate!= null  and  myCollectInAdvanceQueryDto.endDate  !=''">
-                AND iac.signing_time  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
+                AND iac.createtime  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
             </if>
         </where>
         ) AS fee
@@ -639,7 +639,7 @@
             and  a.user_id = #{myCollectInAdvanceQueryDto.userId}
             and  iff.auditstatus=0
             <if test="myCollectInAdvanceQueryDto.startDate!= null  and  myCollectInAdvanceQueryDto.startDate  !='' and myCollectInAdvanceQueryDto.endDate!= null  and  myCollectInAdvanceQueryDto.endDate  !=''">
-                AND ins.signing_time  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
+                AND ins.createtime  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
             </if>
         </where>
     </select>
@@ -665,7 +665,7 @@
                 AND a.first_level_user_id = #{myCollectInAdvanceQueryDto.userId}
             </if>
             <if test="myCollectInAdvanceQueryDto.startDate!= null  and  myCollectInAdvanceQueryDto.startDate  !='' and myCollectInAdvanceQueryDto.endDate!= null  and  myCollectInAdvanceQueryDto.endDate  !=''">
-                AND iac.signing_time  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
+                AND iac.createtime  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
             </if>
         </where>
         UNION
@@ -686,7 +686,7 @@
                 AND a.three_level_user_id = #{myCollectInAdvanceQueryDto.userId}
             </if>
             <if test="myCollectInAdvanceQueryDto.startDate!= null  and  myCollectInAdvanceQueryDto.startDate  !='' and myCollectInAdvanceQueryDto.endDate!= null  and  myCollectInAdvanceQueryDto.endDate  !=''">
-                AND iac.signing_time  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
+                AND iac.createtime  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
             </if>
         </where>
         UNION
@@ -704,10 +704,10 @@
             iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="myCollectInAdvanceQueryDto.userId!=null and  myCollectInAdvanceQueryDto.userId!= ''">
-                AND a.two_level_user_id = #{userId}
+                AND a.two_level_user_id = #{myCollectInAdvanceQueryDto.userId}
             </if>
             <if test="myCollectInAdvanceQueryDto.startDate!= null  and  myCollectInAdvanceQueryDto.startDate  !='' and myCollectInAdvanceQueryDto.endDate!= null  and  myCollectInAdvanceQueryDto.endDate  !=''">
-                AND iac.signing_time  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
+                AND iac.createtime  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
             </if>
         </where>
         ) AS fee
@@ -724,7 +724,7 @@
             and  a.user_id = #{myCollectInAdvanceQueryDto.userId}
             and  iff.auditstatus=0
             <if test="myCollectInAdvanceQueryDto.startDate!= null  and  myCollectInAdvanceQueryDto.startDate  !='' and myCollectInAdvanceQueryDto.endDate!= null  and  myCollectInAdvanceQueryDto.endDate  !=''">
-                AND ins.signing_time  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
+                AND ins.createtime  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
             </if>
         </where>
     </select>
@@ -749,7 +749,7 @@
                 AND a.first_level_user_id = #{myCollectInAdvanceQueryDto.userId}
             </if>
             <if test="myCollectInAdvanceQueryDto.startDate!= null  and  myCollectInAdvanceQueryDto.startDate  !='' and myCollectInAdvanceQueryDto.endDate!= null  and  myCollectInAdvanceQueryDto.endDate  !=''">
-                AND iac.signing_time  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
+                AND iac.createtime  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
             </if>
         </where>
         UNION
@@ -766,7 +766,7 @@
                 AND a.three_level_user_id = #{myCollectInAdvanceQueryDto.userId}
             </if>
             <if test="myCollectInAdvanceQueryDto.startDate!= null  and  myCollectInAdvanceQueryDto.startDate  !='' and myCollectInAdvanceQueryDto.endDate!= null  and  myCollectInAdvanceQueryDto.endDate  !=''">
-                AND iac.signing_time  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
+                AND iac.createtime  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
             </if>
         </where>
         UNION
@@ -783,7 +783,7 @@
                 AND a.two_level_user_id = #{myCollectInAdvanceQueryDto.userId}
             </if>
             <if test="myCollectInAdvanceQueryDto.startDate!= null  and  myCollectInAdvanceQueryDto.startDate  !='' and myCollectInAdvanceQueryDto.endDate!= null  and  myCollectInAdvanceQueryDto.endDate  !=''">
-                AND iac.signing_time  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
+                AND iac.createtime  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
             </if>
         </where>
         ) AS fee
@@ -806,7 +806,7 @@
             and  a.user_id = #{myCollectInAdvanceQueryDto.userId}
             and  iff.auditstatus=0
             <if test="myCollectInAdvanceQueryDto.startDate!= null  and  myCollectInAdvanceQueryDto.startDate  !='' and myCollectInAdvanceQueryDto.endDate!= null  and myCollectInAdvanceQueryDto.endDate  !=''">
-                AND ins.signing_time  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
+                AND ins.createtime  BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
             </if>
         </where>
     </select>