Ver código fonte

第三方商户新增地图是否显示配置,相关开发

hyq 6 anos atrás
pai
commit
56fa01f57f

+ 29 - 9
kmall-api/src/main/java/com/kmall/api/api/ApiAuthController.java

@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Maps;
 import com.kmall.api.annotation.IgnoreAuth;
 import com.kmall.api.entity.*;
-import com.kmall.api.service.ApiMerchUserService;
-import com.kmall.api.service.ApiStoreService;
-import com.kmall.api.service.ApiUserService;
-import com.kmall.api.service.TokenService;
+import com.kmall.api.service.*;
 import com.kmall.api.util.ApiBaseAction;
 import com.kmall.api.util.ApiUserUtils;
 import com.kmall.api.util.CommonUtil;
@@ -44,6 +41,8 @@ public class ApiAuthController extends ApiBaseAction {
     private ApiStoreService apiStoreService;
     @Autowired
     private ApiMerchUserService apiMerchUserService;
+    @Autowired
+    private ApiThirdMerchantBizService apiThirdMerchantBizService;
 
     /**
      * 登录
@@ -71,6 +70,7 @@ public class ApiAuthController extends ApiBaseAction {
         String requestUrl = ApiUserUtils.getWebAccess(code);//通过自定义工具类组合出小程序需要的登录凭证 code
         logger.info("》》》组合token为:" + requestUrl);
         JSONObject sessionData = CommonUtil.httpsRequest(requestUrl, "GET", null);
+        logger.info("》》》sessionData为:" + sessionData);
 
         if (null == sessionData) {
             return toResponsFail("登录失败");
@@ -133,18 +133,37 @@ public class ApiAuthController extends ApiBaseAction {
         }
     }
 
-
-
     /**
-     * 根据经纬度选择门店
+     * 根据经纬度选择门店,微信审核后删除
      */
     @GetMapping("nearbyList")
     @IgnoreAuth
-    public Object nearbyList(@RequestParam BigDecimal latitude, @RequestParam BigDecimal longitude,@RequestParam String storeId) {
+    public Object nearbyList(@RequestParam BigDecimal latitude, @RequestParam BigDecimal longitude, @RequestParam String storeId) {
+        Map param = Maps.newHashMap();
+         if(org.apache.commons.lang3.StringUtils.isNotEmpty(storeId)){
+            param.put("storeId", storeId);
+        }
+        param.put("latitude", latitude);
+        param.put("longitude", longitude);
+        List<StoreVo> storeVoList = apiStoreService.queryNearbyList(param);
+        if (null != storeVoList && storeVoList.size() > 0 && null != getOpenId()) {
+            tokenService.createAndUpdateToken(getOpenId(), storeVoList.get(0).getId(),getUserId(),storeVoList.get(0).getMerchSn());
+        }
+        return toResponsSuccess(storeVoList);
+    }
+    /**
+     * 根据经纬度选择门店
+     */
+    @GetMapping("nearbyLists")
+    @IgnoreAuth
+    public Object nearbyLists(@RequestParam BigDecimal latitude, @RequestParam BigDecimal longitude, @RequestParam String storeId,@RequestParam String thirdPartyMerchCode) {
         Map param = Maps.newHashMap();
         if(org.apache.commons.lang3.StringUtils.isNotEmpty(storeId)){
             param.put("storeId", storeId);
         }
+        if(org.apache.commons.lang3.StringUtils.isNotEmpty(thirdPartyMerchCode)){
+            param.put("thirdPartyMerchCode", thirdPartyMerchCode);
+        }
         param.put("latitude", latitude);
         param.put("longitude", longitude);
         List<StoreVo> storeVoList = apiStoreService.queryNearbyList(param);
@@ -211,6 +230,7 @@ public class ApiAuthController extends ApiBaseAction {
                 apiMerchUserService.save(merchUserVo);
             }
         }
-        return toResponsSuccess("1");
+        ThirdMerchantBizVo thirdMerchantBizVo = apiThirdMerchantBizService.queryDataByStoreId(storeId);
+        return toResponsSuccess(thirdMerchantBizVo);
     }
 }

+ 18 - 12
kmall-api/src/main/java/com/kmall/api/api/ApiGoodsController.java

