Example #1
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, '操作失败');
             }
         }
     }
 }
Example #2
0
 /**
  * 取消审核中的统计代码
  * @param  integer $supid 供应商id
  * @return [type]        [description]
  */
 public function freeStatCodeChecking($supid)
 {
     if (!isset($supid) || $supid <= 0) {
         return $this->outputData('', '400', '参数错误');
     }
     $conditions = 'supid=:supid: and state=0';
     $result = MStatcode::findFirst(array('conditions' => $conditions, 'bind' => array('supid' => intval($supid))));
     //查询数据,并标记开始删除
     if ($result) {
         $result->state = -7;
         $result->checktime = time();
         $result->name = '用户';
         $result->checkdesc = '用户在后台自行删除,转移到这里进行记录';
         //如果数据标记删除成功,则把data中的数据放入到supid中
         if ($result->save()) {
             return $this->outputData(true);
         } else {
             return $this->outputData('', '400', '解绑失败');
         }
     } else {
         return $this->outputData('', '404', '你没有统计代码');
     }
 }