Browse Source

Accept Merge Request #4: (dev-lzl -> dev-feat)

Merge Request: 添加商户管理的是否为供应商字段,添加小程序搜索供应商接口,修改小程序查询店铺接口

Created By: @刘子麟
Accepted By: @刘子麟
URL: https://chuanghaikeji.coding.net/p/moxuanyunshangwaimai/d/backend/git/merge/4?initial=true
刘子麟 1 year atrás
parent
commit
694083e9eb

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

@@ -87,4 +87,20 @@ public class AppGoodsController {
     // public Result getShopActivity(Long shopId){
     //     return Result.success().put("data", goodsShopService.getShopActivity(shopId));
     // }
+
+    @ApiOperation("筛选供应商")
+    @GetMapping(value = "selectSupplierShop")
+    public Result selectSupplierShop(ShopQueryDTO queryDTO){
+        if (StrUtil.isNotBlank(queryDTO.getImpotr())) {
+            //添加历史搜索记录
+            searchHistoryService.insertSearchHistory(queryDTO.getUserId(), queryDTO.getImpotr());
+        }
+        //screen ==1 综合排序(评分), == 2 商户类型筛选, == 3 距离排序,  ==4 销量,  ==5 配送费排序, ==6 免配送费筛选
+        //排序:评分,销量,距离,配送费最低,起送价最低。。。。。
+        //筛选:免配送费,
+        return goodsService.selectSupplierShop(queryDTO);
+    }
+
+
+
 }

+ 2 - 0
src/main/java/com/sqx/modules/goods/dao/GoodsShopDao.java

@@ -105,4 +105,6 @@ public interface GoodsShopDao extends BaseMapper<GoodsShop> {
 
     IPage<GoodsShop> getAdminShoActivityShopList(@Param("pages") Page<GoodsShop> pages, @Param("goodsShop") GoodsShop goodsShop);
 
+    IPage<GoodsShop> selectSupplierShop(Page<GoodsShop> pages, Integer screen, Integer shopTypeId, Double lng, Double lat, String city, String impotr,Long activityId);
+
 }

+ 4 - 0
src/main/java/com/sqx/modules/goods/entity/GoodsShop.java

@@ -254,4 +254,8 @@ public class GoodsShop implements Serializable {
 
     public GoodsShop() {
     }
+
+
+    @ApiModelProperty("是否供应商 0是  1不是")
+    private Integer isSupplier;
 }

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

@@ -62,4 +62,6 @@ public interface GoodsService extends IService<Goods> {
 
     // 查询店铺所有的商品id
     List<Long> getByAllGoodsIdByShopId(Long shopId);
+
+    Result selectSupplierShop(ShopQueryDTO queryDTO);
 }

+ 59 - 0
src/main/java/com/sqx/modules/goods/service/impl/GoodsServiceImpl.java

@@ -752,4 +752,63 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
         return baseMapper.getByAllGoodsIdByShopId(shopId);
     }
 
+    @Override
+    public Result selectSupplierShop(ShopQueryDTO queryDTO) {
+        //如果没有经纬度,则默认为北京的经纬度
+        Double lat = queryDTO.getLat();
+        Double lng = queryDTO.getLng();
+        if (lng == null || lat == null || lng == 0 || lat == 0) {
+            lng = 121.47;
+            lat = 31.23;
+        }
+        Page<GoodsShop> pages = new Page<>(queryDTO.getPage(), queryDTO.getLimit());
+
+        String city = queryDTO.getCity();
+        if (StrUtil.isBlank(city)) {
+            city = getCity(lat, lng);
+        }
+
+        IPage<GoodsShop> goodsShopIPage = goodsShopDao.selectSupplierShop(pages, queryDTO.getScreen(), queryDTO.getShopTypeId(), lng, lat, city, queryDTO.getImpotr(), queryDTO.getActivityId());
+        List<GoodsShop> records = goodsShopIPage.getRecords();
+
+        if (CollUtil.isNotEmpty(records)) {
+            CommonInfo one1 = commonInfoService.findOne(292);
+            CommonInfo one2 = commonInfoService.findOne(293);
+            List<Long> shopIdList = records.stream().map(GoodsShop::getShopId).collect(Collectors.toList());
+            List<Goods> goodsList = goodsDao.selectGoodsBySalesAndGoodsNameAndShopIds(shopIdList, queryDTO.getImpotr());
+            Map<Long, List<Goods>> goodsMap = goodsList.stream().collect(Collectors.groupingBy(Goods::getShopId));
+
+            List<TbCoupon> tbCoupons = tbCouponDao.selectCouponListByShopIdList(shopIdList, null);
+            Map<Long, List<TbCoupon>> couponMap = tbCoupons.stream().collect(Collectors.groupingBy(TbCoupon::getShopId));
+
+            // 查询店铺活动
+            List<ShopActivityVO> shopActivityVOS = activityShopService.getActivityByShopIds(shopIdList);
+            Map<Long, List<ShopActivityVO>> shopActivityMap = shopActivityVOS.stream().collect(Collectors.groupingBy(ShopActivityVO::getShopId));
+
+            for (int a = 0; a < goodsShopIPage.getRecords().size(); a++) {
+                GoodsShop goodsShop = goodsShopIPage.getRecords().get(a);
+                Long shopId = goodsShop.getShopId();
+                goodsShop.setCouponList(couponMap.get(shopId));
+
+                // 设置活动信息
+                goodsShop.setShopActivityList(shopActivityMap.get(shopId));
+
+                if (StringUtils.isNotEmpty(queryDTO.getImpotr())) {
+                    goodsShop.setGoodsList(goodsMap.get(shopId));
+                } else {
+                    goodsShop.setGoodsList(new ArrayList<>());
+                }
+                Double distance = goodsShop.getDistance();
+                double errandTime = distance / Double.parseDouble(one1.getValue());
+                if (errandTime < Double.parseDouble(one2.getValue())) {
+                    errandTime = Double.parseDouble(one2.getValue());
+                }
+                goodsShop.setErrandTime(errandTime);
+            }
+        }
+
+        PageUtils pageUtils = new PageUtils(goodsShopIPage);
+        return Result.success().put("data", pageUtils);
+    }
+
 }

