| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace common\globals;
- use common\globals\BaseGlobal;
- use common\globals\GlobalInvoke;
- use common\models\common\AddonsInvoker;
- class JoinpayPaymentGlobal extends BaseGlobal
- {
- /**
- * 汇聚支付-聚合支付
- * @param [type] $invokes
- * @param array $params
- * @return array
- */
- public function joinPay($invokes, $params = [])
- {
- $pay_type = \addons\JoinPay\common\enums\JoinPayTypeEnum::action(\addons\JoinPay\common\enums\JoinPayTypeEnum::JOINPAY);
- $order = [
- 'title' => $params['trade']->title,
- 'order_no' => $params['trade']->out_trade_no,
- 'amount' => $params['trade']->pay_fee,
- 'mall_id' => $params['trade']->mall_id,
- // 'notify_url' => Url::toApi(['notify/' . $pay_type], TRUE),
- 'notify_url' => \Yii::$app->request->hostInfo . '/join-pay/notify/' . $pay_type,
- 'type' => $params['trade_type'],
- 'open_id' => $params['openid'] ?? '',
- ];
- $config = \Yii::$app->services->setting->mall->get($params['trade']->mall_id, 'pay.' . $pay_type, true);
- $config = json_decode($config, true);
- // dd($invokes, $order, $config);
- foreach ($invokes as $invoke) {
- $result = $this->invoke($invoke['class'], $invoke['method'], $order, $config);
- $is_success = $this->validateInvokeReturn($params['invoke_id'], $result);
- if (!$is_success) {
- throw new \Exception('结果数据格式校验未通过');
- }
- }
- return $result;
- }
- /**
- * 汇聚支付-快捷支付
- * @param [type] $invokes
- * @param array $params
- * @return array
- */
- public function fastPay($invokes, $params = [])
- {
- $order = [
- 'order_no' => $params['trade']->out_trade_no,
- 'sms_code' => $params['sms_code'],
- 'created_at' => $params['trade']->created_at
- ];
- $pay_type = \addons\JoinPay\common\enums\JoinPayTypeEnum::action(\addons\JoinPay\common\enums\JoinPayTypeEnum::JOINPAY_FAST_PAY);
- $config = \Yii::$app->services->setting->mall->get($params['trade']->mall_id, 'pay.' . $pay_type, true);
- $config = json_decode($config, true);
- foreach ($invokes as $invoke) {
- $result = $this->invoke($invoke['class'], $invoke['method'], $order, $config);
- $is_success = $this->validateInvokeReturn($params['invoke_id'], $result);
- // 全局调用获取提现条件
- if (!$is_success) {
- throw new \Exception('结果数据格式校验未通过');
- }
- }
- return $result;
- }
- /**
- * 验证调用结果
- * @param [type] $return
- * @return boolean
- */
- protected function validateJoinPay($return = null): bool
- {
- return true;
- }
- /**
- * 验证调用结果
- * @param [type] $return
- * @return boolean
- */
- protected function validateFastPay($return = null): bool
- {
- return true;
- }
- }
|