Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	conf/KeyId.xml
Veronique 2 лет назад
Родитель
Сommit
02bd01489e

+ 36 - 0
conf/KeyId.xml

@@ -318,6 +318,42 @@
     </Item>
 
     <Item>
+        <IDName>tbStoreInfo.id</IDName>
+        <Table>
+            <TableName>tbStoreInfo</TableName>
+            <IDFieldName>id</IDFieldName>
+            <TableWhere/>
+        </Table>
+    </Item>
+
+    <Item>
+        <IDName>tbStoreInvoiceInfo.id</IDName>
+        <Table>
+            <TableName>tbStoreInvoiceInfo</TableName>
+            <IDFieldName>id</IDFieldName>
+            <TableWhere/>
+        </Table>
+    </Item>
+
+    <Item>
+        <IDName>tbStorePlatform.id</IDName>
+        <Table>
+            <TableName>tbStorePlatform</TableName>
+            <IDFieldName>id</IDFieldName>
+            <TableWhere/>
+        </Table>
+    </Item>
+
+    <Item>
+        <IDName>tbStorePlatformRequire.id</IDName>
+        <Table>
+            <TableName>tbStorePlatformRequire</TableName>
+            <IDFieldName>id</IDFieldName>
+            <TableWhere/>
+        </Table>
+    </Item>
+
+    <Item>
         <IDName>deBusinessOrder.id</IDName>
         <Table>
             <TableName>v_debusinessorder</TableName>

+ 84 - 9
conf/esTemplate/storeinfo.json

@@ -6,14 +6,46 @@
       },
       "storeName": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "idBrand": {
         "type": "long"
       },
       "brandName": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "idStoreType": {
         "type": "long"
@@ -23,34 +55,71 @@
       },
       "storeCodeInput": {
         "type": "text",
-        "index": "not_analyzed"
+        "index": "analyzed",
+        "analyzer": "codefull_analyzer",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          }
+        }
       },
       "storeProvince": {
         "type": "text",
-        "index": "not_analyzed"
+        "index": "not_analyzed",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          }
+        }
       },
       "storeCity": {
         "type": "text",
-        "index": "not_analyzed"
+        "index": "not_analyzed",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          }
+        }
       },
       "storeDistrict": {
         "type": "text",
-        "index": "not_analyzed"
+        "index": "not_analyzed",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          }
+        }
       },
       "storeAddress": {
         "type": "text",
         "index": "not_analyzed"
       },