@@ -507,7 +507,7 @@ public class ApiGoodsController extends ApiBaseAction {
         params.put("store_id", store_id);
         if (!StringUtils.isNullOrEmpty(sort) && !StringUtils.isNullOrEmpty(order)) {
             if (sort.equals("price")) {
-                params.put("sidx", "a.retail_price");
+                params.put("sidx", "psr1.retail_price");
                 params.put("order", order);
             }
         }
@@ -663,20 +663,33 @@ public class ApiGoodsController extends ApiBaseAction {
                               @RequestParam(value = "page", defaultValue = "1") Integer
                                       page, @RequestParam(value = "size", defaultValue = "10") Integer size,
                               String sort, String order) {
+        Long storeId = getStoreId();
         Map params = Maps.newHashMap();
         params.put("is_new", isNew);
         params.put("page", page);
         params.put("limit", size);
         params.put("order", sort);
         params.put("sidx", order);
-        params.put("store_id", getStoreId());
+        params.put("store_id", storeId);
+        StoreVo storeVo = apiStoreService.queryObject(storeId);
+        String isStockShare = "";
+        if(storeVo != null) {
+            ThirdMerchantBizVo thirdMerchantBiz = apiThirdMerchantBizService.getThirdMerchangByCode(storeVo.getThirdPartyMerchCode());
+            if (null == thirdMerchantBiz) {
+                return toResponsFail("第三方商户为空");
+            }
+            isStockShare = thirdMerchantBiz.getIsStockShare();
+        }
         //
         if (null != sort && sort.equals("price")) {
             params.put("sidx", "psr1.retail_price");
             params.put("order", order);
-        } else if (null != sort && sort.equals("sell")) {
+        } else if (null != sort && sort.equals("sell") && Dict.isStockShare.item_0.getItem().equalsIgnoreCase(isStockShare)) {
             params.put("sidx", "psr1.sell_volume");
             params.put("order", order);
+        } else if (null != sort && sort.equals("sell") && Dict.isStockShare.item_1.getItem().equalsIgnoreCase(isStockShare)) {
+            params.put("sidx", "a.sell_volume");
+            params.put("order", order);
         } else {
             params.put("sidx", "id");
             params.put("order", "desc");
@@ -703,19 +716,12 @@ public class ApiGoodsController extends ApiBaseAction {
         // 当前购物车中
         List<CartVo> cartList = new ArrayList();
         if (null != getUserId()) {
-            Long storeId = getStoreId();
             //查询列表数据
             Map cartParam = Maps.newHashMap();
             cartParam.put("user_id", getUserId());
             cartParam.put("store_id", storeId);
-            StoreVo storeVo = apiStoreService.queryObject(storeId);
-            if(storeVo != null) {
-                ThirdMerchantBizVo thirdMerchantBiz = apiThirdMerchantBizService.getThirdMerchangByCode(storeVo.getThirdPartyMerchCode());
-                if (null == thirdMerchantBiz) {
-                    return toResponsFail("第三方商户为空");
-                }
-                cartParam.put("isStockShare", thirdMerchantBiz.getIsStockShare());
-            }
+            cartParam.put("isStockShare", isStockShare);
+
             cartList = cartService.queryList(cartParam);
         }
         if (null != cartList && cartList.size() > 0 && null != goodsList && goodsList.size() > 0) {

+ 1 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiThirdMerchantBizMapper.java

@@ -13,4 +13,5 @@ import org.springframework.stereotype.Component;
 @Component
 public interface ApiThirdMerchantBizMapper extends BaseDao<ThirdMerchantBizVo> {
     ThirdMerchantBizVo getThirdMerchangByCode(@Param("thirdMerchantCode")String thirdMerchantCode);
+    ThirdMerchantBizVo queryDataByStoreId(@Param("storeId")Long storeId);
 }

+ 10 - 0
kmall-api/src/main/java/com/kmall/api/entity/ThirdMerchantBizVo.java

@@ -59,6 +59,16 @@ public class ThirdMerchantBizVo implements Serializable {
      */
     private Date tstm;
 
+    private String isMapShow;
+
+    public String getIsMapShow() {
+        return isMapShow;
+    }
+
+    public void setIsMapShow(String isMapShow) {
+        this.isMapShow = isMapShow;
+    }
+
     public String getIsStoreUserShare() {
         return isStoreUserShare;
     }

+ 5 - 0
kmall-api/src/main/java/com/kmall/api/service/ApiThirdMerchantBizService.java

@@ -59,4 +59,9 @@ public class ApiThirdMerchantBizService {
     public ThirdMerchantBizVo getThirdMerchangByCode(String thirdMerchantCode) {
         return thirdMerchantBizMapper.getThirdMerchangByCode(thirdMerchantCode);
     }
+
+    public ThirdMerchantBizVo queryDataByStoreId(Long storeId) {
+        return thirdMerchantBizMapper.queryDataByStoreId(storeId);
+    }
+
 }

+ 2 - 1
kmall-api/src/main/resources/mybatis/mapper/ApiGoodsMapper.xml

@@ -238,6 +238,7 @@
         LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
         left join third_merchant_biz mb on mb.third_party_merch_code = a.third_party_merch_code and mb.merch_sn=a.merch_sn
         LEFT JOIN mall_product b ON b.id = psr1.product_id
+        left join mall_category c on psr1.category_id = c.id
         where 1 = 1
         <if test="isStockShare == 1">
             and (a.goods_number > 0  or psr1.stock_num > 0 )
@@ -268,7 +269,7 @@
             </foreach>
         </if>
         <if test="category_parent_id != null and category_parent_id != null">
-            and FIND_IN_SET(psr1.category_id, getCategoryChildLst(#{category_parent_id}))
+            and FIND_IN_SET(c.parent_id, getCategoryChildLst(#{category_parent_id}))
         </if>
         <if test="goods_ids != null">
             and a.id in

+ 4 - 1
kmall-api/src/main/resources/mybatis/mapper/ApiStoreMapper.xml

@@ -175,9 +175,12 @@
         <if test="county_name != null and county_name.trim() != ''">
             AND county_name = #{county_name}
         </if>
-        <if test="storeId != null ">
+        <if test="storeId != null and storeId != '' ">
             AND a.id = #{storeId}
         </if>
+        <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != '' ">
+            AND a.third_party_merch_code = #{thirdPartyMerchCode}
+        </if>
         ) tmp
         order by distance asc
         limit 0, 10

+ 20 - 1
kmall-api/src/main/resources/mybatis/mapper/ApiThirdMerchantBizMapper.xml

@@ -16,6 +16,7 @@
         <result property="moderSn" column="moder_sn"/>
         <result property="modTime" column="mod_time"/>
         <result property="tstm" column="tstm"/>
+		<result property="isMapShow" column="is_map_show"/>
     </resultMap>
 
 	<select id="queryObject" resultType="com.kmall.api.entity.ThirdMerchantBizVo">
@@ -27,6 +28,7 @@
 			`is_valid`,
 			is_stock_share,
 			is_store_user_share,
+			is_map_show,
 			`creater_sn`,
 			`create_time`,
 			`moder_sn`,
@@ -45,6 +47,7 @@
 		`is_valid`,
 		is_stock_share,
 		is_store_user_share,
+		is_map_show,
 		`creater_sn`,
 		`create_time`,
 		`moder_sn`,
@@ -63,6 +66,7 @@
 		`is_valid`,
 		is_stock_share,
 		is_store_user_share,
+		is_map_show,
 		`creater_sn`,
 		`create_time`,
 		`moder_sn`,
@@ -72,6 +76,20 @@
 		where third_party_merch_code = #{thirdMerchantCode}
 	</select>
 
+	<select id="queryDataByStoreId" resultType="com.kmall.api.entity.ThirdMerchantBizVo">
+		select
+		b.`third_merch_sn`,
+		b.`merch_sn`,
+		b.`third_party_merch_code`,
+		b.`third_party_merch_name`,
+		b.`is_valid`,
+		b.is_stock_share,
+		b.is_store_user_share,
+		b.is_map_show
+		from third_merchant_biz b inner join mall_store s on s.third_party_merch_code=b.third_party_merch_code
+		where s.id = #{storeId}
+	</select>
+
 	<select id="queryList" resultType="com.kmall.api.entity.ThirdMerchantBizVo">
 		select
     		`third_merch_sn`,
@@ -80,7 +98,8 @@
     		`third_party_merch_name`,
     		`is_valid`,
 			is_stock_share,
-		is_store_user_share,
+			is_store_user_share,
+			is_map_show,
     		`creater_sn`,
     		`create_time`,
     		`moder_sn`,