提交 d1995915 authored 作者: 000516's avatar 000516 提交者: Coding

操作CP计划逻辑展示(变更+删除)

操作CP计划逻辑展示(变更+删除)
...@@ -200,6 +200,9 @@ public class PromPlanCoreController { ...@@ -200,6 +200,9 @@ public class PromPlanCoreController {
return R.success(); return R.success();
} }
/**
* 修改计划
*/
@PutMapping("/one") @PutMapping("/one")
public R putActivityPlan(@RequestBody ActivityPlanOperVo operVo){ public R putActivityPlan(@RequestBody ActivityPlanOperVo operVo){
if (Objects.isNull(operVo.getId())){ if (Objects.isNull(operVo.getId())){
...@@ -214,6 +217,9 @@ public class PromPlanCoreController { ...@@ -214,6 +217,9 @@ public class PromPlanCoreController {
return R.success(); return R.success();
} }
/**
* 变更归属人
*/
@PutMapping("/more") @PutMapping("/more")
public R putActivityPlans(@RequestBody ActivityPlanOperVo operVo){ public R putActivityPlans(@RequestBody ActivityPlanOperVo operVo){
if (Objects.isNull(operVo.getEmployeeId()) || Collections.isEmpty(operVo.getPlanIds())){ if (Objects.isNull(operVo.getEmployeeId()) || Collections.isEmpty(operVo.getPlanIds())){
......
...@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
...@@ -68,6 +69,11 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao { ...@@ -68,6 +69,11 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
@Override @Override
public void updateById(ActivityPlanInfoDto planDto) { public void updateById(ActivityPlanInfoDto planDto) {
// 判断计划是否存在
ActivityPlanInfoDo activityPlanInfoDo = activityPlanInfoMapper.selectPlan(planDto.getStoreCode(), planDto.getDate());
if (Objects.nonNull(activityPlanInfoDo)){
throw new DataException(RCode.ACTIVITY_PLAN_REPETITION_ERROR);
}
ActivityPlanInfoDo planDo = BeanUtils.transitionDto(planDto, ActivityPlanInfoDo.class); ActivityPlanInfoDo planDo = BeanUtils.transitionDto(planDto, ActivityPlanInfoDo.class);
activityPlanInfoMapper.updateById(planDo); activityPlanInfoMapper.updateById(planDo);
} }
...@@ -96,6 +102,7 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao { ...@@ -96,6 +102,7 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
@Override @Override
public void updateByIds(List<Long> planIds, ActivityPlanInfoDto planDto) { public void updateByIds(List<Long> planIds, ActivityPlanInfoDto planDto) {
errorMoreDate(planIds);
activityPlanInfoMapper.updateByIds(planIds, planDto); activityPlanInfoMapper.updateByIds(planIds, planDto);
} }
...@@ -121,16 +128,7 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao { ...@@ -121,16 +128,7 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
if (count > 0 ) { if (count > 0 ) {
throw new FlowException(RCode.ACTIVITY_PLAN_NOT_SELF_DELETE); throw new FlowException(RCode.ACTIVITY_PLAN_NOT_SELF_DELETE);
} }
List<ActivityPlanInfoDo> todayPlans = activityPlanInfoMapper.selectTodayCount(planIds); errorMoreDate(planIds);
// 今日数据存在时,判断当前时间是否在今日10点前
for (ActivityPlanInfoDo todayPlan : todayPlans) {
if (PlanStatus.EXECUTION.getCode().equals(todayPlan.getPlanStatus())) {
throw new FlowException(RCode.ACTIVITY_ID_IS_START.getCode(),String.format(RCode.ACTIVITY_ID_IS_START.getMsg(),todayPlan.getId()));
}
if (LocalDateTime.now().isAfter(todayPlan.getClockInTime().plusHours(1))){
throw new FlowException(RCode.ACTIVITY_PLAN_ID_NOT_DELETE.getCode(),String.format(RCode.ACTIVITY_PLAN_ID_NOT_DELETE.getMsg(),todayPlan.getId()));
}
}
activityPlanInfoMapper.updateIsDelete(planIds,operNo); activityPlanInfoMapper.updateIsDelete(planIds,operNo);
} }
private LambdaQueryWrapper<ActivityPlanInfoDo> buildWrapper(ActivityPlanInfoWrapper wrapper) { private LambdaQueryWrapper<ActivityPlanInfoDo> buildWrapper(ActivityPlanInfoWrapper wrapper) {
...@@ -175,5 +173,18 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao { ...@@ -175,5 +173,18 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
return qw; return qw;
} }
private void errorMoreDate(List<Long> planIds){
List<ActivityPlanInfoDo> todayPlans = activityPlanInfoMapper.selectTodayCount(planIds);
// 今日数据存在时,判断是否执行、上班时间顺延1小时
for (ActivityPlanInfoDo todayPlan : todayPlans) {
if (PlanStatus.EXECUTION.getCode().equals(todayPlan.getPlanStatus())) {
throw new FlowException(RCode.ACTIVITY_ID_IS_START.getCode(),String.format(RCode.ACTIVITY_ID_IS_START.getMsg(),todayPlan.getId()));
}
// 判断修改时间是否在促销员上班1小时内
if (LocalDateTime.now().isAfter(todayPlan.getClockInTime().plusHours(1))){
throw new FlowException(RCode.ACTIVITY_PLAN_ID_NOT_DELETE.getCode(),String.format(RCode.ACTIVITY_PLAN_ID_NOT_DELETE.getMsg(),todayPlan.getId()));
}
}
}
} }
...@@ -105,6 +105,7 @@ public class QinCeClienteleStoreDaoImpl implements QinCeClienteleStoreDao { ...@@ -105,6 +105,7 @@ public class QinCeClienteleStoreDaoImpl implements QinCeClienteleStoreDao {
// 指定字段查询 // 指定字段查询
qw.select(QinCeClienteleStoreDO::getQcId, qw.select(QinCeClienteleStoreDO::getQcId,
QinCeClienteleStoreDO::getStoreName, QinCeClienteleStoreDO::getStoreName,
QinCeClienteleStoreDO::getStoreCode,
QinCeClienteleStoreDO::getDealersName, QinCeClienteleStoreDO::getDealersName,
QinCeClienteleStoreDO::getDealerId, QinCeClienteleStoreDO::getDealerId,
QinCeClienteleStoreDO::getLineName, QinCeClienteleStoreDO::getLineName,
...@@ -139,6 +140,10 @@ public class QinCeClienteleStoreDaoImpl implements QinCeClienteleStoreDao { ...@@ -139,6 +140,10 @@ public class QinCeClienteleStoreDaoImpl implements QinCeClienteleStoreDao {
if (StringUtils.isNotBlank(storeWrapper.getStoreNameVague())) { if (StringUtils.isNotBlank(storeWrapper.getStoreNameVague())) {
qw.like(QinCeClienteleStoreDO::getStoreName, storeWrapper.getStoreNameVague().trim()); qw.like(QinCeClienteleStoreDO::getStoreName, storeWrapper.getStoreNameVague().trim());
} }
// 按经销商ID查询
if (StringUtils.isNotBlank(storeWrapper.getDealerId())) {
qw.eq(QinCeClienteleStoreDO::getDealerId, storeWrapper.getDealerId());
}
return qw; return qw;
} }
......
...@@ -30,4 +30,5 @@ public class StoreWrapper { ...@@ -30,4 +30,5 @@ public class StoreWrapper {
private String storeStatus = "1"; private String storeStatus = "1";
private String storeApprovalStatus = "3"; private String storeApprovalStatus = "3";
private String storeCode; private String storeCode;
private String dealerId;
} }
...@@ -32,4 +32,8 @@ public class ClienteleStoreQueryVo { ...@@ -32,4 +32,8 @@ public class ClienteleStoreQueryVo {
*/ */
private String storeStatus = "1"; private String storeStatus = "1";
private String storeApprovalStatus = "3"; private String storeApprovalStatus = "3";
/**
* 经销商ID(查询同一经销商内的门店)
*/
private String dealerId;
} }
package com.wangxiaolu.promotion.service.activityplanv2.impl; package com.wangxiaolu.promotion.service.activityplanv2.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -19,17 +19,15 @@ import com.wangxiaolu.promotion.enums.plan.OperationType; ...@@ -19,17 +19,15 @@ import com.wangxiaolu.promotion.enums.plan.OperationType;
import com.wangxiaolu.promotion.enums.plan.PlanStatus; import com.wangxiaolu.promotion.enums.plan.PlanStatus;
import com.wangxiaolu.promotion.exception.DataException; import com.wangxiaolu.promotion.exception.DataException;
import com.wangxiaolu.promotion.exception.FlowException; import com.wangxiaolu.promotion.exception.FlowException;
import com.wangxiaolu.promotion.exception.ParamException; import com.wangxiaolu.promotion.pojo.activity.manage.vo.ActivityPlanVo;
import com.wangxiaolu.promotion.pojo.activity.planv2.dto.ActivityPlanInfoDto; import com.wangxiaolu.promotion.pojo.activity.planv2.dto.ActivityPlanInfoDto;
import com.wangxiaolu.promotion.pojo.activity.planv2.dto.ActivityPlanRecordDto; import com.wangxiaolu.promotion.pojo.activity.planv2.dto.ActivityPlanRecordDto;
import com.wangxiaolu.promotion.pojo.activity.manage.vo.ActivityPlanVo;
import com.wangxiaolu.promotion.pojo.activity.planv2.vo.ActivityPlanOperVo; import com.wangxiaolu.promotion.pojo.activity.planv2.vo.ActivityPlanOperVo;
import com.wangxiaolu.promotion.pojo.user.dto.ManageEmployeeInfoDto; import com.wangxiaolu.promotion.pojo.user.dto.ManageEmployeeInfoDto;
import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto; import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto;
import com.wangxiaolu.promotion.result.basedata.RCode; import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.activityplanv2.PromPlanCoreService; import com.wangxiaolu.promotion.service.activityplanv2.PromPlanCoreService;
import com.wangxiaolu.promotion.utils.DateUtils; import com.wangxiaolu.promotion.utils.DateUtils;
import groovyjarjarpicocli.CommandLine;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -38,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -38,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.*; import java.time.*;
import java.time.temporal.TemporalAdjusters;
import java.util.*; import java.util.*;
/** /**
...@@ -484,11 +483,20 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -484,11 +483,20 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
if (PlanStatus.EXECUTION.getCode().equals(dto.getPlanStatus())){ if (PlanStatus.EXECUTION.getCode().equals(dto.getPlanStatus())){
throw new FlowException(RCode.ACTIVITY_IS_START); throw new FlowException(RCode.ACTIVITY_IS_START);
} }
// 判断修改时间是否在促销员上班1小时内 // 不可修改活动日期 <= 今日 的计划
if (LocalDateTime.now().isAfter(dto.getClockInTime().plusHours(1))){ if (DateUtils.parseDateBylocalDate(dto.getDate()).isBefore(LocalDate.now())){
throw new FlowException(RCode.ACTIVITY_PLAN_NOT_DELETE); throw new FlowException(RCode.ACTIVITY_PLAN_NOT_DELETE);
} }
// 判断修改后 月底 >= 活动日期 > 今日
LocalDate today = LocalDate.now();
Date planDate = operVo.getDate();
LocalDate localDatePlan = DateUtils.parseDateBylocalDate(planDate);
LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth());
if (!localDatePlan.isAfter(today) || localDatePlan.isAfter(lastDayOfMonth)){
throw new FlowException(RCode.ACTIVITY_PLAN_DATA_ERROR);
}
ActivityPlanInfoDto planDto = new ActivityPlanInfoDto(); ActivityPlanInfoDto planDto = new ActivityPlanInfoDto();
// 归属人改变 // 归属人改变
if (!operVo.getEmployeeId().equals(dto.getEmployeeId())){ if (!operVo.getEmployeeId().equals(dto.getEmployeeId())){
...@@ -500,7 +508,24 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -500,7 +508,24 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
.setOrgName(employeeInfoDto.getDeptQcName()); .setOrgName(employeeInfoDto.getDeptQcName());
} }
StoreWrapper storeWrap = new StoreWrapper().setStoreCode(operVo.getStoreCode());
QinCeClienteleStoreDto storeDto = qinCeClienteleStoreDao.getOneStore(storeWrap);
if (!storeDto.getDealerId().equals(dto.getDealerId())){
throw new FlowException(RCode.QINCE_STORE_DEALER_ERROR);
}
planDto.setId(operVo.getId()) planDto.setId(operVo.getId())
.setLineName(storeDto.getLineName())
.setStoreCode(storeDto.getStoreCode())
.setStoreName(storeDto.getStoreName())
.setDealerId(storeDto.getDealerId())
.setDealerName(storeDto.getDealersName())
.setProvince(storeDto.getStoreMssProvince())
.setCity(storeDto.getStoreMssCity())
.setArea(storeDto.getStoreMssArea())
.setAddr(storeDto.getStoreAddr())
.setDate(planDate)
.setPattern(operVo.getPattern()) .setPattern(operVo.getPattern())
.setClockInTime(operVo.getClockInTime()) .setClockInTime(operVo.getClockInTime())
.setClockOutTime(operVo.getClockOutTime()) .setClockOutTime(operVo.getClockOutTime())
......
...@@ -50,4 +50,11 @@ public class DateUtils { ...@@ -50,4 +50,11 @@ public class DateUtils {
Instant instant = zonedDateTime.toInstant(); Instant instant = zonedDateTime.toInstant();
return Date.from(instant); return Date.from(instant);
} }
public static LocalDate parseDateBylocalDate(Date date) {
if (date == null) {
return null;
}
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论