Browse Source

fix 店铺官网平台展示

zoujiajian 2 years ago
parent
commit
14e5f51198

+ 3 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/views/OrderDonView.java

@@ -149,6 +149,9 @@ public class OrderDonView {
     @DbField("g.special_type")
     private GoodsDon.SpecialType specialType;
 
+    @DbField("o.yhs.id")
+    private Long yhsId;
+
     @DbIgnore
     private OrderDonWaybill waybill;
 

+ 3 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonViews.java

@@ -129,4 +129,7 @@ public class GoodsDonViews {
 
     @DbIgnore
     private GoodsDonSpecFrontView specs;
+
+    @DbIgnore
+    private OrderCommentFrontView comments;
 }

+ 6 - 0
netflix-dao/src/main/java/com/cyksj/model/views/RenewalView.java

@@ -129,6 +129,12 @@ public class RenewalView {
     @DbField("gr.recharge_status")
     private GroupsRelation.RechargeStatus rechargeStatus;
 
+    /**
+     * 店铺id
+     */
+    @DbField("gr.yhs_id")
+    private Long yhsId;
+
     @DbIgnore
     private GoodsDonViews goodsDonViews;
 

+ 133 - 0
netflix-dao/src/main/java/com/cyksj/model/views/YhShopGoodsFrontView.java

@@ -0,0 +1,133 @@
+package com.cyksj.model.views;
+
+import com.cyksj.model.entity.GoodsDon;
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.DbIgnore;
+import com.ejlchina.searcher.bean.SearchBean;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/*
+ *项目名: yhlxj
+ *文件名: YhShopGoodsFrontView
+ *创建者: JavaZou
+ *创建时间:2023/9/19 15:50
+ */
+@Getter
+@Setter
+@SearchBean(tables = "(select goods_id,min(price) as price from yh_shop_goods_sku where status is true and deleted is true :condition: group by goods_id) yg" +
+		" inner join goods_don g on g.id = yg.goods_id",
+		where = "g.deleted is true and g.status is true and g.type = 1",
+		orderBy = "g.sort_by asc, g.id")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class YhShopGoodsFrontView {
+	@DbField("g.id")
+	private Long id;
+
+	/**
+	 * 商品名称
+	 */
+	@DbField("g.title")
+	private String title;
+
+	/**
+	 * 标签
+	 */
+	@DbField("g.tags")
+	private String tags;
+
+	/**
+	 * 缩略图
+	 */
+	@DbField("g.logo")
+	private String logo;
+
+	/**
+	 * 背景图
+	 */
+	@DbField("g.img")
+	private String img;
+
+	/**
+	 * 类型
+	 */
+	@DbField("g.type")
+	private Integer type;
+
+	/**
+	 * 分类
+	 * 1、AI  2、流媒体
+	 */
+	@DbField("g.category")
+	private Long category;
+
+	@DbField("g.second_type")
+	private Integer secondType;
+
+	@DbField("g.special_type")
+	private GoodsDon.SpecialType specialType;
+
+	/**
+	 * 店铺最低规格价格
+	 */
+	@DbField("yg.price")
+	private BigDecimal price;
+
+	/**
+	 * 最低规格月份
+	 */
+	@DbField("g.min_months")
+	private Integer months;
+
+	/**
+	 * 最低规格天数
+	 */
+	@DbField("g.min_days")
+	private Integer days;
+
+	/**
+	 * 已售
+	 */
+	@DbIgnore
+	private Integer sold;
+
+	/**
+	 * 虚拟销量
+	 */
+	@DbField("g.virtual_sold")
+	private Integer vs;
+
+	@DbIgnore
+	private BigDecimal specificPrice;
+
+	@DbIgnore
+	private Long specificSkuId;
+
+	@DbField("g.pay_desc")
+	private String payDesc;
+
+	/**
+	 * 是否是特定价格平台
+	 */
+	@DbField("g.is_sp")
+	private Boolean isSp;
+
+	/**
+	 * 购买通知信息
+	 */
+	@DbIgnore
+	private String notifyMsg;
+
+	@DbIgnore
+	private List<YhShopGoodsSkuFrontView> skuList;
+
+	@DbIgnore
+	private GoodsDonSpecFrontView specs;
+
+	@DbIgnore
+	private OrderCommentFrontView comments;
+}

+ 118 - 0
netflix-dao/src/main/java/com/cyksj/model/views/YhShopGoodsSkuFrontView.java

@@ -0,0 +1,118 @@
+package com.cyksj.model.views;
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.DbIgnore;
+import com.ejlchina.searcher.bean.SearchBean;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/*
+ *项目名: yhlxj
+ *文件名: YhShopGoodsSkuFrontView
+ *创建者: JavaZou
+ *创建时间:2023/9/19 16:10
+ */
+@Getter
+@Setter
+@SearchBean(tables = "(select * from yh_shop_goods_sku where status is true and deleted is true :condition:) ygs inner join goods_don_sku sku on sku.id = ygs.sku_id",
+		where = "sku.status is true")
+public class YhShopGoodsSkuFrontView {
+	@DbField("sku.id")
+	private Long id;
+
+	@DbField("sku.goods_id")
+	private Long goodsId;
+
+
+	@DbField("sku.sub_title")
+	private String subTitle;
+
+	/**
+	 * 商品规格 ids
+	 */
+	@DbField("sku.spec_ids")
+	private String specIds;
+
+	/**
+	 * 商品规格 value
+	 */
+	@DbField("sku.spec_val")
+	private String specVal;
+
+	/**
+	 * 商品规格 json
+	 */
+	@DbField("sku.spec_json")
+	private String specJson;
+
+	/**
+	 * 规格说明信息
+	 */
+	@DbField("sku.notify_text")
+	private String notifyText;
+
+	/**
+	 * 商品预览图
+	 */
+	@DbField("sku.picture")
+	private String picture;
+
+	/**
+	 * 商品详情图
+	 */
+	@DbField("sku.detail")
+	private String detail;
+
+	/**
+	 * 标签
+	 */
+	@DbField("sku.tags")
+	private String tags;
+
+
+	/**
+	 * 店铺设置的规格价格
+	 */
+	@DbField("ygs.price")
+	private BigDecimal price;
+
+	/**
+	 * 月数
+	 */
+	@DbField("sku.months")
+	private Integer months;
+
+	/**
+	 * 天数
+	 */
+	@DbField("sku.days")
+	private Integer days;
+
+	@DbField("case when sku.spec_val like '%月%' and sku.spec_val not like '%年%' then 0 when sku.spec_val like '%季%' then 1 when sku.spec_val like '%半年%' then 2 when sku.spec_val like '%年%' then 3 else 66 end")
+	private Integer orderBy;
+
+	@DbField("sku.is_dp")
+	private Boolean isDp;
+
+	/**
+	 * 优惠加购商品
+	 */
+	@DbIgnore
+	private List<GoodsDiscountPlusPurchaseRelationFrontView> dpSkuViews;
+
+	/**
+	 * 特定价格
+	 */
+	@DbField("sku.specific_price")
+	private BigDecimal specificPrice;
+
+	/**
+	 * 特定购买平台
+	 */
+	@JsonIgnore
+	private String specificGoodsIds;
+}

+ 2 - 1
netflix-dao/src/main/resources/mapper/GroupRelationMapper.xml

@@ -17,7 +17,8 @@
         recharge_status = null,
         send_time = null,
         submit_time = null,
-        operator = null
+        operator = null,
+        yhs_id = 0,
         where id = #{entity.id}
         <if test="expireTime != null">
             and expiry_time = #{expireTime}

+ 114 - 57
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -32,7 +32,10 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
 
 /**
  * @author chan
@@ -193,13 +196,7 @@ public class GoodsDonController {
             Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
                     .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
             data.setSold(sold + data.getVirtualSold());
-            OrderCommentFrontView comments = beanSearcher.searchFirst(OrderCommentFrontView.class, MapUtils.builder()
-                    .field(OrderCommentFrontView::getGoodsId, data.getId())
-                    .orderBy(OrderCommentFrontView::getCommentTime).desc()
-                    .orderBy(OrderCommentFrontView::getId).desc()
-                    .build());
-            data.setComments(comments);
-            data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
+            data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
         });
         redisService.setNx(pcCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
         //设置特定价格
@@ -211,6 +208,7 @@ public class GoodsDonController {
      * h5 银河首页平台展示
      */
     @GetMapping("/get/homePage")
+    @Deprecated
     public Result<List<GoodsFrontListView>> getGoodsHomePage() {
         List<Long> filter_goodsIds = getFilterGoodsIds();
         String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "H5";
@@ -240,7 +238,7 @@ public class GoodsDonController {
             Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
                     .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
             data.setSold(sold + data.getVirtualSold());
-            data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
+            data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
         });
         redisService.setNx(h5CacheKey, dataList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
         //设置特定价格
@@ -271,7 +269,7 @@ public class GoodsDonController {
             Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
                     .eq(RegisterOrderDon::getGoodsId, data.getId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
             data.setSold(sold + data.getVirtualSold());
-		    data.setNotifyMsg(getPayMsgTime(data.getId(), now, 2));
+            data.setNotifyMsg(getPayMsgTime(data.getId(), now, 2, null));
         });
         redisService.setNx(registerCacheKey, dataList, RedisService.key.REGISTER_HOME_PAGE_CACHE.getTimeout());
         return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
@@ -312,6 +310,13 @@ public class GoodsDonController {
                 }
             }
         });
