| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace addons\YunfastPay\common\models;
- use addons\YunfastPay\common\enums\YunfastPayEnum;
- use addons\YunfastPay\common\enums\YunfastPayTypeEnum;
- use common\models\common\PaymentTradeOrder as PaymentTradeOrderModel;
- use common\models\order\Order;
- /**
- * Mall PaymentTradeOrder
- * @package addons\YunfastPay\common\models
- */
- class PaymentTradeOrder extends PaymentTradeOrderModel
- {
- /**
- * 根据支付订单ID获取是否有门店相关信息
- *
- * @param integer $id
- * @return array
- */
- public static function getStoreInfoByTradeId(int $id)
- {
- return Order::find()
- ->where([
- 'pay_status' => 0,
- 'order_no' => PaymentTradeOrder::find()
- ->where(['trade_id' => $id])
- ->select('order_no')
- ->column(),
- ])
- ->select(['store_id', 'pay_money'])
- ->all();
- }
- /**
- * 通过收银台订单号查找支付订单
- *
- * @param string $order_no
- * @return int|null|false
- */
- public static function getPaymentIdByCashierOrderNo(string $order_no)
- {
- return static::getPaymentIdByOrderNo($order_no, YunfastPayEnum::CASHIER_ORDER);
- }
- /**
- * 通过商城订单号查找支付订单
- *
- * @param string $order_no
- * @param string $order_type
- * @return int|null|false
- */
- public static function getPaymentIdByMallOrderNo(string $order_no, string $order_type = YunfastPayEnum::MALL_ORDER)
- {
- return static::getPaymentIdByOrderNo($order_no, $order_type ?: YunfastPayEnum::MALL_ORDER);
- }
- /**
- * 通过订单号查找支付订单
- *
- * @param string $order_no
- * @return int|null|false
- */
- public static function getPaymentIdByOrderNo(string $order_no, string $order_type)
- {
- return static::find()
- ->where([
- 'order_no' => $order_no,
- 'is_pay' => 1,
- 'pay_type' => YunfastPayTypeEnum::YUNFAST_PAY_NUM,
- 'order_type' => $order_type,
- ])
- ->select('trade_id')
- ->scalar();
- }
- }
|