-      "contractPhone": {
+      "locationStr": {
         "type": "text",
         "index": "not_analyzed"
       },
+      "contractPhone": {
+        "type": "text",
+        "index": "analyzed",
+        "analyzer": "codefull_analyzer",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          }
+        }
+      },
       "storeBossId": {
         "type": "long"
       },
       "companyLicenseNo": {
         "type": "text",
-        "index": "not_analyzed"
+        "index": "analyzed",
+        "analyzer": "codefull_analyzer",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          }
+        }
       },
       "companyLicensePicUrl": {
         "type": "text",
@@ -58,7 +127,13 @@
       },
       "legalPersonIdNo": {
         "type": "text",
-        "index": "not_analyzed"
+        "index": "analyzed",
+        "analyzer": "codefull_analyzer",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          }
+        }
       },
       "legalPersonName": {
         "type": "text",

+ 17 - 1
conf/esTemplate/storeinvoiceinfo.json

@@ -16,7 +16,23 @@
       },
       "companyName": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "defaultTaxItemName": {
         "type": "text",

+ 17 - 1
conf/esTemplate/storeplatform.json

@@ -12,7 +12,23 @@
       },
       "platformName": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "platformType": {
         "type": "integer"

+ 24 - 2
conf/esTemplate/storeplatformrequire.json

@@ -18,11 +18,33 @@
       },
       "platformRequireCode": {
         "type": "text",
-        "index": "not_analyzed"
+        "index": "analyzed",
+        "analyzer": "codefull_analyzer",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          }
+        }
       },
       "platformRequireName": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "itemValue": {
         "type": "text",

+ 10 - 8
conf/sqlroot/com/dderp/business/dao/StoreDao.dql

@@ -50,26 +50,28 @@ brandMemo = #{brandmemo},updateBy = #{updateby},updateTime = #{updatetime},updat
  insert into $table$ (id, storeName, idBrand, brandName,
  idStoreType, deliverSettleKind, storeCodeInput,
  storeProvince, storeCity, storeDistrict,
- storeAddress, contractPhone, storeBossId,
+ storeAddress, locationStr, contractPhone, storeBossId,
  companyLicenseNo, companyLicensePicUrl, legalPersonIdNo,
  legalPersonName, voidFlag, enableInvoice,
  createBy, createTime, createTimeLong,
  updateBy, updateTime, updateTimeLong ) values ( #{id}, #{storename}, #{idbrand}, #{brandname},
  #{idstoretype}, #{deliversettlekind}, #{storecodeinput},
  #{storeprovince}, #{storecity}, #{storedistrict},
- #{storeaddress}, #{contractphone}, #{storebossid},
+ #{storeaddress}, #{locationstr}, #{contractphone}, #{storebossid},
  #{companylicenseno}, #{companylicensepicurl}, #{legalpersonidno},
  #{legalpersonname}, #{voidflag}, #{enableinvoice},
  #{createby}, #{createtime}, #{createtimelong},
  #{updateby}, #{updatetime}, #{updatetimelong} );
 
  -- [updateStoreInfo]
- update $table$ set storeName = #{storename},idBrand = #{idbrand},brandName = #{brandname},idStoreType = #{idstoretype},
- deliverSettleKind = #{deliversettlekind},storeCodeInput = #{storecodeinput},storeProvince = #{storeprovince},storeCity = #{storecity},
- storeDistrict = #{storedistrict},storeAddress = #{storeaddress},contractPhone = #{contractphone},storeBossId = #{storebossid},
- companyLicenseNo = #{companylicenseno},companyLicensePicUrl = #{companylicensepicurl},legalPersonIdNo = #{legalpersonidno},legalPersonName = #{legalpersonname},
- enableInvoice = #{enableinvoice},updateBy = #{updateby},updateTime = #{updatetime},updateTimeLong = #{updatetimelong}
-  where id = #{id};
+ update $table$ set storeName = #{storename},idBrand = #{idbrand}, brandName = #{brandname},
+ idStoreType = #{idstoretype}, deliverSettleKind = #{deliversettlekind},storeCodeInput = #{storecodeinput},
+ storeProvince = #{storeprovince},storeCity = #{storecity}, storeDistrict = #{storedistrict},
+ storeAddress = #{storeaddress},locationStr = #{locationstr},contractPhone = #{contractphone},
+ storeBossId = #{storebossid}, companyLicenseNo = #{companylicenseno},companyLicensePicUrl = #{companylicensepicurl},
+ legalPersonIdNo = #{legalpersonidno},legalPersonName = #{legalpersonname},enableInvoice = #{enableinvoice},
+ updateBy = #{updateby},updateTime = #{updatetime},updateTimeLong = #{updatetimelong}
+ where id = #{id};
 
  -- [updateStoreEnableInvoice]
   update $table$ set enableInvoice = #{enableinvoice},updateBy = #{updateby},

+ 10 - 2
ddBusiness/src/main/java/com/dderp/business/dao/StoreDao.java

@@ -51,6 +51,7 @@ public interface StoreDao extends DaoRepository {
     @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
     @SqlId(clazz = StoreDao.class, sql = "voidStoreInfo", table = "tbStoreInfo", params = {1})
     int voidStoreInfo(StoreInfo storeInfo, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
+
     //endregion
 
     //region 门店发票档案
@@ -62,12 +63,19 @@ public interface StoreDao extends DaoRepository {
     @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
     @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
     @SqlId(clazz = StoreDao.class, sql = "addStoreInvoiceInfo", table = "tbStoreInvoiceInfo", params = {1})
-    int addStoreInvoiceInfo(StoreInvoiceInfo storeInvoiceInfo, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
+    @SqlId(clazz = StoreDao.class, sql = "updateStoreEnableInvoice", table = "tbStoreInfo", params = {2})
+    int addStoreInvoiceInfo(StoreInvoiceInfo storeInvoiceInfo,StoreInfo storeInfo, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
 
     @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
     @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
     @SqlId(clazz = StoreDao.class, sql = "updateStoreInvoiceInfo", table = "tbStoreInvoiceInfo", params = {1})
-    int updateStoreInvoiceInfo(StoreInvoiceInfo storeInvoiceInfo, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
+    @SqlId(clazz = StoreDao.class, sql = "updateStoreEnableInvoice", table = "tbStoreInfo", params = {2})
+    int updateStoreInvoiceInfo(StoreInvoiceInfo storeInvoiceInfo,StoreInfo storeInfo, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
+
+    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
+    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
+    @SqlId(clazz = StoreDao.class, sql = "updateStoreEnableInvoice", table = "tbStoreInfo", params = {1})
+    int updateStoreEnableInvoice(StoreInfo storeInfo, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
 
     //endregion
 

+ 556 - 16
ddBusiness/src/main/java/com/dderp/business/service/StoreServiceImpl.java

@@ -3,6 +3,7 @@ package com.dderp.business.service;
 import com.dderp.business.dao.StoreDao;
 import com.dderp.common.api.NoSqlKeysService;
 import com.dderp.common.api.PlatformService;
+import com.dderp.common.api.SortBuilderExecutor;
 import com.dderp.common.api.StoreService;
 import com.dderp.common.base.BaseService;
 import com.dderp.common.datas.ESKeys;
@@ -12,6 +13,7 @@ import com.dderp.common.entity.site.ERPTokenUser;
 import com.dderp.common.entity.store.*;
 import com.dderp.common.tool.ERPUtils;
 import com.dySweetFishPlugin.elasticsearch.ESClient;
+import com.dySweetFishPlugin.sql.RMapUtils;
 import com.dySweetFishPlugin.sql.TableIdService;
 import com.dySweetFishPlugin.sql.dao.TunaService;
 import com.sweetfish.convert.json.JsonConvert;
@@ -22,19 +24,32 @@ 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.IndexRequestBuilder;
 import org.elasticsearch.action.index.IndexResponse;
 import org.elasticsearch.action.support.WriteRequest;
+import org.elasticsearch.action.update.UpdateRequest;
 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.sort.SortBuilders;
 import org.elasticsearch.search.sort.SortOrder;
 import org.rex.RMap;
 
 import javax.annotation.Resource;
-import java.util.List;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
+
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
 
 @AutoLoad(value = false)
 @Local
@@ -63,9 +78,10 @@ public class StoreServiceImpl extends BaseService implements StoreService {
         storeDao = tunaService.generate(StoreDao.class);
     }
 
+    //region 门店品牌档案
     @Override
     public List<StoreBrand> queryStoreBrandList(RMap params, PageFlipper pageFlipper, long supplierCode) {
-        List<StoreBrand> storeBrandList = searchESList(esClient, jsonConvert,
+        return searchESList(esClient, jsonConvert,
                 StoreBrand.class,
                 null,
                 ((sd) -> {
@@ -89,8 +105,6 @@ public class StoreServiceImpl extends BaseService implements StoreService {
                 }),
                 keysService.getESKey(ESKeys.ES_DELIVER_STORE_BRAND_TYPE, supplierCode),
                 (() -> SortBuilders.fieldSort("id").order(SortOrder.DESC)));
-
-        return storeBrandList;
     }
 
     @Override
@@ -134,7 +148,7 @@ public class StoreServiceImpl extends BaseService implements StoreService {
         if (itemResponse.getResult() == DocWriteResponse.Result.CREATED) {
             storeDao.addStoreBrand(storeBrand, dataSourceId, supplierCode);
         } else {
-            return RetResult.<StoreBrand>errorT().retinfo("创建平台档案失败");
+            return RetResult.<StoreBrand>errorT().retinfo("创建门店品牌失败");
         }
 
         return RetResult.<StoreBrand>successT().result(storeBrand);
@@ -143,55 +157,581 @@ public class StoreServiceImpl extends BaseService implements StoreService {
     @Override
     public RetResult<StoreBrand> uploadBrandLogo(long idStoreBrand, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
         return null;
+
     }
 
     @Override
     public RetResult<StoreBrand> updateStoreBrand(StoreBrand storeBrand, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
-        return null;
+        if (StringUtils.isBlank(storeBrand.getBrandName()))
+            return RetResult.<StoreBrand>errorT().retinfo("门店品牌名称不可为空");
+
+        StoreBrand esInfo = this.getStoreBrand(storeBrand.getId(), supplierCode);
+        if (esInfo == null)
+            return RetResult.<StoreBrand>errorT().retinfo("未找到此门店品牌");
+
+        //先查一下有没有重名的平台信息(防止修改名称改重)
+        StoreBrand checkNameInfo = this.getESOneInfo(esClient, jsonConvert,
+                StoreBrand.class,
+                (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())));
+
+                    return qb;
+                },
+                keysService.getESKey(ESKeys.ES_DELIVER_STORE_BRAND_INDEX, supplierCode),
+                null);
+
+        if (checkNameInfo != null) return RetResult.<StoreBrand>errorT().retinfo("已存在同名的门店品牌");
+
+        esInfo.setBrandName(storeBrand.getBrandName());
+        esInfo.setStartingPrice(storeBrand.getStartingPrice());
+        esInfo.setPackagingFee(storeBrand.getPackagingFee());
+        esInfo.setBrandMemo(storeBrand.getBrandMemo());
+        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) {
+            logger.error("修改门店品牌[" + esInfo.getId() + "出错:" + e.getMessage(), e);
+        }
+        storeDao.updateStoreBrand(esInfo, dataSourceId, supplierCode);
+        return RetResult.successT();
     }
 
     @Override
     public RetResult<StoreBrand> voidStoreBrand(StoreBrand storeBrand, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
-        return null;
+        StoreBrand esInfo = this.getStoreBrand(storeBrand.getId(), 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) {
+            logger.error("禁用或启用门店品牌[" + esInfo.getId() + "出错:" + e.getMessage(), e);
+        }
+        storeDao.voidStoreBrand(esInfo, dataSourceId, supplierCode);
+        return RetResult.successT();
     }
+    //endregion
 
     @Override
     public List<ViewStoreInfo> queryViewStoreInfo(RMap params, PageFlipper pageFlipper, long supplierCode) {
-        return null;
+        Set<Long> idStores = new HashSet<>();
+        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, "storeName")) {
+                        String storeName = params.getString("storeName");
+                        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, "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))
+        );
+
+        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_INFO_INDEX, supplierCode)},
+                (SortBuilderExecutor) null);
+
+        List<ViewStoreInfo> viewStoreInfoList = new ArrayList<>();
+
+        storeInfoList.forEach(x -> {
+            x.setPlatformList(storePlatformMap.get(x.getId()));
+            ViewStoreInfo viewStoreInfo = new ViewStoreInfo(x);
+            viewStoreInfoList.add(viewStoreInfo);
+        });
+
+        return viewStoreInfoList;
     }
 
     @Override
-    public ViewStoreInfo getViewStoreInfo(long idStore, long supplierCode, int withInvoice) {
-        return null;
+    public ViewStoreInfo getViewStoreInfo(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),
+                ESKeys.ES_DELIVER_STORE_INFO_TYPE,
+                null
+        );
+
+        if (readInvoice) {
+            StoreInvoiceInfo storeInvoiceInfo = getESOneInfo(esClient, jsonConvert, StoreInvoiceInfo.class,
+                    ((sd) -> {
+                        BoolQueryBuilder qb = QueryBuilders.boolQuery();
+                        qb = qb.must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_INVOICE_INFO_TYPE))
+                                .must(QueryBuilders.termQuery("idStore", idStore));
+
+                        return qb;
+                    }),
+                    keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_TYPE, supplierCode),
+                    null
+            );
+            storeInfo.setInvoiceInfo(storeInvoiceInfo);
+        }
+
+        if (readEmployee) { //先不用
+
+        }
+
+        if (readPlatform) {
+            List<StorePlatform> platformList = searchESList(esClient,jsonConvert,StorePlatform.class,
+                    null,
+                    ((sd) -> {
+                        BoolQueryBuilder qb = QueryBuilders.boolQuery();
+                        qb = qb.must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE))
+                                .must(QueryBuilders.termQuery("idStore",idStore));
+
+                        return qb;
+                    }),
+                    keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
+                    (SortBuilderExecutor) null
+            );
+            storeInfo.setPlatformList(platformList);
+        }
+
+        return new ViewStoreInfo(storeInfo);
     }
 
     @Override
     public RetResult<StoreInfo> addStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
