|
@@ -2999,6 +2999,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
|
|
|
Long ingOrderNum=statusOrderNumMap.get(DealStatusEnum.ING);
|
|
|
if(Objects.nonNull(ingOrderNum)&&ingOrderNum>1&&order.getStatus().equals(DealStatusEnum.FAILED)){
|
|
|
+ if(Objects.nonNull(order.getBalancePaymentAmount())){
|
|
|
+ sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "网管课购买失败");
|
|
|
+ }
|
|
|
studentPaymentOrderDao.update(order);
|
|
|
return;
|
|
|
}
|
|
@@ -3175,7 +3178,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
|
|
|
- public HttpResponseResult repay(Integer userId,Integer practiceGroupId) {
|
|
|
+ public HttpResponseResult repay(Integer userId,Integer practiceGroupId, boolean useBalancePayment) {
|
|
|
if(Objects.isNull(practiceGroupId)){
|
|
|
throw new BizException("请指定需要重新支付的课程组");
|
|
|
}
|
|
@@ -3183,9 +3186,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
if(Objects.isNull(practiceGroup)){
|
|
|
return BaseController.failed(HttpStatus.FAILED_DEPENDENCY, "该课程组已失效,请重新购买");
|
|
|
}
|
|
|
- if(practiceGroup.getGroupStatus().equals(GroupStatusEnum.NORMAL)){
|
|
|
- return BaseController.failed(HttpStatus.CREATED, "该订单已经支付成功");
|
|
|
- }
|
|
|
+// if(practiceGroup.getGroupStatus().equals(GroupStatusEnum.NORMAL)){
|
|
|
+// return BaseController.failed(HttpStatus.CREATED, "该订单已经支付成功");
|
|
|
+// }
|
|
|
if(practiceGroup.getGroupStatus().equals(GroupStatusEnum.CANCEL)){
|
|
|
return BaseController.failed(HttpStatus.FAILED_DEPENDENCY, "该课程组已失效,请重新购买");
|
|
|
}
|
|
@@ -3193,7 +3196,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
Map<DealStatusEnum, List<StudentPaymentOrder>> statusOrderMap = userGroupOrders.stream().collect(Collectors.groupingBy(StudentPaymentOrder::getStatus));
|
|
|
List<StudentPaymentOrder> successOrders=statusOrderMap.get(DealStatusEnum.SUCCESS);
|
|
|
if(!CollectionUtils.isEmpty(successOrders)&&successOrders.size()>0){
|
|
|
- return BaseController.failed(HttpStatus.CREATED, "该订单已经支付成功");
|
|
|
+ Map<String, Object> result=new HashMap<>();
|
|
|
+ result.put("orderNo", successOrders.get(0).getOrderNo());
|
|
|
+ return BaseController.succeed(result);
|
|
|
}
|
|
|
|
|
|
StudentPaymentOrder latestOrder=userGroupOrders.stream().max(Comparator.comparing(StudentPaymentOrder::getId)).get();
|
|
@@ -3205,13 +3210,46 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
if(CollectionUtils.isEmpty(ingOrders)||ingOrders.size()<=0){
|
|
|
return BaseController.failed(HttpStatus.FAILED_DEPENDENCY, "该课程组已失效,请重新购买");
|
|
|
}
|
|
|
-// else{
|
|
|
-// for (StudentPaymentOrder ingOrder : ingOrders) {
|
|
|
-// ingOrder.setStatus(DealStatusEnum.CLOSE);
|
|
|
-// ingOrder.setMemo("用户重新支付");
|
|
|
-// studentPaymentOrderDao.update(ingOrder);
|
|
|
-// }
|
|
|
-// }
|
|
|
+
|
|
|
+ newOrder.setActualAmount(newOrder.getExpectAmount());
|
|
|
+ newOrder.setBalancePaymentAmount(new BigDecimal(0));
|
|
|
+ newOrder.setStatus(DealStatusEnum.ING);
|
|
|
+ newOrder.setVersion(0);
|
|
|
+ studentPaymentOrderService.insert(newOrder);
|
|
|
+
|
|
|
+ if(useBalancePayment || newOrder.getExpectAmount().doubleValue() == 0){
|
|
|
+ SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
|
|
|
+ if(userCashAccount == null){
|
|
|
+ throw new BizException("用户账户找不到");
|
|
|
+ }
|
|
|
+ newOrder.setPaymentChannel("BALANCE");
|
|
|
+ if(userCashAccount.getBalance().subtract(newOrder.getExpectAmount()).doubleValue() >= 0){
|
|
|
+ // 更新订单信息
|
|
|
+ newOrder.setActualAmount(new BigDecimal(0));
|
|
|
+ newOrder.setBalancePaymentAmount(newOrder.getExpectAmount());
|
|
|
+ newOrder.setStatus(DealStatusEnum.SUCCESS);
|
|
|
+ newOrder.setUpdateTime(new Date());
|
|
|
+ newOrder.setOrganId(practiceGroup.getOrganId());
|
|
|
+
|
|
|
+ sysUserCashAccountService.updateBalance(userId, newOrder.getExpectAmount().negate(),PlatformCashAccountDetailTypeEnum.PAY_FEE,"网管课购买");
|
|
|
+
|
|
|
+ this.orderCallback(newOrder);
|
|
|
+
|
|
|
+ Map<String,Object> result=new HashMap<>();
|
|
|
+ result.put("orderNo",newOrder.getOrderNo());
|
|
|
+
|
|
|
+ return BaseController.succeed(result);
|
|
|
+ }else{
|
|
|
+ if (userCashAccount.getBalance().doubleValue() > 0) {
|
|
|
+ sysUserCashAccountService.updateBalance(userId, userCashAccount.getBalance().negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "网管课购买");
|
|
|
+ BigDecimal amount = newOrder.getExpectAmount().subtract(userCashAccount.getBalance());
|
|
|
+ newOrder.setActualAmount(amount);
|
|
|
+ newOrder.setBalancePaymentAmount(userCashAccount.getBalance());
|
|
|
+ } else {
|
|
|
+ newOrder.setBalancePaymentAmount(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
String orderNo=idGeneratorService.generatorId("payment") + "";
|
|
|
String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
|
|
@@ -3243,7 +3281,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
newOrder.setPaymentChannel((String) payMap.get("type"));
|
|
|
newOrder.setUpdateTime(new Date());
|
|
|
newOrder.setCreateTime(new Date());
|
|
|
- studentPaymentOrderService.insert(newOrder);
|
|
|
+ studentPaymentOrderService.update(newOrder);
|
|
|
|
|
|
return BaseController.succeed(payMap);
|
|
|
} catch (Exception e) {
|
|
@@ -3286,6 +3324,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
if(practiceGroup.getGroupStatus().equals(GroupStatusEnum.LOCK)){
|
|
|
groupService.deleteGroupOtherInfo(groupId.toString(),GroupType.PRACTICE);
|
|
|
practiceGroup.setGroupStatus(GroupStatusEnum.CANCEL);
|
|
|
+ practiceGroupDao.update(practiceGroup);
|
|
|
}else if(practiceGroup.getGroupStatus().equals(GroupStatusEnum.NORMAL)){
|
|
|
return BaseController.failed(HttpStatus.CREATED, "该订单已经支付成功");
|
|
|
}else if(practiceGroup.getGroupStatus().equals(GroupStatusEnum.CANCEL)){
|