Example #1
0
 /**
  * 开始遍历产品信息
  * @param type $cid
  */
 public function proAction($cid)
 {
     echo $cid;
     echo "\n";
     $pid = 0;
     while (1) {
         $proMysql = Pdinfo::find(array("conditions" => "pid > ?1 and cid = ?2", "bind" => array(1 => $pid, 2 => $cid), "columns" => "pid, proname, state", "limit" => 100, "order" => "pid asc"));
         $proMysqlRs = $proMysql->toArray();
         if (empty($proMysqlRs)) {
             echo "=================cid=" . $cid . "的企业的所有产品都已经打入队列处理===============\n";
             return true;
         }
         foreach ($proMysqlRs as $value) {
             $pid = $value["pid"];
             if ($value["state"] != 1) {
                 echo "============" . $pid . "产品状态不正常=============\n";
                 continue;
             }
             $this->writeRabbit($pid, $cid);
         }
     }
 }
Example #2
0
 /**
  * 操作单个产品上下架
  * @param  int $pid   产品id
  * @param  int $cid 供应商cid
  * @param  int online  0是下架 1是上架
  */
 public function operaGoods($pid, $cid, $online = 1)
 {
     $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray());
     $di = \Phalcon\Di::getDefault();
     $cid = intval($cid);
     $pid = intval($pid);
     if (empty($pid) or empty($cid)) {
         return $this->outputData(false, 600, '参数有误');
     }
     $info = \Gcproinfo\Models\Pdinfo::findFirst(array('pid = :pid: and cid = :cid:', 'bind' => array('pid' => $pid, 'cid' => $cid)));
     if ($info) {
         $rs = $di->getShared('gcproinfo')->update('pd_info', array('online'), array($online), 'pid = ' . $pid . ' and cid = ' . $cid);
         $infoMq = json_encode(array('pid' => $pid, 'cid' => $cid));
         $rabbit->setBroadcast('v3product', 'product', $infoMq);
         if ($rs) {
             $di->getShared('gcproinfo')->update('pd_pidgid', array('online'), array($online), 'pid = ' . $pid . ' and cid = ' . $cid);
             if ($online) {
                 $desc = $info->getDesc($info->pid);
                 if (empty($desc)) {
                     $desc = '';
                 }
                 $comInfo = ComBaseService::getInstance()->getComInfo($info->supid, 'comname');
                 $comname = '';
                 if ($comInfo['code'] == 200 and is_array($comInfo['data'])) {
                     $comname = $comInfo['data']['comname'];
                 }
                 $rabbit->setBroadcast('v3prodesc', 'prodesc', json_encode(array('pid' => $info->pid, 'cid' => $info->cid, 'cname' => $comname, 'prodesc' => $desc, 'cateid' => array($info->cate1, $info->cate2, $info->cate3, 0, 0), 'table' => 'product', 'op' => 'weijin')));
                 $mProduct = \Gcproinfo\Models\Mproduct::findFirst(array('pid = :pid:', 'bind' => array('pid' => $info->pid)));
                 if ($mProduct) {
                     if ($mProduct->state == -8) {
                         $mProduct->state = -7;
                         $mProduct->save();
                     }
                 }
             }
             return $this->outputData(1);
         }
     } else {
         return $this->outputData(false, 600, '数据获取失败');
     }
 }
Example #3
0
 /**
  * 营业执照审核
  * @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);
 }
Example #4
0
 /**
  * 获得一组商品的链接 支持普通和特权混合  超过30个就不支持了
  * @param  array $data 要查询的商品  结构是 array(pid,pid,pid,pid,)
  */
 public function getGoodsLink($data, $is_img = 0)
 {
     $data = $this->di['filter']->sanitize($data, 'string', '');
     if (empty($data) or !is_array($data) or count($data) > 50) {
         return $this->outputData(false, 600, '商品信息获取失败');
     }
     $data = array_unique($data);
     $goods = $special = '';
     foreach ($data as $v) {
         if ($v >= 900000000) {
             $special[] = $v;
         } else {
             $goods[] = $v;
         }
     }
     $rs1 = $rs0 = $link = array();
     if (is_array($special)) {
         $special = implode(',', $special);
         $rs0 = Pdspecialpro::find(array('pid in (' . $special . ')', "bind" => array(), 'columns' => 'pid,cate2,cate3,state,picurl'))->toArray();
     }
     if (is_array($goods)) {
         foreach ($goods as $k => $v) {
             $rs = Pdinfo::findFirst(array('pid = :pid:', "bind" => array('pid' => $v), 'columns' => 'pid,cate2,cate3,state,picurl'));
             if ($rs != false) {
                 $rs1[] = array('pid' => $rs->pid, 'cate2' => $rs->cate2, 'cate3' => $rs->cate3, 'state' => $rs->state, 'picurl' => $rs->picurl);
             }
         }
     }
     $info = array_merge($rs0, $rs1);
     foreach ($info as $value) {
         if ($is_img == 1) {
             $link[$value['pid']]['link'] = \Xz\Func\UrlHelper::proLinkCre($value['pid'], $value['cate2'], $value['cate3']);
             $picurlArr = json_decode($value['picurl'], true);
             $link[$value['pid']]['picurl'] = $picurlArr[0];
             $link[$value['pid']]['picurlarr'] = $picurlArr;
         } else {
             $link[$value['pid']] = \Xz\Func\UrlHelper::proLinkCre($value['pid'], $value['cate2'], $value['cate3']);
         }
     }
     return $this->outputData($link);
 }
