service = InterfaceService::instance(); $this->service->setAuth(input('appid'), '')->getInput(false); // 从数据库中账号检查 $map = ['appid' => $this->service->getAppid()]; $this->merchant = $this->app->db->name('MerchantList')->where($map)->find(); // 商户验证 if (empty($this->merchant)) $this->error('接口账号不存在!'); if (empty($this->merchant['status'])) $this->error('接口账号已被禁用!'); if (!empty($this->merchant['is_deleted'])) $this->error('接口账号已被移除!'); if ($this->merchant['surplus'] < 1) $this->error('接口账号余额不足!'); // 接口初始化,接收正确的 appid + data 数据 $this->service->setAuth($this->merchant['appid'], $this->merchant['appkey'])->showCheck(); [$this->data, $this->appid] = [$this->service->getData(), $this->service->getAppid()]; } /** * 返回失败的消息 * @param mixed $info * @param string $data * @param integer $code */ public function error($info, $data = '{-null-}', $code = 0):void { $this->service->error($info, $data, $code); } /** * 返回成功的消息 * @param mixed $info * @param string $data * @param integer $code */ public function success($info, $data = '{-null-}', $code = 1):void { $this->service->success($info, $data, $code); } /** * 返回接口数据 * @param mixed $info * @param array $data * @param integer $code */ protected function response($info, array $data = [], $code = 1):void { $this->service->baseResponse($info, $data, $code); } }