[1, 4]], [['_from'], 'in', 'range' => ['app', 'mini', 'h5']], ]; } public function save() { $this->wechatPay = self::getWechatPay(); if (!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } $order = new IntegralRechargeOrder(); $order->store_id = $this->store_id; $order->user_id = $this->user->id; if ($this->send_integral != 0) { $exists = IntegralRecharge::findOne($this->recharge_id); if (!$exists) { return [ 'code' => 1, 'msg' => '充值失败,请重新充值' ]; } } // 是否是平台小程序订单 if (is_platform()) { $order->is_platform = 1; } $order->pay_price = $this->pay_price; $order->send_integral = $this->send_integral; $order->order_no = OrderNo::getOrderNo(OrderNo::INTEGRAL_RECHARGE); $order->is_pay = 0; $order->pay_type = $this->pay_type; $order->is_delete = 0; $order->recharge_id = $this->recharge_id; $order->created_at = time(); if ($order->save()) { $this->order = $order; $body = "积分套餐充值"; if ($this->pay_type == 1) { if ($this->_from == OrderPayDataForm::PAY_FROM_APP) { if (\Yii::$app->prod_is_dandianpu() && !Store::hasIncoming($this->store_id) && self_mini() === false) { $result = WechatPay::orderUnify($order, OrderNo::ORDER_RECHARGE, $body, 0, true); } else { if (is_profit_pay()) { $result = WechatNewPay::orderUnify($order, OrderNo::ORDER_RECHARGE, $body, 0, true); } else { $result = WechatPay::orderUnify($order, OrderNo::ORDER_RECHARGE, $body, 0, true); } } } else { $is_h5 = false; if (is_h5()) { $is_h5 = true; } if (\Yii::$app->prod_is_dandianpu() && !Store::hasIncoming($this->store_id) && self_mini() === false) { $result = WechatPay::orderUnify($order, OrderNo::ORDER_RECHARGE, $body, 0, false, 0, 0, $is_h5); } else { if (is_profit_pay()) { $result = WechatNewPay::orderUnify($order, OrderNo::ORDER_RECHARGE, $body, 0, false, 0, 0, $is_h5); } else { $result = WechatPay::orderUnify($order, OrderNo::ORDER_RECHARGE, $body, 0, false, 0, 0, $is_h5); } } } if (isset($result['code']) && $result['code'] == 1) { return $result; } return [ 'code' => 0, 'msg' => 'success', 'data' => (object)$result['data'], 'res' => $result['res'], 'body' => $body, ]; } elseif ($this->pay_type == 4) { $user = get_user(); $open_user_id = $user->alipay_open_id; $form = new AlipayThirdForm(); $form->method = "alipay.open.auth.token.app"; $form->bind_store_id = get_store_id(); if (!$open_user_id) { return [ 'code' => 0, 'msg' => '参数获取错误' ]; } if (!empty(get_saas_user())) { if (\Yii::$app->prod_is_dandianpu() && !Store::hasIncoming(get_store_id()) && self_mini() === false) { $res = Alipay::mini($this->order, '充值', get_saas_user(), '', '', 0, 0); } else { if (is_profit_pay('ali')) { $res = AlipayProfit::mini($this->order, '充值', get_saas_user(), '', '', false, 0, 0); } else { $res = Alipay::mini($this->order, '充值', get_saas_user(), '', '', 0, 0); } } if (isset($res['code']) && $res['code'] == 1) { return $res; } if (isset($res['data'])) { $res['data'] = array_merge($res['data'], [ 'is_finish' => 1 ]); } return $res; } } } else { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } } }