Пример #1
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, '数据获取失败');
     }
 }
Пример #2
0
 /**
  * 统计商品条数
  * @param  string  $condition 条件
  * @param  integer $type      选择数据表     默认1为普通商品   2为特权商品  3为未审核的特权商品 4为待优化商品  5违规的商品
  * @param  array   $bind      条件
  * @return int             条数
  */
 public function productNum($condition, $type = 1, $bind = array())
 {
     if (empty($condition)) {
         return $this->outputData(0);
     }
     $count = 0;
     if ($type == 1) {
         $count = Pdinfo::count(array($condition, "bind" => $bind));
     } elseif ($type == 2) {
         $count = Pdspecialpro::count(array($condition, "bind" => $bind));
     } elseif ($type == 3) {
         $count = Mspecialpro::count(array($condition, "bind" => $bind));
     } elseif ($type == 4) {
         $count = Pdoptimize::count(array($condition, "bind" => $bind));
     } elseif ($type == 5) {
         $count = Mproduct::count(array($condition, "bind" => $bind));
     }
     return $this->outputData($count);
 }