Beispiel #1
0
 /**
  * 修改产品
  */
 public function edit($data)
 {
     $this->di['gcproinfo']->begin();
     $di = \Phalcon\Di::getDefault();
     $info = \Gcproinfo\Models\Pdinfo::findFirst(array('pid = :pid: and cid = :cid:', 'bind' => array('pid' => $data['pid'], 'cid' => $data['cid'])));
     if ($info == false) {
         return $this->outputData(false, '600', '产品基本信息获取失败');
         exit;
     }
     $proname = $data['proname'];
     $prokey = $data['prokey'];
     $price = $data['price'];
     $star = isset($data['star']) ? $data['star'] : 20;
     $cate1 = $data['cate1'];
     $cate2 = $data['cate2'];
     $cate3 = isset($data['cate3']) ? intval($data['cate3']) : 0;
     $property = isset($data['property']) ? json_encode($data['property'], JSON_UNESCAPED_UNICODE) : '';
     $userproperty = isset($data['userproperty']) ? json_encode($data['userproperty'], JSON_UNESCAPED_UNICODE) : '';
     $unit = $data['unit'];
     $sellcount = $data['sellcount'];
     $mincount = $data['mincount'];
     $is_att = isset($data['pic']) ? 1 : 0;
     $picurl = json_encode($data['pic']);
     $is_wholesale = $data['is_batch'];
     $state = $data['state'];
     $online = 1;
     $re1 = $di->getShared('gcproinfo')->update('pd_info', array('proname', 'prokey', 'price', 'star', 'cate1', 'cate2', 'cate3', 'property', 'userproperty', 'unit', 'sellcount', 'mincount', 'is_att', 'picurl', 'is_wholesale', 'state', 'online'), array($proname, $prokey, $price, $star, $cate1, $cate2, $cate3, $property, $userproperty, $unit, $sellcount, $mincount, $is_att, $picurl, $is_wholesale, $state, $online), 'pid = ' . intval($info->pid) . ' and cid = ' . $info->cid);
     if ($re1 == false) {
         $this->di['gcproinfo']->rollback('产品基本信息修改失败');
         return $this->outputData(false, '600', '产品基本信息修改失败');
         exit;
     }
     $groupAll = \Gcproinfo\Models\PdPidgid::find(array('pid=:pid: and cid = :cid: and state in (0,1)', 'bind' => array('pid' => $data['pid'], 'cid' => $data['cid'])));
     if (!empty($groupAll)) {
         $groupAll = $groupAll->toArray();
         foreach ($groupAll as $val) {
             $userGroupObj = \Gcproinfo\Models\PdPidgid::findFirst(array('id = :id:', 'bind' => array('id' => $val['id'])));
             $re5 = $userGroupObj->delete();
             if ($re5 == false) {
                 $this->di['gcproinfo']->rollback('产品分组处理失败');
                 return $this->outputData(false, '600', '产品分组处理失败');
                 exit;
             }
             $re6 = true;
             if (empty($val['cgid'])) {
                 $groupobj = \Gcproinfo\Models\Pdcustomgroup::findFirst(array('cid=:cid: and gid = :gid: and parentgid=0', 'bind' => array('gid' => $val['gid'], 'cid' => $val['cid'])));
                 if (!empty($groupobj) && is_object($groupobj)) {
                     if ($groupobj->pronum > 0) {
                         $re6 = $di->getShared('gcproinfo')->update('pd_customgroup', array('pronum'), array($groupobj->pronum - 1), 'cid = ' . $val['cid'] . ' and gid = ' . intval($val['gid']) . ' and parentgid = 0');
                     }
                 }
             } else {
                 $groupobj = \Gcproinfo\Models\Pdcustomgroup::findFirst(array('cid=:cid: and gid = :cgid: and parentgid=:gid:', 'bind' => array('cgid' => $val['cgid'], 'gid' => $val['gid'], 'cid' => $val['cid'])));
                 if (!empty($groupobj) && is_object($groupobj)) {
                     if ($groupobj->pronum > 0) {
                         $re6 = $di->getShared('gcproinfo')->update('pd_customgroup', array('pronum'), array($groupobj->pronum - 1), 'cid = ' . $val['cid'] . ' and gid = ' . intval($val['cgid']) . ' and parentgid= ' . $val['gid']);
                     }
                 }
             }
             if ($re6 == false) {
                 $this->di['gcproinfo']->rollback('产品分组统计产品数目失败');
                 return $this->outputData(false, '600', '产品分组统计产品数目失败');
                 exit;
             }
         }
     }
     $idArr = array();
     if (!empty($data['group']) && is_array($data['group'])) {
         foreach ($data['group'] as $gv) {
             if ($gv != 0) {
                 $pidgid = explode('-', $gv);
                 $gid = isset($pidgid[0]) ? $pidgid[0] : 0;
                 $cgid = isset($pidgid[1]) ? $pidgid[1] : 0;
                 if ($cgid > 0) {
                     $idArr[] = $cgid;
                 } else {
                     $idArr[] = $gid;
                 }
                 $pidgidModel = new \Gcproinfo\Models\PdPidgid();
                 $id = $pidgidModel->last();
                 if (empty($id) or !isset($id) or !is_int($id) or $id < 1) {
                     $this->di['gcproinfo']->rollback('分组插入失败');
                     return $this->outputData(false, '600', '分组插入失败');
                     exit;
                 }
                 $pidgidModel = new \Gcproinfo\Models\PdPidgid();
                 $pidgidModel->id = $id;
                 $pidgidModel->pid = $data['pid'];
                 $pidgidModel->gid = $gid;
                 $pidgidModel->cid = $data['cid'];
                 $pidgidModel->supid = $data['supid'];
                 $pidgidModel->cgid = $cgid;
                 $pidgidModel->state = $data['state'];
                 $pidgidModel->online = 1;
                 $re7 = $pidgidModel->save();
                 if ($re7 == false) {
                     $this->di['gcproinfo']->rollback('产品分组插入失败');
                     return $this->outputData(false, '600', '产品分组插入失败');
                     exit;
                 }
             }
         }
     }
     $this->di['gcproinfo']->commit();
     //删除违规和待优化的产品
     $quest = array('service' => '\\Gcproinfo\\Services\\Pdspecialpro', 'method' => 'illegalDel', 'args' => array($info->pid, $info->cid));
     $this->di['remote']->call($quest);
     $shpinxInfo = array('id' => $info->pid, 'supid' => $data['supid'], 'proname' => $data['proname'], 'cid' => $data['cid'], 'addtime' => time(), 'uptime' => time(), 'state' => $data['state'], 'online' => 1, 'groupid' => implode(',', $idArr), 'cate1' => $data['cate1'], 'cate2' => $data['cate2'], 'cate3' => $data['cate3'], 'whichTable' => 1);
     $cate2 = 0;
     $comname = '';
     $comInfo = ComBaseService::getInstance()->getCom($info->supid);
     if ($comInfo['code'] == 200 and is_array($comInfo['data'])) {
         $cate2 = $comInfo['data']['cate2'];
         $comname = $comInfo['data']['comname'];
     }
     $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray());
     $rabbit->set('v3search', 'prosearch', json_encode($shpinxInfo), 'sphinxRT');
     $rabbit->set('v3work', 'product', json_encode(array('pid' => $data['pid'], 'cid' => $data['cid'])), 'mysql');
     $rabbit->setBroadcast('v3prodesc', 'prodesc', json_encode(array('pid' => $data['pid'], 'cid' => $data['cid'], 'cname' => $comname, 'prodesc' => $data['prodesc'], 'cateid' => array($data['cate1'], $data['cate2'], $data['cate3'], 0, 0), 'table' => 'product', 'op' => 'update')));
     //$rabbit->setBroadcast('v3product', 'product', json_encode(array('pid' => $data['pid'], 'cid' => $data['cid'])));
     //商品统计
     if ($info->cate3 > 0) {
         $procate = $info->cate3;
     } else {
         $procate = $info->cate2;
     }
     $tongjiInfo = array('supid' => $info->supid, 'uid' => 0, 'opuserid' => 0, 'cid' => $info->cid, 'pid' => $info->pid, 'cate2' => $cate2, 'cate3' => $info->cate3, 'procate' => $procate, 'score' => $info->star, 'ptype' => 1);
     Statistic::report(Statistic::SUP_DEL_PRODUCT, $tongjiInfo);
     return $this->outputData(1);
 }
