添加暂停计划

This commit is contained in:
huangdeliang 2021-03-02 18:56:19 +08:00
parent ecbc4705a2
commit 0f47bb8bc9
3 changed files with 85 additions and 122 deletions

View File

@ -27,7 +27,7 @@ import com.stdiet.common.core.page.TableDataInfo;
* @date 2021-01-07 * @date 2021-01-07
*/ */
@RestController @RestController
@RequestMapping("/orderPause/pause") @RequestMapping("/recipes/pause")
public class SysOrderPauseController extends BaseController public class SysOrderPauseController extends BaseController
{ {
@Autowired @Autowired
@ -36,7 +36,7 @@ public class SysOrderPauseController extends BaseController
/** /**
* 查询订单服务暂停列表 * 查询订单服务暂停列表
*/ */
@PreAuthorize("@ss.hasPermi('orderPause:pause:query')") @PreAuthorize("@ss.hasPermi('recipes:pause:query')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysOrderPause sysOrderPause) public TableDataInfo list(SysOrderPause sysOrderPause)
{ {
@ -48,7 +48,7 @@ public class SysOrderPauseController extends BaseController
/** /**
* 导出订单服务暂停列表 * 导出订单服务暂停列表
*/ */
@PreAuthorize("@ss.hasPermi('orderPause:pause:export')") @PreAuthorize("@ss.hasPermi('recipes:pause:export')")
@Log(title = "订单服务暂停", businessType = BusinessType.EXPORT) @Log(title = "订单服务暂停", businessType = BusinessType.EXPORT)
@GetMapping("/export") @GetMapping("/export")
public AjaxResult export(SysOrderPause sysOrderPause) public AjaxResult export(SysOrderPause sysOrderPause)
@ -61,7 +61,7 @@ public class SysOrderPauseController extends BaseController
/** /**
* 获取订单服务暂停详细信息 * 获取订单服务暂停详细信息
*/ */
@PreAuthorize("@ss.hasPermi('orderPause:pause:query')") @PreAuthorize("@ss.hasPermi('recipes:pause:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) public AjaxResult getInfo(@PathVariable("id") Long id)
{ {
@ -71,7 +71,7 @@ public class SysOrderPauseController extends BaseController
/** /**
* 新增订单服务暂停 * 新增订单服务暂停
*/ */
@PreAuthorize("@ss.hasPermi('orderPause:pause:add')") @PreAuthorize("@ss.hasPermi('recipes:pause:add')")
@Log(title = "订单服务暂停", businessType = BusinessType.INSERT) @Log(title = "订单服务暂停", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody SysOrderPause sysOrderPause) public AjaxResult add(@RequestBody SysOrderPause sysOrderPause)
@ -80,13 +80,18 @@ public class SysOrderPauseController extends BaseController
if(count > 0){ if(count > 0){
return AjaxResult.error("时间范围重叠,请检查时间"); return AjaxResult.error("时间范围重叠,请检查时间");
} }
long orderId = sysOrderPauseService.selectNearMainOrderIdByCusId(sysOrderPause.getCusId());
if(orderId < 0) {
return AjaxResult.error("找不到对应的订单信息");
}
sysOrderPause.setOrderId(orderId);
return toAjax(sysOrderPauseService.insertSysOrderPause(sysOrderPause)); return toAjax(sysOrderPauseService.insertSysOrderPause(sysOrderPause));
} }
/** /**
* 修改订单服务暂停 * 修改订单服务暂停
*/ */
@PreAuthorize("@ss.hasPermi('orderPause:pause:edit')") @PreAuthorize("@ss.hasPermi('recipes:pause:edit')")
@Log(title = "订单服务暂停", businessType = BusinessType.UPDATE) @Log(title = "订单服务暂停", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody SysOrderPause sysOrderPause) public AjaxResult edit(@RequestBody SysOrderPause sysOrderPause)
@ -101,7 +106,7 @@ public class SysOrderPauseController extends BaseController
/** /**
* 删除订单服务暂停 * 删除订单服务暂停
*/ */
@PreAuthorize("@ss.hasPermi('orderPause:pause:remove')") @PreAuthorize("@ss.hasPermi('recipes:pause:remove')")
@Log(title = "订单服务暂停", businessType = BusinessType.DELETE) @Log(title = "订单服务暂停", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids)

View File

@ -1,11 +1,12 @@
package com.stdiet.custom.domain; package com.stdiet.custom.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.stdiet.common.annotation.Excel;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity; import java.util.Date;
/** /**
* 订单服务暂停对象 sys_order_pause * 订单服务暂停对象 sys_order_pause
@ -13,115 +14,59 @@ import com.stdiet.common.core.domain.BaseEntity;
* @author xzj * @author xzj
* @date 2021-01-07 * @date 2021-01-07
*/ */
public class SysOrderPause extends BaseEntity @Data
{ public class SysOrderPause {
private static final long serialVersionUID = 1L;
/** $column.columnComment */ /**
* $column.columnComment
*/
private Long id; private Long id;
/** 订单id */ /**
* 订单id
*/
private Long orderId; private Long orderId;
/** 服务暂停开始时间 */ private Long cusId;
/**
* 服务暂停开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "服务暂停开始时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "服务暂停开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date pauseStartDate; private Date pauseStartDate;
/** 服务暂停结束时间 */ /**
* 服务暂停结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "服务暂停结束时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "服务暂停结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date pauseEndDate; private Date pauseEndDate;
/** 服务暂停理由 */ /**
* 服务暂停理由
*/
@Excel(name = "服务暂停理由") @Excel(name = "服务暂停理由")
private String reason; private String reason;
/** 备注 */ /**
* 备注
*/
@Excel(name = "备注") @Excel(name = "备注")
private String remarks; private String remarks;
/** 删除标识 0未删除 1已删除默认0 */ /**
* 删除标识 0未删除 1已删除默认0
*/
private Integer delFlag; private Integer delFlag;
public void setId(Long id) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
{ private Date createTime;
this.id = id;
}
public Long getId() @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
{ private Date updateTime;
return id;
}
public void setOrderId(Long orderId)
{
this.orderId = orderId;
}
public Long getOrderId() private String createBy;
{
return orderId;
}
public void setPauseStartDate(Date pauseStartDate)
{
this.pauseStartDate = pauseStartDate;
}
public Date getPauseStartDate() private String updateBy;
{
return pauseStartDate;
}
public void setPauseEndDate(Date pauseEndDate)
{
this.pauseEndDate = pauseEndDate;
}
public Date getPauseEndDate()
{
return pauseEndDate;
}
public void setReason(String reason)
{
this.reason = reason;
}
public String getReason()
{
return reason;
}
public void setRemarks(String remarks)
{
this.remarks = remarks;
}
public String getRemarks()
{
return remarks;
}
public void setDelFlag(Integer delFlag)
{
this.delFlag = delFlag;
}
public Integer getDelFlag()
{
return delFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("orderId", getOrderId())
.append("pauseStartDate", getPauseStartDate())
.append("pauseEndDate", getPauseEndDate())
.append("reason", getReason())
.append("remarks", getRemarks())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.append("delFlag", getDelFlag())
.toString();
}
} }

View File

@ -7,6 +7,7 @@
<resultMap type="SysOrderPause" id="SysOrderPauseResult"> <resultMap type="SysOrderPause" id="SysOrderPauseResult">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="orderId" column="order_id"/> <result property="orderId" column="order_id"/>
<result property="cusId" column="cus_id"/>
<result property="pauseStartDate" column="pause_start_date"/> <result property="pauseStartDate" column="pause_start_date"/>
<result property="pauseEndDate" column="pause_end_date"/> <result property="pauseEndDate" column="pause_end_date"/>
<result property="reason" column="reason"/> <result property="reason" column="reason"/>
@ -19,21 +20,22 @@
</resultMap> </resultMap>
<sql id="baseSelectField"> <sql id="baseSelectField">
id, order_id, pause_start_date, pause_end_date, reason, remarks, create_time, create_by, update_time, update_by, del_flag id, order_id, cus_id, pause_start_date, pause_end_date, reason, remarks, create_time, create_by, update_time, update_by, del_flag
</sql> </sql>
<sql id="selectSysOrderPauseVo"> <sql id="selectSysOrderPauseVo">
select id, order_id, pause_start_date, pause_end_date, reason, remarks, create_time, create_by, update_time, update_by, del_flag from sys_order_pause sop select id, order_id, cus_id, pause_start_date, pause_end_date, reason, remarks, create_time, create_by, update_time, update_by, del_flag from sys_recipes_pause sop
</sql> </sql>
<select id="selectSysOrderPauseList" parameterType="SysOrderPause" resultMap="SysOrderPauseResult"> <select id="selectSysOrderPauseList" parameterType="SysOrderPause" resultMap="SysOrderPauseResult">
<!--select sop.id, sop.order_id, sop.pause_start_date, sop.pause_end_date, sop.reason, sop.remarks, sop.create_time, sop.create_by, sop.update_time, sop.update_by, sop.del_flag, <!--select sop.id, sop.order_id, sop.pause_start_date, sop.pause_end_date, sop.reason, sop.remarks, sop.create_time, sop.create_by, sop.update_time, sop.update_by, sop.del_flag,
so.customer,so.order_time so.customer,so.order_time
from sys_order_pause sop from sys_recipes_pause sop
left join sys_order so on so.order_id = sop.order_id--> left join sys_order so on so.order_id = sop.order_id-->
<include refid="selectSysOrderPauseVo"></include> <include refid="selectSysOrderPauseVo"></include>
where sop.del_flag = 0 where sop.del_flag = 0
<if test="orderId != null ">and sop.order_id = #{orderId}</if> <if test="orderId != null ">and sop.order_id = #{orderId}</if>
<if test="cusId != null ">and sop.cus_id = #{cusId}</if>
<if test="pauseStartDate != null ">and sop.pause_start_date = #{pauseStartDate}</if> <if test="pauseStartDate != null ">and sop.pause_start_date = #{pauseStartDate}</if>
<if test="pauseEndDate != null ">and sop.pause_end_date = #{pauseEndDate}</if> <if test="pauseEndDate != null ">and sop.pause_end_date = #{pauseEndDate}</if>
<if test="reason != null and reason != ''">and sop.reason = #{reason}</if> <if test="reason != null and reason != ''">and sop.reason = #{reason}</if>
@ -46,9 +48,10 @@
</select> </select>
<insert id="insertSysOrderPause" parameterType="SysOrderPause" useGeneratedKeys="true" keyProperty="id"> <insert id="insertSysOrderPause" parameterType="SysOrderPause" useGeneratedKeys="true" keyProperty="id">
insert into sys_order_pause insert into sys_recipes_pause
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null">order_id,</if> <if test="orderId != null">order_id,</if>
<if test="cusId != null">cus_id,</if>
<if test="pauseStartDate != null">pause_start_date,</if> <if test="pauseStartDate != null">pause_start_date,</if>
<if test="pauseEndDate != null">pause_end_date,</if> <if test="pauseEndDate != null">pause_end_date,</if>
<if test="reason != null">reason,</if> <if test="reason != null">reason,</if>
@ -61,6 +64,7 @@
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if> <if test="orderId != null">#{orderId},</if>
<if test="cusId != null">#{cusId},</if>
<if test="pauseStartDate != null">#{pauseStartDate},</if> <if test="pauseStartDate != null">#{pauseStartDate},</if>
<if test="pauseEndDate != null">#{pauseEndDate},</if> <if test="pauseEndDate != null">#{pauseEndDate},</if>
<if test="reason != null">#{reason},</if> <if test="reason != null">#{reason},</if>
@ -74,9 +78,10 @@
</insert> </insert>
<update id="updateSysOrderPause" parameterType="SysOrderPause"> <update id="updateSysOrderPause" parameterType="SysOrderPause">
update sys_order_pause update sys_recipes_pause
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="orderId != null">order_id = #{orderId},</if> <if test="orderId != null">order_id = #{orderId},</if>
<if test="cusId != null">cus_id = #{cusId},</if>
<if test="pauseStartDate != null">pause_start_date = #{pauseStartDate},</if> <if test="pauseStartDate != null">pause_start_date = #{pauseStartDate},</if>
<if test="pauseEndDate != null">pause_end_date = #{pauseEndDate},</if> <if test="pauseEndDate != null">pause_end_date = #{pauseEndDate},</if>
<if test="reason != null">reason = #{reason},</if> <if test="reason != null">reason = #{reason},</if>
@ -91,11 +96,11 @@
</update> </update>
<update id="deleteSysOrderPauseById" parameterType="Long"> <update id="deleteSysOrderPauseById" parameterType="Long">
update sys_order_pause set del_flag = 1 where id = #{id} update sys_recipes_pause set del_flag = 1 where id = #{id}
</update> </update>
<update id="deleteSysOrderPauseByIds" parameterType="String"> <update id="deleteSysOrderPauseByIds" parameterType="String">
update sys_order_pause set del_flag = 1 where id in update sys_recipes_pause set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
@ -103,7 +108,7 @@
<!-- 根据订单ID、时间范围查询数量 --> <!-- 根据订单ID、时间范围查询数量 -->
<select id="getCountByOrderIdAndPauseDate" parameterType="SysOrderPause" resultType="int"> <select id="getCountByOrderIdAndPauseDate" parameterType="SysOrderPause" resultType="int">
select count(id) from sys_order_pause where del_flag = 0 and order_id = #{orderId} select count(id) from sys_recipes_pause where del_flag = 0 and order_id = #{orderId}
AND (#{pauseStartDate} >= pause_start_date AND pause_end_date >= #{pauseStartDate} AND (#{pauseStartDate} >= pause_start_date AND pause_end_date >= #{pauseStartDate}
OR #{pauseEndDate} >= pause_start_date AND pause_end_date >= #{pauseEndDate}) OR #{pauseEndDate} >= pause_start_date AND pause_end_date >= #{pauseEndDate})
<if test="id != null"> <if test="id != null">
@ -114,10 +119,18 @@
<!-- 根据订单ID删除暂停记录 --> <!-- 根据订单ID删除暂停记录 -->
<update id="deletePauseByOrderId" parameterType="String"> <update id="deletePauseByOrderId" parameterType="String">
update sys_order_pause set del_flag = 1 where order_id in update sys_recipes_pause set del_flag = 1 where order_id in
<foreach item="orderId" collection="array" open="(" separator="," close=")"> <foreach item="orderId" collection="array" open="(" separator="," close=")">
#{orderId} #{orderId}
</foreach> </foreach>
</update> </update>
<select id="selectNearMainOrderIdByCusId" parameterType="Long" resultType="Long">
SELECT order_id
FROM sys_order
WHERE cus_id=#{cusId} AND del_flag = 0 AND order_type IN(0, 1) AND after_sale_commiss_order = 0
AND order_money_type IN(0, 2) AND main_order_id=0 AND server_end_time > NOW()
ORDER BY server_end_time ASC LIMIT 1
</select>
</mapper> </mapper>