Commit 76fa85fc by zhiwj

添加门店日志

parent d6b3c5ce
......@@ -93,7 +93,7 @@ public interface StoreApiService {
* @return com.gic.api.base.commons.ServiceResponse
* @throws
*/
ServiceResponse bulkUpdateStore(String storeIds, String value, Integer enterpriseId, int type);
ServiceResponse bulkUpdateStore(String storeIds, String value, Integer enterpriseId, int type, Integer operatorId, String operatorName);
/**
* @Title: getByStoreNameAndStoreCode
......
......@@ -5,6 +5,8 @@ import com.gic.store.dto.StoreLogDTO;
import com.gic.store.entity.TabStoreLog;
import com.github.pagehelper.Page;
import java.util.List;
/**
*
* @ClassName: StoreLogService
......@@ -37,4 +39,10 @@ public interface StoreLogService {
*/
Page<TabStoreLog> listStoreLog(StoreLogDTO storeLogDTO, PageQO pageQO);
void saveBulkStoreInfoLog(List<Integer> storeIdList, Integer enterpriseId, Integer operatorId, String operatorName, String content);
void saveBulkStoreStatusLog(List<Integer> storeIdList, Integer enterpriseId, Integer operatorId, String operatorName, String content);
void saveBulkStoreGroupLog(List<Integer> storeIdList, Integer enterpriseId, Integer operatorId, String operatorName, String content);
}
\ No newline at end of file
......@@ -3,6 +3,8 @@ package com.gic.store.service.impl;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GlobalInfo;
import com.gic.enterprise.qo.PageQO;
import com.gic.store.constant.StoreLogReasonEnum;
import com.gic.store.constant.StoreLogTypeEnum;
import com.gic.store.dao.mapper.TabStoreLogMapper;
import com.gic.store.dto.StoreLogDTO;
import com.gic.store.entity.TabStoreLog;
......@@ -13,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
*
......@@ -39,4 +42,52 @@ public class StoreLogServiceImpl implements StoreLogService {
PageHelper.startPage(pageQO.getCurrentPage(), pageQO.getPageSize());
return tabStoreLogMapper.listStoreLog(storeLogDTO);
}
@Override
public void saveBulkStoreInfoLog(List<Integer> storeIdList, Integer enterpriseId, Integer operatorId, String operatorName, String content) {
TabStoreLog storeLog = new TabStoreLog();
storeLog.setEnterpriseId(enterpriseId);
storeLog.setReason(StoreLogReasonEnum.WEB.getCode());
storeLog.setLogType(StoreLogTypeEnum.INFO_UPDATE.getCode());
storeLog.setRemark("批量编辑");
storeLog.setOperatorId(operatorId);
storeLog.setOperatorName(operatorName);
storeLog.setContent(content);
for (Integer storeId : storeIdList) {
storeLog.setStoreId(storeId);
tabStoreLogMapper.insertSelective(storeLog);
}
}
@Override
public void saveBulkStoreStatusLog(List<Integer> storeIdList, Integer enterpriseId, Integer operatorId, String operatorName, String content) {
TabStoreLog storeLog = new TabStoreLog();
storeLog.setEnterpriseId(enterpriseId);
storeLog.setReason(StoreLogReasonEnum.WEB.getCode());
storeLog.setLogType(StoreLogTypeEnum.STATUS_UPDATE.getCode());
storeLog.setRemark("批量编辑");
storeLog.setOperatorId(operatorId);
storeLog.setOperatorName(operatorName);
storeLog.setContent(content);
for (Integer storeId : storeIdList) {
storeLog.setStoreId(storeId);
tabStoreLogMapper.insertSelective(storeLog);
}
}
@Override
public void saveBulkStoreGroupLog(List<Integer> storeIdList, Integer enterpriseId, Integer operatorId, String operatorName, String content) {
TabStoreLog storeLog = new TabStoreLog();
storeLog.setEnterpriseId(enterpriseId);
storeLog.setReason(StoreLogReasonEnum.WEB.getCode());
storeLog.setLogType(StoreLogTypeEnum.GROUP_UPDATE.getCode());
storeLog.setRemark("批量编辑");
storeLog.setOperatorId(operatorId);
storeLog.setOperatorName(operatorName);
storeLog.setContent(content);
for (Integer storeId : storeIdList) {
storeLog.setStoreId(storeId);
tabStoreLogMapper.insertSelective(storeLog);
}
}
}
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GlobalInfo;
import com.gic.commons.util.PageHelperUtils;
......@@ -208,8 +209,13 @@ public class StoreApiServiceImpl implements StoreApiService {
}
if (!CollectionUtils.isEqualCollection(oldStore.getBusinessTimeList(), newStore.getBusinessTimeList())) {
this.storeBusinessTimeService.convertBusinessTime(newStore.getBusinessTimeList());
String oldBusinessTimeShow = oldStore.getBusinessTimeList().stream().map(StoreBusinessTimeDTO::getWeekdayShow).reduce((x, y) -> x + "" + y).orElse("");
String newBusinessTimeShow = newStore.getBusinessTimeList().stream().map(StoreBusinessTimeDTO::getWeekdayShow).reduce((x, y) -> x + "" + y).orElse("");
String oldBusinessTimeShow = oldStore.getBusinessTimeList().stream()
.map(e -> e.getWeekdayShow() + ":" + DateUtil.dateToStr(e.getOpenTime(), DateUtil.FORMAT_MINUTE_TIME) + "~" + DateUtil.dateToStr(e.getCloseTime(), DateUtil.FORMAT_MINUTE_TIME))
.reduce((x, y) -> x + "" + y).orElse("");
String newBusinessTimeShow = newStore.getBusinessTimeList().stream()
.map(e -> e.getWeekdayShow() + ":" + DateUtil.dateToStr(e.getOpenTime(), DateUtil.FORMAT_MINUTE_TIME) + "~" + DateUtil.dateToStr(e.getCloseTime(), DateUtil.FORMAT_MINUTE_TIME))
.reduce((x, y) -> x + "," + y)
.orElse("");
sb.append("营业时间").append("【").append(oldBusinessTimeShow).append("】")
.append("变更为【").append(newBusinessTimeShow).append("】");
}
......@@ -593,7 +599,7 @@ public class StoreApiServiceImpl implements StoreApiService {
}
@Override
public ServiceResponse bulkUpdateStore(String storeIds, String value, Integer enterpriseId, int type) {
public ServiceResponse bulkUpdateStore(String storeIds, String value, Integer enterpriseId, int type, Integer operatorId, String operatorName) {
//type表示操作的类型,1更新门店启用状态,2门店电话,3营业时间,4门店照片(替换),5关联品牌,6批量上传图片(原有基础上新增)
//7批量修改门店分组
if (StringUtils.isBlank(storeIds) || StringUtils.isBlank(value)) {
......@@ -605,7 +611,7 @@ public class StoreApiServiceImpl implements StoreApiService {
if (StringUtils.isBlank(storeInfoIds)) {
return ServiceResponse.success();
}
i = storeStrtegyMap.get(type).bulkUpdateStore(storeInfoIds, enterpriseId, value, storeService);
i = storeStrtegyMap.get(type).bulkUpdateStore(storeInfoIds, enterpriseId, value, storeService, operatorId, operatorName);
List<Integer> storeIdList = new ArrayList<>();
if ("all".equals(storeIds)) {
this.removeCache(enterpriseId);
......
......@@ -3,5 +3,5 @@ package com.gic.store.strategy;
import com.gic.store.service.StoreService;
public interface BulkUpdateStoreStrtegy {
int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService);
int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName);
}
package com.gic.store.strategy.impl;
import com.gic.store.entity.TabStoreBrand;
import com.gic.store.service.StoreBrandService;
import com.gic.store.service.StoreLogService;
import com.gic.store.service.StoreService;
import com.gic.store.strategy.BulkUpdateStoreStrtegy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
@Component
public class StoreBrandUpdateStrategyImpl implements BulkUpdateStoreStrtegy {
@Autowired
private StoreLogService storeLogService;
@Autowired
private StoreBrandService storeBrandService;
@Override
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService) {
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStoreBrands(storeIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeIdList;
if ("all".equals(storeIds)) {
storeIdList = storeService.listAllStoreId(enterpriseId);
} else {
storeIdList = new ArrayList<>();
String[] storeIdArr = storeIds.split(",");
for (String s : storeIdArr) {
storeIdList.add(Integer.valueOf(s));
}
}
List<TabStoreBrand> storeBrandList = storeBrandService.listStoreBrandByIds(storeIds);
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 + "】");
}
return i;
}
}
package com.gic.store.strategy.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.GlobalInfo;
import com.gic.store.constant.WeekdayEnum;
import com.gic.store.service.StoreLogService;
import com.gic.store.service.StoreService;
import com.gic.store.strategy.BulkUpdateStoreStrtegy;
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.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Component
public class StoreBusinessTimeStrategyImpl implements BulkUpdateStoreStrtegy {
@Autowired
private StoreLogService storeLogService;
@Override
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService) {
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStoreBusinessTime(storeIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeIdList;
if ("all".equals(storeIds)) {
storeIdList = storeService.listAllStoreId(enterpriseId);
} else {
storeIdList = new ArrayList<>();
String[] storeIdArr = storeIds.split(",");
for (String s : storeIdArr) {
storeIdList.add(Integer.valueOf(s));
}
}
// [{"weekday":"1,2","openTime":"09:42","closeTime":"09:42"}]
StringBuilder btSb = new StringBuilder("营业时间变更为【 ");
List<JSONObject> businessTimeList = JSON.parseArray(value, JSONObject.class);
for (JSONObject storeBusinessTime : businessTimeList) {
String weekday = storeBusinessTime.getString("weekday");
List<Integer> list = Stream.of(weekday.split(GlobalInfo.FLAG_COMMA)).filter(e -> StringUtils.isNotBlank(e)).map(Integer::parseInt).collect(Collectors.toList());
if (list.size() >= 3 && list.get(list.size() - 1) - list.get(0) == list.size() - 1) {
// 超过三条的需要判断
// 都是连续的
btSb.append(WeekdayEnum.parse(list.get(0)) + "至" + WeekdayEnum.parse(list.get(list.size() - 1)));
} else {
// 直接解析返回
StringBuilder sb = new StringBuilder();
for (Integer code : list) {
sb.append(WeekdayEnum.parse(code)).append("、");
}
sb.deleteCharAt(sb.length() - 1);
btSb.append(sb);
}
btSb.append(":").append(storeBusinessTime.getString("openTime")).append("~").append(storeBusinessTime.getString("endTime")).append(",");
}
btSb.deleteCharAt(btSb.length() - 1);
btSb.append("】");
storeLogService.saveBulkStoreInfoLog(storeIdList, enterpriseId, operatorId, operatorName, btSb.toString());
}
return i;
}
}
package com.gic.store.strategy.impl;
import com.gic.store.entity.TabStoreGroup;
import com.gic.store.service.StoreGroupService;
import com.gic.store.service.StoreLogService;
import com.gic.store.service.StoreService;
import com.gic.store.strategy.BulkUpdateStoreStrtegy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
public class StoreGroupStrategyImpl implements BulkUpdateStoreStrtegy {
@Autowired
private StoreLogService storeLogService;
@Autowired
private StoreGroupService storeGroupService;
@Override
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService) {
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStoreGroup(storeIds, enterpriseId, Integer.valueOf(value));
if (i > 0) {
List<Integer> storeIdList;
if ("all".equals(storeIds)) {
storeIdList = storeService.listAllStoreId(enterpriseId);
} else {
storeIdList = new ArrayList<>();
String[] storeIdArr = storeIds.split(",");
for (String s : storeIdArr) {
storeIdList.add(Integer.valueOf(s));
}
}
TabStoreGroup group = storeGroupService.getStoreGroupById(Integer.valueOf(value));
storeLogService.saveBulkStoreGroupLog(storeIdList, enterpriseId, operatorId, operatorName, "门店分组变更为【" + group.getStoreGroupName() + "】");
}
return i;
}
}
package com.gic.store.strategy.impl;
import com.gic.store.service.StoreLogService;
import com.gic.store.service.StoreService;
import com.gic.store.strategy.BulkUpdateStoreStrtegy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
public class StorePhoneStategyImpl implements BulkUpdateStoreStrtegy {
@Autowired
private StoreLogService storeLogService;
@Override
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService) {
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStoreConactsPhone(storeIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeIdList;
if ("all".equals(storeIds)) {
storeIdList = storeService.listAllStoreId(enterpriseId);
} else {
storeIdList = new ArrayList<>();
String[] storeIdArr = storeIds.split(",");
for (String s : storeIdArr) {
storeIdList.add(Integer.valueOf(s));
}
}
storeLogService.saveBulkStoreInfoLog(storeIdList, enterpriseId, operatorId, operatorName, "门店联系电话变更为【" + value + "】");
}
return i;
}
}
package com.gic.store.strategy.impl;
import com.gic.store.service.StoreLogService;
import com.gic.store.service.StoreService;
import com.gic.store.strategy.BulkUpdateStoreStrtegy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
public class StorePhotoAddStrategyImpl implements BulkUpdateStoreStrtegy {
@Autowired
private StoreLogService storeLogService;
@Override
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService) {
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkAddStorePhoto(storeIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeIdList;
if ("all".equals(storeIds)) {
storeIdList = storeService.listAllStoreId(enterpriseId);
} else {
storeIdList = new ArrayList<>();
String[] storeIdArr = storeIds.split(",");
for (String s : storeIdArr) {
storeIdList.add(Integer.valueOf(s));
}
}
storeLogService.saveBulkStoreInfoLog(storeIdList, enterpriseId, operatorId, operatorName, "门店照片添加");
}
return i;
}
}
package com.gic.store.strategy.impl;
import com.gic.store.service.StoreLogService;
import com.gic.store.service.StoreService;
import com.gic.store.strategy.BulkUpdateStoreStrtegy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
public class StorePhotoUpdateStrategyImpl implements BulkUpdateStoreStrtegy {
@Autowired
private StoreLogService storeLogService;
@Override
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService) {
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStorePhoto(storeIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeIdList;
if ("all".equals(storeIds)) {
storeIdList = storeService.listAllStoreId(enterpriseId);
} else {
storeIdList = new ArrayList<>();
String[] storeIdArr = storeIds.split(",");
for (String s : storeIdArr) {
storeIdList.add(Integer.valueOf(s));
}
}
storeLogService.saveBulkStoreInfoLog(storeIdList, enterpriseId, operatorId, operatorName, "门店照片变更");
}
return i;
}
}
package com.gic.store.strategy.impl;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
public class StoreStatusStrategyImpl implements BulkUpdateStoreStrtegy {
@Autowired
private StoreLogService storeLogService;
@Override
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService) {
public int bulkUpdateStore(String storeIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStoreStatus(storeIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeIdList;
if ("all".equals(storeIds)) {
storeIdList = storeService.listAllStoreId(enterpriseId);
} else {
storeIdList = new ArrayList<>();
String[] storeIdArr = storeIds.split(",");
for (String s : storeIdArr) {
storeIdList.add(Integer.valueOf(s));
}
}
storeLogService.saveBulkStoreInfoLog(storeIdList, enterpriseId, operatorId, operatorName, "门店状态变更为【" + StoreStatusEnum.parseCode(Integer.parseInt(value)) + "】");
}
return i;
}
}
......@@ -203,7 +203,7 @@ public class StoreController {
if (StringUtils.isBlank(storeIds) || StringUtils.isBlank(value)) {
return EnterpriseRestResponse.failure(ErrorCode.MISS_PARAMETER);
}
ServiceResponse response = this.storeApiService.bulkUpdateStore(storeIds, value, enterpriseId, type);
ServiceResponse response = this.storeApiService.bulkUpdateStore(storeIds, value, enterpriseId, type, UserDetailUtils.getUserDetail().getUserId(), UserDetailUtils.getUserDetail().getUserInfo().getUserName());
if (response.isSuccess()) {
return RestResponse.success();
}
......
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