Bläddra i källkod

2022考级报名

zouxuan 3 år sedan
förälder
incheckning
1f33cb9da2

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/DegreeRegistration.java

@@ -134,7 +134,7 @@ public class DegreeRegistration extends BaseEntity {
     private Date updateTime;
 
     /**
-     * 0-未支付 1-支付中 2-支付中
+     * 0-未支付 1-支付中 2-已支付 2-已退费
      */
     private Integer status;
 

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/DegreeRegistrationService.java

@@ -31,4 +31,7 @@ public interface DegreeRegistrationService extends BaseService<Integer, DegreeRe
     PageInfoDegree<DegreeRegistration> getPageList(DegreeQueryInfo queryInfo);
 
     HttpResponseResult check(DegreeRegistrationActivityDto degreeRegistration);
+
+    //考级退费
+    int refund(Integer degreeRegistrationId);
 }

+ 27 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/DegreeRegistrationServiceImpl.java

@@ -502,4 +502,31 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
         }
         return BaseController.succeed();
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int refund(Integer degreeRegistrationId) {
+        DegreeRegistration degreeRegistration = degreeRegistrationDao.getLock(degreeRegistrationId);
+        if(Objects.isNull(degreeRegistration)){
+            throw new BizException("报名信息不存在");
+        }
+        if(degreeRegistration.getStatus() != 2){
+            throw new BizException("当前状态不支持退费");
+        }
+        StudentPaymentOrder order = studentPaymentOrderService.findOrderByOrderNo(degreeRegistration.getOrderNo());
+        if(Objects.isNull(order)){
+            throw new BizException("订单信息不存在");
+        }
+        if(order.getStatus() != DealStatusEnum.SUCCESS){
+            throw new BizException("当前订单状态不支持退费");
+        }
+        //退到账户余额
+        if(degreeRegistration.getMoney().compareTo(BigDecimal.ZERO) <= 0){
+            throw new BizException("订单金额异常");
+        }
+        sysUserCashAccountService.updateBalance(order.getUserId(), degreeRegistration.getMoney(), PlatformCashAccountDetailTypeEnum.REFUNDS, "考级退费");
+        degreeRegistration.setStatus(3);
+        degreeRegistration.setUpdateTime(new Date());
+        return degreeRegistrationDao.update(degreeRegistration);
+    }
 }

+ 8 - 0
mec-web/src/main/java/com/ym/mec/web/controller/DegreeController.java

@@ -11,6 +11,7 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -34,4 +35,11 @@ public class DegreeController extends BaseController { ;
         return succeed(degreeRegistrationService.getPageList(queryInfo));
     }
 
+    @ApiOperation(value = "退费")
+    @PostMapping("/refund")
+    @PreAuthorize("@pcs.hasPermissions('degree/refund')")
+    public HttpResponseResult refund(Integer degreeRegistrationId) {
+        return succeed(degreeRegistrationService.refund(degreeRegistrationId));
+    }
+
 }