user = $this->getUser(); } //会员卡列表 public function index() { $model = new UserCardModel(); $list = $model->getList($this->postData()); return $this->renderSuccess('', compact('list')); } //会员卡详情 public function detail($card_id) { $detail = UserCardModel::detail($card_id); return $this->renderSuccess('', compact('detail')); } //我的会员卡详情 public function recordDetail($order_id) { $detail = CardRecordModel::getDetail($order_id); return $this->renderSuccess('', compact('detail')); } /** * 购买 */ public function buy() { $params = $this->request->param(); // 用户信息 $user = $this->user; // 生成订单 $model = new CardRecordModel(); $order_id = $model->createOrder($user, $params); if (!$order_id) { return $this->renderError($model->getError() ?: '购买失败'); } // 在线支付 $model['pay_price'] = $model['money']; $payment = CardRecordModel::onOrderPayment($user, [$model], $params['pay_type'], $params['pay_source']); // 返回结算信息 return $this->renderSuccess(['success' => '支付成功', 'error' => '订单未支付'], [ 'order_id' => $order_id, // 订单id 'pay_type' => $params['pay_type'], // 支付方式 'payment' => $payment, // 微信支付参数 'order_type' => OrderTypeEnum::CARD, //订单类型 ]); } }