+ 4 - 0
src/main/java/com/sqx/modules/goods/service/impl/GoodsShopServiceImpl.java

@@ -143,6 +143,10 @@ public class GoodsShopServiceImpl extends ServiceImpl<GoodsShopDao, GoodsShop> i
         if(goodsShop.getCashDeposit()==null){
             goodsShop.setCashDeposit(0.0);
         }
+        //        默认不是供应商
+        goodsShop.setIsSupplier(1);
+
+
         baseMapper.insert(goodsShop);
         UserEntity userEntity1 = userService.selectUserById(goodsShop.getUserId());
         SysUserShop sysUserShop = shopAdminDao.selectOne(new QueryWrapper<SysUserShop>().eq("user_id", userEntity1.getAdminUserId()));

+ 37 - 1
src/main/resources/mapper/goods/GoodsShopMapper.xml

@@ -217,7 +217,7 @@
         distance
         from goods_shop gs
         left join shop_type st on gs.shop_type_id = st.id
-        where gs.status = 1 and gs.city = #{city} and gs.putaway_flag = 0
+        where gs.status = 1 and gs.city = #{city} and gs.putaway_flag = 0 and gs.is_supplier=1
         <if test="impotr!=null and impotr!=''">
             AND (gs.shop_name LIKE concat('%',#{impotr},'%') or
             st.shop_type_name like concat('%',#{impotr},'%') or
@@ -492,6 +492,42 @@
         order by distance asc
     </select>
 
+    <select id="selectSupplierShop" resultType="com.sqx.modules.goods.entity.GoodsShop">
+        select * from (select gs.*,(st_distance (point (gs.shop_lng,gs.shop_lat),point(#{lng},#{lat}) ) *111195) AS
+        distance
+        from goods_shop gs
+        left join shop_type st on gs.shop_type_id = st.id
+        where gs.status = 1 and gs.city = #{city} and gs.putaway_flag = 0 and gs.is_supplier=0
+        <if test="impotr!=null and impotr!=''">
+            AND (gs.shop_name LIKE concat('%',#{impotr},'%') or
+            st.shop_type_name like concat('%',#{impotr},'%') or
+            gs.shop_lable LIKE concat('%',#{impotr},'%') or
+            gs.shop_id in (
+            select shop_id from goods where goods_name like concat('%',#{impotr},'%')
+            )
+            )
+        </if>
+
+        <if test="activityId!=null">
+            and gs.activity_id = #{activityId}
+        </if>
+        <if test="shopTypeId!=null">
+            and gs.shop_type_id = #{shopTypeId}
+        </if>
+        order by gs.is_recommend desc
+        <if test="screen==1">
+            ,gs.sort,gs.shop_score desc, distance asc
+        </if>
+        <if test="screen==3">
+            ,distance asc
+        </if>
+        <if test="screen==4">
+            ,gs.shop_sales desc
+        </if>
+        ) a
+        where distribution_distance >= distance
+    </select>
+
 
     <insert id="insertGoodsShop" useGeneratedKeys="true" keyProperty="shopId"
             parameterType="com.sqx.modules.goods.entity.GoodsShop">