|
@@ -26,6 +26,7 @@ import com.ym.mec.util.collection.MapUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
@@ -53,6 +54,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
private SysUserCashAccountDao sysUserCashAccountDao;
|
|
|
@Autowired
|
|
|
private StudentRepairService studentRepairService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserCashAccountService sysUserCashAccountService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, StudentPaymentOrder> getDAO() {
|
|
@@ -193,9 +196,30 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
closeOrders(orderNoList);
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void updateOrder(Map<String, String> rpMap) throws Exception {
|
|
|
DealStatusEnum status = rpMap.get("tradeState").equals("1") ? DealStatusEnum.SUCCESS : DealStatusEnum.FAILED;
|
|
|
StudentPaymentOrder order = findOrderByOrderNo(rpMap.get("merOrderNo"));
|
|
|
+ //关闭或失败的订单查询订单成功,订单改成成功,钱退到余额
|
|
|
+ if (order != null && !order.getStatus().equals(DealStatusEnum.ING) && status.equals(DealStatusEnum.SUCCESS)) {
|
|
|
+ String memo = order.getStatus().equals(DealStatusEnum.CLOSE) ? "关闭订单" : "失败订单";
|
|
|
+ memo = memo+",实际支付成功,退到用户余额";
|
|
|
+ //更新订单状态
|
|
|
+ order.setStatus(status);
|
|
|
+ order.setTransNo(rpMap.get("orderNo"));
|
|
|
+ order.setPaymentBusinessChannel(rpMap.get("channelType"));
|
|
|
+ order.setPayTime(new Date());
|
|
|
+ order.setMemo(memo);
|
|
|
+ int updateCount = this.update(order);
|
|
|
+ if (updateCount <= 0) {
|
|
|
+ throw new BizException("订单更新失败");
|
|
|
+ }
|
|
|
+ //增加用户余额
|
|
|
+ sysUserCashAccountService.updateBalance(order.getUserId(), order.getActualAmount(),
|
|
|
+ PlatformCashAccountDetailTypeEnum.REFUNDS, memo+",订单号:"+order.getOrderNo());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (order == null || !order.getStatus().equals(DealStatusEnum.ING)) {
|
|
|
return;
|
|
|
}
|
|
@@ -335,10 +359,6 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
@Override
|
|
|
public Boolean getOrderStatus(Long id) throws Exception {
|
|
|
StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.get(id);
|
|
|
- studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
|
- if (studentPaymentOrderDao.update(studentPaymentOrder) <= 0) {
|
|
|
- throw new BizException("订单状态更新失败,请重试");
|
|
|
- }
|
|
|
List<StudentPaymentOrder> orderList = new ArrayList<>();
|
|
|
orderList.add(studentPaymentOrder);
|
|
|
if (studentPaymentOrder.getPaymentChannel().equals("ADAPAY")) {
|