hrjy 2 years ago
parent
commit
48dfd3045d

+ 1 - 1
app/api/controller/PublicController.php

@@ -63,7 +63,7 @@ class PublicController
         $info['bastBanner'] = sys_data('routine_home_bast_banner') ?? [];//TODO 首页精品推荐图片
         $benefit = StoreProduct::getBenefitProduct('id,image,store_name,cate_id,price,ot_price,stock,unit_name', $promotionNumber);//TODO 首页促销单品
         $lovely = sys_data('routine_home_new_banner') ?: [];//TODO 首发新品顶部图
-        $likeInfo = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,ot_price,unit_name', 3);//TODO 热门榜单 猜你喜欢
+        $likeInfo = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,ot_price,unit_name',3);//TODO 热门榜单 猜你喜欢
         $couponList = StoreCouponIssue::getIssueCouponList($request->uid(), 3);
         if ($request->uid()) {
             $subscribe = WechatUser::where('uid', $request->uid())->value('subscribe') ? true : false;

+ 6 - 1
app/api/controller/store/StoreProductController.php

@@ -3,6 +3,7 @@
 namespace app\api\controller\store;
 
 use app\admin\model\store\StoreDescription;
+use app\admin\model\store\StoreProductAttrResult;
 use app\admin\model\system\SystemAttachment;
 use app\models\routine\RoutineCode;
 use app\models\store\StoreOrder;
@@ -177,6 +178,10 @@ class StoreProductController
         $data['mapKey'] = sys_config('tengxun_map_key');
         $data['store_self_mention'] = (int)sys_config('store_self_mention') ?? 0;//门店自提是否开启
         $data['activity'] = StoreProduct::activity($data['storeInfo']['id'], false);
+        $result = StoreProductAttrResult::where('product_id', $id)->find();
+        $result = json_decode($result->result);
+        $integral = $result->value[0]->integral;
+        $data['integral'] = $integral['integral'] ?? 0;
         return app('json')->successful($data);
     }
 
@@ -196,7 +201,7 @@ class StoreProductController
             ['limit', 0]
         ], $request, true);
         if (!$limit) return app('json')->successful([]);
-        $productHot = StoreProduct::getHotProductLoading('id,image,store_name,cate_id,price,unit_name,ot_price', (int)$page, (int)$limit);
+        $productHot = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,unit_name,ot_price', (int)$limit, (int)$page);
         if (!empty($productHot)) {
             foreach ($productHot as $k => $v) {
                 $productHot[$k]['activity'] = StoreProduct::activity($v['id']);

+ 2 - 2
app/models/store/StoreProduct.php

@@ -199,12 +199,12 @@ class StoreProduct extends BaseModel
      * @param int $limit
      * @return false|\PDOStatement|string|\think\Collection
      */
-    public static function getHotProduct($field = '*', $limit = 0, $uid = 0)
+    public static function getHotProduct($field = '*',$limit = 0,$page =0, $uid = 0)
     {
         $model = self::where('is_hot', 1)->where('is_del', 0)->where('mer_id', 0)
             ->where('stock', '>', 0)->where('is_show', 1)->field($field)
             ->order('sort DESC, id DESC');
-        if ($limit) $model->limit($limit);
+        if ($limit) $model->page($page,$limit);
         $list = $model->select();
         $list = count($list) ? $list->toArray() : [];
         if (!empty($list)) {