|
|
@@ -46,6 +46,8 @@ import com.ruoyi.system.mapper.PosOrderMapper;
|
|
|
import com.ruoyi.system.mapper.PosOrderPromotionMapper;
|
|
|
import com.ruoyi.system.mapper.RiderPositionMapper;
|
|
|
import com.ruoyi.system.mapper.UserBillingMapper;
|
|
|
+import com.ruoyi.system.omgpay.domain.OmgPaymentAttempt;
|
|
|
+import com.ruoyi.system.omgpay.service.IOmgPaymentAttemptService;
|
|
|
import com.ruoyi.system.service.*;
|
|
|
import com.ruoyi.system.utils.Auth;
|
|
|
import com.ruoyi.system.utils.GetArea;
|
|
|
@@ -161,6 +163,8 @@ public class PosOrderController extends BaseController {
|
|
|
private com.ruoyi.app.pay.LinePayOrderGuard linePayOrderGuard;
|
|
|
@Autowired
|
|
|
private IPosOrderLinePaymentService linePaymentService;
|
|
|
+ @Autowired
|
|
|
+ private IOmgPaymentAttemptService omgPaymentAttemptService;
|
|
|
|
|
|
|
|
|
//查询用户足迹
|
|
|
@@ -637,9 +641,47 @@ public class PosOrderController extends BaseController {
|
|
|
query.eq("rider_id", orlist.getQsId());
|
|
|
org.put("RiderPosition", orlist.getQsId() == null ? null : riderPositionService.getOne(query));
|
|
|
org.put("food", JSONArray.parseArray(orlist.getFood()));
|
|
|
+ // 已支付订单附带支付商交易单号,供平台到支付商后台按单号查询交易详情
|
|
|
+ org.put("payTrade", buildPayTrade(orlist));
|
|
|
return success(org);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 已支付订单的支付商交易单号信息,供平台在支付商后台按单号查询交易详情。
|
|
|
+ * OMG 返回 MerchantTradeNo(支付商侧查询键)与网关 TradeNo;
|
|
|
+ * LINE Pay 返回 lineOrderId 与 transactionId;其他渠道(到付等)返回 null。
|
|
|
+ */
|
|
|
+ private JSONObject buildPayTrade(PosOrder order) {
|
|
|
+ // 已退款订单同样需要单号到支付商侧核对退款,因此仅排除未支付
|
|
|
+ if (order.getPayStatus() == null || order.getPayStatus() == 0L) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JSONObject trade = new JSONObject();
|
|
|
+ if (OrderLifecycleService.PAY_TYPE_OMG.equals(order.getPayType())) {
|
|
|
+ OmgPaymentAttempt attempt = omgPaymentAttemptService.selectPaidByDdId(order.getDdId());
|
|
|
+ if (attempt == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ trade.put("channel", "OMG");
|
|
|
+ trade.put("merchantTradeNo", attempt.getMerchantTradeNo());
|
|
|
+ trade.put("gatewayTradeNo", attempt.getTradeNo());
|
|
|
+ } else if (LinePayService.PAY_TYPE_LINE.equals(order.getPayType())) {
|
|
|
+ PosOrderLinePayment paid = linePaymentService.getByDdId(order.getDdId()).stream()
|
|
|
+ .filter(payment -> "PAID".equals(payment.getStatus()))
|
|
|
+ .max(Comparator.comparing(PosOrderLinePayment::getId))
|
|
|
+ .orElse(null);
|
|
|
+ if (paid == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ trade.put("channel", "LINE Pay");
|
|
|
+ trade.put("lineOrderId", paid.getLineOrderId());
|
|
|
+ trade.put("transactionId", paid.getTransactionId());
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return trade;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 通过订单号查询订单详情
|
|
|
*
|