浏览代码

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan 5 年之前
父节点
当前提交
392d912df1

+ 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;
+    }
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/RepairStudentQueryInfo.java

@@ -24,6 +24,8 @@ public class RepairStudentQueryInfo extends QueryInfo {
 
     private Integer studentId;
 
+    private Integer payStatus;
+
     public Integer getSubjectId() {
         return subjectId;
     }
@@ -87,4 +89,12 @@ public class RepairStudentQueryInfo extends QueryInfo {
     public void setStudentId(Integer studentId) {
         this.studentId = studentId;
     }
+
+    public Integer getPayStatus() {
+        return payStatus;
+    }
+
+    public void setPayStatus(Integer payStatus) {
+        this.payStatus = payStatus;
+    }
 }

+ 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");

+ 5 - 2
mec-biz/src/main/resources/config/mybatis/StudentRepairMapper.xml

@@ -189,6 +189,9 @@
             <if test="repairStatus != null">
                 AND sr.repair_status_ = #{repairStatus}
             </if>
+            <if test="payStatus != null">
+                AND sr.pay_status_ = #{payStatus}
+            </if>
             <if test="startTime != null">
                 AND sr.create_time_ >= #{startTime}
             </if>
@@ -240,11 +243,11 @@
         SELECT su.real_name_ username_, su.id_ user_id_, su.avatar_ head_url_
         FROM music_group mg
                  LEFT JOIN student_registration sr on sr.music_group_id_ = mg.id_
-                 LEFT JOIN sys_user su ON su.id_ = sr.id_
+                 LEFT JOIN sys_user su ON su.id_ = sr.user_id_
         WHERE sr.user_id_ = #{studentId}
           AND mg.status_ = 'PROGRESS'
           AND mg.repair_user_id_ IS NOT NULL
-        ORDER BY id_ DESC
+        ORDER BY mg.id_ DESC
         LIMIT 1
     </select>
 

+ 2 - 1
mec-student/src/main/java/com/ym/mec/student/controller/RepairController.java

@@ -40,6 +40,7 @@ public class RepairController extends BaseController {
             return failed("用户信息获取失败");
         }
         queryInfo.setStudentId(sysUser.getId());
+        queryInfo.setPayStatus(2);
         return succeed(studentRepairService.queryPage(queryInfo));
     }
 
@@ -69,7 +70,7 @@ public class RepairController extends BaseController {
 
     @ApiOperation("获取维修技师信息")
     @PostMapping(value = "/getRepairer")
-    public HttpResponseResult getRepairer() throws Exception {
+    public HttpResponseResult getRepairer() {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
             return failed(HttpStatus.FORBIDDEN, "请登录");

+ 1 - 0
mec-web/src/main/java/com/ym/mec/web/controller/education/EduRepairController.java

@@ -74,6 +74,7 @@ public class EduRepairController extends BaseController {
             return failed("用户信息获取失败");
         }
         queryInfo.setEmployeeId(sysUser.getId());
+        queryInfo.setPayStatus(2);
         return succeed(studentRepairService.queryPage(queryInfo));
     }