Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	lb-module/src/main/java/com/ydd/module/mapper/ShopMapper.java
#	lb-module/src/main/java/com/ydd/module/service/IShopService.java
#	lb-module/src/main/java/com/ydd/module/service/impl/AgentServiceImpl.java
#	lb-module/src/main/java/com/ydd/module/service/impl/PackageCityConfigServiceImpl.java
#	lb-module/src/main/java/com/ydd/module/service/impl/PackageDeliveryDetailServiceImpl.java
#	lb-module/src/main/java/com/ydd/module/service/impl/PackageDeliveryServiceImpl.java
#	lb-module/src/main/java/com/ydd/module/service/impl/ShopDeliveryServiceImpl.java
#	lb-module/src/main/java/com/ydd/module/service/impl/ShopServiceImpl.java
#	lb-module/src/main/resources/mapper/module/shopMapper.xml
wangtao 3 tahun lalu
induk
melakukan
63808fceaa
26 mengubah file dengan 1303 tambahan dan 934 penghapusan
  1. 383 0
      lb-app/src/main/java/com/ydd/app/ShopEntityUtils.java
  2. 10 4
      lb-app/src/main/java/com/ydd/app/controller/ShopApi.java
  3. 8 0
      lb-app/src/main/java/com/ydd/app/dto/ShopReq.java
  4. 42 0
      lb-app/src/main/java/com/ydd/app/service/ApiShopNewService.java
  5. 31 1
      lb-app/src/main/java/com/ydd/app/service/impl/ApiOrderDetailServiceImpl.java
  6. 59 49
      lb-app/src/main/java/com/ydd/app/service/impl/ApiOrderValuationServiceImpl.java
  7. 484 0
      lb-app/src/main/java/com/ydd/app/service/impl/ApiShopNewServiceImpl.java
  8. 86 10
      lb-app/src/main/java/com/ydd/app/service/impl/ApiShopServiceImpl.java
  9. 4 0
      lb-app/src/main/resources/application-dev.yml
  10. 4 0
      lb-app/src/main/resources/application-prod.yml
  11. 1 1
      lb-module/src/main/java/com/ydd/module/domain/PackageCityConfig.java
  12. 6 0
      lb-module/src/main/java/com/ydd/module/domain/Shop.java
  13. 74 0
      lb-module/src/main/java/com/ydd/module/domain/ShopDeliveryConfig.java
  14. 15 0
      lb-module/src/main/java/com/ydd/module/mapper/ShopDeliveryConfigMapper.java
  15. 4 19
      lb-module/src/main/java/com/ydd/module/mapper/ShopMapper.java
  16. 13 0
      lb-module/src/main/java/com/ydd/module/service/IShopDeliveryConfigService.java
  17. 8 91
      lb-module/src/main/java/com/ydd/module/service/IShopService.java
  18. 3 9
      lb-module/src/main/java/com/ydd/module/service/impl/AgentServiceImpl.java
  19. 1 1
      lb-module/src/main/java/com/ydd/module/service/impl/PackageCityConfigServiceImpl.java
  20. 6 9
      lb-module/src/main/java/com/ydd/module/service/impl/PackageDeliveryDetailServiceImpl.java
  21. 0 3
      lb-module/src/main/java/com/ydd/module/service/impl/PackageDeliveryServiceImpl.java
  22. 17 0
      lb-module/src/main/java/com/ydd/module/service/impl/ShopDeliveryConfigServiceImpl.java
  23. 15 56
      lb-module/src/main/java/com/ydd/module/service/impl/ShopDeliveryServiceImpl.java
  24. 15 519
      lb-module/src/main/java/com/ydd/module/service/impl/ShopServiceImpl.java
  25. 7 0
      lb-module/src/main/resources/mapper/module/ShopDeliveryConfigMapper.xml
  26. 7 162
      lb-module/src/main/resources/mapper/module/shopMapper.xml

+ 383 - 0
lb-app/src/main/java/com/ydd/app/ShopEntityUtils.java

@@ -4,6 +4,7 @@ import com.ydd.common.enums.DeliveryTypeEnums;
 import com.ydd.module.domain.DspDelivery;
 import com.ydd.module.domain.Merchant;
 import com.ydd.module.domain.Shop;
+import com.ydd.module.domain.ShopDeliveryConfig;
 import com.ydd.third.common.vo.shop.ShopVo;
 
 import java.math.BigDecimal;
@@ -399,4 +400,386 @@ public class ShopEntityUtils {
         }
         return shopVo;
     }
+
+    public static ShopVo createShopVoNew(Shop shop, ShopDeliveryConfig delivery, Merchant merchant) {
+        ShopVo shopVo = new ShopVo();
+        if (DeliveryTypeEnums.DADA.getType().equals(delivery.getType())) {
+            shopVo.setLbClient(DeliveryTypeEnums.DADA.getName());
+            /**
+             * 门店名称
+             * 达达:station_name,门店名称,必传
+             * */
+            shopVo.setShopName(shop.getName());
+            /**
+             * 业务类型
+             * 达达:business,必传,业务类型
+             * (食品小吃-1,饮料-2,鲜花-3,文印票务-8,便利店-9,水果生鲜-13,同城电商-19, 医药-20,蛋糕-21,酒品-24,小商品市场-25,服装-26,汽修零配-27,
+             * 数码-28,小龙虾-29,火锅-51,其他-5)
+             */
+            shopVo.setBusiness(merchant.getDdCcategory());
+            /**
+             * 城市名称
+             * 达达:city_name 必传,城市名称(如,上海)
+             */
+            shopVo.setCityName(shop.getCityName());
+            /**
+             * 区域名称
+             * 达达:area_name 必传,	区域名称(如,浦东新区)
+             */
+            shopVo.setAreaName(shop.getDistrictName());
+            /**
+             * 门店地址
+             * 达达:station_address 必传,门店地址
+             */
+            shopVo.setShopAddress(shop.getAddress());
+            /**
+             *门店经度
+             * 达达:lng 必传,门店经度,店铺经度
+             */
+            shopVo.setShopLng(new BigDecimal(shop.getLng()));
+            /**
+             * 门店纬度
+             * 达达:lat 必传,门店纬度
+             */
+            shopVo.setShopLat(new BigDecimal(shop.getLat()));
+            /**
+             * 联系人姓名
+             * 达达:contact_name 必传 联系人姓名
+             */
+            shopVo.setContactName(shop.getContactName());
+            /**
+             * 联系人电话
+             * 达达:phone 必传,联系人电话
+             */
+            shopVo.setContactPhone(shop.getMobile());
+
+        } else if (DeliveryTypeEnums.DADA_YZ.getType().equals(delivery.getType())) {
+            shopVo.setLbClient(DeliveryTypeEnums.DADA_YZ.getName());
+            /**
+             * 门店名称
+             * 达达:station_name,门店名称,必传
+             * */
+            shopVo.setShopName(shop.getName());
+            /**
+             * 业务类型
+             * 达达:business,必传,业务类型
+             * (食品小吃-1,饮料-2,鲜花-3,文印票务-8,便利店-9,水果生鲜-13,同城电商-19, 医药-20,蛋糕-21,酒品-24,小商品市场-25,服装-26,汽修零配-27,
+             * 数码-28,小龙虾-29,火锅-51,其他-5)
+             */
+            shopVo.setBusiness(merchant.getDdCcategory());
+            /**
+             * 城市名称
+             * 达达:city_name 必传,城市名称(如,上海)
+             */
+            shopVo.setCityName(shop.getCityName());
+            /**
+             * 区域名称
+             * 达达:area_name 必传,	区域名称(如,浦东新区)
+             */
+            shopVo.setAreaName(shop.getDistrictName());
+            /**
+             * 门店地址
+             * 达达:station_address 必传,门店地址
+             */
+            shopVo.setShopAddress(shop.getAddress());
+            /**
+             *门店经度
+             * 达达:lng 必传,门店经度,店铺经度
+             */
+            shopVo.setShopLng(new BigDecimal(shop.getLng()));
+            /**
+             * 门店纬度
+             * 达达:lat 必传,门店纬度
+             */
+            shopVo.setShopLat(new BigDecimal(shop.getLat()));
+            /**
+             * 联系人姓名
+             * 达达:contact_name 必传 联系人姓名
+             */
+            shopVo.setContactName(shop.getContactName());
+            /**
+             * 联系人电话
+             * 达达:phone 必传,联系人电话
+             */
+            shopVo.setContactPhone(shop.getMobile());
+
+        } else if (DeliveryTypeEnums.SHAN_SONG.getType().equals(delivery.getType())) {
+            shopVo.setLbClient(DeliveryTypeEnums.SHAN_SONG.getName());
+
+            /**
+             * 门店名称
+             * 闪送:storeName门店名称,店铺名称
+             * */
+            shopVo.setShopName(shop.getName());
+
+            /**
+             * 业务类型
+             * 闪送:goodType,必传,店铺业务类型
+             * 1-文件广告	3-电子产品 5-蛋糕	6-快餐水果 7-鲜花绿植 8-海鲜水产	9-汽车配件 10-其他 11-宠物	12-母婴	13-医药健康 14-教育
+             */
+            shopVo.setBusiness(merchant.getSsProductType());
+            /**
+             * 城市名称
+             * 闪送:cityName 必传,城市名称(如,上海)
+             */
+            shopVo.setCityName(shop.getCityName());
+
+            /**
+             * 店铺地址
+             * 闪送:address 必传,店铺地址
+             */
+            shopVo.setShopAddress(shop.getAddress());
+
+            /**
+             * 详细地址
+             * 闪送:addressDetail,门牌号
+             */
+            shopVo.setShopAddressDetail(shop.getStreet());
+
+            /**
+             *门店经度
+             * 闪送:longitude必传,店铺经度
+             */
+            shopVo.setShopLng(new BigDecimal(shop.getLng()));
+            /**
+             * 门店纬度
+             * 达达:latitude  必传,店铺纬度
+             */
+            shopVo.setShopLat(new BigDecimal(shop.getLat()));
+
+            /**
+             * 联系人电话
+             * 达达:phone 必传,店铺联系人手机号/座机
+             */
+            shopVo.setContactPhone(shop.getMobile());
+
+            /**
+             * 1.保存 2.更新,默认为1
+             */
+            shopVo.setOperationType(1);
+        } else if (DeliveryTypeEnums.SHUN_FENG.getType().equals(delivery.getType())) {
+            shopVo.setLbClient(DeliveryTypeEnums.SHUN_FENG.getName());
+
+        } else if (DeliveryTypeEnums.MEI_TUAN_ZB.getType().equals(delivery.getType())) {
+            shopVo.setLbClient(DeliveryTypeEnums.MEI_TUAN_ZB.getName());
+
+        } else if (DeliveryTypeEnums.UUPT.getType().equals(delivery.getType())) {
+            shopVo.setLbClient(DeliveryTypeEnums.UUPT.getName());
+
+        } else if (DeliveryTypeEnums.KUAI_FU.getType().equals(delivery.getType())) {
+            shopVo.setLbClient(DeliveryTypeEnums.KUAI_FU.getName());
+
+        } else if (DeliveryTypeEnums.HUO_LA_LA.getType().equals(delivery.getType())) {
+            shopVo.setLbClient(DeliveryTypeEnums.HUO_LA_LA.getName());
+
+        } else if (DeliveryTypeEnums.DWD.getType().equals(delivery.getType())) {
+            shopVo.setLbClient(DeliveryTypeEnums.DWD.getName());
+
+        } else if (DeliveryTypeEnums.FENG_NIAO.getType().equals(delivery.getType())) {
+            shopVo.setLbClient(DeliveryTypeEnums.FENG_NIAO.getName());
+            /**
+             * 蜂鸟V3
+             * 蜂鸟V3:branch_shop_name 必传 门店分店名
+             */
+            shopVo.setHeadShopName(shop.getName());
+            /**
+             * 蜂鸟V3
+             * 蜂鸟V3:branch_shop_name 必传 门店分店名
+             */
+            shopVo.setBranchShopName(shop.getName());
+            /**
+             * 蜂鸟V3
+             * 外部门店编码
+             * 蜂鸟V3:out_shop_code  必传 外部门店编码
+             */
+            shopVo.setOutShopCode(shop.getCode());
+            /**
+             * 蜂鸟,蜂鸟V3
+             * 门店类型
+             * 蜂鸟V3 chainstore_type 不必传, 1为正式门店,2为测试门店 不传时默认为1
+             */
+            shopVo.setShopType(1);
+
+            /**
+             * 品类
+             * 蜂鸟V3
+             * 蜂鸟V3:category_id 必传 门店类目 按二级类目表编码传入,二级类目表编码附表后
+             */
+            shopVo.setCategory(Integer.parseInt(merchant.getCategoryName()));
+
+
+            /**
+             * 门店地址
+             * 蜂鸟V3:address 必传,门店地址
+             */
+            shopVo.setShopAddress(shop.getAddress()+shop.getStreet());
+            /**
+             *门店经度
+             * 蜂鸟V3:longitude 必传,门店经度
+             *
+             */
+            shopVo.setShopLng(new BigDecimal(shop.getLng()));
+            /**
+             * 门店纬度
+             * 蜂鸟V3:latitude,必传,门店纬度
+             */
+            shopVo.setShopLat(new BigDecimal(shop.getLat()));
+            /**
+             * 联系人姓名
+             * 蜂鸟V3: owner_name 必传 门店拥有人姓名
+             */
+            shopVo.setContactName("殷宝珠");
+            /**
+             * 联系人电话
+             * 蜂鸟V3:contact_phone 必传,门店联系方式
+             */
+            shopVo.setContactPhone(shop.getMobile());
+            /**
+             * 蜂鸟V3
+             * 门店拥有人身份证号
+             * 蜂鸟V3:owner_id_num 必传 门店拥有人身份证号
+             */
+            shopVo.setOwnerIdNum("34252919570501502X");
+            /**
+             * 蜂鸟V3
+             * 身份证正面
+             * 蜂鸟V3:owner_id_pic_front_hash 必传 身份证正面,调用图片上传接口后返回的id
+             */
+            shopVo.setOwnerIdPicFrontHash("https://ecloud-cdn.51sssd.com/20210604/364b8355956740a281f676221d1a7a9b.jpg");
+            /**
+             * 蜂鸟V3
+             * 门店拥有人手持身份证、营业执照图片
+             * 蜂鸟V3:handheld_licence_pic_hash 门店拥有人手持身份证、营业执照图片
+             * 调用图片上传接口后返回的id
+             */
+            shopVo.setHandheldLicencePicHash("https://ecloud-cdn.51sssd.com/20210604/364b8355956740a281f676221d1a7a9b.jpg");
+            /**
+             * 蜂鸟V3
+             * 身份证反面
+             * 蜂鸟V3:owner_id_pic_back_hash 必传 身份证反面,调用图片上传接口后返回的id
+             */
+            shopVo.setOwnerIdPicBackHash("https://ecloud-cdn.51sssd.com/20210604/364b8355956740a281f676221d1a7a9b.jpg");
+            /**
+             * 蜂鸟V3
+             * 统一社会信用代码
+             * 蜂鸟V3 credit_code 必传  统一社会信用代码
+             */
+            shopVo.setCreditCode("91320505MA22564J7P");
+            /**
+             * 蜂鸟V3
+             * 营业执照图片
+             * 蜂鸟V3 business_licence_pic_hash 必传 营业执照图片 调用图片上传接口后返回的id
+             */
+            shopVo.setBusinessLicencePicHash("https://ecloud-cdn.51sssd.com/20210604/364b8355956740a281f676221d1a7a9b.jpg");
+
+            /**
+             * 蜂鸟V3,
+             * 商户ID
+             */
+            shopVo.setMerchantId(delivery.getShopId()); //"3640883");
+
+            /**
+             * 闪送,蜂鸟V3
+             * 商户Token
+             */
+            shopVo.setAccessToken(delivery.getAuthToken());
+            /**
+             * 经营类目需要食品经营许可的必传
+             */
+            shopVo.setFoodLicensePicHash("https://ecloud-cdn.51sssd.com/20210604/364b8355956740a281f676221d1a7a9b.jpg");
+
+        } else if (DeliveryTypeEnums.MEI_TUAN.getType().equals(delivery.getType())){
+            shopVo.setLbClient(DeliveryTypeEnums.MEI_TUAN.getName());
+
+            /**
+             * 门店编码
+             * 美团
+             * 美团:shop_id,必传,取货门店id,即合作方向美团提供的门店id
+             */
+            shopVo.setShopId(shop.getCode());
+
+            /**
+             * 门店名称
+             * 美团
+             * 美团:shop_name 必传,门店名称 说明:门店名称格式请按照 【XX品牌-XX店】填写,例:百果园-望京店,注:该名称需与实体门店门牌保持一致,保证骑手取货可确认门店
+             * 蜂鸟:chain_store_name 必传,门店名称(支持汉字、符号、字母的组合),门店名称重复时,请确保推单时带入合法且唯一的门店编码,否则将订单推送失败,蜂鸟配送开放平台无责。测试门店名称必须含有“测试”或“test”文字,正式门店名称不得含有“测试”或“test”文字!否则影响结算!
+             */
+            shopVo.setShopName(shop.getName());
+
+            /**
+             * 一级品类
+             * 美团
+             * 美团:category,必传,一级品类,见附件品类代码表 说明:品类需按门店真实配送品类选择
+             *
+             */
+            String[] categorys = merchant.getMtCcategoryName().split(",");
+            shopVo.setCategory(Integer.parseInt(categorys[0]));
+
+            /**
+             * 二级品类
+             * 美团
+             * 美团:second_category,必传,二级品类,见附件品类代码表 说明:品类需按门店真实配送品类选择
+             */
+            shopVo.setSecondCategory(Integer.parseInt(categorys[1]));
+
+            /**
+             * 联系人姓名
+             * 美团
+             * 美团:contact_name 必传,门店联系人姓名
+             */
+            shopVo.setContactName(shop.getContactName());
+
+            /**
+             * 联系人电话
+             * 美团
+             * 美团:contact_phone 必传,联系电话
+             */
+            shopVo.setContactPhone(shop.getMobile());
+
+            /**
+             * 门店地址
+             * 美团,蜂
+             * 美团:shop_address,必传,门店地址
+             */
+            shopVo.setShopAddress(shop.getAddress()+shop.getStreet());
+
+            /**
+             * 详细地址
+             * 美团
+             * 美团:shop_address_detail,不必传,门牌号
+             */
+//            shopVo.setShopAddressDetail("");
+
+            /**
+             *门店经度
+             * 美团
+             * 美团:shop_lng,必传,门店经度(高德),
+             */
+            shopVo.setShopLng(new BigDecimal(shop.getLng()));
+
+            /**
+             * 门店纬度
+             * 美团
+             * 美团:shop_lat,必传,门店纬度(高德)
+             */
+            shopVo.setShopLat(new BigDecimal(shop.getLat()));
+
+            /**
+             * 配送服务代码
+             * 美团
+             * 美团:delivery_service_codes 必传
+             * 配送服务代码,详情见合同 1)服务包 飞速达:4002 快速达:4011 及时达:4012 集中送:4013 跑腿B帮送:4031 例如:4011,4012(多个英文逗号隔开) 2)新服务产品 具体可参考新服务产品列表。(多个英文逗号隔开)
+             * 默认光速达 光速达-45-> 100001,光速达-40->100000,光速达-50->100002,光速达-55->100003
+             */
+            shopVo.setDeliveryServiceCodes("100004");// 等确认后再改
+
+            /**
+             * 营业时间
+             * 美团
+             * 美团:营业时间 例:[{"beginTime":"00:00","endTime":"24:00"}] 注:传入后美团根据区域可配送时间取交集时间作为门店配送时间
+             */
+            shopVo.setBusinessHours("[{\"beginTime\":\"00:00\",\"endTime\":\"24:00\"}]");
+        }
+        return shopVo;
+    }
 }

