コード例 #1
0
 /**
  * 运营商验证营业执照接口(运营商调取)营业执照默认通过+工厂认证默认通过
  * @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);
 }