@@ -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 . getPageSiz e ( ) ) ;
log . info ( " getPlanListPage openPlanShopList:{} " , JSONObject . toJSONString ( openPlanShopList ) ) ;
List < OpenPlanShopInfoDTO > openPlanShopList = shopInfoDAO .
getOpenPlanShopListByShopName ( shopIdlist , request . getShopName ( ) , request . getBigName ( ) ,
request . getFightNam e ( )
) ;
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 ;
}
}