alias('h') ->join('ls_retail_goods as g on g.id=h.' . $this::GOODS_ID) ->where($map) ->group($this::GOODS_ID) ->order($order) ->field($fields) ->select(); return $goods; } /** * @param $map * @param $fields * @param $order * @return mixed */ public function getHostGoods_v1($map, $fields, $order, $page) { if ($page) { $goods = $this->alias('h') ->join('ls_retail_goods as g on g.id=h.' . $this::GOODS_ID) ->join('ls_retail_store_sale_goods as s on g.id=s.goods_id') ->where($map) ->group('h.' . $this::GOODS_ID) ->order($order) ->page($page) ->field($fields) ->select(); } else { $goods = $this->alias('h') ->join('ls_retail_goods as g on g.id=h.' . $this::GOODS_ID) ->join('ls_retail_store_sale_goods as s on g.id=s.goods_id') ->where($map) ->group('h.' . $this::GOODS_ID) ->order($order) ->field($fields) ->select(); } return $goods; } /** * 获取推荐、最新商品 * @param $map * @param string $fields * @param string $order * @param string $page * @return mixed */ public function getActGoods($map, $fields = 'h.*,g.goods_name,g.goods_num,g.attribute_state,g.online_price', $order = 'h.id asc', $page = '1,10') { $goods = $this->alias('h') ->join('ls_retail_goods as g on g.id=h.' . $this::GOODS_ID) ->where($map) ->group($this::GOODS_ID) ->order($order) ->page($page) ->field($fields) ->select(); return $goods; } /** * 商城获取最新商品 * @param $map * @param string $fields * @param string $order * @param string $page * @return array */ public function getOtherGoods($map, $fields = '*', $order = 'g.goods_order asc,g.id desc', $page = '1,10') { if (empty($map)) { return array(); } $time = time(); $list = $this->alias('h') ->join("ls_retail_goods as g on g.id=h.goods_id") ->join("ls_retail_host as h1 on g.id=h1.goods_id AND h1.type=2 AND h1.starttime<={$time} AND h1.endtime>={$time} AND h1.state=1 AND h1.status=1", 'LEFT') ->where($map) ->order($order) ->group('g.id') ->page($page) ->field($fields) ->select(); return $list; } /** * 查询促销、推荐、最新商品及名称列表 * @param $map 搜索条件 * @param string $fields 所需字段 * @param string $order 排序方式 * @param string $page 分页 * @return mixed */ public function getGoodsList($map, $fields = 'h.*,g.goods_name,g.goods_code,g.goods_number,s.sku_id_list,s.sku_goods_number,s.sku_code', $order = 'h.id desc', $page = '1,10') { if (empty($map)) { return array(); } $list = $this->alias('h') ->join('ls_retail_goods as g on g.id=h.' . $this::GOODS_ID) ->join('ls_retail_sku_goods as s on s.id=h.' . $this::SKU_ID, 'LEFT') ->where($map) ->order($order) ->page($page) ->field($fields) ->select(); return $list; } /** * 查询促销、推荐、最新商品及名称数量 * @param $map 搜索条件 * @return mixed */ public function getGoodsCount($map) { if (empty($map)) { return 0; } $count = $this->alias('h') ->join('ls_retail_goods as g on g.id=h.' . $this::GOODS_ID) ->where($map) ->count(); return intval($count); } }