Przeglądaj źródła

门店档案重构

jlutt@163.com 2 lat temu
rodzic
commit
fa53a2051c
29 zmienionych plików z 935 dodań i 652 usunięć
  1. 1 7
      conf/esTemplate/storeinfo.json
  2. 8 3
      conf/esTemplate/storeplatform.json
  3. 1 1
      conf/esTemplate/storeplatformrequire.json
  4. 6 19
      conf/script/1000/init/Init_15_Store.groovy
  5. 2 1
      conf/script/1000/orderApi/BE_Order_ProcessRefund_Request.groovy
  6. 0 1
      conf/script/1000/orderApi/BE_Order_SubmitDeliveryInfo_DYLK.groovy
  7. 26 9
      conf/script/1000/scriptFiles/platformCode.json
  8. 6 7
      conf/script/1000/storeApi/BE_Store_BindStorePlatform_Douyin.groovy
  9. 0 1
      conf/script/1000/sync/BE_BusinessOrder_SyncDataBase2ES.groovy
  10. 20 6
      conf/sqlroot/com/dderp/business/dao/StoreDao.dql
  11. 1 0
      ddBusiness/src/main/java/com/dderp/business/dao/StoreDao.java
  12. 4 0
      ddBusiness/src/main/java/com/dderp/business/service/PlatformServiceImpl.java
  13. 475 255
      ddBusiness/src/main/java/com/dderp/business/service/StoreServiceImpl.java
  14. 54 0
      ddBusiness/src/main/java/com/dderp/business/service/SupplierInitImpl.java
  15. 2 2
      ddBusiness/src/main/java/com/dderp/business/service/flycat/OrderSearchServiceImpl.java
  16. 2 0
      ddCommon/src/main/java/com/dderp/common/api/PlatformService.java
  17. 33 24
      ddCommon/src/main/java/com/dderp/common/api/StoreService.java
  18. 24 0
      ddCommon/src/main/java/com/dderp/common/api/SupplierInitService.java
  19. 1 1
      ddCommon/src/main/java/com/dderp/common/base/BaseService.java
  20. 6 117
      ddCommon/src/main/java/com/dderp/common/datas/ESKeys.java
  21. 0 5
      ddCommon/src/main/java/com/dderp/common/datas/RedisKeys.java
  22. 7 0
      ddCommon/src/main/java/com/dderp/common/entity/convert/EntityReproduce.java
  23. 5 2
      ddCommon/src/main/java/com/dderp/common/entity/order/BusinessOrder.java
  24. 33 0
      ddCommon/src/main/java/com/dderp/common/entity/store/StoreBrand.java
  25. 10 12
      ddCommon/src/main/java/com/dderp/common/servlet/file/FileUploadEntity.java
  26. 15 118
      ddCommon/src/main/java/com/dderp/common/servlet/file/FileUploadServlet.java
  27. 113 51
      ddWebCore/src/main/java/com/dderp/webcore/rest/StoreRest.java
  28. 79 9
      ddWebCore/src/main/java/com/dderp/webcore/rest/flycat/OrderRest.java
  29. 1 1
      ddWebCore/src/main/java/com/dderp/webcore/servlet/OrderCallServlet.java

+ 1 - 7
conf/esTemplate/storeinfo.json