Beispiel #2
0
 /**
  * 设置审核信息
  * @author 彭东江
  * @param int $id 主键id
  * @return array 审核信息
  */
 public function audit($id, $state, $comname, $checkdesc = '', $mname = '')
 {
     if (empty($id) || empty($state) || empty($comname) || empty($mname)) {
         return $this->outputData('', '600', '参数错误');
     }
     $certify = MGccertify::findFirst(array('id = ?1', 'bind' => array(1 => $id), 'order' => 'id DESC'));
     $certify->state = $state;
     $certify->checkdesc = $checkdesc;
     $certify->checktime = time();
     $certify->name = $mname;
     if ($certify->save()) {
         $com = Gccompany::findFirst(array('supid = ?1', 'bind' => array(1 => $certify->supid)));
         $com->is_gccertify = $certify->state;
         if ($com->save() && $com->is_gccertify == 1) {
             $gc_gccertify = new GcGccertify();
             $gc_gccertify->supid = $certify->supid;
             $gc_gccertify->state = 1;
             $gc_gccertify->comname = $comname;
             $gc_gccertify->addtime = time();
             $result = $gc_gccertify->save();
         }
     }
     $msg['supid'] = $certify->supid;
     if ($state == 1) {
         //工厂认证 添加基础评分
         $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray());
         $queueData = json_encode(array('cid' => $com->cid, 'supid' => $certify->supid, 'scoretype' => 4));
         $rabbit->set('v3work', 'sup', $queueData, 'score');
         //工厂认证统计
         $array = array('supid' => $certify->supid, 'province' => $com->province, 'city' => $com->city, 'cate1' => $com->cate1, 'cate2' => $com->cate2, 'busmode' => $com->busmode, 'auth' => 1);
         Statistic::report(Statistic::SUP_PERSONAL_AUTH, $array);
         //站内信
         $msg['subject'] = "工厂认证审核通过";
         $msg['message'] = '您提交的工厂认证申请已经审核通过,拥有发布10条普通特权产品的权限,可以更好的提升营销效果。如需发布更多特权产品,您可以开通营销4.0服务!【<a href="' . $this->di['config']->base->sup . '/product/special/index/">发布特权产品</a>】【<a href="' . $this->di['config']->base->sup . '/cost/" target="_blank">开通营销4.0</a>】';
     } else {
         //站内信
         $msg['subject'] = "工厂认证被拒审";
         $msg['message'] = '您提交的工厂认证申请已经被拒审,拘审原因是:(' . $checkdesc . ')!【<a href="' . $this->di['config']->base->sup . '/company/gongchang/">重新认证</a>】';
     }
     \Gcsupplier\Services\MsgService::getInstance()->addMsg($msg);
     return $this->outputData($certify);
 }
 /**
  * 营业执照审核
  * @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);
 }
Beispiel #4
0
 public function beforeSave()
 {
     $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray());
     $rabbit->set('v3com', 'com', $this->cid, 'ssdb');
 }
Beispiel #5
0
 public function afterSave()
 {
     $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray());
     $rabbit->set('v3com', 'com', $this->cid, 'ssdb');
     //更新二维码名片
     $rabbit->set('v3work', 'qrcode', $this->supid, 'mysql');
 }
 public function sphinxNotice($id, $type)
 {
     $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray());
     if ($type == 1) {
         $obj = Pdspecialpro::findFirst(array('pid = :pid:', 'bind' => array('pid' => $id)));
         if ($obj == false) {
             return $this->outputData(1);
         }
         $sphinxInfo2 = array('id' => $obj->pid, 'supid' => $obj->supid, 'proname' => $obj->proname, 'cid' => $obj->cid, 'addtime' => $obj->addtime, 'uptime' => $obj->uptime, 'state' => $obj->state, 'online' => 1, 'groupid' => 0, 'cate1' => $obj->cate1, 'cate2' => $obj->cate2, 'cate3' => $obj->cate3, 'whichTable' => 2);
         $rabbit->set('v3search', 'prosearch', json_encode($sphinxInfo2), 'sphinxRT');
         $sphinxInfo3 = array('id' => $obj->pid, 'cid' => $obj->cid, 'supid' => $obj->supid, 'proname' => $obj->proname, 'addtime' => $obj->addtime, 'uptime' => $obj->uptime, 'star' => $obj->star, 'cate3' => $obj->cate3, 'state' => $obj->state, 'is_op' => $obj->is_op, 'ratio' => $obj->ratio, 'whichTable' => 3);
         $rabbit->set('v3search', 'prosearch', json_encode($sphinxInfo3), 'sphinxRT');
     } elseif ($type == 2) {
         $obj = Mspecialpro::findFirst(array('id = :id:', 'bind' => array('id' => $id)));
         if ($obj == false) {
             return $this->outputData(1);
         }
         $sphinxInfo4 = array('id' => $obj->id, 'cid' => $obj->cid, 'supid' => $obj->supid, 'proname' => $obj->proname, 'addtime' => $obj->addtime, 'uptime' => $obj->uptime, 'star' => $obj->star, 'cate3' => $obj->cate3, 'state' => $obj->state, 'is_op' => $obj->is_op, 'ratio' => $obj->ratio, 'whichTable' => 4);
         $rabbit->set('v3search', 'prosearch', json_encode($sphinxInfo4), 'sphinxRT');
     }
 }