|
|
@@ -419,6 +419,58 @@ 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
|
|
|
+ * @author mjf
|
|
|
+ * @date 2024/3/18 16:49
|
|
|
+ */
|
|
|
+ public static function workerSharePay($payWay, $from, $order, $userInfo, $redirectUrl)
|
|
|
+ {
|
|
|
+ $terminal = 2;
|
|
|
+ $paySn = self::formatOrderSn($order['sn'], $terminal);
|
|
|
+ RechargeOrder::update(['pay_way' => $payWay, 'pay_sn' => $paySn], ['id' => $order['id']]);
|
|
|
+
|
|
|
+ if ($order['order_amount'] == 0) {
|
|
|
+ PayNotifyLogic::handle($from, $order['sn']);
|
|
|
+ return ['sn' => $order['sn'],'need_pay'=>0];
|
|
|
+ }
|
|
|
+
|
|
|
+ $mapSession = MappingMworkerSession::where([['type', '=', 1],['map_token', '=', $userInfo['token']], ['expire_time', '>', time()]])->findOrEmpty();
|
|
|
+ if(!$mapSession->isEmpty()) {
|
|
|
+ $token = '';
|
|
|
+ $mapSession->token && $token = $mapSession->token;
|
|
|
+ $token && $userInfo = (new MasterWokerTokenCache())->getUserInfo($token);
|
|
|
+ }
|
|
|
+
|
|
|
+ $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
|