@@ -6,13 +6,7 @@
       },
       "loginAccount": {
         "type": "text",
-        "index": "analyzed",
-        "analyzer": "codefull_analyzer",
-        "fields": {
-          "raw": {
-            "type": "keyword"
-          }
-        }
+        "index": "not_analyzed"
       },
       "loginPass": {
         "type": "text",

+ 8 - 3
conf/esTemplate/storeplatform.json

@@ -1,5 +1,8 @@
 {
-  "info": {
+  "storeplatform": {
+    "_parent": {
+      "type": "info"
+    },
     "properties": {
       "id": {
         "type": "long"
@@ -9,7 +12,8 @@
       },
       "platformStoreId": {
         "type": "text",
-        "analyzer": "index_ansj",
+        "index": "analyzed",
+        "analyzer": "codefull_analyzer",
         "fields": {
           "raw": {
             "type": "keyword"
@@ -41,7 +45,8 @@
       },
       "platformCode": {
         "type": "text",
-        "analyzer": "index_ansj",
+        "index": "analyzed",
+        "analyzer": "codefull_analyzer",
         "fields": {
           "raw": {
             "type": "keyword"

+ 1 - 1
conf/esTemplate/storeplatformrequire.json

@@ -1,7 +1,7 @@
 {
   "storeplatformrequire": {
     "_parent": {
-      "type": "info"
+      "type": "storeplatform"
     },
     "properties": {
       "id": {

+ 6 - 19
conf/script/1000/init/Init_15_Store.groovy

@@ -2,11 +2,7 @@ import com.dderp.business.dao.StoreDao
 import com.dderp.common.api.NoSqlKeysService
 import com.dderp.common.datas.ESKeys
 import com.dderp.common.datas.RedisKeys
-import com.dderp.common.entity.store.StoreBrand
-import com.dderp.common.entity.store.StoreInfo
-import com.dderp.common.entity.store.StoreInvoiceInfo
-import com.dderp.common.entity.store.StorePlatform
-import com.dderp.common.entity.store.StorePlatformRequire
+import com.dderp.common.entity.store.*
 import com.dySweetFishPlugin.elasticsearch.ESClient
 import com.dySweetFishPlugin.redis.RedisService
 import com.sweetfish.convert.json.JsonConvert
@@ -25,30 +21,20 @@ static def createRunnable(ESClient esClient, RedisService redisService, NoSqlKey
         esClient.createIndex(keysService.getESKey(ESKeys.ES_DELIVER_STORE_BRAND_INDEX, supplierCode),
                 ESKeys.INDEX_CONFIG,
                 Utility.ofMap(ESKeys.ES_DELIVER_STORE_BRAND_TYPE, "storebrand.json"))
-        redisService.del(keysService.getRedisKey(RedisKeys.KEY_DELIVER_STORE_BRAND, supplierCode))
 
         esClient.createIndex(keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
                 ESKeys.INDEX_CONFIG,
                 Utility.ofMap(ESKeys.ES_DELIVER_STORE_INFO_TYPE, "storeinfo.json",
-                        ESKeys.ES_DELIVER_STORE_INVOICE_INFO_TYPE, "storeinvoiceinfo.json"))
-
-        esClient.createIndex(keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode),
-                ESKeys.INDEX_CONFIG,
-                Utility.ofMap(ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE, "storeplatform.json",
+                        ESKeys.ES_DELIVER_STORE_INVOICE_INFO_TYPE, "storeinvoiceinfo.json",
+                        ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE, "storeplatform.json",
                         ESKeys.ES_DELIVER_STORE_PLATFORM_REQUIRE_TYPE, "storeplatformrequire.json"))
 
-
         RMap params = new RMap()
         params.put("voidFlag", -1)
 
         Ignore_ExecPageFlipper.execute(1000, { PageFlipper p ->
             List<StoreBrand> storeBrandList = storeDao.queryStoreBrandList(params, p, dataSourceId, supplierCode)
             if (!storeBrandList.isEmpty()) {
-                Map<String, String> redisMap = storeBrandList.collectEntries { [String.valueOf(it.getId()), jsonConvert.convertTo(it)] }
-                if (!redisMap.isEmpty()) {
-                    redisService.hmset(keysService.getRedisKey(RedisKeys.KEY_DELIVER_STORE_BRAND, supplierCode), redisMap)
-                }
-
                 BulkRequestBuilder bulkRequest = esClient.getClient().prepareBulk()
                 storeBrandList.each { x ->
                     IndexRequestBuilder indexRequest = esClient.getClient()
@@ -116,7 +102,8 @@ static def createRunnable(ESClient esClient, RedisService redisService, NoSqlKey
                 BulkRequestBuilder bulkRequest = esClient.getClient().prepareBulk()
                 storePlatformList.each { x ->
                     IndexRequestBuilder indexRequest = esClient.getClient()
-                            .prepareIndex(keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE)
+                            .prepareIndex(keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE)
+                            .setParent(String.valueOf(x.idStore))
                             .setId(String.valueOf(x.getId()))
                             .setSource(jsonConvert.convertTo(x), XContentType.JSON)
                     bulkRequest.add(indexRequest)
@@ -137,7 +124,7 @@ static def createRunnable(ESClient esClient, RedisService redisService, NoSqlKey
                 BulkRequestBuilder bulkRequest = esClient.getClient().prepareBulk()
                 storePlatformRequireList.each { x ->
                     IndexRequestBuilder indexRequest = esClient.getClient()
-                            .prepareIndex(keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_PLATFORM_REQUIRE_TYPE)
+                            .prepareIndex(keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_PLATFORM_REQUIRE_TYPE)
                             .setId(String.valueOf(x.getId()))
                             .setParent(String.valueOf(x.idStorePlatform))
                             .setSource(jsonConvert.convertTo(x), XContentType.JSON)

+ 2 - 1
conf/script/1000/orderApi/BE_Order_ProcessRefund_Request.groovy

@@ -105,7 +105,8 @@ class BE_Order_ProcessRefund_Request implements BusinessExecutor<InvokeCallParam
         String rejectReasonCode = invokeOrder["rejectReasonCode"] as String
         String rejectMemo = invokeOrder["rejectMemo"] as String
 
-        RetResult<OrderRefundRequest> requestRetResult = orderSearchService.searchOrderRefundRequest(new RMap<>(ERPUtils.PARAM_SEARCH_ID: idRefundRequest),
+        //groovy 不能直接使用ERPUtils.PARAM_SEARCH_ID,要么直接用字符串,不知道下面的用法是否可以,需要测试一下
+        RetResult<OrderRefundRequest> requestRetResult = orderSearchService.searchOrderRefundRequest(new RMap<>("${ERPUtils.PARAM_SEARCH_ID}": idRefundRequest),
                 currentUser, dataSourceId, supplierCode, null)
         if (!requestRetResult.isSuccess()) return RetResult.<InvokeCallResult> errorT().retinfo(requestRetResult.retinfo)
 

+ 0 - 1
conf/script/1000/orderApi/BE_Order_SubmitDeliveryInfo_DYLK.groovy

@@ -7,7 +7,6 @@ import com.dderp.common.api.flycat.OrderSearchService
 import com.dderp.common.api.flycat.OrderService
 import com.dderp.common.api.flycat.OrderStepService
 import com.dderp.common.datas.ERPModule
-import com.dderp.common.datas.flycat.BusinessOrderStatus
 import com.dderp.common.entity.base.InvokeCallParams
 import com.dderp.common.entity.base.InvokeCallResult
 import com.dderp.common.entity.order.BusinessOrder

+ 26 - 9
conf/script/1000/scriptFiles/platformCode.json

@@ -1,27 +1,44 @@
 [
   {
-    "code": "DYLK",
-    "name": "抖音来客",
-    "kind": 0
-  },
-  {
     "code": "ELM",
     "name": "饿了么",
-    "kind": 0
+    "kind": 0,
+    "sort": 1
+  },
+  {
+    "code": "MTWM",
+    "name": "美团外卖",
+    "kind": 0,
+    "sort": 2
+  },
+  {
+    "code": "ELMLS",
+    "name": "饿了么零售",
+    "kind": 0,
+    "sort": 3
+  },
+  {
+    "code": "DYLK",
+    "name": "抖音来客",
+    "kind": 0,
+    "sort": 4
   },
   {
     "code": "MEITUAN",
     "name": "美团闪购",
-    "kind": 0
+    "kind": 0,
+    "sort": 5
   },
   {
     "code": "SFTC",
     "name": "顺丰同城",
-    "kind": 1
+    "kind": 1,
+    "sort": 30
   },
   {
     "code": "DDPT",
     "name": "达达跑腿",
-    "kind": 1
+    "kind": 1,
+    "sort": 31
   }
 ]

+ 6 - 7
conf/script/1000/storeApi/BE_Store_BindStorePlatform_Douyin.groovy

@@ -69,8 +69,6 @@ class BE_Store_BindStorePlatform_Douyin implements BusinessExecutor<ProcessStrin
 
 
     RetResult<StorePlatform> execute(ProcessStringItem source) {
-        //秒级时间戳,groovy里面不让用system
-        long currentTime = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8))
         String dataSourceId = source.dataSourceId
         long supplierCode = source.supplierCode
         ERPTokenUser currentUser = source.currentUser
@@ -120,19 +118,20 @@ class BE_Store_BindStorePlatform_Douyin implements BusinessExecutor<ProcessStrin
         }
 
 
-        BulkRequestBuilder bulkRequest = esClient.getClient().prepareBulk().setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
+        BulkRequestBuilder bulkRequest = esClient.getClient().prepareBulk().setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
 
         bulkRequest.add(esClient.getClient().prepareIndex(
-                keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE)
+                keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE)
+                .setParent(String.valueOf(storePlatform.idStore))
                 .setId(String.valueOf(storePlatform.getId()))
-                .setSource(jsonConvert.convertTo(storePlatform), XContentType.JSON));
+                .setSource(source.getConvert("storePlatformWriteConvert").convertTo(storePlatform), XContentType.JSON))
 
         storePlatform.getRequireList().forEach(x -> {
             bulkRequest.add(esClient.getClient().prepareIndex(
-                    keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_PLATFORM_REQUIRE_TYPE)
+                    keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_PLATFORM_REQUIRE_TYPE)
                     .setId(String.valueOf(x.getId()))
                     .setParent(String.valueOf(storePlatform.getId()))
-                    .setSource(jsonConvert.convertTo(x), XContentType.JSON));
+                    .setSource(jsonConvert.convertTo(x), XContentType.JSON))
         });
 
         BulkResponse bulkResponse = bulkRequest.get();

+ 0 - 1
conf/script/1000/sync/BE_BusinessOrder_SyncDataBase2ES.groovy

@@ -186,7 +186,6 @@ class BE_BusinessOrder_SyncDataBase2ES implements BusinessExecutor<ProcessString
             }
         })
 
-
         return RetResult.successT()
     }
 }

+ 20 - 6
conf/sqlroot/com/dderp/business/dao/StoreDao.dql

@@ -14,22 +14,36 @@ order by #{orderBy}
 ;
 
 -- [addStoreBrand]
-insert into $table$ (id, brandName, brandLogoUrl, startingPrice,
+insert into $table$
+(id, brandName, brandLogoUrl, startingPrice,
 packagingFee, brandMemo, voidFlag,
 createBy, createTime, createTimeLong,
-updateBy, updateTime, updateTimeLong ) values ( #{id}, #{brandname}, #{brandlogourl}, #{startingprice},
+updateBy, updateTime, updateTimeLong )
+values (
+#{id}, #{brandname}, #{brandlogourl}, #{startingprice},
 #{packagingfee}, #{brandmemo}, #{voidflag},
 #{createby}, #{createtime}, #{createtimelong},
 #{updateby}, #{updatetime}, #{updatetimelong} );
 
 -- [updateStoreBrand]
-update $table$ set brandName = #{brandname},brandLogoUrl = #{brandlogourl},startingPrice = #{startingprice},packagingFee = #{packagingfee},
-brandMemo = #{brandmemo},updateBy = #{updateby},updateTime = #{updatetime},updateTimeLong = #{updatetimelong}
+update $table$ set
+brandName = #{brandname},
+brandLogoUrl = #{brandlogourl},
+startingPrice = #{startingprice},
+packagingFee = #{packagingfee},
+brandMemo = #{brandmemo},
+updateBy = #{updateby},
+updateTime = #{updatetime},
+updateTimeLong = #{updatetimelong}
  where id = #{id};
 
  -- [voidStoreBrand]
- update $table$ set voidFlag = #{voidflag},updateBy = #{updateby},
- updateTime = #{updatetime},updateTimeLong = #{updatetimelong} where id = #{id};
+ update $table$ set
+ voidFlag = #{voidflag},
+ updateBy = #{updateby},
+ updateTime = #{updatetime},
+ updateTimeLong = #{updatetimelong}
+ where id = #{id};
 
  -- [updateBrandLogoUrl]
   update $table$ set brandLogoUrl = #{brandlogourl} where id = #{id};

+ 1 - 0
ddBusiness/src/main/java/com/dderp/business/dao/StoreDao.java

@@ -7,6 +7,7 @@ import org.rex.RMap;
 
 import java.util.List;
 
+@SuppressWarnings("rawtypes")
 public interface StoreDao extends DaoRepository {
     //region 门店品牌档案
     @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)

+ 4 - 0
ddBusiness/src/main/java/com/dderp/business/service/PlatformServiceImpl.java

@@ -69,6 +69,10 @@ public class PlatformServiceImpl extends BaseService implements PlatformService
 
     }
 
+    public List<PlatformInfo> getRedisPlatformList(long supplierCode) {
+        return getRedisDocInfos(keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_INFO, supplierCode), PlatformInfo.class);
+    }
+
     @Override
     public PlatformInfo getPlatformInfo(long idPlatformInfo, boolean withDetail, long supplierCode) {
         PlatformInfo platformInfo = getRedisDocInfo(keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_INFO, supplierCode), String.valueOf(idPlatformInfo), PlatformInfo.class);

+ 475 - 255
ddBusiness/src/main/java/com/dderp/business/service/StoreServiceImpl.java

@@ -1,23 +1,27 @@
 package com.dderp.business.service;
 
 import com.dderp.business.dao.StoreDao;
-import com.dderp.common.api.NoSqlKeysService;
-import com.dderp.common.api.SortBuilderExecutor;
-import com.dderp.common.api.StoreService;
+import com.dderp.common.api.*;
 import com.dderp.common.base.BaseService;
 import com.dderp.common.datas.ERPModule;
 import com.dderp.common.datas.ESKeys;
 import com.dderp.common.entity.base.ProcessIdItem;
 import com.dderp.common.entity.base.ProcessStringItem;
 import com.dderp.common.entity.base.ScriptStringResult;
+import com.dderp.common.entity.convert.EntityReproduce;
+import com.dderp.common.entity.platform.PlatformInfo;
 import com.dderp.common.entity.site.ERPTokenUser;
-import com.dderp.common.entity.store.*;
+import com.dderp.common.entity.store.StoreBrand;
+import com.dderp.common.entity.store.StoreInfo;
+import com.dderp.common.entity.store.StoreInvoiceInfo;
+import com.dderp.common.entity.store.StorePlatform;
 import com.dderp.common.tool.ERPUtils;
 import com.dySweetFishPlugin.elasticsearch.ESClient;
 import com.dySweetFishPlugin.sql.TableIdService;
 import com.dySweetFishPlugin.sql.dao.TunaService;
 import com.dySweetFishPlugin.tool.crypto.EncryptUtil;
 import com.sweetfish.convert.json.JsonConvert;
+import com.sweetfish.convert.json.JsonFactory;
 import com.sweetfish.service.Local;
 import com.sweetfish.service.RetResult;
 import com.sweetfish.source.PageFlipper;
@@ -25,25 +29,33 @@ import com.sweetfish.util.AnyValue;
 import com.sweetfish.util.AutoLoad;
 import com.sweetfish.util.ResourceType;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.lucene.search.join.ScoreMode;
 import org.elasticsearch.action.DocWriteResponse;
-import org.elasticsearch.action.bulk.BulkRequestBuilder;
-import org.elasticsearch.action.bulk.BulkResponse;
 import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.action.support.WriteRequest;
 import org.elasticsearch.action.update.UpdateRequest;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
 import org.elasticsearch.common.xcontent.XContentType;
 import org.elasticsearch.index.query.BoolQueryBuilder;
 import org.elasticsearch.index.query.Operator;
 import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.index.reindex.DeleteByQueryAction;
+import org.elasticsearch.join.query.JoinQueryBuilders;
+import org.elasticsearch.search.aggregations.AggregationBuilders;
+import org.elasticsearch.search.aggregations.bucket.terms.Terms;
+import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
+import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCount;
 import org.elasticsearch.search.sort.SortBuilders;
 import org.elasticsearch.search.sort.SortOrder;
 import org.rex.RMap;
 
 import javax.annotation.Resource;
 import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
 
@@ -63,16 +75,44 @@ public class StoreServiceImpl extends BaseService implements StoreService {
     private NoSqlKeysService keysService;
 
     @Resource
+    private SupplierInitService supplierService;
+
+    @Resource
     private TableIdService tableIdService;
 
     @Resource
     private TunaService tunaService;
 
+    @Resource
+    private PlatformService platformService;
+
+    @Resource
+    JsonFactory jsonRootFactory;
+
     private StoreDao storeDao;
 
     @Resource(name = "property.passwordSalt")
     private String passwordSalt;
 
+    private JsonConvert storeWriteConvert;
+
+    private JsonConvert storePlatformWriteConvert;
+
+    @Override
+    public void init(AnyValue config) {
+        super.init(config);
+
+        final JsonFactory storeChildFactory = jsonRootFactory.createChild();
+        storeChildFactory.register(StoreInfo.class, true, "invoiceInfo", "employeeList", "platformList");
+        storeChildFactory.reloadCoder(StoreInfo.class);
+        this.storeWriteConvert = storeChildFactory.getConvert();
+
+        final JsonFactory storePlatformChildFactory = jsonRootFactory.createChild();
+        storePlatformChildFactory.register(StorePlatform.class, true, "requireList");
+        storePlatformChildFactory.reloadCoder(StorePlatform.class);
+        this.storePlatformWriteConvert = storePlatformChildFactory.getConvert();
+    }
+
     @Override
     public void start(AnyValue config) {
         super.start(config);
@@ -80,17 +120,19 @@ public class StoreServiceImpl extends BaseService implements StoreService {
     }
 
     //region 门店品牌档案
+
     @Override
-    public List<StoreBrand> queryStoreBrandList(RMap params, PageFlipper pageFlipper, long supplierCode) {
-        return searchESList(esClient, jsonConvert,
+    @SuppressWarnings("rawtypes")
+    public List<StoreBrand> queryStoreBrandList(RMap params, PageFlipper pageFlipper, String dataSourceId, long supplierCode) {
+        List<StoreBrand> storeBrandList = searchESList(esClient, jsonConvert,
                 StoreBrand.class,
                 params,
                 ((sd) -> {
                     BoolQueryBuilder qb = QueryBuilders.boolQuery();
                     qb = qb.must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_BRAND_TYPE));
 
-                    if (ERPUtils.mapContainKey(params, "brandName")) {
-                        String platformName = params.getString("brandName");
+                    if (ERPUtils.mapContainKey(params, "keyWord")) {
+                        String platformName = params.getString("keyWord");
                         BoolQueryBuilder qbPlatformName = QueryBuilders.boolQuery()
                                 .should(QueryBuilders.matchQuery("brandName", platformName).analyzer("query_ansj").operator(Operator.AND))
                                 .should(QueryBuilders.termQuery("brandName.number", platformName.toLowerCase()))
@@ -99,7 +141,10 @@ public class StoreServiceImpl extends BaseService implements StoreService {
                     }
 
                     if (ERPUtils.mapContainKey(params, "voidFlag")) {
-                        qb = qb.must(QueryBuilders.termQuery("voidFlag", params.getInt("voidFlag")));
+                        int voidFlag = params.getInt("voidFlag");
+                        if (voidFlag >= 0) {
+                            qb = qb.must(QueryBuilders.termQuery("voidFlag", voidFlag));
+                        }
                     }
 
                     return qb;
@@ -107,15 +152,57 @@ public class StoreServiceImpl extends BaseService implements StoreService {
                 keysService.getESKey(ESKeys.ES_DELIVER_STORE_BRAND_INDEX, supplierCode),
                 pageFlipper,
                 (() -> SortBuilders.fieldSort("id").order(SortOrder.DESC)));
+
+        //region 统计品牌门店数量
+
+        if (!storeBrandList.isEmpty()) {
+
+            storeBrandList.forEach((x) -> {
+                x.setViewLogoImageUrl(supplierService.getFileDownloadUrl(x.getViewLogoImageUrl(), "", dataSourceId, supplierCode));
+                x.setViewWebLogoImageUrl(supplierService.getFileWebDownloadUrl(x.getViewLogoImageUrl(), "", dataSourceId, supplierCode));
+            });
+
+            long[] idBrands = storeBrandList.stream().mapToLong(StoreBrand::getId).toArray();
+
+            BoolQueryBuilder qbChild = QueryBuilders.boolQuery();
+            qbChild = qbChild.must(QueryBuilders.termsQuery("idBrand", idBrands));
+            TermsAggregationBuilder childAggregation = AggregationBuilders.terms("info_Brand").field("idBrand").size(storeBrandList.size());
+            childAggregation.subAggregation(AggregationBuilders.count("sub_count").field("id"));
+
+            SearchResponse childRes = esClient.getClient().prepareSearch(keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode))
+                    .setTypes(ESKeys.ES_DELIVER_STORE_INFO_TYPE)
+                    .setQuery(qbChild)
+                    .addAggregation(childAggregation)
+                    //.setSize(0)
+                    .execute()
+                    .actionGet();
+
+            Terms genders = childRes.getAggregations().get("info_Brand");
+            for (Terms.Bucket bucket : genders.getBuckets()) {
+                ValueCount valueCount = bucket.getAggregations().get("sub_count");
+                storeBrandList.stream().filter((a) -> (a.getId() == Long.parseLong(bucket.getKeyAsString()))).findFirst().ifPresent(brand -> brand.setStoreCount(valueCount.getValue()));
+            }
+        }
+
+
+        //endregion
+
+        return storeBrandList;
     }
 
     @Override
-    public StoreBrand getStoreBrand(long id, long supplierCode) {
-        return this.getESOneInfo(esClient, jsonConvert, StoreBrand.class,
+    public StoreBrand getStoreBrand(long id, String dataSourceId, long supplierCode) {
+        StoreBrand esInfo = this.getESOneInfo(esClient, jsonConvert, StoreBrand.class,
                 String.valueOf(id),
                 keysService.getESKey(ESKeys.ES_DELIVER_STORE_BRAND_INDEX, supplierCode),
                 ESKeys.ES_DELIVER_STORE_BRAND_TYPE,
                 null);
+
+        if (esInfo != null) {
+            esInfo.setViewLogoImageUrl(supplierService.getFileDownloadUrl(esInfo.getViewLogoImageUrl(), "", dataSourceId, supplierCode));
+            esInfo.setViewWebLogoImageUrl(supplierService.getFileWebDownloadUrl(esInfo.getViewLogoImageUrl(), "", dataSourceId, supplierCode));
+        }
+        return esInfo;
     }
 
     @Override
@@ -153,30 +240,6 @@ public class StoreServiceImpl extends BaseService implements StoreService {
             return RetResult.<StoreBrand>errorT().retinfo("创建门店品牌失败");
         }
 
-        return RetResult.<StoreBrand>successT().result(storeBrand);
-    }
-
-    @Override
-    public RetResult<StoreBrand> uploadBrandLogo(long idStoreBrand, String fileLink, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
-        StoreBrand esInfo = this.getStoreBrand(idStoreBrand, supplierCode);
-        if (esInfo == null)
-            return RetResult.<StoreBrand>errorT().retinfo("未找到此门店品牌");
-
-        esInfo.setBrandLogoUrl(fileLink);
-        try {
-            UpdateRequest updateRequest = new UpdateRequest(keysService.getESKey(ESKeys.ES_DELIVER_STORE_BRAND_INDEX, supplierCode),
-                    ESKeys.ES_DELIVER_STORE_BRAND_TYPE, String.valueOf(esInfo.getId()))
-                    .doc(jsonBuilder()
-                            .startObject()
-                            .field("brandLogoUrl", esInfo.getBrandLogoUrl())
-                            .endObject())
-                    .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
-
-            esClient.getClient().update(updateRequest).get();
-        } catch (IOException | InterruptedException | ExecutionException e) {
-            logger.error("修改门店品牌[" + esInfo.getId() + "出错:" + e.getMessage(), e);
-        }
-        storeDao.updateBrandLogoUrl(esInfo, dataSourceId, supplierCode);
         return RetResult.successT();
     }
 
@@ -185,7 +248,7 @@ public class StoreServiceImpl extends BaseService implements StoreService {
         if (StringUtils.isBlank(storeBrand.getBrandName()))
             return RetResult.<StoreBrand>errorT().retinfo("门店品牌名称不可为空");
 
-        StoreBrand esInfo = this.getStoreBrand(storeBrand.getId(), supplierCode);
+        StoreBrand esInfo = this.getStoreBrand(storeBrand.getId(), dataSourceId, supplierCode);
         if (esInfo == null)
             return RetResult.<StoreBrand>errorT().retinfo("未找到此门店品牌");
 
@@ -195,7 +258,7 @@ public class StoreServiceImpl extends BaseService implements StoreService {
                 (a) -> {
                     BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_BRAND_TYPE));
                     qb.must(QueryBuilders.termQuery("brandName.raw", storeBrand.getBrandName()))
-                            .mustNot(QueryBuilders.idsQuery(String.valueOf(storeBrand.getId())));
+                            .mustNot(QueryBuilders.idsQuery(ESKeys.ES_DELIVER_STORE_BRAND_TYPE).addIds(String.valueOf(storeBrand.getId())));
 
                     return qb;
                 },
@@ -204,64 +267,73 @@ public class StoreServiceImpl extends BaseService implements StoreService {
 
         if (checkNameInfo != null) return RetResult.<StoreBrand>errorT().retinfo("已存在同名的门店品牌");
 
-        esInfo.setBrandName(storeBrand.getBrandName());
-        esInfo.setStartingPrice(storeBrand.getStartingPrice());
-        esInfo.setPackagingFee(storeBrand.getPackagingFee());
-        esInfo.setBrandMemo(storeBrand.getBrandMemo());
+        EntityReproduce.storeBrandReproduce.apply(esInfo, storeBrand);
         StoreBrand.update(esInfo, currentUser.getId());
-        try {
-            UpdateRequest updateRequest = new UpdateRequest(keysService.getESKey(ESKeys.ES_DELIVER_STORE_BRAND_INDEX, supplierCode),
-                    ESKeys.ES_DELIVER_STORE_BRAND_TYPE, String.valueOf(esInfo.getId()))
-                    .doc(jsonBuilder()
-                            .startObject()
-                            .field("brandName", esInfo.getBrandName())
-                            .field("startingPrice", esInfo.getStartingPrice())
-                            .field("packagingFee", esInfo.getPackagingFee())
-                            .field("brandMemo", esInfo.getBrandMemo())
-                            .field("updateTimeLong", esInfo.getUpdateTimeLong())
-                            .field("updateBy", esInfo.getUpdateBy())
-                            .endObject())
-                    .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
 
-            esClient.getClient().update(updateRequest).get();
-        } catch (IOException | InterruptedException | ExecutionException e) {
+
+        try (XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()) {
+            xContentBuilder.startObject()
+                    .field("brandName", esInfo.getBrandName())
+                    .field("brandLogoUrl", esInfo.getBrandLogoUrl())
+                    .field("startingPrice", esInfo.getStartingPrice())
+                    .field("packagingFee", esInfo.getPackagingFee())
+                    .field("brandMemo", esInfo.getBrandMemo())
+                    .field("updateTimeLong", esInfo.getUpdateTimeLong())
+                    .field("updateBy", esInfo.getUpdateBy())
+                    .endObject();
+
+            esClient.getClient().prepareUpdate(keysService.getESKey(ESKeys.ES_DELIVER_STORE_BRAND_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_BRAND_TYPE,
+                            String.valueOf(esInfo.getId()))
+                    .setDoc(xContentBuilder)
+                    .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
+                    .get();
+
+            storeDao.updateStoreBrand(esInfo, dataSourceId, supplierCode);
+
+            return RetResult.successT();
+        } catch (IOException e) {
             logger.error("修改门店品牌[" + esInfo.getId() + "出错:" + e.getMessage(), e);
+            return RetResult.<StoreBrand>errorT().retinfo("修改门店品牌[" + esInfo.getId() + "出错:" + e.getMessage());
         }
-        storeDao.updateStoreBrand(esInfo, dataSourceId, supplierCode);
-        return RetResult.successT();
     }
 
     @Override
     public RetResult<StoreBrand> voidStoreBrand(StoreBrand storeBrand, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
-        StoreBrand esInfo = this.getStoreBrand(storeBrand.getId(), supplierCode);
+        StoreBrand esInfo = this.getStoreBrand(storeBrand.getId(), dataSourceId, supplierCode);
         if (esInfo == null) {
             return RetResult.<StoreBrand>errorT().retinfo("未找到此门店品牌");
         }
         esInfo.setVoidFlag(storeBrand.getVoidFlag());
         StoreBrand.update(esInfo, currentUser.getId());
-        try {
-            UpdateRequest updateRequest = new UpdateRequest(keysService.getESKey(ESKeys.ES_DELIVER_STORE_BRAND_INDEX, supplierCode),
-                    ESKeys.ES_DELIVER_STORE_BRAND_TYPE, String.valueOf(esInfo.getId()))
-                    .doc(jsonBuilder()
-                            .startObject()
-                            .field("voidFlag", esInfo.getVoidFlag())
-                            .field("updateTimeLong", esInfo.getUpdateTimeLong())
-                            .field("updateBy", esInfo.getUpdateBy())
-                            .endObject())
-                    .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
 
-            esClient.getClient().update(updateRequest).get();
-        } catch (IOException | InterruptedException | ExecutionException e) {
+        try (XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()) {
+            xContentBuilder.startObject()
+                    .field("voidFlag", esInfo.getVoidFlag())
+                    .field("updateTimeLong", esInfo.getUpdateTimeLong())
+                    .field("updateBy", esInfo.getUpdateBy())
+                    .endObject();
+
+            esClient.getClient().prepareUpdate(keysService.getESKey(ESKeys.ES_DELIVER_STORE_BRAND_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_BRAND_TYPE,
+                            String.valueOf(esInfo.getId()))
+                    .setDoc(xContentBuilder)
+                    .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
+                    .get();
+
+            storeDao.voidStoreBrand(esInfo, dataSourceId, supplierCode);
+
+            return RetResult.successT();
+        } catch (IOException e) {
             logger.error("禁用或启用门店品牌[" + esInfo.getId() + "出错:" + e.getMessage(), e);
+            return RetResult.<StoreBrand>errorT().retinfo("禁用或启用门店品牌[" + esInfo.getId() + "出错:" + e.getMessage());
         }
-        storeDao.voidStoreBrand(esInfo, dataSourceId, supplierCode);
-        return RetResult.successT();
     }
+
     //endregion
 
-    @Override
-    public List<ViewStoreInfo> queryViewStoreInfo(RMap params, PageFlipper pageFlipper, long supplierCode) {
-        Set<Long> idStores = new HashSet<>();
+    //region 门店档案
+
+    @SuppressWarnings("rawtypes")
+    public List<StoreInfo> queryStoreInfo(RMap params, PageFlipper pageFlipper, long supplierCode) {
         List<StoreInfo> storeInfoList = searchESList(esClient, jsonConvert,
                 StoreInfo.class,
                 null,
@@ -269,8 +341,8 @@ public class StoreServiceImpl extends BaseService implements StoreService {
                     BoolQueryBuilder qb = QueryBuilders.boolQuery();
                     qb = qb.must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_INFO_TYPE));
 
-                    if (ERPUtils.mapContainKey(params, "storeName")) {
-                        String storeName = params.getString("storeName");
+                    if (ERPUtils.mapContainKey(params, "keyWord")) {
+                        String storeName = params.getString("keyWord");
                         BoolQueryBuilder qbStoreName = QueryBuilders.boolQuery()
                                 .should(QueryBuilders.matchQuery("storeName", storeName).analyzer("query_ansj").operator(Operator.AND))
                                 .should(QueryBuilders.termQuery("storeName.number", storeName.toLowerCase()))
@@ -304,52 +376,49 @@ public class StoreServiceImpl extends BaseService implements StoreService {
                         qb = qb.must(QueryBuilders.termQuery("contractPhone", phone));
                     }
 
+                    if (ERPUtils.mapContainKey(params, "signPlatformId")) {
+                        //查找开通某个平台的门店
+                        long signPlatformId = params.getLong("signPlatformId");
+                        if (signPlatformId > 0L) {
+                            qb = qb.must(JoinQueryBuilders.hasChildQuery(
+                                    ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE,
+                                    QueryBuilders.boolQuery()
+                                            .must(QueryBuilders.termQuery("idPlatformInfo", signPlatformId))
+                                            .must(QueryBuilders.termQuery("enableStatue", 1)),
+                                    ScoreMode.None
+                            ));
+                        }
+                    }
+
+                    if (ERPUtils.mapContainKey(params, "signNotPlatformId")) {
+                        //查找未开通某个平台的门店
+                        long signPlatformId = params.getLong("signNotPlatformId");
+                        if (signPlatformId > 0L) {
+                            qb = qb.mustNot(JoinQueryBuilders.hasChildQuery(
+                                    ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE,
+                                    QueryBuilders.boolQuery()
+                                            .must(QueryBuilders.termQuery("idPlatformInfo", signPlatformId))
+                                            .must(QueryBuilders.termQuery("enableStatue", 1)),
+                                    ScoreMode.None
+                            ));
+                        }
+                    }
+
                     if (ERPUtils.mapContainKey(params, "voidFlag")) {
                         qb = qb.must(QueryBuilders.termQuery("voidFlag", params.getInt("voidFlag")));
                     }
 
                     return qb;
                 }),
-                ((op) -> {
-                    idStores.add(op.getId());
-                }),
                 keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
                 pageFlipper,
                 (() -> SortBuilders.fieldSort("id").order(SortOrder.DESC))
         );
-
-        List<ViewStoreInfo> viewStoreInfoList = new ArrayList<>();
-
-        if (idStores.size() > 0) {
-            long[] idStoreArray = idStores.stream().mapToLong(Long::valueOf).toArray();
-            String idStoreStr = idStores.stream().map(String::valueOf).collect(Collectors.joining(","));
-            Map<Long, List<StorePlatform>> storePlatformMap = searchESMapList(idStoreArray, esClient, jsonConvert,
-                    StorePlatform.class,
-                    null,
-                    ((sd) -> {
-                        BoolQueryBuilder qb = QueryBuilders.boolQuery();
-                        qb = qb.must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE))
-                                .must(QueryBuilders.termsQuery("idStore", idStoreStr.split(",")));
-
-                        return qb;
-                    }),
-                    (StorePlatform::getIdStore),
-                    new String[]{keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode)},
-                    (SortBuilderExecutor) null);
-
-            storeInfoList.forEach(x -> {
-                x.setPlatformList(storePlatformMap.get(x.getId()));
-                ViewStoreInfo viewStoreInfo = new ViewStoreInfo(x);
-                viewStoreInfoList.add(viewStoreInfo);
-            });
-        }
-
-
-        return viewStoreInfoList;
+        storeInfoList.forEach((x) -> x.setLoginPass(""));
+        return storeInfoList;
     }
 
-    @Override
-    public ViewStoreInfo getViewStoreInfo(long idStore, long supplierCode, boolean readInvoice, boolean readEmployee, boolean readPlatform) {
+    public StoreInfo getStoreInfo(long idStore, long supplierCode, boolean readInvoice, boolean readEmployee, boolean readPlatform) {
         StoreInfo storeInfo = getESOneInfo(esClient, jsonConvert, StoreInfo.class,
                 String.valueOf(idStore),
                 keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
@@ -363,7 +432,7 @@ public class StoreServiceImpl extends BaseService implements StoreService {
         }
 
         if ((storeInfo != null) && (readEmployee)) { //先不用
-
+            //todo
         }
 
         if ((storeInfo != null) && (readPlatform)) {
@@ -376,13 +445,13 @@ public class StoreServiceImpl extends BaseService implements StoreService {
 
                         return qb;
                     }),
-                    keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode),
+                    keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
                     (SortBuilderExecutor) null
             );
             storeInfo.setPlatformList(platformList);
         }
 
-        return new ViewStoreInfo(storeInfo);
+        return storeInfo;
     }
 
     @Override
@@ -399,19 +468,6 @@ public class StoreServiceImpl extends BaseService implements StoreService {
                 StoreBrand.class,
                 (a) -> {
                     BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_INFO_TYPE));
-                    qb.must(QueryBuilders.termQuery("storeName.raw", storeInfo.getStoreName()));
-
-                    return qb;
-                },
-                keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
-                null);
-
-        if (esInfo != null) return RetResult.<StoreInfo>errorT().retinfo("已存在同名的门店");
-
-        esInfo = this.getESOneInfo(esClient, jsonConvert,
-                StoreBrand.class,
-                (a) -> {
-                    BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_INFO_TYPE));
                     qb.must(QueryBuilders.termQuery("loginAccount.raw", storeInfo.getLoginAccount()));
 
                     return qb;
@@ -431,13 +487,14 @@ public class StoreServiceImpl extends BaseService implements StoreService {
             storeInfo.setLoginPass(EncryptUtil.md5Digest(storeInfo.getLoginAccount() + passwordSalt));
         }
 
-        StoreInfo.create(storeInfo, currentUser.getId());
         storeInfo.setEnableInvoice(0);
+        StoreInfo.create(storeInfo, currentUser.getId());
+
 
         IndexResponse itemResponse = esClient.getClient()
                 .prepareIndex(keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_INFO_TYPE)
                 .setId(String.valueOf(storeInfo.getId()))
-                .setSource(jsonConvert.convertTo(storeInfo), XContentType.JSON)
+                .setSource(storeWriteConvert.convertTo(storeInfo), XContentType.JSON)
                 .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
                 .get();
 
@@ -451,20 +508,240 @@ public class StoreServiceImpl extends BaseService implements StoreService {
     }
 
     @Override
-    public RetResult<ScriptStringResult> generateStoreAuthUrl_Douyin(long idStore, String dataSourceId, long supplierCode) {
-        return this.handleScript("Store_GenerateStoreAuthUrl_Douyin", ERPModule.STORE_API, dataSourceId, supplierCode,
-                () -> {
-                    return ProcessIdItem.newBuilder()
-                            .id(idStore)
-                            .dataSourceId(dataSourceId)
-                            .supplierCode(supplierCode)
-                            .build();
-                });
+    public RetResult<StoreInfo> updateStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
+        if (StringUtils.isBlank(storeInfo.getStoreName()))
+            return RetResult.<StoreInfo>errorT().retinfo("门店名称不可为空");
+
+        StoreInfo esInfo = this.getStoreInfo(storeInfo.getId(), supplierCode, false, false, false);
+        if (esInfo == null) {
+            return RetResult.<StoreInfo>errorT().retinfo("未找到此门店");
+        }
+
+        esInfo.setStoreName(storeInfo.getStoreName());
+        esInfo.setIdBrand(storeInfo.getIdBrand());
+        esInfo.setBrandName(storeInfo.getBrandName());
+        esInfo.setIdStoreType(storeInfo.getIdStoreType());
+        esInfo.setDeliverSettleKind(storeInfo.getDeliverSettleKind());
+        esInfo.setStoreCodeInput(storeInfo.getStoreCodeInput());
+        esInfo.setStoreProvince(storeInfo.getStoreProvince());
+        esInfo.setStoreCity(storeInfo.getStoreCity());
+        esInfo.setStoreDistrict(storeInfo.getStoreDistrict());
+        esInfo.setStoreAddress(storeInfo.getStoreAddress());
+        esInfo.setLocationStr(storeInfo.getLocationStr());
+        esInfo.setContractPhone(storeInfo.getContractPhone());
+        esInfo.setStoreBossId(storeInfo.getStoreBossId());
+        StoreInfo.update(esInfo, currentUser.getId());
+
+        try (XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()) {
+            xContentBuilder.startObject()
+                    .field("storeName", esInfo.getStoreName())
+                    .field("idBrand", esInfo.getIdBrand())
+                    .field("brandName", esInfo.getBrandName())
+                    .field("idStoreType", esInfo.getIdStoreType())
+                    .field("deliverSettleKind", esInfo.getDeliverSettleKind())
+                    .field("storeCodeInput", esInfo.getStoreCodeInput())
+                    .field("storeProvince", esInfo.getStoreProvince())
+                    .field("storeCity", esInfo.getStoreCity())
+                    .field("storeDistrict", esInfo.getStoreDistrict())
+                    .field("storeAddress", esInfo.getStoreAddress())
+                    .field("locationStr", esInfo.getLocationStr())
+                    .field("contractPhone", esInfo.getContractPhone())
+                    .field("storeBossId", esInfo.getStoreBossId())
+                    .field("updateTimeLong", esInfo.getUpdateTimeLong())
+                    .field("updateBy", esInfo.getUpdateBy())
+                    .endObject();
+
+            esClient.getClient().prepareUpdate(keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_INFO_TYPE,
+                            String.valueOf(esInfo.getId()))
+                    .setDoc(xContentBuilder)
+                    .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
+                    .get();
+
+            storeDao.updateStoreInfo(esInfo, dataSourceId, supplierCode);
+
+            return RetResult.successT();
+        } catch (IOException e) {
+            logger.error("修改门店[" + esInfo.getId() + "出错:" + e.getMessage(), e);
+            return RetResult.<StoreInfo>errorT().retinfo("修改门店[" + esInfo.getId() + "出错:" + e.getMessage());
+        }
+    }
+
+    @Override
+    public RetResult<StoreInfo> voidStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
+        StoreInfo esInfo = this.getStoreInfo(storeInfo.getId(), supplierCode, false, false, false);
+        if (esInfo == null) {
+            return RetResult.<StoreInfo>errorT().retinfo("未找到此门店");
+        }
+        esInfo.setVoidFlag(storeInfo.getVoidFlag());
+        StoreInfo.update(esInfo, currentUser.getId());
+
+        try (XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()) {
+            xContentBuilder.startObject()
+                    .field("voidFlag", esInfo.getVoidFlag())
+                    .field("updateTimeLong", esInfo.getUpdateTimeLong())
+                    .field("updateBy", esInfo.getUpdateBy())
+                    .endObject();
+
+            esClient.getClient().prepareUpdate(keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_INFO_TYPE,
+                            String.valueOf(esInfo.getId()))
+                    .setDoc(xContentBuilder)
+                    .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
+                    .get();
+
+            storeDao.voidStoreInfo(esInfo, dataSourceId, supplierCode);
+
+            return RetResult.successT();
+        } catch (IOException e) {
+            logger.error("禁用或启用门店[" + esInfo.getId() + "出错:" + e.getMessage(), e);
+            return RetResult.<StoreInfo>errorT().retinfo("禁用或启用门店[" + esInfo.getId() + "出错:" + e.getMessage());
+        }
     }
 
+    //endregion
+
+    //region 门店平台
+
     @Override
-    public RetResult<StorePlatform> bindStorePlatformDouyin(String requestContent, String dataSourceId, long supplierCode, ERPTokenUser currentUser) {
-        return handleScript("Store_BindStorePlatform_Douyin", ERPModule.STORE_API,
+    @SuppressWarnings("rawtypes")
+    public List<Map<String, String>> queryViewStoreInfo(RMap params, PageFlipper pageFlipper, long supplierCode) {
+        List<Long> idStores = new ArrayList<>();
+        List<StoreInfo> storeInfoList = searchESList(esClient, jsonConvert,
+                StoreInfo.class,
+                null,
+                ((sd) -> {
+                    BoolQueryBuilder qb = QueryBuilders.boolQuery();
+                    qb = qb.must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_INFO_TYPE));
+
+                    if (ERPUtils.mapContainKey(params, "keyWord")) {
+                        String storeName = params.getString("keyWord");
+                        BoolQueryBuilder qbStoreName = QueryBuilders.boolQuery()
+                                .should(QueryBuilders.matchQuery("storeName", storeName).analyzer("query_ansj").operator(Operator.AND))
+                                .should(QueryBuilders.termQuery("storeName.number", storeName.toLowerCase()))
+                                .should(QueryBuilders.matchQuery("storeName.letter", storeName.toLowerCase()).operator(Operator.AND));
+                        qb = qb.must(qbStoreName);
+                    }
+
+                    if (ERPUtils.mapContainKey(params, "idBrand")) {
+                        qb = qb.must(QueryBuilders.termQuery("idBrand", params.getLong("idBrand")));
+                    }
+
+                    if (ERPUtils.mapContainKey(params, "idStoreType")) {
+                        qb = qb.must(QueryBuilders.termQuery("idStoreType", params.getLong("idStoreType")));
+                    }
+
+                    if (ERPUtils.mapContainKey(params, "deliverSettleKind")) {
+                        qb = qb.must(QueryBuilders.termQuery("deliverSettleKind", params.getInt("deliverSettleKind")));
+                    }
+
+                    if (ERPUtils.mapContainKey(params, "storeCodeInput")) {
+                        String storeCodeInput = params.getString("storeCodeInput");
+                        BoolQueryBuilder qbStoreCode = QueryBuilders.boolQuery()
+                                .should(QueryBuilders.matchQuery("storeCodeInput", storeCodeInput).analyzer("query_ansj").operator(Operator.AND))
+                                .should(QueryBuilders.termQuery("storeCodeInput.number", storeCodeInput.toLowerCase()))
+                                .should(QueryBuilders.matchQuery("storeCodeInput.letter", storeCodeInput.toLowerCase()).operator(Operator.AND));
+                        qb = qb.must(qbStoreCode);
+                    }
+
+                    if (ERPUtils.mapContainKey(params, "contractPhone")) {
+                        String phone = params.getString("contractPhone");
+                        qb = qb.must(QueryBuilders.termQuery("contractPhone", phone));
+                    }
+
+                    if (ERPUtils.mapContainKey(params, "signPlatformId")) {
+                        //查找开通某个平台的门店
+                        long signPlatformId = params.getLong("signPlatformId");
+                        if (signPlatformId > 0L) {
+                            qb = qb.must(JoinQueryBuilders.hasChildQuery(
+                                    ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE,
+                                    QueryBuilders.boolQuery()
+                                            .must(QueryBuilders.termQuery("idPlatformInfo", signPlatformId))
+                                            .must(QueryBuilders.termQuery("enableStatue", 1)),
+                                    ScoreMode.None
+                            ));
+                        }
+                    }
+
+                    if (ERPUtils.mapContainKey(params, "signNotPlatformId")) {
+                        //查找未开通某个平台的门店
+                        long signPlatformId = params.getLong("signNotPlatformId");
+                        if (signPlatformId > 0L) {
+                            qb = qb.mustNot(JoinQueryBuilders.hasChildQuery(
+                                    ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE,
+                                    QueryBuilders.boolQuery()
+                                            .must(QueryBuilders.termQuery("idPlatformInfo", signPlatformId))
+                                            .must(QueryBuilders.termQuery("enableStatue", 1)),
+                                    ScoreMode.None
+                            ));
+                        }
+                    }
+
+                    if (ERPUtils.mapContainKey(params, "voidFlag")) {
+                        qb = qb.must(QueryBuilders.termQuery("voidFlag", params.getInt("voidFlag")));
+                    }
+
+                    return qb;
+                }),
+                ((op) -> idStores.add(op.getId())),
+                keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
+                pageFlipper,
+                (() -> SortBuilders.fieldSort("id").order(SortOrder.DESC))
+        );
+
+        List<Map<String, String>> viewStoreInfoList = new ArrayList<>();
+        List<PlatformInfo> platformInfoList = platformService.getRedisPlatformList(supplierCode);
+
+        if (!idStores.isEmpty()) {
+            long[] idStoreArray = ERPUtils.longListToArray(idStores);
+            String idStoreStr = idStores.stream().map(String::valueOf).collect(Collectors.joining(","));
+            Map<Long, List<StorePlatform>> storePlatformMap = searchESMapList(idStoreArray, esClient, jsonConvert,
+                    StorePlatform.class,
+                    null,
+                    ((sd) -> {
+                        BoolQueryBuilder qb = QueryBuilders.boolQuery();
+                        qb = qb.must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE))
+                                .must(QueryBuilders.termsQuery("idStore", idStoreStr.split(",")));
+
+                        return qb;
+                    }),
+                    (StorePlatform::getIdStore),
+                    keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
+                    (SortBuilderExecutor) null);
+
+            storeInfoList.forEach(x -> x.setPlatformList(storePlatformMap.get(x.getId())));
+
+            viewStoreInfoList = storeInfoList.stream().map((x) -> {
+                Map<String, String> mapStoreInfo = new HashMap<>();
+                //这里其实有简便的写法,但列表上无需门店过多信息,手写几个算了
+                mapStoreInfo.put("id", String.valueOf(x.getId()));
+                mapStoreInfo.put("storeName", x.getStoreName());
+                mapStoreInfo.put("brandName", x.getBrandName());
+
+                platformInfoList.forEach((p) -> {
+                    if (x.getPlatformList().stream().anyMatch((s) -> (s.getIdPlatformInfo() == p.getId()) && (s.getEnableStatue() == 1))) {
+                        mapStoreInfo.put("flag_" + p.getPlatformCode(), "1");
+                    } else {
+                        mapStoreInfo.put("flag_" + p.getPlatformCode(), "0");
+                    }
+                });
+
+                return mapStoreInfo;
+            }).collect(Collectors.toList());
+        }
+
+        return viewStoreInfoList;
+    }
+
+    public RetResult<ScriptStringResult> generateStorePlatformAuthUrl(long idStore, String platformCode, String dataSourceId, long supplierCode) {
+        return this.handleScript("Store_GenerateStoreAuthUrl_" + platformCode.toUpperCase(), ERPModule.STORE_API, dataSourceId, supplierCode,
+                () -> ProcessIdItem.newBuilder()
+                        .id(idStore)
+                        .dataSourceId(dataSourceId)
+                        .supplierCode(supplierCode)
+                        .build());
+    }
+
+    public RetResult<StorePlatform> bindStorePlatform(String requestContent, String platformCode, String dataSourceId, long supplierCode, ERPTokenUser currentUser) {
+        return handleScript("Store_BindStorePlatform_" + platformCode.toUpperCase(), ERPModule.STORE_API,
                 dataSourceId, supplierCode,
                 () -> ProcessStringItem.newBuilder()
                         .itemValue(requestContent)
@@ -472,10 +749,59 @@ public class StoreServiceImpl extends BaseService implements StoreService {
                         .supplierCode(supplierCode)
                         .currentUser(currentUser)
                         .build()
+                        .addConvert("storePlatformWriteConvert", storePlatformWriteConvert)
+        );
+    }
+
+    public RetResult<List<StorePlatform>> getStorePlatformList(long idStore, String platformCode, long supplierCode) {
+        PlatformInfo platformInfo = platformService.getPlatformInfoByCode(platformCode, false, supplierCode);
+        if (platformInfo == null) {
+            return RetResult.<List<StorePlatform>>errorT().retinfo("无效的平台编码");
+        }
+
+        List<StorePlatform> storePlatformList = searchESList(esClient, jsonConvert,
+                StorePlatform.class,
+                null,
+                ((sd) -> QueryBuilders.boolQuery()
+                        .must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE))
+                        .must(QueryBuilders.termQuery("idStore", idStore))
+                        .must(QueryBuilders.termQuery("idPlatformInfo", platformInfo.getId()))),
+                keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
+                (() -> SortBuilders.fieldSort("id").order(SortOrder.DESC))
         );
+
+        return RetResult.<List<StorePlatform>>successT().result(storePlatformList);
     }
 
     @Override
+    public StorePlatform getStorePlatformInfo(long id, long supplierCode) {
+        return this.getESOneInfo(esClient, jsonConvert, StorePlatform.class,
+                String.valueOf(id),
+                keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
+                ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE,
+                null);
+    }
+
+    @Override
+    public StorePlatform getStorePlatformByInvokeInfo(String platformStoreId, String platformCode, int platformType, long supplierCode) {
+        return this.getESOneInfo(esClient, jsonConvert, StorePlatform.class,
+                (a) -> {
+                    BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE));
+                    qb.must(QueryBuilders.termQuery("platformStoreId.raw", platformStoreId))
+                            .must(QueryBuilders.termQuery("platformCode.raw", platformCode))
+                            .must(QueryBuilders.termQuery("platformType", platformType));
+
+                    return qb;
+                },
+                keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
+                null);
+    }
+
+    //endregion
+
+    //region 门店发票
+
+    @Override
     public StoreInvoiceInfo getStoreInvoiceInfo(long idStore, long supplierCode) {
         return this.getESOneInfo(esClient, jsonConvert,
                 StoreInvoiceInfo.class,
@@ -490,10 +816,11 @@ public class StoreServiceImpl extends BaseService implements StoreService {
 
     @Override
     public RetResult<StoreInvoiceInfo> configStoreInvoiceInfo(StoreInvoiceInfo invoiceInfo, int enableInvoice, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
-        StoreInfo esStoreInfo = this.getViewStoreInfo(invoiceInfo.getIdStore(), supplierCode, false, false, false).getStoreInfo();
+        StoreInfo esStoreInfo = this.getStoreInfo(invoiceInfo.getIdStore(), supplierCode, false, false, false);
         if (esStoreInfo == null)
             return RetResult.<StoreInvoiceInfo>errorT().retinfo("未找到门店信息");
         esStoreInfo.setEnableInvoice(enableInvoice);
+
         StoreInfo.update(esStoreInfo, currentUser.getId());
         try {
             UpdateRequest updateRequest = new UpdateRequest(
@@ -570,113 +897,6 @@ public class StoreServiceImpl extends BaseService implements StoreService {
         return RetResult.successT();
     }
 
-    @Override
-    public RetResult<StoreInfo> updateStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
-        if (StringUtils.isBlank(storeInfo.getStoreName()))
-            return RetResult.<StoreInfo>errorT().retinfo("门店名称不可为空");
-
-        StoreInfo esInfo = this.getViewStoreInfo(storeInfo.getId(), supplierCode, false, false, false).getStoreInfo();
-        if (esInfo == null) {
-            return RetResult.<StoreInfo>errorT().retinfo("未找到此门店");
-        }
-
-        esInfo.setStoreName(storeInfo.getStoreName());
-        esInfo.setIdBrand(storeInfo.getIdBrand());
-        esInfo.setBrandName(storeInfo.getBrandName());
-        esInfo.setIdStoreType(storeInfo.getIdStoreType());
-        esInfo.setDeliverSettleKind(storeInfo.getDeliverSettleKind());
-        esInfo.setStoreCodeInput(storeInfo.getStoreCodeInput());
-        esInfo.setStoreProvince(storeInfo.getStoreProvince());
-        esInfo.setStoreCity(storeInfo.getStoreCity());
-        esInfo.setStoreDistrict(storeInfo.getStoreDistrict());
-        esInfo.setStoreAddress(storeInfo.getStoreAddress());
-        esInfo.setLocationStr(storeInfo.getLocationStr());
-        esInfo.setContractPhone(storeInfo.getContractPhone());
-        esInfo.setStoreBossId(storeInfo.getStoreBossId());
-        StoreInfo.update(esInfo, currentUser.getId());
-        try {
-            UpdateRequest updateRequest = new UpdateRequest(keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
-                    ESKeys.ES_DELIVER_STORE_INFO_TYPE, String.valueOf(esInfo.getId()))
-                    .doc(jsonBuilder()
-                            .startObject()
-                            .field("storeName", esInfo.getStoreName())
-                            .field("idBrand", esInfo.getIdBrand())
-                            .field("brandName", esInfo.getBrandName())
-                            .field("idStoreType", esInfo.getIdStoreType())
-                            .field("deliverSettleKind", esInfo.getDeliverSettleKind())
-                            .field("storeCodeInput", esInfo.getStoreCodeInput())
-                            .field("storeProvince", esInfo.getStoreProvince())
-                            .field("storeCity", esInfo.getStoreCity())
-                            .field("storeDistrict", esInfo.getStoreDistrict())
-                            .field("storeAddress", esInfo.getStoreAddress())
-                            .field("locationStr", esInfo.getLocationStr())
-                            .field("contractPhone", esInfo.getContractPhone())
-                            .field("storeBossId", esInfo.getStoreBossId())
-                            .field("updateTimeLong", esInfo.getUpdateTimeLong())
-                            .field("updateBy", esInfo.getUpdateBy())
-                            .endObject())
-                    .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
-
-            esClient.getClient().update(updateRequest).get();
-        } catch (IOException | InterruptedException | ExecutionException e) {
-            logger.error("修改门店[" + esInfo.getId() + "出错:" + e.getMessage(), e);
-        }
-        storeDao.updateStoreInfo(esInfo, dataSourceId, supplierCode);
-        return RetResult.successT();
-    }
-
-    @Override
-    public RetResult<StoreInfo> voidStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
-        StoreInfo esInfo = this.getViewStoreInfo(storeInfo.getId(), supplierCode, false, false, false).getStoreInfo();
-        if (esInfo == null) {
-            return RetResult.<StoreInfo>errorT().retinfo("未找到此门店");
-        }
-        esInfo.setVoidFlag(storeInfo.getVoidFlag());
-        StoreInfo.update(esInfo, currentUser.getId());
-        try {
-            UpdateRequest updateRequest = new UpdateRequest(keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
-                    ESKeys.ES_DELIVER_STORE_INFO_TYPE, String.valueOf(esInfo.getId()))
-                    .doc(jsonBuilder()
-                            .startObject()
-                            .field("voidFlag", esInfo.getVoidFlag())
-                            .field("updateTimeLong", esInfo.getUpdateTimeLong())
-                            .field("updateBy", esInfo.getUpdateBy())
-                            .endObject())
-                    .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
-
-            esClient.getClient().update(updateRequest).get();
-        } catch (IOException | InterruptedException | ExecutionException e) {
-            logger.error("禁用或启用门店[" + esInfo.getId() + "出错:" + e.getMessage(), e);
-        }
-        storeDao.voidStoreInfo(esInfo, dataSourceId, supplierCode);
-        return RetResult.successT();
-    }
-
-    //region 门店平台
-
-
-    @Override
-    public StorePlatform getStorePlatformInfo(long id, long supplierCode) {
-        return this.getESOneInfo(esClient, jsonConvert, StorePlatform.class,
-                String.valueOf(id),
-                keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode),
-                ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE,
-                null);
-    }
-
-    @Override
-    public StorePlatform getStorePlatformByInvokeInfo(String platformStoreId, String platformCode, int platformType, long supplierCode) {
-        return this.getESOneInfo(esClient, jsonConvert, StorePlatform.class,
-                (a) -> {
-                    BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE));
-                    qb.must(QueryBuilders.termQuery("platformStoreId.raw", platformStoreId))
-                            .must(QueryBuilders.termQuery("platformCode.raw", platformCode))
-                            .must(QueryBuilders.termQuery("platformType", platformType));
-
-                    return qb;
-                },
-                keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode),
-                null);
-    }
     //endregion
+
 }

+ 54 - 0
ddBusiness/src/main/java/com/dderp/business/service/SupplierInitImpl.java

@@ -49,6 +49,8 @@ import javax.annotation.Priority;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -685,4 +687,56 @@ public class SupplierInitImpl extends BaseService implements SupplierInitService
         ConfigValue downUrlConfig = configService.getRedisConfigValue("OrderDownloadServer", dataSourceId, supplierCode);
         return (downUrlConfig == null) ? outDownloadUrl : downUrlConfig.getConfigValue2();
     }
+
+    /**
+     * 获取文件内网下载地址
+     * 由于直接存入拼接好的下载地址不利于后期修改地址,而且存储字段过长,改为实时获取下载地址
+     * 下面链接未做跨域处理,如需跨域,可参考 <a href="https://note.youdao.com/s/3WoWIIj3">...</a>
+     * @param bucketFileName 文件名,包含目录,比如 productImage/abc.jpg
+     * @param srcFileName    原文件名,比如订单的文件名,用于下载文件时可以更方便的命名
+     * @param dataSourceId   分库
+     * @param supplierCode   分表
+     * @return 下载地址
+     */
+    public String getFileDownloadUrl(String bucketFileName, String srcFileName, String dataSourceId, long supplierCode) {
+        if (StringUtils.isEmpty(bucketFileName)) {
+            return "";
+        }
+
+        ConfigValue downUrlConfig = configService.getRedisConfigValue("OrderDownloadServer", dataSourceId, supplierCode);
+        String httpUrl = (downUrlConfig == null) ? downloadUrl : downUrlConfig.getConfigValue1();
+
+        String url = httpUrl + supplierCode + "/" +
+                bucketFileName;
+        if (StringUtils.isNotBlank(srcFileName)) {
+            url = url + "?filename=" + URLEncoder.encode(srcFileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
+        }
+        return url;
+    }
+
+    /**
+     * 获取文件外网下载地址
+     * 由于直接存入拼接好的下载地址不利于后期修改地址,而且存储字段过长,改为实时获取下载地址
+     *
+     * @param bucketFileName 文件名,包含目录,比如 productImage/abc.jpg
+     * @param srcFileName    原文件名,比如订单的文件名,用于下载文件时可以更方便的命名
+     * @param dataSourceId   分库
+     * @param supplierCode   分表
+     * @return 下载地址
+     */
+    public String getFileWebDownloadUrl(String bucketFileName, String srcFileName, String dataSourceId, long supplierCode) {
+        if (StringUtils.isEmpty(bucketFileName)) {
+            return "";
+        }
+
+        ConfigValue downUrlConfig = configService.getRedisConfigValue("OrderDownloadServer", dataSourceId, supplierCode);
+        String httpUrl = (downUrlConfig == null) ? downloadUrl : downUrlConfig.getConfigValue2();
+
+        String url = httpUrl + supplierCode + "/" +
+                bucketFileName;
+        if (StringUtils.isNotBlank(srcFileName)) {
+            url = url + "?filename=" + URLEncoder.encode(srcFileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
+        }
+        return url;
+    }
 }

+ 2 - 2
ddBusiness/src/main/java/com/dderp/business/service/flycat/OrderSearchServiceImpl.java

@@ -57,7 +57,7 @@ public class OrderSearchServiceImpl extends BaseService implements OrderSearchSe
     /**
      * 查询单个订单信息
      * <br>在groovy里面使用可以按下面的方法调用
-     * <br>RetResult<PrintOrder> orderResult = orderSearchService.searchBusinessOrder(new RMap<>(ERPUtils.PARAM_SEARCH_ID: 100L), currentUser, dataSourceId, supplierCode)
+     * <br>RetResult<PrintOrder> orderResult = orderSearchService.searchBusinessOrder(new RMap<>("${ERPUtils.PARAM_SEARCH_ID}": 100L), currentUser, dataSourceId, supplierCode)
      * <br>或者在java里面封装一个
      * <br> getBusinessOrder(long id)的方法,提供给其它服务调用,写法差不多,简化不了一行代码
      *
@@ -115,7 +115,7 @@ public class OrderSearchServiceImpl extends BaseService implements OrderSearchSe
     /**
      * 多订单查询,无需分页参数,
      * <br>在groovy里面使用可以按下面的方法调用,比如通过多id获取订单
-     * <br>RetResult<List<PrintOrder></PrintOrder>> orderResult = orderSearchService.searchPrintOrderList(new RMap<>(ERPUtils.PARAM_SEARCH_IDS: "1,2,3"), currentUser, dataSourceId, supplierCode)
+     * <br>RetResult<List<PrintOrder></PrintOrder>> orderResult = orderSearchService.searchPrintOrderList(new RMap<>("${ERPUtils.PARAM_SEARCH_IDS}": "1,2,3"), currentUser, dataSourceId, supplierCode)
      * <br>或者在java里面封装一个
      * <br> getPrintOrder(long id)的方法,提供给其它服务调用,写法差不多,简化不了一行代码
      *

+ 2 - 0
ddCommon/src/main/java/com/dderp/common/api/PlatformService.java

@@ -17,6 +17,8 @@ public interface PlatformService extends ScriptService {
     @SuppressWarnings("rawtypes")
     RetResult<List<PlatformInfo>> queryPlatformList(RMap params, PageFlipper pageFlipper, String dataSourceId, long supplierCode);
 
+    List<PlatformInfo> getRedisPlatformList(long supplierCode);
+
     PlatformInfo getPlatformInfo(long idPlatformInfo, boolean withDetail, long supplierCode);
 
     PlatformInfo getPlatformInfoByCode(String platformCode, boolean withDetail, long supplierCode);

+ 33 - 24
ddCommon/src/main/java/com/dderp/common/api/StoreService.java

@@ -9,63 +9,72 @@ import com.sweetfish.util.AutoLoad;
 import org.rex.RMap;
 
 import java.util.List;
+import java.util.Map;
 
 @AutoLoad(value = false)
 public interface StoreService extends ScriptService {
+
     //region 门店品牌档案
-    List<StoreBrand> queryStoreBrandList(RMap params, PageFlipper pageFlipper, long supplierCode);
 
-    StoreBrand getStoreBrand(long id, long supplierCode);
+    @SuppressWarnings("rawtypes")
+    List<StoreBrand> queryStoreBrandList(RMap params, PageFlipper pageFlipper, String dataSourceId, long supplierCode);
 
-    RetResult<StoreBrand> addStoreBrand(StoreBrand storeBrand, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
+    StoreBrand getStoreBrand(long id, String dataSourceId, long supplierCode);
 
-    RetResult<StoreBrand> uploadBrandLogo(long idStoreBrand, String fileLink, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
+    RetResult<StoreBrand> addStoreBrand(StoreBrand storeBrand, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
 
     RetResult<StoreBrand> updateStoreBrand(StoreBrand storeBrand, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
 
     RetResult<StoreBrand> voidStoreBrand(StoreBrand storeBrand, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
+
     //endregion
 
     //region 门店档案
-    List<ViewStoreInfo> queryViewStoreInfo(RMap params, PageFlipper pageFlipper, long supplierCode);
 
-    ViewStoreInfo getViewStoreInfo(long idStore, long supplierCode, boolean readInvoice, boolean readEmployee, boolean readPlatform);
+    @SuppressWarnings("rawtypes")
+    List<StoreInfo> queryStoreInfo(RMap params, PageFlipper pageFlipper, long supplierCode);
+
+    StoreInfo getStoreInfo(long idStore, long supplierCode, boolean readInvoice, boolean readEmployee, boolean readPlatform);
 
     RetResult<StoreInfo> addStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
 
+    RetResult<StoreInfo> updateStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
+
+    RetResult<StoreInfo> voidStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
+
+    //endregion
+
+    //region 门店平台
+
+    @SuppressWarnings("rawtypes")
+    List<Map<String, String>> queryViewStoreInfo(RMap params, PageFlipper pageFlipper, long supplierCode);
+
     /**
-     * 生成门店授权url_抖音来客
-     *
-     * @param idStore
-     * @param dataSourceId
-     * @param supplierCode
-     * @return
+     * 生成门店授权url
      */
-    RetResult<ScriptStringResult> generateStoreAuthUrl_Douyin(long idStore, String dataSourceId, long supplierCode);
+    RetResult<ScriptStringResult> generateStorePlatformAuthUrl(long idStore, String platformCode, String dataSourceId, long supplierCode);
 
+    RetResult<StorePlatform> bindStorePlatform(String requestContent, String platformCode, String dataSourceId, long supplierCode, ERPTokenUser currentUser);
 
-    RetResult<StorePlatform> bindStorePlatformDouyin(String requestContent, String dataSourceId, long supplierCode, ERPTokenUser currentUser);
+    RetResult<List<StorePlatform>> getStorePlatformList(long idStore, String platformCode, long supplierCode);
 
     /**
-     * 获取门店开票信息
+     * 获取已开通平台信息
      */
-    StoreInvoiceInfo getStoreInvoiceInfo(long idStore, long supplierCode);
-
-    RetResult<StoreInvoiceInfo> configStoreInvoiceInfo(StoreInvoiceInfo invoiceInfo, int enableInvoice, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
+    StorePlatform getStorePlatformInfo(long id, long supplierCode);
 
-    RetResult<StoreInfo> updateStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
+    StorePlatform getStorePlatformByInvokeInfo(String platformStoreId, String platformCode, int platformType, long supplierCode);
 
-    RetResult<StoreInfo> voidStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
     //endregion
 
-    //region 门店平台
+    //region 门店发票
 
     /**
-     * 获取已开通平台信息
+     * 获取门店开票信息
      */
-    StorePlatform getStorePlatformInfo(long id, long supplierCode);
+    StoreInvoiceInfo getStoreInvoiceInfo(long idStore, long supplierCode);
 
-    StorePlatform getStorePlatformByInvokeInfo(String platformStoreId, String platformCode, int platformType, long supplierCode);
+    RetResult<StoreInvoiceInfo> configStoreInvoiceInfo(StoreInvoiceInfo invoiceInfo, int enableInvoice, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
 
     //endregion
 

+ 24 - 0
ddCommon/src/main/java/com/dderp/common/api/SupplierInitService.java

@@ -83,4 +83,28 @@ public interface SupplierInitService extends ScriptService {
     String getDownloadRootUrl(String dataSourceId, long supplierCode);
 
     String getWebDownloadRootUrl(String dataSourceId, long supplierCode);
+
+    /**
+     * 获取文件内网下载地址
+     * 由于直接存入拼接好的下载地址不利于后期修改地址,而且存储字段过长,改为实时获取下载地址
+     *
+     * @param bucketFileName 文件名,包含目录,比如 productImage/abc.jpg
+     * @param srcFileName    原文件名,比如订单的文件名,用于下载文件时可以更方便的命名
+     * @param dataSourceId   分库
+     * @param supplierCode   分表
+     * @return 下载地址
+     */
+    String getFileDownloadUrl(String bucketFileName, String srcFileName, String dataSourceId, long supplierCode);
+
+    /**
+     * 获取文件外网下载地址
+     * 由于直接存入拼接好的下载地址不利于后期修改地址,而且存储字段过长,改为实时获取下载地址
+     *
+     * @param bucketFileName 文件名,包含目录,比如 productImage/abc.jpg
+     * @param srcFileName    原文件名,比如订单的文件名,用于下载文件时可以更方便的命名
+     * @param dataSourceId   分库
+     * @param supplierCode   分表
+     * @return 下载地址
+     */
+    String getFileWebDownloadUrl(String bucketFileName, String srcFileName, String dataSourceId, long supplierCode);
 }

+ 1 - 1
ddCommon/src/main/java/com/dderp/common/base/BaseService.java

@@ -1328,7 +1328,7 @@ public abstract class BaseService extends AbstractService {
                                                      Class<T> clazz,
                                                      RMap searchData, QueryBuilderExecutor qbe,
                                                      ToLongFunction<T> tl,
-                                                     String[] index, SortBuilderExecutor... sbe) {
+                                                     String index, SortBuilderExecutor... sbe) {
         QueryBuilder qb = qbe.execute(searchData);
 
         SearchRequestBuilder requestBuilder = esClient.getClient().prepareSearch(index)

+ 6 - 117
ddCommon/src/main/java/com/dderp/common/datas/ESKeys.java

@@ -85,139 +85,28 @@ public class ESKeys {
 
     //endregion
 
-    //region 订单
-
-    public static final String ES_ERP_PRINT_ORDER_INDEX = "es.printorder.index";
-    public static final String ES_ERP_PRINT_ORDER_TYPE = "info";
-    //订单修图处理情况
-    public static final String ES_ERP_ORDER_DISPATCH_ITEM_TYPE = "orderimagedispatchitem";
-    //订单收货地址
-    public static final String ES_ERP_ORDER_SEND_ADDRESS_TYPE = "ordersendaddress";
-    //订单发货通知
-    public static final String ES_ERP_ORDER_DELIVER_INFORM_TYPE = "orderdeliverinform";
-    //订单部件
-    public static final String ES_ERP_ORDER_PART_TYPE = "orderpart";
-    //订单部件参数
-    public static final String ES_ERP_ORDER_PART_PARAMS_TYPE = "orderpartparamvalue";
-    //订单部件工序
-    public static final String ES_ERP_ORDER_PART_PROCESS_TYPE = "orderpartprocess";
-    //订单组版部件
-    public static final String ES_ERP_WORK_PART_TYPE = "workpart";
-    //订单物料
-    public static final String ES_ERP_ORDER_MATERIAL_TYPE = "ordermaterial";
-    //订单预收款申请
-    public static final String ES_ERP_ORDER_PREPAY_TYPE = "orderprepay";
-    //订单应收账款
-    public static final String ES_ERP_ORDER_RECEIVABLE_TYPE = "orderreceivable";
-    //收款记录
-    public static final String ES_ERP_ORDER_CHARGE_DATA_TYPE = "orderchargedata";
-    //订单生命周期表,作为订单子表
-    public static final String ES_ERP_ORDER_LIFECYCLE_TYPE = "orderlifecycle";
-    //订单生命周期数量
-    public static final String ES_ERP_ORDER_LIFECYCLE_COUNT_TYPE = "orderlifecyclecount";
-    //订单成本划分表
-    public static final String ES_ERP_ORDER_COST_ITEM_TYPE = "ordercostitem";
-
-    //发货反馈记录,记作订单子表,使用订单的index
-    public static final String ES_ERP_DELIVERY_FEED_BACK_INFO_TYPE = "deliveryfeedbackinfo";
-
-    public static final String ES_ERP_ORDER_STOCK_ITEM_TYPE = "orderstockitem";
-    public static final String ES_ERP_ORDER_STOCK_LABEL_TYPE = "orderstocklabel";
-
-    //订单脚印
-    public static final String ES_ERP_ORDER_STEP_TYPE = "info";
-    public static final String ES_ERP_ORDER_STEP_INDEX = "es.orderstep.index";
-
-    //endregion
-
-    //region 施工单
-
-    public static final String ES_ERP_PRINTBILL_INDEX = "es.printbill.index";
-    public static final String ES_ERP_PRINTBILL_TYPE = "info";
-
-    public static final String ES_ERP_PRINTBILL_BREED_TYPE = "breed";
-    //施工单生命周期,是版的子表,三级子表结构
-    public static final String ES_ERP_PRINTBILL_LIFECYCLE_TYPE = "printbilllifecycle";
-
-    public static final String ES_ERP_PRINT_BREED_PART_TYPE = "printbreedpart";
-
-    public static final String ES_ERP_MACHINE_BREED_TASK_TYPE = "machinebreedtask";
-
-    public static final String ES_ERP_PRINTBILL_STEP_INDEX = "es.billstep.index";
-    public static final String ES_ERP_PRINTBILL_STEP_TYPE = "info";
-
-    public static final String ES_ERP_PRINTBREED_PROCESS_INDEX = "es.breedprocess.index";
-    public static final String ES_ERP_PRINTBREED_PROCESS_TYPE = "info";
-
-    //endregion
-
-    //region 客户档案
-
-    public static final String ES_ERP_CLIENT_INFO_INDEX = "es.clientinfo.index";
-    public static final String ES_ERP_CLIENT_INFO_TYPE = "info";
-
-    public static final String ES_ERP_CLIENT_RECEIVEADDRESS_INDEX = "es.clientreceiveaddress.index";
-    public static final String ES_ERP_CLIENT_RECEIVEADDRESS_TYPE = "info";
-    //endregion
-
-    //region 辅料
-    public static final String ES_ERP_MATERIALTYPE_INDEX = "es.materialinfotype.index";
-    public static final String ES_ERP_MATERIALTYPE_TYPE = "info";
-    public static final String ES_ERP_MATERIALINFO_INDEX = "es.materialinfo.index";
-    public static final String ES_ERP_MATERIALINFO_TYPE = "info";
-    //endregion
-
-    //region 纸张模块
-    public static final String ES_ERP_PAPERINFO_INDEX = "es.paperinfo.index";
-    public static final String ES_ERP_PAPERINFO_TYPE = "info";
-    public static final String ES_ERP_PAPERTYPE_INDEX = "es.paperinfotype.index";
-    public static final String ES_ERP_PAPERTYPE_TYPE = "info";
-    public static final String ES_ERP_PAPERBASEINFO_INDEX = "es.paperbaseinfo.index";
-    public static final String ES_ERP_PAPERBASEINFO_TYPE = "info";
-    public static final String ES_ERP_PAPERQUOTEINFO_INDEX = "es.paperquoteinfo.index";
-    public static final String ES_ERP_PAPERQUOTEINFO_TYPE = "info";
-
-    //endregion
-
-    //region 外协档案
-    public static final String ES_ERP_OUTASSIST_INFO_INDEX = "es.outassistinfo.index";
-    public static final String ES_ERP_OUTASSIST_INFO_TYPE = "info";
-    //endregion
-
-    //region 供应商档案
-    public static final String ES_ERP_SUPPLIER_INFO_INDEX = "es.supplierInfo.index";
-    public static final String ES_ERP_SUPPLIER_INFO_TYPE = "info";
-    //endregion
-
-    //region 平台档案,包括订单和配送平台
-    public static final String ES_DELIVER_PLATFORM_INFO_INDEX = "es.platforminfo.index";
-    public static final String ES_DELIVER_PLATFORM_INFO_TYPE = "info";
-    //endregion
-
-    //region 平台需求信息档案
-    public static final String ES_DELIVER_PLATFORM_REQUIRE_INDEX = "es.platformrequire.index";
-    public static final String ES_DELIVER_PLATFORM_REQUIRE_TYPE = "info";
-    //endregion
 
     //region 门店品牌档案
+
     public static final String ES_DELIVER_STORE_BRAND_INDEX = "es.storebrand.index";
     public static final String ES_DELIVER_STORE_BRAND_TYPE = "info";
+
     //endregion
 
     //region 门店档案
     public static final String ES_DELIVER_STORE_INFO_INDEX = "es.storeinfo.index";
     public static final String ES_DELIVER_STORE_INFO_TYPE = "info";
     public static final String ES_DELIVER_STORE_INVOICE_INFO_TYPE = "storeinvoiceinfo";
-    //endregion
 
-    //region 门店已开通平台
-    public static final String ES_DELIVER_STORE_PLATFORM_INDEX = "es.storeplatform.index";
-    public static final String ES_DELIVER_STORE_PLATFORM_TYPE = "info";
+    public static final String ES_DELIVER_STORE_PLATFORM_TYPE = "storeplatform";
+
     public static final String ES_DELIVER_STORE_PLATFORM_REQUIRE_TYPE = "storeplatformrequire";
+
     //endregion
 
 
     //region 订单
+
     public static final String ES_DELIVER_BUSINESS_ORDER_INDEX = "es.businesorder.index";
     public static final String ES_DELIVER_BUSINESS_ORDER_TYPE = "info";
     public static final String ES_DELIVER_ORDER_DELIVERY_INFO_TYPE = "orderdeliveryinfo";

+ 0 - 5
ddCommon/src/main/java/com/dderp/common/datas/RedisKeys.java

@@ -298,11 +298,6 @@ public class RedisKeys {
      */
     public static final String KEY_DELIVER_PLATFORM_REQUIRE = "redis.deliver.platformrequire";
 
-    /**
-     * 门店品牌档案
-     */
-    public static final String KEY_DELIVER_STORE_BRAND = "redis.deliver.storebrand";
-
     //region 锁定数据
 
     public static final String KEY_ERP_WORKING_ORDER = "redis.erp.working.order";

+ 7 - 0
ddCommon/src/main/java/com/dderp/common/entity/convert/EntityReproduce.java

@@ -1,5 +1,6 @@
 package com.dderp.common.entity.convert;
 
+import com.dderp.common.entity.store.StoreBrand;
 import com.dderp.common.entity.system.Dept;
 import com.sweetfish.util.Reproduce;
 
@@ -12,4 +13,10 @@ public class EntityReproduce {
             Dept.class,
             (t) -> Arrays.stream(deptIgnoreFields).noneMatch(t::equalsIgnoreCase)
     );
+
+    private static final String[] storeBrandIgnoreFields = new String[]{"id", "voidFlag"};
+    public static final Reproduce<StoreBrand, StoreBrand> storeBrandReproduce = Reproduce.create(StoreBrand.class,
+            StoreBrand.class,
+            (t) -> Arrays.stream(storeBrandIgnoreFields).noneMatch(t::equalsIgnoreCase)
+    );
 }

+ 5 - 2
ddCommon/src/main/java/com/dderp/common/entity/order/BusinessOrder.java

@@ -20,13 +20,13 @@ public class BusinessOrder extends BaseEntity {
 
     @RColumn("ordername")
     @Comment("订单名称--一般是门店名称+订单渠道")
-    @ApiPlace("Express_aaaa")
+    @ApiPlace("/orderOperation/queryOrderList")
     @ApiPlace("Express_bbbbb")
     private String orderName;
 
     @RColumn("ordercode")
     @Comment("订单编号")
-    @ApiPlace("Express_aaaa")
+    @ApiPlace("/orderOperation/queryOrderList")
     private String orderCode;
 
     @RColumn("orderstatus")
@@ -44,10 +44,12 @@ public class BusinessOrder extends BaseEntity {
 
     @RColumn("incomeplatformname")
     @Comment("订单来源平台")
+    @ApiPlace("/orderOperation/queryOrderList")
     private String incomePlatformName;
 
     @RColumn("incomeplatformordercode")
     @Comment("来源平台的订单编号")
+    @ApiPlace("/orderOperation/queryOrderList")
     private String incomePlatformOrderCode;
 
     @RColumn("incomeplatformordertime")
@@ -72,6 +74,7 @@ public class BusinessOrder extends BaseEntity {
 
     @RColumn("storename")
     @Comment("门店名称")
+    @ApiPlace("/orderOperation/queryOrderList")
     private String storeName;
 
     @RColumn("deliverfee")

+ 33 - 0
ddCommon/src/main/java/com/dderp/common/entity/store/StoreBrand.java

@@ -38,6 +38,15 @@ public class StoreBrand extends BaseEntity {
     @RColumn("voidflag")
     private int voidFlag;
 
+    @Comment("冗余下门店数量")
+    private long storeCount;
+
+    @Comment("内网logo显示地址")
+    private String viewLogoImageUrl;
+
+    @Comment("外网logo显示地址")
+    private String viewWebLogoImageUrl;
+
     public long getId() {
         return id;
     }
@@ -93,4 +102,28 @@ public class StoreBrand extends BaseEntity {
     public void setVoidFlag(int voidFlag) {
         this.voidFlag = voidFlag;
     }
+
+    public long getStoreCount() {
+        return storeCount;
+    }
+
+    public void setStoreCount(long storeCount) {
+        this.storeCount = storeCount;
+    }
+
+    public String getViewLogoImageUrl() {
+        return viewLogoImageUrl;
+    }
+
+    public void setViewLogoImageUrl(String viewLogoImageUrl) {
+        this.viewLogoImageUrl = viewLogoImageUrl;
+    }
+
+    public String getViewWebLogoImageUrl() {
+        return viewWebLogoImageUrl;
+    }
+
+    public void setViewWebLogoImageUrl(String viewWebLogoImageUrl) {
+        this.viewWebLogoImageUrl = viewWebLogoImageUrl;
+    }
 }

+ 10 - 12
ddCommon/src/main/java/com/dderp/common/servlet/file/FileUploadEntity.java

@@ -8,6 +8,8 @@ public class FileUploadEntity {
 
     private String srcFileName;
 
+    private String fileLink;
+
     private String url;
 
     private String webUrl;
@@ -17,18 +19,6 @@ public class FileUploadEntity {
     public FileUploadEntity() {
     }
 
-    public FileUploadEntity(String fileName, String url) {
-        this.fileName = fileName;
-        this.url = url;
-        this.code = 0;
-    }
-
-    public FileUploadEntity(String fileName, String url, int code) {
-        this.fileName = fileName;
-        this.url = url;
-        this.code = code;
-    }
-
     public String getFileName() {
         return fileName;
     }
@@ -68,4 +58,12 @@ public class FileUploadEntity {
     public void setWebUrl(String webUrl) {
         this.webUrl = webUrl;
     }
+
+    public String getFileLink() {
+        return fileLink;
+    }
+
+    public void setFileLink(String fileLink) {
+        this.fileLink = fileLink;
+    }
 }

+ 15 - 118
ddCommon/src/main/java/com/dderp/common/servlet/file/FileUploadServlet.java

@@ -1,12 +1,9 @@
 package com.dderp.common.servlet.file;
 
-import com.dderp.common.api.StoreService;
 import com.dderp.common.api.SupplierInitService;
-import com.dderp.common.api.SystemService;
 import com.dderp.common.base.ERPAdminHttpServlet;
 import com.dderp.common.entity.site.ERPTokenUser;
 import com.dderp.common.tool.ERPUtils;
-import com.dySweetFishPlugin.qiniu.QiniuOSSService;
 import com.sweetfish.net.http.*;
 import com.sweetfish.util.AutoLoad;
 import org.apache.commons.lang3.StringUtils;
@@ -15,13 +12,10 @@ import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.*;
-
-import static com.sweetfish.net.Server.RESNAME_SERVER_ROOT;
+import java.util.UUID;
 
 /**
  * Created by jlutt on 2020-07-31
@@ -31,42 +25,29 @@ import static com.sweetfish.net.Server.RESNAME_SERVER_ROOT;
  */
 @AutoLoad(false)
 @WebServlet(value = {"/upload/*"}, comment = "文件上传服务")
+@SuppressWarnings("unused")
 public class FileUploadServlet extends ERPAdminHttpServlet {
 
-    @Resource(name = RESNAME_SERVER_ROOT)
-    String webRootStr;
-
     @Resource(name = "property.bucketFileRoot")
     private String bucketFileRoot;
 
     @Resource
-    SystemService systemService;
-
-    @Resource
     SupplierInitService supplierInitService;
 
-    @Resource
-    private QiniuOSSService qiniuOSSService;
-
-    @Resource
-    StoreService storeService;
-
 
     /**
      * 使用plupload上传大文件,可分块上传
      * 通用文件上传
+     *
      * @param req  http请求
      * @param resp http响应
      * @throws IOException 异常
      */
     @HttpMapping(url = "/upload/bucketFile", auth = true, comment = "通用文件上传")
+    @SuppressWarnings("ResultOfMethodCallIgnored")
     public void uploadBucketFile(HttpRequest req, HttpResponse resp) throws IOException {
         ERPTokenUser currentUser = req.currentUser();
-        long supplierCode = currentUser.getSupplierCode();
         for (MultiPart part : req.multiParts()) {
-            /**
-             * @see D:\\
-             * */
             //plupload会分块上传,name为文件名,chunks为上传总块数,chunk为当前块数
             //如果chunk=0,表示是第一块,此时需要创建文件,其后是在文件末尾添加内容
             //文件名的处理,如果在服务端生成,那么分块的时候还需要保存实际文件名和随机名的生成关系,处理相对麻烦
@@ -99,32 +80,22 @@ public class FileUploadServlet extends ERPAdminHttpServlet {
             InputStream in = part.getInputStream();
 
             if ((chunk == 0) && (chunks > 0)) {
-                if (Files.exists(Paths.get(destFile))) {
+                Path destFilePath = Paths.get(destFile);
+
+                if (Files.exists(destFilePath)) {
                     resp.finish(500, "文件已存在");
                     return;
                 }
 
-                Files.deleteIfExists(Paths.get(destFile));
+                Files.deleteIfExists(destFilePath);
 
                 ERPUtils.createFileFromInStream(destFile, in);
             } else {
                 ERPUtils.appendFileFromInStream(destFile, in);
             }
 
-            String downloadHttpUrl = supplierInitService.getDownloadRootUrl(currentUser.getDataSourceId(), currentUser.getSupplierCode());
-            String webDownloadHttpUrl = supplierInitService.getWebDownloadRootUrl(currentUser.getDataSourceId(), currentUser.getSupplierCode());
-
-            //下面链接未做跨域处理,如需跨域,可参考 https://note.youdao.com/s/3WoWIIj3
-            String downloadUrlStr = downloadHttpUrl + currentUser.getSupplierCode() + "/" +
-                    bucketName + "/" +
-                    fileName;
-            downloadUrlStr = downloadUrlStr + "?filename=" + URLEncoder.encode(srcFileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
+            String fileLink = bucketName + "/" + fileName;
 
-            String webDownloadUrlStr = webDownloadHttpUrl + currentUser.getSupplierCode() + "/" +
-                    bucketName + "/" +
-                    fileName;
-
-            webDownloadUrlStr = webDownloadUrlStr + "?filename=" + URLEncoder.encode(srcFileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
 
             if (chunk == chunks - 1) {
                 //上传完成
@@ -132,92 +103,18 @@ public class FileUploadServlet extends ERPAdminHttpServlet {
             }
 
             FileUploadEntity entity = new FileUploadEntity();
+
             entity.setFileName(fileName);
             entity.setSrcFileName(srcFileName);
-            entity.setUrl(downloadUrlStr);
-            entity.setWebUrl(webDownloadUrlStr);
-            resp.finishJson(entity);
-            return;
-        }
-        resp.finish("success");
-    }
-
-    @HttpMapping(url = "/upload/uploadStoreBrandLogo", auth = true, comment = "门店品牌logo上传")
-    public void uploadStoreBrandLogo(HttpRequest req, HttpResponse resp) throws IOException {
-        ERPTokenUser currentUser = req.currentUser();
-        long supplierCode = currentUser.getSupplierCode();
-        for (MultiPart part : req.multiParts()) {
-            //plupload会分块上传,name为文件名,chunks为上传总块数,chunk为当前块数
-            //如果chunk=0,表示是第一块,此时需要创建文件,其后是在文件末尾添加内容
-            //文件名的处理,如果在服务端生成,那么分块的时候还需要保存实际文件名和随机名的生成关系,处理相对麻烦
-            //系统这里使用plupload配置unique_names属性,将会得到一个不重复的文件名
-            // String fileName = req.getParameter("name");
-            String srcFileName = req.getParameter("srcfilename");
-            long idStoreBrand = req.getLongParameter("idStoreBrand", 0L);
-
-            if (idStoreBrand <= 0) {
-                resp.finish(500, "门店品牌id未指定");
-                return;
-            }
-
-            logger.info(srcFileName);
+            entity.setFileLink(fileLink);
 
-            int chunks = req.getIntParameter("chunks", 0);
-            int chunk = req.getIntParameter("chunk", 0);
+            entity.setUrl(supplierInitService.getFileDownloadUrl(fileLink, "", currentUser.getDataSourceId(), currentUser.getSupplierCode()));
+            entity.setWebUrl(supplierInitService.getFileWebDownloadUrl(fileLink, "", currentUser.getDataSourceId(), currentUser.getSupplierCode()));
 
-            //由于当前orderRoot不在是本地文件夹,先传到本地,再拷贝到
-            File destPath = new File(bucketFileRoot + File.separator +
-                    currentUser.getSupplierCode() + File.separator +
-                    "storeBrand" + File.separator + String.valueOf(idStoreBrand) + File.separator + "logo");
-            if (!destPath.exists()) {
-                destPath.mkdirs();
-            }
-
-            //String destFile = destPath.getCanonicalPath() + File.separator + srcFileName;
-
-            Calendar cal = Calendar.getInstance();
-            int second = cal.get(Calendar.SECOND);
-            int millSecond = cal.get(Calendar.MILLISECOND);
-            int minute = cal.get(Calendar.MINUTE);
-            int hour = cal.get(Calendar.HOUR_OF_DAY);
-            //示例:OB2112100022原图162545954.png
-            String targetFileName = String.valueOf(idStoreBrand) + "logo" + String.valueOf(hour) + String.valueOf(minute) +
-                    String.valueOf(second) + String.valueOf(millSecond) + srcFileName.substring(srcFileName.lastIndexOf("."));
-            String destFile = destPath.getCanonicalPath() + File.separator + targetFileName;
-            InputStream in = part.getInputStream();
-
-            if ((chunk == 0) && (chunks > 0)) {
-                if (Files.exists(Paths.get(destFile))) {
-                    resp.finish(500, "文件已存在");
-                    return;
-                }
-
-                Files.deleteIfExists(Paths.get(destFile));
-
-                ERPUtils.createFileFromInStream(destFile, in);
-            } else {
-                ERPUtils.appendFileFromInStream(destFile, in);
-            }
-
-            String orderDownloadHttpUrl = supplierInitService.getDownloadRootUrl(currentUser.getDataSourceId(), currentUser.getSupplierCode());
-            String downloadUrlStr = orderDownloadHttpUrl + currentUser.getSupplierCode() + "/" +
-                    "storeBrand/" +
-                    String.valueOf(idStoreBrand) + "/" +
-                    "logo" + "/" + targetFileName;
-            if (chunk == chunks - 1) {
-                //扔至后台进行处理
-                //上传完成
-                storeService.uploadBrandLogo(idStoreBrand, downloadUrlStr, currentUser,
-                        currentUser.getDataSourceId(), currentUser.getSupplierCode());
-                logger.info("文件上传完成name:" + req.getParameter("name") + "总块数:" + req.getParameter("chunks"));
-            }
-
-            FileUploadEntity entity = new FileUploadEntity();
-            entity.setFileName(targetFileName);
-            entity.setUrl(downloadUrlStr);
             resp.finishJson(entity);
             return;
         }
         resp.finish("success");
     }
+
 }

+ 113 - 51
ddWebCore/src/main/java/com/dderp/webcore/rest/StoreRest.java

@@ -1,20 +1,19 @@
 package com.dderp.webcore.rest;
 
 import com.dderp.common.api.LoginService;
-import com.dderp.common.api.PlatformService;
 import com.dderp.common.api.StoreService;
 import com.dderp.common.base.BaseService;
 import com.dderp.common.datas.ERPHeader;
-import com.dderp.common.datas.ERPModule;
 import com.dderp.common.datas.HttpCode;
 import com.dderp.common.datas.TokenUserFrom;
 import com.dderp.common.entity.base.ScriptStringResult;
-import com.dderp.common.entity.platform.PlatformInfo;
-import com.dderp.common.entity.platform.PlatformRequire;
 import com.dderp.common.entity.site.ERPTokenUser;
 import com.dderp.common.entity.site.LoginRequest;
 import com.dderp.common.entity.site.LoginResult;
-import com.dderp.common.entity.store.*;
+import com.dderp.common.entity.store.StoreBrand;
+import com.dderp.common.entity.store.StoreInfo;
+import com.dderp.common.entity.store.StoreInvoiceInfo;
+import com.dderp.common.entity.store.StorePlatform;
 import com.dySweetFishPlugin.sql.RMapUtils;
 import com.sweetfish.net.http.*;
 import com.sweetfish.service.Local;
@@ -26,6 +25,7 @@ import org.rex.RMap;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.CompletableFuture;
 
 /**
@@ -36,6 +36,7 @@ import java.util.concurrent.CompletableFuture;
 @AutoLoad(false)
 @Local
 @RestService(name = "store", moduleid = 0, comment = "门店档案模块")
+@SuppressWarnings("rawtypes")
 public class StoreRest extends BaseService {
     @Resource
     private StoreService storeService;
@@ -44,6 +45,7 @@ public class StoreRest extends BaseService {
     private LoginService loginService;
 
     //region 门店品牌档案
+
     @RestMapping(name = "queryStoreBrandList", auth = true, sort = 1, comment = "获取门店品牌档案列表", methods = {"GET", "POST"})
     @WebApiBean(result = true, type = StoreBrand.class)
     public CompletableFuture<RMap> queryStoreBrandList(
@@ -53,21 +55,21 @@ public class StoreRest extends BaseService {
             @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
         return CompletableFuture.supplyAsync(
                 () -> {
-                    List<StoreBrand> resultList = storeService.queryStoreBrandList(searchData, pageFlipper, Long.parseLong(supplierCode));
+                    List<StoreBrand> resultList = storeService.queryStoreBrandList(searchData, pageFlipper, dataSourceId, Long.parseLong(supplierCode));
                     return RMapUtils.successV2(resultList, null, pageFlipper);
                 }, getExecutor()
         );
     }
 
     @RestMapping(name = "getStoreBrand", auth = true, sort = 2, comment = "门店品牌档案", methods = {"GET", "POST"})
-    @WebApiBean(result = true, type = PlatformInfo.class)
+    @WebApiBean(result = true, type = StoreBrand.class)
     public CompletableFuture<RMap> getStoreBrand(
             @RestParam(name = "idStoreBrand", comment = "门店品牌档案id") long idStoreBrand,
             @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
             @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
         return CompletableFuture.supplyAsync(
                 () -> {
-                    StoreBrand resultObj = storeService.getStoreBrand(idStoreBrand, Long.parseLong(supplierCode));
+                    StoreBrand resultObj = storeService.getStoreBrand(idStoreBrand, dataSourceId, Long.parseLong(supplierCode));
                     if (resultObj == null) return RMapUtils.error(HttpCode.BAD_REQUEST.value(), "门店品牌档案不存在");
                     return RMapUtils.successV2(resultObj, null, null);
                 }, getExecutor()
@@ -75,7 +77,7 @@ public class StoreRest extends BaseService {
     }
 
     @RestMapping(name = "addStoreBrand", auth = true, sort = 3, comment = "新增门店品牌", methods = {"POST"})
-    @WebApiBean(result = true, type = StoreBrand.class)
+    @WebApiBean(type = StoreBrand.class)
     public CompletableFuture<RMap> addStoreBrand(
             @RestParam(name = "storeBrand", comment = "门店品牌档案") StoreBrand storeBrand,
             @RestParam(name = "&", comment = "当前用户,不需要传入") ERPTokenUser currentUser,
@@ -91,7 +93,7 @@ public class StoreRest extends BaseService {
     }
 
     @RestMapping(name = "updateStoreBrand", auth = true, sort = 4, comment = "修改门店品牌", methods = {"POST"})
-    @WebApiBean(result = true, type = StoreBrand.class)
+    @WebApiBean(type = StoreBrand.class)
     public CompletableFuture<RMap> updateStoreBrand(
             @RestParam(name = "storeBrand", comment = "门店品牌档案") StoreBrand storeBrand,
             @RestParam(name = "&", comment = "当前用户,不需要传入") ERPTokenUser currentUser,
@@ -107,7 +109,7 @@ public class StoreRest extends BaseService {
     }
 
     @RestMapping(name = "voidStoreBrand", auth = true, sort = 5, comment = "禁用门店品牌档案", methods = {"POST"})
-    @WebApiBean(result = true, type = StoreBrand.class)
+    @WebApiBean(type = StoreBrand.class)
     public CompletableFuture<RMap> voidStoreBrand(
             @RestParam(name = "storeBrand", comment = "门店品牌档案") StoreBrand storeBrand,
             @RestParam(name = "&", comment = "当前用户,不需要传入") ERPTokenUser currentUser,
@@ -121,33 +123,35 @@ public class StoreRest extends BaseService {
                 }, getExecutor()
         );
     }
+
     //endregion
 
     //region 门店档案
-    @RestMapping(name = "queryViewStoreInfo", auth = true, sort = 11, comment = "获取门店档案列表", methods = {"GET", "POST"})
-    @WebApiBean(result = true, type = ViewStoreInfo.class)
-    public CompletableFuture<RMap> queryViewStoreInfo(
+
+    @RestMapping(name = "queryStoreInfoList", auth = true, sort = 20, comment = "获取门店档案列表", methods = {"GET", "POST"})
+    @WebApiBean(result = true, type = StoreInfo.class)
+    public CompletableFuture<RMap> queryStoreInfoList(
             @RestParam(name = "params", comment = "搜索内容", required = false) RMap searchData,
             @RestParam(name = "page", comment = "分页信息", required = false) PageFlipper pageFlipper,
             @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
             @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
         return CompletableFuture.supplyAsync(
                 () -> {
-                    List<ViewStoreInfo> platformRequireList = storeService.queryViewStoreInfo(searchData, pageFlipper, Long.parseLong(supplierCode));
-                    return RMapUtils.successV2(platformRequireList, null, pageFlipper);
+                    List<StoreInfo> esList = storeService.queryStoreInfo(searchData, pageFlipper, Long.parseLong(supplierCode));
+                    return RMapUtils.successV2(esList, null, pageFlipper);
                 }, getExecutor()
         );
     }
 
-    @RestMapping(name = "getViewStoreInfo", auth = true, sort = 12, comment = "获取门店档案", methods = {"GET", "POST"})
-    @WebApiBean(result = true, type = ViewStoreInfo.class)
-    public CompletableFuture<RMap> getViewStoreInfo(
+    @RestMapping(name = "getStoreInfo", auth = true, sort = 21, comment = "获取门店档案", methods = {"GET", "POST"})
+    @WebApiBean(result = true, type = StoreInfo.class)
+    public CompletableFuture<RMap> getStoreInfo(
             @RestParam(name = "idStore", comment = "平台档案id") long idStore,
             @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
             @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
         return CompletableFuture.supplyAsync(
                 () -> {
-                    ViewStoreInfo resultObj = storeService.getViewStoreInfo(idStore, Long.parseLong(supplierCode), true, true, true);
+                    StoreInfo resultObj = storeService.getStoreInfo(idStore, Long.parseLong(supplierCode), false, false, false);
                     if (resultObj == null)
                         return RMapUtils.error(HttpCode.BAD_REQUEST.value(), "门店档案不存在");
                     return RMapUtils.successV2(resultObj, null, null);
@@ -155,10 +159,10 @@ public class StoreRest extends BaseService {
         );
     }
 
-    @RestMapping(name = "addStoreInfo", auth = true, sort = 13, comment = "新增门店档案", methods = {"POST"})
-    @WebApiBean(result = true, type = StoreInfo.class)
+    @RestMapping(name = "addStoreInfo", auth = true, sort = 22, comment = "新增门店档案", methods = {"POST"})
+    @WebApiBean(type = StoreInfo.class)
     public CompletableFuture<RMap> addStoreInfo(
-            @RestParam(name = "storeInfo", comment = "平台需求条件档案") StoreInfo storeInfo,
+            @RestParam(name = "storeInfo", comment = "门店档案") StoreInfo storeInfo,
             @RestParam(name = "&", comment = "当前用户,不需要传入") ERPTokenUser currentUser,
             @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
             @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
@@ -167,72 +171,130 @@ public class StoreRest extends BaseService {
                     RetResult<StoreInfo> resultRet = storeService.addStoreInfo(storeInfo, currentUser, dataSourceId, Long.parseLong(supplierCode));
                     if (!resultRet.isSuccess())
                         return RMapUtils.error(HttpCode.BAD_REQUEST.value(), resultRet.getRetinfo());
-                    return RMapUtils.successV2(resultRet.getResult(), null, null);
+                    return RMapUtils.success();
                 }, getExecutor()
         );
     }
 
-
-    @RestMapping(name = "generateStoreAuthUrl_Douyin", auth = true, sort = 14, comment = "生成门店平台授权地址_抖音来客", methods = {"POST"})
-    @WebApiBean(result = true, type = StoreInfo.class)
-    public CompletableFuture<RMap> generateStoreAuthUrl_Douyin(
-            @RestParam(name = "idStore", comment = "门店id") long idStore,
+    @RestMapping(name = "updateStoreInfo", auth = true, sort = 23, comment = "修改门店档案", methods = {"POST"})
+    @WebApiBean(type = StoreInfo.class)
+    public CompletableFuture<RMap> updateStoreInfo(
+            @RestParam(name = "storeInfo", comment = "门店档案") StoreInfo storeInfo,
             @RestParam(name = "&", comment = "当前用户,不需要传入") ERPTokenUser currentUser,
             @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
             @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
         return CompletableFuture.supplyAsync(
                 () -> {
-                    RetResult<ScriptStringResult> resultRet = storeService.generateStoreAuthUrl_Douyin(idStore,  dataSourceId, Long.parseLong(supplierCode));
-                    if (!resultRet.isSuccess())
-                        return RMapUtils.error(HttpCode.BAD_REQUEST.value(), resultRet.getRetinfo());
-                    return RMapUtils.successV2(resultRet.getResult(), null, null);
+                    RetResult<StoreInfo> result = storeService.updateStoreInfo(storeInfo, currentUser, dataSourceId, Long.parseLong(supplierCode));
+                    if (!result.isSuccess()) return RMapUtils.error(HttpCode.BAD_REQUEST.value(), result.getRetinfo());
+                    return RMapUtils.success();
                 }, getExecutor()
         );
     }
 
-    @RestMapping(name = "configStoreInvoiceInfo", auth = true, sort = 14, comment = "开启与关闭门店开票", methods = {"POST"})
-    @WebApiBean(result = true, type = StoreInvoiceInfo.class)
-    public CompletableFuture<RMap> configStoreInvoiceInfo(
-            @RestParam(name = "storeInvoiceInfo", comment = "门店开票信息") StoreInvoiceInfo storeInvoiceInfo,
-            @RestParam(name = "enableInvoice", comment = "1开启0关闭") int enableInvoice,
+    @RestMapping(name = "voidStoreInfo", auth = true, sort = 24, comment = "禁用门店档案", methods = {"POST"})
+    @WebApiBean(type = StoreInfo.class)
+    public CompletableFuture<RMap> voidStoreInfo(
+            @RestParam(name = "storeInfo", comment = "门店档案") StoreInfo storeInfo,
             @RestParam(name = "&", comment = "当前用户,不需要传入") ERPTokenUser currentUser,
             @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
             @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
         return CompletableFuture.supplyAsync(
                 () -> {
-                    RetResult<StoreInvoiceInfo> result = storeService.configStoreInvoiceInfo(storeInvoiceInfo, enableInvoice, currentUser, dataSourceId, Long.parseLong(supplierCode));
+                    RetResult<StoreInfo> result = storeService.voidStoreInfo(storeInfo, currentUser, dataSourceId, Long.parseLong(supplierCode));
                     if (!result.isSuccess()) return RMapUtils.error(HttpCode.BAD_REQUEST.value(), result.getRetinfo());
-                    return RMapUtils.successV2(result.getResult(), null, null);
+                    return RMapUtils.success();
+                }, getExecutor()
+        );
+    }
+
+    //endregion
+
+    //region 门店平台
+
+    @RestMapping(name = "queryStorePlatformList", auth = true, sort = 50, comment = "获取门店平台授权信息列表", methods = {"GET", "POST"})
+    public CompletableFuture<RMap> queryStorePlatformList(
+            @RestParam(name = "params", comment = "搜索内容", required = false) RMap searchData,
+            @RestParam(name = "page", comment = "分页信息", required = false) PageFlipper pageFlipper,
+            @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
+            @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
+        return CompletableFuture.supplyAsync(
+                () -> {
+                    List<Map<String, String>> esList = storeService.queryViewStoreInfo(searchData, pageFlipper, Long.parseLong(supplierCode));
+                    return RMapUtils.successV2(esList, null, pageFlipper);
                 }, getExecutor()
         );
     }
 
-    @RestMapping(name = "updateStoreInfo", auth = true, sort = 15, comment = "修改门店档案", methods = {"POST"})
+    @RestMapping(name = "getStorePlatformList", auth = true, sort = 21, comment = "获取门店某平台授权信息", methods = {"GET", "POST"})
     @WebApiBean(result = true, type = StoreInfo.class)
-    public CompletableFuture<RMap> updateStoreInfo(
-            @RestParam(name = "storeInfo", comment = "门店档案") StoreInfo storeInfo,
-            @RestParam(name = "&", comment = "当前用户,不需要传入") ERPTokenUser currentUser,
+    public CompletableFuture<RMap> getStorePlatformList(
+            @RestParam(name = "idStore", comment = "门店id") long idStore,
+            @RestParam(name = "platformCode", comment = "平台编号") String platformCode,
             @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
             @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
         return CompletableFuture.supplyAsync(
                 () -> {
-                    RetResult<StoreInfo> result = storeService.updateStoreInfo(storeInfo, currentUser, dataSourceId, Long.parseLong(supplierCode));
-                    if (!result.isSuccess()) return RMapUtils.error(HttpCode.BAD_REQUEST.value(), result.getRetinfo());
-                    return RMapUtils.successV2(result.getResult(), null, null);
+                    RetResult<List<StorePlatform>> esResult = storeService.getStorePlatformList(idStore, platformCode, Long.parseLong(supplierCode));
+                    if (esResult.isSuccess()) {
+                        return RMapUtils.error(HttpCode.BAD_REQUEST.value(), "门店档案不存在");
+                    }
+                    return RMapUtils.successV2(esResult.getResult(), null, null);
                 }, getExecutor()
         );
     }
 
-    @RestMapping(name = "voidStoreInfo", auth = true, sort = 16, comment = "禁用门店档案", methods = {"POST"})
+    @RestMapping(name = "getStorePlatformInfo", auth = true, sort = 21, comment = "获取门店授权平台信息", methods = {"GET", "POST"})
+    @WebApiBean(result = true, type = StorePlatform.class)
+    public CompletableFuture<RMap> getStorePlatformInfo(
+            @RestParam(name = "idStorePlatform", comment = "门店平台授权id") long idStorePlatform,
+            @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
+            @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
+        return CompletableFuture.supplyAsync(
+                () -> {
+                    StorePlatform esResult = storeService.getStorePlatformInfo(idStorePlatform, Long.parseLong(supplierCode));
+                    if (esResult == null) {
+                        return RMapUtils.error(HttpCode.BAD_REQUEST.value(), "门店档案不存在");
+                    }
+                    return RMapUtils.successV2(esResult, null, null);
+                }, getExecutor()
+        );
+    }
+
+
+    @RestMapping(name = "generateStorePlatformAuthUrl", auth = true, sort = 14, comment = "生成门店平台授权地址", methods = {"POST"})
     @WebApiBean(result = true, type = StoreInfo.class)
-    public CompletableFuture<RMap> voidStoreInfo(
-            @RestParam(name = "storeInfo", comment = "门店档案") StoreInfo storeInfo,
+    public CompletableFuture<RMap> generateStorePlatformAuthUrl(
+            @RestParam(name = "idStore", comment = "门店id") long idStore,
+            @RestParam(name = "platformCode", comment = "平台编号") String platformCode,
             @RestParam(name = "&", comment = "当前用户,不需要传入") ERPTokenUser currentUser,
             @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
             @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
         return CompletableFuture.supplyAsync(
                 () -> {
-                    RetResult<StoreInfo> result = storeService.voidStoreInfo(storeInfo, currentUser, dataSourceId, Long.parseLong(supplierCode));
+                    RetResult<ScriptStringResult> resultRet = storeService.generateStorePlatformAuthUrl(idStore, platformCode, dataSourceId, Long.parseLong(supplierCode));
+                    if (!resultRet.isSuccess())
+                        return RMapUtils.error(HttpCode.BAD_REQUEST.value(), resultRet.getRetinfo());
+                    return RMapUtils.successV2(resultRet.getResult(), null, null);
+                }, getExecutor()
+        );
+    }
+
+    //endregion
+
+    //region 门店发票
+
+    @RestMapping(name = "configStoreInvoiceInfo", auth = true, sort = 14, comment = "开启与关闭门店开票", methods = {"POST"})
+    @WebApiBean(result = true, type = StoreInvoiceInfo.class)
+    public CompletableFuture<RMap> configStoreInvoiceInfo(
+            @RestParam(name = "storeInvoiceInfo", comment = "门店开票信息") StoreInvoiceInfo storeInvoiceInfo,
+            @RestParam(name = "enableInvoice", comment = "1开启0关闭") int enableInvoice,
+            @RestParam(name = "&", comment = "当前用户,不需要传入") ERPTokenUser currentUser,
+            @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
+            @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
+        return CompletableFuture.supplyAsync(
+                () -> {
+                    RetResult<StoreInvoiceInfo> result = storeService.configStoreInvoiceInfo(storeInvoiceInfo, enableInvoice, currentUser, dataSourceId, Long.parseLong(supplierCode));
                     if (!result.isSuccess()) return RMapUtils.error(HttpCode.BAD_REQUEST.value(), result.getRetinfo());
                     return RMapUtils.successV2(result.getResult(), null, null);
                 }, getExecutor()

+ 79 - 9
ddWebCore/src/main/java/com/dderp/webcore/rest/flycat/OrderRest.java

@@ -1,25 +1,28 @@
 package com.dderp.webcore.rest.flycat;
 
+import com.dderp.common.api.SystemService;
 import com.dderp.common.api.flycat.OrderSearchService;
 import com.dderp.common.api.flycat.OrderService;
 import com.dderp.common.base.BaseService;
 import com.dderp.common.datas.ERPHeader;
 import com.dderp.common.datas.HttpCode;
+import com.dderp.common.datas.ReadOrderOption;
 import com.dderp.common.entity.base.InvokeCallParams;
 import com.dderp.common.entity.base.InvokeCallResult;
-import com.dderp.common.entity.order.BusinessOrder;
+import com.dderp.common.entity.order.*;
 import com.dderp.common.entity.site.ERPTokenUser;
-import com.dderp.common.entity.store.StoreBrand;
 import com.dySweetFishPlugin.sql.RMapUtils;
 import com.sweetfish.net.http.*;
 import com.sweetfish.service.Local;
 import com.sweetfish.service.RetResult;
 import com.sweetfish.source.PageFlipper;
+import com.sweetfish.util.AnyValue;
 import com.sweetfish.util.AutoLoad;
+import org.apache.commons.lang3.StringUtils;
 import org.rex.RMap;
 
 import javax.annotation.Resource;
-import java.util.List;
+import java.util.*;
 import java.util.concurrent.CompletableFuture;
 
 @AutoLoad(false)
@@ -32,9 +35,38 @@ public class OrderRest extends BaseService {
     OrderService orderService;
 
     @Resource
+    SystemService systemService;
+
+    @Resource
     OrderSearchService orderSearchService;
 
-    @RestMapping(name = "callOrder", auth = true, sort = 1, logging = 4, comment = "订单接口", methods = {"POST"})
+    private final Map<String, ReadOrderOption> readOrderOptionMap = new HashMap<>();
+
+    @Override
+    public void init(AnyValue config) {
+        super.init(config);
+
+        readOrderOptionMap.put("total", ReadOrderOption.ORDER_TOTAL);
+        readOrderOptionMap.put("finances", ReadOrderOption.ORDER_FINANCES);
+        readOrderOptionMap.put("delivery", ReadOrderOption.ORDER_DELIVERY);
+        readOrderOptionMap.put("product", ReadOrderOption.ORDER_PRODUCT);
+        readOrderOptionMap.put("rider", ReadOrderOption.ORDER_RIDER);
+    }
+
+    @RestMapping(name = "orderFormToken", auth = true, sort = 1, comment = "请求token", methods = {"POST"})
+    public CompletableFuture<RMap> orderFormToken(
+            @RestParam(name = "&", comment = "登录用户,无需传入") ERPTokenUser currentUser,
+            @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
+            @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
+        return CompletableFuture.supplyAsync(
+                () -> {
+                    String token = systemService.requestFormToken("businessOrderForm", Long.parseLong(supplierCode));
+                    return RMapUtils.successV2(token, null, null);
+                }, getExecutor()
+        );
+    }
+
+    @RestMapping(name = "callOrder", auth = true, sort = 2, logging = 4, comment = "订单接口", methods = {"POST"})
     public CompletableFuture<InvokeCallResult> callOrder(
             @RestBody(comment = "提交数据") InvokeCallParams callParams,
             @RestParam(name = "&", comment = "登录用户,无需传入") ERPTokenUser currentUser,
@@ -51,7 +83,7 @@ public class OrderRest extends BaseService {
         );
     }
 
-    @RestMapping(name = "queryOrderList", auth = true, sort = 2, comment = "获取订单列表", methods = {"GET", "POST"})
+    @RestMapping(name = "queryOrderList", auth = true, sort = 3, comment = "获取订单列表", methods = {"GET", "POST"})
     @WebApiBean(result = true, type = BusinessOrder.class)
     public CompletableFuture<RMap> queryOrderList(
             @RestParam(name = "params", comment = "搜索内容", required = false) RMap searchData,
@@ -62,10 +94,48 @@ public class OrderRest extends BaseService {
         return CompletableFuture.supplyAsync(
                 () -> {
                     RetResult<List<BusinessOrder>> retResult = orderSearchService.searchBusinessOrderList(searchData, currentUser, null,
-                            pageFlipper, dataSourceId, Long.parseLong(supplierCode), null);
-                    if (retResult.isSuccess())
-                        return RMapUtils.successV2(retResult.getResult(), null, pageFlipper);
-                    else return RMapUtils.error(HttpCode.NOT_FOUND.value(), retResult.getRetinfo());
+                            pageFlipper, dataSourceId, Long.parseLong(supplierCode), ReadOrderOption.ORDER_FINANCES, ReadOrderOption.ORDER_TOTAL);
+                    if (retResult.isSuccess()) {
+                        return RMapUtils.successV2(retResult.getResult(), retResult.getAttachRMap(), retResult.getPageFlipper());
+                    }
+                    return RMapUtils.error(HttpCode.NOT_FOUND.value(), retResult.getRetinfo());
+                }, getExecutor()
+        );
+    }
+
+    @RestMapping(name = "getBusinessOrder", auth = true, sort = 5, comment = "获取订单详情", methods = {"GET", "POST"})
+    @WebApiBean(type = BusinessOrder.class, result = true)
+    @WebApiBean(type = OrderFinances.class, result = true)
+    @WebApiBean(type = OrderDetailItem.class, result = true)
+    @WebApiBean(type = OrderDeliveryInfo.class, result = true)
+    @WebApiBean(type = OrderRiderItem.class, result = true)
+    public CompletableFuture<RMap> getSendOrder(
+            @RestParam(name = "idOrder", comment = "订单id") long idOrder,
+            @RestParam(name = "options", comment = "读取内容,不传为全部", required = false) String options,
+            @RestParam(name = "&", comment = "登录用户,无需传入") ERPTokenUser currentUser,
+            @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
+            @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
+        return CompletableFuture.supplyAsync(
+                () -> {
+                    ReadOrderOption[] optionArr;
+                    if (StringUtils.isBlank(options)) {
+                        optionArr = new ReadOrderOption[]{ReadOrderOption.ORDER_FINANCES, ReadOrderOption.ORDER_DELIVERY, ReadOrderOption.ORDER_PRODUCT};
+                    } else {
+                        List<ReadOrderOption> optionList = new ArrayList<>();
+                        Arrays.stream(options.split(","))
+                                .forEach(s -> {
+                                    if (readOrderOptionMap.containsKey(s)) {
+                                        optionList.add(readOrderOptionMap.get(s));
+                                    }
+                                });
+                        optionArr = optionList.toArray(new ReadOrderOption[0]);
+                    }
+
+                    RetResult<BusinessOrder> result = orderSearchService.getBusinessOrder(idOrder, currentUser, dataSourceId, Long.parseLong(supplierCode), optionArr);
+                    if (!result.isSuccess()) {
+                        return RMapUtils.error(HttpCode.BAD_REQUEST.value(), result.getRetinfo());
+                    }
+                    return RMapUtils.successV2(result.getResult(), null, null);
                 }, getExecutor()
         );
     }

+ 1 - 1
ddWebCore/src/main/java/com/dderp/webcore/servlet/OrderCallServlet.java

@@ -124,7 +124,7 @@ public class OrderCallServlet extends HttpServlet {
             case "life_saas_cooperate_auth_with_bind": {
                 //能力授权&门店绑定消息
                 CompletableFuture.runAsync(() -> {
-                    RetResult<StorePlatform> result = storeService.bindStorePlatformDouyin(callBody.getContent(), dataSourceId, supplierCode, currentUser);
+                    RetResult<StorePlatform> result = storeService.bindStorePlatform(callBody.getContent(), "DYLK", dataSourceId, supplierCode, currentUser);
                     if (result.isSuccess()) logger.info("[抖音来客]平台门店绑定成功");
                     else logger.error("[抖音来客]平台门店绑定失败:" + result.getRetinfo());
                 });