|
@@ -28,11 +28,15 @@ import cn.newfeifan.mall.module.pay.enums.fuyouorder.OrderTypeEnum;
|
|
|
import cn.newfeifan.mall.module.pay.enums.notify.PayNotifyTypeEnum;
|
|
|
import cn.newfeifan.mall.module.pay.enums.order.PayOrderStatusEnum;
|
|
|
import cn.newfeifan.mall.module.pay.framework.pay.config.PayProperties;
|
|
|
+import cn.newfeifan.mall.module.pay.order.TradeOrderProducer;
|
|
|
import cn.newfeifan.mall.module.pay.service.app.PayAppService;
|
|
|
import cn.newfeifan.mall.module.pay.service.channel.PayChannelService;
|
|
|
+import cn.newfeifan.mall.module.pay.service.fuyouorder.FuYouPayOrderService;
|
|
|
import cn.newfeifan.mall.module.pay.service.notify.PayNotifyService;
|
|
|
+import cn.newfeifan.mall.module.pay.topupconsumptionpoints.TopUpConsumptionPointsProducer;
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -64,6 +68,13 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
@Resource
|
|
|
private PayOrderMapper orderMapper;
|
|
|
@Resource
|
|
|
+ @Lazy
|
|
|
+ private FuYouPayOrderService fuYouPayOrderService;
|
|
|
+ @Resource
|
|
|
+ private TradeOrderProducer tradeOrderProducer;
|
|
|
+ @Resource
|
|
|
+ private TopUpConsumptionPointsProducer topUpConsumptionPointsProducer;
|
|
|
+ @Resource
|
|
|
private PayOrderExtensionMapper orderExtensionMapper;
|
|
|
@Resource
|
|
|
private PayNoRedisDAO noRedisDAO;
|
|
@@ -421,6 +432,19 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
if (updateCounts == 0) { // 校验状态,必须是待支付
|
|
|
throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING);
|
|
|
}
|
|
|
+
|
|
|
+ PayOrderDO payOrderDO = orderMapper.selectById(order.getId());
|
|
|
+ System.out.println(payOrderDO.getStatus());
|
|
|
+
|
|
|
+ // 判断是商品订单还是充值订单
|
|
|
+ if (payOrderDO.getNo().contains(DictTypeConstants.TUP_UP_NO)) {
|
|
|
+ // 充值消费分订单
|
|
|
+ topUpConsumptionPointsProducer.sendTradeOrderMessage(payOrderDO);
|
|
|
+ } else {
|
|
|
+ //如果确实是漏了订单未支付成功,那就补充回来
|
|
|
+ tradeOrderProducer.sendTradeOrderMessage(order.getId());
|
|
|
+ }
|
|
|
+
|
|
|
log.info("[updateOrderExtensionSuccess][order({}) 更新为已支付]", order.getId());
|
|
|
return false;
|
|
|
}
|
|
@@ -533,6 +557,28 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
*/
|
|
|
public boolean syncOrder(PayOrderExtensionDO orderExtension) {
|
|
|
try {
|
|
|
+
|
|
|
+ // 如果是对接富友的支付单,则查询富友的订单状态
|
|
|
+ if (channelService.getChannelById(orderExtension.getChannelId())) {
|
|
|
+ PayOrderDO order = orderMapper.selectById(orderExtension.getOrderId());
|
|
|
+
|
|
|
+ // 查询状态,修改支付订单状态
|
|
|
+ PayOrderDO payOrder = fuYouPayOrderService.getPayOrderByStatus(order);
|
|
|
+
|
|
|
+ // 支付单状态发生变化才更新
|
|
|
+ if (payOrder != null && !payOrder.getStatus().equals(order.getStatus()) && payOrder.getStatus().equals(PayOrderStatusEnum.SUCCESS.getStatus())) {
|
|
|
+ // 判断是商品订单还是充值订单
|
|
|
+ if (payOrder.getPayOrderNo().contains(DictTypeConstants.TUP_UP_NO)) {
|
|
|
+ // 充值消费分订单
|
|
|
+ topUpConsumptionPointsProducer.sendTradeOrderMessage(payOrder);
|
|
|
+ } else {
|
|
|
+ // 修改订单状态
|
|
|
+ tradeOrderProducer.sendTradeOrderMessage(order.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
// 1.1 查询支付订单信息
|
|
|
PayClient payClient = channelService.getPayClient(orderExtension.getChannelId());
|
|
|
if (payClient == null) {
|
|
@@ -589,6 +635,11 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) {
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
+ if (channelService.getChannelById(orderExtension.getChannelId())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
// 情况一:校验数据库中的 orderExtension 是不是已支付
|
|
|
if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) {
|
|
|
log.error("[expireOrder][order({}) 的 extension({}) 已支付,可能是数据不一致]",
|