Exemplo n.º 1
0
 /**
  * 撤销统计代码操作,将gc表中的标记为删除
  * @param  integer $supid 供应商id
  * @return array(fmart)
  */
 public function freeStatCode($supid)
 {
     if (!isset($supid) || $supid <= 0) {
         return $this->outputData('', '400', '参数错误');
     }
     $conditions = 'supid=:supid: and state=1';
     $result = Statcode::findFirst(array('conditions' => $conditions, 'bind' => array('supid' => intval($supid))));
     //查询数据,并标记开始删除
     if ($result) {
         //准备要转移的数据
         $data = array();
         $data['supid'] = $result->supid;
         $data['statcode'] = $result->statcode;
         $data['name'] = '用户';
         $data['state'] = -7;
         $data['checktime'] = time();
         $data['checkdesc'] = '用户在后台自行删除,转移到这里进行记录';
         $result->state = -7;
         //如果数据标记删除成功,则把data中的数据放入到supid中
         if ($result->save()) {
             $MStatcode = new MStatcode();
             //不论在m表中有没有该用户的未审核信息,直接更新状态为-7,用户主动删除
             if ($MStatcode->save($data)) {
                 //调用结果批量更新,此操作返回的结果永远是 true ...未知原因
                 $success = $this->di->getShared('gccominfo')->update("m_statcode", array("state"), array("-7"), "supid={$supid} and (state=0 or state=1)");
                 return $this->outputData('解绑成功');
             } else {
                 return $this->outputData('', '400', '解绑失败');
             }
         } else {
             return $this->outputData('', '400', '解绑失败');
         }
     } else {
         return $this->outputData('', '400', '你没有统计代码');
     }
 }
Exemplo n.º 2
0
 /**
  * 审核操作!
  * 如果通过了,标记m表中的状态为1, 并把数据更新到gc表中
  * 如果拒审了,只更新m表
  * @param  integer $id [<description>]
  * @return
  */
 public function check($id, $state, $name, $checkdesc = '')
 {
     if ($id < 1 || !in_array($state, array(1, -1))) {
         return $this->outputData('', '401', '数据校检失败');
     }
     $data = MStatcode::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 = Statcode::findFirst(array('conditions' => 'supid=:supid: and state=1', 'bind' => array('supid' => $data->supid)));
             if ($findData) {
                 $findData->statcode = $data->statcode;
                 $res = $findData->save();
             } else {
                 $StatcodeService = new Statcode();
                 $StatcodeService->supid = $data->supid;
                 $StatcodeService->cid = 0;
                 $StatcodeService->closttime = 0;
                 $StatcodeService->statcode = $data->statcode;
                 $StatcodeService->state = $data->state;
                 $res = $StatcodeService->save();
             }
             if ($res) {
                 return $this->outputData('操作成功');
             } else {
                 return $this->outputData('', 503, '操作失败');
             }
         }
         //审核失败操作
     } else {
         $data->state = $state;
         $data->checkdesc = $checkdesc;
         $data->name = $name;
         $data->checktime = time();
         $res = $data->save();
         //更新完状态之后,将信息保存或更新到正常表中
         if ($res) {
             if ($res) {
                 return $this->outputData('操作成功');
             } else {
                 return $this->outputData('', 503, '操作失败');
             }
         }
     }
 }