-        return null;
+        if (StringUtils.isBlank(storeInfo.getStoreName()))
+            return RetResult.<StoreInfo>errorT().retinfo("门店名称不可为空");
+
+        //其他是否必须输入 前端判断
+        //先查一下有没有重名的平台信息
+        StoreBrand 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("storeName.raw", storeInfo.getStoreName()));
+
+                    return qb;
+                },
+                keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
+                null);
+
+        if (esInfo != null) return RetResult.<StoreInfo>errorT().retinfo("已存在同名的门店");
+
+        storeInfo.setId(tableIdService.getTableIdMulti("tbStoreInfo.id", 1, dataSourceId, String.valueOf(supplierCode)));
+        StoreInfo.create(storeInfo, currentUser.getId());
+        storeInfo.setEnableInvoice(0);
+
+        IndexResponse itemResponse = esClient.getClient()
+                .prepareIndex(keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_TYPE, supplierCode), ESKeys.ES_DELIVER_STORE_INFO_INDEX)
+                .setId(String.valueOf(storeInfo.getId()))
+                .setSource(jsonConvert.convertTo(storeInfo), XContentType.JSON)
+                .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
+                .get();
+
+        if (itemResponse.getResult() == DocWriteResponse.Result.CREATED) {
+            storeDao.addStoreInfo(storeInfo, dataSourceId, supplierCode);
+        } else {
+            return RetResult.<StoreInfo>errorT().retinfo("创建门店失败");
+        }
+
+        return RetResult.successT();
+    }
+
+    @Override
+    public StoreInvoiceInfo getStoreInvoiceInfo(long idStore, long supplierCode) {
+        return this.getESOneInfo(esClient, jsonConvert,
+                StoreInvoiceInfo.class,
+                (sd) -> {
+                    BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_INVOICE_INFO_TYPE));
+                    qb.must(QueryBuilders.termQuery("idStore", idStore));
+                    return qb;
+                },
+                keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_TYPE, supplierCode),
+                null);
     }
 
     @Override
     public RetResult<StoreInvoiceInfo> configStoreInvoiceInfo(StoreInvoiceInfo invoiceInfo, int enableInvoice, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
-        return null;
+        StoreInfo esStoreInfo = this.getViewStoreInfo(invoiceInfo.getIdStore(), supplierCode, false, false, false).getStoreInfo();
+        if (esStoreInfo == null)
+            return RetResult.<StoreInvoiceInfo>errorT().retinfo("未找到门店信息");
+        esStoreInfo.setEnableInvoice(enableInvoice);
+        StoreInfo.update(esStoreInfo, currentUser.getId());
+        try {
+            UpdateRequest updateRequest = new UpdateRequest(
+                    keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
+                    ESKeys.ES_DELIVER_STORE_INFO_TYPE, String.valueOf(esStoreInfo.getId()))
+                    .doc(jsonBuilder()
+                            .startObject()
+                            .field("enableInvoice", esStoreInfo.getEnableInvoice())
+                            .field("updateTimeLong", esStoreInfo.getUpdateTimeLong())
+                            .field("updateBy", esStoreInfo.getUpdateBy())
+                            .endObject())
+                    .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
+            esClient.getClient().update(updateRequest).get();
+
+        } catch (IOException | InterruptedException | ExecutionException e) {
+            logger.error("启用或停用门店开票信息[" + esStoreInfo.getId() + "出错:" + e.getMessage(), e);
+            RetResult.<StoreInvoiceInfo>errorT().retinfo("启用或停用门店开票信息[" + esStoreInfo.getId() + "出错:");
+        }
+        if (enableInvoice == 0) { //停用门店开票 不动发票信息
+            storeDao.updateStoreEnableInvoice(esStoreInfo, dataSourceId, supplierCode);
+            return RetResult.successT();
+        }
+        // 启用开票
+        StoreInvoiceInfo esInvoice = getStoreInvoiceInfo(invoiceInfo.getIdStore(), supplierCode);
+        if (esInvoice == null) { // 未设置过发票信息 需要新增
+            invoiceInfo.setId(tableIdService.getTableIdMulti("tbStoreInvoiceInfo.id", 1, dataSourceId, String.valueOf(supplierCode)));
+            StoreInvoiceInfo.create(invoiceInfo, currentUser.getId());
+            IndexResponse itemResponse = esClient.getClient()
+                    .prepareIndex(
+                            keysService.getESKey(ESKeys.ES_DELIVER_STORE_INVOICE_INFO_TYPE, supplierCode), ESKeys.ES_DELIVER_STORE_INFO_INDEX)
+                    .setId(String.valueOf(invoiceInfo.getId()))
+                    .setParent(String.valueOf(invoiceInfo.getIdStore()))
+                    .setSource(jsonConvert.convertTo(invoiceInfo), XContentType.JSON)
+                    .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
+                    .get();
+
+            if (itemResponse.getResult() == DocWriteResponse.Result.CREATED) {
+                storeDao.addStoreInvoiceInfo(invoiceInfo, esStoreInfo, dataSourceId, supplierCode);
+            } else {
+                return RetResult.<StoreInvoiceInfo>errorT().retinfo("门店启用开票失败");
+            }
+        } else {
+            esInvoice.setTaxIdNo(invoiceInfo.getTaxIdNo());
+            esInvoice.setCompanyName(invoiceInfo.getCompanyName());
+            esInvoice.setDefaultTaxItemCode(invoiceInfo.getDefaultTaxItemCode());
+            esInvoice.setDefaultTaxItemName(invoiceInfo.getDefaultTaxItemName());
+            esInvoice.setTaxRate(invoiceInfo.getTaxRate());
+            StoreInvoiceInfo.update(esInvoice, currentUser.getId());
+
+            try {
+                UpdateRequest updateInvoiceRequest = new UpdateRequest(
+                        keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
+                        ESKeys.ES_DELIVER_STORE_INVOICE_INFO_TYPE, String.valueOf(esStoreInfo.getId()))
+                        .doc(jsonBuilder()
+                                .startObject()
+                                .field("taxIdNo", esInvoice.getTaxIdNo())
+                                .field("companyName", esInvoice.getCompanyName())
+                                .field("defaultTaxItemName", esInvoice.getDefaultTaxItemName())
+                                .field("defaultTaxItemCode", esInvoice.getDefaultTaxItemCode())
+                                .field("taxRate", esInvoice.getTaxRate())
+                                .field("updateTimeLong", esInvoice.getUpdateTimeLong())
+                                .field("updateBy", esInvoice.getUpdateBy())
+                                .endObject())
+                        .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
+                esClient.getClient().update(updateInvoiceRequest).get();
+
+            } catch (IOException | InterruptedException | ExecutionException e) {
+                logger.error("门店启用开票信息[" + esStoreInfo.getId() + "出错" + e.getMessage(), e);
+                return RetResult.<StoreInvoiceInfo>errorT().retinfo("门店启用开票失败");
+            }
+            storeDao.updateStoreInvoiceInfo(esInvoice, esStoreInfo, dataSourceId, supplierCode);
+        }
+        return RetResult.successT();
     }
 
     @Override
     public RetResult<StoreInfo> updateStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