+        //评论
+//        OrderCommentFrontView comments = beanSearcher.searchFirst(OrderCommentFrontView.class, MapUtils.builder()
+//                .field(OrderCommentFrontView::getGoodsId, views.getId())
+//                .orderBy(OrderCommentFrontView::getCommentTime).desc()
+//                .orderBy(OrderCommentFrontView::getId).desc()
+//                .build());
+//        views.setComments(comments);
         return GatewayResponse.SUCCESS.newBuilder().toResult(views);
     }
 
@@ -395,56 +400,57 @@ public class GoodsDonController {
     }
 
     /**
-     *
      * @param goodsId
-     * @param type 1、普通,2、注册平台
+     * @param type    1、普通,2、注册平台
+     * @param yhsId   店铺id
      * @return
      */
-    public String getPayMsgTime(Long goodsId, DateTime now, Integer type) {
-	    Date startTime = null;
-	    StringBuilder notifyMsg = new StringBuilder();
-	    if (type == 1) {
-		    OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
-				    .eq(OrderDon::getGoodsId, goodsId)
-				    .notIn(OrderDon::getStatus, Constant.noOrderStatus).select(OrderDon::getCreatedTime, OrderDon::getPayTime, OrderDon::getId)
-				    .orderByDesc(OrderDon::getId)
-				    .last("limit 1"));
-		    if (orderDon == null) {
-			    notifyMsg.append("点击购买立即上车");
-			    return notifyMsg.toString();
-		    }
-		    startTime = orderDon.getPayTime() != null ? orderDon.getPayTime() : orderDon.getCreatedTime();
-	    } else if (type == 2) {
-		    RegisterOrderDon orderDon = registerOrderDonMapper.selectOne(Wrappers.lambdaQuery(RegisterOrderDon.class)
-				    .eq(RegisterOrderDon::getGoodsId, goodsId)
-				    .notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus).select(RegisterOrderDon::getCreatedTime, RegisterOrderDon::getPayTime, RegisterOrderDon::getId)
-				    .orderByDesc(RegisterOrderDon::getId)
-				    .last("limit 1"));
-		    if (orderDon == null) {
-			    return null;
-		    }
-		    startTime = orderDon.getPayTime() != null ? orderDon.getPayTime() : orderDon.getCreatedTime();
-	    }
-	    long hour = DateUtil.between(startTime, now, DateUnit.HOUR);
-	    if (hour == 0) {
-		    long minute = DateUtil.between(startTime, now, DateUnit.MINUTE);
-		    if (minute == 0) {
-			    notifyMsg.append("1分钟");
-		    } else {
-			    notifyMsg.append(minute);
-			    notifyMsg.append("分钟");
-		    }
-	    } else {
-		    if (hour > 3) {
-			    int hours = RandomUtil.randomInt(3) + 1;
-			    notifyMsg.append(hours);
-		    } else {
-			    notifyMsg.append(hour);
-		    }
-		    notifyMsg.append("小时");
-	    }
-	    notifyMsg.append("前有人购买");
-	    return notifyMsg.toString();
+    public String getPayMsgTime(Long goodsId, DateTime now, Integer type, Long yhsId) {
+        Date startTime = null;
+        StringBuilder notifyMsg = new StringBuilder();
+        if (type == 1) {
+            OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
+                    .eq(OrderDon::getGoodsId, goodsId)
+                    .notIn(OrderDon::getStatus, Constant.noOrderStatus).select(OrderDon::getCreatedTime, OrderDon::getPayTime, OrderDon::getId)
+                    .eq(yhsId != null, OrderDon::getYhsId, yhsId)
+                    .orderByDesc(OrderDon::getId)
+                    .last("limit 1"));
+            if (orderDon == null) {
+                notifyMsg.append("点击购买立即上车");
+                return notifyMsg.toString();
+            }
+            startTime = orderDon.getPayTime() != null ? orderDon.getPayTime() : orderDon.getCreatedTime();
+        } else if (type == 2) {
+            RegisterOrderDon orderDon = registerOrderDonMapper.selectOne(Wrappers.lambdaQuery(RegisterOrderDon.class)
+                    .eq(RegisterOrderDon::getGoodsId, goodsId)
+                    .notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus).select(RegisterOrderDon::getCreatedTime, RegisterOrderDon::getPayTime, RegisterOrderDon::getId)
+                    .orderByDesc(RegisterOrderDon::getId)
+                    .last("limit 1"));
+            if (orderDon == null) {
+                return null;
+            }
+            startTime = orderDon.getPayTime() != null ? orderDon.getPayTime() : orderDon.getCreatedTime();
+        }
+        long hour = DateUtil.between(startTime, now, DateUnit.HOUR);
+        if (hour == 0) {
+            long minute = DateUtil.between(startTime, now, DateUnit.MINUTE);
+            if (minute == 0) {
+                notifyMsg.append("1分钟");
+            } else {
+                notifyMsg.append(minute);
+                notifyMsg.append("分钟");
+            }
+        } else {
+            if (hour > 3) {
+                int hours = RandomUtil.randomInt(3) + 1;
+                notifyMsg.append(hours);
+            } else {
+                notifyMsg.append(hour);
+            }
+            notifyMsg.append("小时");
+        }
+        notifyMsg.append("前有人购买");
+        return notifyMsg.toString();
     }
 
     /**
@@ -518,4 +524,55 @@ public class GoodsDonController {
             });
         }
     }
+
+    /**
+     * 店铺平台列表
+     */
+    @GetMapping("/get/shop/goods/{yhsId}")
+    public Result<List<YhShopGoodsFrontView>> getShopGoods(@PathVariable Long yhsId) {
+        String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "yhShop:" + yhsId;
+        Object value = redisService.get(yhShopCacheKey);
+        List<YhShopGoodsFrontView> list = null;
+        if (value != null) {
+            try {
+                list = Jsons.parseList(value, YhShopGoodsFrontView.class);
+            } catch (Exception e) {
+            }
+        }
+        if (CollUtil.isEmpty(list)) {
+            MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
+            builder.put("condition", String.format("and yhs_id = %s", yhsId));
+            list = beanSearcher.searchAll(YhShopGoodsFrontView.class, builder.build());
+            redisService.setNx(yhShopCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
+        }
+        DateTime now = DateTime.now();
+        list.forEach(data->{
+            Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
+                    .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
+            data.setSold(sold + data.getVs());
+            data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, yhsId));
+        });
+        return GatewayResponse.SUCCESS.newBuilder().toResult(list);
+    }
+
+    /**
+     * 店铺平台详情
+     */
+    @GetMapping("/get/shop/goods/detail/{yhsId}/{goodsId}")
+    public Result<YhShopGoodsFrontView> getGoodsDetailByYhsId(@PathVariable Long yhsId, @PathVariable Long goodsId) {
+        MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
+        String condition = String.format("and yhs_id = %s and goods_id = %s", yhsId, goodsId);
+        builder.put("condition", condition);
+        YhShopGoodsFrontView goodsDetailView = beanSearcher.searchFirst(YhShopGoodsFrontView.class, builder.build());
+
+        goodsDetailView.setSkuList(beanSearcher.searchAll(YhShopGoodsSkuFrontView.class, MapUtils.builder().put("condition", condition).orderBy(YhShopGoodsSkuFrontView::getOrderBy).asc().build()));
+        goodsDetailView.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::getGoodsId, goodsDetailView.getId()).build()));
+        OrderCommentFrontView comments = beanSearcher.searchFirst(OrderCommentFrontView.class, MapUtils.builder()
+                .field(OrderCommentFrontView::getGoodsId, goodsDetailView.getId())
+                .orderBy(OrderCommentFrontView::getCommentTime).desc()
+                .orderBy(OrderCommentFrontView::getId).desc()
+                .build());
+        goodsDetailView.setComments(comments);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDetailView);
+    }
 }