/** * 运营商验证营业执照接口(运营商调取)营业执照默认通过+工厂认证默认通过 * @author zhuyuping 2015.08.28 * @return array */ public function saveLic($postData = array(), $cid = '', $supid = '') { $cid = intval($cid); $supid = intval($supid); if ($cid <= 0 || empty($postData) || $supid <= 0) { return $this->outputData('', '600', '参数错误'); } $comObj = \Gccominfo\Models\Gccompany::findFirst(array('cid = :cid:', 'bind' => array('cid' => $cid))); if (empty($comObj)) { return $this->outputData('', '600', '企业信息不存在'); } $tmpArr = array('ceo', 'regcapital', 'province', 'city', 'area', 'address', 'comname', 'username'); foreach ($tmpArr as $key => $value) { if (empty($postData[$value])) { return $this->outputData('', '600', $value . "不能为空"); } } $response = CombusinessService::getInstance()->getByName($postData['comname']); $businessInfo = !empty($response) && $response['code'] == 200 ? $response['data'] : array(); $comObj->licensestate = 1; $comObj->is_gccertify = 1; if ($businessInfo) { $comObj->cbcid = $businessInfo['cid']; //更新前台缓存 CombusinessService::getInstance()->updateGccid($cid, $businessInfo['cid']); } $save = array('lic' => array('cid' => $cid, 'supid' => $supid, 'state' => 1, 'comname' => $postData['comname'], 'ceo' => $postData['ceo'], 'regcapital' => intval($postData['regcapital']), 'province' => intval($postData['province']), 'city' => intval($postData['city']), 'zone' => intval($postData['area']), 'address' => $postData['address'], 'licensetype' => 2, 'licenseurl' => '', 'endtime' => 0, 'addtime' => time()), 'mlic' => array('cid' => $cid, 'supid' => $supid, 'username' => $postData['username'], 'comname' => $postData['comname'], 'addtime' => time(), 'checktime' => time(), 'state' => 1, 'checkdesc' => '运营商后台添加默认认证', 'name' => 'op'), 'certify' => array('supid' => $supid, 'state' => 1, 'comname' => $postData['comname'], 'ceo' => $postData['ceo'], 'addtime' => time()), 'mcertify' => array('supid' => $supid, 'addtime' => time(), 'checktime' => time(), 'state' => 1, 'checkdesc' => '运营商后台添加默认通过工厂认证', 'name' => 'op')); $Obj = GcBuslicense::findFirst(array('columns' => 'id, state', 'conditions' => "cid=:cid:", 'bind' => array('cid' => $cid))); if (is_object($Obj) && isset($Obj->state) && $Obj->state == 1) { return $this->outputData(true); } else { $this->di['gccominfo']->begin(); if (!is_object($Obj)) { $Obj = new \Gccominfo\Models\GcBuslicense(); } if ($Obj->save($save['lic']) === false) { return $this->outputData(false, '600', $Obj->getMessages()); } if ($comObj->save() === false) { $this->di['gccominfo']->rollback(); return $this->outputData(false, '600', $comObj->getMessages()); } $mlicObj = new \Gccominfo\Models\Mbuslicense(); if ($mlicObj->save($save['mlic']) === false) { $this->di['gccominfo']->rollback(); return $this->outputData(false, '600', $mlicObj->getMessages()); } $certifyObj = new \Gccominfo\Models\GcGccertify(); if ($certifyObj->save($save['certify']) === false) { $this->di['gccominfo']->rollback(); return $this->outputData(false, '600', $certifyObj->getMessages()); } $mcertifyObj = new \Gccominfo\Models\MGccertify(); if ($mcertifyObj->save($save['mcertify']) === false) { $this->di['gccominfo']->rollback(); return $this->outputData(false, '600', $mcertifyObj->getMessages()); } $this->di['gccominfo']->commit(); $scoretypeArr = array(3, 4); foreach ($scoretypeArr as $key => $scoretype) { $score = $this->di['config']->company->score[$scoretype]; $insertLogData = array('supid' => $supid, 'cid' => $cid, 'pid' => 0, 'scoretype' => $scoretype, 'score' => $score, 'addtime' => time()); $logObj = new Supscorelog(); //入评分日志表 $logObj->save($insertLogData); } $Obj = Supscore::findFirst(array("supid = :supid:", 'bind' => array('supid' => $supid))); if (is_object($Obj)) { $dataArr = array('basescore' => 80); } else { $Obj = new Supscore(); $dataArr = array('supid' => $supid, 'cid' => $cid, 'basescore' => 80); } //更新评分表 $Obj->save($dataArr); //执照认证统计 $array = array('supid' => $supid, 'province' => intval($postData['province']), 'city' => intval($postData['city']), 'cate1' => 0, 'cate2' => 0, 'busmode' => 1, 'licence' => 1); Statistic::report(Statistic::SUP_PERSONAL_LICENCE, $array); /* //工厂认证 添加基础评分 $queueData2 = json_encode(array('cid' => $cid, 'supid' => $supid, 'scoretype' => 4)); $rabbit->set('v3work', 'sup', $queueData2, 'score');*/ //工厂认证统计 $array = array('supid' => $supid, 'province' => intval($postData['province']), 'city' => intval($postData['city']), 'cate1' => 0, 'cate2' => 0, 'busmode' => 1, 'auth' => 1); Statistic::report(Statistic::SUP_PERSONAL_AUTH, $array); } return $this->outputData(true); }
/** * 营业执照审核 * @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); }
/** * 获取审核状态 * @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); }