|
@@ -19,10 +19,12 @@ import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
import com.yonge.cooleshow.common.service.IdGeneratorService;
|
|
|
import com.yonge.toolset.base.result.BaseResult;
|
|
|
+import com.yonge.toolset.payment.base.enums.OpenEnum;
|
|
|
import com.yonge.toolset.payment.base.enums.PaymentClientEnum;
|
|
|
import com.yonge.toolset.payment.base.enums.TradeStatusEnum;
|
|
|
import com.yonge.toolset.payment.base.model.Payment;
|
|
|
import com.yonge.toolset.payment.base.model.callback.PaymentCallBack;
|
|
|
+import com.yonge.toolset.payment.core.props.PaymentProperties;
|
|
|
import com.yonge.toolset.payment.core.service.PaymentClient;
|
|
|
import com.yonge.toolset.utils.string.StringUtil;
|
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
@@ -72,6 +74,8 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
|
|
|
private PianoRoomBuyRecordService pianoRoomBuyRecordService;
|
|
|
@Autowired
|
|
|
private RedissonClient redissonClient;
|
|
|
+ @Autowired
|
|
|
+ private PaymentProperties paymentProperties;
|
|
|
|
|
|
//验证订单是否可以下单,获取订单金额信息
|
|
|
private static final Map<GoodTypeEnum, Function<OrderReq.OrderReqInfo, HttpResponseResult<OrderCreateRes>>> orderCreate = new HashMap<>();
|
|
@@ -200,7 +204,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
|
|
|
query.setStatus("WAIT_PAY,PAYING");
|
|
|
List<UserOrderVo> userOrderVos = selectList(query);
|
|
|
for (UserOrderVo userOrderVo : userOrderVos) {
|
|
|
- orderSuccess(userOrderVo);
|
|
|
+ testOrderSuccess(userOrderVo);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -227,7 +231,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
|
|
|
doOrderCancel(detail, orderStatus, "测试接口-订单交易失败");
|
|
|
}
|
|
|
if (OrderStatusEnum.PAID.equals(orderStatus)) {
|
|
|
- orderSuccess(detail);
|
|
|
+ testOrderSuccess(detail);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -313,7 +317,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
|
|
|
//入订单付款表,同时修改订单状态
|
|
|
doOrderCancel(detail, OrderStatusEnum.FAIL, e.getMessage());
|
|
|
return HttpResponseResult.failed(e.getMessage());
|
|
|
- } catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
//入订单付款表,同时修改订单状态
|
|
|
doOrderCancel(detail, OrderStatusEnum.FAIL, e.getMessage());
|
|
|
return HttpResponseResult.failed("付款失败");
|
|
@@ -640,8 +644,8 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
+ log.error("订单完成-更新付款单失败, UserOrderVo is {},PaymentCallBack is {}", JSONObject.toJSONString(detail), JSONObject.toJSONString(data));
|
|
|
e.printStackTrace();
|
|
|
- log.error("完成订单失败,参数{}", JSONObject.toJSONString(data));
|
|
|
}
|
|
|
//调用业务
|
|
|
List<UserOrderDetailVo> orderDetailList = orderDetailService.getOrderDetilListByOrderNo(detail.getOrderNo());
|
|
@@ -654,14 +658,34 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
|
|
|
userOrderVoConsumer.accept(orderDetailVo);
|
|
|
}
|
|
|
Long merchId = orderDetailVo.getMerchId();
|
|
|
- if (null != merchId) {
|
|
|
+ if (merchId != null && merchId != 0) {
|
|
|
+
|
|
|
redissonClient.getBucket(CacheNameEnum.TEACHER_SUBJECT_ITEM.getRedisKey(merchId)).delete();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
//清除老师声部缓存
|
|
|
redissonClient.getBucket(CacheNameEnum.STUDENT_SUBJECT_ITEM.getRedisKey(detail.getUserId())).delete();
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void testOrderSuccess(UserOrderVo detail) {
|
|
|
+ UserOrderPayment orderPayment = new UserOrderPayment();
|
|
|
+
|
|
|
+ OpenEnum openType = OpenEnum.valueOf(paymentProperties.getOpenType());
|
|
|
+ orderPayment.setOpenType(openType);
|
|
|
+
|
|
|
+ orderPayment.setOrderNo(detail.getOrderNo());
|
|
|
+
|
|
|
+ //支付订单号生成
|
|
|
+ Long paymentNo = idGeneratorService.generatorId("paymentNo");
|
|
|
+ orderPayment.setPaymentNo(paymentNo.toString());
|
|
|
+
|
|
|
+ orderPayment.setPayAmt(detail.getActualPrice());
|
|
|
+ orderPayment.setStatus(TradeStatusEnum.succeeded);
|
|
|
+
|
|
|
+ //保存新的付款单
|
|
|
+ orderPaymentService.save(orderPayment);
|
|
|
+ orderSuccess(detail, null);
|
|
|
+ }
|
|
|
+
|
|
|
}
|