getUser(); // 充值套餐列表 $planList = (new PlanModel)->getList(); // 充值设置 $setting = SettingModel::getItem('recharge'); return $this->renderSuccess(compact('userInfo', 'planList', 'setting')); } /** * 确认充值 * @param null $planId * @param int $customMoney * @return array * @throws \app\common\exception\BaseException * @throws \think\exception\DbException */ public function submit($planId = null, $customMoney = 0) { // 用户信息 $userInfo = $this->getUser(); // 生成充值订单 $model = new OrderModel; if (!$model->createOrder($userInfo, $planId, $customMoney)) { return $this->renderError($model->getError() ?: '充值失败'); } // 构建微信支付 $payment = PaymentService::wechat( $userInfo, $model['order_id'], $model['order_no'], $model['pay_price'], OrderTypeEnum::RECHARGE ); // 充值状态提醒 $message = ['success' => '充值成功', 'error' => '订单未支付']; return $this->renderSuccess(compact('payment', 'message'), $message); } }