提交 66c4ee62 authored 作者: 000516's avatar 000516

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

@丘杰欣 1、原编辑按钮更改为变更按键(即修改名称); 2、变更逻辑为以下: 1> 重新选择门店 :同经销商下所有门店可选 2>修改活动日期 : 当月日期范围:次日 - 月底 3> 活动模式、归属人、上下班时间、工资、杂费:原逻辑不变 3、操作权限卡控: 1>变更操作: 活动日期 > 今日,方可进行变更操作; 活动日期 <= 今日,变更按键不可操作; 2>修改归属人、删除操作: 活动日期 > 今日,方可进行修改归属人、删除操作,否则不可选择; 活动日期 = 今日,分为以后逻辑: 操作时间在上班时间顺延1小时前,可选择,进行修改归属人、删除操作 操作时间在上班时间顺延1小时后,不可选择;
......@@ -200,6 +200,9 @@ public class PromPlanCoreController {
return R.success();
}
/**
* 修改计划
*/
@PutMapping("/one")
public R putActivityPlan(@RequestBody ActivityPlanOperVo operVo){
if (Objects.isNull(operVo.getId())){
......@@ -214,6 +217,9 @@ public class PromPlanCoreController {
return R.success();
}
/**
* 变更归属人
*/
@PutMapping("/more")
public R putActivityPlans(@RequestBody ActivityPlanOperVo operVo){
if (Objects.isNull(operVo.getEmployeeId()) || Collections.isEmpty(operVo.getPlanIds())){
......
......@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;
import java.util.List;
import java.util.Objects;
......@@ -68,8 +69,12 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
@Override
public void updateById(ActivityPlanInfoDto planDto) {
ActivityPlanInfoDo planDo = BeanUtils.transitionDto(planDto, ActivityPlanInfoDo.class);
activityPlanInfoMapper.updateById(planDo);
try {
ActivityPlanInfoDo planDo = BeanUtils.transitionDto(planDto, ActivityPlanInfoDo.class);
activityPlanInfoMapper.updateById(planDo);
} catch (PersistenceException e) {
throw new DataException(RCode.ACTIVITY_PLAN_REPETITION_ERROR);
}
}
@Override
......@@ -96,6 +101,7 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
@Override
public void updateByIds(List<Long> planIds, ActivityPlanInfoDto planDto) {
errorMoreDate(planIds);
activityPlanInfoMapper.updateByIds(planIds, planDto);
}
......@@ -121,16 +127,7 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
if (count > 0 ) {
throw new FlowException(RCode.ACTIVITY_PLAN_NOT_SELF_DELETE);
}
List<ActivityPlanInfoDo> todayPlans = activityPlanInfoMapper.selectTodayCount(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()));
}
}
errorMoreDate(planIds);
activityPlanInfoMapper.updateIsDelete(planIds,operNo);
}
private LambdaQueryWrapper<ActivityPlanInfoDo> buildWrapper(ActivityPlanInfoWrapper wrapper) {
......@@ -175,5 +172,18 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
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 {
// 指定字段查询
qw.select(QinCeClienteleStoreDO::getQcId,
QinCeClienteleStoreDO::getStoreName,
QinCeClienteleStoreDO::getStoreCode,
QinCeClienteleStoreDO::getDealersName,
QinCeClienteleStoreDO::getDealerId,
QinCeClienteleStoreDO::getLineName,
......@@ -139,6 +140,10 @@ public class QinCeClienteleStoreDaoImpl implements QinCeClienteleStoreDao {
if (StringUtils.isNotBlank(storeWrapper.getStoreNameVague())) {
qw.like(QinCeClienteleStoreDO::getStoreName, storeWrapper.getStoreNameVague().trim());
}
// 按经销商ID查询
if (StringUtils.isNotBlank(storeWrapper.getDealerId())) {
qw.eq(QinCeClienteleStoreDO::getDealerId, storeWrapper.getDealerId());
}
return qw;
}
......
......@@ -30,4 +30,5 @@ public class StoreWrapper {
private String storeStatus = "1";
private String storeApprovalStatus = "3";
private String storeCode;
private String dealerId;
}
......@@ -32,4 +32,8 @@ public class ClienteleStoreQueryVo {
*/
private String storeStatus = "1";
private String storeApprovalStatus = "3";
/**
* 经销商ID(查询同一经销商内的门店)
*/
private String dealerId;
}
package com.wangxiaolu.promotion.service.activityplanv2.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -19,17 +19,15 @@ import com.wangxiaolu.promotion.enums.plan.OperationType;
import com.wangxiaolu.promotion.enums.plan.PlanStatus;
import com.wangxiaolu.promotion.exception.DataException;
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.ActivityPlanRecordDto;
import com.wangxiaolu.promotion.pojo.activity.manage.vo.ActivityPlanVo;
import com.wangxiaolu.promotion.pojo.activity.planv2.vo.ActivityPlanOperVo;
import com.wangxiaolu.promotion.pojo.user.dto.ManageEmployeeInfoDto;
import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.activityplanv2.PromPlanCoreService;
import com.wangxiaolu.promotion.utils.DateUtils;
import groovyjarjarpicocli.CommandLine;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -38,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.*;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
/**
......@@ -484,11 +483,20 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
if (PlanStatus.EXECUTION.getCode().equals(dto.getPlanStatus())){
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);
}
// 判断修改后 月底 >= 活动日期 > 今日
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();
// 归属人改变
if (!operVo.getEmployeeId().equals(dto.getEmployeeId())){
......@@ -500,7 +508,24 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
.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())
.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())
.setClockInTime(operVo.getClockInTime())
.setClockOutTime(operVo.getClockOutTime())
......
......@@ -50,4 +50,11 @@ public class DateUtils {
Instant instant = zonedDateTime.toInstant();
return Date.from(instant);
}
public static LocalDate parseDateBylocalDate(Date date) {
if (date == null) {
return null;
}
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}
}
......@@ -12,8 +12,8 @@ spring:
database: 0
password: QjL6H5nH
main:
web-application-type: reactive
# main:
# web-application-type: reactive
cloud:
nacos:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论