-        return null;
+        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("未找到此门店品牌");
+        }
+        //先查一下有没有重名的门店信息(防止修改名称改重)同行业门店不同地区门店名可以重
+        StoreBrand checkNameInfo = this.getESOneInfo(esClient, jsonConvert,
+                StoreBrand.class,
+                (a) -> {
+                    BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_INFO_TYPE));
+                    qb.must(QueryBuilders.termQuery("storeName.raw", esInfo.getStoreName()))
+                            .mustNot(QueryBuilders.idsQuery(String.valueOf(esInfo.getId())));
+
+                    return qb;
+                },
+                keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
+                null);
+
+        if (checkNameInfo != 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) {
-        return null;
+        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 getStoreStorePlatformInfo(long id, long supplierCode) {
+        return this.getESOneInfo(esClient, jsonConvert, StorePlatform.class,
+                String.valueOf(id),
+                keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_INFO_INDEX, supplierCode),
+                ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE,
+                null);
     }
 
     @Override
     public RetResult<StorePlatform> addStorePlatform(StorePlatform storePlatform, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
-        return null;
+        StorePlatform esInfo = this.getESOneInfo(esClient, jsonConvert,
+                StorePlatform.class,
+                (a) -> {
+                    BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE));
+                    qb.must(QueryBuilders.termQuery("idPlatformInfo", storePlatform.getIdPlatformInfo()));
+                    return qb;
+                },
+                keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode),
+                null);
+        if (esInfo != null)
+            return RetResult.<StorePlatform>errorT().retinfo("此平台已开通:" + storePlatform.getPlatformName());
+
+        storePlatform.setId(tableIdService.getTableIdMulti("tbStorePlatform.id", 1, dataSourceId, String.valueOf(supplierCode)));
+        StorePlatform.create(storePlatform, currentUser.getId());
+        storePlatform.setEnableStatue(0);
+
+        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)
+                .setId(String.valueOf(storePlatform.getId()))
+                .setSource(jsonConvert.convertTo(storePlatform), XContentType.JSON));
+
+        storePlatform.getRequireList().forEach(x -> {
+            x.setId(tableIdService.getTableIdMulti("tbStorePlatformRequire.id", 1, dataSourceId, String.valueOf(supplierCode)));
+            x.setIdStore(storePlatform.getIdStore());
+            x.setIdStorePlatform(storePlatform.getId());
+            StorePlatformRequire.create(x, currentUser.getId());
+
+            bulkRequest.add(esClient.getClient().prepareIndex(
+                            keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_PLATFORM_REQUIRE_TYPE)
+                    .setId(String.valueOf(x.getId()))
+                    .setParent(String.valueOf(storePlatform.getId()))
+                    .setSource(jsonConvert.convertTo(storePlatform), XContentType.JSON));
+        });
+
+        BulkResponse bulkResponse = bulkRequest.get();
+
+        if (bulkResponse.hasFailures()) {
+            logger.error("门店开通平台出错:" + bulkResponse.buildFailureMessage());
+            return RetResult.<StorePlatform>errorT().retinfo("门店开通平台出错:" + storePlatform.getPlatformName());
+        } else {
+            logger.info("门店开通平台成功");
+            //写数据库
+            storeDao.addStorePlatform(storePlatform, storePlatform.getRequireList(), dataSourceId, supplierCode);
+            return RetResult.successT();
+        }
     }
 
     @Override
     public RetResult<StorePlatform> configStorePlatform(StorePlatform storePlatform, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
-        return null;
+        StorePlatform esInfo = this.getStoreStorePlatformInfo(storePlatform.getId(), supplierCode);
+        if (esInfo == null) {
+            return RetResult.<StorePlatform>errorT().retinfo("未找到此开通平台");
+        }
+
+        esInfo.setIdStore(storePlatform.getIdPlatformInfo());
+        esInfo.setPlatformName(storePlatform.getPlatformName());
+        esInfo.setPlatformType(storePlatform.getPlatformType());
+        esInfo.setEnableStatue(storePlatform.getEnableStatue());
+        StorePlatform.update(esInfo, currentUser.getId());
+
+        BulkRequestBuilder bulkRequest = esClient.getClient().prepareBulk().setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
+        UpdateRequest updateRequest = null;
+        try {
+            updateRequest = new UpdateRequest(keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode),
+                    ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE, String.valueOf(esInfo.getId()))
+                    .doc(jsonBuilder()
+                            .startObject()
+                            .field("idPlatformInfo", esInfo.getIdPlatformInfo())
+                            .field("platformName", esInfo.getPlatformName())
+                            .field("platformType", esInfo.getPlatformType())
+                            .field("enableStatue", esInfo.getEnableStatue())
+                            .field("updateTimeLong", esInfo.getUpdateTimeLong())
+                            .field("updateBy", esInfo.getUpdateBy())
+                            .endObject());
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        bulkRequest.add(updateRequest);
+
+        storePlatform.getRequireList().forEach(x -> {
+            if (x.getId() <= 0) {
+                x.setId(tableIdService.getTableIdMulti("tbStorePlatformRequire.id", 1, dataSourceId, String.valueOf(supplierCode)));
+                StorePlatformRequire.create(x, currentUser.getId());
+            }
+            x.setIdStore(storePlatform.getIdStore());
+            x.setIdStorePlatform(storePlatform.getIdPlatformInfo());
+            StorePlatformRequire.update(x, currentUser.getId());
+            bulkRequest.add(esClient.getClient().prepareIndex(
+                            keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_PLATFORM_REQUIRE_TYPE)
+                    .setId(String.valueOf(x.getId()))
+                    .setParent(String.valueOf(storePlatform.getId()))
+                    .setSource(jsonConvert.convertTo(storePlatform), XContentType.JSON));
+        });
+
+        BoolQueryBuilder qbOrderPart = QueryBuilders.boolQuery()
+                .must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_PLATFORM_REQUIRE_TYPE))
+                .must(QueryBuilders.termQuery("idStorePlatform", esInfo.getId()));
+        DeleteByQueryAction.INSTANCE.newRequestBuilder(esClient.getClient())
+                .refresh(true)
+                .source(keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode))
+                .filter(qbOrderPart)
+                .get();
+
+        BulkResponse bulkResponse = bulkRequest.get();
+
+        if (bulkResponse.hasFailures()) {
+            logger.error("门店配置平台出错:" + bulkResponse.buildFailureMessage());
+            return RetResult.<StorePlatform>errorT().retinfo("门店配置平台出错:" + storePlatform.getPlatformName());
+        } else {
+            logger.info("门店配置平台成功");
+            //写数据库
+            storeDao.updateStorePlatform(esInfo, storePlatform.getRequireList(), dataSourceId, supplierCode);
+            return RetResult.successT();
+        }
     }
