开业筹备阶段4.0

This commit is contained in:
shuo.wang
2024-04-26 14:14:44 +08:00
parent 46c3f61aa6
commit a5ca7a3a63
13 changed files with 179 additions and 185 deletions

View File

@@ -1,5 +1,6 @@
package com.cool.store.service;
import com.cool.store.context.LoginUserInfo;
import com.cool.store.dto.openPreparation.FirstOrderDTO;
import com.cool.store.entity.FirstOrderDO;
import com.cool.store.request.FirstOrderRequest;
@@ -12,7 +13,8 @@ import com.cool.store.request.FirstOrderRequest;
*/
public interface FirstOrderService {
Integer saveOrder(FirstOrderRequest request);
Integer saveOrder(FirstOrderRequest request, LoginUserInfo user);
FirstOrderDTO getOrder(Long shopId);
FirstOrderDTO flush(Long shopId);
}

View File

@@ -1,5 +1,6 @@
package com.cool.store.service;
import com.cool.store.context.LoginUserInfo;
import com.cool.store.request.OpeningOperationPlanRequest;
import com.cool.store.request.PlanListRequest;
import com.cool.store.vo.OpeningOperationPlanListVO;
@@ -20,7 +21,7 @@ public interface OpeningOperationPlanService {
* @Date: 2024/4/23
* @description: 提交开业运营方案
*/
Long savePlan(OpeningOperationPlanRequest openingOperationPlanRequest);
Long savePlan(OpeningOperationPlanRequest openingOperationPlanRequest, LoginUserInfo userInfo);
OpeningOperationPlanVO getPlanByShopId(Long ShopId);
/**
@@ -29,5 +30,5 @@ public interface OpeningOperationPlanService {
* @description: 根据条件查询方案列表
*/
List<OpeningOperationPlanListVO> getPlanListPage(PlanListRequest request);
Boolean flush(Long shopId);
}

View File

