浏览代码

问题修复

FengChaoYu 1 天之前
父节点
当前提交
933e6fb9b0

+ 6 - 2
mall-server-api/src/main/java/com/gree/mall/manager/bean/user/UserCompanyCreditBillVO.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.gree.mall.manager.annotation.ZfireField;
 import com.gree.mall.manager.annotation.ZfireList;
+import com.gree.mall.manager.enums.UserCreditBillStatusEnum;
 import com.gree.mall.manager.plus.entity.UserCompanyCreditBill;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -36,6 +37,9 @@ public class UserCompanyCreditBillVO {
     @ApiModelProperty(value = "账单总金额")
     private BigDecimal amount;
 
+    @ApiModelProperty(value = "已还款金额")
+    private BigDecimal payAmount;
+
     @ApiModelProperty(value = "剩余未还金额")
     private BigDecimal remainingAmount;
 
@@ -45,8 +49,8 @@ public class UserCompanyCreditBillVO {
     @ApiModelProperty(value = "账单到期日期")
     private Date dueDate;
 
-    @ApiModelProperty(value = "是否已支付 1=是 0=否")
-    private Boolean isPaid;
+    @ApiModelProperty(value = "状态")
+    private UserCreditBillStatusEnum status;
 
     @ApiModelProperty(value = "创建时间")
     private Date createTime;

+ 19 - 0
mall-server-api/src/main/java/com/gree/mall/manager/enums/UserCreditBillStatusEnum.java

@@ -0,0 +1,19 @@
+package com.gree.mall.manager.enums;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public enum UserCreditBillStatusEnum {
+
+    UNPAID ("UNPAID","未还款"),
+    REPAYMENT("REPAYMENT","部分还款"),
+    REPAID("REPAID","已还款"),
+    ;
+
+
+    private final String key;
+    private final String remark;
+}

+ 3 - 2
mall-server-api/src/main/java/com/gree/mall/manager/logic/user/UserCompanyCreditLogic.java

@@ -12,6 +12,7 @@ import com.gree.mall.manager.commonmapper.CommonMapper;
 import com.gree.mall.manager.commonmapper.LockQueryMapper;
 import com.gree.mall.manager.constant.Constant;
 import com.gree.mall.manager.enums.TransactionTypeEnum;
+import com.gree.mall.manager.enums.UserCreditBillStatusEnum;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.plus.entity.OrderInfo;
@@ -90,7 +91,7 @@ public class UserCompanyCreditLogic {
             if (!creditBill.getCompanyWechatId().equals(adminUser.getCompanyWechatId())) {
                 throw new RemoteServiceException("请使用商户账号");
             }
-            if (creditBill.getIsPaid()) {
+            if (creditBill.getStatus().equals(UserCreditBillStatusEnum.REPAID.getKey())) {
                 throw new RemoteServiceException(billId + "账单已还款");
             }
 
@@ -106,7 +107,7 @@ public class UserCompanyCreditLogic {
             final BigDecimal newRemainingAmount = creditBill.getRemainingAmount().subtract(amount);
 
             // 更新账单
-            creditBill.setIsPaid(newRemainingAmount.compareTo(BigDecimal.ZERO) == 0)
+            creditBill.setStatus(newRemainingAmount.compareTo(BigDecimal.ZERO) == 0 ? UserCreditBillStatusEnum.REPAID.getKey() : UserCreditBillStatusEnum.REPAYMENT.getKey())
                     .setRemainingAmount(newRemainingAmount)
                     .updateById();
         } else {

+ 2 - 1
mall-server-api/src/main/java/com/gree/mall/manager/schedule/UserCompanyCreditBillSchedule.java

@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.gree.mall.manager.commonmapper.LockQueryMapper;
 import com.gree.mall.manager.enums.TransactionTypeEnum;
+import com.gree.mall.manager.enums.UserCreditBillStatusEnum;
 import com.gree.mall.manager.enums.workorder.OrderBaseStatusEnum;
 import com.gree.mall.manager.plus.entity.PgOrderBase;
 import com.gree.mall.manager.plus.entity.UserCompanyCredit;
@@ -154,7 +155,7 @@ public class UserCompanyCreditBillSchedule {
                 .setRemainingAmount(totalAmount)
                 .setCreateDate(DateUtil.parseDate(DateUtil.formatDate(today)))
                 .setDueDate(dueDate)
-                .setIsPaid(totalAmount.compareTo(BigDecimal.ZERO) <= 0)
+                .setStatus(totalAmount.compareTo(BigDecimal.ZERO) <= 0 ? UserCreditBillStatusEnum.REPAID.getKey() : UserCreditBillStatusEnum.UNPAID.getKey())
                 .setRemark(DateUtil.formatDateTime(startTime) + " - " + DateUtil.formatDateTime(endTime))
                 .insert();
 

+ 2 - 1
mall-server-api/src/main/resources/mapper/CommonMapper.xml

@@ -1111,7 +1111,8 @@
             resultType="com.gree.mall.manager.bean.user.UserCompanyCreditBillVO">
         SELECT
         ${ex.selected},
-        b.nick_name
+        b.nick_name,
+        (IFNULL(a.amount, 0) - IFNULL(a.remaining_amount, 0)) AS pay_amount
         FROM user_company_credit_bill a LEFT JOIN user b ON a.user_id = b.user_id
         ${ex.query}
         <if test="ex.orderBy == null or ex.orderBy ==''">