Răsfoiți Sursa

bugfix:1408 推荐喜欢套餐

qxy 1 lună în urmă
părinte
comite
6f66246e3f

+ 6 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/LifeGroupBuyMainVo.java

@@ -27,6 +27,12 @@ public class LifeGroupBuyMainVo extends LifeGroupBuyMain {
     @ApiModelProperty(value = "商家名称")
     private String storeName;
 
+    @ApiModelProperty(value = "商家评分")
+    private String scoreAvg;
+
+    @ApiModelProperty(value = "团购图片url")
+    private String imagePaths;
+
     @ApiModelProperty(value = "商家手机号")
     private String phone;
 

+ 58 - 0
alien-entity/src/main/java/shop/alien/mapper/LifeGroupBuyMainMapper.java

@@ -1,5 +1,6 @@
 package shop.alien.mapper;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -8,10 +9,14 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
+import org.apache.poi.ss.formula.functions.T;
 import shop.alien.entity.store.LifeGroupBuyMain;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import shop.alien.entity.store.vo.LifeGroupBuyMainVo;
 import shop.alien.entity.store.vo.LifeGroupBuyThaliVo;
 
+import java.util.List;
+
 /**
 * @author youch
 * @description 针对表【life_group_buy_main(团购主表)】的数据库操作Mapper
@@ -47,6 +52,59 @@ public interface LifeGroupBuyMainMapper extends BaseMapper<LifeGroupBuyMain> {
             @Param("buyCount") int buyCount,
             @Param("soldOutStatus") int soldOutStatus
     );
+
+    @Select("SELECT\n" +
+            "    g.id AS id,\n" +
+            "    g.group_no AS group_no,\n" +
+            "    g.group_type AS group_type,\n" +
+            "    g.status AS status,\n" +
+            "    g.approval_comments AS approval_comments,\n" +
+            "    g.store_id AS store_id,\n" +
+            "    g.image_id AS image_id,\n" +
+            "    g.group_name AS group_name,\n" +
+            "    g.start_time_type AS start_time_type,\n" +
+            "    g.start_time_value AS start_time_value,\n" +
+            "    g.end_time AS end_time,\n" +
+            "    g.inventory_num AS inventory_num,\n" +
+            "    g.quota_type AS quota_type,\n" +
+            "    g.quota_value AS quota_value,\n" +
+            "    g.original_price AS original_price,\n" +
+            "    g.preferential_price AS preferential_price,\n" +
+            "    g.effective_date_type AS effective_date_type,\n" +
+            "    g.effective_date_value AS effective_date_value,\n" +
+            "    g.disable_date_type AS disable_date_type,\n" +
+            "    g.disable_date_value AS disable_date_value,\n" +
+            "    g.write_off AS write_off,\n" +
+            "    g.reservation_rules AS reservation_rules,\n" +
+            "    g.use_rules AS use_rules,\n" +
+            "    g.applicable_num AS applicable_num,\n" +
+            "    g.other_rules AS other_rules,\n" +
+            "    g.invoice_type AS invoice_type,\n" +
+            "    g.invoice_describe AS invoice_describe,\n" +
+            "    g.insured_flag AS insured_flag,\n" +
+            "    g.insured_price AS insured_price,\n" +
+            "    g.coupon_id AS coupon_id,\n" +
+            "    g.delete_flag AS delete_flag,\n" +
+            "    g.created_time AS created_time,\n" +
+            "    g.updated_time AS updated_time,\n" +
+            "    g.created_user_id AS created_user_id,\n" +
+            "    g.updated_user_id AS updated_user_id,\n" +
+            "    s.store_name AS store_name,\n" +
+            "    s.score_avg AS scoreAvg,\n" +
+            "    IFNULL(GROUP_CONCAT(img.img_url SEPARATOR ','), '') AS imagePaths\n" +
+            "FROM\n" +
+            "    life_group_buy_main g\n" +
+            "LEFT JOIN store_info s \n" +
+            "    ON g.store_id = s.id \n" +
+            "    AND s.delete_flag = 0 \n" +
+            "LEFT JOIN store_img img \n" +
+            "    ON FIND_IN_SET(img.id, g.image_id) > 0 \n" +
+            "    AND img.delete_flag = 0\t\t \n" +
+            "WHERE\n" +
+            "    g.delete_flag = 0\n" +
+            "GROUP BY\n" +
+            "    g.id")
+    List<LifeGroupBuyMainVo> getLifeGroupInfo(@Param(Constants.WRAPPER) LambdaQueryWrapper<LifeGroupBuyMainVo> queryWrapper);
 }
 
 

+ 11 - 11
alien-store/src/main/java/shop/alien/store/controller/LifeGroupPackageController.java

@@ -12,11 +12,14 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
 import shop.alien.entity.store.LifeCoupon;
+import shop.alien.entity.store.LifeGroupBuyMain;
 import shop.alien.entity.store.StoreGroupInfo;
 import shop.alien.entity.store.StoreHotelGroupRoomInfo;
 import shop.alien.entity.store.vo.LifeCouponVo;
+import shop.alien.entity.store.vo.LifeGroupBuyMainVo;
 import shop.alien.entity.store.vo.LifeTuanGouParamVo;
 import shop.alien.mapper.LifeCouponMapper;
+import shop.alien.mapper.LifeGroupBuyMainMapper;
 import shop.alien.mapper.StoreGroupInfoMapper;
 import shop.alien.mapper.StoreHotelGroupRoomInfoMapper;
 import shop.alien.store.service.LifeCouponService;
@@ -49,6 +52,8 @@ public class LifeGroupPackageController {
 
     private final StoreHotelGroupRoomInfoMapper storeHotelGroupRoomInfoMapper;
 
+    private final LifeGroupBuyMainMapper lifeGroupBuyMainMapper;
+
     @ApiOperation("新建团购")
     @PostMapping("/addOrUpdateGroupPackage")
     public R<Boolean> addOrUpdateGroupPackage(@RequestBody LifeTuanGouParamVo lifeTuanGouParamVo) {
@@ -169,17 +174,12 @@ public class LifeGroupPackageController {
 
     @ApiOperation("猜你喜欢")
     @GetMapping("/getRecommendForYou")
-    private R<IPage<LifeCoupon>> getRecommendForYou() {
-        LambdaUpdateWrapper<LifeCoupon> wrapper = new LambdaUpdateWrapper<>();
-        List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectList(wrapper);
+    private R<IPage<LifeGroupBuyMainVo>> getRecommendForYou() {
+        LambdaQueryWrapper<LifeGroupBuyMainVo> wrapper = new LambdaQueryWrapper<>();
+        List<LifeGroupBuyMainVo> lifeGroupBuyMains = lifeGroupBuyMainMapper.getLifeGroupInfo(wrapper);
         // 打乱数据顺序
-        Collections.shuffle(lifeCoupons);
-        Random random = new Random();
-        for (LifeCoupon coupon : lifeCoupons) {
-            // 生成 1 到 5 之间的随机整数
-            int randomScore = random.nextInt(5) + 1;
-            coupon.setRateScore(randomScore);
-        }
-        return R.data(ListToPage.setPage(lifeCoupons, 1, 4));
+        Collections.shuffle(lifeGroupBuyMains);
+//        Random random = new Random();
+        return R.data(ListToPage.setPage(lifeGroupBuyMains, 1, 4));
     }
 }