diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java new file mode 100644 index 000000000..258244d2a --- /dev/null +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java @@ -0,0 +1,197 @@ +package com.stdiet.web.controller.custom; + +import java.util.Date; +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.stdiet.common.annotation.Log; +import com.stdiet.common.core.controller.BaseController; +import com.stdiet.common.core.domain.AjaxResult; +import com.stdiet.common.enums.BusinessType; +import com.stdiet.custom.domain.SysLiveSchedul; +import com.stdiet.custom.service.ISysLiveSchedulService; +import com.stdiet.common.utils.poi.ExcelUtil; +import com.stdiet.common.core.page.TableDataInfo; + +/** + * 直播排班Controller + * + * @author xzj + * @date 2021-05-12 + */ +@RestController +@RequestMapping("/custom/liveSchedul") +public class SysLiveSchedulController extends BaseController +{ + @Autowired + private ISysLiveSchedulService sysLiveSchedulService; + + /** + * 查询直播排班列表 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:list')") + @GetMapping("/list") + public TableDataInfo list(SysLiveSchedul sysLiveSchedul) + { + startPage(); + List list = sysLiveSchedulService.selectSysLiveSchedulList(sysLiveSchedul); + return getDataTable(list); + } + + /** + * 导出直播排班列表 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:export')") + @Log(title = "直播排班", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(SysLiveSchedul sysLiveSchedul) + { + List list = sysLiveSchedulService.selectSysLiveSchedulList(sysLiveSchedul); + ExcelUtil util = new ExcelUtil(SysLiveSchedul.class); + return util.exportExcel(list, "liveSchedul"); + } + + /** + * 获取直播排班详细信息 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(sysLiveSchedulService.selectSysLiveSchedulById(id)); + } + + /** + * 新增直播排班 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:add')") + @Log(title = "直播排班", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysLiveSchedul sysLiveSchedul) + { + SysLiveSchedul oldLiveSchedul = sysLiveSchedulService.getLiveSchedulByLiveTime(sysLiveSchedul); + if(oldLiveSchedul != null){ + return AjaxResult.error("直播时间冲突,无法添加"); + } + //下播,补全下播时间 + if (sysLiveSchedul.getLiveStatus() != null && sysLiveSchedul.getLiveStatus().longValue() == 2 + && sysLiveSchedul.getLiveEndTime() == null){ + sysLiveSchedul.setLiveEndTime(new Date()); + } + int row = sysLiveSchedulService.insertSysLiveSchedul(sysLiveSchedul); + if(row > 0){ + if(sysLiveSchedul.getLiveStatus() != null){ + //开播 + if(sysLiveSchedul.getLiveStatus().longValue() == 1){ + SysLiveSchedul lastLiveSchedul = sysLiveSchedulService.getLastLiveSchedulById(sysLiveSchedul); + //上一个直播还在直播,需要关闭上一个直播 + if(lastLiveSchedul != null && lastLiveSchedul.getLiveStatus().longValue() == 1){ + lastLiveSchedul.setLiveStatus(2L); + if(lastLiveSchedul.getLiveEndTime() == null){ + lastLiveSchedul.setLiveEndTime(sysLiveSchedul.getLiveStartTime()); + } + row = sysLiveSchedulService.updateSysLiveSchedul(lastLiveSchedul); + } + } + } + } + return toAjax(row); + } + + /** + * 修改直播排班 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:edit')") + @Log(title = "直播排班", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysLiveSchedul sysLiveSchedul) + { + SysLiveSchedul oldLiveSchedul = sysLiveSchedulService.getLiveSchedulByLiveTime(sysLiveSchedul); + if(oldLiveSchedul != null && oldLiveSchedul.getId().longValue() != sysLiveSchedul.getId().longValue()){ + return AjaxResult.error("直播时间冲突,无法修改"); + } + //下播,补全下播时间 + if (sysLiveSchedul.getLiveStatus() != null && sysLiveSchedul.getLiveStatus().longValue() == 2 + && sysLiveSchedul.getLiveEndTime() == null){ + sysLiveSchedul.setLiveEndTime(new Date()); + } + int row = sysLiveSchedulService.updateSysLiveSchedulById(sysLiveSchedul); + if(row > 0){ + if(sysLiveSchedul.getLiveStatus() != null){ + //开播 + if(sysLiveSchedul.getLiveStatus().longValue() == 1){ + SysLiveSchedul lastLiveSchedul = sysLiveSchedulService.getLastLiveSchedulById(sysLiveSchedul); + //上一个直播还在直播,需要关闭上一个直播 + if(lastLiveSchedul != null && lastLiveSchedul.getLiveStatus().longValue() == 1){ + lastLiveSchedul.setLiveStatus(2L); + if(lastLiveSchedul.getLiveEndTime() == null){ + lastLiveSchedul.setLiveEndTime(sysLiveSchedul.getLiveStartTime()); + } + row = sysLiveSchedulService.updateSysLiveSchedul(lastLiveSchedul); + } + } + } + } + return toAjax(row); + } + + /** + * 删除直播排班 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:remove')") + @Log(title = "直播排班", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(sysLiveSchedulService.deleteSysLiveSchedulByIds(ids)); + } + + /** + * 开播、下播 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:edit')") + @Log(title = "开播下播", businessType = BusinessType.UPDATE) + @GetMapping(value = "/updateLiveStatus") + public AjaxResult updateLiveStatus(SysLiveSchedul sysLiveSchedul) + { + if(sysLiveSchedul.getId() == null || sysLiveSchedul.getLiveStatus() == null){ + return AjaxResult.error("操作失败"); + } + int row = 0; + if(sysLiveSchedul.getLiveStatus().longValue() == 1){ + row = sysLiveSchedulService.updateSysLiveSchedul(sysLiveSchedul); + if(row > 0){ + sysLiveSchedul = sysLiveSchedulService.selectSysLiveSchedulById(sysLiveSchedul.getId()); + if(sysLiveSchedul != null && sysLiveSchedul.getLiveStatus() != null){ + //开播 + if(sysLiveSchedul.getLiveStatus().longValue() == 1){ + SysLiveSchedul lastLiveSchedul = sysLiveSchedulService.getLastLiveSchedulById(sysLiveSchedul); + //上一个直播还在直播,需要关闭上一个直播 + if(lastLiveSchedul != null && lastLiveSchedul.getLiveStatus().longValue() == 1){ + lastLiveSchedul.setLiveStatus(2L); + if(lastLiveSchedul.getLiveEndTime() == null){ + lastLiveSchedul.setLiveEndTime(sysLiveSchedul.getLiveStartTime()); + } + row = sysLiveSchedulService.updateSysLiveSchedul(lastLiveSchedul); + } + } + } + } + }else{ + SysLiveSchedul newLiveSchedul = sysLiveSchedulService.selectSysLiveSchedulById(sysLiveSchedul.getId()); + if(newLiveSchedul != null && newLiveSchedul.getLiveEndTime() == null){ + sysLiveSchedul.setLiveEndTime(new Date()); + } + row = sysLiveSchedulService.updateSysLiveSchedul(sysLiveSchedul); + } + return toAjax(row); + } +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysLiveSchedul.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysLiveSchedul.java new file mode 100644 index 000000000..1af68872a --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysLiveSchedul.java @@ -0,0 +1,83 @@ +package com.stdiet.custom.domain; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.stdiet.common.annotation.Excel; +import com.stdiet.common.core.domain.BaseEntity; +import lombok.Data; + +/** + * 直播排班对象 sys_live_schedul + * + * @author xzj + * @date 2021-05-12 + */ +@Data +public class SysLiveSchedul extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 直播间序号 */ + @Excel(name = "直播间序号") + private Integer liveRoom; + + /** 排班日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "排班日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date liveSchedulDate; + + /** 直播开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + @Excel(name = "直播开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date liveStartTime; + + /** 直播结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + @Excel(name = "直播结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date liveEndTime; + + /** 直播营养师 */ + @Excel(name = "直播营养师") + private Long liveNutritionistId; + + /** 直播运营 */ + @Excel(name = "直播运营") + private Long liveOperatorId; + + /** 直播策划 */ + @Excel(name = "直播策划") + private Long livePlannerId; + + /** 微信账号管理的进粉渠道 */ + @Excel(name = "微信账号管理的进粉渠道") + private Integer fanChannel; + + /** 直播状态,0未开播 1已开播 2已下播 */ + @Excel(name = "直播状态,0未开播 1已开播 2已下播") + private Long liveStatus; + + /** 删除标识,默认0 */ + private Integer delFlag; + + //微信账号ID + private Long wxAccountId; + + //直播间名称 + private String liveRoomName; + + private String liveNutritionistName; + + private String livePlannerName; + + private String liveOperatorName; + + private String fanChannelName; + + private List> wxAccountList; +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysLiveSchedulMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysLiveSchedulMapper.java new file mode 100644 index 000000000..a64893bbc --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysLiveSchedulMapper.java @@ -0,0 +1,80 @@ +package com.stdiet.custom.mapper; + +import java.util.List; +import com.stdiet.custom.domain.SysLiveSchedul; + +/** + * 直播排班Mapper接口 + * + * @author xzj + * @date 2021-05-12 + */ +public interface SysLiveSchedulMapper +{ + /** + * 查询直播排班 + * + * @param id 直播排班ID + * @return 直播排班 + */ + public SysLiveSchedul selectSysLiveSchedulById(Long id); + + /** + * 查询直播排班列表 + * + * @param sysLiveSchedul 直播排班 + * @return 直播排班集合 + */ + public List selectSysLiveSchedulList(SysLiveSchedul sysLiveSchedul); + + /** + * 新增直播排班 + * + * @param sysLiveSchedul 直播排班 + * @return 结果 + */ + public int insertSysLiveSchedul(SysLiveSchedul sysLiveSchedul); + + /** + * 修改直播排班 + * + * @param sysLiveSchedul 直播排班 + * @return 结果 + */ + public int updateSysLiveSchedul(SysLiveSchedul sysLiveSchedul); + + /** + * 删除直播排班 + * + * @param id 直播排班ID + * @return 结果 + */ + public int deleteSysLiveSchedulById(Long id); + + /** + * 批量删除直播排班 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteSysLiveSchedulByIds(Long[] ids); + + /** + * 根据直播时间查询是否重叠 + */ + public SysLiveSchedul getLiveSchedulByLiveTime(SysLiveSchedul sysLiveSchedul); + + /** + * 更新部分字段 + * @param sysLiveSchedul + * @return + */ + public int updateSysLiveSchedulById(SysLiveSchedul sysLiveSchedul); + + /** + * 根据ID查询上一条记录 + * @param sysLiveSchedul + * @return + */ + public SysLiveSchedul getLastLiveSchedulById(SysLiveSchedul sysLiveSchedul); +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysLiveSchedulService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysLiveSchedulService.java new file mode 100644 index 000000000..cd75428c4 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysLiveSchedulService.java @@ -0,0 +1,80 @@ +package com.stdiet.custom.service; + +import java.util.List; +import com.stdiet.custom.domain.SysLiveSchedul; + +/** + * 直播排班Service接口 + * + * @author xzj + * @date 2021-05-12 + */ +public interface ISysLiveSchedulService +{ + /** + * 查询直播排班 + * + * @param id 直播排班ID + * @return 直播排班 + */ + public SysLiveSchedul selectSysLiveSchedulById(Long id); + + /** + * 查询直播排班列表 + * + * @param sysLiveSchedul 直播排班 + * @return 直播排班集合 + */ + public List selectSysLiveSchedulList(SysLiveSchedul sysLiveSchedul); + + /** + * 新增直播排班 + * + * @param sysLiveSchedul 直播排班 + * @return 结果 + */ + public int insertSysLiveSchedul(SysLiveSchedul sysLiveSchedul); + + /** + * 修改直播排班 + * + * @param sysLiveSchedul 直播排班 + * @return 结果 + */ + public int updateSysLiveSchedul(SysLiveSchedul sysLiveSchedul); + + /** + * 批量删除直播排班 + * + * @param ids 需要删除的直播排班ID + * @return 结果 + */ + public int deleteSysLiveSchedulByIds(Long[] ids); + + /** + * 删除直播排班信息 + * + * @param id 直播排班ID + * @return 结果 + */ + public int deleteSysLiveSchedulById(Long id); + + /** + * 根据直播时间查询是否重叠 + */ + public SysLiveSchedul getLiveSchedulByLiveTime(SysLiveSchedul sysLiveSchedul); + + /** + * 更新部分字段 + * @param sysLiveSchedul + * @return + */ + public int updateSysLiveSchedulById(SysLiveSchedul sysLiveSchedul); + + /** + * 根据ID查询上一条记录 + * @param sysLiveSchedul + * @return + */ + public SysLiveSchedul getLastLiveSchedulById(SysLiveSchedul sysLiveSchedul); +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysLiveSchedulServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysLiveSchedulServiceImpl.java new file mode 100644 index 000000000..8e15c6662 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysLiveSchedulServiceImpl.java @@ -0,0 +1,126 @@ +package com.stdiet.custom.service.impl; + +import java.util.List; +import com.stdiet.common.utils.DateUtils; +import lombok.Data; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.stdiet.custom.mapper.SysLiveSchedulMapper; +import com.stdiet.custom.domain.SysLiveSchedul; +import com.stdiet.custom.service.ISysLiveSchedulService; + +/** + * 直播排班Service业务层处理 + * + * @author xzj + * @date 2021-05-12 + */ +@Service +public class SysLiveSchedulServiceImpl implements ISysLiveSchedulService +{ + @Autowired + private SysLiveSchedulMapper sysLiveSchedulMapper; + + /** + * 查询直播排班 + * + * @param id 直播排班ID + * @return 直播排班 + */ + @Override + public SysLiveSchedul selectSysLiveSchedulById(Long id) + { + return sysLiveSchedulMapper.selectSysLiveSchedulById(id); + } + + /** + * 查询直播排班列表 + * + * @param sysLiveSchedul 直播排班 + * @return 直播排班 + */ + @Override + public List selectSysLiveSchedulList(SysLiveSchedul sysLiveSchedul) + { + return sysLiveSchedulMapper.selectSysLiveSchedulList(sysLiveSchedul); + } + + /** + * 新增直播排班 + * + * @param sysLiveSchedul 直播排班 + * @return 结果 + */ + @Override + public int insertSysLiveSchedul(SysLiveSchedul sysLiveSchedul) + { + sysLiveSchedul.setCreateTime(DateUtils.getNowDate()); + return sysLiveSchedulMapper.insertSysLiveSchedul(sysLiveSchedul); + } + + /** + * 修改直播排班 + * + * @param sysLiveSchedul 直播排班 + * @return 结果 + */ + @Override + public int updateSysLiveSchedul(SysLiveSchedul sysLiveSchedul) + { + sysLiveSchedul.setUpdateTime(DateUtils.getNowDate()); + return sysLiveSchedulMapper.updateSysLiveSchedul(sysLiveSchedul); + } + + /** + * 批量删除直播排班 + * + * @param ids 需要删除的直播排班ID + * @return 结果 + */ + @Override + public int deleteSysLiveSchedulByIds(Long[] ids) + { + return sysLiveSchedulMapper.deleteSysLiveSchedulByIds(ids); + } + + /** + * 删除直播排班信息 + * + * @param id 直播排班ID + * @return 结果 + */ + @Override + public int deleteSysLiveSchedulById(Long id) + { + return sysLiveSchedulMapper.deleteSysLiveSchedulById(id); + } + + /** + * 根据直播时间查询是否重叠 + */ + @Override + public SysLiveSchedul getLiveSchedulByLiveTime(SysLiveSchedul sysLiveSchedul){ + return sysLiveSchedulMapper.getLiveSchedulByLiveTime(sysLiveSchedul); + } + + /** + * 更新部分字段 + * @param sysLiveSchedul + * @return + */ + @Override + public int updateSysLiveSchedulById(SysLiveSchedul sysLiveSchedul){ + sysLiveSchedul.setUpdateTime(DateUtils.getNowDate()); + return sysLiveSchedulMapper.updateSysLiveSchedulById(sysLiveSchedul); + } + + /** + * 根据ID查询上一条记录 + * @param sysLiveSchedul + * @return + */ + @Override + public SysLiveSchedul getLastLiveSchedulById(SysLiveSchedul sysLiveSchedul){ + return sysLiveSchedulMapper.getLastLiveSchedulById(sysLiveSchedul); + } +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderPauseServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderPauseServiceImpl.java index c4255ddfc..9dbdddceb 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderPauseServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderPauseServiceImpl.java @@ -98,10 +98,13 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService public int deleteSysOrderPauseByIds(Long[] ids) { SysOrderPause sysOrderPause = selectSysOrderPauseById(ids[0]); - if(sysOrderPauseMapper.deleteSysOrderPauseByIds(ids) > 0){ - return sysOrderService.updateOrderServerStartEndDate(sysOrderPause.getCusId()); + int row = sysOrderPauseMapper.deleteSysOrderPauseByIds(ids); + if(row > 0){ + if(sysOrderPause != null && sysOrderPause.getCusId() != null){ + sysOrderService.updateOrderServerStartEndDate(sysOrderPause.getCusId()); + } } - return 0; + return row; } /** diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml new file mode 100644 index 000000000..878d805bc --- /dev/null +++ b/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, live_room, live_schedul_date,live_start_time, live_end_time, live_nutritionist_id, live_operator_id, live_planner_id, fan_channel, live_status, create_time, create_by, update_time, update_by, del_flag + + + + + + + + insert into sys_live_schedul + + live_room, + live_schedul_date, + live_start_time, + live_end_time, + live_nutritionist_id, + live_operator_id, + live_planner_id, + fan_channel, + live_status, + create_time, + create_by, + update_time, + update_by, + del_flag, + + + #{liveRoom}, + #{liveSchedulDate}, + #{liveStartTime}, + #{liveEndTime}, + #{liveNutritionistId}, + #{liveOperatorId}, + #{livePlannerId}, + #{fanChannel}, + #{liveStatus}, + #{createTime}, + #{createBy}, + #{updateTime}, + #{updateBy}, + #{delFlag}, + + + + + update sys_live_schedul + + live_room = #{liveRoom}, + live_schedul_date = #{liveSchedulDate}, + live_start_time = #{liveStartTime}, + live_end_time = #{liveEndTime}, + live_nutritionist_id = #{liveNutritionistId}, + live_operator_id = #{liveOperatorId}, + live_planner_id = #{livePlannerId}, + fan_channel = #{fanChannel}, + live_status = #{liveStatus}, + create_time = #{createTime}, + create_by = #{createBy}, + update_time = #{updateTime}, + update_by = #{updateBy}, + del_flag = #{delFlag}, + + where id = #{id} + + + + update sys_live_schedul set live_room = #{liveRoom},live_schedul_date = #{liveSchedulDate},live_start_time = #{liveStartTime}, + live_end_time = #{liveEndTime},live_nutritionist_id = #{liveNutritionistId},live_operator_id = #{liveOperatorId},live_planner_id = #{livePlannerId}, + fan_channel = #{fanChannel},live_status = #{liveStatus},update_time = #{updateTime} + where id = #{id} + + + + update sys_live_schedul set del_flag = 1 where id = #{id} + + + + update sys_live_schedul set del_flag = 1 where id in + + #{id} + + + + + + + + + + + \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml index c81aff4a7..b5af6eb3d 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml @@ -114,8 +114,8 @@