[1, 4]], [['_from'], 'in', 'range' => ['app', 'mini', 'h5']], [['saas_id', 'user', 'order', 'pay_price','pay_type'], 'safe'], ]; } public function payData() { if (!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } $orderType = OrderNo::ORDER_PURCHASE_RE; $order = new PurchaseReOrder(); $order->store_id = $this->store_id; $order->user_id = $this->user->id; $order->saas_id = $this->saas_id; // 是否是平台小程序订单 if (is_platform()) { $order->is_platform = 1; } $order->pay_price = $this->pay_price; $order->send_price = $this->send_price; $order->order_no = OrderNo::getOrderNo(OrderNo::ORDER_PURCHASE_RE); $order->is_pay = 0; $order->pay_type = $this->pay_type; $order->is_delete = 0; $order->created_at = time(); // var_dump($this);die; if ($order->save()) { $this->order = $order; $body = "充值"; if ($this->pay_type == 1) { // $result = WechatAlliancePay::orderUnify($this->order,$orderType, $body, 0, false, 0); $result = WechatBusinessPay::orderUnify($this->order, $orderType, $body, 0, false, 0); if (isset($result['code']) && $result['code'] == 1) { return $result; } return [ 'code' => 0, 'msg' => 'success', 'data' => (object)$result['data'], 'res' => $result['res'], 'body' => $body, ]; } $goods_names = $body; $res = Alipay::mini($this->order, $goods_names, $this->user, '', '', 0, 0); if ($res['code'] != 0) { return $res; } return [ 'code' => 0, 'msg' => 'success', 'data' => $res['data'], 'res' => $res['data'], 'body' => $body, ]; } else { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } } public function payDataLeague() { if (!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } $orderType = OrderNo::ORDER_PURCHASE_RE; $order = new RechargeReOrder(); $order->user_id = $this->user->id; $order->saas_id = $this->saas_id; // 是否是平台小程序订单 if (is_platform()) { $order->is_platform = 1; } $order->pay_price = $this->pay_price; // $store_recharge_profit_model = Option::findOne(['name' => 'store_recharge_profit']); // $profit = $store_recharge_profit_model->value; $admin = Admin::findOne(['saas_user_id' => $this->saas_id, 'is_delete' => 0, 'type' => 'store']); $store = Store::findOne($admin->type_id); $order->store_id = $store->id; $order->league_price = $this->pay_price; $order->send_price = $this->send_price; $order->order_no = OrderNo::getOrderNo(OrderNo::LEAGUE_PRICE); $order->is_pay = 0; $order->pay_type = $this->pay_type; $order->is_delete = 0; $order->created_at = time(); // var_dump($this);die; if ($order->save()) { $this->order = $order; $body = "充值联盟券"; if ($this->pay_type == 1) { // $result = WechatAlliancePay::orderUnify($this->order,$orderType, $body, 0, false, 0); $result = WechatBusinessPay::orderUnify($this->order, $orderType, $body, 0, false, 0); if (isset($result['code']) && $result['code'] == 1) { return $result; } return [ 'code' => 0, 'msg' => 'success', 'data' => (object)$result['data'], 'res' => $result['res'], 'body' => $body, ]; } $goods_names = $body; $res = Alipay::mini($this->order, $goods_names, $this->user, '', '', 0, 0); if ($res['code'] != 0) { return $res; } return [ 'code' => 0, 'msg' => 'success', 'data' => $res['data'], 'res' => $res['data'], 'body' => $body, ]; } else { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } } //商户充值 public function storeSubmitRecharge(){ $order = $this->order; $store_id = $order->store_id; $item = \app\models\StoreCloud::findOne(['store_id' => $store_id, 'is_delete' => 0, 'is_enable' => 1]); // $storeCloud = get_saas_purchase_store_cloud(); if (!$item) { return [ 'code' => 11, 'msg' => '商户未找到', ]; } $form = new PlatformForm(); $form->attributes = [ 'id' => $item->cloud_store_id, 'price' => $order->pay_price, ]; $res = $form->storeSubmitRecharge(); \Yii::error([__METHOD__, 'storeSubmitRecharge', $res, $this->order, $item]); return $res; } }