Przeglądaj źródła

首页二级页接口

zhijiezhao 1 miesiąc temu
rodzic
commit
ffc2c2e4c4

+ 21 - 3
src/main/java/com/caimei365/commodity/controller/ProductPageApi.java

@@ -57,7 +57,7 @@ public class ProductPageApi {
     })
     @PostMapping("/push/vote")
     public ResponseJson vote(Integer id, Integer userId, Integer voteType, HttpServletRequest request) {
-        return pageService.vote(id, userId, voteType,request);
+        return pageService.vote(id, userId, voteType, request);
     }
 
     @ApiOperation("删除sku")
@@ -111,6 +111,19 @@ public class ProductPageApi {
         return pageService.getHomeData(userId, source);
     }
 
+    @ApiOperation("新首页专区二级页")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "zoneId", value = "专区id"),
+            @ApiImplicitParam(required = true, name = "userId", value = "用户id"),
+            @ApiImplicitParam(required = false, name = "typeSort", value = "分类类型:1产品,2仪器,3耗材配件"),
+            @ApiImplicitParam(required = true, name = "source", value = "来源:1网站,2小程序")})
+    @IpSave(saveName = "新首页专区二级页", saveParams = true)
+    @GetMapping("/zone/second")
+    public ResponseJson<Map<String, Object>> zoneSecondData(Integer zoneId, Integer userId, Integer typeSort, Integer source,
+                                                            @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                            @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+        return pageService.getZoneSecondData(zoneId, userId, typeSort, source,pageNum,pageSize);
+    }
 
     @ApiOperation("新品橱窗重点推荐数据")
     @GetMapping("/home/recommend")
