|
|
@@ -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
|
|
|
+
|
|
|
}
|