@@ -2,12 +2,15 @@ package com.cool.store.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.context.CurrentUserHolder;
import com.cool.store.context.LoginUserInfo;
import com.cool.store.dao.FirstOrderDAO;
import com.cool.store.dao.ShopStageInfoDAO;
import com.cool.store.dto.openPreparation.FirstOrderDTO;
import com.cool.store.entity.FirstOrderDO;
import com.cool.store.entity.ShopInfoDO;
import com.cool.store.entity.ShopStageInfoDO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.point.ShopSubStageEnum;
import com.cool.store.enums.point.ShopSubStageStatusEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.request.FirstOrderRequest;
@@ -48,8 +51,12 @@ public class FirstOrderServiceImp implements FirstOrderService {
private CoolStoreStartFlowService coolStoreStartFlowService;
@Override
public Integer saveOrder(FirstOrderRequest request) {
String userId = CurrentUserHolder.getUserId();
public Integer saveOrder(FirstOrderRequest request, LoginUserInfo user) {
log.info("save order:{}", JSONObject.toJSONString(request));
if (request == null) {
throw new ServiceException(ErrorCodeEnum.FIRST_ORDER_PARAM_NULL);
}
String userId = user.getUserId();
FirstOrderDO order = new FirstOrderDO();
try {
BeanUtils.copyProperties(order, request);
@@ -58,22 +65,16 @@ public class FirstOrderServiceImp implements FirstOrderService {
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
log.info("save order:{}", JSONObject.toJSONString(order));
if (order == null) {
throw new ServiceException(ErrorCodeEnum.FIRST_ORDER_PARAM_NULL);
}
FirstOrderDTO firstOrderDTO = firstOrderDAO.selectFirstOrderByShopId(order.getShopId());
if (firstOrderDTO == null) {
//第一次提交
order.setCreateTime(new Date());
order.setUpdateTime(new Date());
order.setCreateUserId(userId);
order.setUpdateUserId(userId);
} else {
//修改提交
order.setUpdateTime(new Date());
order.setUpdateUserId(userId);
}
//修改只更新下面2个
order.setUpdateTime(new Date());
order.setUpdateUserId(userId);
Integer num = firstOrderDAO.insertFirstOrder(order);
//云立方同步
if (num > 0) {
@@ -105,6 +106,37 @@ public class FirstOrderServiceImp implements FirstOrderService {
log.error("shopId/shopCode is null");
throw new ServiceException(ErrorCodeEnum.FIRST_ORDER_PARAM_NULL);
}
return firstOrderDAO.selectFirstOrderByShopId(shopId);
FirstOrderDTO order = firstOrderDAO.selectFirstOrderByShopId(shopId);
ShopStageInfoDO firstOrderStageInfo = shopStageInfoDAO.
getShopSubStageInfo(shopId, ShopSubStageEnum.SHOP_STAGE_15);
order.setResultType(firstOrderStageInfo.getShopSubStageStatus());
return order;
}
@Override
public FirstOrderDTO flush(Long shopId) {
ShopStageInfoDO orderStageInfo = shopStageInfoDAO.getShopSubStageInfo(shopId, ShopSubStageEnum.SHOP_STAGE_15);
try {
if (!orderStageInfo.getShopSubStageStatus().
equals(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_151.getShopSubStageStatus())) {
ShopInfoDO shopInfo = shopService.getShopInfo(shopId);
String shopCode = shopInfo.getShopCode();
Boolean flag = coolStoreStartFlowService.getFirstOrder(shopCode);
log.info("saveOrder,flag:{}", flag);
if (flag == null) {
throw new ServiceException(ErrorCodeEnum.GET_FIRST_ORDER);
}
if (flag) {
//更改子阶段状态
shopStageInfoDAO.updateShopStageAndAuditInfo(shopId,
ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_151, null);
preparationService.whetherToOpenForAcceptance(shopId);
}
}
} catch (Exception e) {
log.error("获取鲜丰订货金异常", e);
}
FirstOrderDTO order = getOrder(shopId);
return order;
}
}

View File

@@ -3,21 +3,25 @@ package com.cool.store.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.constants.CommonConstants;
import com.cool.store.context.CurrentUserHolder;
import com.cool.store.context.LoginUserInfo;
import com.cool.store.dao.*;
import com.cool.store.dto.openPreparation.OpenPlanShopInfoDTO;
import com.cool.store.dto.openPreparation.OpeningOperationPlanDTO;
import com.cool.store.dto.openPreparation.PlanLineDTO;
import com.cool.store.dto.openPreparation.UserNameDTO;
import com.cool.store.entity.OpeningOperationPlanDO;
import com.cool.store.entity.ShopInfoDO;
import com.cool.store.entity.ShopStageInfoDO;
import com.cool.store.enums.AuditStatusEnum;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.point.ShopSubStageEnum;
import com.cool.store.enums.point.ShopSubStageStatusEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.request.OpeningOperationPlanAuditRequest;
import com.cool.store.request.OpeningOperationPlanRequest;
import com.cool.store.request.PlanListRequest;
import com.cool.store.service.AuditOpeningOperationPlanService;
import com.cool.store.service.OpeningOperationPlanService;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.*;
import com.cool.store.utils.poi.StringUtils;
import com.cool.store.vo.OpeningOperationPlanListVO;
import com.cool.store.vo.OpeningOperationPlanVO;
@@ -54,101 +58,84 @@ public class OpeningOperationPlanImpl implements OpeningOperationPlanService {
private LineInfoDAO lineInfoDAO;
@Resource
private ShopStageInfoDAO shopStageInfoDAO;
@Resource
private ShopService shopService;
@Resource
private CoolStoreStartFlowService coolStoreStartFlowService;
@Resource
private PreparationService preparationService;
@Override
@Transactional(rollbackFor = Exception.class)
public Long savePlan(OpeningOperationPlanRequest request) {
public Long savePlan(OpeningOperationPlanRequest request, LoginUserInfo userInfo) {
log.info("addNewPlan request:{}", JSONObject.toJSONString(request));
if (request.getActivityTheme().length() > CommonConstants.MAX_LENGTH_ONE_HUNDRED){
if (request.getActivityTheme().length() > CommonConstants.MAX_LENGTH_ONE_HUNDRED) {
log.error("addNewPlan ActivityTheme length error");
throw new ServiceException(ErrorCodeEnum.ACTIVITY_THEME_LENGTH_FALSE);
}
if (request.getSurveyResult().length() >CommonConstants.MAX_LENGTH_ONE_HUNDRED){
if (request.getSurveyResult().length() > CommonConstants.MAX_LENGTH_ONE_HUNDRED) {
log.error("addNewPlan SurveyResult length error");
throw new ServiceException(ErrorCodeEnum.SURVEYRESULT_LENGTH_FALSE);
}
String userId = CurrentUserHolder.getUserId();
String userId = userInfo.getUserId();
try {
String userName = enterpriseUserDAO.getUserName(userId);
if (StringUtils.isBlank(userName)){
log.error("addNewPlan userName is null");
throw new ServiceException(ErrorCodeEnum.USER_NOT_EXIST);
}
OpeningOperationPlanAuditRequest openingOperationPlanAuditRequest = new OpeningOperationPlanAuditRequest();
openingOperationPlanAuditRequest.setShopId(request.getShopId());
Long AuditId = auditOpeningOperationPlanService.addNewPlanAudit(openingOperationPlanAuditRequest);
if (Objects.isNull(AuditId) ){
log.error("addNewPlan AuditId is null");
throw new ServiceException(ErrorCodeEnum.INSERT_OPENING_OPERATION_PLAN_AUDIT_FALSE);
}
OpeningOperationPlanDO selectByShopId = openingOperationPlanDAO.selectByShopId(request.getShopId());
Long planId ;
Long planId;
OpeningOperationPlanDO openingOperationPlanDO = request.toOpeningOperationPlanDO();
if (!Objects.isNull(selectByShopId)){
openingOperationPlanDO.setUpdateTime(new Date());
openingOperationPlanDO.setUpdateUserId(userId);
openingOperationPlanDO.setResultType(AuditStatusEnum.TODO.getCode());
if (!Objects.isNull(selectByShopId)) {
//提交修改
openingOperationPlanDO.setId(selectByShopId.getId());
openingOperationPlanDO.setSubmissionTime(new Date());
openingOperationPlanDO.setSubmittedUserId(userId);
openingOperationPlanDO.setUpdateTime(new Date());
openingOperationPlanDO.setUpdateUserId(userId);
openingOperationPlanDO.setResultType(AuditStatusEnum.TODO.getCode());
planId = openingOperationPlanDAO.updateSelective(openingOperationPlanDO);
}
else {
} else {
//新增
openingOperationPlanDO.setSubmissionTime(new Date());
openingOperationPlanDO.setSubmittedUserId(userId);
openingOperationPlanDO.setCreateTime(new Date());
openingOperationPlanDO.setCreateUserId(userId);
openingOperationPlanDO.setUpdateTime(new Date());
openingOperationPlanDO.setUpdateUserId(userId);
openingOperationPlanDO.setAuditId(AuditId);
openingOperationPlanDO.setResultType(AuditStatusEnum.TODO.getCode());
planId = openingOperationPlanDAO.insertSelective(openingOperationPlanDO);
}
if (Objects.isNull(planId)){
log.error("addNewPlan PlanId is null");
throw new ServiceException(ErrorCodeEnum.INSERT_OPENING_OPERATION_PLAN_FALSE);
}
Integer Stage = shopStageInfoDAO.updateShopStageAndAuditInfo(request.getShopId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_141, request.getShopId());
if (Objects.isNull(Stage)){
if (Objects.isNull(Stage) || Stage == CommonConstants.ZERO) {
log.error("auditPlan stage is null");
throw new ServiceException(ErrorCodeEnum.UPDATE_SHOP_SUB_STAGE_STATUS_FALSE);
throw new ServiceException(ErrorCodeEnum.UPDATE_SHOP_SUB_STAGE_STATUS_FALSE);
}
return planId;
}catch (Exception e) {
} catch (Exception e) {
log.error("addNewPlan Exception:{}", e);
e.printStackTrace();
return null;
return null;
}
}
@Override
public OpeningOperationPlanVO getPlanByShopId(Long shopId) {
log.info( "getPlanBy shopId:{}", shopId );
if (Objects.isNull(shopId)){
log.info("getPlanBy shopId:{}", shopId);
if (Objects.isNull(shopId)) {
log.error(" getPlanByShopId shopId is null");
throw new ServiceException(ErrorCodeEnum.SHOP_ID_IS_NULL);
}
OpeningOperationPlanVO openingOperationPlanVO = new OpeningOperationPlanVO();
OpeningOperationPlanDO openingOperationPlanDO = openingOperationPlanDAO.selectByShopId(shopId);
try {
if ((openingOperationPlanDO!=null)){
String preparationUserIds = openingOperationPlanDO.getPreparationUserIds();
List<String> stream = Arrays.stream(preparationUserIds.split(CommonConstants.COMMA)).collect(Collectors.toList());
List<UserNameDTO> nameByUserId = enterpriseUserDAO.getNameByUserId(stream);
List<String> names = nameByUserId.stream()
.map(UserNameDTO::getName)
.collect(Collectors.toList());
String preparationUserName = String.join(CommonConstants.COMMA, names);
BeanUtils.copyProperties(openingOperationPlanDO, openingOperationPlanVO);
openingOperationPlanVO.setPreparationUsers(preparationUserName);
return openingOperationPlanVO;
}
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return null;
}
try {
if (openingOperationPlanDO != null) {
String preparationUserIds = openingOperationPlanDO.getPreparationUserIds();
List<String> stream = Arrays.stream(preparationUserIds.split(CommonConstants.COMMA)).collect(Collectors.toList());
List<UserNameDTO> nameByUserId = enterpriseUserDAO.getNameByUserId(stream);
BeanUtils.copyProperties(openingOperationPlanDO, openingOperationPlanVO);
openingOperationPlanVO.setPreparationUsers(nameByUserId);
return openingOperationPlanVO;
}
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return null;
}
return openingOperationPlanVO;
}
@@ -156,11 +143,12 @@ public class OpeningOperationPlanImpl implements OpeningOperationPlanService {
public List<OpeningOperationPlanListVO> getPlanListPage(PlanListRequest request) {
log.info("getPlanListPage request:{}", JSONObject.toJSONString(request));
//shopId,提交时间,审核状态
List<OpeningOperationPlanDTO> openingOperationPlanDTOS = openingOperationPlanDAO.
selectConditionPlanList(request.getPlanStartDate(),request.getPlanEndDate(),request.getResultType());
log.info("getPlanListPage openingOperationPlanDTOS:{}",JSONObject.toJSONString(openingOperationPlanDTOS) );
//包装VO
List<OpeningOperationPlanListVO> openingOperationPlanListVOList = openingOperationPlanDTOS.stream().map(dto->{
Page<OpeningOperationPlanDTO> openingOperationPlanDTOS = openingOperationPlanDAO.
selectConditionPlanList(request.getPlanStartDate(), request.getPlanEndDate(),
request.getResultType(), request.getPageNum(), request.getPageSize());
log.info("getPlanListPage openingOperationPlanDTOS:{}", JSONObject.toJSONString(openingOperationPlanDTOS));
//包装VO
List<OpeningOperationPlanListVO> openingOperationPlanListVOList = openingOperationPlanDTOS.stream().map(dto -> {
OpeningOperationPlanListVO vO = new OpeningOperationPlanListVO();
vO.setShopId(dto.getShopId());
vO.setSubmissionTime(dto.getSubmissionTime());
@@ -168,46 +156,48 @@ public class OpeningOperationPlanImpl implements OpeningOperationPlanService {
vO.setAuditId(dto.getAuditId());
return vO;
}).collect(Collectors.toList());
log.info("getPlanListPage openingOperationPlanVOList:{}", JSONObject.toJSONString(openingOperationPlanListVOList) );
log.info("getPlanListPage openingOperationPlanVOList:{}",
JSONObject.toJSONString(openingOperationPlanListVOList));
List<Long> shopIdlist = openingOperationPlanDTOS.stream().map(OpeningOperationPlanDTO::getShopId)
.collect(Collectors.toList());
log.info("getPlanListPage shopIdlist:{}",JSONObject.toJSONString(shopIdlist) );
log.info("getPlanListPage shopIdlist:{}", JSONObject.toJSONString(shopIdlist));
//根据ShopName等查询门店名字1门店代码1开店负责人id1督导id1,大区名称,战区名称,线索id
Page<OpenPlanShopInfoDTO> openPlanShopList = shopInfoDAO.
getOpenPlanShopListByShopName(shopIdlist,request.getShopName(), request.getBigName(), request.getFightName(),
request.getPageNum(), request.getPageSize());
log.info("getPlanListPage openPlanShopList:{}",JSONObject.toJSONString(openPlanShopList) );
List<OpenPlanShopInfoDTO> openPlanShopList = shopInfoDAO.
getOpenPlanShopListByShopName(shopIdlist, request.getShopName(), request.getBigName(),
request.getFightName()
);
log.info("getPlanListPage openPlanShopList:{}", JSONObject.toJSONString(openPlanShopList));
Map<Long, OpenPlanShopInfoDTO> shopInfoMap = openPlanShopList.stream()
.collect(Collectors.toMap(OpenPlanShopInfoDTO::getShopId, vo -> vo));
log.info("getPlanListPage shopInfoMap:{}", JSONObject.toJSONString(shopInfoMap) );
log.info("getPlanListPage shopInfoMap:{}", JSONObject.toJSONString(shopInfoMap));
//开店负责人name
List<String> shopManagerUserIdList = openPlanShopList.stream()
.map(OpenPlanShopInfoDTO::getShopManagerUserId)
.collect(Collectors.toList());
List<UserNameDTO> shopManagerList = enterpriseUserDAO.getNameByUserId(shopManagerUserIdList);
log.info("getPlanListPage hopManagerList :{}",JSONObject.toJSONString(shopManagerList) );
log.info("getPlanListPage hopManagerList :{}", JSONObject.toJSONString(shopManagerList));
Map<Long, UserNameDTO> voManagerMap = shopManagerList.stream()
.collect(Collectors.toMap(UserNameDTO::getUserId, vo -> vo));
log.info("getPlanListPage voManagerMap:{}", JSONObject.toJSONString(voManagerMap) );
log.info("getPlanListPage voManagerMap:{}", JSONObject.toJSONString(voManagerMap));
//督导name
List<String> supervisorUserIdList = openPlanShopList.stream()
.map(OpenPlanShopInfoDTO::getSupervisorUserId)
.collect(Collectors.toList());
List<UserNameDTO> supervisorList = enterpriseUserDAO.getNameByUserId(supervisorUserIdList);
log.info("getPlanListPage supervisorList :{}",JSONObject.toJSONString(supervisorList) );
log.info("getPlanListPage supervisorList :{}", JSONObject.toJSONString(supervisorList));
Map<Long, UserNameDTO> voSupervisorList = supervisorList.stream()
.collect(Collectors.toMap(UserNameDTO::getUserId, vo -> vo));
log.info("getPlanListPage openingOperationPlanVOList:{}", JSONObject.toJSONString(openingOperationPlanListVOList) );
log.info("getPlanListPage openingOperationPlanVOList:{}", JSONObject.toJSONString(openingOperationPlanListVOList));
//加盟商姓名,手机号,招商name
List<Long> lines = openPlanShopList.stream()
.map(OpenPlanShopInfoDTO::getLineId)
.collect(Collectors.toList());
List<PlanLineDTO> getLines = lineInfoDAO.getLines(lines);
log.info("getPlanListPage getLines:{}",JSONObject.toJSONString(getLines) );
Map<Long,PlanLineDTO> linemap = getLines.stream()
log.info("getPlanListPage getLines:{}", JSONObject.toJSONString(getLines));
Map<Long, PlanLineDTO> linemap = getLines.stream()
.collect(Collectors.toMap(PlanLineDTO::getLineId, vo -> vo));
log.info("getPlanListPage linemap:{}",JSONObject.toJSONString(linemap) );
for (OpeningOperationPlanListVO vo:openingOperationPlanListVOList){
log.info("getPlanListPage linemap:{}", JSONObject.toJSONString(linemap));
for (OpeningOperationPlanListVO vo : openingOperationPlanListVOList) {
vo.setLineId(shopInfoMap.get(vo.getShopId()).getLineId());
vo.setShopName(shopInfoMap.get(vo.getShopId()).getShopName());
vo.setShopCode(shopInfoMap.get(vo.getShopId()).getShopCode());
@@ -222,6 +212,29 @@ public class OpeningOperationPlanImpl implements OpeningOperationPlanService {
return openingOperationPlanListVOList;
}
@Override
public Boolean flush(Long shopId) {
ShopStageInfoDO orderStageInfo = shopStageInfoDAO.getShopSubStageInfo(shopId, ShopSubStageEnum.SHOP_STAGE_15);
try {
if (orderStageInfo.getShopSubStageStatus().
equals(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_152.getShopSubStageStatus())) {
ShopInfoDO shopInfo = shopService.getShopInfo(shopId);
String shopCode = shopInfo.getShopCode();
Boolean firstOrder = coolStoreStartFlowService.getFirstOrder(shopCode);
log.info("saveOrder,flag:{}", firstOrder);
if (firstOrder) {
//更改子阶段状态
shopStageInfoDAO.updateShopStageAndAuditInfo(shopId,
ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_151, null);
preparationService.whetherToOpenForAcceptance(shopId);
}
}
} catch (Exception e) {
log.error("获取鲜丰订货金异常", e);
return Boolean.FALSE;
}
return Boolean.TRUE;
}
}