+    //endregion
 }

+ 13 - 1
ddCommon/src/main/java/com/dderp/common/api/StoreService.java

@@ -28,15 +28,27 @@ public interface StoreService extends ScriptService {
     //region 门店管理
     List<ViewStoreInfo> queryViewStoreInfo(RMap params, PageFlipper pageFlipper, long supplierCode);
 
-    ViewStoreInfo getViewStoreInfo(long idStore, long supplierCode, int withInvoice);
+    ViewStoreInfo getViewStoreInfo(long idStore, long supplierCode, boolean readInvoice,boolean readEmployee,boolean readPlatform);
 
     RetResult<StoreInfo> addStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
 
+    /**
+     * 获取门店开票信息
+     */
+    StoreInvoiceInfo getStoreInvoiceInfo(long idStore,long supplierCode);
+
     RetResult<StoreInvoiceInfo> configStoreInvoiceInfo(StoreInvoiceInfo invoiceInfo, int enableInvoice, 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 门店平台
+    /**
+     * 获取已开通平台信息
+     */
+    StorePlatform getStoreStorePlatformInfo(long id,long supplierCode);
 
     RetResult<StorePlatform> addStorePlatform(StorePlatform storePlatform, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
 

+ 17 - 1
ddCommon/src/main/java/com/dderp/common/entity/store/StoreInfo.java

@@ -4,6 +4,7 @@ import com.dderp.common.entity.base.BaseEntity;
 import com.dderp.common.entity.geo.GeoPoiLocation;
 import com.dderp.common.entity.system.LoginUser;
 import com.sweetfish.util.Comment;
+import org.apache.commons.lang3.StringUtils;
 import org.rex.db.RColumn;
 
 import java.util.ArrayList;
@@ -59,6 +60,10 @@ public class StoreInfo extends BaseEntity {
     @Comment("门店geo信息")
     private GeoPoiLocation location;
 
+    @Comment("经度,纬度")
+    @RColumn("locationstr")
+    private String locationStr;
+
     @RColumn("contractphone")
     @Comment("门店联系电话")
     private String contractPhone;
@@ -87,7 +92,7 @@ public class StoreInfo extends BaseEntity {
     @RColumn("voidflag")
     private int voidFlag;
 
-    @Comment("启用开票信息标记")
+    @Comment("启用开票信息标记1启用,0不启用")
     @RColumn("enableinvoice")
     private int enableInvoice;
     @Comment("门店开票信息")
@@ -195,6 +200,14 @@ public class StoreInfo extends BaseEntity {
         this.location = location;
     }
 
+    public String getLocationStr() {
+        return locationStr;
+    }
+
+    public void setLocationStr(String locationStr) {
+        this.locationStr = locationStr;
+    }
+
     public String getContractPhone() {
         return contractPhone;
     }
@@ -282,4 +295,7 @@ public class StoreInfo extends BaseEntity {
     public void setEnableInvoice(int enableInvoice) {
         this.enableInvoice = enableInvoice;
     }
+
+
+
 }

+ 6 - 1
ddCommon/src/main/java/com/dderp/common/servlet/file/FileUploadServlet.java

@@ -18,7 +18,7 @@ import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
-import java.util.UUID;
+import java.util.*;
 
 import static com.sweetfish.net.Server.RESNAME_SERVER_ROOT;
 
@@ -137,4 +137,9 @@ public class FileUploadServlet extends ERPAdminHttpServlet {
         }
         resp.finish("success");
     }
+
+    @HttpMapping(url = "/upload/uploadStoreBrandLogo", auth = true, comment = "门店品牌logo上传")
+    public void uploadStoreBrandLogo(HttpRequest req, HttpResponse resp) throws IOException {
+        //todo 感觉logo只是展示用,需要记录下存放位置即可,不需要下载,待大哥有空的时候详细问下
+    }
 }