Преглед изворни кода

add 添加获取学生维修技师接口

周箭河 пре 5 година
родитељ
комит
df65a9f417

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentRepair.java

@@ -122,6 +122,11 @@ public class StudentRepair {
     private Integer repairStatus;
 
     /**
+     * 使用余额
+     */
+    private Boolean isUseBalancePayment;
+
+    /**
     * 送修时间
     */
     private Date createTime;
@@ -338,4 +343,12 @@ public class StudentRepair {
     public void setEmployeeAddress(String employeeAddress) {
         this.employeeAddress = employeeAddress;
     }
+
+    public Boolean getIsUseBalancePayment() {
+        return isUseBalancePayment;
+    }
+
+    public void setIsUseBalancePayment(Boolean useBalancePayment) {
+        isUseBalancePayment = useBalancePayment;
+    }
 }

+ 37 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -6,18 +6,13 @@ import com.ym.mec.biz.dal.dao.StudentRepairDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.StudentManageListDto;
-import com.ym.mec.biz.dal.entity.Group;
-import com.ym.mec.biz.dal.entity.MusicGroup;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.entity.StudentRepair;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
-import com.ym.mec.biz.service.PayService;
-import com.ym.mec.biz.service.StudentPaymentOrderService;
-import com.ym.mec.biz.service.StudentRepairService;
-import com.ym.mec.biz.service.SysConfigService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
@@ -49,7 +44,8 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     private SysConfigDao sysConfigDao;
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
-
+    @Autowired
+    private SysUserCashAccountService sysUserCashAccountService;
 
     @Override
     public BaseDAO<Integer, StudentRepair> getDAO() {
@@ -121,6 +117,22 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         studentPaymentOrderService.insert(studentPaymentOrder);
         studentPaymentOrder.setVersion(0);
 
+        if (repairInfo.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
+            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(repairInfo.getStudentId());
+            if (userCashAccount == null) {
+                throw new BizException("用户账户找不到");
+            }
+            if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
+                BigDecimal balance = amount.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : amount;
+                amount = amount.subtract(balance);
+                studentPaymentOrder.setActualAmount(amount);
+                studentPaymentOrder.setBalancePaymentAmount(balance);
+                sysUserCashAccountService.updateBalance(repairInfo.getStudentId(), balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐器维修");
+            }
+        }
+        studentPaymentOrderService.update(studentPaymentOrder);
+        studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);
+
         if (amount.compareTo(BigDecimal.ZERO) == 0) {
             Map<String, String> notifyMap = new HashMap<>();
             notifyMap.put("tradeState", "1");
@@ -236,6 +248,22 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         studentPaymentOrderService.insert(studentPaymentOrder);
         studentPaymentOrder.setVersion(0);
 
+        if (repairInfo.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
+            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(repairInfo.getStudentId());
+            if (userCashAccount == null) {
+                throw new BizException("用户账户找不到");
+            }
+            if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
+                BigDecimal balance = amount.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : amount;
+                amount = amount.subtract(balance);
+                studentPaymentOrder.setActualAmount(amount);
+                studentPaymentOrder.setBalancePaymentAmount(balance);
+                sysUserCashAccountService.updateBalance(repairInfo.getStudentId(), balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐器维修");
+            }
+        }
+        studentPaymentOrderService.update(studentPaymentOrder);
+        studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);
+
         if (amount.compareTo(BigDecimal.ZERO) == 0) {
             Map<String, String> notifyMap = new HashMap<>();
             notifyMap.put("tradeState", "1");