liu 9 месяцев назад
Родитель
Сommit
893b4154ea

+ 1 - 1
src/main/java/com/sqx/modules/goods/controller/GoodsShopController.java

@@ -122,7 +122,7 @@ public class GoodsShopController {
         return goodsShopService.selectGoodsShop(phone,msg);
     }
 
-        @ApiOperation("修改商户信息")
+    @ApiOperation("修改商户信息")
     @PostMapping("/updateGoodsShop")
     public Result updateGoodsShop(@RequestBody GoodsShop goodsShop){
         if (ObjectUtils.isEmpty(goodsShop.getShopTypeId())) {

+ 2 - 2
src/main/java/com/sqx/modules/goods/controller/app/AppGoodsController.java

@@ -34,9 +34,9 @@ public class AppGoodsController {
 
     @ApiOperation("根据商铺id查看商品列表")
     @GetMapping(value = "/selectGoodsList")
-    public Result selectGoodsList(Long shopId, Double lng, Double lat){
+    public Result selectGoodsList(Long shopId, Double lng, Double lat,Integer page, Integer limit){
 
-        return goodsService.selectGoodsList(shopId, lng, lat);
+        return goodsService.selectGoodsList(shopId, lng, lat,page,limit);
     }
 
     @ApiOperation("查看商品详情")

+ 3 - 0
src/main/java/com/sqx/modules/goods/dao/GoodsDao.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.sqx.modules.goods.entity.Goods;
 import com.sqx.modules.goods.entity.GoodsClassify;
 import com.sqx.modules.goods.entity.GoodsShop;
+import com.sqx.modules.goods.vo.GoodsListVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -43,4 +44,6 @@ public interface GoodsDao extends BaseMapper<Goods> {
     IPage<Goods> goodsPictureList(Page<Goods> pages,@Param("name") String name,@Param("total") Integer total);
 
     IPage<Goods> goodsParticularsPictureList(Page<Goods> pages,@Param("name") String name,@Param("total") Integer total);
+
+    List<GoodsListVo> selectGoodsVoByClassify(@Param("classifyId") Integer classifyId, @Param("shopId") Long shopId);
 }

+ 1 - 1
src/main/java/com/sqx/modules/goods/service/GoodsService.java

@@ -16,7 +16,7 @@ public interface GoodsService extends IService<Goods> {
 
     Result selectGoodsById(Long goodsId);
 
-    Result selectGoodsList(Long shopId, Double lng, Double lat);
+    Result selectGoodsList(Long shopId, Double lng, Double lat,Integer page, Integer limit);
 
     Result updateGoods(Goods goods);
 

+ 13 - 3
src/main/java/com/sqx/modules/goods/service/impl/GoodsServiceImpl.java

@@ -38,6 +38,7 @@ import com.sqx.modules.goods.service.GoodsAttrValueService;
 import com.sqx.modules.goods.service.GoodsService;
 import com.sqx.modules.goods.service.GoodsSkuService;
 import com.sqx.modules.goods.utils.SkuUtil;
+import com.sqx.modules.goods.vo.GoodsListVo;
 import com.sqx.modules.goods.vo.GoodsVo;
 import com.sqx.modules.order.entity.Evaluate;
 import com.sqx.modules.shop.dao.ShopMessageDao;
@@ -170,15 +171,20 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
 
 
     @Override
-    public Result selectGoodsList(Long shopId, Double lng, Double lat) {
+    public Result selectGoodsList(Long shopId, Double lng, Double lat,Integer page, Integer limit) {
         GoodsShop goodsShop = goodsShopDao.selectGoodsList(shopId, lng, lat);
         //List<Goods> goodsList = goodsDao.selectGoodsClassifyList(shopId);
-        List<GoodsClassify> goodsClassifies = goodsDao.selectAllClassifyList(null, shopId);
+        Page<GoodsClassify> pages = new Page<>(page,limit);
+        IPage<GoodsClassify> goodsClassifyIPage = goodsDao.selectAllClassify(pages,null, shopId);
+//        List<GoodsClassify> goodsClassifyIPage = goodsDao.selectAllClassifyList(null, shopId);
+
+        List<GoodsClassify> goodsClassifies = goodsClassifyIPage.getRecords();
         List<Map<String, Object>> list = new ArrayList<>();
         for (int i = 0; i < goodsClassifies.size(); i++) {
             Map<String, Object> hashMap = new HashMap<>();
             GoodsClassify goodsClassify = goodsClassifies.get(i);
-            List<Goods> goodsList1 = goodsDao.selectGoodsByClassify(goodsClassify.getClassifyId(), shopId);
+//            List<Goods> goodsList1 = goodsDao.selectGoodsByClassify(goodsClassify.getClassifyId(), shopId);
+            List<GoodsListVo> goodsList1 = goodsDao.selectGoodsVoByClassify(goodsClassify.getClassifyId(), shopId);
             hashMap.put("classifyId", goodsClassifies.get(i).getClassifyId());
             hashMap.put("classifyName", goodsClassify.getClassifyName());
             hashMap.put("goodsList", goodsList1);
@@ -197,6 +203,10 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
         Map<String, Object> result = new HashMap<>();
         result.put("goodsShop", goodsShop);
         result.put("list", list);
+        result.put("pages", goodsClassifyIPage.getPages());
+        result.put("current", goodsClassifyIPage.getCurrent());
+        result.put("size", goodsClassifyIPage.getSize());
+        result.put("total", goodsClassifyIPage.getTotal());
         return Result.success().put("data", result);
     }
 

+ 28 - 0
src/main/java/com/sqx/modules/goods/vo/GoodsListVo.java

@@ -0,0 +1,28 @@
+package com.sqx.modules.goods.vo;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class GoodsListVo {
+    @ApiModelProperty("goods_id")
+    private Long goodsId;
+
+    @ApiModelProperty("商品封面图")
+    private String goodsCover;
+
+    @ApiModelProperty("商品名称")
+    private String goodsName;
+
+    @ApiModelProperty("商品销量")
+    private Integer sales;
+
+    @ApiModelProperty("商品描述")
+    private String goodsDescribe;
+
+    @ApiModelProperty("商品实际价格")
+    private BigDecimal goodsMoney;
+}

+ 1 - 1
src/main/java/com/sqx/modules/goods/vo/GoodsShopVo.java

@@ -33,7 +33,7 @@ public class GoodsShopVo implements Serializable {
 
 
     @ApiModelProperty("商铺类型id")
-    private Long shopTypeId;
+    private String shopTypeId;
 
 
     @ApiModelProperty("商铺标签")

+ 15 - 0
src/main/resources/mapper/goods/GoodsMapper.xml

@@ -199,4 +199,19 @@
         GROUP BY a.goods_particulars_picture
     </select>
 
+    <select id="selectGoodsVoByClassify" resultType="com.sqx.modules.goods.vo.GoodsListVo">
+        select g.goods_id as goodsId,
+               g.goods_cover as goodsCover,
+               g.goods_name as goodsName,
+               g.goods_describe as goodsDescribe,
+               g.goods_money as goodsMoney,
+               gsr.sales as sales
+        from goods_shop_relevancy gsr
+                 left join goods g on gsr.goods_id = g.goods_id
+        where gsr.shop_id = #{shopId}
+          and g.classify_id = #{classifyId}
+          and g.status = 0
+        order by g.sort asc
+    </select>
+
 </mapper>