Commit 38ae55ab by 陶光胜

门店批量导入修改

parent a58f3106
......@@ -151,6 +151,11 @@
<artifactId>gic-spark-run-api</artifactId>
<version>${gic-spark-run-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-member-config-api</artifactId>
<version>${gic-member-config-api}</version>
</dependency>
</dependencies>
<build>
......
package com.gic.store.strategy.impl;
import com.gic.member.config.api.dto.UserOwnerDefaultDTO;
import com.gic.member.config.api.service.CardAscriptionConfigService;
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;
import com.gic.store.strategy.BulkUpdateStoreStrtegy;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Component("1")
public class StoreStatusStrategyImpl implements BulkUpdateStoreStrtegy {
......@@ -18,27 +24,42 @@ public class StoreStatusStrategyImpl implements BulkUpdateStoreStrtegy {
private StoreLogService storeLogService;
@Autowired
private SparkJobApiService sparkJobApiService;
@Autowired
private CardAscriptionConfigService cardAscriptionConfigService;
@Override
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStoreStatus(storeInfoIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeInfoIdList;
if ("all".equals(storeInfoIds)) {
storeInfoIdList = storeService.listAllStoreInfoId(enterpriseId);
} else {
storeInfoIdList = new ArrayList<>();
String[] storeIdArr = storeInfoIds.split(",");
for (String s : storeIdArr) {
storeInfoIdList.add(Integer.valueOf(s));
}
List<Integer> storeInfoIdList = new ArrayList<>();
List<Integer> storeInfoIdListNew = new ArrayList<>();
List<UserOwnerDefaultDTO> result = this.cardAscriptionConfigService.getDefaultUserOwner(enterpriseId).getResult();
if ("all".equals(storeInfoIds)) {
storeInfoIdList = storeService.listAllStoreInfoId(enterpriseId);
} else {
storeInfoIdList = new ArrayList<>();
String[] storeIdArr = storeInfoIds.split(",");
for (String s : storeIdArr) {
storeInfoIdList.add(Integer.valueOf(s));
}
}
if(CollectionUtils.isNotEmpty(result) && StoreStatusEnum.INONLINE.getCode() == Integer.valueOf(value)){
storeInfoIdListNew = storeInfoIdList.stream().filter(storeInfoId -> {
for(UserOwnerDefaultDTO dto : result){
if(storeInfoId.intValue() == dto.getStoreInfoId().intValue()){
return false;
}
}
return true;
}).collect(Collectors.toList());
}
String storeInfoIdsNew = StringUtils.join(CollectionUtils.isNotEmpty(storeInfoIdListNew) ? storeInfoIdListNew : storeInfoIdList, ",");
int i = storeService.bulkUpdateStoreStatus(storeInfoIdsNew, enterpriseId, value);
if (i > 0) {
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;
......
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