50], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'prod_cate_id' => 'Prod Cate ID', 'cms_cate_id' => 'Cms Cate ID', 'show_sort' => 'Show Sort', 'delete_flag' => 'Delete Flag', 'create_time' => 'Create Time', 'update_time' => 'Update Time', 'update_user' => 'Update User', 'system' => 'System', ]; } /* * 获取子产品列表 */ public function getChildProdList($param) { $page_size = $param['page_size']; $current_page = $param['current_page']; $system_id = $param['system_id']; $cms_category_id = $param['cms_category_id']; $where = [ 'and', ['=', 'a.delete_flag', 0], ['=', 'a.system', $system_id], ['=', 'a.cms_cate_id', $cms_category_id], ['=', 'b.delete_flag', 0], ['!=', 'b.show_img', ''] ]; $offset = ($current_page - 1) * $page_size; $select = [ 'a.prod_cate_id', 'a.show_sort', 'b.pro_cate_name' ]; $result = self::find()->select($select) ->from(self::tableName() . ' a') ->innerJoin(ProdCategory::tableName() . ' b', 'b.pro_cate_id = a.prod_cate_id') ->where($where) ->groupBy('a.prod_cate_id') ->orderBy('a.show_sort DESC') ->offset($offset) ->limit((int)$page_size) ->asArray() ->all(); $result1 = self::find()->select('count(1) as count') ->from(self::tableName() . ' a') ->leftJoin(ProdCategory::tableName() . ' b', 'b.pro_cate_id = a.prod_cate_id') ->asArray() ->where($where) ->one(); $result1 = $result1['count']; return ['list' => $result, 'count' => $result1]; } /* * 选择产品 */ public function selectProd($param) { $pro_cate_id = $param['pro_cate_id']; $system_id = $param['system_id']; $cms_cate_id = $param['cms_cate_id']; $values = [ 'cms_cate_id' => $cms_cate_id, 'system' => $system_id, 'create_time' => date('Y-m-d H:i:s'), 'show_sort' => 1000, 'delete_flag' => 0, 'prod_cate_id' => $pro_cate_id ]; $this->attributes = $values; $flag = $this->insert(); return $flag; } /* * 取消或删除产品 */ public function cancelSelectProd($param) { $pro_cate_id = $param['pro_cate_id']; $system_id = $param['system_id']; $cms_cate_id = $param['cms_cate_id']; $tab = clone $this; $flag = $tab::deleteAll(['and', ['=', 'system', $system_id], ['=', 'cms_cate_id', $cms_cate_id], ['=', 'prod_cate_id', $pro_cate_id]]); return $flag; } /* * 修改子产品排序 */ public function changeProdSort($param) { $system_id = $param['system_id']; $cms_cate_id = $param['cms_cate_id']; $show_sort = $param['show_sort']; $prod_cate_id = $param['prod_cate_id']; $flag = self::updateAll(['show_sort' => $show_sort, 'update_time' => date('Y-m-d H:i:s')], ['and', ['=', 'system', $system_id], ['=', 'cms_cate_id', $cms_cate_id], ['=', 'prod_cate_id', $prod_cate_id], ['=', 'delete_flag', 0]]); return $flag; } /* * ************************C端接口 * * */ /** * Des:获取首页产品数据 * Name: getHomePro * @param $cmsArr * @return array|ActiveRecord[] * @author 倪宗锋 */ public function getHomePro($cmsArr) { $where = [ 'and', ['=', 'a.delete_flag', 0], ['=', 'a.system', 2], ['=', 'a.cms_cate_id', $cmsArr['cms_id']], ['!=', 'b.show_img', ''], ['=', 'b.delete_flag', 0] ]; $select = [ 'b.pro_cate_id', 'b.pro_cate_name', 'b.show_price', 'b.star', 'b.show_img', 'b.sales_count', 'b.original_price', 'b.category_id', '(select category_name from base_category as c where c.category_id = b.category_id) as category_name' ]; $result = self::find()->select($select) ->from(self::tableName() . ' a') ->innerJoin(ProdCategory::tableName() . ' b', 'b.pro_cate_id = a.prod_cate_id') ->where($where) ->groupBy('a.prod_cate_id') ->orderBy('a.show_sort DESC') ->limit($cmsArr['cnt']) ->asArray() ->all(); return $result; } //猜你喜欢 public function getLikeList() { $where = ['and', ['=', 'a.delete_flag', 0], ['=', 'a.system', 2], ['=', 'a.cms_cate_id', 106]]; $select = [ 'b.pro_cate_id', 'b.pro_cate_name', 'b.show_price', 'b.star', 'b.show_img', 'b.sales_count', 'b.original_price', 'b.category_id', '(select category_name from base_category as c where c.category_id = b.category_id) as category_name' ]; $result = self::find()->select($select) ->from(self::tableName() . ' a') ->innerJoin(ProdCategory::tableName() . ' b', 'b.pro_cate_id = a.prod_cate_id') ->where($where) ->groupBy('a.prod_cate_id') ->orderBy('a.show_sort DESC') ->limit(3) ->asArray() ->all(); foreach ($result as &$v) { $v['show_price'] = $this->dealFloat($v['show_price']); } return $result; } //精品推荐 public function getRecommendList($config) { $where = ['and', ['=', 'a.delete_flag', 0], ['=', 'b.delete_flag', 0], ['=', 'c.delete_flag', 0], ['=', 'a.system', 2], ['=', 'a.cms_cate_id', $config['cms_id']], ['!=', 'b.category_id', 1]]; $select = [ 'b.pro_cate_id', 'b.pro_cate_name', 'b.show_price', 'show_img' => new Expression("CONCAT(b.show_img,'.min',RIGHT(b.show_img,LOCATE('.', REVERSE(b.show_img))))"), 'b.original_price', 'b.category_id', 'c.category_name', 'comment_count' => new Expression('(select count(id) from prod_comment where prod_id=b.pro_cate_id)'), 'b.sales_count', 'b.star' ]; $result = self::find()->select($select) ->from(self::tableName() . ' a') ->innerJoin(ProdCategory::tableName() . ' b', 'b.pro_cate_id = a.prod_cate_id') ->leftJoin(BaseCategory::tableName() . ' c', 'c.category_id = b.category_id') ->where($where) ->groupBy('a.prod_cate_id') ->orderBy('a.show_sort DESC,a.prod_cate_id') ->limit($config['cnt']) ->asArray() ->all(); foreach ($result as &$v) { $v['show_price'] = $this->dealFloat($v['show_price']); } return $result; } public function getShowProdList($prodIds) { $where = [ 'and', ['=', 'b.delete_flag', 0], ['=', 'c.delete_flag', 0], ['!=', 'b.category_id', 1], ['in', 'b.pro_cate_id', explode(",", $prodIds)] ]; $select = [ 'b.pro_cate_id', 'b.pro_cate_name', 'b.show_price', 'show_img' => new Expression("CONCAT(b.show_img,'.min',RIGHT(b.show_img,LOCATE('.', REVERSE(b.show_img))))"), 'b.original_price', 'b.category_id', 'c.category_name', 'comment_count' => new Expression('(select count(id) from prod_comment where prod_id=b.pro_cate_id)'), 'b.sales_count', 'b.star' ]; $result = self::find()->select($select) ->from(ProdCategory::tableName() . ' b') ->leftJoin(BaseCategory::tableName() . ' c', 'c.category_id = b.category_id') ->where($where) ->groupBy('b.pro_cate_id') ->orderBy('b.pro_cate_id DESC') ->asArray() ->all(); foreach ($result as &$v) { $v['show_price'] = $this->dealFloat($v['show_price']); } return $result; } /** * Des:获取门票数据列表 * Name: getCatCold * @param $param * @return array * @author 孙彤 */ public function getProdForDestination($param) { $select = [ 'b.prod_cate_id', 'd.category_name', 'c.pro_cate_name', 'c.star', 'c.prod_des', 'c.category_id', 'c.show_price', 'c.original_price', 'c.show_img', 'c.sales_count', ]; $where = [ 'and', ['=', 'b.cms_cate_id', $param['cms_category_id']], ['=', 'c.delete_flag', 0] ]; if (empty($param['prod_name']) == false) { $where[] = ['like', 'c.pro_cate_name', $param['prod_name']]; } $list = self::find()->select($select) ->from(self::tableName() . ' b') ->innerJoin(CmsCategory::tableName() . ' a', 'b.cms_cate_id=a.cms_category_id') ->innerJoin(ProdCategory::tableName() . ' c', 'c.pro_cate_id = b.prod_cate_id') ->innerJoin(BaseCategory::tableName() . ' d', 'c.category_id=d.category_id') ->where($where) ->orderBy('b.show_sort DESC') ->asArray() ->all(); if (empty($list['0'])) { return []; } else { foreach ($list as &$v) { $v['show_price'] = $this->dealFloat($v['show_price']); $v['original_price'] = $this->dealFloat($v['original_price']); } } return $list; } /** * Function Description:根据cms_category_id获取当地玩乐一日游信息 * Function Name: getOneDayTrip * @param $categoryId * @return array|ActiveRecord[] * @author 田玲菲 */ public function getOneDayTrip($categoryId) { $select = [ 'b.prod_cate_id', 'd.category_name', 'c.pro_cate_name', 'c.star', 'c.prod_des', 'c.category_id', 'c.show_price', 'c.original_price', 'show_img' => new Expression('concat(c.show_img,".min.jpg")'), 'c.sales_count', 'comment_count' => new Expression('(select count(id) from prod_comment where prod_id=c.pro_cate_id)'), ]; $where = [ 'and', ['=', 'b.cms_cate_id', $categoryId], ['=', 'c.delete_flag', 0], ['=', 'd.category_id', 4] ]; $list = self::find()->select($select) ->from(self::tableName() . ' b') ->innerJoin(CmsCategory::tableName() . ' a', 'b.cms_cate_id=a.cms_category_id and a.system = 2') ->innerJoin(ProdCategory::tableName() . ' c', 'c.pro_cate_id = b.prod_cate_id') ->innerJoin(BaseCategory::tableName() . ' d', 'c.category_id=d.category_id') ->where($where) ->orderBy('b.show_sort DESC') ->asArray() ->all(); if (empty($list['0'])) { return []; } else { foreach ($list as &$v) { $v['show_price'] = $this->dealFloat($v['show_price']); $v['original_price'] = $this->dealFloat($v['original_price']); } } return $list; } /** * Function Description:根据cms_category_id获取当地玩乐门票信息 * Function Name: getTicket * @param $categoryId * @return array|ActiveRecord[] * @author 田玲菲 */ public function getTicket($categoryId) { $food_list = self::find()->select('prod_cate_id')->from(self::tableName()) ->where(['and', ['=', 'delete_flag', 0], ['=', 'system', 2], ['=', 'cms_cate_id', 127]])->indexBy('prod_cate_id')->asArray()->all(); $food_list = array_keys($food_list); $select = [ 'b.prod_cate_id', 'd.category_name', 'c.pro_cate_name', 'c.star', 'c.prod_des', 'c.category_id', 'c.show_price', 'c.original_price', 'show_img' => new Expression('concat(c.show_img,".min.jpg")'), 'c.sales_count', 'comment_count' => new Expression('(select count(id) from prod_comment where prod_id=c.pro_cate_id)'), ]; $where = [ 'and', ['=', 'b.cms_cate_id', $categoryId], ['=', 'c.delete_flag', 0], ['=', 'd.category_id', 2], ['!=', 'a.cms_category_id', 127], ['not in', 'b.prod_cate_id', $food_list] ]; $list = self::find()->select($select) ->from(self::tableName() . ' b') ->innerJoin(CmsCategory::tableName() . ' a', 'b.cms_cate_id=a.cms_category_id and a.system = 2') ->innerJoin(ProdCategory::tableName() . ' c', 'c.pro_cate_id = b.prod_cate_id') ->innerJoin(BaseCategory::tableName() . ' d', 'c.category_id=d.category_id') ->where($where) ->orderBy('b.show_sort DESC') ->asArray() ->all(); if (empty($list['0'])) { return []; } else { foreach ($list as &$v) { $v['show_price'] = $this->dealFloat($v['show_price']); $v['original_price'] = $this->dealFloat($v['original_price']); } } return $list; } /** * Function Description:根据cms_category_id获取当地玩乐美食娱乐的列表 * Function Name: getFoodList * @param $categoryId * @return array|ActiveRecord[] * @author 田玲菲 */ public function getFoodList($categoryId) { $cmcCategory = new CmsCategory(); $foodId = $cmcCategory->getFoodId(); if (!isset($foodId['cms_category_id'])) { $foodId['cms_category_id'] = 0; } $select = [ 'b.prod_cate_id', 'd.category_name', 'c.pro_cate_name', 'c.star', 'c.prod_des', 'c.category_id', 'c.show_price', 'c.original_price', 'show_img' => new Expression('concat(c.show_img,".min.jpg")'), 'c.sales_count', 'comment_count' => new Expression('(select count(id) from prod_comment where prod_id=c.pro_cate_id)'), ]; $where = [ 'and', ['=', 'b.cms_cate_id', $categoryId], ['=', 'c.delete_flag', 0], ]; $list = self::find()->select($select) ->from(self::tableName() . ' b') ->innerJoin(self::tableName() . ' e', 'e.prod_cate_id = b.prod_cate_id and e.cms_cate_id = ' . $foodId['cms_category_id']) // ->innerJoin(self::tableName() . ' e') ->innerJoin(CmsCategory::tableName() . ' a', 'b.cms_cate_id=a.cms_category_id and a.system = 2') ->innerJoin(ProdCategory::tableName() . ' c', 'c.pro_cate_id = b.prod_cate_id') ->innerJoin(BaseCategory::tableName() . ' d', 'c.category_id=d.category_id') ->where($where) ->orderBy('b.show_sort DESC') ->asArray() ->all(); if (empty($list['0'])) { return []; } else { foreach ($list as &$v) { $v['show_price'] = $this->dealFloat($v['show_price']); $v['original_price'] = $this->dealFloat($v['original_price']); } } return $list; } /** * Function Description:处理价格 * Function Name: dealFloat * @param $float * * @return float * * @author LUOCJ */ public function dealFloat($float) { $int = floor($float); if ($float - $int == 0) { $float = $int; } return $float; } }