/** * 提交独立域名进来,需要进行数据校检,详细的规则见各个参数 * 现在的流程是,把用户提交的信息入到m_comdomain中,当审核通过的时候,把字段 domain 和 recordno录入到 gc_comdomain中去 * @param integer $supid 供应商id,直接intval,不再判断,就算是为负值也没什么 * @param Domain $domain 域名,格式必须为: www\.(([\w]{1,63})||([\u4e00-\u9fa5]{1,20}))\.[\w]{2,8} * @param string $recordno 备案号 * @return */ public function addDomain($supid, $domain, $recordno) { if (!isset($supid) || $supid == 0 || empty($domain) || empty($recordno)) { return $this->outputData('', '302', '参数错误'); } $supid = intval($supid); $domainRule = "/^www\\.([\\w-]{1,63})\\.([\\w]{2,8})\$/u"; //匹配独立域名 if (!preg_match($domainRule, $domain)) { return $this->outputData('', '401', '独立域名不符合规则'); } //防止用户通过其他途径重复提交独立域名信息 $conditions = 'supid=:supid: and state=0'; $result = MDomain::findFirst(array('columns' => 'id', 'conditions' => $conditions, 'bind' => array('supid' => $supid))); if ($result) { return $this->outputData('', '402', '您已经有一条未审核的记录,如果要再次提交,请选择取消绑定并重新提交'); } $mdomain = new MDomain(); $mdomain->supid = $supid; $mdomain->domain = $domain; $mdomain->recordno = $recordno; if ($mdomain->save()) { return $this->outputData('域名添加成功'); } else { return $this->outputData('', '600', '域名添加失败,请重试'); } }
/** * 审核操作! * 如果通过了,标记m表中的状态为1, 并把数据更新到gc表中 * 如果拒审了,只更新m表 * @param integer $id [<description>] * @return */ public function check($id, $state, $name, $checkdesc = '', $msg = false) { if ($id < 1 || !in_array($state, array(1, -1))) { return $this->outputData('', '401', '数据校检失败'); } $data = MDomain::findFirst(array('conditions' => 'id=:id:', 'bind' => array('id' => $id))); if (!$data) { return $this->outputData('', '402', '信息不存在'); } if (!isset($data->state) || $data->state != 0) { return $this->outputData('', '403', '已被审核'); } //审核通过操作 if ($state == 1) { $data->state = $state; $data->checkdesc = '审核成功'; $data->name = $name; $data->checktime = time(); //更新完状态之后,将信息保存或更新到正常表中 if ($data->save()) { //判断域名表中是否存在,存在则更新,不存在则新增 $findData = Domain::findFirst(array('conditions' => 'supid=:supid: and state=1', 'bind' => array('supid' => $data->supid))); if ($findData) { $findData->domain = $data->domain; $findData->recordno = $data->recordno; $res = $findData->save(); } else { $domainService = new Domain(); $domainService->supid = $data->supid; $domainService->domain = $data->domain; $domainService->recordno = $data->recordno; $domainService->state = $data->state; $res = $domainService->save(); } if ($res) { //审核通过 发送站内信 $msgData['supid'] = $data->supid; $msgData['subject'] = '独立域名通过审核'; $msgData['message'] = $msg; $request = array('service' => 'Gcsupplier\\Services\\Msg', 'method' => 'addMsg', 'args' => array($msgData)); $this->di['local']->call($request); return $this->outputData('操作成功'); } return $this->outputData('操作失败'); } //审核失败操作 } else { $data->state = $state; $data->checkdesc = $checkdesc; $data->name = $name; $data->checktime = time(); $res = $data->save(); if ($res) { //拒审 发送站内信 $msgData['supid'] = $data->supid; $msgData['subject'] = '独立域名被拒审'; $msgData['message'] = $msg; $request = array('service' => 'Gcsupplier\\Services\\Msg', 'method' => 'addMsg', 'args' => array($msgData)); $this->di['local']->call($request); return $this->outputData('操作成功'); } return $this->outputData('操作失败'); } }