renderSuccess('', compact('category')); } /** * 活动列表 */ public function index($category_id = 0) { $model = new ActivityModel; $list = $model->getList($category_id, $this->postData()); return $this->renderSuccess('', compact('list')); } /** *活动详情 */ public function detail($activity_id) { $detail = ActivityModel::detail($activity_id); $user = $this->getUser(); $detail["balance"]=$user["balance"]; return $this->renderSuccess('', compact('detail')); } /** *提交活动报名 */ public function submit() { $params = $this->request->param(); // 用户信息 $user = $this->getUser(); // 生成报名用户 $model = new UserModel(); $order_id = $model->addUser($user,$params); if(!$order_id){ return $this->renderError($model->getError() ?: '报名失败'); } if($params['activity_fee'] > 0){ // 处理微信支付 $payment = UserModel::onOrderPayment($user, $model, $params['pay_type'], $params['pay_source']); // 返回结算信息 return $this->renderSuccess(['success' => '支付成功', 'error' => '未支付'], [ 'order_id' => $order_id, // 订单id 'activity_fee' => $params['activity_fee'], // 活动费用 'pay_type' => $params['pay_type'], // 支付方式 'payment' => $payment, // 微信支付参数 'order_type' => OrderTypeEnum::REGACTIVITY, //订单类型 ]); }else{ return $this->renderSuccess('', compact('order_id')); } } }