From 5588aa2e4c1648c0f4c2f2e2133846e9b842acc5 Mon Sep 17 00:00:00 2001 From: xiezhijun <15270898033@163.com> Date: Mon, 18 Jan 2021 19:12:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=9F=E8=B0=B1=E8=AE=A1=E5=88=92=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E3=80=81=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/SysCustomerController.java | 26 +- .../controller/custom/SysOrderController.java | 39 ++ .../custom/SysRecipesPlanController.java | 34 +- .../stdiet/custom/domain/SysRecipesPlan.java | 99 ++- .../custom/mapper/SysCustomerMapper.java | 7 + .../custom/mapper/SysOrderPauseMapper.java | 7 + .../custom/mapper/SysRecipesPlanMapper.java | 11 +- .../custom/service/ISysCustomerService.java | 7 + .../custom/service/ISysOrderPauseService.java | 7 + .../custom/service/ISysOrderService.java | 7 +- .../service/ISysRecipesPlanService.java | 19 +- .../service/impl/SysCustomerServiceImpl.java | 10 + .../impl/SysOrderPauseServiceImpl.java | 23 +- .../service/impl/SysOrderServiceImpl.java | 96 ++- .../impl/SysRecipesPlanServiceImpl.java | 87 ++- .../mapper/custom/SysCustomerMapper.xml | 5 + .../mapper/custom/SysOrderPauseMapper.xml | 8 + .../mapper/custom/SysRecipesPlanMapper.xml | 39 +- stdiet-ui/src/api/custom/customer.js | 10 + stdiet-ui/src/api/custom/order.js | 9 + stdiet-ui/src/api/custom/recipesPlan.js | 36 + .../src/views/custom/recipesPlan/index.vue | 616 ++++++++++++++++++ 22 files changed, 1122 insertions(+), 80 deletions(-) create mode 100644 stdiet-ui/src/api/custom/recipesPlan.js create mode 100644 stdiet-ui/src/views/custom/recipesPlan/index.vue diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerController.java index 1381c6f1f..58846352d 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerController.java @@ -7,18 +7,13 @@ import com.stdiet.common.utils.StringUtils; import com.stdiet.custom.domain.SysPhysicalSigns; import com.stdiet.common.utils.bean.ObjectUtils; +import com.stdiet.custom.domain.SysRecipesPlan; import com.stdiet.custom.dto.request.CustomerInvestigateRequest; import com.stdiet.custom.dto.response.CustomerListResponse; +import org.omg.PortableInterceptor.SYSTEM_EXCEPTION; 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 org.springframework.web.bind.annotation.*; import com.stdiet.common.annotation.Log; import com.stdiet.common.core.controller.BaseController; import com.stdiet.common.core.domain.AjaxResult; @@ -146,4 +141,19 @@ public class SysCustomerController extends BaseController { return toAjax(sysCustomerService.delCustomerAndSignById(ids)); } + + + /** + * 根据手机号查看用户体征 + */ + @GetMapping("/getCustomerAndSignByPhone") + @PreAuthorize("@ss.hasPermi('custom:customer:query')") + public AjaxResult getCustomerAndSignByPhone(@RequestParam("phone")String phone) + { + SysCustomer sysCustomer = null; + if(StringUtils.isNotEmpty(phone)){ + sysCustomer = sysCustomerService.selectSysCustomerAndSignByPhone(phone); + } + return AjaxResult.success(sysCustomer); + } } \ No newline at end of file diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysOrderController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysOrderController.java index abdc1c6b1..bdc6f8902 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysOrderController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysOrderController.java @@ -137,6 +137,45 @@ public class SysOrderController extends OrderBaseController { return AjaxResult.success(sysOrderService.selectSysOrderById(orderId)); } + /** + * 获取销售订单详细信息(列出所有营养师、助理等名称) + */ + @PreAuthorize("@ss.hasPermi('custom:order:query')") + @GetMapping(value = "/getInfoDetail") + public AjaxResult getInfoDetail(@RequestParam("orderId") Long orderId) { + SysOrder order = sysOrderService.selectSysOrderById(orderId); + if(order != null){ + List userList = userService.selectAllUser(); + for(SysUser user : userList){ + if (user.getUserId().equals(order.getPreSaleId())) { + order.setPreSale(user.getNickName()); + } + if (user.getUserId().equals(order.getAfterSaleId())) { + order.setAfterSale(user.getNickName()); + } + if (user.getUserId().equals(order.getNutritionistId())) { + order.setNutritionist(user.getNickName()); + } + if (user.getUserId().equals(order.getNutriAssisId())) { + order.setNutriAssis(user.getNickName()); + } + if (user.getUserId().equals(order.getOperatorId())) { + order.setOperator(user.getNickName()); + } + if (user.getUserId().equals(order.getPlannerId())) { + order.setPlanner(user.getNickName()); + } + if (user.getUserId().equals(order.getPlannerAssisId())) { + order.setPlannerAssis(user.getNickName()); + } + if (user.getUserId().equals(order.getOperatorAssisId())) { + order.setOperatorAssis(user.getNickName()); + } + } + } + return AjaxResult.success(order); + } + /** * 新增销售订单 */ 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 d91d238c5..e021a93cd 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 @@ -3,14 +3,7 @@ package com.stdiet.web.controller.custom; 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 org.springframework.web.bind.annotation.*; import com.stdiet.common.annotation.Log; import com.stdiet.common.core.controller.BaseController; import com.stdiet.common.core.domain.AjaxResult; @@ -41,10 +34,31 @@ public class SysRecipesPlanController extends BaseController public TableDataInfo list(SysRecipesPlan sysRecipesPlan) { startPage(); - List list = sysRecipesPlanService.selectSysRecipesPlanList(sysRecipesPlan); + List list = sysRecipesPlanService.selectPlanListByCondition(sysRecipesPlan); return getDataTable(list); } + /** + * 获取食谱计划详细信息 + */ + @PreAuthorize("@ss.hasPermi('recipes:recipesPlan:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(sysRecipesPlanService.selectSysRecipesPlanById(id)); + } + + /** + * 修改食谱计划 + */ + @PreAuthorize("@ss.hasPermi('recipes:recipesPlan:edit')") + @Log(title = "食谱计划", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysRecipesPlan sysRecipesPlan) + { + return toAjax(sysRecipesPlanService.updateSysRecipesPlan(sysRecipesPlan)); + } + /** * 导出食谱计划列表 */ @@ -53,7 +67,7 @@ public class SysRecipesPlanController extends BaseController @GetMapping("/export") public AjaxResult export(SysRecipesPlan sysRecipesPlan) { - List list = sysRecipesPlanService.selectSysRecipesPlanList(sysRecipesPlan); + List list = sysRecipesPlanService.selectPlanListByCondition(sysRecipesPlan); ExcelUtil util = new ExcelUtil(SysRecipesPlan.class); return util.exportExcel(list, "recipesPlan"); } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlan.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlan.java index 668fe0541..b2cf33063 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlan.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlan.java @@ -21,9 +21,16 @@ public class SysRecipesPlan extends BaseEntity private Long id; /** 订单ID */ - @Excel(name = "订单ID") + //@Excel(name = "订单ID") private Long orderId; + //非持久化字段,客户姓名 + @Excel(name = "客户姓名") + private String customer; + + //非持久化字段,客户手机号 + private String phone; + /** 食谱开始日期 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "食谱开始日期", width = 30, dateFormat = "yyyy-MM-dd") @@ -34,12 +41,34 @@ public class SysRecipesPlan extends BaseEntity @Excel(name = "食谱结束日期", width = 30, dateFormat = "yyyy-MM-dd") private Date endDate; + //非持久化字段,服务开始时间 + //@Excel(name = "服务开始时间", dateFormat = "yyyy-MM-dd") + private Date orderStartDate; + + //非持久化字段,服务结束时间 + //@Excel(name = "服务结束时间", dateFormat = "yyyy-MM-dd") + private Date orderEndDate; + + //非持久化字段,营养师ID + private Long nutritionistId; + + //非持久化字段,营养师姓名 + @Excel(name = "营养师") + private String nutritionist; + + //非持久化字段,营养师助理ID + private Long nutritionistAssisId; + + //非持久化字段,营养师助理姓名 + @Excel(name = "营养师助理") + private String nutritionistAssis; + /** 食谱ID */ - @Excel(name = "食谱ID") + //@Excel(name = "食谱ID") private Long recipesId; /** 食谱是否发送,0未发送 1已发送 */ - @Excel(name = "食谱是否发送,0未发送 1已发送") + @Excel(name = "食谱是否发送", readConverterExp="0=未发送,1=已发送") private Integer sendFlag; /** 食谱发送时间 */ @@ -123,6 +152,70 @@ public class SysRecipesPlan extends BaseEntity return delFlag; } + public String getCustomer() { + return customer; + } + + public void setCustomer(String customer) { + this.customer = customer; + } + + public Long getNutritionistId() { + return nutritionistId; + } + + public void setNutritionistId(Long nutritionistId) { + this.nutritionistId = nutritionistId; + } + + public String getNutritionist() { + return nutritionist; + } + + public void setNutritionist(String nutritionist) { + this.nutritionist = nutritionist; + } + + public Long getNutritionistAssisId() { + return nutritionistAssisId; + } + + public void setNutritionistAssisId(Long nutritionistAssisId) { + this.nutritionistAssisId = nutritionistAssisId; + } + + public String getNutritionistAssis() { + return nutritionistAssis; + } + + public void setNutritionistAssis(String nutritionistAssis) { + this.nutritionistAssis = nutritionistAssis; + } + + public Date getOrderStartDate() { + return orderStartDate; + } + + public void setOrderStartDate(Date orderStartDate) { + this.orderStartDate = orderStartDate; + } + + public Date getOrderEndDate() { + return orderEndDate; + } + + public void setOrderEndDate(Date orderEndDate) { + this.orderEndDate = orderEndDate; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCustomerMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCustomerMapper.java index c386f3ee5..c10c14829 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCustomerMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCustomerMapper.java @@ -70,4 +70,11 @@ public interface SysCustomerMapper //查询客户基础信息以及体征信息 List selectSysCustomerAndSignList(SysCustomer sysCustomer); + + /** + * 根据手机号查询客户以及体征 + * @param phone + * @return + */ + SysCustomer selectSysCustomerAndSignByPhone(String phone); } \ 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 8845ad381..6805e9e5f 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 @@ -66,4 +66,11 @@ public interface SysOrderPauseMapper * @return */ int getCountByOrderIdAndPauseDate(SysOrderPause sysOrderPause); + + /** + * 根据订单ID删除暂停记录 + * @param orderIds + * @return + */ + int deletePauseByOrderId(Long[] orderIds); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanMapper.java index 616aecf96..45dec7152 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanMapper.java @@ -68,8 +68,15 @@ public interface SysRecipesPlanMapper /** * 根据订单ID删除对应食谱计划 - * @param orderId + * @param orderIds * @return */ - int delRecipesPlanByOrderId(Long orderId); + int delRecipesPlanByOrderId(Long[] orderIds); + + /** + * 多条件查询食谱计划列表 + * @param sysRecipesPlan + * @return + */ + List selectPlanListByCondition(SysRecipesPlan sysRecipesPlan); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCustomerService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCustomerService.java index 5cbee5969..c35403c4a 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCustomerService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCustomerService.java @@ -93,4 +93,11 @@ public interface ISysCustomerService SysCustomer getCustomerAndSignById(Long id); int delCustomerAndSignById(Long[] ids); + + /** + * 根据手机号查询客户以及体征 + * @param phone + * @return + */ + SysCustomer selectSysCustomerAndSignByPhone(String phone); } \ No newline at end of file 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 c2bd331e2..0f98bdc97 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 @@ -65,4 +65,11 @@ public interface ISysOrderPauseService * @return */ int getCountByOrderIdAndPauseDate(SysOrderPause sysOrderPause); + + /** + * 根据订单ID删除暂停记录 + * @param orderIds + * @return + */ + int deletePauseByOrderId(Long[] orderIds); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysOrderService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysOrderService.java index a3d744dc5..e641dcb76 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysOrderService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysOrderService.java @@ -69,9 +69,10 @@ public interface ISysOrderService public BigDecimal selectAllOrderAmount(SysOrder sysOrder); /** - * 根据订单ID更新该订单的服务到期时间 - * @param orderId + * 根据订单ID更新该订单的服务到期时间,异步更新食谱计划 + * @param orderId 订单ID + * @param updatePlan 是否更新食谱 * @return */ - int updateOrderServerEndDate(Long orderId); + int updateOrderServerEndDate(Long orderId, boolean updatePlan); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanService.java index a349ca941..6d809a6a1 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanService.java @@ -61,10 +61,23 @@ public interface ISysRecipesPlanService public int deleteSysRecipesPlanById(Long id); /** - * 根据订单ID生成对应的食谱计划 - * + * 订单发生更新时(开始时间、服务时长、赠送时长),重新生成食谱计划 * @param orderId 订单ID * @return 结果 */ - public void autoGenerateRecipesPlanByOrderId(Long orderId); + public void regenerateRecipesPlan(Long orderId); + + /** + * 根据订单ID删除所有食谱安排计划 + * @param orderIds 订单ID + * @return + */ + int delRecipesPlanByOrderId(Long[] orderIds); + + /** + * 多条件查询食谱计划列表 + * @param sysRecipesPlan + * @return + */ + List selectPlanListByCondition(SysRecipesPlan sysRecipesPlan); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerServiceImpl.java index 466cd1caa..37e4f655f 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerServiceImpl.java @@ -178,4 +178,14 @@ public class SysCustomerServiceImpl implements ISysCustomerService } return 0; } + + /** + * 根据手机号查询客户以及体征 + * @param phone + * @return + */ + @Override + public SysCustomer selectSysCustomerAndSignByPhone(String phone){ + return sysCustomerMapper.selectSysCustomerAndSignByPhone(phone); + } } \ 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 8100534d8..70228dd13 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 @@ -7,6 +7,7 @@ import com.stdiet.common.utils.DateUtils; import com.stdiet.custom.domain.SysOrder; import com.stdiet.custom.service.ISysCommissionDayService; import com.stdiet.custom.service.ISysOrderService; +import com.stdiet.custom.service.ISysRecipesPlanService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.stdiet.custom.mapper.SysOrderPauseMapper; @@ -27,9 +28,6 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService @Autowired private SysOrderPauseMapper sysOrderPauseMapper; - @Autowired - private ISysCommissionDayService sysCommissionDayService; - @Autowired private ISysOrderService sysOrderService; @@ -69,7 +67,7 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService sysOrderPause.setCreateTime(DateUtils.getNowDate()); if(sysOrderPauseMapper.insertSysOrderPause(sysOrderPause) > 0){ //修改订单服务到期时间 - return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId()); + return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId(), true); } return 0; } @@ -85,7 +83,7 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService { sysOrderPause.setUpdateTime(DateUtils.getNowDate()); if(sysOrderPauseMapper.updateSysOrderPause(sysOrderPause) > 0){ - return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId()); + return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId(), true); } return 0; } @@ -101,7 +99,7 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService { SysOrderPause sysOrderPause = selectSysOrderPauseById(ids[0]); if(sysOrderPause != null && sysOrderPauseMapper.deleteSysOrderPauseByIds(ids) > 0){ - return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId()); + return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId(), true); } return 0; } @@ -117,7 +115,7 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService { SysOrderPause sysOrderPause = selectSysOrderPauseById(id); if(sysOrderPause != null && sysOrderPauseMapper.deleteSysOrderPauseById(id) > 0){ - return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId()); + return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId(), true); } return 0; } @@ -127,7 +125,18 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService * @param sysOrderPause * @return */ + @Override public int getCountByOrderIdAndPauseDate(SysOrderPause sysOrderPause){ return sysOrderPauseMapper.getCountByOrderIdAndPauseDate(sysOrderPause); } + + /** + * 根据订单ID删除暂停记录 + * @param orderIds + * @return + */ + @Override + public int deletePauseByOrderId(Long[] orderIds){ + return sysOrderPauseMapper.deletePauseByOrderId(orderIds); + } } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderServiceImpl.java index 3c29682a4..fd401cd6a 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderServiceImpl.java @@ -1,16 +1,14 @@ package com.stdiet.custom.service.impl; import java.math.BigDecimal; -import java.time.LocalDate; +import java.time.temporal.ChronoUnit; import java.util.Date; import java.util.List; -import java.util.Map; import com.stdiet.common.utils.DateUtils; -import com.stdiet.custom.domain.SysOrderCommisionDayDetail; -import com.stdiet.custom.domain.SysOrderPause; import com.stdiet.custom.service.ISysCommissionDayService; import com.stdiet.custom.service.ISysOrderPauseService; +import com.stdiet.custom.service.ISysRecipesPlanService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.stdiet.custom.mapper.SysOrderMapper; @@ -33,6 +31,12 @@ public class SysOrderServiceImpl implements ISysOrderService { @Autowired private ISysCommissionDayService sysCommissionDayService; + @Autowired + private ISysRecipesPlanService sysRecipesPlanService; + + @Autowired + private ISysOrderPauseService sysOrderPauseService; + /** * 查询销售订单 * @@ -65,11 +69,16 @@ public class SysOrderServiceImpl implements ISysOrderService { public int insertSysOrder(SysOrder sysOrder) { Date orderTime = DateUtils.getNowDate(); sysOrder.setCreateTime(orderTime); -// sysOrder.setOrderTime(orderTime); + //sysOrder.setOrderTime(orderTime); //计算服务到期时间 setOrderServerEndDate(sysOrder); sysOrder.setOrderId(Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, orderTime))); - return sysOrderMapper.insertSysOrder(sysOrder); + int row = sysOrderMapper.insertSysOrder(sysOrder); + if(row > 0){ + //异步生成食谱计划 + sysRecipesPlanService.regenerateRecipesPlan(sysOrder.getOrderId()); + } + return row; } /** @@ -80,10 +89,40 @@ public class SysOrderServiceImpl implements ISysOrderService { */ @Override public int updateSysOrder(SysOrder sysOrder) { - sysOrder.setUpdateTime(DateUtils.getNowDate()); + //获取旧订单对象 + SysOrder oldSysOrder = sysOrderMapper.selectSysOrderById(sysOrder.getOrderId()); //计算服务到期时间 setOrderServerEndDate(sysOrder); - return sysOrderMapper.updateSysOrder(sysOrder); + sysOrder.setUpdateTime(DateUtils.getNowDate()); + //更新订单 + int row = sysOrderMapper.updateSysOrder(sysOrder); + if(row > 0){ + //异步更新食谱计划 + if(isNeedRegenerateRecipesPlan(oldSysOrder, sysOrder)){ + sysRecipesPlanService.regenerateRecipesPlan(sysOrder.getOrderId()); + } + } + return row; + } + + /** + * 判断是否需要重新生成食谱计划 + * @param oldSysOrder + * @param newSysOrder + * @return + */ + private boolean isNeedRegenerateRecipesPlan(SysOrder oldSysOrder, SysOrder newSysOrder){ + if(oldSysOrder.getServeTimeId() != null && newSysOrder.getServeTimeId() != null && oldSysOrder.getServeTimeId().intValue() != newSysOrder.getServeTimeId().intValue()){ + return true; + } + if(newSysOrder.getGiveServeDay() != null && oldSysOrder.getGiveServeDay() != null && oldSysOrder.getGiveServeDay().intValue() != newSysOrder.getGiveServeDay().intValue()){ + return true; + } + if(oldSysOrder.getStartTime() != null && newSysOrder.getStartTime() != null + && ChronoUnit.DAYS.between(DateUtils.dateToLocalDate(oldSysOrder.getStartTime()), DateUtils.dateToLocalDate(newSysOrder.getStartTime())) != 0){ + return true; + } + return false; } /** @@ -94,7 +133,11 @@ public class SysOrderServiceImpl implements ISysOrderService { */ @Override public int deleteSysOrderByIds(Long[] orderIds) { - return sysOrderMapper.deleteSysOrderByIds(orderIds); + int row = sysOrderMapper.deleteSysOrderByIds(orderIds); + if(row > 0){ + deletePauseAndPlan(orderIds); + } + return row; } /** @@ -105,7 +148,13 @@ public class SysOrderServiceImpl implements ISysOrderService { */ @Override public int deleteSysOrderById(Long orderId) { - return sysOrderMapper.deleteSysOrderById(orderId); + int row = sysOrderMapper.deleteSysOrderById(orderId); + if(row > 0){ + Long[] orderIdArray = new Long[1]; + orderIdArray[0] = orderId; + deletePauseAndPlan(orderIdArray); + } + return row; } /** @@ -119,21 +168,27 @@ public class SysOrderServiceImpl implements ISysOrderService { } /** - * 根据订单ID更新该订单的服务到期时间 - * @param orderId + * 根据订单ID更新该订单的服务到期时间,异步更新食谱计划 + * @param orderId 订单ID + * @param updatePlan 是否更新食谱 * @return */ @Override - public int updateOrderServerEndDate(Long orderId){ + public int updateOrderServerEndDate(Long orderId, boolean updatePlan){ + int row = 0; //更新订单服务到期时间 SysOrder sysOrder = selectSysOrderById(orderId); if(sysOrder != null){ //设置服务到期时间 setOrderServerEndDate(sysOrder); sysOrder.setUpdateTime(new Date()); - return updateSysOrder(sysOrder); + row = updateSysOrder(sysOrder); + if(row > 0){ + //异步更新食谱计划 + sysRecipesPlanService.regenerateRecipesPlan(sysOrder.getOrderId()); + } } - return 0; + return row; } /** @@ -143,4 +198,15 @@ public class SysOrderServiceImpl implements ISysOrderService { private void setOrderServerEndDate(SysOrder sysOrder){ sysOrder.setServerEndTime(DateUtils.localDateToDate(sysCommissionDayService.getServerEndDate(sysOrder))); } + + /** + * 删除订单的同时删除暂停记录、食谱计划安排 + * @param orderIds 订单ID集合 + */ + private void deletePauseAndPlan(Long[] orderIds){ + //删除暂停记录 + sysOrderPauseService.deletePauseByOrderId(orderIds); + //删除食谱计划 + sysRecipesPlanService.delRecipesPlanByOrderId(orderIds); + } } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java index 8f2107850..eac4536eb 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java @@ -91,6 +91,8 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService public int updateSysRecipesPlan(SysRecipesPlan sysRecipesPlan) { sysRecipesPlan.setUpdateTime(DateUtils.getNowDate()); + //目前只能修改发送状态,所以修改时加上发送时间 + sysRecipesPlan.setSendTime(DateUtils.getNowDate()); return sysRecipesPlanMapper.updateSysRecipesPlan(sysRecipesPlan); } @@ -119,40 +121,50 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService } /** - * 根据订单ID生成对应的食谱计划 + * 异步方法,根据订单ID生成对应的食谱计划,退款订单不生成食谱计划 * * @param orderId 订单ID * @return 结果 */ @Override - @Async("generateRecipesPlan") - public void autoGenerateRecipesPlanByOrderId(Long orderId){ + @Async + public void regenerateRecipesPlan(Long orderId){ if(orderId == null || orderId <= 0){ return; } SysOrder sysOrder = sysOrderService.selectSysOrderById(orderId); + //订单为空、金额小于0不进行食谱生成、更新 if(sysOrder == null){ return; } try{ //获取redis中该订单对应的锁 if(synchrolockUtil.lock(String.format(generateRecipesPlanLockKey, orderId))){ - //删除该订单对于食谱 - sysRecipesPlanMapper.delRecipesPlanByOrderId(orderId); - //订单服务开始时间、结束时间不能为空 - if(sysOrder.getStartTime() != null && sysOrder.getServerEndTime() != null){ - SysOrderPause pauseParam = new SysOrderPause(); - pauseParam.setOrderId(sysOrder.getOrderId()); - //暂停记录列表 - List pauseList = sysOrderPauseService.selectSysOrderPauseList(pauseParam); - List planList = generatePlan(orderId, DateUtils.dateToLocalDate(sysOrder.getStartTime()), DateUtils.dateToLocalDate(sysOrder.getServerEndTime()), pauseList); - if(planList != null && planList.size() > 0){ - sysRecipesPlanMapper.insertBatch(planList); - } - for (SysRecipesPlan sysRecipesPlan : planList) { - getTestDate(sysRecipesPlan.getStartDate(), sysRecipesPlan.getEndDate()); - } + SysRecipesPlan queryParam = new SysRecipesPlan(); + queryParam.setOrderId(orderId); + List oldRecipesPlanList = sysRecipesPlanMapper.selectSysRecipesPlanList(queryParam); + //判断是否已存在食谱 + if(oldRecipesPlanList != null && oldRecipesPlanList.size() > 0){ + Long[] orderIdArray = new Long[1]; + orderIdArray[0] = orderId; + //删除该订单对于食谱 + delRecipesPlanByOrderId(orderIdArray); } + //判断订单金额、开始时间、结束时间,为空则直接返回,不重新生成食谱计划 + if(sysOrder.getAmount().floatValue() <= 0 || sysOrder.getStartTime() == null || sysOrder.getServerEndTime() == null){ + return; + } + SysOrderPause pauseParam = new SysOrderPause(); + pauseParam.setOrderId(sysOrder.getOrderId()); + //暂停记录列表 + List pauseList = sysOrderPauseService.selectSysOrderPauseList(pauseParam); + List planList = generatePlan(orderId, oldRecipesPlanList, DateUtils.dateToLocalDate(sysOrder.getStartTime()), DateUtils.dateToLocalDate(sysOrder.getServerEndTime()), pauseList); + if(planList != null && planList.size() > 0){ + sysRecipesPlanMapper.insertBatch(planList); + } + /*for (SysRecipesPlan sysRecipesPlan : planList) { + getTestDate(sysRecipesPlan.getStartDate(), sysRecipesPlan.getEndDate()); + }*/ } } catch (Exception e) { @@ -174,23 +186,21 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService /** * 根据订单ID、订单开始服务时间、结束时间、暂停列表生成食谱计划列表 * @param orderId 订单ID + * @param oldRecipesPlanList 旧的食谱计划 * @param serverStartDate 服务开始时间 * @param serverEndDate 服务结束时间 * @param pauseList 暂停列表 * @return */ - public List generatePlan(Long orderId, LocalDate serverStartDate, LocalDate serverEndDate, List pauseList){ + public List generatePlan(Long orderId, List oldRecipesPlanList, LocalDate serverStartDate, LocalDate serverEndDate, List pauseList){ List planList = new ArrayList<>(); boolean breakFlag = false; LocalDate planStartDate = serverStartDate; LocalDate planEndDate = planStartDate.plusDays(6); while (true){ - SysRecipesPlan sysRecipesPlan = new SysRecipesPlan(); //判断是否大于服务到期时间 - if(ChronoUnit.DAYS.between(planEndDate, serverEndDate) > 0){ - - }else{ + if(ChronoUnit.DAYS.between(planEndDate, serverEndDate) <= 0){ planEndDate = serverEndDate; breakFlag = true; } @@ -200,6 +210,17 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService sysRecipesPlan.setStartDate(DateUtils.localDateToDate(planStartDate)); sysRecipesPlan.setEndDate(DateUtils.localDateToDate(planEndDate)); sysRecipesPlan.setOrderId(orderId); + /*//当开始时间小于等于当前时间,默认为已发送,发送时间为前一天 + if(ChronoUnit.DAYS.between(planStartDate, LocalDate.now()) >= 0){ + sysRecipesPlan.setSendFlag(1); + sysRecipesPlan.setSendTime(DateUtils.localDateToDate(LocalDate.now().minusDays(1))); + }*/ + //将旧食谱计划中的发送状态、发送时间、食谱复制到新食谱计划中 + boolean existFlag =oldRecipesPlanList.size() >= planList.size()+1; + sysRecipesPlan.setSendFlag(existFlag ? oldRecipesPlanList.get(planList.size()).getSendFlag() : 0); + sysRecipesPlan.setSendTime(existFlag ? oldRecipesPlanList.get(planList.size()).getSendTime() : null); + sysRecipesPlan.setRecipesId(existFlag ? oldRecipesPlanList.get(planList.size()).getRecipesId() : null); + planList.add(sysRecipesPlan); planStartDate = planEndDate.plusDays(1); @@ -240,4 +261,24 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService } return pauseDay; } + + /** + * 根据订单ID删除所有食谱安排计划 + * @param orderIds 订单ID + * @return + */ + @Override + public int delRecipesPlanByOrderId(Long[] orderIds){ + return sysRecipesPlanMapper.delRecipesPlanByOrderId(orderIds); + } + + /** + * 多条件查询食谱计划列表 + * @param sysRecipesPlan + * @return + */ + @Override + public List selectPlanListByCondition(SysRecipesPlan sysRecipesPlan){ + return sysRecipesPlanMapper.selectPlanListByCondition(sysRecipesPlan); + } } \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml index 04ac3f68d..4a24643fd 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml @@ -213,4 +213,9 @@ select * from sys_physical_signs sps where FIND_IN_SET(id, #{physical_signs_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 0bd2ad5ad..6b175989b 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml @@ -112,4 +112,12 @@ order by id desc + + + update sys_order_pause set del_flag = 1 where order_id in + + #{orderId} + + + \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml index 62a3cbe8a..376f1bc76 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml @@ -17,6 +17,15 @@ + + + + + + + + + @@ -87,11 +96,11 @@ - update sys_recipes_plan set del_flag = 0 where id = #{id} + update sys_recipes_plan set del_flag = 1 where id = #{id} - update sys_recipes_plan set del_flag = 0 where id in + update sys_recipes_plan set del_flag = 1 where id in #{id} @@ -100,16 +109,34 @@ INSERT INTO sys_recipes_plan - (order_id, start_date, end_date) + (order_id, start_date, end_date, send_flag, send_time, recipes_id) VALUES - (#{plan.orderId}, #{plan.startDate}, #{plan.end_date}) + (#{plan.orderId}, #{plan.startDate}, #{plan.endDate}, #{plan.sendFlag}, #{plan.sendTime}, #{plan.recipesId}) - - update sys_recipes_plan set del_flag = 0 and order_id = #{orderId} + + update sys_recipes_plan set del_flag = 1 where order_id in + + #{orderId} + + + \ No newline at end of file diff --git a/stdiet-ui/src/api/custom/customer.js b/stdiet-ui/src/api/custom/customer.js index f01a7e50c..3c6741529 100644 --- a/stdiet-ui/src/api/custom/customer.js +++ b/stdiet-ui/src/api/custom/customer.js @@ -51,3 +51,13 @@ export function exportCustomer(query) { params: query }) } + +// 查询客户信息详细 +export function getCustomerAndSignByPhone(query) { + return request({ + url: '/custom/customer/getCustomerAndSignByPhone', + method: 'get', + params: query + }) +} + diff --git a/stdiet-ui/src/api/custom/order.js b/stdiet-ui/src/api/custom/order.js index b47b55d81..d3735c9f6 100644 --- a/stdiet-ui/src/api/custom/order.js +++ b/stdiet-ui/src/api/custom/order.js @@ -58,3 +58,12 @@ export function getOptions() { method: 'get' }) } + +// 查询销售订单详细 +export function getInfoDetail(query) { + return request({ + url: '/custom/order/getInfoDetail', + method: 'get', + params: query + }) +} diff --git a/stdiet-ui/src/api/custom/recipesPlan.js b/stdiet-ui/src/api/custom/recipesPlan.js new file mode 100644 index 000000000..5fe40ae7c --- /dev/null +++ b/stdiet-ui/src/api/custom/recipesPlan.js @@ -0,0 +1,36 @@ +import request from '@/utils/request' + +// 查询食谱计划列表 +export function listRecipesPlan(query) { + return request({ + url: '/recipes/recipesPlan/list', + method: 'get', + params: query + }) +} + +// 查询食谱计划详细 +export function getRecipesPlan(id) { + return request({ + url: '/recipes/recipesPlan/' + id, + method: 'get' + }) +} + +// 修改食谱计划 +export function updateRecipesPlan(data) { + return request({ + url: '/recipes/recipesPlan', + method: 'put', + data: data + }) +} + +// 导出食谱计划 +export function exportRecipesPlan(query) { + return request({ + url: '/recipes/recipesPlan/export', + method: 'get', + params: query + }) +} diff --git a/stdiet-ui/src/views/custom/recipesPlan/index.vue b/stdiet-ui/src/views/custom/recipesPlan/index.vue new file mode 100644 index 000000000..98f0233ad --- /dev/null +++ b/stdiet-ui/src/views/custom/recipesPlan/index.vue @@ -0,0 +1,616 @@ + + + + + +