|
|
@@ -20,6 +20,7 @@ use app\common\enum\YesNoEnum;
|
|
|
use app\common\model\effective\EffectiveCategory;
|
|
|
use app\common\model\pay\PayWay;
|
|
|
use app\common\model\recharge\RechargeOrder;
|
|
|
+use app\common\model\shops\ShopOrders;
|
|
|
use app\common\model\user\User;
|
|
|
use app\common\service\pay\AliPayService;
|
|
|
use app\common\service\pay\WeChatPayService;
|
|
|
@@ -138,8 +139,6 @@ class PaymentLogic extends BaseLogic
|
|
|
* @notes 获取预支付订单信息
|
|
|
* @param $params
|
|
|
* @return RechargeOrder|array|false|\think\Model
|
|
|
- * @author 段誉
|
|
|
- * @date 2023/2/27 15:19
|
|
|
*/
|
|
|
public static function getPayOrderInfo($params)
|
|
|
{
|
|
|
@@ -167,6 +166,30 @@ class PaymentLogic extends BaseLogic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @notes 获取电子商城预支付订单信息
|
|
|
+ * @param $params
|
|
|
+ * @return RechargeOrder|array|false|\think\Model
|
|
|
+ */
|
|
|
+ public static function getPayShopOrderInfo($params)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $order = ShopOrders::findOrEmpty($params['order_id']);
|
|
|
+ if ($order->isEmpty()) {
|
|
|
+ throw new Exception('订单不存在');
|
|
|
+ }
|
|
|
+ if ($order['pay_status'] == PayEnum::ISPAID) {
|
|
|
+ throw new Exception('订单已支付');
|
|
|
+ }
|
|
|
+ return $order;
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ self::$error = $e->getMessage();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @notes 支付
|
|
|
* @param $payWay
|
|
|
@@ -288,6 +311,55 @@ class PaymentLogic extends BaseLogic
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @notes 电子商城支付
|
|
|
+ * @param $payWay
|
|
|
+ * @param $from
|
|
|
+ * @param $order
|
|
|
+ * @param $terminal
|
|
|
+ * @param $redirectUrl
|
|
|
+ * @return array|false|mixed|string|string[]
|
|
|
+ * @throws \Exception
|
|
|
+ */
|
|
|
+ public static function shopPay($payWay, $from, $order, $terminal, $redirectUrl)
|
|
|
+ {
|
|
|
+ // 支付编号-仅为微信支付预置(同一商户号下不同客户端支付需使用唯一订单号)
|
|
|
+ $paySn = $order['sn'];
|
|
|
+ if ($payWay == PayEnum::WECHAT_PAY) {
|
|
|
+ $paySn = self::formatOrderSn($order['sn'], $terminal);
|
|
|
+ }
|
|
|
+ //更新支付方式
|
|
|
+ switch ($from) {
|
|
|
+ case 'shop_goods':
|
|
|
+ ShopOrders::update(['pay_way' => $payWay, 'pay_sn' => $paySn], ['id' => $order['id']]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($order['order_amount'] == 0) {
|
|
|
+ PayNotifyLogic::handle($from, $order['sn']);
|
|
|
+ return ['sn' => $order['sn'],'need_pay'=>0];
|
|
|
+ }
|
|
|
+
|
|
|
+ $payService = null;
|
|
|
+ switch ($payWay) {
|
|
|
+ case PayEnum::WECHAT_PAY:
|
|
|
+ $payService = (new WorkerWeChatPayService($terminal, $userInfo['user_id'] ?? null));
|
|
|
+ $order['pay_sn'] = $paySn;
|
|
|
+ $order['redirect_url'] = $redirectUrl;
|
|
|
+ $result = $payService->pay($from, $order);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ self::$error = '订单异常';
|
|
|
+ $result = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (false === $result && !self::hasError()) {
|
|
|
+ self::setError($payService->getError());
|
|
|
+ }
|
|
|
+// $result['need_pay'] = 1;
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @notes 设置订单号 支付回调时截取前面的单号 18个
|
|
|
* @param $orderSn
|