+ 10 - 4
lb-app/src/main/java/com/ydd/app/controller/ShopApi.java

@@ -2,6 +2,7 @@ package com.ydd.app.controller;
 
 import com.alibaba.fastjson.JSONObject;
 import com.ydd.app.dto.ShopReq;
+import com.ydd.app.service.ApiShopNewService;
 import com.ydd.app.service.ApiShopService;
 import com.ydd.common.annotation.AccessToken;
 import com.ydd.common.annotation.ControllerLog;
@@ -40,6 +41,8 @@ public class ShopApi extends BaseController {
 
     private final ApiShopService apiShopService;
 
+    private final ApiShopNewService apiShopNewService;
+
     /**
      * 门店列表
      */
@@ -70,7 +73,8 @@ public class ShopApi extends BaseController {
     @AccessToken
     public BaseResult saveShop(ShopReq shop) {
         logger.info("创建门店参数---"+JSONObject.toJSONString(shop));
-        Shop shop1 = apiShopService.saveShop(getLoginId(), shop,false);
+        // Shop shop1 = apiShopService.saveShop(getLoginId(), shop,false);
+        Shop shop1 = apiShopNewService.saveShop(getLoginId(), shop,false);
         return BaseResult.success(shop1);
     }
 
@@ -95,7 +99,8 @@ public class ShopApi extends BaseController {
     @AccessToken
     public BaseResult modify(ShopReq shopReq) {
         logger.info("-----更新门店资料-提交数据----"+ JSONObject.toJSONString(shopReq));
-        apiShopService.modify(getLoginId(), shopReq);
+        // apiShopService.modify(getLoginId(), shopReq);
+        apiShopNewService.modify(getLoginId(), shopReq);
         return BaseResult.success();
     }
 
@@ -124,8 +129,9 @@ public class ShopApi extends BaseController {
     })
     @RequestMapping(value = "/delete", method = RequestMethod.POST)
     @AccessToken
-    public BaseResult delete(@RequestParam("shopId") Integer shopId) {
-        apiShopService.delete(getLoginId(), shopId);
+    public BaseResult delete(@RequestParam("shopId") Long shopId) {
+        // apiShopService.delete(getLoginId(), shopId);
+        apiShopNewService.delete(getLoginId(), shopId);
         return BaseResult.success();
     }
 

+ 8 - 0
lb-app/src/main/java/com/ydd/app/dto/ShopReq.java

@@ -123,4 +123,12 @@ public class ShopReq implements Serializable {
     /** 食品经营许可 */
     @ApiModelProperty(value = "门店分类ID")
     private Long categoryId;
+
+    /** 门牌号 */
+    @ApiModelProperty(value = "门牌号")
+    private String houseNo;
+
+    /** POI */
+    @ApiModelProperty(value = "POI")
+    private String poi;
 }

+ 42 - 0
lb-app/src/main/java/com/ydd/app/service/ApiShopNewService.java

@@ -0,0 +1,42 @@
+package com.ydd.app.service;
+
+import com.ydd.app.dto.ShopReq;
+import com.ydd.module.domain.DspDelivery;
+import com.ydd.module.domain.Shop;
+import com.ydd.module.domain.ShopDeliveryConfig;
+import com.ydd.third.common.config.DeliveryConfig;
+
+/**
+ * Demo class
+ *
+ * @author 14027
+ * @date 2021/11/30 14:33
+ */
+public interface ApiShopNewService {
+
+    /**
+     * 新增门店
+     * @param loginId
+     * @param shop
+     * @param isMerchant true是商家,false是门店
+     */
+    Shop saveShop(Long loginId, ShopReq shop, boolean isMerchant);
+
+    Integer getFengniaoShopStatusNew(Shop shop, ShopDeliveryConfig d);
+
+    Integer getFengniaoShopStatus(Shop shop, DspDelivery d);
+
+    /**
+     * 删除门店
+     * @param loginId
+     * @param shopId
+     */
+    void delete(Long loginId, Long shopId);
+
+    /**
+     * 更新门店信息
+     * @param loginId
+     * @param shopReq
+     */
+    void modify(Long loginId, ShopReq shopReq);
+}

+ 31 - 1
lb-app/src/main/java/com/ydd/app/service/impl/ApiOrderDetailServiceImpl.java

@@ -6,6 +6,7 @@ import com.ydd.app.service.ApiOrderDetailService;
 import com.ydd.app.service.ApiRiderLocationService;
 import com.ydd.common.enums.DeliveryTypeEnums;
 import com.ydd.module.domain.*;
+import com.ydd.module.dto.MemberConfigDto;
 import com.ydd.module.dto.OrderDto;
 import com.ydd.module.enums.DeliveryStatusEnum;
 import com.ydd.module.expection.CustomAppException;
@@ -13,12 +14,16 @@ import com.ydd.module.service.*;
 import com.ydd.third.common.utils.AddressLngLatExchanger;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.compress.utils.Lists;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 /**
  * Project:lb-server
@@ -47,6 +52,9 @@ public class ApiOrderDetailServiceImpl implements ApiOrderDetailService {
     private final IOrderDeliveryService iOrderDeliveryService;
     private final ApiRiderLocationService apiRiderLocationService;
 
+    private final IMemberConfigService iMemberConfigService;
+    private final IWaimaiFoodImgService iWaimaiFoodImgService;
+
     @Override
     public List<Order> findList(List<Long> memberIds, Integer status, String searchKey, Integer shopId,String startDate,String endDate) {
         List<Order> list = iOrderService.findList(memberIds, status, searchKey,shopId,startDate,endDate);
@@ -151,8 +159,30 @@ public class ApiOrderDetailServiceImpl implements ApiOrderDetailService {
             dto.setWaimaiLogo(waimai.getLogo());
             dto.setOutOrderId(waimaiOrder.getOutOrderId());
             dto.setOrderType(waimaiOrder.getOrderType());
-        //    dto.setWaimaiOrderDetails(details);
+            List<OrderDto.OrderDetailItem> orderDetailItems = Lists.newArrayList();
+            if (!CollectionUtils.isEmpty(details)) {
+                MemberConfigDto memberConfig = iMemberConfigService.findDetail(loginId);
+                boolean showFoodImg = memberConfig == null || memberConfig.getShowFoodImg() == 1;
+                orderDetailItems = details.stream().map(waimaiDetail -> {
+                    OrderDto.OrderDetailItem orderDetailItem = new OrderDto.OrderDetailItem();
+                    orderDetailItem.setFoodName(waimaiDetail.getFoodName());
+                    orderDetailItem.setQuantity(waimaiDetail.getQuantity());
+                    orderDetailItem.setPrice(waimaiDetail.getPrice());
+                    if (showFoodImg) {
+                        WaimaiFoodImg waimaiFoodImg = iWaimaiFoodImgService.getOne(new QueryWrapper<WaimaiFoodImg>()
+                                .eq("sku_id", waimaiDetail.getSkuId())
+                                .eq("waimai_id", waimaiOrder.getWaimaiId())
+                                .eq("shop_id", order.getShopId())
+                                .eq("deleted", 0));
+                        orderDetailItem.setFoodPic(Objects.isNull(waimaiFoodImg) ? "" : waimaiFoodImg.getImg());
+                    }
+                    return orderDetailItem;
+                }).collect(Collectors.toList());
+            }
             dto.setList(details);
+            dto.setProductAmount(waimaiOrder.getTotalPrice());
+            dto.setWaimaiList(orderDetailItems);
+            dto.setTotalQuantity(orderDetailItems.stream().mapToLong(OrderDto.OrderDetailItem::getQuantity).sum());
             dto.setWmstatus(waimaiOrder.getStatus());
             dto.setExceptTime(waimaiOrder.getDeliveryTime());
             dto.setOrderTime(waimaiOrder.getOrderTime());

+ 59 - 49
lb-app/src/main/java/com/ydd/app/service/impl/ApiOrderValuationServiceImpl.java

@@ -88,6 +88,7 @@ public class ApiOrderValuationServiceImpl implements ApiOrderValuationService {
     public ValuationRes orderValuation(Member member, OrderReq orderReq, Integer type) {
         log.info("<===========>订单计价参数: loginId:{}, type: {}, orderReq: {} ", member.getId(), type, JsonMapper.nonEmptyMapper().toJson(orderReq));
         try {
+            Member loginMember = member;
             if (member.getMemberType().equals(MemberTypeEnum.SHOP.type)) {
                 member = iMemberService.getOne(new QueryWrapper<Member>().eq("member_type", MemberTypeEnum.MERCHANT.type).eq("merchant_id", member.getMerchantId()));
             }
@@ -105,6 +106,7 @@ public class ApiOrderValuationServiceImpl implements ApiOrderValuationService {
             Integer defaultShop = 0;
             orderReq.setOrderNo(SnCodeUtils.createSn());
             if (orderReq.getOrderId() != null) {
+                orderReq.setShopId(null);
                 Order order = iOrderService.getById(orderReq.getOrderId());
                 orderReq.setWaimaiOrderId(order.getWaimaiOrderId());
                 if (order.getDeliveryStatus() >= DeliveryStatusEnum.ORDERS_TO_BE_RECEIVED.status && !DeliveryStatusEnum.FINISH.status.equals(order.getDeliveryStatus())) {
@@ -120,13 +122,11 @@ public class ApiOrderValuationServiceImpl implements ApiOrderValuationService {
                 shopId = order.getShopId();
                 takeRemark = order.getTakeRemark();
             }
-            if(member.getShopId() != null && shopId == null){
-                Shop shop = iShopService.getById(member.getShopId());
+            if(loginMember.getShopId() != null && orderReq.getShopId() == null) {
+                Shop shop = iShopService.getById(loginMember.getShopId());
                 double distance = CoordinateUtils.getDistance(Double.parseDouble(sendAddress.getLng()), Double.parseDouble(sendAddress.getLat()), Double.parseDouble(shop.getLng()), Double.parseDouble(shop.getLat()));
-                if (distance > BillingConstant.SHOP_BILLING_DISTANCE) { //暂定小于百米 是门店发单
+                if (distance > BillingConstant.SHOP_BILLING_DISTANCE) { //暂定小于百米 是门店发单
                     defaultShop = 1;
-                } else {
-                    shopId = member.getShopId();
                 }
             }
 
@@ -145,8 +145,11 @@ public class ApiOrderValuationServiceImpl implements ApiOrderValuationService {
             List<ValuationRes> list = new ArrayList<>();
             List<ValuationRes> supports = new ArrayList<>();
 
+            // 门店用户使用首页个人发单, 则使用用户默认的shopId进行包查询
+            Long packageShopId = shopId == null ? loginMember.getShopId() : shopId;
+
             // 获取最匹配的运力包(门店 > 城市 > 全国)
-            Long deliveryPackageId = iPackageCityConfigService.getPackageId(shopId, member.getAgentId(), orderReq.getSendAddress().getCityCode(), PackageCityConfigPackageTypeEnum.DELIVERY.type);
+            Long deliveryPackageId = iPackageCityConfigService.getPackageId(packageShopId, loginMember, orderReq.getSendAddress().getCityCode(), PackageCityConfigPackageTypeEnum.DELIVERY.type);
             List<Integer> types = Lists.newArrayList();
             PackageDeliveryDto packageDeliveryDto = null;
             if (deliveryPackageId != null) {
@@ -168,20 +171,20 @@ public class ApiOrderValuationServiceImpl implements ApiOrderValuationService {
 
             List<Integer> deliveryTypes = deliveryInfos.stream().map(DspDelivery::getType).collect(Collectors.toList());
             // 获取最匹配的优惠包(门店 > 代理商 > 全国)
-            Long discountPackageId = iPackageCityConfigService.getPackageId(shopId, member.getAgentId(), orderReq.getSendAddress().getCityCode(), PackageCityConfigPackageTypeEnum.DISCOUNT.type);
+            Long discountPackageId = iPackageCityConfigService.getPackageId(packageShopId, loginMember, orderReq.getSendAddress().getCityCode(), PackageCityConfigPackageTypeEnum.DISCOUNT.type);
             Map<Integer, List<PackageDiscountDetailDto>> packageDiscountMap = new HashMap<>();
             if (discountPackageId != null) {
                 List<PackageDiscountDetailDto> discountDetailDtoList = iPackageDiscountDetailService.getDiscountListByPackageIdAndDeliveryType(discountPackageId, deliveryTypes);
                 packageDiscountMap = discountDetailDtoList.stream().collect(Collectors.groupingBy(PackageDiscountDetailDto::getDeliveryType));
             }
             // 获取最匹配的佣金包(门店 > 代理商 > 全国)
-            Long commissionPackageId = iPackageCityConfigService.getPackageId(shopId, member.getAgentId(), orderReq.getSendAddress().getCityCode(), PackageCityConfigPackageTypeEnum.COMMISSION.type);
+            Long commissionPackageId = iPackageCityConfigService.getPackageId(packageShopId, loginMember, orderReq.getSendAddress().getCityCode(), PackageCityConfigPackageTypeEnum.COMMISSION.type);
             Map<Integer, List<PackageCommissionDetailDto>> packageCommissionMap = new HashMap<>();
             if (commissionPackageId != null) {
                 List<PackageCommissionDetailDto> commissionDetailDtoList = iPackageCommissionDetailService.getCommissionListByPackageIdAndDeliveryType(commissionPackageId, deliveryTypes);
                 packageCommissionMap = commissionDetailDtoList.stream().collect(Collectors.groupingBy(PackageCommissionDetailDto::getDeliveryType));
             }
-
+            log.info("运力包: {}, 优惠包:{}, 佣金包: {}", deliveryPackageId, discountPackageId, commissionPackageId);
             for (DeliveryInfo info : deliveryInfos) {
                 // 计价
                 ValuationRes valuationRes = this.queryOrderDeliverFee(orderReq, info, member.getMerchantId(), shopId, defaultShop);
@@ -213,19 +216,16 @@ public class ApiOrderValuationServiceImpl implements ApiOrderValuationService {
             }
 
             // 默认价格优先
-            list.sort((o1, o2) -> {
-                BigDecimal i = o1.getDeliveryAmount().subtract(o2.getDeliveryAmount());
-                return i.intValue();
-            });
+            list.sort(Comparator.comparing(ValuationRes::getDeliveryAmount));
             // Res数据组装
-            this.setValuationRes(list, res, member);
+            this.setValuationRes(list, res, loginMember);
             // 运力包发单类型为自定义, 则先按照sort排,再按价格排
             if (packageDeliveryDto != null && PackageDeliveryTypeEnum.CUSTOM.type.equals(packageDeliveryDto.getType())) {
                 Collections.sort(list);
             }
 
             // 处理发单运力
-            List<ValuationRes> billList = this.handleBillList(type, member.getId(), list);
+            List<ValuationRes> billList = this.handleBillList(loginMember.getId(), list);
             // 设置发单时长
             if (packageDeliveryDto != null) {
                 billList = this.setBillingDuration(packageDeliveryDto, billList);
@@ -239,22 +239,20 @@ public class ApiOrderValuationServiceImpl implements ApiOrderValuationService {
         }
     }
 
-    private List<ValuationRes> handleBillList(Integer type, Long loginId, List<ValuationRes> list) {
+    private List<ValuationRes> handleBillList(Long loginId, List<ValuationRes> list) {
         // 查询下单设置推荐屏蔽运力
         List<ValuationRes> billList = new ArrayList<>();
-        if (type == 1) {
-            MemberConfig config = iMemberConfigService.getOne(new QueryWrapper<MemberConfig>().eq("member_id",loginId));
-            if (config != null) {
-                if (StringUtils.isNotEmpty(config.getBillDeliveryIds())) {
-                    List<String> billDeliveryIds = Arrays.asList(config.getBillDeliveryIds().split(","));
-                    // 过滤出商家设置的推荐运力, 计价页面靠前显示
-                    billList = list.stream().filter(a -> billDeliveryIds.contains(a.getDeliveryId().toString())).collect(Collectors.toList());
-                }
-                if (StringUtils.isNotEmpty(config.getShieldDeliveryIds())) {
-                    List<String> shieldDeliveryIds = Arrays.asList(config.getShieldDeliveryIds().split(","));
-                    // 过滤掉商家设置的屏蔽运力
-                    list = list.stream().filter(a -> !shieldDeliveryIds.contains(a.getDeliveryId().toString())).collect(Collectors.toList());
-                }
+        MemberConfig config = iMemberConfigService.getOne(new QueryWrapper<MemberConfig>().eq("member_id",loginId));
+        if (config != null) {
+            if (StringUtils.isNotEmpty(config.getBillDeliveryIds())) {
+                List<String> billDeliveryIds = Arrays.asList(config.getBillDeliveryIds().split(","));
+                // 过滤出商家设置的推荐运力, 计价页面靠前显示
+                billList = list.stream().filter(a -> billDeliveryIds.contains(a.getDeliveryId().toString())).collect(Collectors.toList());
+            }
+            if (StringUtils.isNotEmpty(config.getShieldDeliveryIds())) {
+                List<String> shieldDeliveryIds = Arrays.asList(config.getShieldDeliveryIds().split(","));
+                // 过滤掉商家设置的屏蔽运力
+                list = list.stream().filter(a -> !shieldDeliveryIds.contains(a.getDeliveryId().toString())).collect(Collectors.toList());
             }
         }
         list.removeAll(billList);
@@ -274,7 +272,7 @@ public class ApiOrderValuationServiceImpl implements ApiOrderValuationService {
         return billList;
     }
 
-    private void setValuationRes(List<ValuationRes> list, ValuationRes res, Member member) {
+    private void setValuationRes(List<ValuationRes> list, ValuationRes res, Member loginMember) {
         // 获取聚合配送的预估价,选最低价格展示
         if (CollectionUtils.isNotEmpty(list)) {
             res.setDeliveryId(list.get(0).getDeliveryId());
@@ -286,10 +284,10 @@ public class ApiOrderValuationServiceImpl implements ApiOrderValuationService {
         }
         // 新用户只要没有产生支付成功的订单数据 算首单
         int successOrderCount;
-        if (member.getShopId() != null) {
-            successOrderCount = iOrderService.count(new QueryWrapper<Order>().eq("shop_id", member.getShopId()).eq("status", PayStatusEnum.PAYED.status));
+        if (loginMember.getShopId() != null) {
+            successOrderCount = iOrderService.count(new QueryWrapper<Order>().eq("shop_id", loginMember.getShopId()).eq("status", PayStatusEnum.PAYED.status));
         } else {
-            successOrderCount = iOrderService.count(new QueryWrapper<Order>().eq("member_id", member.getId()).eq("status", PayStatusEnum.PAYED.status));
+            successOrderCount = iOrderService.count(new QueryWrapper<Order>().eq("member_id", loginMember.getId()).eq("status", PayStatusEnum.PAYED.status));
         }
         if (successOrderCount == 0) {
             String configValue = iSysConfigService.selectConfigByKey("NEW_COMERS");
@@ -311,24 +309,35 @@ public class ApiOrderValuationServiceImpl implements ApiOrderValuationService {
     private List<ValuationRes> setBillingDuration(PackageDeliveryDto packageDeliveryDto, List<ValuationRes> billList) {
         String billDurationStr = packageDeliveryDto.getBillDurationStr();
         List<PackageDeliveryDetailDto> deliveryDetailList = packageDeliveryDto.getPackageDeliveryDetailDtoList();
-        if (PackageDeliveryBillDurationTypeEnum.CUSTOM.type.equals(packageDeliveryDto.getBillDurationType()) && StringUtils.isNotEmpty(billDurationStr) && CollectionUtils.isNotEmpty(deliveryDetailList)) {
-            deliveryDetailList = deliveryDetailList.stream().filter(item -> item.getSort() != null && item.getSort() > 0).collect(Collectors.toList());
-            deliveryDetailList.sort(Comparator.comparing(PackageDeliveryDetailDto::getSort));
+        if (StringUtils.isNotEmpty(billDurationStr) && CollectionUtils.isNotEmpty(deliveryDetailList)) {
             String[] split = billDurationStr.split(",");
-            for (int i = 0; i < deliveryDetailList.size(); i++) {
-                PackageDeliveryDetailDto packageDeliveryDetailDto = deliveryDetailList.get(i);
-                if (i < split.length) {
-                    packageDeliveryDetailDto.setBillDuration(Integer.parseInt(split[i]));
+            if (PackageDeliveryTypeEnum.CUSTOM.type.equals(packageDeliveryDto.getType())) {
+                deliveryDetailList = deliveryDetailList.stream().filter(item -> item.getSort() != null && item.getSort() > 0).collect(Collectors.toList());
+                deliveryDetailList.sort(Comparator.comparing(PackageDeliveryDetailDto::getSort));
+                for (int i = 0; i < deliveryDetailList.size(); i++) {
+                    PackageDeliveryDetailDto packageDeliveryDetailDto = deliveryDetailList.get(i);
+                    if (i < split.length) {
+                        packageDeliveryDetailDto.setBillDuration(Integer.parseInt(split[i]));
+                    }
                 }
-            }
-            for (ValuationRes valuationRes : billList) {
-                int billDuration = BillingConstant.DEFAULT_BILL_DURATION;
-                Optional<PackageDeliveryDetailDto> optional = deliveryDetailList.stream().filter(item -> item.getDeliveryType().equals(valuationRes.getDeliveryType())).findAny();
-                if (optional.isPresent()) {
-                    PackageDeliveryDetailDto packageDeliveryDetailDto = optional.get();
-                    billDuration = packageDeliveryDetailDto.getBillDuration();
+                for (ValuationRes valuationRes : billList) {
+                    int billDuration = BillingConstant.DEFAULT_BILL_DURATION;
+                    Optional<PackageDeliveryDetailDto> optional = deliveryDetailList.stream().filter(item -> item.getDeliveryType().equals(valuationRes.getDeliveryType())).findAny();
+                    if (optional.isPresent()) {
+                        PackageDeliveryDetailDto packageDeliveryDetailDto = optional.get();
+                        billDuration = packageDeliveryDetailDto.getBillDuration();
+                    }
+                    valuationRes.setBillDuration(billDuration == 0 ? BillingConstant.DEFAULT_BILL_DURATION : billDuration);
+                }
+            } else {
+                for (int i = 0; i < billList.size(); i++) {
+                    ValuationRes valuationRes = billList.get(i);
+                    int billDuration = BillingConstant.DEFAULT_BILL_DURATION;
+                    if (i < split.length) {
+                        billDuration = Integer.parseInt(split[i]);
+                    }
+                    valuationRes.setBillDuration(billDuration);
                 }
-                valuationRes.setBillDuration(billDuration == 0 ? BillingConstant.DEFAULT_BILL_DURATION : billDuration);
             }
         } else {
             billList = billList.stream().map(valuationRes -> valuationRes.setBillDuration(BillingConstant.DEFAULT_BILL_DURATION)).collect(Collectors.toList());
@@ -393,7 +402,8 @@ public class ApiOrderValuationServiceImpl implements ApiOrderValuationService {
                     boolean inRange = BigDecimalUtils.inRange(item.getLeftValue(), item.getRightValue(), valuationRes.getDeliveryAmount());
                     if (inRange) {
                         if (item.getValue() != null) {
-                            valuationRes.setDeliveryAmount(valuationRes.getDeliveryAmount().subtract(item.getValue()));
+                            BigDecimal discountAmount = valuationRes.getDeliveryAmount().subtract(item.getValue());
+                            valuationRes.setDeliveryAmount(discountAmount.compareTo(BigDecimal.ZERO) > 0 ? discountAmount : BigDecimal.ZERO);
                             valuationRes.setMj(item.getValue());
                         }
                         break;

+ 484 - 0
lb-app/src/main/java/com/ydd/app/service/impl/ApiShopNewServiceImpl.java

@@ -0,0 +1,484 @@
+package com.ydd.app.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ydd.api.DeliveryService;
+import com.ydd.app.ShopEditUtils;
+import com.ydd.app.ShopEntityUtils;
+import com.ydd.app.dto.ShopReq;
+import com.ydd.app.service.ApiShopNewService;
+import com.ydd.app.service.ApiWaimaiService;
+import com.ydd.common.enums.DeliveryTypeEnums;
+import com.ydd.common.utils.SnCodeUtils;
+import com.ydd.common.utils.StringUtils;
+import com.ydd.ecloud.core.utils.JsonMapper;
+import com.ydd.module.domain.*;
+import com.ydd.module.dto.DeliveryConfigDto;
+import com.ydd.module.dto.ShopDto;
+import com.ydd.module.dto.WaimaiDto;
+import com.ydd.module.enums.*;
+import com.ydd.module.expection.CustomAppException;
+import com.ydd.module.service.*;
+import com.ydd.system.service.ISysConfigService;
+import com.ydd.third.common.vo.ResObject;
+import com.ydd.third.common.vo.shop.ShopQueryResultVo;
+import com.ydd.third.common.vo.shop.ShopQueryVo;
+import com.ydd.third.common.vo.shop.ShopResultVo;
+import com.ydd.third.common.vo.shop.ShopVo;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Demo class
+ *
+ * @author 14027
+ * @date 2021/11/30 14:34
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+public class ApiShopNewServiceImpl implements ApiShopNewService {
+
+    private final IMemberService iMemberService;
+
+    private final IShopService iShopService;
+
+    private final IMerchantService iMerchantService;
+
+    private final IShopDeliveryService iShopDeliveryService;
+
+    private final IDspDeliveryService iDspDeliveryService;
+
+    private final DeliveryService deliveryClient;
+    private final IShopThirdService iShopThirdService;
+
+    private final IMerchantCategoryService iMerchantCategoryService;
+
+    private final ISysConfigService iSysConfigService;
+
+    private final IShopWaimaiService iShopWaimaiService;
+
+    private final IShopUserService iShopUserService;
+
+    private final ApiWaimaiService apiWaimaiService;
+
+    private final IShopDeliveryConfigService iShopDeliveryConfigService;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Shop saveShop(Long loginId, ShopReq shopReq, boolean isMerchant) {
+        Member member = iMemberService.getById(loginId);
+
+        // 判断店铺名称是否重复
+        List<Shop> shops = iShopService.getShopByName(shopReq.getName(), null);
+        if (shops != null && shops.size() > 0) {
+            throw new CustomAppException("店铺名称重复!");
+        }
+
+        Long categoryId = null;
+        if (null != shopReq.getCategoryId()){
+            categoryId = shopReq.getCategoryId();
+        }
+        MerchantCategory category = iMerchantCategoryService.getById(categoryId);
+        if (category == null){
+            throw new CustomAppException("门店分类不存在!");
+        }
+
+        Merchant merchant = new Merchant();
+        // 第一个店铺新增的时候创建默认商家
+        if (member.getMerchantId() == null) {
+            merchant.setCode(SnCodeUtils.createMerchantSn());
+            merchant.setMerchantName(shopReq.getName());
+            if (member.getAgentId() != null){
+                merchant.setAgentId(member.getAgentId());
+            }
+            if (member.getPersonnelId() != null){
+                merchant.setPersonnelId(member.getPersonnelId());
+            }
+            merchant.setProvinceName(shopReq.getProvinceName());
+            merchant.setCityName(shopReq.getCityName());
+            merchant.setDistrictName(shopReq.getDistrictName());
+            merchant.setCityCode(shopReq.getCityCode());
+            merchant.setCategoryId(shopReq.getCategoryId());
+            merchant.setContactName(shopReq.getContactName());
+            merchant.setMobile(shopReq.getMobile());
+            merchant.setBizLicense(shopReq.getBizLicense());
+            merchant.setBizLicenseNo(shopReq.getBizLicenseNo());
+            merchant.setLegalPerson(shopReq.getLegalPerson());
+            merchant.setIdcardNo(shopReq.getIdcardNo());
+            merchant.setIdcardFront(shopReq.getIdcardFront());
+            merchant.setIdcardBack(shopReq.getIdcardBack());
+            merchant.setBizLicenseIdcard(shopReq.getBizLicenseIdcard());
+            merchant.setLng(shopReq.getLng());
+            merchant.setLat(shopReq.getLat());
+            merchant.setAddress(shopReq.getAddress());
+            merchant.setStreet(shopReq.getStreet());
+            merchant.setFoodLicensePic(shopReq.getFoodLicensePic());
+            merchant.setStatus(MerchantStatusEnum.CERTIFIED.status);
+            iMerchantService.save(merchant);
+            member.setMerchantId(merchant.getId());
+            member.setMemberType(MemberTypeEnum.MERCHANT.type);
+        }else {
+            merchant = iMerchantService.getById(member.getMerchantId());
+            if (merchant.getStatus().equals(MerchantStatusEnum.STOP.status)) {
+                throw new CustomAppException("该商家已禁用!");
+            }
+        }
+
+        Shop shop = new Shop();
+        shop.setAddress(shopReq.getAddress());
+        shop.setCategoryId(categoryId);
+        shop.setCode(SnCodeUtils.createShopSn());
+        shop.setContactName(shopReq.getContactName());
+        shop.setDoorHeadPhoto(shopReq.getDoorHeadPhoto());
+        shop.setLat(shopReq.getLat());
+        shop.setLng(shopReq.getLng());
+        shop.setMerchantId(member.getMerchantId());
+        shop.setMobile(shopReq.getMobile());
+        shop.setName(shopReq.getName());
+        shop.setStreet(shopReq.getStreet());
+        shop.setProvinceName(shopReq.getProvinceName());
+        shop.setCityName(shopReq.getCityName());
+        shop.setDistrictName(shopReq.getDistrictName());
+        shop.setCityCode(shopReq.getCityCode());
+        shop.setBizLicense(shopReq.getBizLicense());
+        shop.setBizLicenseNo(shopReq.getBizLicenseNo());
+        shop.setLegalPerson(shopReq.getLegalPerson());
+        shop.setIdcardNo(shopReq.getIdcardNo());
+        shop.setIdcardFront(shopReq.getIdcardFront());
+        shop.setIdcardBack(shopReq.getIdcardBack());
+        shop.setBizLicenseIdcard(shopReq.getBizLicenseIdcard());
+        shop.setFoodLicensePic(shopReq.getFoodLicensePic());
+        shop.setHouseNo(shopReq.getHouseNo());
+        shop.setPoi(shopReq.getPoi());
+        iShopService.save(shop);
+
+        // 判断商家拥有几个门店
+        List<ShopDto> shopList = iShopService.findList(shop.getMerchantId());
+        if (shopList != null && shopList.size() == 1) {
+            member.setShopId(shop.getId());
+            iMemberService.updateById(member);
+            //创建默认管理员
+            ShopUser shopUser = new ShopUser();
+            shopUser.setShopId(shop.getId());
+            shopUser.setMemberId(loginId);
+            shopUser.setName(member.getNickname());
+            shopUser.setMerchantId(member.getMerchantId());
+            shopUser.setType(ShopUserTypeEnum.DINA_ZHANG.type);
+            iShopUserService.save(shopUser);
+            apiWaimaiService.saveConfig(loginId,new DeliveryConfigDto());
+        }
+        //绑定最新门店到账户
+//        member.setShopId(shop.getId());
+//        iMemberService.saveOrUpdate(member);
+        //创建三方门店,如果通过自动绑定该运力
+        //创建门店
+        List<ShopDeliveryConfig> list = iShopDeliveryConfigService.list(new QueryWrapper<ShopDeliveryConfig>().eq("status", StatusEnum.SHOW.status).eq("deleted", IsDeleteEnum.NORMAL.status));
+        list = list.stream().filter(a->!a.getType().equals(DeliveryTypeEnums.AIPT.getType())).collect(Collectors.toList());
+//        MerchantCategory category = iMerchantCategoryService.getById(merchant.getCategoryId());
+        merchant.setCategoryName(category.getFnProductType());
+        merchant.setMtCcategoryName(category.getMtProductType());
+        merchant.setDdCcategory(category.getDadaProductType());
+        merchant.setSsProductType(category.getSsProductType());
+        if (!isMerchant){
+            merchant.setBizLicense(shop.getBizLicense());
+            merchant.setBizLicenseNo(shop.getBizLicenseNo());
+            merchant.setLegalPerson(shop.getLegalPerson());
+            merchant.setIdcardNo(shop.getIdcardNo());
+            merchant.setIdcardFront(shop.getIdcardFront());
+            merchant.setIdcardBack(shop.getIdcardBack());
+            merchant.setBizLicenseIdcard(shop.getBizLicenseIdcard());
+        }
+        for (ShopDeliveryConfig d : list) {
+
+            ShopVo shopVo = ShopEntityUtils.createShopVoNew(shop, d, merchant);
+            log.info("门店信息:" + JsonMapper.nonEmptyMapper().toJson(shopVo));
+
+            ResObject<ShopResultVo> res = deliveryClient.createShop(shopVo);
+            ShopDelivery delivery = new ShopDelivery();
+            delivery.setDeliveryId(d.getId());
+            delivery.setMerchantId(shop.getMerchantId());
+            delivery.setShopId(shop.getId());
+            if ("shunfeng".equals(shopVo.getLbClient()) || "uupt".equals(shopVo.getLbClient()) ||
+                    "kuanfu".equals(shopVo.getLbClient()) || "huolala".equals(shopVo.getLbClient()) || "meituanzb".equals(shopVo.getLbClient())) {
+                delivery.setBindStatus(BindStatusEnum.BIND.getStatus());
+            } else {
+                delivery.setBindStatus(BindStatusEnum.UNBIND.getStatus());
+            }
+            if (res.getCode() == 0) {//操作成功
+                ShopResultVo shopResultVo = res.getData();
+                String shopId = shopResultVo.getShopId();//返回的门店id,作保存以作后用
+                Object resData = shopResultVo.getResData(); //返回的详细数据
+                delivery.setBindStatus(BindStatusEnum.BIND.getStatus());
+                // 如果是蜂鸟要查询门店审核状态
+                if ("fengniao".equals(shopVo.getLbClient())){
+                    delivery.setBindStatus(getFengniaoShopStatusNew(shop,d));
+                }
+                if ("fengniaoka".equals(shopVo.getLbClient())){
+                    delivery.setBindStatus(BindStatusEnum.CHECK.getStatus());
+                }
+                if ("meituan".equals(shopVo.getLbClient())){
+                    delivery.setBindStatus(BindStatusEnum.CHECK.status);
+                }
+                delivery.setThirdShopId(shopId);
+            }else {
+                delivery.setAuthMsg(res.getMsg());
+            }
+            iShopDeliveryService.save(delivery);
+            // 存lb_shop_third表中
+            ShopThird shopThird = new ShopThird();
+            shopThird.setShopId(shopReq.getId());
+            shopThird.setAddress(shopReq.getAddress());
+            shopThird.setContactName(shopReq.getContactName());
+            shopThird.setDoorHeadPhoto(shopReq.getDoorHeadPhoto());
+            shopThird.setLat(shopReq.getLat());
+            shopThird.setLng(shopReq.getLng());
+            shopThird.setCityCode(shopReq.getCityCode());
+            shopThird.setMobile(shopReq.getMobile());
+            shopThird.setName(shopReq.getName());
+            shopThird.setStreet(shopReq.getStreet());
+            shopThird.setDeliveryId(delivery.getDeliveryId());
+            shopThird.setShopId(shop.getId());
+            shopThird.setProvinceName(shopReq.getProvinceName());
+            shopThird.setCityName(shopReq.getCityName());
+            shopThird.setDistrictName(shopReq.getDistrictName());
+            iShopThirdService.saveOrUpdate(shopThird);
+        }
+
+
+        return shop;
+    }
+
+    /**
+     * 获取蜂鸟门店审核信息
+     * @param shop
+     * @param d
+     * @return
+     */
+    @Override
+    public Integer getFengniaoShopStatusNew(Shop shop,ShopDeliveryConfig d){
+        Integer status = BindStatusEnum.UNBIND.status;
+        ShopQueryVo shopQueryVo = new ShopQueryVo();
+        shopQueryVo.setLbClient(DeliveryTypeEnums.FENG_NIAO.getName());
+        shopQueryVo.setOutShopCode(shop.getCode());
+        shopQueryVo.setMerchantId(d.getShopId());
+        shopQueryVo.setAccessToken(d.getAuthToken());
+        ResObject<ShopQueryResultVo> shopRes = deliveryClient.queryShop(shopQueryVo);
+        // 10-上架审核中,20-正常(已上架),30-上架审核失败,40-已冻结,50-已下架
+        if (shopRes.getCode() == 0) {
+            ShopQueryResultVo getShopStatus = shopRes.getData();
+            Integer shopStatus = getShopStatus.getShopStatus();
+            Integer modifyStatus = getShopStatus.getModifyStatus();
+            if (10 == shopStatus){
+                status=BindStatusEnum.CHECK.status;
+            }else if (20 == shopStatus){
+                status = BindStatusEnum.BIND.status;
+            }else if (30 == shopStatus || 40 == shopStatus || 50 == shopStatus){
+                status = BindStatusEnum.REFUND.status;
+            }
+        }
+        return status;
+    }
+
+    /**
+     * 获取蜂鸟门店审核信息
+     * @param shop
+     * @param d
+     * @return
+     */
+    @Override
+    public Integer getFengniaoShopStatus(Shop shop,DspDelivery d){
+        Integer status = BindStatusEnum.UNBIND.status;
+        ShopQueryVo shopQueryVo = new ShopQueryVo();
+        shopQueryVo.setLbClient(DeliveryTypeEnums.FENG_NIAO.getName());
+        shopQueryVo.setOutShopCode(shop.getCode());
+        shopQueryVo.setMerchantId(d.getShopId());
+        shopQueryVo.setAccessToken(d.getAuthToken());
+        ResObject<ShopQueryResultVo> shopRes = deliveryClient.queryShop(shopQueryVo);
+        // 10-上架审核中,20-正常(已上架),30-上架审核失败,40-已冻结,50-已下架
+        if (shopRes.getCode() == 0) {
+            ShopQueryResultVo getShopStatus = shopRes.getData();
+            Integer shopStatus = getShopStatus.getShopStatus();
+            Integer modifyStatus = getShopStatus.getModifyStatus();
+            if (10 == shopStatus){
+                status=BindStatusEnum.CHECK.status;
+            }else if (20 == shopStatus){
+                status = BindStatusEnum.BIND.status;
+            }else if (30 == shopStatus || 40 == shopStatus || 50 == shopStatus){
+                status = BindStatusEnum.REFUND.status;
+            }
+        }
+        return status;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void delete(Long loginId, Long shopId) {
+        Member loginMember = iMemberService.getById(loginId);
+        log.info("删除门店id---"+shopId);
+        // 判断门店是否绑定美团、饿了么、饿百
+        List<WaimaiDto> shopWaimais = iShopWaimaiService.findList(shopId);
+        StringBuffer stringBuffer = new StringBuffer();
+        for (int i=0;i<shopWaimais.size();i++){
+            if (shopWaimais.get(i).getBindStatus().equals(1)){
+                stringBuffer.append(shopWaimais.get(i).getName());
+                if (shopWaimais.size()>1 && i<shopWaimais.size()-1){
+                    stringBuffer.append(",");
+                }
+            }
+        }
+        if (StringUtils.isNotEmpty(stringBuffer.toString())){
+            throw new CustomAppException("当前绑定["+stringBuffer.toString()+"]请先解绑",201);
+        }
+
+        if (loginMember.getMemberType().equals(MemberTypeEnum.MERCHANT.type) && shopId.equals(loginMember.getShopId())) {
+            throw new CustomAppException("默认门店不能删除!");
+        }
+
+        iShopService.removeById(shopId);
+        // 删除门店账号,并且用户变为个人,如果是商家不管
+        List<ShopUser> shopUsers = iShopUserService.queryByShopId(shopId);
+        for (ShopUser u : shopUsers){
+            Member member = iMemberService.getById(u.getMemberId());
+            if (member.getMemberType().equals(MemberTypeEnum.MERCHANT.type)){
+                continue;
+            }
+            iMemberService.updateMember(member.getId());
+            iShopUserService.removeById(u.getId());
+        }
+
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void modify(Long loginId, ShopReq shopReq) {
+        Shop shop = iShopService.getById(shopReq.getId());
+        if (shop == null) {
+            throw new CustomAppException("门店不存在!");
+        }
+        // 判断店铺名称是否重复
+        List<Shop> shops = iShopService.getShopByName(shopReq.getName(), shopReq.getId());
+        if (shops != null && shops.size() > 0) {
+            throw new CustomAppException("店铺名称重复!");
+        }
+        shop.setProvinceName(shopReq.getProvinceName());
+        shop.setCityName(shopReq.getCityName());
+        shop.setDistrictName(shopReq.getDistrictName());
+        shop.setAddress(shopReq.getAddress());
+        shop.setContactName(shopReq.getContactName());
+        shop.setDoorHeadPhoto(shopReq.getDoorHeadPhoto());
+        shop.setLat(shopReq.getLat());
+        shop.setLng(shopReq.getLng());
+        shop.setCityCode(shopReq.getCityCode());
+        shop.setMobile(shopReq.getMobile());
+        shop.setName(shopReq.getName());
+        shop.setStreet(shopReq.getStreet());
+        shop.setBizLicense(shopReq.getBizLicense());
+        shop.setBizLicenseNo(shopReq.getBizLicenseNo());
+        shop.setLegalPerson(shopReq.getLegalPerson());
+        shop.setIdcardNo(shopReq.getIdcardNo());
+        shop.setIdcardFront(shopReq.getIdcardFront());
+        shop.setIdcardBack(shopReq.getIdcardBack());
+        shop.setBizLicenseIdcard(shopReq.getBizLicenseIdcard());
+        shop.setHouseNo(shopReq.getHouseNo());
+        shop.setPoi(shopReq.getPoi());
+        if (shopReq.getCategoryId() != null){
+            shop.setCategoryId(shopReq.getCategoryId());
+        }
+        iShopService.updateById(shop);
+        // 提交审核
+        List<ShopDelivery> shopDeliveries = iShopDeliveryService.findByShopId(shopReq.getId());
+        for (ShopDelivery delivery : shopDeliveries) {
+            DspDelivery dspDelivery = iDspDeliveryService.getById(delivery.getDeliveryId());
+            Member member = iMemberService.getById(loginId);
+            Merchant merchant = iMerchantService.getById(member.getMerchantId());
+            Long categoryId = merchant.getCategoryId();
+            if (shopReq.getCategoryId() != null){
+                categoryId = shopReq.getCategoryId();
+            }
+            MerchantCategory category = iMerchantCategoryService.getById(categoryId);
+            merchant.setCategoryName(category.getFnProductType());
+            merchant.setMtCcategoryName(category.getMtProductType());
+            merchant.setDdCcategory(category.getDadaProductType());
+            merchant.setSsProductType(category.getSsProductType());
+            if (delivery.getThirdShopId() != null) {
+                // 更新
+                shopReq.setThirdShopId(delivery.getThirdShopId());
+                shopReq.setCode(shop.getCode());
+                ShopVo shopVo = ShopEditUtils.editShopVo(shopReq, dspDelivery, merchant);
+                if ("shunfeng".equals(shopVo.getLbClient()) || "uupt".equals(shopVo.getLbClient()) ||
+                        "kuanfu".equals(shopVo.getLbClient()) || "huolala".equals(shopVo.getLbClient()) || "meituanzb".equals(shopVo.getLbClient())) {
+                    delivery.setBindStatus(BindStatusEnum.BIND.getStatus());
+                }
+                ResObject<ShopResultVo> res = deliveryClient.updateShop(shopVo);
+                if (res.getCode() == 0) {//操作成功
+                    ShopResultVo shopResultVo = res.getData();
+                    String shopId = shopResultVo.getShopId();//返回的门店id,作保存以作后用
+                    Object resData = shopResultVo.getResData(); //返回的详细数据
+                    delivery.setBindStatus(BindStatusEnum.BIND.getStatus());
+                    if (shopVo.getLbClient().equals("fengniao")) {
+                        Integer status = getFengniaoShopStatus(shop, dspDelivery);
+                        delivery.setBindStatus(status);
+                    }
+                    if ("meituan".equals(shopVo.getLbClient())) {
+                        delivery.setBindStatus(BindStatusEnum.CHECK.status);
+                    }
+                    delivery.setThirdShopId(shopId);
+                } else {
+                    delivery.setAuthMsg(res.getMsg());
+                }
+                iShopDeliveryService.updateById(delivery);
+            } else {
+                // 新增
+                Shop shop1 = new Shop();
+                BeanUtils.copyProperties(shopReq, shop1);
+                ShopVo shopVo = ShopEntityUtils.createShopVo(shop1, dspDelivery, merchant);
+                ResObject<ShopResultVo> res = deliveryClient.createShop(shopVo);
+                delivery.setBindStatus(BindStatusEnum.UNBIND.getStatus());
+                if ("shunfeng".equals(shopVo.getLbClient()) || "uupt".equals(shopVo.getLbClient()) ||
+                        "kuanfu".equals(shopVo.getLbClient()) || "huolala".equals(shopVo.getLbClient())  || "meituanzb".equals(shopVo.getLbClient())) {
+                    delivery.setBindStatus(BindStatusEnum.BIND.getStatus());
+                }
+                if (res.getCode() == 0) {//操作成功
+                    ShopResultVo shopResultVo = res.getData();
+                    String shopId = shopResultVo.getShopId();//返回的门店id,作保存以作后用
+                    delivery.setBindStatus(BindStatusEnum.BIND.getStatus());
+                    if (shopVo.getLbClient().equals("fengniao")) {
+                        Integer status = getFengniaoShopStatus(shop1, dspDelivery);
+                        delivery.setBindStatus(status);
+                    }
+                    if (shopVo.getLbClient().equals("meituan")) {
+                        delivery.setBindStatus(BindStatusEnum.CHECK.getStatus());
+                    }
+                    delivery.setThirdShopId(shopId);
+                } else {
+                    delivery.setAuthMsg(res.getMsg());
+                }
+                iShopDeliveryService.updateById(delivery);
+            }
+            ShopThird shopThird = new ShopThird();
+            shopThird.setShopId(shopReq.getId());
+            shopThird.setAddress(shopReq.getAddress());
+            shopThird.setContactName(shopReq.getContactName());
+            shopThird.setDoorHeadPhoto(shopReq.getDoorHeadPhoto());
+            shopThird.setLat(shopReq.getLat());
+            shopThird.setLng(shopReq.getLng());
+            shopThird.setCityCode(shopReq.getCityCode());
+            shopThird.setMobile(shopReq.getMobile());
+            shopThird.setName(shopReq.getName());
+            shopThird.setStreet(shopReq.getStreet());
+            shopThird.setDeliveryId(delivery.getDeliveryId());
+            shopThird.setProvinceName(shopReq.getProvinceName());
+            shopThird.setCityName(shopReq.getCityName());
+            shopThird.setDistrictName(shopReq.getDistrictName());
+
+            iShopThirdService.saveOrUpdate(shopThird);
+        }
+    }
+}

+ 86 - 10
lb-app/src/main/java/com/ydd/app/service/impl/ApiShopServiceImpl.java

@@ -7,11 +7,13 @@ import com.ydd.app.ShopEditUtils;
 import com.ydd.app.ShopEntityUtils;
 import com.ydd.app.dto.ShopReq;
 import com.ydd.app.service.ApiShopService;
+import com.ydd.app.service.ApiWaimaiService;
 import com.ydd.common.enums.DeliveryTypeEnums;
 import com.ydd.common.utils.SnCodeUtils;
 import com.ydd.common.utils.StringUtils;
 import com.ydd.ecloud.core.utils.JsonMapper;
 import com.ydd.module.domain.*;
+import com.ydd.module.dto.DeliveryConfigDto;
 import com.ydd.module.dto.DeliveryDto;
 import com.ydd.module.dto.ShopDto;
 import com.ydd.module.dto.WaimaiDto;
@@ -71,6 +73,8 @@ public class ApiShopServiceImpl implements ApiShopService {
 
     private final IShopUserService iShopUserService;
 
+    private final ApiWaimaiService apiWaimaiService;
+
     @Override
     public List<ShopDto> findList(Long loginId) {
         Member member = iMemberService.getById(loginId);
@@ -111,17 +115,25 @@ public class ApiShopServiceImpl implements ApiShopService {
     @Transactional(rollbackFor = Exception.class)
     public Shop saveShop(Long loginId, ShopReq shopReq,boolean isMerchant) {
         Member member = iMemberService.getById(loginId);
-        if (member.getMerchantId() == null) {
-            throw new CustomAppException("请先申请成为商家!");
-        }
-        Merchant merchant = iMerchantService.getById(member.getMerchantId());
-        if (merchant.getStatus().equals(MerchantStatusEnum.STOP.status)) {
-            throw new CustomAppException("该商家已禁用!");
-        }
-        if (merchant.getStatus().equals(MerchantStatusEnum.TO_BE_CERTIFIED.status)) {
-            throw new CustomAppException("请等待商家通过认证!");
+
+        // 判断店铺名称是否重复
+        List<Shop> shops = iShopService.getShopByName(shopReq.getName(), null);
+        if (shops != null && shops.size() > 0) {
+            throw new CustomAppException("店铺名称重复!");
         }
-        Long categoryId = merchant.getCategoryId();
+
+//        if (member.getMerchantId() == null) {
+//            throw new CustomAppException("请先申请成为商家!");
+//        }
+//        Merchant merchant = iMerchantService.getById(member.getMerchantId());
+//        if (merchant.getStatus().equals(MerchantStatusEnum.STOP.status)) {
+//            throw new CustomAppException("该商家已禁用!");
+//        }
+//        if (merchant.getStatus().equals(MerchantStatusEnum.TO_BE_CERTIFIED.status)) {
+//            throw new CustomAppException("请等待商家通过认证!");
+//        }
+//        Long categoryId = merchant.getCategoryId();
+        Long categoryId = null;
         if (null != shopReq.getCategoryId()){
             categoryId = shopReq.getCategoryId();
         }
@@ -129,6 +141,49 @@ public class ApiShopServiceImpl implements ApiShopService {
         if (category == null){
             throw new CustomAppException("门店分类不存在!");
         }
+
+        Merchant merchant = new Merchant();
+        // 第一个店铺新增的时候创建默认商家
+        if (member.getMerchantId() == null) {
+            merchant.setCode(SnCodeUtils.createMerchantSn());
+            merchant.setMerchantName(shopReq.getName());
+            if (member.getAgentId() != null){
+                merchant.setAgentId(member.getAgentId());
+            }
+            if (member.getPersonnelId() != null){
+                merchant.setPersonnelId(member.getPersonnelId());
+            }
+            merchant.setProvinceName(shopReq.getProvinceName());
+            merchant.setCityName(shopReq.getCityName());
+            merchant.setDistrictName(shopReq.getDistrictName());
+            merchant.setCityCode(shopReq.getCityCode());
+            merchant.setCategoryId(shopReq.getCategoryId());
+            merchant.setContactName(shopReq.getContactName());
+            merchant.setMobile(shopReq.getMobile());
+            merchant.setBizLicense(shopReq.getBizLicense());
+            merchant.setBizLicenseNo(shopReq.getBizLicenseNo());
+            merchant.setLegalPerson(shopReq.getLegalPerson());
+            merchant.setIdcardNo(shopReq.getIdcardNo());
+            merchant.setIdcardFront(shopReq.getIdcardFront());
+            merchant.setIdcardBack(shopReq.getIdcardBack());
+            merchant.setBizLicenseIdcard(shopReq.getBizLicenseIdcard());
+            merchant.setLng(shopReq.getLng());
+            merchant.setLat(shopReq.getLat());
+            merchant.setAddress(shopReq.getAddress());
+            merchant.setStreet(shopReq.getStreet());
+            merchant.setFoodLicensePic(shopReq.getFoodLicensePic());
+            merchant.setStatus(MerchantStatusEnum.CERTIFIED.status);
+            iMerchantService.save(merchant);
+            member.setMerchantId(merchant.getId());
+            member.setMemberType(MemberTypeEnum.MERCHANT.type);
+        }else {
+            merchant = iMerchantService.getById(member.getMerchantId());
+            if (merchant.getStatus().equals(MerchantStatusEnum.STOP.status)) {
+                throw new CustomAppException("该商家已禁用!");
+            }
+        }
+
+
         Shop shop = new Shop();
         shop.setAddress(shopReq.getAddress());
         shop.setCategoryId(categoryId);
@@ -153,7 +208,28 @@ public class ApiShopServiceImpl implements ApiShopService {
         shop.setIdcardBack(shopReq.getIdcardBack());
         shop.setBizLicenseIdcard(shopReq.getBizLicenseIdcard());
         shop.setFoodLicensePic(shopReq.getFoodLicensePic());
+        shop.setHouseNo(shopReq.getHouseNo());
+        shop.setPoi(shopReq.getPoi());
         iShopService.save(shop);
+
+        // 判断商家拥有几个门店
+        List<ShopDto> shopList = iShopService.findList(shop.getMerchantId());
+        if (shopList != null && shopList.size() == 1) {
+            member.setShopId(shop.getId());
+            iMemberService.updateById(member);
+            //创建默认管理员
+            ShopUser shopUser = new ShopUser();
+            shopUser.setShopId(shop.getId());
+            shopUser.setMemberId(loginId);
+            shopUser.setName(member.getNickname());
+            shopUser.setMerchantId(member.getMerchantId());
+            shopUser.setType(ShopUserTypeEnum.DINA_ZHANG.type);
+            iShopUserService.save(shopUser);
+            apiWaimaiService.saveConfig(loginId,new DeliveryConfigDto());
+        }
+
+
+
         //绑定最新门店到账户
 //        member.setShopId(shop.getId());
 //        iMemberService.saveOrUpdate(member);

+ 4 - 0
lb-app/src/main/resources/application-dev.yml

@@ -113,6 +113,10 @@ waimai:
     url: https://nr.ele.me/eleme_nr_bfe_retail/api_bind_shop#/bindShop?source=07EA0D6AC36FB8B025FEB8FB7F9527B0832CB9D195CCB8BE&fromSys=2
     appid: 34590482
     appScert: pKmcIwTxER
+  meituansg:
+    url: https://open-shangou.meituan.com/erp/login?code=gWwAXGhJraVQU%2FwITEV484hR7NU%2ByMl9s4aegBAo1ArH9bpmJJcqrNlJyt6eglINGM0j1jy5A4cbNM0BRwqgm7i3aj3UU2DYlTDHiLQEhyE%3D&auth_type=oauth&company_name=%E7%8C%8E%E8%B1%B9ai=#!/login
+    appid: 7418
+    appScert: 1e7630a9417312e1940badf67519641d
 ##同城配送平台配置参数
 delivery:
   isTest: true

+ 4 - 0
lb-app/src/main/resources/application-prod.yml

@@ -105,6 +105,10 @@ waimai:
     url: https://nr.ele.me/eleme_nr_bfe_retail/api_bind_shop#/bindShop?source=30763AE66C2D05A84C8F67FAE3806674D7BB533E42CED969&fromSys=2
     appid: 49547270
     appScert: bsyk7rDtTap
+  meituansg:
+    url: https://open-shangou.meituan.com/erp/login?code=gWwAXGhJraVQU%2FwITEV484hR7NU%2ByMl9s4aegBAo1ArH9bpmJJcqrNlJyt6eglINGM0j1jy5A4cbNM0BRwqgm7i3aj3UU2DYlTDHiLQEhyE%3D&auth_type=oauth&company_name=%E7%8C%8E%E8%B1%B9ai=#!/login
+    appid: 7418
+    appScert: 1e7630a9417312e1940badf67519641d
 ##同城配送平台配置参数
 delivery:
   isTest: false

+ 1 - 1
lb-module/src/main/java/com/ydd/module/domain/PackageCityConfig.java

@@ -15,7 +15,7 @@ import java.util.Date;
 
 /**
  * 城市运力/优惠/佣金配置表 lb_package_city_config
- * 
+ *
  * @author 叶君翔
  * @date 2021-11-16
  */

+ 6 - 0
lb-module/src/main/java/com/ydd/module/domain/Shop.java

@@ -197,6 +197,12 @@ private static final long serialVersionUID=1L;
     @ApiModelProperty(value = "食品经营许可")
     private String foodLicensePic;
 
+    @ApiModelProperty(value = "门牌号")
+    private String houseNo;
+
+    @ApiModelProperty(value = "POI")
+    private String poi;
+
     /**
      * 打印二维码:1->打印,0->不打印
      */

+ 74 - 0
lb-module/src/main/java/com/ydd/module/domain/ShopDeliveryConfig.java

@@ -0,0 +1,74 @@
+package com.ydd.module.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ydd.common.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Demo class
+ *
+ * @author 14027
+ * @date 2021/11/30 15:11
+ */
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+@TableName("lb_shop_delivery_config")
+public class ShopDeliveryConfig implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /** $column.columnComment */
+    @TableId(value = "id")
+    private Long id;
+
+    /** 配送平台ID */
+    @Excel(name = "配送平台ID")
+    private Long deliveryId;
+
+    /** 配送平台名称 */
+    @Excel(name = "配送平台名称")
+    private String name;
+
+    /** 顺序 */
+    @Excel(name = "顺序")
+    private Integer sort;
+
+    /** 状态:1->提交,0->不提交 */
+    @Excel(name = "状态:1->提交,0->不提交")
+    private Integer status;
+
+    /** 创建时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /** 更新时间 */
+    @TableField(update = "now()")
+    private Date updateTime;
+
+    /** 删除标识位: 0正常 1删除 */
+    @TableLogic
+    private Integer deleted;
+
+    private Integer type;
+
+    /**
+     * 门店(商家)ID
+     */
+    @ApiModelProperty(value = "门店(商家)ID")
+    private String shopId;
+
+    @ApiModelProperty(value = "平台授权TOKEN")
+    private String authToken;
+}

+ 15 - 0
lb-module/src/main/java/com/ydd/module/mapper/ShopDeliveryConfigMapper.java

@@ -0,0 +1,15 @@
+package com.ydd.module.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydd.module.domain.ShopDeliveryConfig;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * Demo class
+ *
+ * @author 14027
+ * @date 2021/11/30 15:19
+ */
+@Mapper
+public interface ShopDeliveryConfigMapper extends BaseMapper<ShopDeliveryConfig> {
+}

+ 4 - 19
lb-module/src/main/java/com/ydd/module/mapper/ShopMapper.java

@@ -1,10 +1,9 @@
 package com.ydd.module.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ydd.module.domain.Shop;
-import com.ydd.module.dto.*;
+import com.ydd.module.dto.DeliveryDto;
+import com.ydd.module.dto.ShopDto;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -17,7 +16,7 @@ import java.util.List;
  */
 public interface ShopMapper extends BaseMapper<Shop> {
 
-    List<ShopDto> findList(@Param("merchantId") Long merchantId,@Param("shopId")Long shopId);
+    List<ShopDto> findList(@Param("merchantId") Long merchantId);
 
     List<DeliveryDto> findDeliveryList(@Param("shopId")Long shopId);
 
@@ -44,20 +43,6 @@ public interface ShopMapper extends BaseMapper<Shop> {
 
     Integer getOpenQrCode(@Param("shopId") Long shopId);
 
-    List<ShopBindDto> findListByMerchantId(@Param("merchantId") Long merchantId);
-
-    List<ShopBindDto> findListById(@Param("shopId") Long shopId);
-
-    List<Long> getIdListByFreightPackageId(@Param("freightPackageId") Long freightPackageId);
-
-    List<DadaDspMerchantShopInfoDto> queryShopListByMerchantId(@Param("params") DadaDspMerchantShopListQuery shopListQuery);
-
-    Page<DadaShopListDto> queryDadaShopList(@Param("params") DadaShopListQuery listQuery, IPage<DadaShopListDto> pageArt);
-
-    List<ShopDiscountPackageStatisticsDto> getDiscountPackageList(Page page, @Param("params") DiscountPackageStatisticsQuery query);
-
-    List<Long> findShopIdByMerchantId(@Param("merchantIds") List<Long> merchantIds);
-
-    List<Shop> getShopByMerchantIds(@Param("merchantIds") List<Long> merchantIds);
+    List<Shop> getShopByName(@Param("name") String name, @Param("id") Long id);
 
 }

+ 13 - 0
lb-module/src/main/java/com/ydd/module/service/IShopDeliveryConfigService.java

@@ -0,0 +1,13 @@
+package com.ydd.module.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydd.module.domain.ShopDeliveryConfig;
+
+/**
+ * Demo class
+ *
+ * @author 14027
+ * @date 2021/11/30 15:17
+ */
+public interface IShopDeliveryConfigService extends IService<ShopDeliveryConfig> {
+}

+ 8 - 91
lb-module/src/main/java/com/ydd/module/service/IShopService.java

@@ -1,12 +1,10 @@
 package com.ydd.module.service;
 
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ydd.common.core.domain.entity.SysUser;
-import com.ydd.common.core.page.PageResult;
-import com.ydd.module.domain.Merchant;
 import com.ydd.module.domain.Shop;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.ydd.module.dto.*;
+import com.ydd.module.dto.DeliveryDto;
+import com.ydd.module.dto.ShopDto;
 import com.ydd.module.request.ShopBindRulePackageRequest;
 
 import java.util.List;
@@ -26,7 +24,7 @@ public interface IShopService extends IService<Shop> {
      */
     List<Shop> queryList(Shop shop);
 
-    List<ShopDto> findList(Long merchantId,Long shopId);
+    List<ShopDto> findList(Long merchantId);
 
     List<DeliveryDto> findDeliveryList(Long id);
 
@@ -38,8 +36,6 @@ public interface IShopService extends IService<Shop> {
 
     List<Integer> findByMerchantIds(List<Integer> merchantIds);
 
-    List<Long> findShopIdByMerchantId(List<Long> merchantIds);
-
     List<Integer> findByMerchantId(Integer merchantId);
 
     /**
@@ -82,89 +78,10 @@ public interface IShopService extends IService<Shop> {
     void bindValuationRulePackage(ShopBindRulePackageRequest request);
 
     /**
-     * 根据商户id获取门店列表
-     * @param merchantId 商户id
-     * @return 门店列表
-     */
-    List<ShopBindDto> findListByMerchantId(Long merchantId);
-
-    /**
-     * 根据门店id获取门店
-     * @param shopId 门店id
-     * @return 门店
-     */
-    List<ShopBindDto> findListById(Long shopId);
-
-    /**
-     * 根据运费包获取关联门店id
-     * @param packageFreightId 运费包id
-     * @return 门店id列表
-     */
-    List<Long> getIdListByFreightPackageId(Long packageFreightId);
-
-    /**
-     * 根据商户id查询门店列表
-     * @param shopListQuery 请求参数
-     * @return 门店列表
-     */
-    List<DadaDspMerchantShopInfoDto> queryShopListByMerchantId(DadaDspMerchantShopListQuery shopListQuery);
-
-    /**
-     * 查询达达门店列表
-     * @param listQuery 查询参数
-     * @param user 登录用户
-     * @return 列表
-     */
-    PageResult queryDadaShopList(DadaShopListQuery listQuery, SysUser user);
-
-    /**
-     * 获取达达配送商 商户列表
-     * @param dadaDspId 配送商id
-     * @return 列表
-     */
-    List<Merchant> queryDadaMerchantList(Long dadaDspId);
-
-    /**
-     * 绑定运费包
-     * @param bindFreightQuery 参数
-     * @return 绑定结果
-     */
-    boolean bindFreightPackage(DadaDspBindFreightQuery bindFreightQuery);
-
-    /**
-     * 达达配送商新增门店
-     * @param shopReq 请求参数
-     * @param user 登录用户信息
-     * @return 新增结果
-     */
-    boolean saveDadaShop(DadaShopAddQuery shopReq, SysUser user);
-
-    /**
-     * 查询达达门店列表
-     * @param user 登录用户
-     * @return 门店列表
-     */
-    List<Shop> getDadaShopOption(SysUser user);
-
-    /**
-     * 达达配送商修改门店
-     * @param shopReq 请求参数
-     * @param user 登录用户
-     * @return 修改结果
-     */
-    boolean editDadaShop(DadaShopAddQuery shopReq, SysUser user);
-
-    /**
-     * 获取门店优惠包
-     * @return 优惠包列表
-     */
-    List<ShopDiscountPackageStatisticsDto> getDiscountPackageList(Page page, DiscountPackageStatisticsQuery query);
-
-    /**
-     * 通过商户id查找门店
-     * @param merchantIds 商户id
-     * @return 门店列表
+     * 根据门店名称查询门店
+     * @param name 门店名称
+     * @param id 门店id
+     * @return
      */
-    List<Shop> getShopByMerchantIds(List<Long> merchantIds);
-
+    List<Shop> getShopByName(String name, Long id);
 }

+ 3 - 9
lb-module/src/main/java/com/ydd/module/service/impl/AgentServiceImpl.java

@@ -1,12 +1,10 @@
 package com.ydd.module.service.impl;
 
-import com.aliyun.oss.OSSClient;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.google.zxing.common.BitMatrix;
 import com.ydd.common.constant.UserConstants;
 import com.ydd.common.core.domain.entity.SysUser;
 import com.ydd.common.enums.UserTypeEnums;
@@ -15,7 +13,6 @@ import com.ydd.common.exception.CustomException;
 import com.ydd.common.oss.cloud.CloudStorageConfig;
 import com.ydd.common.oss.cloud.OSSFactory;
 import com.ydd.common.utils.SecurityUtils;
-import com.ydd.ecloud.core.utils.OSSHelper;
 import com.ydd.module.domain.*;
 import com.ydd.module.dto.BaseConfgMinDto;
 import com.ydd.module.enums.PackageCityConfigPackageTypeEnum;
@@ -25,7 +22,6 @@ import com.ydd.module.mapper.AgentMapper;
 import com.ydd.module.request.AgentBindRulePackageRequest;
 import com.ydd.module.service.*;
 import com.ydd.module.utils.BarCodeUtils;
-import com.ydd.module.utils.QRCodeUtil;
 import com.ydd.system.service.ISysUserService;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
@@ -237,8 +233,7 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public Boolean createAgent(Agent agent, SysUser user) {
+    public Boolean createAgent(Agent agent, SysUser user) throws Exception {
         Agent agents = baseMapper.selectByMobile(agent.getMobile(), null);
 //        Integer gentLevel = null;
         if (agents != null) {
@@ -300,7 +295,6 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public Boolean updateAgent(Agent agent) {
         Agent agents = baseMapper.selectByMobile(agent.getMobile(), agent.getId());
         if (agents != null) {
@@ -449,8 +443,8 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
     }
 
     @Override
-    public Integer getSAgentNum(Integer pid, String todayStartDate) {
-        return baseMapper.getSAgentNum(pid, todayStartDate);
+    public Integer getSAgentNum(Integer pid, Date date) {
+        return baseMapper.getSAgentNum(pid, date);
     }
 
     @Override

+ 1 - 1
lb-module/src/main/java/com/ydd/module/service/impl/PackageCityConfigServiceImpl.java

@@ -6,12 +6,12 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydd.common.exception.CustomException;
 import com.ydd.common.utils.StringUtils;
+import com.ydd.common.utils.bean.BeanUtils;
 import com.ydd.module.domain.*;
 import com.ydd.module.dto.PackageCityConfigDto;
 import com.ydd.module.enums.PackageCityConfigPackageTypeEnum;
 import com.ydd.module.mapper.PackageCityConfigMapper;
 import com.ydd.module.service.*;
-import org.springframework.beans.BeanUtils;
 import org.springframework.security.core.parameters.P;
 import org.springframework.stereotype.Service;
 

+ 6 - 9
lb-module/src/main/java/com/ydd/module/service/impl/PackageDeliveryDetailServiceImpl.java

@@ -1,22 +1,19 @@
 package com.ydd.module.service.impl;
 
-import com.ydd.module.domain.DspDelivery;
-import com.ydd.module.dto.PackageDeliveryDetailDto;
-import com.ydd.module.service.IDspDeliveryService;
-import jdk.nashorn.internal.ir.annotations.Reference;
-import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import org.apache.commons.lang3.StringUtils;
-import com.ydd.module.mapper.PackageDeliveryDetailMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydd.module.domain.DspDelivery;
 import com.ydd.module.domain.PackageDeliveryDetail;
+import com.ydd.module.dto.PackageDeliveryDetailDto;
+import com.ydd.module.mapper.PackageDeliveryDetailMapper;
+import com.ydd.module.service.IDspDeliveryService;
 import com.ydd.module.service.IPackageDeliveryDetailService;
+import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 /**
  * 运力包明细Service业务层处理

+ 0 - 3
lb-module/src/main/java/com/ydd/module/service/impl/PackageDeliveryServiceImpl.java

@@ -8,8 +8,6 @@ import com.ydd.module.domain.PackageDelivery;
 import com.ydd.module.domain.PackageDeliveryDetail;
 import com.ydd.module.dto.PackageDeliveryDetailDto;
 import com.ydd.module.dto.PackageDeliveryDto;
-import com.ydd.module.dto.PackageGradientConfigDto;
-import com.ydd.module.enums.PackageCommissionTypeEnum;
 import com.ydd.module.enums.PackageDeliveryBillDurationTypeEnum;
 import com.ydd.module.enums.PackageDeliveryTypeEnum;
 import com.ydd.module.mapper.PackageDeliveryMapper;
@@ -21,7 +19,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
 import java.util.List;
 
 /**

+ 17 - 0
lb-module/src/main/java/com/ydd/module/service/impl/ShopDeliveryConfigServiceImpl.java

@@ -0,0 +1,17 @@
+package com.ydd.module.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydd.module.domain.ShopDeliveryConfig;
+import com.ydd.module.mapper.ShopDeliveryConfigMapper;
+import com.ydd.module.service.IShopDeliveryConfigService;
+import org.springframework.stereotype.Service;
+
+/**
+ * Demo class
+ *
+ * @author 14027
+ * @date 2021/11/30 15:18
+ */
+@Service
+public class ShopDeliveryConfigServiceImpl extends ServiceImpl<ShopDeliveryConfigMapper, ShopDeliveryConfig> implements IShopDeliveryConfigService {
+}

+ 15 - 56
lb-module/src/main/java/com/ydd/module/service/impl/ShopDeliveryServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydd.api.DeliveryService;
 import com.ydd.common.core.domain.entity.SysUser;
 import com.ydd.common.core.page.PageResult;
 import com.ydd.common.enums.DeliveryTypeEnums;
@@ -19,12 +20,8 @@ import com.ydd.module.enums.IsDeleteEnum;
 import com.ydd.module.mapper.ShopDeliveryMapper;
 import com.ydd.module.service.*;
 import com.ydd.third.common.vo.ResObject;
-import com.ydd.third.delivery.Client;
-import com.ydd.third.delivery.dada.DadaClient;
-import com.ydd.third.delivery.shansong.ShansongClient;
-import com.ydd.third.delivery.vo.callback.ShansongTokenVo;
-import com.ydd.third.delivery.vo.shop.AmountResultVo;
-import com.ydd.third.delivery.vo.shop.QueryAmount;
+import com.ydd.third.common.vo.shop.AmountResultVo;
+import com.ydd.third.common.vo.shop.QueryAmount;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,7 +30,10 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 商家授权配送平台Service业务层处理
@@ -66,14 +66,8 @@ public class ShopDeliveryServiceImpl extends ServiceImpl<ShopDeliveryMapper, Sho
     @Resource
     private IMemberService iMemberService;
 
-    private final DadaClient dadaClient;
+    private final DeliveryService client;
 
-    private final Client client;
-
-    private final ShansongClient shansongClient;
-
-    @Resource
-    private IShopDeliveryBindService iShopDeliveryBindService;
 
     @Override
     public List<ShopDelivery> queryList(ShopDelivery shopDelivery) {
@@ -250,10 +244,10 @@ public class ShopDeliveryServiceImpl extends ServiceImpl<ShopDeliveryMapper, Sho
         Map<String, ShopWaimaiDto> map = new HashMap();
 
         for (ShopWaimaiDto d :dtos){
-            ShopWaimaiDto  dto =  map.get(d.getShopId()+d.getWaimaiId()+d.getDeleted()+d.getThirdShopId() + "");
+            ShopWaimaiDto  dto =  map.get(d.getShopId()+d.getWaimaiId()+d.getDeleted()+"");
             if (dto == null) {
                 dto=d;
-                map.put(d.getShopId()+d.getWaimaiId()+d.getDeleted()+d.getThirdShopId()+"", d);
+                map.put(d.getShopId()+d.getWaimaiId()+d.getDeleted()+"", d);
             }else {
                 continue;
             }
@@ -295,26 +289,12 @@ public class ShopDeliveryServiceImpl extends ServiceImpl<ShopDeliveryMapper, Sho
                         delivery.setBalance(resultVoResObject.getData().getBalanceAmount());
                         baseMapper.updateById(delivery);
                     }
-                } else if (shopDeliveryDto.getType().equals(DeliveryTypeEnums.SHUN_FENG.getType())) {
-                    // 调顺丰平台查询余额
-                    QueryAmount queryAmount = new QueryAmount();
-                    queryAmount.setMerchantId(delivery.getThirdShopId());
-                    queryAmount.setLbClient(DeliveryTypeEnums.SHUN_FENG.getName());
-                    queryAmount.setShopType(1);
-                    ResObject<AmountResultVo> resultVoResObject = client.queryAmount(queryAmount);
-                    if (resultVoResObject.getCode().equals(1)){
-                        flg = resultVoResObject.getMsg();
-                    } else {
-                        delivery.setBindStatus(BindStatusEnum.BIND.status);
-                        delivery.setBalance(resultVoResObject.getData().getBalanceAmount());
-                        baseMapper.updateById(delivery);
-                    }
-                } else {
-                    // 其他
+                }else {
+                    // 顺丰
                     delivery.setBindStatus(BindStatusEnum.BIND.status);
                     baseMapper.updateById(delivery);
                 }
-            } else if (shopDeliveryDto.getBindStatus().equals(BindStatusEnum.REFUND.status)){
+            }else if (shopDeliveryDto.getBindStatus().equals(BindStatusEnum.REFUND.status)){
                 delivery.setBindStatus(shopDeliveryDto.getBindStatus());
                 delivery.setAuthMsg(shopDeliveryDto.getAuthMsg());
                 baseMapper.updateById(delivery);
@@ -360,28 +340,6 @@ public class ShopDeliveryServiceImpl extends ServiceImpl<ShopDeliveryMapper, Sho
         List<ShopDelivery> deliverys = baseMapper.selectShopDeliverys();
         return deliverys;
     }
-    @Override
-    public void shanSongTask() {
-        try {
-            List<ShopDeliveryBind> bindDeliveryList = iShopDeliveryBindService.getShopBindDeliveryList();
-//            List<ShopDelivery> deliverys = baseMapper.selectShopDeliverys();
-            if (bindDeliveryList != null && bindDeliveryList.size() > 0) {
-                for (ShopDeliveryBind delivery : bindDeliveryList) {
-                    ResObject<ShansongTokenVo> resObject = shansongClient.refreshToken(delivery.getRefreshToken(), delivery.getThirdShopId());
-                    if (resObject.getCode()==0) {
-                        delivery.setAuthToken(resObject.getData().getAccessToken());
-                        delivery.setRefreshToken(resObject.getData().getRefreshToken());
-                        delivery.setExpiresIn(resObject.getData().getExpireIn());
-                        delivery.setCreateTime(new Date());
-                        iShopDeliveryBindService.updateById(delivery);
-                    }
-                }
-            }
-        } catch (Exception e) {
-            log.error("闪送刷新token定时任务出现异常", e);
-            e.printStackTrace();
-        }
-    }
 
     /**
      * 根据门店id查询提交的运力
@@ -439,7 +397,8 @@ public class ShopDeliveryServiceImpl extends ServiceImpl<ShopDeliveryMapper, Sho
 
         // 查询余额
         queryAmount.setMerchantId(delivery.getThirdShopId());
-        ResObject<AmountResultVo> res = dadaClient.queryAmount(queryAmount);
+        queryAmount.setLbClient(DeliveryTypeEnums.DADA.getName());
+        ResObject<AmountResultVo> res = client.queryAmount(queryAmount);
         if(res.getCode().intValue()==0){
             BigDecimal balanceAmount = res.getData().getBalanceAmount();
             delivery.setBalance(balanceAmount);

+ 15 - 519
lb-module/src/main/java/com/ydd/module/service/impl/ShopServiceImpl.java

@@ -1,43 +1,27 @@
 package com.ydd.module.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydd.common.core.domain.entity.SysUser;
-import com.ydd.common.core.page.PageResult;
-import com.ydd.common.enums.DeliveryTypeEnums;
 import com.ydd.common.enums.UserTypeEnums;
-import com.ydd.common.exception.CustomException;
-import com.ydd.common.utils.SnCodeUtils;
-import com.ydd.ecloud.core.utils.JsonMapper;
 import com.ydd.module.domain.*;
-import com.ydd.module.dto.*;
-import com.ydd.module.enums.*;
-import com.ydd.module.expection.CustomAppException;
+import com.ydd.module.dto.DeliveryDto;
+import com.ydd.module.dto.ShopDto;
+import com.ydd.module.enums.MemberTypeEnum;
+import com.ydd.module.enums.PackageCityConfigPackageTypeEnum;
 import com.ydd.module.expection.CustomWebException;
 import com.ydd.module.mapper.ShopMapper;
 import com.ydd.module.request.ShopBindRulePackageRequest;
 import com.ydd.module.service.*;
-import com.ydd.third.common.utils.AddressLngLatExchanger;
-import com.ydd.third.common.vo.ResObject;
-import com.ydd.third.delivery.Client;
-import com.ydd.third.delivery.vo.shop.ShopResultVo;
-import com.ydd.third.delivery.vo.shop.ShopVo;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.compress.utils.Lists;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import org.apache.commons.lang3.StringUtils;
 
 import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.stream.Collectors;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
 
 /**
  * 商家门店Service业务层处理
@@ -46,7 +30,6 @@ import java.util.stream.Collectors;
  * @date 2021-02-01
  */
 @Service
-@Slf4j
 public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements IShopService {
 
     @Resource
@@ -70,21 +53,6 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements IS
     @Resource
     private IPackageCommissionService iPackageCommissionService;
 
-    @Resource
-    private IPackageFreightService iPackageFreightService;
-
-    @Resource
-    private IShopThirdService iShopThirdService;
-
-    @Resource
-    private IShopDeliveryService iShopDeliveryService;
-
-    @Resource
-    private IDspDeliveryService iDspDeliveryService;
-
-    @Resource
-    private Client deliveryClient;
-
     @Override
     public List<Shop> queryList(Shop shop) {
         LambdaQueryWrapper<Shop> lqw = Wrappers.lambdaQuery();
@@ -188,8 +156,8 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements IS
     }
 
     @Override
-    public List<ShopDto> findList(Long merchantId,Long shopId) {
-        return baseMapper.findList(merchantId,shopId);
+    public List<ShopDto> findList(Long merchantId) {
+        return baseMapper.findList(merchantId);
     }
 
     @Override
@@ -219,11 +187,6 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements IS
     }
 
     @Override
-    public List<Long> findShopIdByMerchantId(List<Long> merchantIds) {
-        return baseMapper.findShopIdByMerchantId(merchantIds);
-    }
-
-    @Override
     public List<Integer> findByMerchantId(Integer merchantId) {
         return baseMapper.findByMerchantId(merchantId);
     }
@@ -335,475 +298,8 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements IS
     }
 
     @Override
-    public List<ShopBindDto> findListByMerchantId(Long merchantId) {
-        return baseMapper.findListByMerchantId(merchantId);
-    }
-
-    @Override
-    public List<ShopBindDto> findListById(Long shopId) {
-        return baseMapper.findListById(shopId);
-    }
-
-    @Override
-    public List<Long> getIdListByFreightPackageId(Long freightPackageId) {
-        List<Long> merchantIds =  baseMapper.getIdListByFreightPackageId(freightPackageId);
-        return CollectionUtils.isNotEmpty(merchantIds) ? merchantIds : Lists.newArrayList();
-    }
-
-    @Override
-    public List<DadaDspMerchantShopInfoDto> queryShopListByMerchantId(DadaDspMerchantShopListQuery shopListQuery) {
-        return baseMapper.queryShopListByMerchantId(shopListQuery);
-    }
-
-    @Override
-    public PageResult queryDadaShopList(DadaShopListQuery listQuery, SysUser user) {
-        if (UserTypeEnums.DADA_DELIVERY_RAP.getCode().equals(user.getType())
-                || UserTypeEnums.DADA_DELIVERY.getCode().equals(user.getType())) {
-            listQuery.setDadaDspId(user.getDadaDspId());
-        }
-        if (UserTypeEnums.DADA_MERCHANT.getCode().equals(user.getType())) {
-            Merchant merchant = iMerchantService.findByMobile(user.getPhonenumber());
-            listQuery.setMerchantId(merchant != null ? merchant.getId() : null);
-        }
-        if (listQuery.getFreightPackageId() != null) {
-            PackageFreight packageFreight = iPackageFreightService.getById(listQuery.getFreightPackageId());
-            if (packageFreight != null) {
-                listQuery.setDimension(packageFreight.getDimension());
-            }
-        }
-        Page<DadaShopListDto> page = baseMapper.queryDadaShopList(listQuery, new Page<>(listQuery.getPageNum(), listQuery.getPageSize()));
-        List<DadaShopListDto> list = page.getRecords();
-        for (DadaShopListDto shopListDto : list) {
-            // 门店运费包
-            PackageFreight packageFreight = iPackageFreightService.getById(shopListDto.getFreightPackageId());
-            int dimension = 2;
-            if (packageFreight == null) {
-                // 商户运费包
-                packageFreight = iPackageFreightService.getById(shopListDto.getMerchantFreightPackageId());
-                dimension = 1;
-            }
-            if (packageFreight == null) {
-                // 全国运费包
-                Optional<PackageFreight> first = iPackageFreightService.list(new QueryWrapper<PackageFreight>()
-                        .eq("dimension", PackageFreightDimensionEnum.NORMAL.getType())
-                        .eq("dada_dsp_id", user.getDadaDspId())
-                        .eq("deleted", 0)
-                        .orderByDesc("id")).stream().findFirst();
-                if (first.isPresent()) {
-                    packageFreight = first.get();
-                    dimension = 0;
-                }
-            }
-            shopListDto.setFreightPackageName(packageFreight == null ? "" : packageFreight.getName());
-            shopListDto.setDimensionName(packageFreight != null ? PackageFreightDimensionEnum.getNameByType(dimension) : "");
-        }
-        return new PageResult(page);
-    }
-
-    @Override
-    public List<Merchant> queryDadaMerchantList(Long dadaDspId) {
-        LambdaQueryWrapper<Merchant> lqw = Wrappers.lambdaQuery();
-        if (dadaDspId != null && dadaDspId != 0){
-            lqw.eq(Merchant::getDadaDspId ,dadaDspId);
-        }
-        lqw.orderByDesc(Merchant::getId);
-        return iMerchantService.list(lqw);
-    }
-
-    @Override
-    public boolean bindFreightPackage(DadaDspBindFreightQuery bindFreightQuery) {
-        int result = baseMapper.update(null,
-                new UpdateWrapper<Shop>()
-                        .set("freight_package_id", bindFreightQuery.getPackageId())
-                        .eq("id", bindFreightQuery.getShopId()));
-        return result == 1;
-    }
-
-    @Transactional
-    @Override
-    public boolean saveDadaShop(DadaShopAddQuery shopReq, SysUser user) {
-        if (StringUtils.isBlank(shopReq.getProvinceName())
-                || StringUtils.isBlank(shopReq.getCityName())
-                || StringUtils.isBlank(shopReq.getDistrictName())
-                || StringUtils.isBlank(shopReq.getAddress())
-                || StringUtils.isBlank(shopReq.getStreet())) {
-            throw new CustomWebException("省市区详细地址、门牌号不可为空!");
-        }
-        if (StringUtils.isBlank(shopReq.getName())){
-            throw new CustomWebException("门店名称不能为空!");
-        }
-        if (StringUtils.isBlank(shopReq.getContactName())){
-            throw new CustomWebException("联系人名称不能为空!");
-        }
-        if (StringUtils.isBlank(shopReq.getMobile()) || shopReq.getMobile().length() != 11) {
-            throw new CustomException("联系电话不可为空, 且长度为11位!");
-        }
-        Merchant merchant = iMerchantService.getById(shopReq.getMerchantId());
-        if (merchant == null) {
-            throw new CustomAppException("商家不存在!");
-        }
-        if (merchant.getStatus().equals(MerchantStatusEnum.STOP.status)) {
-            throw new CustomAppException("该商家已禁用!");
-        }
-        if (merchant.getStatus().equals(MerchantStatusEnum.TO_BE_CERTIFIED.status)) {
-            throw new CustomAppException("请等待商家通过认证!");
-        }
-        Long categoryId = merchant.getCategoryId();
-        if (null != shopReq.getCategoryId()){
-            categoryId = shopReq.getCategoryId();
-        }
-        // 根据详细地址获取经纬度等信息
-        String address = shopReq.getProvinceName() + shopReq.getCityName() + shopReq.getDistrictName() + shopReq.getAddress() + shopReq.getStreet();
-        Map<String, Object> lngLanMap = AddressLngLatExchanger.addressToLngAndLag(address);
-        if (lngLanMap == null || lngLanMap.get("lat") == null || lngLanMap.get("lng") == null) {
-            throw new CustomWebException("解析地址经纬度失败!");
-        }
-        shopReq.setLat(String.valueOf(lngLanMap.get("lat")));
-        shopReq.setLng(String.valueOf(lngLanMap.get("lng")));
-        shopReq.setCityCode(String.valueOf(lngLanMap.get("cityCode")));
-
-        Shop shop = this.saveOrUpdateShop(shopReq, null, categoryId, merchant.getId());
-
-        Member member = iMemberService.findOne(merchant.getId());
-        // 默认第一次创建的门店设为商家默认门店
-        if (member != null && member.getShopId() == null) {
-            member.setShopId(shop.getId());
-            boolean memberUpdate = iMemberService.updateById(member);
-            if (!memberUpdate) {
-                throw new CustomAppException("用户默认门店变更失败!");
-            }
-        }
-        MerchantCategory category = iMerchantCategoryService.getById(categoryId);
-        if (category == null){
-            throw new CustomAppException("门店分类不存在!");
-        }
-        // 创建三方门店,如果通过自动绑定该运力
-        ShopVo shopVo = this.createShopVo(shop, category.getDadaProductType());
-        log.info("门店信息:{}", JsonMapper.nonEmptyMapper().toJson(shopVo));
-        ResObject<ShopResultVo> res = deliveryClient.createShop(shopVo);
-        log.info("创建三方门店返回结果: {}", JsonMapper.nonEmptyMapper().toJson(res));
-
-        DspDelivery dspDelivery = iDspDeliveryService.findOne(DeliveryTypeEnums.DADA.getType());
-        ShopDelivery delivery = new ShopDelivery();
-        delivery.setDeliveryId(dspDelivery.getId());
-        delivery.setMerchantId(shop.getMerchantId());
-        delivery.setShopId(shop.getId());
-        if (res.getCode() == 0) {
-            ShopResultVo shopResultVo = res.getData();
-            String shopId = shopResultVo.getShopId();
-            delivery.setBindStatus(BindStatusEnum.BIND.getStatus());
-            delivery.setThirdShopId(shopId);
-        } else {
-            delivery.setAuthMsg(res.getMsg());
-        }
-        boolean result2 = iShopDeliveryService.save(delivery);
-        if (!result2) {
-            throw new CustomWebException("保存门店对应第三方运力信息失败!");
-        }
-
-        this.saveShopThird(shopReq, delivery.getDeliveryId(), shop.getId());
-        return true;
-    }
-
-    private void saveShopThird(DadaShopAddQuery shopReq, Long deliveryId, Long shopId) {
-        // 存lb_shop_third表中
-        ShopThird shopThird = new ShopThird();
-        shopThird.setShopId(shopReq.getId());
-        shopThird.setAddress(shopReq.getAddress());
-        shopThird.setContactName(shopReq.getContactName());
-        shopThird.setLat(shopReq.getLat());
-        shopThird.setLng(shopReq.getLng());
-        shopThird.setCityCode(shopReq.getCityCode());
-        shopThird.setMobile(shopReq.getMobile());
-        shopThird.setName(shopReq.getName());
-        shopThird.setStreet(shopReq.getStreet());
-        shopThird.setDeliveryId(deliveryId);
-        shopThird.setShopId(shopId);
-        shopThird.setProvinceName(shopReq.getProvinceName());
-        shopThird.setCityName(shopReq.getCityName());
-        shopThird.setDistrictName(shopReq.getDistrictName());
-        boolean result = iShopThirdService.saveOrUpdate(shopThird);
-        if (!result) {
-            throw new CustomWebException("保存门店对应第三方门店信息失败!");
-        }
-    }
-
-    private Shop saveOrUpdateShop(DadaShopAddQuery shopReq, Shop shop, Long categoryId, Long merchantId) {
-        if (shop == null) {
-            shop = new Shop();
-        }
-        if (shop.getId() == null) {
-            shop.setCode(SnCodeUtils.createShopSn());
-        }
-        shop.setAddress(shopReq.getAddress());
-        shop.setStreet(shopReq.getStreet());
-        shop.setCategoryId(categoryId);
-        shop.setContactName(shopReq.getContactName());
-        shop.setLat(shopReq.getLat());
-        shop.setLng(shopReq.getLng());
-        shop.setMerchantId(merchantId);
-        shop.setMobile(shopReq.getMobile());
-        shop.setName(shopReq.getName());
-        shop.setStreet(shopReq.getStreet());
-        shop.setProvinceName(shopReq.getProvinceName());
-        shop.setCityName(shopReq.getCityName());
-        shop.setDistrictName(shopReq.getDistrictName());
-        shop.setCityCode(shopReq.getCityCode());
-        shop.setProvinceId(shopReq.getProvinceId());
-        shop.setCityId(shopReq.getCityId());
-        shop.setDistrictId(shopReq.getDistrictId());
-        boolean result1 = this.saveOrUpdate(shop);
-        if (!result1) {
-            throw new CustomWebException("保存门店信息失败!");
-        }
-        return shop;
-    }
-
-    private ShopVo createShopVo(Shop shop, Integer dadaCategory) {
-        ShopVo shopVo = new ShopVo();
-        shopVo.setLbClient(DeliveryTypeEnums.DADA.getName());
-        /**
-         * 门店名称
-         * 达达:station_name,门店名称,必传
-         * */
-        shopVo.setShopName(shop.getName());
-        /**
-         * 业务类型
-         * 达达:business,必传,业务类型
-         * (食品小吃-1,饮料-2,鲜花-3,文印票务-8,便利店-9,水果生鲜-13,同城电商-19, 医药-20,蛋糕-21,酒品-24,小商品市场-25,服装-26,汽修零配-27,
-         * 数码-28,小龙虾-29,火锅-51,其他-5)
-         */
-        shopVo.setBusiness(dadaCategory);
-        /**
-         * 城市名称
-         * 达达:city_name 必传,城市名称(如,上海)
-         */
-        shopVo.setCityName(shop.getCityName());
-        /**
-         * 区域名称
-         * 达达:area_name 必传,	区域名称(如,浦东新区)
-         */
-        shopVo.setAreaName(shop.getDistrictName());
-        /**
-         * 门店地址
-         * 达达:station_address 必传,门店地址
-         */
-        shopVo.setShopAddress(shop.getAddress()+shop.getStreet());
-        /**
-         *门店经度
-         * 达达:lng 必传,门店经度,店铺经度
-         */
-        shopVo.setShopLng(new BigDecimal(shop.getLng()));
-        /**
-         * 门店纬度
-         * 达达:lat 必传,门店纬度
-         */
-        shopVo.setShopLat(new BigDecimal(shop.getLat()));
-        /**
-         * 联系人姓名
-         * 达达:contact_name 必传 联系人姓名
-         */
-        shopVo.setContactName(shop.getContactName());
-        /**
-         * 联系人电话
-         * 达达:phone 必传,联系人电话
-         */
-        shopVo.setContactPhone(shop.getMobile());
-        return shopVo;
-    }
-
-    @Override
-    public List<Shop> getDadaShopOption(SysUser user) {
-        List<Merchant> merchantList = iMerchantService.list(new QueryWrapper<Merchant>()
-                .eq(user.getDadaDspId() != null, "dada_dsp_id", user.getDadaDspId())
-                .isNotNull(user.getDadaDspId() == null, "dada_dsp_id")
-                .eq("deleted", 0));
-        List<Shop> shopList = Lists.newArrayList();
-        if (CollectionUtils.isNotEmpty(merchantList)) {
-            List<Long> merchantIds = merchantList.stream().map(Merchant::getId).collect(Collectors.toList());
-            shopList = this.list(new QueryWrapper<Shop>()
-                    .in("merchant_id", merchantIds)
-                    .eq("deleted", 0));
-
-        }
-        return shopList;
-    }
-
-    @Override
-    public boolean editDadaShop(DadaShopAddQuery shopReq, SysUser user) {
-        Shop shop = this.getById(shopReq.getId());
-        if (shop == null) {
-            throw new CustomWebException("门店不存在!");
-        }
-        if (StringUtils.isBlank(shopReq.getProvinceName())
-                || StringUtils.isBlank(shopReq.getCityName())
-                || StringUtils.isBlank(shopReq.getDistrictName())
-                || StringUtils.isBlank(shopReq.getAddress())
-                || StringUtils.isBlank(shopReq.getStreet())) {
-            throw new CustomWebException("省市区详细地址、门牌号不可为空!");
-        }
-        if (StringUtils.isBlank(shopReq.getName())){
-            throw new CustomWebException("门店名称不能为空!");
-        }
-        if (StringUtils.isBlank(shopReq.getContactName())){
-            throw new CustomWebException("联系人名称不能为空!");
-        }
-        if (StringUtils.isBlank(shopReq.getMobile()) || shopReq.getMobile().length() != 11) {
-            throw new CustomException("联系电话不可为空, 且长度为11位!");
-        }
-        Merchant merchant = iMerchantService.getById(shopReq.getMerchantId());
-        if (merchant == null) {
-            throw new CustomAppException("商家不存在!");
-        }
-        if (merchant.getStatus().equals(MerchantStatusEnum.STOP.status)) {
-            throw new CustomAppException("该商家已禁用!");
-        }
-        if (merchant.getStatus().equals(MerchantStatusEnum.TO_BE_CERTIFIED.status)) {
-            throw new CustomAppException("请等待商家通过认证!");
-        }
-        Long categoryId = merchant.getCategoryId();
-        if (null != shopReq.getCategoryId()){
-            categoryId = shopReq.getCategoryId();
-        }
-        MerchantCategory category = iMerchantCategoryService.getById(categoryId);
-        if (category == null){
-            throw new CustomAppException("门店分类不存在!");
-        }
-        // 根据详细地址获取经纬度等信息
-        String address = shopReq.getProvinceName() + shopReq.getCityName() + shopReq.getDistrictName() + shopReq.getAddress();
-        Map<String, Object> lngLanMap = AddressLngLatExchanger.addressToLngAndLag(address);
-        if (lngLanMap == null || lngLanMap.get("lat") == null || lngLanMap.get("lng") == null) {
-            throw new CustomWebException("解析地址经纬度失败!");
-        }
-        shopReq.setLat(String.valueOf(lngLanMap.get("lat")));
-        shopReq.setLng(String.valueOf(lngLanMap.get("lng")));
-        shopReq.setCityCode(String.valueOf(lngLanMap.get("cityCode")));
-
-        // 修改门店信息
-        shop = this.saveOrUpdateShop(shopReq, shop, categoryId, merchant.getId());
-
-        DspDelivery dspDelivery = iDspDeliveryService.findOne(DeliveryTypeEnums.DADA.getType());
-        // 修改三方门店信息
-        ShopDelivery delivery = iShopDeliveryService.findOne(shop.getId(), dspDelivery.getId());
-        if (delivery.getThirdShopId() != null) {
-            // 更新
-            ShopVo shopVo = this.editShopVo(shop, category.getDadaProductType(), delivery.getThirdShopId());
-            log.info("门店信息:{}", JsonMapper.nonEmptyMapper().toJson(shopVo));
-            ResObject<ShopResultVo> res = deliveryClient.updateShop(shopVo);
-            log.info("变更三方门店返回结果: {}", JsonMapper.nonEmptyMapper().toJson(res));
-            if (res.getCode() == 0) {//操作成功
-                ShopResultVo shopResultVo = res.getData();
-                String shopId = shopResultVo.getShopId();
-                delivery.setBindStatus(BindStatusEnum.BIND.getStatus());
-                delivery.setThirdShopId(shopId);
-            } else {
-                delivery.setAuthMsg(res.getMsg());
-            }
-            boolean result2 = iShopDeliveryService.updateById(delivery);
-            if (!result2) {
-                throw new CustomWebException("保存门店对应第三方运力信息失败!");
-            }
-        } else {
-            // 新增
-            Shop shop1 = new Shop();
-            BeanUtils.copyProperties(shopReq, shop1);
-            ShopVo shopVo = this.createShopVo(shop1, category.getDadaProductType());
-            log.info("门店信息:{}", JsonMapper.nonEmptyMapper().toJson(shopVo));
-            ResObject<ShopResultVo> res = deliveryClient.createShop(shopVo);
-            log.info("创建三方门店返回结果: {}", JsonMapper.nonEmptyMapper().toJson(res));
-            delivery.setBindStatus(BindStatusEnum.UNBIND.getStatus());
-            if (res.getCode() == 0) {//操作成功
-                ShopResultVo shopResultVo = res.getData();
-                String shopId = shopResultVo.getShopId();//返回的门店id,作保存以作后用
-                delivery.setBindStatus(BindStatusEnum.BIND.getStatus());
-                delivery.setThirdShopId(shopId);
-            } else {
-                delivery.setAuthMsg(res.getMsg());
-            }
-            boolean result2 = iShopDeliveryService.updateById(delivery);
-            if (!result2) {
-                throw new CustomWebException("保存门店对应第三方运力信息失败!");
-            }
-        }
-        this.saveShopThird(shopReq, delivery.getDeliveryId(), shop.getId());
-        return true;
-    }
-
-    private ShopVo editShopVo(Shop shop, Integer dadaCategory, String thirdShopId) {
-        ShopVo shopVo = new ShopVo();
-        shopVo.setLbClient(DeliveryTypeEnums.DADA.getName());
-        /**
-         * 门店编码
-         * 达达:origin_shop_id,门店编码, 必传
-         *
-         */
-        shopVo.setShopId(thirdShopId);
-
-        /**
-         * 门店名称
-         * 达达:station_name,门店名称,需要修改时传入否则为空
-         * */
-        shopVo.setShopName(shop.getName());
-        /**
-         * 业务类型
-         * 达达:business,业务类型,需要修改时传入否则为空
-         * (食品小吃-1,饮料-2,鲜花-3,文印票务-8,便利店-9,水果生鲜-13,同城电商-19, 医药-20,蛋糕-21,酒品-24,小商品市场-25,服装-26,汽修零配-27,
-         * 数码-28,小龙虾-29,火锅-51,其他-5)
-         */
-        shopVo.setBusiness(dadaCategory);
-        /**
-         * 城市名称
-         * 达达:city_name 城市名称(如,上海),需要修改时传入否则为空
-         */
-        shopVo.setCityName(shop.getCityName());
-        /**
-         * 区域名称
-         * 达达:area_name 	区域名称(如,浦东新区),需要修改时传入否则为空
-         */
-        shopVo.setAreaName(shop.getDistrictName());
-        /**
-         * 门店地址
-         * 达达:station_address 门店地址,需要修改时传入否则为空
-         */
-        shopVo.setShopAddress(shop.getAddress());
-        /**
-         *门店经度
-         * 达达:lng 门店经度 需要修改时传入否则为空
-         */
-        shopVo.setShopLng(new BigDecimal(shop.getLng()));
-        /**
-         * 门店纬度
-         * 达达:lat  门店纬度,需要修改时传入否则为空
-         */
-        shopVo.setShopLat(new BigDecimal(shop.getLat()));
-        /**
-         * 联系人姓名
-         * 达达:contact_name  联系人姓名,需要修改时传入否则为空
-         */
-        shopVo.setContactName(shop.getContactName());
-        /**
-         * 联系人电话
-         * 达达:phone 联系人电话,需要修改时传入否则为空
-         */
-        shopVo.setContactPhone(shop.getMobile());
-
-        /**
-         * 门店状态
-         * 达达
-         * 达达:status,门店状态(1-门店激活,0-门店下线),需要修改时传入否则为空
-         */
-        shopVo.setShopStatus(1);
-        return shopVo;
-    }
-
-    @Override
-    public List<ShopDiscountPackageStatisticsDto> getDiscountPackageList(Page page, DiscountPackageStatisticsQuery query) {
-        return baseMapper.getDiscountPackageList(page, query);
-    }
-
-    @Override
-    public List<Shop> getShopByMerchantIds(List<Long> merchantIds) {
-        return baseMapper.getShopByMerchantIds(merchantIds);
+    public List<Shop> getShopByName(String name, Long id) {
+        return baseMapper.getShopByName(name, id);
     }
 
 }

+ 7 - 0
lb-module/src/main/resources/mapper/module/ShopDeliveryConfigMapper.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ydd.module.mapper.ShopDeliveryConfigMapper">
+
+</mapper>

+ 7 - 162
lb-module/src/main/resources/mapper/module/shopMapper.xml

@@ -35,11 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         from
         lb_shop
         where
-        merchant_id = #{merchantId}
-        <if test="shopId != null">
-            and id = #{shopId}
-        </if>
-        and deleted = 0 and status = 1
+        merchant_id = #{merchantId} and deleted = 0 and status = 1
     </select>
     <select id="findDeliveryList" resultType="com.ydd.module.dto.DeliveryDto">
         select
@@ -140,165 +136,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         AND deleted = 0
     </select>
 
-    <select id="findListByMerchantId" resultType="com.ydd.module.dto.ShopBindDto">
-        select
-            id as shopId,
-            name as shopName
-        from
-        lb_shop
-        where
-        merchant_id = #{merchantId} and deleted = 0
-    </select>
-
-    <select id="findListById" resultType="com.ydd.module.dto.ShopBindDto">
-        select
-            id as shopId,
-            name as shopName
-        from
-        lb_shop
-        where
-        id = #{shopId} and deleted = 0
-    </select>
-
-    <select id="getIdListByFreightPackageId" resultType="java.lang.Long">
-        SELECT id FROM lb_shop
-        WHERE freight_package_id = #{freightPackageId} AND deleted = 0
-    </select>
-
-    <select id="queryShopListByMerchantId" resultType="com.ydd.module.dto.DadaDspMerchantShopInfoDto">
-        select
-            id,
-            name as shopName,
-            contact_name,
-            mobile as contactMobile,
-            province_name,
-            city_name,
-            district_name,
-            address,
-            street,
-            create_time,
-            status
-        from lb_shop
-        where merchant_id = #{params.merchantId}
-        <if test="params.name != null and params.name != ''">
-            and name like concat('%', #{params.name}, '%')
-        </if>
-        <if test="params.contactName != null and params.contactName != ''">
-            and contact_name like concat('%', #{params.contactName}, '%')
-        </if>
-        <if test="params.mobile != null and params.mobile != ''">
-            and mobile like concat('%', #{params.mobile}, '%')
-        </if>
-        <if test="params.startTime != null and params.startTime != ''">
-            AND create_time >= #{params.startTime}
-        </if>
-        <if test="params.endTime != null and params.startTime != ''">
-            AND #{params.endTime} >= create_time
-        </if>
-        order by id desc
-    </select>
-
-    <select id="queryDadaShopList" resultType="com.ydd.module.dto.DadaShopListDto">
-        select
-            s.id,
-            s.name,
-            s.code,
-            s.type,
-            s.contact_name,
-            s.mobile,
-            s.create_time,
-            s.status,
-            s.freight_package_id,
-            m.freight_package_id as merchantFreightPackageId,
-            m.merchant_name,
-            ifnull(lm.amount, 0) as amount,
-            mc.name as categoryName
-        from lb_shop s
-        left join lb_merchant m on s.merchant_id = m.id
-        left join lb_member lm on lm.merchant_id = m.id and member_type = 2
-        left join lb_merchant_category mc on s.category_id = mc.id
-        where 1 = 1 and m.dada_dsp_id is not null
-        <if test="params.dadaDspId != null and params.dadaDspId != ''">
-            and lm.dada_dsp_id = #{params.dadaDspId}
-        </if>
-        <if test="params.name != null and params.name != ''">
-            and s.name like concat('%', #{params.name}, '%')
-        </if>
-        <if test="params.mobile != null and params.mobile != ''">
-            and s.mobile like concat('%', #{params.mobile}, '%')
-        </if>
-        <if test="params.merchantId != null and params.merchantId != ''">
-            AND s.merchant_id = #{params.merchantId}
-        </if>
-        <if test="params.categoryId != null and params.categoryId != ''">
-            AND s.category_id = #{params.categoryId}
-        </if>
-        <if test="params.startTime != null and params.startTime != ''">
-            AND s.create_time >= #{params.startTime}
-        </if>
-        <if test="params.endTime != null and params.startTime != ''">
-            AND #{params.endTime} >= s.create_time
-        </if>
-        <if test="params.amountStart != null and params.amountStart != ''">
-            AND lm.amount >= #{params.amountStart}
-        </if>
-        <if test="params.amountEnd != null and params.amountEnd != ''">
-            AND #{params.amountEnd} >= lm.amount
-        </if>
-        <if test="params.freightPackageId != null and params.freightPackageId != ''">
-            <if test="params.dimension != null">
-                <if test="params.dimension == 0">
-                    AND s.freight_package_id is null AND m.freight_package_id is null
-                </if>
-                <if test="params.dimension == 1">
-                    AND m.freight_package_id = #{params.freightPackageId} AND s.freight_package_id is null
-                </if>
-                <if test="params.dimension == 2">
-                    AND s.freight_package_id = #{params.freightPackageId}
-                </if>
-            </if>
-        </if>
-        order by s.id desc
-    </select>
-
-    <select id="getDiscountPackageList" resultType="com.ydd.module.dto.ShopDiscountPackageStatisticsDto">
-        SELECT
-            s.city_name,
-            s.district_name,
-            s.name as shopName,
-            d.name as packageName,
-            a.name as agentName
-        FROM
-            lb_shop s
-            JOIN lb_package_discount d ON s.package_discount_id = d.id
-            JOIN lb_merchant m ON s.merchant_id = m.id
-            JOIN lb_agent a ON m.agent_id = a.id
-        WHERE 1 = 1
-        <if test="params.shopName != null and params.shopName != ''">
-            AND s.name like concat('%', #{params.shopName}, '%')
-        </if>
-        <if test="params.packageName != null and params.packageName != ''">
-            AND d.name like concat('%', #{params.packageName}, '%')
-        </if>
-    </select>
-
-    <select id="findShopIdByMerchantId" resultType="java.lang.Long">
-        SELECT id FROM lb_shop WHERE 1 = 1
-        AND deleted = 0
-        AND merchant_id IN
-        <foreach collection="merchantIds" index="index" item="merchantId" open="(" separator="," close=")">
-            #{merchantId}
-        </foreach>
-    </select>
-
-    <select id="getShopByMerchantIds" resultType="com.ydd.module.domain.Shop">
-        SELECT id, merchant_id
+    <select id="getShopByName" resultType="com.ydd.module.domain.Shop">
+        SELECT id
         FROM lb_shop
         WHERE deleted = 0
-        AND merchant_id IN
-        <foreach collection="merchantIds" index="index" item="merchantId" open="(" separator="," close=")">
-            #{merchantId}
-        </foreach>
+        AND `name` = #{name}
+        <if test="id != null">
+            AND id != #{id}
+        </if>
     </select>
 
 </mapper>