enterpriseId = $enterpriseId; $this->userCenterId = $userCenterId; $this->objDGoodsGroups = new DGoodsGroups(); $this->objDGoodsGroups->setTable('qianniao_goods_groups_'.$enterpriseId); } /** * 商品分组添加 * @param $params * @return ResultWrapper * @throws Exception */ public function addGoodsGroups($params) { $dbResult = $this->objDGoodsGroups->insert($params); if($dbResult === false){ return ResultWrapper::fail($this->objDGoodsGroups->error(), ErrorCode::$dberror); } return ResultWrapper::success($dbResult); } /** * 商品分组修改 * @param $update * @param $where * @return ResultWrapper */ public function updateGoodsGroups($update, $where) { $update['updateTime'] = time(); $dbResult = $this->objDGoodsGroups->update($update,$where); if($dbResult === false){ return ResultWrapper::fail($this->objDGoodsGroups->error(), ErrorCode::$dberror); } return ResultWrapper::success($dbResult); } /** * 商品分组列表 * @param $selectParams * @return ResultWrapper */ public function getAllGoodsGroups($selectParams) { $limit = $selectParams['limit']; unset($selectParams['limit']); $offset = $selectParams['offset']; unset($selectParams['offset']); $return = [ 'data' => [], 'total' => 0, ]; $whereSql = ''; if (isset($selectParams['name']) && !empty($selectParams['name'])) { $where = empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= $where . 'name LIKE "%' . $selectParams['name'] . '%" '; } $where = empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= $where . ' deleteStatus = ' . StatusCode::$standard; $sql = 'SELECT * FROM ' .$this->objDGoodsGroups->get_Table().$whereSql . ' ORDER BY sort DESC,updateTime DESC LIMIT ' . $offset . ' , ' . $limit; $dbResult = $this->objDGoodsGroups->query($sql); if ($dbResult === false) { return ResultWrapper::fail($this->objDGoodsGroups->error(), ErrorCode::$dberror); } if(empty($dbResult)){ return ResultWrapper::success($return); } $totalSql = 'SELECT COUNT(1) as count FROM ' .$this->objDGoodsGroups->get_Table() . $whereSql; $dbTotalResult = $this->objDGoodsGroups->query($totalSql); if ($dbTotalResult === false) { return ResultWrapper::fail($this->objDGoodsGroups->error(), ErrorCode::$dberror); } if(empty($dbTotalResult)){ return ResultWrapper::success([]); } $return = [ 'data' => $dbResult, 'total' => $dbTotalResult[0]['count'], ]; return ResultWrapper::success($return); } /** * 商品分组详情 * @param $where * @return ResultWrapper */ public function getReservoirInfo($where) { $dbResult = $this->objDGoodsGroups->get($where); if($dbResult === false){ return ResultWrapper::fail($this->objDGoodsGroups->error(), ErrorCode::$dberror); } return ResultWrapper::success($dbResult); } }