提交 b2b62cc8 authored 作者: 李秋林's avatar 李秋林

管理员删除活动记录,关联删除打卡记录,恢复促销计划执行状态

上级 653f20df
package com.wangxiaolu.promotion.controller.activity.manage.tem;
import com.wangxiaolu.promotion.enums.activity.TemActApproveStatus;
import com.wangxiaolu.promotion.enums.plan.PlanStatus;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.pojo.activity.manage.vo.ApproveVo;
import com.wangxiaolu.promotion.result.basedata.R;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.activity.manage.EmployeeCoreTemActivityService;
import com.wangxiaolu.promotion.service.activity.manage.EmployeeCoreTemClockService;
import com.wangxiaolu.promotion.service.activityplanv2.PromPlanCoreService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
/**
......@@ -22,7 +26,11 @@ import org.springframework.web.bind.annotation.*;
public class EmployeeCoreTemActivityController {
@Autowired
EmployeeCoreTemActivityService employeeCoreTemActivityService;
private EmployeeCoreTemActivityService employeeCoreTemActivityService;
@Autowired
private EmployeeCoreTemClockService employeeCoreTemClockService;
@Autowired
private PromPlanCoreService promPlanCoreService;
/**
* 管理员审批上报活动数据
......@@ -39,9 +47,15 @@ public class EmployeeCoreTemActivityController {
/**
* 管理员删除活动记录
*/
@Transactional(rollbackFor = Exception.class)
@DeleteMapping("/delete/{id}")
public R deleteActivityById(@PathVariable("id") long id){
employeeCoreTemActivityService.deleteById(id);
// 删除打卡记录
Long planId = employeeCoreTemClockService.deleteClockByReportedId(id);
// 把计划状态改为未执行
promPlanCoreService.updatePlanStatus(planId, PlanStatus.NOT_EXECUTION);
return R.success();
}
......
......@@ -2,12 +2,15 @@ package com.wangxiaolu.promotion.controller.activity.manage.tem;
import com.wangxiaolu.promotion.common.redis.RedisKeys;
import com.wangxiaolu.promotion.common.redis.service.RedisCache;
import com.wangxiaolu.promotion.enums.plan.PlanStatus;
import com.wangxiaolu.promotion.pojo.activity.manage.vo.ClockVo;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryClockDto;
import com.wangxiaolu.promotion.result.basedata.R;
import com.wangxiaolu.promotion.service.activity.manage.EmployeeCoreTemClockService;
import com.wangxiaolu.promotion.service.activityplanv2.PromPlanCoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
/**
......@@ -21,7 +24,9 @@ import org.springframework.web.bind.annotation.*;
public class EmployeeCoreTemClockController {
@Autowired
EmployeeCoreTemClockService employeeCoreTemClockService;
private EmployeeCoreTemClockService employeeCoreTemClockService;
@Autowired
private PromPlanCoreService promPlanCoreService;
@Autowired
private RedisCache redisCache;
......@@ -37,9 +42,14 @@ public class EmployeeCoreTemClockController {
return R.success();
}
@Transactional(rollbackFor = Exception.class)
@DeleteMapping("/delete/{id}")
public R deleteClockById(@PathVariable("id") long id){
employeeCoreTemClockService.deleteClockById(id);
// 删除打卡记录
Long planId = employeeCoreTemClockService.deleteClockById(id);
// 把计划状态改为未执行
promPlanCoreService.updatePlanStatus(planId, PlanStatus.NOT_EXECUTION);
return R.success();
}
......
......@@ -10,5 +10,7 @@ import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryClockDto;
public interface EmployeeCoreTemClockService {
void updateClockactivityPattern(TemporaryClockDto temporaryClockDto);
void deleteClockById(long id);
Long deleteClockById(long id);
Long deleteClockByReportedId(long reportedId);
}
......@@ -63,7 +63,6 @@ public class EmployeeCoreTemActivityServiceImpl implements EmployeeCoreTemActivi
tempActivityLogDao.save(reportedDto.getTemporaryId(), reportedDto.getTemporaryName(), logType, temActDto.getId(), temActDto);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void deleteById(long id) {
// 查询记录判断是否存在
......
......@@ -4,6 +4,7 @@ import com.wangxiaolu.promotion.common.enums.StatusType;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityClockDao;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityPhotoDao;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityReportedDao;
import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryClockWrapper;
import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryPhotoWrapper;
import com.wangxiaolu.promotion.exception.DataException;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
......@@ -53,13 +54,28 @@ public class EmployeeCoreTemClockServiceImpl implements EmployeeCoreTemClockServ
}
@Override
public void deleteClockById(long id) {
public Long deleteClockById(long id) {
// 查询打卡记录并删除
TemporaryClockDto clockDto = temporaryActivityClockDao.selectById(id);
if (Objects.isNull(clockDto)){
throw new DataException(RCode.CLOCK_DATA_NOT_HAVE_ERROR);
}
return deleteClock(clockDto);
}
@Override
public Long deleteClockByReportedId(long reportedId) {
// 查询打卡记录并删除
TemporaryClockWrapper tcw = new TemporaryClockWrapper();
tcw.setReportedId(reportedId);
TemporaryClockDto clockDto = temporaryActivityClockDao.selectOne(tcw);
if (Objects.isNull(clockDto)){
throw new DataException(RCode.CLOCK_DATA_NOT_HAVE_ERROR);
}
return deleteClock(clockDto);
}
private Long deleteClock(TemporaryClockDto clockDto){
TemporaryClockDto updateClockDto = new TemporaryClockDto();
updateClockDto.setId(clockDto.getId()).setIsDelete(StatusType.INVALID.getType());
temporaryActivityClockDao.updateById(updateClockDto);
......@@ -69,6 +85,7 @@ public class EmployeeCoreTemClockServiceImpl implements EmployeeCoreTemClockServ
tpw.setTemporaryId(clockDto.getTemporaryId())
.setClockId(clockDto.getId());
temporaryActivityPhotoDao.updateStatus(tpw,StatusType.INVALID.getType());
return clockDto.getPlanId();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论