/**
  * 营业执照审核
  * @param id int 审核表主键
  * @param int                    $opType 1通过 -1拒审
  * @return boolean true/false
  * @author zhuyuping <[<email address>]>
  */
 public function check($id = '', $opType = '', $checkdesc = '', $mname = '', $postData = array())
 {
     $opType = intval($opType);
     if ($id <= 0 || empty($opType) || empty($mname)) {
         return $this->outputData('', '600', '参数错误');
     }
     $mobj = MCompermit::findFirst(array('id = ?1', 'bind' => array(1 => $id)));
     if (!empty($mobj) && empty($mobj->state)) {
         $mArr = $mobj->toArray();
         $cid = $mArr['cid'];
         $obj = Gccompermit::findFirst(array("cid = ?1", 'bind' => array(1 => $cid)));
         if (empty($obj) || !empty($obj->state)) {
             return $this->outputData(false, '600', '行业资格证信息不存在');
         }
     } else {
         return $this->outputData(false, '600', '要审核行业资格证信息不存在');
     }
     $this->di['gccominfo']->begin();
     $comObj = \Gccominfo\Models\Gccompany::findFirst(array("cid = ?1", 'bind' => array(1 => $cid)));
     if (empty($comObj)) {
         return $this->outputData(false, '600', '企业不存在');
     }
     $msg['supid'] = $mArr['supid'];
     $msg['addtime'] = time();
     //审核通过
     if ($opType == 1) {
         //执照通过否
         $is_buslicense = 0;
         $buslicenseObj = Mbuslicense::findFirst(array("cid  = ?1", 'bind' => array(1 => $cid), 'order' => 'id desc'));
         if (!empty($buslicenseObj) && $buslicenseObj->state == 1) {
             $is_buslicense = 1;
         }
         //发产品否
         $is_pubpro = 0;
         $proObj = \Gcproinfo\Models\Pdinfo::findFirst(array('cid = :cid:', 'bind' => array('cid' => $cid)));
         if ($proObj) {
             $is_pubpro = 1;
         }
         //企业资料已完善
         if ($is_buslicense == 1) {
             $comObj->is_complete = 1;
         }
         if ($is_buslicense == 1 && $is_pubpro == 1) {
             //已完善 + 已发
             $comObj->state = 1;
         } elseif ($is_buslicense == 0 && $is_pubpro == 1) {
             //未完善 + 已发
             $comObj->state = -4;
         } elseif ($is_buslicense == 1 && $is_pubpro == 0) {
             //已完善 + 未发
             $comObj->state = -3;
         } else {
             $comObj->state = -2;
         }
         $comObj->save();
         //更新资格证主表 客服修改的信息
         if (isset($postData['permitno'])) {
             $obj->permitno = $postData['permitno'];
         }
         if (isset($postData['permittype'])) {
             $obj->permittype = $postData['permittype'];
         }
         if (isset($postData['endtime'])) {
             $obj->endtime = strtotime($postData['endtime']);
         }
         //更新审核表
         $mobj->checktime = time();
         $mobj->state = $opType;
         $mobj->name = $mname;
         //站内信
         $msg['subject'] = "行业资格证审核通过";
         $msg['message'] = '您提交的行业资格证已经审核通过,可以在工厂网经营该行业产品,快去发布产品吧!【<a href="' . $this->di['config']->base->sup . '/product/new/">立即发布</a>】';
     } else {
         //拒审
         //更新审核表
         if (empty($checkdesc)) {
             return $this->outputData(false, '600', '拒审理由非空');
         }
         $mobj->checkdesc = $checkdesc;
         $mobj->checktime = time();
         $mobj->state = $opType;
         $mobj->name = $mname;
         //站内信
         $msg['subject'] = "行业资证被拒审";
         $msg['message'] = '您提交的行业资格证已经被拒审,原因是:(' . $checkdesc . ')!【<a href="' . $this->di['config']->base->sup . '/company/index/init2/">重新提交</a>】';
     }
     //更新资格证主表
     $obj->state = $opType;
     if ($obj->save() === false) {
         $this->di['gccominfo']->rollback();
         return $this->outputData(false, '600', $obj->getMessages());
     }
     //更新审核表
     if ($mobj->save() === false) {
         $this->di['gccominfo']->rollback();
         return $this->outputData(false, '600', $mobj->getMessages());
     }
     $this->di['gccominfo']->commit();
     if ($opType == 1 && $is_buslicense == 1 && $is_pubpro == 1) {
         $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray());
         $queueData = json_encode(array('cid' => $cid, 'supid' => $comObj->supid));
         $rabbit->set('v3work', 'open', $queueData, 'store');
     }
     \Gcsupplier\Services\MsgService::getInstance()->addMsg($msg);
     return $this->outputData(true);
 }
 /**
  * 获取一条审核信息
  * @param    int id   执照审核表id
  * @return   [type] [description]
  * @author   zhuyuping
  * @dateTime 2015-08-26
  */
 public function getCheckDetail($id = 0)
 {
     $id = $this->di['filter']->sanitize($id, 'int', 0);
     if (!empty($id)) {
         $buslicenseArr = Mbuslicense::findFirst(array("id = ?1", 'bind' => array(1 => $id)))->toArray();
         $buslicenseObj = Gcbuslicense::findFirst(array("cid = ?1 and state = 0", 'bind' => array(1 => $buslicenseArr['cid'])));
         $buslicenseInfo = array();
         if ($buslicenseObj) {
             $buslicenseInfo = $buslicenseObj->toArray();
         }
         if ($buslicenseArr['checkdesc']) {
             $buslicenseInfo['checkdesc'] = $buslicenseArr['checkdesc'];
         }
     }
     /*else {
                 //获取正在审核的信息
                 $isOpen     = ''; //$this->di['memObj']->get('sup_checkbuslicense');
                 $conditions = ' state=0 ';
                 if (!empty($isOpen)) {
                     $conditions .= " and id not in({$isOpen})";
                 }
                 //倒序获取一条待审核的信息
                 $buslicenseObj = Mbuslicense::findFirst(array('columns' => 'id, cid', 'conditions' => $conditions, 'order' => 'addtime asc'));
     
                 if (empty($buslicenseObj)) {
                     return $this->outputData(false, '600', '没有待审核信息或者审核信息正被其他客服审核');
                 }
                 $buslicenseArr  = $buslicenseObj->toArray();
                 $cid            = $buslicenseArr['cid'];
                 $buslicenseInfo = Gcbuslicense::findFirst(array('cid = ?1', 'bind' => array(1 => $cid)))->toArray();
     
                 //设置当前打开的执照信息
                 if (!empty($buslicenseInfo)) {
                     if (empty($isOpen)) {
                         $isOpenBuslicenseVal = $buslicenseArr['id'];
                     } else {
                         $isOpenArr = explode(',', $isOpen);
                         if (!in_array($buslicenseArr['id'], $isOpenArr)) {
                             $isOpenArr[] = $buslicenseArr['id'];
                         }
                         $isOpenBuslicenseVal = implode(',', $isOpenArr);
                     }
                     //$this->di['memObj']->set('sup_checkbuslicense', $isOpenBuslicenseVal, '', 300);
                 }
             }*/
     $cominfo = Mbuslicense::findFirst(array('columns' => 'supid,cid,comname,username,addtime', 'id=:id:', 'bind' => array('id' => $buslicenseArr['id'])));
     $buslicenseInfo['id'] = $buslicenseArr['id'];
     $buslicenseInfo['state'] = $buslicenseArr['state'];
     $buslicenseInfo['comname'] = $cominfo['comname'];
     $buslicenseInfo['username'] = $cominfo['username'];
     $buslicenseInfo['addtime'] = $cominfo['addtime'];
     return $this->outputData($buslicenseInfo);
 }
Beispiel #3
0
 /**
  * 获取审核状态
  * @param int $supid 供应商用户id
  * @return array 审核信息
  */
 public function getAudit($supid = 0)
 {
     $supid = $this->di['filter']->sanitize($supid, 'int', 0);
     $buslicense = Mbuslicense::findFirst(array('supid = :supid:', 'bind' => array('supid' => $supid)));
     return $this->outputData($buslicense);
 }