request->post('promoter_id', 0)); $res = PromotionService::bindPromoter(intval($this->auth->id), $promoterId); $this->success('', ['bound' => $res]); } catch (\Exception $e) { if ($e instanceof HttpResponseException) { throw $e; } $this->error($e->getMessage()); } } /** * 推广中心概览 * * @ApiMethod (GET) */ public function info() { try { $this->success('', PromotionService::getOverview(intval($this->auth->id))); } catch (\Exception $e) { if ($e instanceof HttpResponseException) { throw $e; } $this->error($e->getMessage()); } } /** * 推广订单列表 * * @ApiMethod (GET) * @param int $page 页码 * @param int $pageSize 每页条数 */ public function orders() { try { $pageSize = min(max(intval($this->request->get('pageSize', 10)), 1), 50); $this->success('', PromotionService::getOrderList(intval($this->auth->id), $pageSize)); } catch (\Exception $e) { if ($e instanceof HttpResponseException) { throw $e; } $this->error($e->getMessage()); } } /** * 推广小程序码 * * @ApiMethod (GET) * @param string $envVersion 小程序版本 release|trial|develop */ public function qrcode() { try { $envVersion = (string)$this->request->get('envVersion', 'release'); $qrcode = PromotionService::getQrcode(intval($this->auth->id), $envVersion); $this->success('', ['qrcode' => $qrcode]); } catch (\Exception $e) { if ($e instanceof HttpResponseException) { throw $e; } $this->error($e->getMessage()); } } }