Example #5
0
 /**
  * 获得单个普通商品详情
  * @param  int $supid 供应商supid
  * @param  int $pid   商品id
  * @param  int $isdesc   是否要商品详情
  * @param  string $column   要显示的字段
  */
 public function getProductDetails($supid, $pid, $isdesc = 0, $column = '*')
 {
     $supid = $this->di['filter']->sanitize($supid, 'int', 0);
     $pid = $this->di['filter']->sanitize($pid, 'int', 0);
     if (empty($supid) or empty($pid)) {
         return $this->outputData(false, 600, '商品信息获取失败');
     }
     $params = ['conditions' => 'pid = :pid: and supid = :supid:', 'bind' => ['supid' => $supid, 'pid' => $pid], 'columns' => $column];
     $goods = $this->setModel('Pdinfo')->get($params);
     if ($goods && isset($goods[0])) {
         $goods = $goods[0];
         if (is_array($goods) && !empty($goods)) {
             if ($isdesc == 1) {
                 $obj = new \Gcproinfo\Models\Pdinfo();
                 $desc = $obj->getDesc($pid);
                 $goods['desc'] = '';
                 if (!empty($desc)) {
                     $goods['desc'] = $desc;
                 }
                 return $this->outputData($goods);
             } else {
                 return $this->outputData($goods);
             }
         }
     } else {
         return $this->outputData(false, 600, '商品信息获取失败');
     }
 }
Example #6
0
 /**
  * [productByPids description]
  * @param  array  $pids [description]
  * @return [type]       [description]
  */
 public function productByPids($pids = array())
 {
     if (empty($pids)) {
         return $this->outputData(false, 600, '产品PID数组为空');
     }
     $cjpids = array();
     $normalpids = array();
     $specialpids = array();
     foreach ($pids as $k => $v) {
         $pid = intval($v);
         if (empty($pid)) {
             continue;
         }
         if ($pid >= 900000000) {
             $specialpids[] = $pid;
         } elseif ($pid >= 500000000 && $pid < 900000000) {
             $cjpids[] = $pid;
         } else {
             $normalpids[] = $pid;
         }
     }
     $normalpids = array_unique($normalpids);
     $specialpids = array_unique($specialpids);
     $cjpids = array_unique($cjpids);
     $proInfo = array();
     if (!empty($normalpids)) {
         $proInfoObj = Pdinfo::find(array('conditions' => "pid in (" . implode(',', $normalpids) . ")"));
         if (is_object($proInfoObj)) {
             $proInfo = $proInfoObj->toArray();
         }
     }
     $spProInfo = array();
     if (!empty($specialpids)) {
         $spProInfoObj = Pdspecialpro::find(array('conditions' => "pid in (" . implode(',', $specialpids) . ")"));
         if (is_object($spProInfoObj)) {
             $spProInfo = $spProInfoObj->toArray();
         }
     }
     $cjProInfo = array();
     if (!empty($cjpids)) {
         $cjProInfoObj = CaijiPdinfo::find(array('conditions' => "pid in (" . implode(',', $cjpids) . ")"));
         if (is_object($cjProInfoObj)) {
             $cjProInfo = $cjProInfoObj->toArray();
         }
     }
     $result = array();
     $result = array_merge($result, $proInfo);
     $result = array_merge($result, $cjProInfo);
     $result = array_merge($result, $spProInfo);
     $result = ArrayHelper::convertPrimary($result, 'pid');
     return $this->outputData($result);
 }