@@ -388,7 +401,10 @@ public class ProductPageApi {
      * @return
      */
     @ApiOperation("超级会员优惠商品页面")
-    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "userId", value = "用户id"), @ApiImplicitParam(required = false, name = "source", value = "来源 : 1 网站 ; 2 小程序"), @ApiImplicitParam(required = false, name = "pageNum", value = "页码"), @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")})
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "userId", value = "用户id"),
+            @ApiImplicitParam(required = false, name = "source", value = "来源 : 1 网站 ; 2 小程序"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")})
     @GetMapping("/svip/product/page")
     public ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
         if (null == userId || source == null) {
@@ -440,7 +456,9 @@ public class ProductPageApi {
      * 采美百科产品仪器分类数据
      */
     @ApiOperation("采美百科产品仪器分类数据")
-    @ApiImplicitParams({@ApiImplicitParam(required = true, name = "typeId", value = "分类id"), @ApiImplicitParam(required = false, name = "pageNum", value = "页码"), @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),})
+    @ApiImplicitParams({@ApiImplicitParam(required = true, name = "typeId", value = "分类id"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")})
     @GetMapping("/baike/type")
     public ResponseJson<PaginationVo<BaikeProductVo>> getBaikeTypeData(Integer typeId, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
         if (null == typeId) {

+ 4 - 0
src/main/java/com/caimei365/commodity/mapper/PageMapper.java

@@ -520,4 +520,8 @@ public interface PageMapper {
     List<NewPageZone> getPageZone(Integer source);
 
     List<NewPageZoneImage> getZoneImageList(@Param("id") Integer id, @Param("source") Integer source);
+
+    List<ProductItemVo> getZoneProducts(Integer id);
+
+    List<ProductItemVo> getZoneProductBySort(@Param("zoneId") Integer zoneId, @Param("typeSort") Integer typeSort);
 }

+ 2 - 0
src/main/java/com/caimei365/commodity/service/PageService.java

@@ -353,4 +353,6 @@ public interface PageService {
     ResponseJson<Map<String,Object>> getVoteList();
 
     ResponseJson vote(Integer id, Integer userId,  Integer voteType,HttpServletRequest request);
+
+    ResponseJson<Map<String, Object>> getZoneSecondData(Integer zoneId, Integer userId,Integer typeSort, Integer source, int pageNum, int pageSize);
 }

+ 36 - 17
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -158,22 +158,6 @@ public class PageServiceImpl implements PageService {
         Map<String, Object> map = new HashMap<>(6);
         //楼层管理
         source = source == null ? 1 : source;
-//        List<PageFloorVo> homePageFloor = pageMapper.getHomePageFloor(source);
-//        Iterator<PageFloorVo> floorIterator = homePageFloor.iterator();
-//        while (floorIterator.hasNext()) {
-//            PageFloorVo floor = floorIterator.next();
-//            FloorContentVo floorContent = pageMapper.getFloorContentById(floor.getId());
-//            setFloorLinkType(floorContent);
-//            floor.setFloorContent(floorContent);
-//            List<FloorImageVo> floorImageList = pageMapper.getFloorImageById(floor.getId(), source);
-//            if (floorImageList == null || floorImageList.size() == 0) {
-//                floorIterator.remove();
-//                continue;
-//            }
-//            setFloorImageProduct(userId, floorImageList, source);
-//            floor.setFloorImageList(floorImageList);
-//        }
-//        map.put("homePageFloor", homePageFloor);
         /**
          * 专区
          */
@@ -181,12 +165,13 @@ public class PageServiceImpl implements PageService {
         for (NewPageZone zone : zones) {
             Integer finalSource = source;
             List<NewPageZoneImage> imageList = pageMapper.getZoneImageList(zone.getId(), finalSource);
-            List<ProductItemVo> products = zone.getProducts();
+//            zone.setProducts(pageMapper.getZoneProducts(zone.getId()));
             imageList.forEach(i -> {
                 Integer linkType = AppletsLinkUtil.getLinkType(i.getLink());
                 i.setLinkType(linkType);
                 i.setLinkParam(AppletsLinkUtil.getLinkParam(linkType, i.getLink()));
             });
+            List<ProductItemVo> products = zone.getProducts();
             zone.setImageList(imageList);
             products.forEach(p -> {
                 priceUtilService.setProductDetails(userId, p, 0);
@@ -1593,6 +1578,7 @@ public class PageServiceImpl implements PageService {
      * @param id
      * @return
      */
+    @Override
     public ResponseJson<BaikeProductVo> getEntryInfoById(Integer id) {
         //获取词条信息
         BaikeProductVo entryInfo = pageMapper.getEntryInfoById(id);
@@ -1907,4 +1893,37 @@ public class PageServiceImpl implements PageService {
         }
         return ResponseJson.success("投票成功!");
     }
+
+    /**
+     * 专区二级页  1.根据仪器,产品,耗材配件筛选商品
+     * 2. 头部展示专区轮播图
+     *
+     * @param zoneId
+     * @param userId
+     * @param typeSort
+     * @param source
+     * @return
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getZoneSecondData(Integer zoneId, Integer userId, Integer typeSort, Integer source, int pageNum, int pageSize) {
+        Map<String, Object> map = new HashMap<>();
+        List<NewPageZoneImage> imageList = pageMapper.getZoneImageList(zoneId, source);
+        imageList.forEach(i -> {
+            Integer linkType = AppletsLinkUtil.getLinkType(i.getLink());
+            i.setLinkType(linkType);
+            i.setLinkParam(AppletsLinkUtil.getLinkParam(linkType, i.getLink()));
+        });
+        PageHelper.startPage(pageNum, pageSize);
+        List<ProductItemVo> products = pageMapper.getZoneProductBySort(zoneId, typeSort);
+        for (ProductItemVo product : products) {
+            priceUtilService.setProductDetails(userId, product, 0);
+            //优惠券标识
+            Boolean couponsLogo = setCouponsLogo(userId, product.getProductId(), source);
+            product.setCouponsLogo(couponsLogo);
+        }
+        PaginationVo<ProductItemVo> pageData = new PaginationVo(products);
+        map.put("imageList", imageList);
+        map.put("products", pageData);
+        return ResponseJson.success(map);
+    }
 }

+ 84 - 12
src/main/resources/mapper/PageMapper.xml

@@ -1809,10 +1809,13 @@
         p.productType,
         p.brandID
         from new_page_zone npz
-        left join(select * from new_page_zone_product order by sort)npzp on npz.id = npzp.zoneId
+        left join
+        (SELECT zp.zoneId,zp.productId,ROW_NUMBER() OVER (PARTITION BY zp.zoneId ORDER BY zp.sort) AS rn FROM
+        new_page_zone_product zp)
+        npzp ON npz.id = npzp.zoneId AND npzp.rn <![CDATA[ <= ]]> 4
         left join product p on npzp.productId = p.productId
         left join cm_organize_product_info copi on copi.productId = p.productId
-        where  npz.delFlag = 0
+        where npz.delFlag = 0
         <if test="source == 1">
             and npz.wwwEnabledStatus = 1
         </if>
@@ -1824,16 +1827,16 @@
 
     <select id="getZoneImageList" resultType="com.caimei365.commodity.model.vo.NewPageZoneImage">
         select id as imageId,
-               zoneId,
-               image,
-               crmImage,
-               title,
-               crmTitle,
-               link,
-               crmLink,
-               wwwEnabledStatus,
-               crmEnabledStatus,
-               sort
+        zoneId,
+        image,
+        crmImage,
+        title,
+        crmTitle,
+        link,
+        crmLink,
+        wwwEnabledStatus,
+        crmEnabledStatus,
+        sort
         from new_page_zone_image
         where zoneId = #{id}
         <if test="source == 1">
@@ -1844,4 +1847,73 @@
         </if>
         order by sort
     </select>
+
+    <select id="getZoneProducts" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
+        select p.productId,
+               p.name,
+               p.mainImage,
+               p.actStatus,
+               p.visibility,
+               p.productCode as code,
+               p.priceFlag,
+               p.shopId,
+               p.taxPoint    as taxRate,
+               p.includedTax,
+               p.invoiceType,
+               p.productCategory,
+               copi.validFlag,
+               p.commodityType,
+               p.bigTypeId,
+               p.smallTypeId,
+               p.tinyTypeId,
+               p.productType,
+               p.brandID
+        from new_page_zone_product npzp
+                 left join product p on npzp.productId = p.productId
+                 left join cm_organize_product_info copi on copi.productId = p.productId
+        where npzp.zoneId = #{id}
+        order by npzp.sort
+        limit 4
+    </select>
+
+    <select id="getZoneProductBySort" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
+        select p.productId,
+        p.name,
+        p.mainImage,
+        p.actStatus,
+        p.visibility,
+        p.productCode as code,
+        p.priceFlag,
+        p.shopId,
+        p.taxPoint as taxRate,
+        p.includedTax,
+        p.invoiceType,
+        p.productCategory,
+        copi.validFlag,
+        p.commodityType,
+        p.bigTypeId,
+        p.smallTypeId,
+        p.tinyTypeId,
+        p.productType,
+        p.brandID
+        from new_page_zone_product npzp
+        left join product p on npzp.productId = p.productId
+        left join bigtype bt on p.bigTypeID = bt.bigTypeID
+        left join cm_organize_product_info copi on copi.productId = p.productId
+        <where>
+            npzp.zoneId = #{zoneId}
+            and copi.organizeId = 0
+            and copi.validFlag = 2
+            <if test="typeSort == 1">
+                and bt.typeSort = '1'
+            </if>
+            <if test="typeSort == 2">
+                and bt.typeSort = '2'
+            </if>
+            <if test="typeSort == 3">
+                and bt.bigTypeID = 1023
+            </if>
+        </where>
+        order by npzp.sort
+    </select>
 </mapper>