|
@@ -4,11 +4,14 @@ use app\common\model\GoodsCate;
|
|
|
use app\common\model\GoodsSeason;
|
|
|
use app\common\model\GoodsServe;
|
|
|
use app\common\model\StoreGoods;
|
|
|
+use app\common\model\User;
|
|
|
use app\common\model\UserCollect;
|
|
|
use app\common\model\UserSearch;
|
|
|
use app\common\model\UserTrack;
|
|
|
use app\common\service\Activity;
|
|
|
use library\tools\Data;
|
|
|
+use think\Db;
|
|
|
+
|
|
|
/**
|
|
|
* @title 商城
|
|
|
* @controller Mall
|
|
@@ -58,6 +61,40 @@ class Mall extends Base
|
|
|
$this->success('ok',['list'=>$list]);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @title 商城商品推荐
|
|
|
+ * @desc 商城商品推荐
|
|
|
+ * @author qc
|
|
|
+ * @method GET
|
|
|
+ * @url /api/Mall/getRecommendList
|
|
|
+ * @header name:Authorization require:1 desc:Token
|
|
|
+ * @param name:page type:int default:0 desc:页数
|
|
|
+ * @param name:page_num type:int default:20 desc:每页数
|
|
|
+ * @return name:id type:int default:-- desc:id
|
|
|
+ * @return name:name type:string default:-- desc:商品名称
|
|
|
+ * @return name:cover type:string default:-- desc:封面
|
|
|
+ * @return name:low_price type:float default:-- desc:价格
|
|
|
+ */
|
|
|
+ public function getRecommendList()
|
|
|
+ {
|
|
|
+ $search_log = UserSearch::getSearchTitle($this->user_id,7);
|
|
|
+ $search_arr = [];
|
|
|
+ $where_str = 'b.id > 0';
|
|
|
+ foreach ($search_log as $t){
|
|
|
+ $search_arr[] = " b.title like '".'%'.$t."%'" .' ';
|
|
|
+ }
|
|
|
+ if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
|
|
|
+ $field = 'a.id,title,a.user_id,label,address,price_min,price_max,company,education,experience_min,experience_max,welfare,province,city,IFNULL(is_recommend,0) is_recommend ';
|
|
|
+ $table = 'dd_store_goods';
|
|
|
+ $order_by_two = 'id';
|
|
|
+ $sql = "SELECT $field FROM " .$table . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM $table b WHERE ( $where_str )) AS c ON c.id = a.id ORDER BY is_recommend DESC , $order_by_two desc LIMIT {$this->off_set},{$this->page_num}";
|
|
|
+ $list = Db::query($sql);
|
|
|
+ $this->success('ok',['list'=>$list]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @title 获取商品列表
|
|
|
* @desc 获取商品列表
|