package com.dsh.guns.modular.system.controller.general;
|
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.dsh.course.feignClient.activity.DriverActivityClient;
|
import com.dsh.course.feignClient.driver.DriverClient;
|
import com.dsh.course.feignClient.driver.model.DriverInfoRes;
|
import com.dsh.guns.config.UserExt;
|
import com.dsh.guns.core.base.controller.BaseController;
|
import com.dsh.guns.core.base.tips.SuccessTip;
|
import com.dsh.guns.core.exception.ServiceException;
|
import com.dsh.guns.core.log.LogObjectHolder;
|
import com.dsh.guns.core.util.SinataUtil;
|
import com.dsh.guns.modular.system.enums.ActivityTypeEnum;
|
import com.dsh.guns.modular.system.enums.RuleStatusEnum;
|
import com.dsh.guns.modular.system.model.*;
|
import com.dsh.guns.modular.system.service.*;
|
import com.dsh.guns.modular.system.util.DateUtil;
|
import com.dsh.guns.modular.system.util.TimeUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.ui.Model;
|
import org.springframework.util.StringUtils;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.time.LocalDateTime;
|
import java.time.LocalTime;
|
import java.time.format.DateTimeFormatter;
|
import java.util.*;
|
|
/**
|
* 控制器
|
*
|
* @author fengshuonan
|
* @Date 2023-04-20 10:57:51
|
*/
|
@Controller
|
@RequestMapping("/tEnsureIncomeRule")
|
public class TEnsureIncomeRuleController extends BaseController {
|
|
private String PREFIX = "/system/tEnsureIncomeRule/";
|
|
@Autowired
|
private ITEnsureIncomeRuleService tEnsureIncomeRuleService;
|
@Autowired
|
private ITEnsureIncomeFoundationService tEnsureIncomeFoundationService;
|
@Autowired
|
private ITEnsureIncomeSpecialService tEnsureIncomeSpecialService;
|
@Autowired
|
private ITEnsureIncomeSpecialTimeSoltService tEnsureIncomeSpecialTimeSoltService;
|
@Autowired
|
private DriverActivityClient driverActivityClient;
|
@Autowired
|
private DriverClient driverClient;
|
@Autowired
|
private ITAuditRecordService auditRecordService;
|
|
/**
|
* 跳转到首页
|
*/
|
@RequestMapping("")
|
public String index(Model model) {
|
model.addAttribute("language", UserExt.getLanguage());
|
return PREFIX + "tEnsureIncomeRule.html";
|
}
|
|
/**
|
* 跳转到添加
|
*/
|
@RequestMapping("/tEnsureIncomeRule_add")
|
public String tEnsureIncomeRuleAdd(Model model) {
|
model.addAttribute("language", UserExt.getLanguage());
|
return PREFIX + "tEnsureIncomeRule_add.html";
|
}
|
|
/**
|
* 跳转到修改
|
*/
|
@RequestMapping("/tEnsureIncomeRule_update/{tEnsureIncomeRuleId}")
|
public String tEnsureIncomeRuleUpdate(@PathVariable Integer tEnsureIncomeRuleId, Model model) {
|
TEnsureIncomeRule tEnsureIncomeRule = tEnsureIncomeRuleService.getById(tEnsureIncomeRuleId);
|
model.addAttribute("item",tEnsureIncomeRule);
|
LogObjectHolder.me().set(tEnsureIncomeRule);
|
return PREFIX + "tEnsureIncomeRule_edit.html";
|
}
|
|
/**
|
* 跳转到立即处理页面
|
*/
|
@RequestMapping("/tEnsureIncomeRule_immediately/{id}")
|
public String sysCouponActivityImmediately(@PathVariable Integer id, Model model) {
|
model.addAttribute("id",id);
|
model.addAttribute("language", UserExt.getLanguage());
|
return PREFIX + "tEnsureIncomeRule_immediately.html";
|
}
|
|
/**
|
* 立即处理操作
|
*/
|
@RequestMapping(value = "/immediately")
|
@Transactional(rollbackFor = Exception.class)
|
@ResponseBody
|
public Object immediately(@RequestParam Integer id,@RequestParam Integer state,@RequestParam String remark) {
|
TEnsureIncomeRule tEnsureIncomeRule = tEnsureIncomeRuleService.getById(id);
|
if (SinataUtil.isNotEmpty(tEnsureIncomeRule)){
|
tEnsureIncomeRule.setState(state);
|
tEnsureIncomeRule.setRemark(remark);
|
|
if(state == 3){
|
if(LocalDateTime.now().isBefore(TimeUtil.getDayStart(tEnsureIncomeRule.getStartTime()))){
|
tEnsureIncomeRule.setStatus(RuleStatusEnum.NOT_START.getCode());
|
}
|
if(LocalDateTime.now().isAfter(TimeUtil.getDayStart(tEnsureIncomeRule.getStartTime())) && LocalDateTime.now().isBefore(TimeUtil.getDayEnd(tEnsureIncomeRule.getEndTime()))){
|
tEnsureIncomeRule.setStatus(RuleStatusEnum.STARTED.getCode());
|
}
|
}
|
|
tEnsureIncomeRuleService.updateById(tEnsureIncomeRule);
|
|
// 添加审核记录
|
TAuditRecord tAuditRecord = new TAuditRecord();
|
tAuditRecord.setActivityId(id);
|
tAuditRecord.setActivityName(tEnsureIncomeRule.getRuleName());
|
if(state == 2){
|
tAuditRecord.setAuditStatus(3);
|
}
|
if(state == 3){
|
tAuditRecord.setAuditStatus(2);
|
}
|
tAuditRecord.setAuditTime(new Date());
|
tAuditRecord.setAuditUserId(Objects.requireNonNull(UserExt.getUser()).getId());
|
tAuditRecord.setRemark(remark);
|
tAuditRecord.setActivityType(ActivityTypeEnum.INCOME_RULE.getCode());
|
auditRecordService.save(tAuditRecord);
|
}
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 跳转到详情
|
*/
|
@RequestMapping("/tEnsureIncomeRuleDetail/{tEnsureIncomeRuleId}")
|
public String tEnsureIncomeRuleDetail(@PathVariable Integer tEnsureIncomeRuleId, Model model) {
|
model.addAttribute("language", UserExt.getLanguage());
|
model.addAttribute("tEnsureIncomeRuleId", tEnsureIncomeRuleId);
|
TEnsureIncomeRule tEnsureIncomeRule = tEnsureIncomeRuleService.getById(tEnsureIncomeRuleId);
|
tEnsureIncomeRule.setExpireTime(tEnsureIncomeRule.getStartTime().toLocalDate() + "-" +tEnsureIncomeRule.getEndTime().toLocalDate());
|
model.addAttribute("item",tEnsureIncomeRule);
|
LogObjectHolder.me().set(tEnsureIncomeRule);
|
// 查询基础时间段配置
|
List<TEnsureIncomeFoundation> foundationList = tEnsureIncomeFoundationService.list(Wrappers.lambdaQuery(TEnsureIncomeFoundation.class)
|
.eq(TEnsureIncomeFoundation::getEnsureIncomeId, tEnsureIncomeRuleId));
|
model.addAttribute("foundationList",foundationList);
|
// 查询特殊时间段配置
|
List<TEnsureIncomeSpecial> specialList = tEnsureIncomeSpecialService.list(Wrappers.lambdaQuery(TEnsureIncomeSpecial.class)
|
.eq(TEnsureIncomeSpecial::getEnsureIncomeId, tEnsureIncomeRuleId));
|
for (TEnsureIncomeSpecial tEnsureIncomeSpecial : specialList) {
|
tEnsureIncomeSpecial.setStartTimeString(new SimpleDateFormat("yyyy-MM-dd").format(tEnsureIncomeSpecial.getStartTime()));
|
List<TEnsureIncomeSpecialTimeSolt> specialTimeSoltList = tEnsureIncomeSpecialTimeSoltService.list(Wrappers.lambdaQuery(TEnsureIncomeSpecialTimeSolt.class)
|
.eq(TEnsureIncomeSpecialTimeSolt::getEnsureIncomeSpecialId, tEnsureIncomeSpecial.getId()));
|
tEnsureIncomeSpecial.setSpecialTimeSoltList(specialTimeSoltList);
|
}
|
model.addAttribute("specialList",specialList);
|
return PREFIX + "tEnsureIncomeRuleDetail.html";
|
}
|
|
/**
|
* 获取列表
|
*/
|
@RequestMapping(value = "/list")
|
@ResponseBody
|
public Object list(String ruleName,String createTime) {
|
LambdaQueryWrapper<TEnsureIncomeRule> wrapper = new LambdaQueryWrapper<>();
|
if(StringUtils.hasLength(ruleName)){
|
wrapper.like(TEnsureIncomeRule::getRuleName,ruleName);
|
}
|
Date startTimes = null;
|
Date endTimes = null;
|
if (StringUtils.hasLength(createTime)){
|
String[] timeArray = createTime.split(" - ");
|
startTimes = DateUtil.getDate_str3(timeArray[0]+" 00:00:00");
|
endTimes = DateUtil.getDate_str3(timeArray[1]+" 23:59:59");
|
wrapper.between(TEnsureIncomeRule::getCreateTime,startTimes,endTimes);
|
}
|
Integer objectId = Objects.requireNonNull(UserExt.getUser()).getObjectId();
|
if(objectId != 1){
|
wrapper.eq(TEnsureIncomeRule::getCompanyId, Objects.requireNonNull(UserExt.getUser()).getObjectId());
|
}
|
wrapper.orderByDesc(TEnsureIncomeRule::getCreateTime);
|
List<TEnsureIncomeRule> list = tEnsureIncomeRuleService.list(wrapper);
|
for (TEnsureIncomeRule tEnsureIncomeRule : list) {
|
tEnsureIncomeRule.setExpireTime(tEnsureIncomeRule.getStartTime().format(DateTimeFormatter.ofPattern("yyyy.MM.dd"))
|
+ "-" + tEnsureIncomeRule.getEndTime().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")));
|
// 计算参与人次
|
Integer count = driverActivityClient.queryJoinCount(tEnsureIncomeRule.getId());
|
tEnsureIncomeRule.setJoinCount(count);
|
}
|
return list;
|
}
|
|
/**
|
* 获取司机保底收入列表
|
*/
|
@RequestMapping(value = "/incomeList")
|
@ResponseBody
|
public Object incomeList(Integer tEnsureIncomeRuleId) {
|
if(Objects.isNull(tEnsureIncomeRuleId)){
|
return null;
|
}
|
List<Map<String, Object>> list = driverActivityClient.queryDriverIncomeMoney(tEnsureIncomeRuleId);
|
for (Map<String, Object> map : list) {
|
DriverInfoRes driver = driverClient.getDriver(Integer.valueOf(String.valueOf(map.get("driverId"))));
|
map.put("driverName",driver.getName());
|
map.put("driverPhone",driver.getPhone());
|
}
|
return list;
|
}
|
|
/**
|
* 新增
|
*/
|
@RequestMapping(value = "/add")
|
@Transactional(rollbackFor = Exception.class)
|
@ResponseBody
|
public Object add(TEnsureIncomeRule tEnsureIncomeRule,String incomeFoundation,String incomeSpecial){
|
Integer language = UserExt.getLanguage();
|
if(Objects.isNull(language)){
|
language = 1;
|
}
|
|
int count = tEnsureIncomeRuleService.count(Wrappers.lambdaQuery(TEnsureIncomeRule.class)
|
.eq(TEnsureIncomeRule::getRuleName, tEnsureIncomeRule.getRuleName()));
|
if(count > 0){
|
if(1 == language){
|
throw new ServiceException(500,"该活动名称已存在!");
|
}
|
if(2 == language){
|
throw new ServiceException(500,"The activity name already exists!");
|
}
|
if(3 == language){
|
throw new ServiceException(500,"Nama aktivitas sudah ada!");
|
}
|
}
|
|
tEnsureIncomeRule.setStartTime(TimeUtil.getDayStart(TimeUtil.getLocalDateTime(tEnsureIncomeRule.getStartTimeString())));
|
Date date_str3 = new Date();
|
try {
|
Date parse = new SimpleDateFormat("yyyy-MM-dd").parse(tEnsureIncomeRule.getEndTimeString());
|
Map<String, Date> monthDate = TimeUtil.getMonthDate(parse);
|
Date last = monthDate.get("last");
|
String format = new SimpleDateFormat("yyyy-MM-dd").format(last);
|
date_str3 = DateUtil.getDate_str3(format + " 23:59:59");
|
} catch (ParseException e) {
|
throw new RuntimeException(e);
|
}
|
tEnsureIncomeRule.setEndTime(TimeUtil.dateToLocalDateTime(date_str3));
|
|
tEnsureIncomeRule.setCreateTime(LocalDateTime.now());
|
|
// if(LocalDateTime.now().isBefore(TimeUtil.getDayStart(tEnsureIncomeRule.getStartTime()))){
|
// tEnsureIncomeRule.setStatus(RuleStatusEnum.NOT_START.getCode());
|
// }
|
// if(LocalDateTime.now().isAfter(TimeUtil.getDayStart(tEnsureIncomeRule.getStartTime())) && LocalDateTime.now().isBefore(TimeUtil.getDayEnd(tEnsureIncomeRule.getEndTime()))){
|
// tEnsureIncomeRule.setStatus(RuleStatusEnum.STARTED.getCode());
|
// }
|
if(LocalDateTime.now().isAfter(TimeUtil.getDayEnd(tEnsureIncomeRule.getEndTime()))){
|
if(1 == language){
|
throw new ServiceException(500,"有效期无效,请选择正确的有效期!");
|
}
|
if(2 == language){
|
throw new ServiceException(500,"The validity period is invalid. Please select the correct validity period!");
|
}
|
if(3 == language){
|
throw new ServiceException(500,"Periode validitas tidak valid. Please select the correct validity period!");
|
}
|
}
|
tEnsureIncomeRule.setCompanyId(UserExt.getUser().getObjectId());
|
// 活动主数据
|
tEnsureIncomeRuleService.save(tEnsureIncomeRule);
|
|
// 活动基础时间配置
|
JSONArray jsonArray = JSONObject.parseArray(incomeFoundation);
|
List<TEnsureIncomeFoundation> foundationList = new ArrayList<>();
|
Map<String,String> incomeMap = new HashMap<>();
|
Map<String,LocalTime> incomeTimeMap = new HashMap<>();
|
for (int i = 0; i < jsonArray.size(); i++) {
|
String startTime1 = jsonArray.getJSONObject(i).getString("startTime");
|
String endTime1 = jsonArray.getJSONObject(i).getString("endTime");
|
String startTime = incomeMap.get(startTime1);
|
String endTime = incomeMap.get(endTime1);
|
|
if(StringUtils.hasLength(startTime) && StringUtils.hasLength(endTime)){
|
if(1 == language){
|
throw new ServiceException(500,"基础时间段配置存在重复时间段!");
|
}
|
if(2 == language){
|
throw new ServiceException(500,"There are duplicate time periods in the basic time period configuration!");
|
}
|
if(3 == language){
|
throw new ServiceException(500,"Ada periode waktu duplikasi dalam konfigurasi periode waktu dasar!");
|
}
|
}
|
|
LocalTime localStart= LocalTime.parse(startTime1+":00");
|
LocalTime localEnd= LocalTime.parse(endTime1+":00");
|
for (int j = 0; j < incomeTimeMap.entrySet().size(); j++) {
|
LocalTime localStartTime = incomeTimeMap.get("startTime" + j);
|
LocalTime localEndTime = incomeTimeMap.get("endTime" + j);
|
if(Objects.nonNull(localStartTime) && Objects.nonNull(localEndTime)){
|
if((localStart.isAfter(localStartTime) && localStart.isBefore(localEndTime))
|
|| (localEnd.isAfter(localStartTime) && localEnd.isBefore(localEndTime))
|
|| (localStart.isAfter(localStartTime) && localEnd.isBefore(localEndTime))
|
|| (localStart.isBefore(localStartTime) && localEnd.isAfter(localEndTime))
|
|| (localStart.compareTo(localStartTime) == 0)
|
|| (localEnd.compareTo(localEndTime) == 0)){
|
if(1 == language){
|
throw new ServiceException(500,"基础时间段配置存在重合时间段!");
|
}
|
if(2 == language){
|
throw new ServiceException(500,"The basic time period configuration has overlapping time periods!");
|
}
|
if(3 == language){
|
throw new ServiceException(500,"Konfigurasi peristiwa waktu dasar memiliki peristiwa waktu yang meliputi!");
|
}
|
}
|
}
|
}
|
|
TEnsureIncomeFoundation tEnsureIncomeFoundation = new TEnsureIncomeFoundation();
|
tEnsureIncomeFoundation.setEnsureIncomeId(tEnsureIncomeRule.getId());
|
tEnsureIncomeFoundation.setCreateTime(new Date());
|
tEnsureIncomeFoundation.setStartTime(jsonArray.getJSONObject(i).getString("startTime"));
|
tEnsureIncomeFoundation.setEndTime(jsonArray.getJSONObject(i).getString("endTime"));
|
tEnsureIncomeFoundation.setAmount(jsonArray.getJSONObject(i).getBigDecimal("amount"));
|
tEnsureIncomeFoundation.setOnLineTime(jsonArray.getJSONObject(i).getInteger("onLineTime"));
|
foundationList.add(tEnsureIncomeFoundation);
|
|
incomeMap.put(jsonArray.getJSONObject(i).getString("startTime"),jsonArray.getJSONObject(i).getString("startTime"));
|
incomeMap.put(jsonArray.getJSONObject(i).getString("endTime"),jsonArray.getJSONObject(i).getString("endTime"));
|
incomeTimeMap.put("startTime"+i,localStart);
|
incomeTimeMap.put("endTime"+i,localEnd);
|
}
|
tEnsureIncomeFoundationService.saveBatch(foundationList);
|
|
// 活动特殊时间配置
|
if(StringUtils.hasLength(incomeSpecial)){
|
JSONArray jsonArray1 = JSONObject.parseArray(incomeSpecial);
|
Map<String,String> specialMap = new HashMap<>();
|
for (int i = 0; i < jsonArray1.size(); i++) {
|
String dayTime = specialMap.get(jsonArray1.getJSONObject(i).getString("dayTime"));
|
if(StringUtils.hasLength(dayTime)){
|
if(1 == language){
|
throw new ServiceException(500,"特殊时间段基础配置存在重复日期!");
|
}
|
if(2 == language){
|
throw new ServiceException(500,"Special time period basic configuration has duplicate dates!");
|
}
|
if(3 == language){
|
throw new ServiceException(500,"Konfigurasi dasar periode waktu khusus memiliki tanggal duplikasi!");
|
}
|
}
|
|
TEnsureIncomeSpecial tEnsureIncomeSpecial = new TEnsureIncomeSpecial();
|
tEnsureIncomeSpecial.setEnsureIncomeId(tEnsureIncomeRule.getId());
|
tEnsureIncomeSpecial.setCreateTime(new Date());
|
tEnsureIncomeSpecial.setStartTime(DateUtil.parse(jsonArray1.getJSONObject(i).getString("dayTime"),"yyyy-MM-dd"));
|
tEnsureIncomeSpecial.setPeriodDayAmount(jsonArray1.getJSONObject(i).getBigDecimal("periodDaySpecialAmount"));
|
tEnsureIncomeSpecialService.save(tEnsureIncomeSpecial);
|
|
JSONArray incomeSpecialTimeArr = jsonArray1.getJSONObject(i).getJSONArray("incomeSpecialTimeArr");
|
List<TEnsureIncomeSpecialTimeSolt> specialTimeSoltList = new ArrayList<>(incomeSpecialTimeArr.size());
|
Map<String,String> specialSoltMap = new HashMap<>();
|
Map<String,LocalTime> incomeTimeSpecialMap = new HashMap<>();
|
for (int j = 0; j < incomeSpecialTimeArr.size(); j++) {
|
String startSpecialTime1 = incomeSpecialTimeArr.getJSONObject(j).getString("startSpecialTime");
|
String endSpecialTime1 = incomeSpecialTimeArr.getJSONObject(j).getString("endSpecialTime");
|
String startSpecialTime = specialSoltMap.get(startSpecialTime1);
|
String endSpecialTime = specialSoltMap.get(endSpecialTime1);
|
if(StringUtils.hasLength(startSpecialTime) && StringUtils.hasLength(endSpecialTime)){
|
if(1 == language){
|
throw new ServiceException(500,"特殊时间段日期为-"+jsonArray1.getJSONObject(i).getString("dayTime")+"-存在重复时间段!");
|
}
|
if(2 == language){
|
throw new ServiceException(500,"Special time period dates are-"+jsonArray1.getJSONObject(i).getString("dayTime")+"-There are duplicate time periods!");
|
}
|
if(3 == language){
|
throw new ServiceException(500,"Tanggal periode waktu khusus adalah-"+jsonArray1.getJSONObject(i).getString("dayTime")+"-Ada periode waktu duplikasi!");
|
}
|
}
|
|
LocalTime localStart= LocalTime.parse(startSpecialTime1+":00");
|
LocalTime localEnd= LocalTime.parse(endSpecialTime1+":00");
|
for (int a = 0; a < incomeTimeSpecialMap.entrySet().size(); a++) {
|
LocalTime localStartTime = incomeTimeSpecialMap.get("startSpecialTime" + a);
|
LocalTime localEndTime = incomeTimeSpecialMap.get("endSpecialTime" + a);
|
if(Objects.nonNull(localStartTime) && Objects.nonNull(localEndTime)){
|
if((localStart.isAfter(localStartTime) && localStart.isBefore(localEndTime))
|
|| (localEnd.isAfter(localStartTime) && localEnd.isBefore(localEndTime))
|
|| (localStart.isAfter(localStartTime) && localEnd.isBefore(localEndTime))
|
|| (localStart.isBefore(localStartTime) && localEnd.isAfter(localEndTime))
|
|| (localStart.compareTo(localStartTime) == 0)
|
|| (localEnd.compareTo(localEndTime) == 0)){
|
if(1 == language){
|
throw new ServiceException(500,"特殊时间段配置存在重合时间段!");
|
}
|
if(2 == language){
|
throw new ServiceException(500,"Special time period configuration with overlapping time periods!");
|
}
|
if(3 == language){
|
throw new ServiceException(500,"Konfigurasi peristiwa waktu khusus dengan peristiwa waktu yang saling bertindak!");
|
}
|
}
|
}
|
}
|
|
incomeTimeSpecialMap.put("startSpecialTime"+j,localStart);
|
incomeTimeSpecialMap.put("endSpecialTime"+j,localEnd);
|
|
TEnsureIncomeSpecialTimeSolt specialTimeSolt = new TEnsureIncomeSpecialTimeSolt();
|
specialTimeSolt.setEnsureIncomeSpecialId(tEnsureIncomeSpecial.getId());
|
specialTimeSolt.setCreateTime(new Date());
|
specialTimeSolt.setStartTime(incomeSpecialTimeArr.getJSONObject(j).getString("startSpecialTime"));
|
specialTimeSolt.setEndTime(incomeSpecialTimeArr.getJSONObject(j).getString("endSpecialTime"));
|
specialTimeSolt.setAmount(incomeSpecialTimeArr.getJSONObject(j).getBigDecimal("specialAmount"));
|
specialTimeSolt.setOnLineTime(incomeSpecialTimeArr.getJSONObject(j).getInteger("specialOnLineTime"));
|
specialTimeSoltList.add(specialTimeSolt);
|
|
specialSoltMap.put(incomeSpecialTimeArr.getJSONObject(j).getString("startSpecialTime"),incomeSpecialTimeArr.getJSONObject(j).getString("startSpecialTime"));
|
specialSoltMap.put(incomeSpecialTimeArr.getJSONObject(j).getString("endSpecialTime"),incomeSpecialTimeArr.getJSONObject(j).getString("endSpecialTime"));
|
}
|
specialMap.put(jsonArray1.getJSONObject(i).getString("dayTime"),jsonArray1.getJSONObject(i).getString("dayTime"));
|
tEnsureIncomeSpecialTimeSoltService.saveBatch(specialTimeSoltList);
|
}
|
}
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除
|
*/
|
@RequestMapping(value = "/delete")
|
@ResponseBody
|
public Object delete(@RequestParam Integer tEnsureIncomeRuleId) {
|
tEnsureIncomeRuleService.removeById(tEnsureIncomeRuleId);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改
|
*/
|
@RequestMapping(value = "/update")
|
@ResponseBody
|
public Object update(TEnsureIncomeRule tEnsureIncomeRule) {
|
tEnsureIncomeRuleService.updateById(tEnsureIncomeRule);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 暂停,开启
|
*/
|
@RequestMapping(value = "/stopOrStart")
|
@ResponseBody
|
public Object stopOrStart(@RequestParam Integer tEnsureIncomeRuleId) {
|
Integer language = UserExt.getLanguage();
|
if(Objects.isNull(language)){
|
language = 1;
|
}
|
TEnsureIncomeRule tEnsureIncomeRule = tEnsureIncomeRuleService.getById(tEnsureIncomeRuleId);
|
if(tEnsureIncomeRule.getState() == 1){
|
if(1==language){
|
return new SuccessTip(500,"请先审核该数据!");
|
}
|
if(2==language){
|
return new SuccessTip(500,"Please review the data first!");
|
}
|
if(3==language){
|
return new SuccessTip(500,"Please review the data first!");
|
}
|
}
|
if(RuleStatusEnum.PAUSED.getCode() != tEnsureIncomeRule.getStatus()){
|
// 不是暂停中的状态,点击按钮变为暂停中的状态
|
tEnsureIncomeRule.setStatus(RuleStatusEnum.PAUSED.getCode());
|
tEnsureIncomeRuleService.updateById(tEnsureIncomeRule);
|
return SUCCESS_TIP;
|
}
|
if(RuleStatusEnum.PAUSED.getCode() == tEnsureIncomeRule.getStatus()){
|
// 是暂停中的状态,判断单签时间是否在有效期内已开始
|
if(LocalDateTime.now().isBefore(TimeUtil.getDayStart(tEnsureIncomeRule.getStartTime()))){
|
tEnsureIncomeRule.setStatus(RuleStatusEnum.NOT_START.getCode());
|
}
|
if(LocalDateTime.now().isAfter(TimeUtil.getDayStart(tEnsureIncomeRule.getStartTime())) && LocalDateTime.now().isBefore(TimeUtil.getDayEnd(tEnsureIncomeRule.getEndTime()))){
|
tEnsureIncomeRule.setStatus(RuleStatusEnum.STARTED.getCode());
|
}
|
if(LocalDateTime.now().isAfter(TimeUtil.getDayEnd(tEnsureIncomeRule.getEndTime()))){
|
return new SuccessTip(500,"已结束活动不可开启!");
|
}
|
tEnsureIncomeRuleService.updateById(tEnsureIncomeRule);
|
return SUCCESS_TIP;
|
}
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 详情
|
*/
|
@RequestMapping(value = "/detail/{tEnsureIncomeRuleId}")
|
@ResponseBody
|
public Object detail(@PathVariable("tEnsureIncomeRuleId") Integer tEnsureIncomeRuleId) {
|
return tEnsureIncomeRuleService.getById(tEnsureIncomeRuleId);
|
}
|
}
|