/** * 删除产品的单个分组 * @param ing $gid 分组id * @param ing $pid 产品id * @param ing $supid 供应商id */ public function delGoodsGroup($pidgid, $pid, $cid) { $this->di['gcproinfo']->begin(); $pidgid = explode('-', $pidgid); $gid = isset($pidgid[0]) ? intval($pidgid[0]) : 0; $cgid = isset($pidgid[1]) ? intval($pidgid[1]) : 0; $pid = empty($pid) ? 0 : intval($pid); $rs = \Gcproinfo\Models\PdPidgid::findFirst(array('pid = :pid: and cid = :cid: and gid = :gid: and cgid=:cgid: and state in (0,1)', 'bind' => array('pid' => $pid, 'cid' => $cid, 'gid' => $gid, 'cgid' => $cgid))); if ($rs->delete()) { if (empty($cgid)) { $groupobj = \Gcproinfo\Models\Pdcustomgroup::findFirst(array('cid=:cid: and gid = :gid: and parentgid=0', 'bind' => array('gid' => $gid, 'cid' => $cid))); } else { $groupobj = \Gcproinfo\Models\Pdcustomgroup::findFirst(array('cid=:cid: and gid = :cgid: and parentgid=:gid:', 'bind' => array('cgid' => $cgid, 'gid' => $gid, 'cid' => $cid))); } if (!empty($groupobj) && is_object($groupobj)) { if ($groupobj->pronum > 0) { $groupobj->pronum = $groupobj->pronum - 1; $re3 = $groupobj->save(); if ($re3 == false) { $this->di['gcproinfo']->rollback(); return $this->outputData(0); exit; } } } $this->di['gcproinfo']->commit(); return $this->outputData(1); } else { $this->di['gcproinfo']->rollback(); return $this->outputData(false, '600', '处理失败'); } }
/** * 获得普通商品列表 * @param int $cid 企业id * @param string $groupid 分组字符串 * @param int $offset 分页起始值 * @param int $limit 分页 * @param string $column 字段 默认为全部 * @param string $order 排序 */ public function getProductList($cid, $groupid = 0, $offset = 0, $limit = 20, $column = '*', $order = ' uptime desc') { $cid = $this->di['filter']->sanitize($cid, 'int', 0); if ($cid > 50000000) { //采集企业商品列表 $data = $this->getCaijiProductList($cid, $groupid, $offset, $limit, $column, $order); } else { $groupid = $this->di['filter']->sanitize($groupid, 'string', 0); $offset = $this->di['filter']->sanitize($offset, 'int', 0); $limit = $this->di['filter']->sanitize($limit, 'int', 20); if (!empty($groupid)) { $pidgid = explode('-', $groupid); $gid = isset($pidgid[0]) ? $pidgid[0] : 0; $cgid = isset($pidgid[1]) ? $pidgid[1] : 0; if (empty($cgid)) { $condition = 'cid = :cid: and gid=:gid: and state =1'; $bind = array('cid' => $cid, 'gid' => $gid); } else { $condition = 'cid = :cid: and gid=:gid: and cgid=:cgid: and state =1'; $bind = array('cid' => $cid, 'gid' => $gid, 'cgid' => $cgid); } //修改保法的接口: 查询时候改为查询不同的pid因为可能存在重复id的情况 //@author Jea $pidgid = PdPidgid::find(array('columns' => 'distinct(pid) as pid', $condition, 'bind' => $bind, 'order' => 'pid DESC', 'limit' => $limit, 'offset' => $offset)); $pidArr = array(); if (is_object($pidgid)) { $pidgid = $pidgid->toArray(); foreach ($pidgid as $v) { if (isset($v['pid'])) { $pidArr[] = $v['pid']; } } if (is_array($pidArr)) { $pidArr = implode(',', $pidArr); } if (!empty($pidArr)) { $data = PdInfo::find(array('cid = :cid: and pid in (' . $pidArr . ')', 'bind' => array('cid' => $cid), 'columns' => $column)); if ($data) { $data = $data->toArray(); } else { $data = array(); } } } $count = PdPidgid::findFirst(array('columns' => 'count(distinct(pid)) as num', $condition, 'bind' => $bind)); $data['count'] = $count->num; } else { $condition = 'cid = :cid: and state = 1'; $bind = array('cid' => $cid); $data = Pdinfo::find(array($condition, 'bind' => $bind, 'limit' => $limit, 'offset' => $offset, 'order' => $order, 'columns' => $column)); if ($data) { $data = $data->toArray(); } else { $data = array(); } $data['count'] = Pdinfo::count(array($condition, 'bind' => $bind)); } } return $this->outputData($data); }