diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysOrderPauseController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysOrderPauseController.java index 5c84378a5..e22c8b304 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysOrderPauseController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysOrderPauseController.java @@ -27,7 +27,7 @@ import com.stdiet.common.core.page.TableDataInfo; * @date 2021-01-07 */ @RestController -@RequestMapping("/orderPause/pause") +@RequestMapping("/recipes/pause") public class SysOrderPauseController extends BaseController { @Autowired @@ -36,7 +36,7 @@ public class SysOrderPauseController extends BaseController /** * 查询订单服务暂停列表 */ - @PreAuthorize("@ss.hasPermi('orderPause:pause:query')") + @PreAuthorize("@ss.hasPermi('recipes:pause:query')") @GetMapping("/list") 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) @GetMapping("/export") 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}") 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) @PostMapping public AjaxResult add(@RequestBody SysOrderPause sysOrderPause) @@ -80,13 +80,18 @@ public class SysOrderPauseController extends BaseController if(count > 0){ return AjaxResult.error("时间范围重叠,请检查时间"); } + long orderId = sysOrderPauseService.selectNearMainOrderIdByCusId(sysOrderPause.getCusId()); + if(orderId < 0) { + return AjaxResult.error("找不到对应的订单信息"); + } + sysOrderPause.setOrderId(orderId); return toAjax(sysOrderPauseService.insertSysOrderPause(sysOrderPause)); } /** * 修改订单服务暂停 */ - @PreAuthorize("@ss.hasPermi('orderPause:pause:edit')") + @PreAuthorize("@ss.hasPermi('recipes:pause:edit')") @Log(title = "订单服务暂停", businessType = BusinessType.UPDATE) @PutMapping 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) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesPlanController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesPlanController.java index 88f35a1f4..d3383d550 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesPlanController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesPlanController.java @@ -31,7 +31,7 @@ public class SysRecipesPlanController extends BaseController /** * 查询食谱计划列表 */ - @PreAuthorize("@ss.hasPermi('recipes:recipesPlan:list')") + @PreAuthorize("@ss.hasPermi('recipes:plan:list')") @GetMapping("/list") public TableDataInfo list(SysRecipesPlan sysRecipesPlan) { @@ -48,7 +48,7 @@ public class SysRecipesPlanController extends BaseController /** * 根据订单查询完整食谱计划列表 */ - @PreAuthorize("@ss.hasPermi('recipes:recipesPlan:list')") + @PreAuthorize("@ss.hasPermi('recipes:plan:list')") @GetMapping("/getAllPlanByOrderId") public TableDataInfo getAllPlanByOrderId(SysRecipesPlan sysRecipesPlan) { @@ -57,7 +57,7 @@ public class SysRecipesPlanController extends BaseController return getDataTable(list); } - @PreAuthorize("@ss.hasPermi('recipes:recipesPlan:list')") + @PreAuthorize("@ss.hasPermi('recipes:plan:list')") @GetMapping(value = "/list/{cusId}") public AjaxResult getAllPlanByCusId(@PathVariable Long cusId) { return AjaxResult.success(sysRecipesPlanService.selectPlanListByCusId(cusId)); @@ -66,7 +66,7 @@ public class SysRecipesPlanController extends BaseController /** * 获取食谱计划详细信息 */ - @PreAuthorize("@ss.hasPermi('recipes:recipesPlan:query')") + @PreAuthorize("@ss.hasPermi('recipes:plan:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { @@ -76,7 +76,7 @@ public class SysRecipesPlanController extends BaseController /** * 修改食谱计划 */ - @PreAuthorize("@ss.hasPermi('recipes:recipesPlan:edit')") + @PreAuthorize("@ss.hasPermi('recipes:plan:edit')") @Log(title = "食谱计划", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody SysRecipesPlan sysRecipesPlan) @@ -87,7 +87,7 @@ public class SysRecipesPlanController extends BaseController /** * 导出食谱计划列表 */ - @PreAuthorize("@ss.hasPermi('recipes:recipesPlan:export')") + @PreAuthorize("@ss.hasPermi('recipes:plan:export')") @Log(title = "食谱计划", businessType = BusinessType.EXPORT) @GetMapping("/export") public AjaxResult export(SysRecipesPlan sysRecipesPlan) diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesTemplateController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesTemplateController.java index ffb0c8cca..1185cb7bb 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesTemplateController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesTemplateController.java @@ -26,7 +26,7 @@ public class SysRecipesTemplateController extends BaseController { /** * 查询 */ - @PreAuthorize("@ss.hasPermi('recipes:recipesTemplate:list')") + @PreAuthorize("@ss.hasPermi('recipes:template:list')") @GetMapping("/list") public TableDataInfo list(SysRecipesTemplate sysRecipesTemplate) { startPage(); @@ -34,7 +34,7 @@ public class SysRecipesTemplateController extends BaseController { return getDataTable(list); } - @PreAuthorize("@ss.hasPermi('recipes:recipesTemplate:list')") + @PreAuthorize("@ss.hasPermi('recipes:template:list')") @GetMapping(value = "/{id}") public AjaxResult detail(@PathVariable Long id) { return AjaxResult.success(iSysRecipesTemplateService.getRecipesTemplateById(id)); @@ -43,7 +43,7 @@ public class SysRecipesTemplateController extends BaseController { /** * 添加 */ - @PreAuthorize("@ss.hasPermi('recipes:recipesTemplate:edit')") + @PreAuthorize("@ss.hasPermi('recipes:template:edit')") @PostMapping("/add") public AjaxResult add(@RequestBody SysRecipesTemplate sysRecipesTemplate) { return toAjax(iSysRecipesTemplateService.insertRecipsesTemplate(sysRecipesTemplate)); @@ -52,7 +52,7 @@ public class SysRecipesTemplateController extends BaseController { /** * 更新 */ - @PreAuthorize("@ss.hasPermi('recipes:recipesTemplate:list')") + @PreAuthorize("@ss.hasPermi('recipes:template:list')") @PutMapping(value = "/update") public AjaxResult update(@RequestBody SysRecipesTemplate sysRecipesTemplate) { return toAjax(iSysRecipesTemplateService.updateRecipesTemplate(sysRecipesTemplate)); @@ -61,7 +61,7 @@ public class SysRecipesTemplateController extends BaseController { /** * 删除 */ - @PreAuthorize("@ss.hasPermi('recipes:recipesTemplate:query')") + @PreAuthorize("@ss.hasPermi('recipes:template:query')") @DeleteMapping(value = "/delete/{id}") public AjaxResult delete(@PathVariable("id") Long id) { return AjaxResult.success(iSysRecipesTemplateService.removeRecipesTemplate(id)); diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysOrderPause.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysOrderPause.java index 18462e2ec..ff5b2d792 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysOrderPause.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysOrderPause.java @@ -1,11 +1,12 @@ package com.stdiet.custom.domain; -import java.util.Date; 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.ToStringStyle; -import com.stdiet.common.annotation.Excel; -import com.stdiet.common.core.domain.BaseEntity; + +import java.util.Date; /** * 订单服务暂停对象 sys_order_pause @@ -13,115 +14,59 @@ import com.stdiet.common.core.domain.BaseEntity; * @author xzj * @date 2021-01-07 */ -public class SysOrderPause extends BaseEntity -{ - private static final long serialVersionUID = 1L; +@Data +public class SysOrderPause { - /** $column.columnComment */ + /** + * $column.columnComment + */ private Long id; - /** 订单id */ + /** + * 订单id + */ private Long orderId; - /** 服务暂停开始时间 */ + private Long cusId; + + /** + * 服务暂停开始时间 + */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "服务暂停开始时间", width = 30, dateFormat = "yyyy-MM-dd") private Date pauseStartDate; - /** 服务暂停结束时间 */ + /** + * 服务暂停结束时间 + */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "服务暂停结束时间", width = 30, dateFormat = "yyyy-MM-dd") private Date pauseEndDate; - /** 服务暂停理由 */ + /** + * 服务暂停理由 + */ @Excel(name = "服务暂停理由") private String reason; - /** 备注 */ + /** + * 备注 + */ @Excel(name = "备注") private String remarks; - /** 删除标识 0未删除 1已删除,默认0 */ + /** + * 删除标识 0未删除 1已删除,默认0 + */ private Integer delFlag; - public void setId(Long id) - { - this.id = id; - } + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; - public Long getId() - { - return id; - } - public void setOrderId(Long orderId) - { - this.orderId = orderId; - } + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; - public Long getOrderId() - { - return orderId; - } - public void setPauseStartDate(Date pauseStartDate) - { - this.pauseStartDate = pauseStartDate; - } + private String createBy; - public Date getPauseStartDate() - { - 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(); - } + private String updateBy; } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysOrderPauseMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysOrderPauseMapper.java index f12b8a48d..8d94a6a27 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysOrderPauseMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysOrderPauseMapper.java @@ -74,6 +74,8 @@ public interface SysOrderPauseMapper */ int deletePauseByOrderId(Long[] orderIds); + long selectNearMainOrderIdByCusId(Long cusId); + /** * 根据订单ID获取暂停计划 * @param orderId diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysOrderPauseService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysOrderPauseService.java index 142f990ae..8ad61a600 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysOrderPauseService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysOrderPauseService.java @@ -79,4 +79,6 @@ public interface ISysOrderPauseService * @return */ List getPauseListByOrderId(Long orderId); + + long selectNearMainOrderIdByCusId(Long cusId); } \ 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 1d6c24ed5..3f957b8fb 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 @@ -149,4 +149,9 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService public List getPauseListByOrderId(Long orderId){ return sysOrderPauseMapper.getPauseListByOrderId(orderId); } + + @Override + public long selectNearMainOrderIdByCusId(Long cusId) { + return sysOrderPauseMapper.selectNearMainOrderIdByCusId(cusId); + } } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesTemplateServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesTemplateServiceImpl.java index ad260731a..b8f9f9e84 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesTemplateServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesTemplateServiceImpl.java @@ -41,6 +41,7 @@ public class SysRecipesTemplateServiceImpl implements ISysRecipesTemplateService sysRecipesPlan.setStartNumDay(1); sysRecipesPlan.setEndNumDay(7); sysRecipesPlan.setType(1); + sysRecipesPlan.setCusId(0L); sysRecipesPlanMapper.insertSysRecipesPlan(sysRecipesPlan); if (!StringUtils.isNull(sysRecipesPlan.getId())) { sysRecipesTemplate.setCreateBy(SecurityUtils.getUsername()); @@ -60,7 +61,15 @@ public class SysRecipesTemplateServiceImpl implements ISysRecipesTemplateService @Override public int removeRecipesTemplate(Long id) { - return sysRecipesTemplateMapper.removeRecipesTemplate(id); + SysRecipesTemplate sysRecipesTemplate= sysRecipesTemplateMapper.getRecipesTemplateById(id); + if(StringUtils.isNull(sysRecipesTemplate)) { + return 0; + } + int rows = sysRecipesTemplateMapper.removeRecipesTemplate(sysRecipesTemplate.getId()); + if(rows > 0) { + return sysRecipesPlanMapper.deleteSysRecipesPlanById(sysRecipesTemplate.getPlanId()); + } + return 0; } @Override diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml index a79ab03a5..ad88bdcc1 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml @@ -44,6 +44,7 @@ and review_status = #{reviewStatus} and is_main = #{isMain} + order by id desc diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml index 8cc719ed4..d3c6b0968 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml @@ -5,39 +5,41 @@ - - - - - - - - - - - + + + + + + + + + + + + - 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 - 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 - insert into sys_order_pause + insert into sys_recipes_pause order_id, + cus_id, pause_start_date, pause_end_date, reason, @@ -61,6 +64,7 @@ #{orderId}, + #{cusId}, #{pauseStartDate}, #{pauseEndDate}, #{reason}, @@ -74,9 +78,10 @@ - update sys_order_pause + update sys_recipes_pause order_id = #{orderId}, + cus_id = #{cusId}, pause_start_date = #{pauseStartDate}, pause_end_date = #{pauseEndDate}, reason = #{reason}, @@ -91,11 +96,11 @@ - update sys_order_pause set del_flag = 1 where id = #{id} + update sys_recipes_pause set del_flag = 1 where id = #{id} - update sys_order_pause set del_flag = 1 where id in + update sys_recipes_pause set del_flag = 1 where id in #{id} @@ -103,7 +108,7 @@ + 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 id, out_id, start_date, end_date, start_num_day, end_num_day, recipes_id, review_status from sys_recipes_plan - where cus_id=#{cusId} and del_flag = 0 order by id desc + where cus_id=#{cusId} and del_flag = 0 order by id asc