|
|
@@ -2247,6 +2247,57 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
|
|
|
+ public R payConfirmReward(LiveOrder liveOrder) {
|
|
|
+ Long orderId = liveOrder.getOrderId();
|
|
|
+ if(orderId==null) return R.error("订单ID不存在");
|
|
|
+ Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
|
|
|
+ try {
|
|
|
+ liveOrder = baseMapper.selectLiveOrderByOrderId(String.valueOf(orderId));
|
|
|
+ if(liveOrder==null || !liveOrder.getStatus().equals(1)){
|
|
|
+ throw new CustomException("当前订单未找到或者订单状态不为待支付! orderId:" + orderId);
|
|
|
+ }
|
|
|
+ String payCode = liveOrder.getOrderCode();
|
|
|
+
|
|
|
+ LiveOrderPayment storePayment = liveOrderPaymentMapper.selectLiveOrderPaymentByPaymentCode(payCode);
|
|
|
+ if (storePayment!=null){
|
|
|
+ if(storePayment.getStatus().equals(0)){
|
|
|
+ LiveOrderPayment paymentMap=new LiveOrderPayment();
|
|
|
+ paymentMap.setPaymentId(storePayment.getPaymentId());
|
|
|
+ paymentMap.setStatus(1);
|
|
|
+ paymentMap.setPayTime(new Date());
|
|
|
+ liveOrderPaymentMapper.updateLiveOrderPayment(paymentMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ log.info("支付单号不存在:"+payCode);
|
|
|
+ throw new CustomException("当前支付记录未找到!");
|
|
|
+ }
|
|
|
+ if(liveOrder.getStatus()!=1){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return R.error("当前订单未找到或者订单状态不为待支付!");
|
|
|
+ }
|
|
|
+ //增加用户购买次数
|
|
|
+ userService.incPayCount(Long.valueOf(liveOrder.getUserId()));
|
|
|
+
|
|
|
+ liveOrder.setStatus(2);
|
|
|
+ liveOrder.setPayTime(LocalDateTime.now());
|
|
|
+ baseMapper.updateLiveOrder(liveOrder);
|
|
|
+ return R.ok("支付成功");
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("抽奖订单支付错误:"+e.getMessage());
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
|
|
|
+ LiveOrderPaymentError err = new LiveOrderPaymentError();
|
|
|
+ err.setOrderNo(String.valueOf(orderId));
|
|
|
+ err.setStatus(0);
|
|
|
+ err.setMsg("抽奖订单支付错误:"+e.getMessage());
|
|
|
+ err.setCreateTime(DateUtils.getNowDate());
|
|
|
+ liveOrderPaymentErrorMapper.insertLiveOrderPaymentError(err);
|
|
|
+ return R.error("支付失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
|