Commit 53ad2e6f by 陶光胜

Merge branch 'developer' into 'master'

Developer

See merge request !33
parents 72968cd9 8b903107
......@@ -94,7 +94,7 @@ public class ClerkDTO implements Serializable {
}
public void setClerkName(String clerkName) {
this.clerkName = clerkName;
this.clerkName = clerkName.trim();
}
public String getClerkCode() {
......@@ -102,7 +102,7 @@ public class ClerkDTO implements Serializable {
}
public void setClerkCode(String clerkCode) {
this.clerkCode = clerkCode;
this.clerkCode = clerkCode.trim();
}
public Integer getEnterpriseId() {
......
......@@ -135,7 +135,7 @@ public class StoreInfoDTO implements Serializable {
}
public void setStoreName(String storeName) {
this.storeName = storeName;
this.storeName = storeName.trim();
}
public String getStoreCode() {
......@@ -143,7 +143,7 @@ public class StoreInfoDTO implements Serializable {
}
public void setStoreCode(String storeCode) {
this.storeCode = storeCode;
this.storeCode = storeCode.trim();
}
public Integer getRegionId() {
......
......@@ -54,8 +54,6 @@ public class StoreStrategyDTO implements Serializable {
/**
* 门店分组条件,json数组
*/
@NotBlank(message = "门店属性条件配置不能为空", groups = { StoreStrategyApiService.SaveStoreStrategy.class,
StoreStrategyApiService.ModifyStoreStrategy.class })
private String conditions;
/**
......
......@@ -134,6 +134,8 @@ public interface ClerkApiService {

*/
ServiceResponse<ClerkDTO> getHeadClerk(Integer enterpriseId, Integer storeId);
ServiceResponse<ClerkDTO> getHeadClerkByStoreInfoId(Integer enterpriseId, Integer storeInfoId);
ServiceResponse<ClerkDTO> getClerkById(Integer enterpriseId, Integer clerkId);
ServiceResponse<List<ClerkDTO>> listClerk(Integer enterpriseId, String search);
......
......@@ -32,6 +32,8 @@ public interface StoreApiService {
*/
ServiceResponse<Integer> saveStoreForOrder(Integer enterpriseId, String storeCode, String storeName, Integer regionId, String orderNum);
ServiceResponse<Integer> saveStoreForOrder(Integer enterpriseId, String storeCode, String storeName, Integer regionId, String orderNum, Integer storeBrandId);
/**
* @Title: saveStoreForPosMember
* @Description: 同步pos会员创建门店
......@@ -46,6 +48,8 @@ public interface StoreApiService {
*/
ServiceResponse<Integer> saveStoreForPosMember(Integer enterpriseId, String storeCode, String storeName, Integer regionId, String cardNO);
ServiceResponse<Integer> saveStoreForPosMember(Integer enterpriseId, String storeCode, String storeName, Integer regionId, String cardNO, Integer storeBrandId);
/**
* @Title: countByOverflowStatus
* @Description:
......
......@@ -146,6 +146,11 @@
<artifactId>gic-weimob-api</artifactId>
<version>${gic-weimob-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-spark-run-api</artifactId>
<version>${gic-spark-run-api}</version>
</dependency>
</dependencies>
<build>
......
......@@ -84,4 +84,6 @@ public interface TabClerkMapper {
List<TabClerk> listHaobanClerk(@Param("enterpriseIdList") List<Integer> enterpriseIdList, @Param("keyword") String keyword, @Param("storeInfoIdList") List<Integer> storeInfoIdList);
List<TabClerk> listClerkByPositionId(@Param("enterpriseId") Integer enterpriseId, @Param("positionId") Integer positionId);
List<Integer> listAllClerkId(@Param("enterpriseId") Integer enterpriseId);
}
\ No newline at end of file
......@@ -85,6 +85,8 @@ public interface TabStoreInfoMapper {
List<Integer> listAllstoreInfoId(@Param("enterpriseId") Integer enterpriseId);
List<Integer> listAllstoreId(@Param("enterpriseId") Integer enterpriseId);
TabStoreInfo getByStore(@Param("store") StoreDTO store);
StoreDTO getDTOByStore(@Param("store") StoreDTO store);
......
......@@ -106,12 +106,12 @@ public interface ClerkService {
* @Description: 批量修改导购状态
* @author zhiwj
* @param enterpriseId 企业id
* @param clerkIds 导购ids
* @param clerkIdList 导购ids
* @param status 状态
* @return java.lang.Integer
* @throws
*/
Integer updateClerkStatus(Integer enterpriseId, String clerkIds, Integer status);
Integer updateClerkStatus(Integer enterpriseId, List<Integer> clerkIdList, Integer status);
List<TabClerk> listClerkByIds(Integer enterpriseId, String clerkIds);
......@@ -132,4 +132,6 @@ public interface ClerkService {
List<TabClerk> listHaobanClerk(List<Integer> enterpriseIdList, String keyword, List<Integer> storeInfoIdList);
List<TabClerk> listClerkByPositionId(Integer enterpriseId, Integer positionId);
List<Integer> listAllClerkId(Integer enterpriseId);
}
......@@ -86,6 +86,8 @@ public interface StoreService {
List<Integer> listAllStoreId(Integer enterpriseId);
List<Integer> listAllStoreInfoId(Integer enterpriseId);
boolean validateStoreCodeIsExist(Integer enterpriseId, Integer regionId, String storeCode, Integer storeId);
/**
......
......@@ -120,18 +120,7 @@ public class ClerkServiceImpl implements ClerkService {
}
@Override
public Integer updateClerkStatus(Integer enterpriseId, String clerkIds, Integer status) {
List<Integer> clerkIdList;
if (StringUtils.isNotBlank(clerkIds)) {
if (StringUtils.equals("all", clerkIds)) {
clerkIdList = null;
} else {
String[] split = clerkIds.split(GlobalInfo.FLAG_COMMA);
clerkIdList = Stream.of(split).map(Integer::parseInt).collect(Collectors.toList());
}
} else {
return 0;
}
public Integer updateClerkStatus(Integer enterpriseId, List<Integer> clerkIdList, Integer status) {
return tabClerkMapper.updateClerkStatus(enterpriseId, clerkIdList, status);
}
......@@ -197,4 +186,9 @@ public class ClerkServiceImpl implements ClerkService {
return tabClerkMapper.listClerkByPositionId(enterpriseId, positionId);
}
@Override
public List<Integer> listAllClerkId(Integer enterpriseId) {
return tabClerkMapper.listAllClerkId(enterpriseId);
}
}
......@@ -92,7 +92,8 @@ public class StoreLogServiceImpl implements StoreLogService {
storeLog.setOperatorId(operatorId);
storeLog.setOperatorName(operatorName);
storeLog.setContent(content);
for (Integer storeId : storeInfoIdList) {
List<Integer> storeIdList = storeService.listStoredByStoreInfoList(storeInfoIdList, enterpriseId);
for (Integer storeId : storeIdList) {
storeLog.setStoreId(storeId);
tabStoreLogMapper.insertSelective(storeLog);
}
......
......@@ -226,13 +226,13 @@ public class StoreServiceImpl implements StoreService {
}
@Override
public int bulkUpdateStoreStatus(String storeIds, Integer enterpriseId, String value) {
if ("all".equals(storeIds)) {
public int bulkUpdateStoreStatus(String storeInfoIds, Integer enterpriseId, String value) {
if ("all".equals(storeInfoIds)) {
return this.tabStoreInfoMapper.updateAllStoreStatus(enterpriseId, Integer.valueOf(value));
}
String[] storeIdArr = storeIds.split(",");
String[] storeInfoIdArr = storeInfoIds.split(",");
List<Integer> list = new ArrayList<>();
for (String s : storeIdArr) {
for (String s : storeInfoIdArr) {
list.add(Integer.valueOf(s));
}
return this.tabStoreInfoMapper.updateStoreStatusBystoreInfoIds(Integer.valueOf(value), list);
......@@ -388,6 +388,11 @@ public class StoreServiceImpl implements StoreService {
@Override
public List<Integer> listAllStoreId(Integer enterpriseId) {
return this.tabStoreInfoMapper.listAllstoreId(enterpriseId);
}
@Override
public List<Integer> listAllStoreInfoId(Integer enterpriseId) {
return this.tabStoreInfoMapper.listAllstoreInfoId(enterpriseId);
}
......@@ -548,4 +553,4 @@ public class StoreServiceImpl implements StoreService {
public int refreshStoreIndex(Integer enterpriseId, Integer storeGroupId) {
return this.tabStoreMapper.refreshStoreIndexByStoreGroup(enterpriseId, storeGroupId);
}
}
}
\ No newline at end of file
......@@ -192,6 +192,19 @@ public class StoreStrategyServiceImpl implements StoreStrategyService{
validSize ++;
if (strategyType == StoreGroupConstant.STORE_STRATEGY_TYPE) {
//如果是门店启用状态策略,需要验证门店创建方式
if (!isValueHitStrategy(store.getCreateType().toString(), storeCreateType)) {
continue;
}
if (StringUtils.isBlank(conditions)) {
//如果没有条件,则是所有门店适用
result = targetValue;
break;
}
validSize ++;
}
JSONArray jsonArray = JSONArray.parseArray(conditions);
for (int i = 0, length = jsonArray.size(); i < length; i ++) {
JSONObject object = jsonArray.getJSONObject(i);
......@@ -230,13 +243,6 @@ public class StoreStrategyServiceImpl implements StoreStrategyService{
validSize ++;
}
if (strategyType == StoreGroupConstant.STORE_STRATEGY_TYPE) {
//如果是门店启用状态策略,需要验证门店创建方式
if (!isValueHitStrategy(store.getCreateType().toString(), storeCreateType)) {
continue;
}
validSize ++;
}
int hitSize;
if (strategyType == StoreGroupConstant.STORE_STRATEGY_TYPE) {
......
......@@ -6,6 +6,7 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.CollectionUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.commons.util.GlobalInfo;
import com.gic.enterprise.constants.Constants;
import com.gic.enterprise.dto.wm.WmStoreSyncLogDTO;
import com.gic.enterprise.error.ErrorCode;
......@@ -13,6 +14,7 @@ import com.gic.enterprise.response.EnterpriseServiceResponse;
import com.gic.enterprise.service.EnterpriseApiService;
import com.gic.enterprise.service.WmStoreSyncLogApiService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.spark.api.service.SparkJobApiService;
import com.gic.store.constant.ClerkLogReasonEnum;
import com.gic.store.constant.ImportClerkBatchResultEnum;
import com.gic.store.constant.StoreLogTypeEnum;
......@@ -35,6 +37,7 @@ import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author zhiwj
......@@ -67,6 +70,8 @@ public class ClerkApiServiceImpl implements ClerkApiService {
private WmStoreSyncLogApiService wmStoreSyncLogApiService;
@Autowired
private ClerkPositionService clerkPositionService;
@Autowired
private SparkJobApiService sparkJobApiService;
@Override
public ServiceResponse saveOrUpdate(ClerkDTO clerkDTO) {
......@@ -94,10 +99,10 @@ public class ClerkApiServiceImpl implements ClerkApiService {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店下导购手机号重复");
}
}
if (clerkService.isRepeatByClerkName(clerkDTO.getStoreInfoId(), clerkDTO.getClerkName(),
clerkDTO.getClerkId())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店下导购名称重复");
}
// if (clerkService.isRepeatByClerkName(clerkDTO.getStoreInfoId(), clerkDTO.getClerkName(),
// clerkDTO.getClerkId())) {
// return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店下导购名称重复");
// }
if (clerkDTO.getPositionId() == null) {
clerkDTO.setPositionId(com.gic.store.constant.Constants.CLERK_POSITION_ID);
......@@ -431,7 +436,21 @@ public class ClerkApiServiceImpl implements ClerkApiService {
@Override
public ServiceResponse updateClerkStatus(Integer enterpriseId, String clerkIds, Integer status) {
return ServiceResponse.success(clerkService.updateClerkStatus(enterpriseId, clerkIds, status));
List<Integer> clerkIdList;
if (StringUtils.isNotBlank(clerkIds)) {
if (StringUtils.equals("all", clerkIds)) {
clerkIdList = clerkService.listAllClerkId(enterpriseId);
} else {
String[] split = clerkIds.split(GlobalInfo.FLAG_COMMA);
clerkIdList = Stream.of(split).map(Integer::parseInt).collect(Collectors.toList());
}
Integer i = clerkService.updateClerkStatus(enterpriseId, clerkIdList, status);
for (Integer clerkId : clerkIdList) {
sparkJobApiService.updateClerkStatus(enterpriseId, clerkId.longValue(), 1 == status ? 0 : 1);
}
}
return ServiceResponse.success();
}
@Override
......@@ -465,10 +484,16 @@ public class ClerkApiServiceImpl implements ClerkApiService {
public ServiceResponse<ClerkDTO> getHeadClerk(Integer enterpriseId, Integer storeId) {
ServiceResponse<StoreDTO> response = storeApiService.getStoreById(enterpriseId, storeId);
if (response.isSuccess() && response.getResult() != null) {
TabClerk clerkLeader = clerkService.getClerkLeaderByStoreInfoId(enterpriseId, response.getResult().getStoreInfoId());
if (clerkLeader != null) {
return ServiceResponse.success(EntityUtil.changeEntityNew(ClerkDTO.class, clerkLeader));
}
return this.getHeadClerkByStoreInfoId(enterpriseId, response.getResult().getStoreInfoId());
}
return ServiceResponse.success();
}
@Override
public ServiceResponse<ClerkDTO> getHeadClerkByStoreInfoId(Integer enterpriseId, Integer storeInfoId) {
TabClerk clerkLeader = clerkService.getClerkLeaderByStoreInfoId(enterpriseId, storeInfoId);
if (clerkLeader != null) {
return ServiceResponse.success(EntityUtil.changeEntityNew(ClerkDTO.class, clerkLeader));
}
return ServiceResponse.success();
}
......
......@@ -24,6 +24,7 @@ import com.gic.search.business.api.dto.DynamicSearchDTO;
import com.gic.search.business.api.dto.ESResponseQueryBatchDTO;
import com.gic.search.business.api.service.EsBusinessOperaApiService;
import com.gic.search.business.api.utils.QueryConditionAssemblyUtil;
import com.gic.spark.api.service.SparkJobApiService;
import com.gic.store.constant.*;
import com.gic.store.dto.*;
import com.gic.store.entity.*;
......@@ -112,6 +113,8 @@ public class StoreApiServiceImpl implements StoreApiService {
private WeimobStoreSiteService weimobStoreSiteService;
@Autowired
private WmStoreSyncLogApiService wmStoreSyncLogApiService;
@Autowired
private SparkJobApiService sparkJobApiService;
private Map<String, BulkUpdateStoreStrtegy> storeStrtegyMap = new ConcurrentHashMap<>();
......@@ -205,6 +208,10 @@ public class StoreApiServiceImpl implements StoreApiService {
//修改门店同步到微盟
updateStoreToWm(storeDTO);
// 给会员组发通知
if (StringUtils.isNotBlank(storeDTO.getBrandIds()) && !StringUtils.equals(existStore.getResult().getBrandIds(), storeDTO.getBrandIds())) {
sparkJobApiService.updateStoreBrand(storeDTO.getEnterpriseId(), storeDTO.getStoreInfoId(), Integer.parseInt(existStore.getResult().getBrandIds()), Integer.parseInt(storeDTO.getBrandIds()));
}
}
// 自定义属性
String error = storeExtendService.saveOrUpdate(storeDTO.getEnterpriseId(), storeDTO.getStoreInfoId(), storeDTO.getStoreExtendList());
......@@ -228,21 +235,43 @@ public class StoreApiServiceImpl implements StoreApiService {
// 更新缓存
refreshCache(storeDTO.getEnterpriseId(), storeDTO.getStoreId());
JSONObject json = new JSONObject();
/* JSONObject json = new JSONObject();
json.put("enterpriseId", storeDTO.getEnterpriseId());
json.put("storeId", storeDTO.getStoreId());
json.put("logId", -1);
this.addStoreToIndexMq(json.toJSONString());
this.addStoreToIndexMq(json.toJSONString());*/
return ServiceResponse.success(storeDTO);
}
@Override
public ServiceResponse<Integer> saveStoreForOrder(Integer enterpriseId, String storeCode, String storeName, Integer regionId, String orderNum) {
return saveStoreForOrder(enterpriseId, storeCode, storeName, regionId, orderNum, null);
}
@Override
public ServiceResponse<Integer> saveStoreForOrder(Integer enterpriseId, String storeCode, String storeName, Integer regionId, String orderNum, Integer storeBrandId) {
ServiceResponse<List<EnterpriseLicenseDTO>> listEnterpriseLicense = this.enterpriseApiService.listEnterpriseLicense(enterpriseId);
Integer storeLicenseNum = 0;
if(listEnterpriseLicense.isSuccess() && CollectionUtils.isNotEmpty(listEnterpriseLicense.getResult())){
boolean hasStoreLicense = listEnterpriseLicense.getResult()
.stream()
.anyMatch(e -> LicenseUtils.STORE_LICENSE_CODE.equals(e.getLicenseCode()));
if(hasStoreLicense){
storeLicenseNum = listEnterpriseLicense.getResult().stream()
.filter(e -> LicenseUtils.STORE_LICENSE_CODE.equals(e.getLicenseCode()))
.collect(Collectors.toList()).get(0).getUpperLimit();
}
}
Integer count = this.storeService.countByStoreName(enterpriseId, null, null);
if(count >= storeLicenseNum){
return ServiceResponse.failure(ErrorCode.SYSTEM_ERROR.getCode(), "门店license超出限制");
}
StoreDTO storeDTO = new StoreDTO();
storeDTO.setEnterpriseId(enterpriseId);
storeDTO.setStoreCode(storeCode);
storeDTO.setStoreName(storeName);
storeDTO.setRegionId(regionId);
storeDTO.setStoreBrands(storeBrandId.toString());
storeDTO.setCreateType(CreateTypeEnum.ORDER.getCode());
ServiceResponse<StoreDTO> response = this.saveOrUpdate(storeDTO);
if(response.isSuccess()){
......@@ -253,11 +282,33 @@ public class StoreApiServiceImpl implements StoreApiService {
@Override
public ServiceResponse<Integer> saveStoreForPosMember(Integer enterpriseId, String storeCode, String storeName, Integer regionId, String cardNO) {
return saveStoreForPosMember(enterpriseId, storeCode, storeName, regionId, cardNO, null);
}
@Override
public ServiceResponse<Integer> saveStoreForPosMember(Integer enterpriseId, String storeCode, String storeName, Integer regionId, String cardNO, Integer storeBrandId) {
ServiceResponse<List<EnterpriseLicenseDTO>> listEnterpriseLicense = this.enterpriseApiService.listEnterpriseLicense(enterpriseId);
Integer storeLicenseNum = 0;
if(listEnterpriseLicense.isSuccess() && CollectionUtils.isNotEmpty(listEnterpriseLicense.getResult())){
boolean hasStoreLicense = listEnterpriseLicense.getResult()
.stream()
.anyMatch(e -> LicenseUtils.STORE_LICENSE_CODE.equals(e.getLicenseCode()));
if(hasStoreLicense){
storeLicenseNum = listEnterpriseLicense.getResult().stream()
.filter(e -> LicenseUtils.STORE_LICENSE_CODE.equals(e.getLicenseCode()))
.collect(Collectors.toList()).get(0).getUpperLimit();
}
}
Integer count = this.storeService.countByStoreName(enterpriseId, null, null);
if(count >= storeLicenseNum){
return ServiceResponse.failure(ErrorCode.SYSTEM_ERROR.getCode(), "门店license超出限制");
}
StoreDTO storeDTO = new StoreDTO();
storeDTO.setEnterpriseId(enterpriseId);
storeDTO.setStoreCode(storeCode);
storeDTO.setStoreName(storeName);
storeDTO.setRegionId(regionId);
storeDTO.setBrandIds(storeBrandId.toString());
storeDTO.setCreateType(CreateTypeEnum.MEMBER.getCode());
ServiceResponse<StoreDTO> response = this.saveOrUpdate(storeDTO);
if(response.isSuccess()){
......@@ -452,7 +503,7 @@ public class StoreApiServiceImpl implements StoreApiService {
private String validBrandIsExist(String brandIds) {
if (StringUtils.isBlank(brandIds)) {
return null;
return "请填写店招品牌";
}
List<TabStoreBrand> storeBrandList = storeBrandService.listStoreBrandByIds(brandIds);
if (CollectionUtils.isEmpty(storeBrandList) || brandIds.split(GlobalInfo.FLAG_COMMA).length > storeBrandList.size()) {
......@@ -530,7 +581,8 @@ public class StoreApiServiceImpl implements StoreApiService {
sortJson = QueryConditionAssemblyUtil.createSortNodeByLocation(StoreESFieldsEnum.LOCATION.getField(), QueryConditionAssemblyUtil.SORT_RULE_ASC,
Double.valueOf(storeSearchDTO.getLatitude()), Double.valueOf(storeSearchDTO.getLongitude()));
}else {
sortJson = QueryConditionAssemblyUtil.createSortNode(StoreESFieldsEnum.UPDATETIME.getField(), QueryConditionAssemblyUtil.SORT_RULE_DESC);
sortJson = QueryConditionAssemblyUtil.createSortNode(StoreESFieldsEnum.STATUS.getField(), QueryConditionAssemblyUtil.SORT_RULE_ASC);
// sortJson = QueryConditionAssemblyUtil.createSortNode(StoreESFieldsEnum.UPDATETIME.getField(), QueryConditionAssemblyUtil.SORT_RULE_DESC);
}
ServiceResponse<ESResponseQueryBatchDTO> response = this.queryStoreFromES(enterpriseJson, pageNum, pageSize, sortJson, returnFileds);
if (response.isSuccess() && response.getResult() != null) {
......@@ -1082,7 +1134,12 @@ public class StoreApiServiceImpl implements StoreApiService {
if(response.isSuccess() && response.getResult() != null){
List<StoreDTO> result = response.getResult().getResult();
if(CollectionUtils.isNotEmpty(result)){
return ServiceResponse.success(result.get(0));
StoreDTO storeDTO = result.get(0);
if (CollectionUtils.isNotEmpty(storeDTO.getLocation())) {
storeDTO.setLongitude(storeDTO.getLocation().get(0).toString());
storeDTO.setLatitude(storeDTO.getLocation().get(1).toString());
}
return ServiceResponse.success(storeDTO);
}
}
return ServiceResponse.success();
......@@ -1249,7 +1306,12 @@ public class StoreApiServiceImpl implements StoreApiService {
}
int i = 0;
try {
String storeInfoIds = storeService.listStoreInfoIdByStoreIds(storeIds, enterpriseId);
String storeInfoIds;
if (StringUtils.equals("all", storeIds)) {
storeInfoIds = "all";
} else {
storeInfoIds = storeService.listStoreInfoIdByStoreIds(storeIds, enterpriseId);
}
if (StringUtils.isBlank(storeInfoIds)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店不存在或非自有门店");
}
......
......@@ -53,12 +53,22 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
}
}
String conditions = storeStrategyDTO.getConditions();
//验证conditions合法性
if (isConditionsSizeOver(conditions)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店属性条件配置超出5个");
boolean isNotRightConditionsField = storeStrategyDTO.getStrategyType() != StoreGroupConstant.STORE_STRATEGY_TYPE && StringUtils.isBlank(conditions);
if (isNotRightConditionsField) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店分组策略条件不能为空");
}
if (validConditionsIsRepeatKey(conditions)) {
ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店属性条件每一种都不能重复");
//是否是门店启用状态没有选择条件,即所有门店策略
boolean isAllConditions = storeStrategyDTO.getStrategyType() == StoreGroupConstant.STORE_STRATEGY_TYPE && StringUtils.isBlank(conditions);
if (!isAllConditions) {
//验证conditions合法性
if (isConditionsSizeOver(conditions)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店属性条件配置超出5个");
}
if (validConditionsIsRepeatKey(conditions)) {
ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店属性条件每一种都不能重复");
}
}
storeStrategyDTO.setCreateTime(new Date());
......@@ -96,12 +106,22 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "策略主键ID错误,查询不到数据");
}
String conditions = storeStrategyDTO.getConditions();
//验证conditions合法性
if (isConditionsSizeOver(conditions)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店属性条件配置超出5个");
boolean isNotRightConditionsField = storeStrategyDTO.getStrategyType() != StoreGroupConstant.STORE_STRATEGY_TYPE && StringUtils.isBlank(conditions);
if (isNotRightConditionsField) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店分组策略条件不能为空");
}
if (validConditionsIsRepeatKey(conditions)) {
ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店属性条件每一种都不能重复");
//是否是门店启用状态没有选择条件,即所有门店策略
boolean isAllConditions = storeStrategyDTO.getStrategyType() == StoreGroupConstant.STORE_STRATEGY_TYPE && StringUtils.isBlank(conditions);
if (!isAllConditions) {
//验证conditions合法性
if (isConditionsSizeOver(conditions)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店属性条件配置超出5个");
}
if (validConditionsIsRepeatKey(conditions)) {
ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店属性条件每一种都不能重复");
}
}
if (storeStrategy.getStrategyType() == StoreGroupConstant.STORE_STRATEGY_TYPE) {
//如果是门店状态策略类型,必须有
......
......@@ -12,7 +12,6 @@ import com.gic.store.service.*;
import com.gic.store.utils.baidumap.BaiduMapUtils;
import com.gic.store.utils.baidumap.Location;
import com.github.pagehelper.Page;
import com.google.common.base.Joiner;
import com.task.allocation.api.AbstractTaskAllocationOperation;
import com.task.allocation.exception.TaskAllocationException;
import com.task.allocation.qo.InitTaskQO;
......@@ -24,7 +23,10 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
/**
* @author zhiwj
......@@ -126,16 +128,18 @@ public class StoreTaskServiceImpl extends AbstractTaskAllocationOperation implem
if (StringUtils.isNotBlank(brands)) {
String[] brandArr = brands.trim().split("、");
List<TabStoreBrand> storeBrandList = storeBrandService.listAllStoreBrand(t.getEnterpriseId(), null);
TabStoreBrand storeBrand = storeBrandService.getByStoreBrandName(t.getEnterpriseId(), brands);
List<Integer> list = new ArrayList<>();
for (String brandName : brandArr) {
for (TabStoreBrand storeBrand : storeBrandList) {
if (storeBrand.getStoreBrandName().equals(brandName)) {
list.add(storeBrand.getStoreBrandId());
break;
}
}
}
storeDTO.setBrandIds(Joiner.on(GlobalInfo.FLAG_COMMA).join(list));
// for (String brandName : brandArr) {
// for (TabStoreBrand storeBrand : storeBrandList) {
// if (storeBrand.getStoreBrandName().equals(brandName)) {
// list.add(storeBrand.getStoreBrandId());
// break;
// }
// }
// }
// storeDTO.setBrandIds(Joiner.on(GlobalInfo.FLAG_COMMA).join(list));
storeDTO.setBrandIds(storeBrand.getStoreBrandId().toString());
}
// 判断省市区
ServiceResponse<List<CityDTO>> cityResponse = provincesApiService.selectAllCity();
......
package com.gic.store.strategy.impl;
import com.gic.spark.api.service.SparkJobApiService;
import com.gic.store.dto.StoreDTO;
import com.gic.store.dto.StoreSearchDBDTO;
import com.gic.store.entity.TabStoreBrand;
import com.gic.store.service.StoreBrandService;
import com.gic.store.service.StoreLogService;
......@@ -12,6 +15,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Component("5")
public class StoreBrandUpdateStrategyImpl implements BulkUpdateStoreStrtegy {
......@@ -20,25 +24,54 @@ public class StoreBrandUpdateStrategyImpl implements BulkUpdateStoreStrtegy {
private StoreLogService storeLogService;
@Autowired
private StoreBrandService storeBrandService;
@Autowired
private SparkJobApiService sparkJobApiService;
@Override
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStoreBrands(storeInfoIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeIdList;
if ("all".equals(storeInfoIds)) {
storeIdList = storeService.listAllStoreId(enterpriseId);
} else {
storeIdList = new ArrayList<>();
String[] storeIdArr = storeInfoIds.split(",");
for (String s : storeIdArr) {
storeIdList.add(Integer.valueOf(s));
}
List<Integer> storeInfoIdList;
List<StoreDTO> storeList;
if ("all".equals(storeInfoIds)) {
StoreSearchDBDTO storeSearchDBDTO = new StoreSearchDBDTO();
storeSearchDBDTO.setOverflowStatus(0);
storeList = storeService.listStore(storeSearchDBDTO, 1, Integer.MAX_VALUE);
storeInfoIdList = storeService.listAllStoreInfoId(enterpriseId);
} else {
storeInfoIdList = new ArrayList<>();
String[] storeIdArr = storeInfoIds.split(",");
for (String s : storeIdArr) {
storeInfoIdList.add(Integer.valueOf(s));
}
List<TabStoreBrand> storeBrandList = storeBrandService.listStoreBrandByIds(storeInfoIds);
String content = Optional.ofNullable(storeBrandList).orElse(Collections.emptyList()).stream().map(TabStoreBrand::getStoreBrandName).reduce((x, y) -> x + "," + y).orElse("");
storeLogService.saveBulkStoreInfoLog(storeIdList, enterpriseId, operatorId, operatorName, "门店品牌变更为【" + content + "】");
StoreSearchDBDTO storeSearchDBDTO = new StoreSearchDBDTO();
storeSearchDBDTO.setOverflowStatus(0);
storeSearchDBDTO.setStoreInfoIdList(storeInfoIdList);
storeList = storeService.listStore(storeSearchDBDTO, 1, Integer.MAX_VALUE);
}
List<BrandUpdateDTO> brandUpdateList = new ArrayList<>(storeList.size());
for (StoreDTO storeDTO : storeList) {
brandUpdateList.add(new BrandUpdateDTO(storeDTO.getStoreInfoId(), Integer.valueOf(storeDTO.getBrandIds())));
}
int i = storeService.bulkUpdateStoreBrands(storeInfoIds, enterpriseId, value);
List<TabStoreBrand> storeBrandList = storeBrandService.listStoreBrandByIds(value);
String content = Optional.ofNullable(storeBrandList).orElse(Collections.emptyList()).stream().map(TabStoreBrand::getStoreBrandName).collect(Collectors.joining(","));
storeLogService.saveBulkStoreInfoLog(storeInfoIdList, enterpriseId, operatorId, operatorName, "门店品牌变更为【" + content + "】");
Integer newBrand = Integer.valueOf(value);
for (BrandUpdateDTO brandUpdateDTO : brandUpdateList) {
sparkJobApiService.updateStoreBrand(enterpriseId, brandUpdateDTO.storeInfoId, brandUpdateDTO.oldStoreBrand, newBrand);
}
return i;
}
class BrandUpdateDTO{
public Integer storeInfoId;
public Integer oldStoreBrand;
public BrandUpdateDTO(Integer storeInfoId, Integer oldStoreBrand) {
this.storeInfoId = storeInfoId;
this.oldStoreBrand = oldStoreBrand;
}
}
}
......@@ -28,7 +28,7 @@ public class StoreBusinessTimeStrategyImpl implements BulkUpdateStoreStrtegy {
if (i > 0) {
List<Integer> storeInfoIdList;
if ("all".equals(storeInfoIds)) {
storeInfoIdList = storeService.listAllStoreId(enterpriseId);
storeInfoIdList = storeService.listAllStoreInfoId(enterpriseId);
} else {
storeInfoIdList = new ArrayList<>();
String[] storeInfoIdArr = storeInfoIds.split(",");
......
......@@ -23,18 +23,18 @@ public class StoreGroupStrategyImpl implements BulkUpdateStoreStrtegy {
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStoreGroup(storeInfoIds, enterpriseId, Integer.valueOf(value));
if (i > 0) {
List<Integer> storeIdList;
List<Integer> storeInfoIdList;
if ("all".equals(storeInfoIds)) {
storeIdList = storeService.listAllStoreId(enterpriseId);
storeInfoIdList = storeService.listAllStoreInfoId(enterpriseId);
} else {
storeIdList = new ArrayList<>();
storeInfoIdList = new ArrayList<>();
String[] storeIdArr = storeInfoIds.split(",");
for (String s : storeIdArr) {
storeIdList.add(Integer.valueOf(s));
storeInfoIdList.add(Integer.valueOf(s));
}
}
TabStoreGroup group = storeGroupService.getStoreGroupById(Integer.valueOf(value));
storeLogService.saveBulkStoreGroupLog(storeIdList, enterpriseId, operatorId, operatorName, "门店分组变更为【" + group.getStoreGroupName() + "】");
storeLogService.saveBulkStoreGroupLog(storeInfoIdList, enterpriseId, operatorId, operatorName, "门店分组变更为【" + group.getStoreGroupName() + "】");
}
return i;
}
......
......@@ -19,17 +19,17 @@ public class StorePhoneStategyImpl implements BulkUpdateStoreStrtegy {
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStoreConactsPhone(storeInfoIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeIdList;
List<Integer> storeInfoIdList;
if ("all".equals(storeInfoIds)) {
storeIdList = storeService.listAllStoreId(enterpriseId);
storeInfoIdList = storeService.listAllStoreInfoId(enterpriseId);
} else {
storeIdList = new ArrayList<>();
storeInfoIdList = new ArrayList<>();
String[] storeIdArr = storeInfoIds.split(",");
for (String s : storeIdArr) {
storeIdList.add(Integer.valueOf(s));
storeInfoIdList.add(Integer.valueOf(s));
}
}
storeLogService.saveBulkStoreInfoLog(storeIdList, enterpriseId, operatorId, operatorName, "门店联系电话变更为【" + value + "】");
storeLogService.saveBulkStoreInfoLog(storeInfoIdList, enterpriseId, operatorId, operatorName, "门店联系电话变更为【" + value + "】");
}
return i;
}
......
......@@ -21,7 +21,7 @@ public class StorePhotoAddStrategyImpl implements BulkUpdateStoreStrtegy {
if (i > 0) {
List<Integer> storeInfoIdList;
if ("all".equals(storeInfoIds)) {
storeInfoIdList = storeService.listAllStoreId(enterpriseId);
storeInfoIdList = storeService.listAllStoreInfoId(enterpriseId);
} else {
storeInfoIdList = new ArrayList<>();
String[] storeIdArr = storeInfoIds.split(",");
......
......@@ -18,17 +18,17 @@ public class StorePhotoUpdateStrategyImpl implements BulkUpdateStoreStrtegy {
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStorePhoto(storeInfoIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeIdList;
List<Integer> storeInfoIdList;
if ("all".equals(storeInfoIds)) {
storeIdList = storeService.listAllStoreId(enterpriseId);
storeInfoIdList = storeService.listAllStoreInfoId(enterpriseId);
} else {
storeIdList = new ArrayList<>();
storeInfoIdList = new ArrayList<>();
String[] storeIdArr = storeInfoIds.split(",");
for (String s : storeIdArr) {
storeIdList.add(Integer.valueOf(s));
storeInfoIdList.add(Integer.valueOf(s));
}
}
storeLogService.saveBulkStoreInfoLog(storeIdList, enterpriseId, operatorId, operatorName, "门店照片变更");
storeLogService.saveBulkStoreInfoLog(storeInfoIdList, enterpriseId, operatorId, operatorName, "门店照片变更");
}
return i;
}
......
package com.gic.store.strategy.impl;
import com.gic.spark.api.service.SparkJobApiService;
import com.gic.store.constant.StoreStatusEnum;
import com.gic.store.service.StoreLogService;
import com.gic.store.service.StoreService;
......@@ -15,6 +16,8 @@ public class StoreStatusStrategyImpl implements BulkUpdateStoreStrtegy {
@Autowired
private StoreLogService storeLogService;
@Autowired
private SparkJobApiService sparkJobApiService;
@Override
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
......@@ -22,7 +25,7 @@ public class StoreStatusStrategyImpl implements BulkUpdateStoreStrtegy {
if (i > 0) {
List<Integer> storeInfoIdList;
if ("all".equals(storeInfoIds)) {
storeInfoIdList = storeService.listAllStoreId(enterpriseId);
storeInfoIdList = storeService.listAllStoreInfoId(enterpriseId);
} else {
storeInfoIdList = new ArrayList<>();
String[] storeIdArr = storeInfoIds.split(",");
......@@ -30,7 +33,13 @@ public class StoreStatusStrategyImpl implements BulkUpdateStoreStrtegy {
storeInfoIdList.add(Integer.valueOf(s));
}
}
storeLogService.saveBulkStoreStatusLog(storeInfoIdList, enterpriseId, operatorId, operatorName, "门店状态变更为【" + StoreStatusEnum.parseCode(Integer.parseInt(value)) + "】");
int valueCode = Integer.parseInt(value);
storeLogService.saveBulkStoreStatusLog(storeInfoIdList, enterpriseId, operatorId, operatorName, "门店状态变更为【" + StoreStatusEnum.parseCode(valueCode) + "】");
for (Integer storeInfoId : storeInfoIdList) {
// 启用禁用的值和会员组取的不一致 需要转换下
sparkJobApiService.updateStoreStatus(enterpriseId, storeInfoId, StoreStatusEnum.ONLINE.getCode() == valueCode ? 0 : 1);
}
}
return i;
}
......
......@@ -68,4 +68,5 @@
<dubbo:reference interface="com.gic.weimob.api.service.WeimobStoreSiteService" id="weimobStoreSiteService" timeout="6000"/>
<dubbo:reference interface="com.gic.enterprise.service.WmStoreSyncLogApiService" id="wmStoreSyncLogApiService" timeout="6000"/>
<dubbo:reference interface="com.gic.spark.api.service.SparkJobApiService" id="sparkJobApiService" timeout="6000"/>
</beans>
......@@ -402,4 +402,10 @@
</if>
</where>
</select>
<select id="listAllClerkId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_clerk
where enterprise_id = #{enterpriseId}
</select>
</mapper>
\ No newline at end of file
......@@ -484,6 +484,10 @@
select t1.store_info_id from tab_store_info t1,tab_store t2 where t2.enterprise_id=#{enterpriseId}
and t1.store_info_id=t2.store_info_id and t1.overflow_status=0
</select>
<select id="listAllstoreId" resultType="Integer">
select t2.store_id from tab_store_info t1,tab_store t2 where t2.enterprise_id=#{enterpriseId}
and t1.store_info_id=t2.store_info_id and t1.overflow_status=0
</select>
<select id="getByStore" resultMap="BaseResultMap" parameterType="com.gic.store.dto.StoreDTO">
select
<include refid="Base_Column_List" >
......
......@@ -187,6 +187,12 @@ public class StoreController extends DownloadUtils {
}else {
returnFileds += ","+obj.toString();
}
if (!returnFileds.contains(StoreESFieldsEnum.COMPLETESTATUS.getField())) {
returnFileds += "," + StoreESFieldsEnum.COMPLETESTATUS.getField();
}
if (!returnFileds.contains(StoreESFieldsEnum.STATUS.getField())) {
returnFileds += "," + StoreESFieldsEnum.STATUS.getField();
}
ServiceResponse<Page<StoreDTO>> serviceResponse = storeApiService.listStore(storeSearchDTO, storeSearchDTO.getCurrentPage(), storeSearchDTO.getPageSize(), returnFileds);
if (serviceResponse.isSuccess()) {
Page<StoreDTO> page = serviceResponse.getResult();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment