Commit d5dbbca2 by zhiwj

门店批量修改

parent 9357bbe6
......@@ -253,4 +253,16 @@ public interface TabClerkMapper {
* @throws
*/
List<Integer> listAllClerkId(@Param("enterpriseId") Integer enterpriseId);
/**
* listStoreInfoIdByStoreInfoId
* @Title: listStoreInfoIdByStoreInfoId
* @Description:
* @author zhiwj
* @param enterpriseId
* @param storeInfoIdList
* @return java.util.List<java.lang.Integer>
* @throws
*/
List<Integer> listStoreInfoIdByStoreInfoId(@Param("enterpriseId") Integer enterpriseId, @Param("ids") List<Integer> storeInfoIdList);
}
\ No newline at end of file
......@@ -293,4 +293,16 @@ public interface ClerkService {
* @throws
*/
List<Integer> listAllClerkId(Integer enterpriseId);
/**
* listStoreInfoIdByStoreInfoId
* @Title: listStoreInfoIdByStoreInfoId
* @Description:
* @author zhiwj
* @param enterpriseId
* @param storeInfoIdList
* @return java.util.List<java.lang.Integer>
* @throws
*/
List<Integer> listStoreInfoIdByStoreInfoId(Integer enterpriseId, List<Integer> storeInfoIdList);
}
......@@ -190,4 +190,9 @@ public class ClerkServiceImpl implements ClerkService {
return tabClerkMapper.listAllClerkId(enterpriseId);
}
@Override
public List<Integer> listStoreInfoIdByStoreInfoId(Integer enterpriseId, List<Integer> storeInfoIdList) {
return tabClerkMapper.listStoreInfoIdByStoreInfoId(enterpriseId, storeInfoIdList);
}
}
......@@ -1311,7 +1311,6 @@ public class StoreApiServiceImpl implements StoreApiService {
if (StringUtils.isBlank(storeIds) || StringUtils.isBlank(value)) {
return EnterpriseServiceResponse.failure(com.gic.enterprise.error.ErrorCode.MISS_PARAMETER);
}
int i = 0;
try {
String storeInfoIds;
if (StringUtils.equals(Constants.ALL, storeIds)) {
......@@ -1322,7 +1321,7 @@ public class StoreApiServiceImpl implements StoreApiService {
if (StringUtils.isBlank(storeInfoIds)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店不存在或非自有门店");
}
i = storeStrtegyMap.get(type+"").bulkUpdateStore(storeInfoIds, enterpriseId, value, storeService, operatorId, operatorName);
String msg = storeStrtegyMap.get(type+"").bulkUpdateStore(storeInfoIds, enterpriseId, value, storeService, operatorId, operatorName);
List<Integer> storeIdList = new ArrayList<>();
if (Constants.ALL.equals(storeIds)) {
this.removeCache(enterpriseId);
......@@ -1340,6 +1339,9 @@ public class StoreApiServiceImpl implements StoreApiService {
this.bulkAddStoreToIndex(enterpriseId, storeIdList);
}
}
if (StringUtils.isNotBlank(msg)) {
return ServiceResponse.failure("7777", msg);
}
// bulkUpdateLog(storeIds, value, enterpriseId, type, operatorId, operatorName);
} catch (Exception e) {
logger.error("", e);
......
......@@ -24,5 +24,5 @@ public interface BulkUpdateStoreStrtegy {
* @return int
* @throws
*/
int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName);
String bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName);
}
......@@ -36,7 +36,7 @@ public class StoreBrandUpdateStrategyImpl implements BulkUpdateStoreStrtegy {
private SparkJobApiService sparkJobApiService;
@Override
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
public String bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
List<Integer> storeInfoIdList;
List<StoreDTO> storeList;
if (Constants.ALL.equals(storeInfoIds)) {
......@@ -70,7 +70,7 @@ public class StoreBrandUpdateStrategyImpl implements BulkUpdateStoreStrtegy {
sparkJobApiService.updateStoreBrand(enterpriseId, brandUpdateDTO.storeInfoId, brandUpdateDTO.oldStoreBrand, newBrand);
}
return i;
return null;
}
class BrandUpdateDTO{
......
......@@ -30,7 +30,7 @@ public class StoreBusinessTimeStrategyImpl implements BulkUpdateStoreStrtegy {
private StoreLogService storeLogService;
@Override
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
public String bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStoreBusinessTime(storeInfoIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeInfoIdList;
......@@ -68,6 +68,6 @@ public class StoreBusinessTimeStrategyImpl implements BulkUpdateStoreStrtegy {
btSb.append("】");
storeLogService.saveBulkStoreInfoLog(storeInfoIdList, enterpriseId, operatorId, operatorName, btSb.toString());
}
return i;
return null;
}
}
......@@ -27,7 +27,7 @@ public class StoreGroupStrategyImpl implements BulkUpdateStoreStrtegy {
private StoreGroupService storeGroupService;
@Override
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
public String 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> storeInfoIdList;
......@@ -43,6 +43,6 @@ public class StoreGroupStrategyImpl implements BulkUpdateStoreStrtegy {
TabStoreGroup group = storeGroupService.getStoreGroupById(Integer.valueOf(value));
storeLogService.saveBulkStoreGroupLog(storeInfoIdList, enterpriseId, operatorId, operatorName, "门店分组变更为【" + group.getStoreGroupName() + "】");
}
return i;
return null;
}
}
......@@ -23,7 +23,7 @@ public class StorePhoneStategyImpl implements BulkUpdateStoreStrtegy {
private StoreLogService storeLogService;
@Override
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
public String 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> storeInfoIdList;
......@@ -38,6 +38,6 @@ public class StorePhoneStategyImpl implements BulkUpdateStoreStrtegy {
}
storeLogService.saveBulkStoreInfoLog(storeInfoIdList, enterpriseId, operatorId, operatorName, "门店联系电话变更为【" + value + "】");
}
return i;
return null;
}
}
......@@ -24,7 +24,7 @@ public class StorePhotoAddStrategyImpl implements BulkUpdateStoreStrtegy {
private StoreLogService storeLogService;
@Override
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
public String bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkAddStorePhoto(storeInfoIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeInfoIdList;
......@@ -39,6 +39,6 @@ public class StorePhotoAddStrategyImpl implements BulkUpdateStoreStrtegy {
}
storeLogService.saveBulkStoreInfoLog(storeInfoIdList, enterpriseId, operatorId, operatorName, "门店照片添加");
}
return i;
return null;
}
}
......@@ -24,7 +24,7 @@ public class StorePhotoUpdateStrategyImpl implements BulkUpdateStoreStrtegy {
private StoreLogService storeLogService;
@Override
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
public String 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> storeInfoIdList;
......@@ -39,6 +39,6 @@ public class StorePhotoUpdateStrategyImpl implements BulkUpdateStoreStrtegy {
}
storeLogService.saveBulkStoreInfoLog(storeInfoIdList, enterpriseId, operatorId, operatorName, "门店照片变更");
}
return i;
return null;
}
}
......@@ -5,6 +5,9 @@ import com.gic.member.config.api.service.CardAscriptionConfigService;
import com.gic.spark.api.service.SparkJobApiService;
import com.gic.store.constant.Constants;
import com.gic.store.constant.StoreStatusEnum;
import com.gic.store.dto.StoreDTO;
import com.gic.store.dto.StoreSearchDbDTO;
import com.gic.store.service.ClerkService;
import com.gic.store.service.StoreLogService;
import com.gic.store.service.StoreService;
import com.gic.store.strategy.BulkUpdateStoreStrtegy;
......@@ -33,9 +36,13 @@ public class StoreStatusStrategyImpl implements BulkUpdateStoreStrtegy {
private SparkJobApiService sparkJobApiService;
@Autowired
private CardAscriptionConfigService cardAscriptionConfigService;
@Autowired
private ClerkService clerkService;
@Autowired
private StoreService storeService;
@Override
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
public String bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
List<Integer> storeInfoIdList = new ArrayList<>();
List<UserOwnerDefaultDTO> result = this.cardAscriptionConfigService.getDefaultUserOwner(enterpriseId).getResult();
if (Constants.ALL.equals(storeInfoIds)) {
......@@ -58,10 +65,26 @@ public class StoreStatusStrategyImpl implements BulkUpdateStoreStrtegy {
}).collect(Collectors.toList());
}
if(CollectionUtils.isNotEmpty(storeInfoIdList)){
int valueCode = Integer.parseInt(value);
String errorMsg = null;
if (StoreStatusEnum.ONLINE.getCode() == valueCode) {
// 改成启用 需要判断门店下有没有导购 没有导购不能启用 先查出来有导购的门店
List<Integer> storeInfoIdListNew = clerkService.listStoreInfoIdByStoreInfoId(enterpriseId, storeInfoIdList);
if (CollectionUtils.isEmpty(storeInfoIdListNew)) {
// 每个门店下都没有导购
return getStoreHasNotClerkMsg(enterpriseId, storeInfoIdList, storeInfoIdListNew);
} else if (storeInfoIdListNew.size() == storeInfoIdList.size()) {
// 每个门店下都有导购
errorMsg = null;
} else {
errorMsg = getStoreHasNotClerkMsg(enterpriseId, storeInfoIdList, storeInfoIdListNew);
storeInfoIdList = storeInfoIdListNew;
}
}
String storeInfoIdsNew = StringUtils.join(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) {
// 启用禁用的值和会员组取的不一致 需要转换下
......@@ -69,8 +92,30 @@ public class StoreStatusStrategyImpl implements BulkUpdateStoreStrtegy {
}
}
return i;
return errorMsg;
}
return null;
}
private String getStoreHasNotClerkMsg(Integer enterpriseId, List<Integer> storeInfoIdList, List<Integer> storeInfoIdListNew) {
// 没有导购的门店
List<Integer> storeInfoIdHasNotClerkMsgList;
if (CollectionUtils.isNotEmpty(storeInfoIdListNew)) {
storeInfoIdHasNotClerkMsgList = storeInfoIdList.stream().filter(e -> !storeInfoIdListNew.contains(e)).collect(Collectors.toList());
} else {
storeInfoIdHasNotClerkMsgList = storeInfoIdList;
}
return 0;
StoreSearchDbDTO storeSearchDbDTO = new StoreSearchDbDTO();
storeSearchDbDTO.setEnterpriseId(enterpriseId);
storeSearchDbDTO.setStoreInfoIdList(storeInfoIdHasNotClerkMsgList);
String msg = storeService.listStore(storeSearchDbDTO, 1, Integer.MAX_VALUE).stream().map(StoreDTO::getStoreName).collect(Collectors.joining(","));
return String.format("共选中%d家门店,%d家成功启用,%s下无可用导购,无法启用门店,请在门店下至少新建或启用一个导购",
storeInfoIdList.size(),
CollectionUtils.isNotEmpty(storeInfoIdListNew) ? storeInfoIdListNew.size() : 0,
msg
);
}
}
......@@ -411,4 +411,16 @@
from tab_clerk
where enterprise_id = #{enterpriseId}
</select>
<!-- listStoreInfoIdByStoreInfoId-->
<select id="listStoreInfoIdByStoreInfoId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_clerk where enterprise_id = #{enterpriseId}
<if test="null != ids and ids.size > 0">
and store_info_id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
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