method = $method; return $this; } /** * 设置下单的客户端 * @param string $client 客户端 * @return $this */ public function setClient(string $client): Identity { $this->client = $client; return $this; } /** * 开通会员页面数据 * @param string $client 当前客户端 * @return array * @throws BaseException * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function userCenter(string $client): array { // 当期用户信息 $userInfo = UserService::getCurrentLoginUser(true); //是否分销商 if (UserService::isDealerMember() || UserService::isStore()) { throwError('非法操作'); } // 获取充值方案列表 $model = new \app\api\model\user\Identity(); $planList = $model->getList(['type' => IdentityEnum::MEMBER]); // 根据指定客户端获取可用的支付方式 $PaymentModel = new PaymentModel; $methods = $PaymentModel->getMethodsByClient($client); // 返回数据 return [ 'personal' => $userInfo, 'list' => $planList, 'paymentMethods' => $methods ]; } /** * 开通分销页面数据 * @param string $client 当前客户端 * @return array * @throws BaseException * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function dealerCenter(string $client): array { // 当期用户信息 $userInfo = UserService::getCurrentLoginUser(true); if (UserService::isStore()) { throwError('非法操作'); } // 获取充值方案列表 $model = new \app\api\model\user\Identity(); $planList = $model->getList(['type' => IdentityEnum::DEALER]); // 根据指定客户端获取可用的支付方式 $PaymentModel = new PaymentModel; $methods = $PaymentModel->getMethodsByClient($client); // 返回数据 return [ 'personal' => $userInfo, 'list' => $planList, 'paymentMethods' => $methods ]; } /** * 确认订单支付事件 * @param int $identityId * @param array $extra 附加数据 * @return array[] * @throws BaseException * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function orderPay(int $identityId, array $extra = []): array { $PaymentService = new Payment(); $result = $PaymentService->setMethod($this->method) ->setClient($this->client) ->orderPay($identityId, $extra); $this->message = $PaymentService->getMessage(); return $result; } /** * 交易查询 * 查询第三方支付订单是否付款成功 * @param string $outTradeNo 商户订单号 * @return bool * @throws BaseException * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function tradeQuery(string $outTradeNo): bool { $PaymentService = new Payment(); return $PaymentService->setMethod($this->method)->setClient($this->client)->tradeQuery($outTradeNo); } /** * 返回消息提示 * @return string */ public function getMessage(): string { return $this->message; } }