whitefang 1 год назад
Родитель
Сommit
4bf554935c

+ 3 - 4
app/common/logic/PaymentLogic.php

@@ -179,8 +179,9 @@ class PaymentLogic extends BaseLogic
      * @author mjf
      * @date 2024/3/18 16:49
      */
-    public static function pay($payWay, $from, $order, $terminal, $redirectUrl)
+    public static function pay($payWay, $from, $order, $userInfo, $redirectUrl)
     {
+        $terminal = $userInfo['terminal'];
         // 支付编号-仅为微信支付预置(同一商户号下不同客户端支付需使用唯一订单号)
         $paySn = $order['sn'];
         if ($payWay == PayEnum::WECHAT_PAY) {
@@ -204,11 +205,9 @@ class PaymentLogic extends BaseLogic
         $payService = null;
         switch ($payWay) {
             case PayEnum::WECHAT_PAY:
-                $payService = (new WorkerWeChatPayService($terminal, $order['user_id'] ?? null));
+                $payService = (new WorkerWeChatPayService($terminal, $userInfo['user_id'] ?? null));
                 $order['pay_sn'] = $paySn;
                 $order['redirect_url'] = $redirectUrl;
-                dd($from, $order);
-
                 $result = $payService->pay($from, $order);
                 break;
             default:

+ 1 - 4
app/common/service/pay/WorkerWeChatPayService.php

@@ -57,9 +57,7 @@ class WorkerWeChatPayService extends BasePayService
         $this->terminal = $terminal;
         $this->config = WeChatConfigService::getPayConfigByTerminal($terminal);
         $this->app = new Application($this->config);
-        if ($userId !== null) {
-            $this->auth = MasterWorkerAuth::where(['worker_id' => $userId, 'terminal' => $terminal])->findOrEmpty();
-        }
+        $this->auth = MasterWorkerAuth::where(['worker_id' => $userId, 'terminal' => $terminal])->findOrEmpty();
     }
 
 
@@ -121,7 +119,6 @@ class WorkerWeChatPayService extends BasePayService
             ],
             'attach' => $from
         ]);
-
         $result = $response->toArray(false);
         $this->checkResultFail($result);
         return $this->getPrepayConfig($result['prepay_id'], $appId);

+ 1 - 1
app/workerapi/controller/PayController.php

@@ -29,7 +29,7 @@ class PayController extends \app\workerapi\controller\BaseApiController
         }
         //支付流程
         $redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
-        $result = PaymentLogic::pay($params['pay_way'], $params['from'], $order, $this->userInfo['terminal'], $redirectUrl);
+        $result = PaymentLogic::pay($params['pay_way'], $params['from'], $order, $this->userInfo, $redirectUrl);
         if (false === $result) {
             return $this->fail(PaymentLogic::getError(), $params);
         }