|
|
@@ -14,6 +14,7 @@ namespace app\api\model;
|
|
|
|
|
|
use app\common\model\PaymentTrade as PaymentTradeModel;
|
|
|
use app\common\enum\payment\trade\TradeStatus as TradeStatusEnum;
|
|
|
+use cores\exception\BaseException;
|
|
|
|
|
|
/**
|
|
|
* 模型类:第三方支付交易记录
|
|
|
@@ -61,8 +62,34 @@ class PaymentTrade extends PaymentTradeModel
|
|
|
'user_id' => $orderInfo['user_id'],
|
|
|
'out_trade_no' => $payment['out_trade_no'] ?? '',
|
|
|
'prepay_id' => $payment['prepay_id'] ?? '',
|
|
|
- 'trade_status' => TradeStatusEnum::NOTPAY,
|
|
|
+ 'trade_status' => TradeStatusEnum::UNPAID,
|
|
|
'store_id' => self::$storeId,
|
|
|
]);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据订单ID查询记录
|
|
|
+ * @param int $orderId 订单ID
|
|
|
+ * @param int $orderType 订单类型
|
|
|
+ * @return static|array|\think\Model|null
|
|
|
+ * @throws BaseException
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ private function detailByOrderId(int $orderId, string $method, string $client, int $orderType)
|
|
|
+ {
|
|
|
+ $detail = $this->where('order_id', '=', $orderId)
|
|
|
+ ->where('order_type', '=', $orderType)
|
|
|
+ ->where('client', '=', $client)
|
|
|
+ ->where('pay_method', '=', $method)
|
|
|
+ ->find();
|
|
|
+ if (empty($detail)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (\in_array($detail['trade_state'], [TradeStatusEnum::SUCCESS, TradeStatusEnum::REFUND])) {
|
|
|
+ throwError('该支付订单已完成交易');
|
|
|
+ }
|
|
|
+ return $detail;
|
|
|
+ }
|
|
|
}
|