食谱计划页面、逻辑优化

This commit is contained in:
xiezhijun 2021-01-18 19:12:55 +08:00
parent 072b0a1f36
commit 5588aa2e4c
22 changed files with 1122 additions and 80 deletions

View File

@ -7,18 +7,13 @@ import com.stdiet.common.utils.StringUtils;
import com.stdiet.custom.domain.SysPhysicalSigns; import com.stdiet.custom.domain.SysPhysicalSigns;
import com.stdiet.common.utils.bean.ObjectUtils; 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.request.CustomerInvestigateRequest;
import com.stdiet.custom.dto.response.CustomerListResponse; import com.stdiet.custom.dto.response.CustomerListResponse;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
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.annotation.Log;
import com.stdiet.common.core.controller.BaseController; import com.stdiet.common.core.controller.BaseController;
import com.stdiet.common.core.domain.AjaxResult; import com.stdiet.common.core.domain.AjaxResult;
@ -146,4 +141,19 @@ public class SysCustomerController extends BaseController
{ {
return toAjax(sysCustomerService.delCustomerAndSignById(ids)); 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);
}
} }

View File

@ -137,6 +137,45 @@ public class SysOrderController extends OrderBaseController {
return AjaxResult.success(sysOrderService.selectSysOrderById(orderId)); 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<SysUser> 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);
}
/** /**
* 新增销售订单 * 新增销售订单
*/ */

View File

@ -3,14 +3,7 @@ package com.stdiet.web.controller.custom;
import java.util.List; import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
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.annotation.Log;
import com.stdiet.common.core.controller.BaseController; import com.stdiet.common.core.controller.BaseController;
import com.stdiet.common.core.domain.AjaxResult; import com.stdiet.common.core.domain.AjaxResult;
@ -41,10 +34,31 @@ public class SysRecipesPlanController extends BaseController
public TableDataInfo list(SysRecipesPlan sysRecipesPlan) public TableDataInfo list(SysRecipesPlan sysRecipesPlan)
{ {
startPage(); startPage();
List<SysRecipesPlan> list = sysRecipesPlanService.selectSysRecipesPlanList(sysRecipesPlan); List<SysRecipesPlan> list = sysRecipesPlanService.selectPlanListByCondition(sysRecipesPlan);
return getDataTable(list); 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") @GetMapping("/export")
public AjaxResult export(SysRecipesPlan sysRecipesPlan) public AjaxResult export(SysRecipesPlan sysRecipesPlan)
{ {
List<SysRecipesPlan> list = sysRecipesPlanService.selectSysRecipesPlanList(sysRecipesPlan); List<SysRecipesPlan> list = sysRecipesPlanService.selectPlanListByCondition(sysRecipesPlan);
ExcelUtil<SysRecipesPlan> util = new ExcelUtil<SysRecipesPlan>(SysRecipesPlan.class); ExcelUtil<SysRecipesPlan> util = new ExcelUtil<SysRecipesPlan>(SysRecipesPlan.class);
return util.exportExcel(list, "recipesPlan"); return util.exportExcel(list, "recipesPlan");
} }

View File

@ -21,9 +21,16 @@ public class SysRecipesPlan extends BaseEntity
private Long id; private Long id;
/** 订单ID */ /** 订单ID */
@Excel(name = "订单ID") //@Excel(name = "订单ID")
private Long orderId; private Long orderId;
//非持久化字段客户姓名
@Excel(name = "客户姓名")
private String customer;
//非持久化字段客户手机号
private String phone;
/** 食谱开始日期 */ /** 食谱开始日期 */
@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")
@ -34,12 +41,34 @@ public class SysRecipesPlan extends BaseEntity
@Excel(name = "食谱结束日期", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "食谱结束日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date endDate; 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 */ /** 食谱ID */
@Excel(name = "食谱ID") //@Excel(name = "食谱ID")
private Long recipesId; private Long recipesId;
/** 食谱是否发送0未发送 1已发送 */ /** 食谱是否发送0未发送 1已发送 */
@Excel(name = "食谱是否发送0未发送 1已发送") @Excel(name = "食谱是否发送", readConverterExp="0=未发送,1=已发送")
private Integer sendFlag; private Integer sendFlag;
/** 食谱发送时间 */ /** 食谱发送时间 */
@ -123,6 +152,70 @@ public class SysRecipesPlan extends BaseEntity
return delFlag; 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 @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -70,4 +70,11 @@ public interface SysCustomerMapper
//查询客户基础信息以及体征信息 //查询客户基础信息以及体征信息
List<SysCustomer> selectSysCustomerAndSignList(SysCustomer sysCustomer); List<SysCustomer> selectSysCustomerAndSignList(SysCustomer sysCustomer);
/**
* 根据手机号查询客户以及体征
* @param phone
* @return
*/
SysCustomer selectSysCustomerAndSignByPhone(String phone);
} }

View File

@ -66,4 +66,11 @@ public interface SysOrderPauseMapper
* @return * @return
*/ */
int getCountByOrderIdAndPauseDate(SysOrderPause sysOrderPause); int getCountByOrderIdAndPauseDate(SysOrderPause sysOrderPause);
/**
* 根据订单ID删除暂停记录
* @param orderIds
* @return
*/
int deletePauseByOrderId(Long[] orderIds);
} }

View File

@ -68,8 +68,15 @@ public interface SysRecipesPlanMapper
/** /**
* 根据订单ID删除对应食谱计划 * 根据订单ID删除对应食谱计划
* @param orderId * @param orderIds
* @return * @return
*/ */
int delRecipesPlanByOrderId(Long orderId); int delRecipesPlanByOrderId(Long[] orderIds);
/**
* 多条件查询食谱计划列表
* @param sysRecipesPlan
* @return
*/
List<SysRecipesPlan> selectPlanListByCondition(SysRecipesPlan sysRecipesPlan);
} }

View File

@ -93,4 +93,11 @@ public interface ISysCustomerService
SysCustomer getCustomerAndSignById(Long id); SysCustomer getCustomerAndSignById(Long id);
int delCustomerAndSignById(Long[] ids); int delCustomerAndSignById(Long[] ids);
/**
* 根据手机号查询客户以及体征
* @param phone
* @return
*/
SysCustomer selectSysCustomerAndSignByPhone(String phone);
} }

View File

@ -65,4 +65,11 @@ public interface ISysOrderPauseService
* @return * @return
*/ */
int getCountByOrderIdAndPauseDate(SysOrderPause sysOrderPause); int getCountByOrderIdAndPauseDate(SysOrderPause sysOrderPause);
/**
* 根据订单ID删除暂停记录
* @param orderIds
* @return
*/
int deletePauseByOrderId(Long[] orderIds);
} }

View File

@ -69,9 +69,10 @@ public interface ISysOrderService
public BigDecimal selectAllOrderAmount(SysOrder sysOrder); public BigDecimal selectAllOrderAmount(SysOrder sysOrder);
/** /**
* 根据订单ID更新该订单的服务到期时间 * 根据订单ID更新该订单的服务到期时间异步更新食谱计划
* @param orderId * @param orderId 订单ID
* @param updatePlan 是否更新食谱
* @return * @return
*/ */
int updateOrderServerEndDate(Long orderId); int updateOrderServerEndDate(Long orderId, boolean updatePlan);
} }

View File

@ -61,10 +61,23 @@ public interface ISysRecipesPlanService
public int deleteSysRecipesPlanById(Long id); public int deleteSysRecipesPlanById(Long id);
/** /**
* 根据订单ID生成对应的食谱计划 * 订单发生更新时(开始时间服务时长赠送时长)重新生成食谱计划
*
* @param orderId 订单ID * @param orderId 订单ID
* @return 结果 * @return 结果
*/ */
public void autoGenerateRecipesPlanByOrderId(Long orderId); public void regenerateRecipesPlan(Long orderId);
/**
* 根据订单ID删除所有食谱安排计划
* @param orderIds 订单ID
* @return
*/
int delRecipesPlanByOrderId(Long[] orderIds);
/**
* 多条件查询食谱计划列表
* @param sysRecipesPlan
* @return
*/
List<SysRecipesPlan> selectPlanListByCondition(SysRecipesPlan sysRecipesPlan);
} }

View File

@ -178,4 +178,14 @@ public class SysCustomerServiceImpl implements ISysCustomerService
} }
return 0; return 0;
} }
/**
* 根据手机号查询客户以及体征
* @param phone
* @return
*/
@Override
public SysCustomer selectSysCustomerAndSignByPhone(String phone){
return sysCustomerMapper.selectSysCustomerAndSignByPhone(phone);
}
} }

View File

@ -7,6 +7,7 @@ import com.stdiet.common.utils.DateUtils;
import com.stdiet.custom.domain.SysOrder; import com.stdiet.custom.domain.SysOrder;
import com.stdiet.custom.service.ISysCommissionDayService; import com.stdiet.custom.service.ISysCommissionDayService;
import com.stdiet.custom.service.ISysOrderService; import com.stdiet.custom.service.ISysOrderService;
import com.stdiet.custom.service.ISysRecipesPlanService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysOrderPauseMapper; import com.stdiet.custom.mapper.SysOrderPauseMapper;
@ -27,9 +28,6 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService
@Autowired @Autowired
private SysOrderPauseMapper sysOrderPauseMapper; private SysOrderPauseMapper sysOrderPauseMapper;
@Autowired
private ISysCommissionDayService sysCommissionDayService;
@Autowired @Autowired
private ISysOrderService sysOrderService; private ISysOrderService sysOrderService;
@ -69,7 +67,7 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService
sysOrderPause.setCreateTime(DateUtils.getNowDate()); sysOrderPause.setCreateTime(DateUtils.getNowDate());
if(sysOrderPauseMapper.insertSysOrderPause(sysOrderPause) > 0){ if(sysOrderPauseMapper.insertSysOrderPause(sysOrderPause) > 0){
//修改订单服务到期时间 //修改订单服务到期时间
return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId()); return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId(), true);
} }
return 0; return 0;
} }
@ -85,7 +83,7 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService
{ {
sysOrderPause.setUpdateTime(DateUtils.getNowDate()); sysOrderPause.setUpdateTime(DateUtils.getNowDate());
if(sysOrderPauseMapper.updateSysOrderPause(sysOrderPause) > 0){ if(sysOrderPauseMapper.updateSysOrderPause(sysOrderPause) > 0){
return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId()); return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId(), true);
} }
return 0; return 0;
} }
@ -101,7 +99,7 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService
{ {
SysOrderPause sysOrderPause = selectSysOrderPauseById(ids[0]); SysOrderPause sysOrderPause = selectSysOrderPauseById(ids[0]);
if(sysOrderPause != null && sysOrderPauseMapper.deleteSysOrderPauseByIds(ids) > 0){ if(sysOrderPause != null && sysOrderPauseMapper.deleteSysOrderPauseByIds(ids) > 0){
return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId()); return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId(), true);
} }
return 0; return 0;
} }
@ -117,7 +115,7 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService
{ {
SysOrderPause sysOrderPause = selectSysOrderPauseById(id); SysOrderPause sysOrderPause = selectSysOrderPauseById(id);
if(sysOrderPause != null && sysOrderPauseMapper.deleteSysOrderPauseById(id) > 0){ if(sysOrderPause != null && sysOrderPauseMapper.deleteSysOrderPauseById(id) > 0){
return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId()); return sysOrderService.updateOrderServerEndDate(sysOrderPause.getOrderId(), true);
} }
return 0; return 0;
} }
@ -127,7 +125,18 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService
* @param sysOrderPause * @param sysOrderPause
* @return * @return
*/ */
@Override
public int getCountByOrderIdAndPauseDate(SysOrderPause sysOrderPause){ public int getCountByOrderIdAndPauseDate(SysOrderPause sysOrderPause){
return sysOrderPauseMapper.getCountByOrderIdAndPauseDate(sysOrderPause); return sysOrderPauseMapper.getCountByOrderIdAndPauseDate(sysOrderPause);
} }
/**
* 根据订单ID删除暂停记录
* @param orderIds
* @return
*/
@Override
public int deletePauseByOrderId(Long[] orderIds){
return sysOrderPauseMapper.deletePauseByOrderId(orderIds);
}
} }

View File

@ -1,16 +1,14 @@
package com.stdiet.custom.service.impl; package com.stdiet.custom.service.impl;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.temporal.ChronoUnit;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import com.stdiet.common.utils.DateUtils; 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.ISysCommissionDayService;
import com.stdiet.custom.service.ISysOrderPauseService; import com.stdiet.custom.service.ISysOrderPauseService;
import com.stdiet.custom.service.ISysRecipesPlanService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysOrderMapper; import com.stdiet.custom.mapper.SysOrderMapper;
@ -33,6 +31,12 @@ public class SysOrderServiceImpl implements ISysOrderService {
@Autowired @Autowired
private ISysCommissionDayService sysCommissionDayService; 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) { public int insertSysOrder(SysOrder sysOrder) {
Date orderTime = DateUtils.getNowDate(); Date orderTime = DateUtils.getNowDate();
sysOrder.setCreateTime(orderTime); sysOrder.setCreateTime(orderTime);
// sysOrder.setOrderTime(orderTime); //sysOrder.setOrderTime(orderTime);
//计算服务到期时间 //计算服务到期时间
setOrderServerEndDate(sysOrder); setOrderServerEndDate(sysOrder);
sysOrder.setOrderId(Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, orderTime))); 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 @Override
public int updateSysOrder(SysOrder sysOrder) { public int updateSysOrder(SysOrder sysOrder) {
sysOrder.setUpdateTime(DateUtils.getNowDate()); //获取旧订单对象
SysOrder oldSysOrder = sysOrderMapper.selectSysOrderById(sysOrder.getOrderId());
//计算服务到期时间 //计算服务到期时间
setOrderServerEndDate(sysOrder); 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 @Override
public int deleteSysOrderByIds(Long[] orderIds) { 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 @Override
public int deleteSysOrderById(Long orderId) { 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更新该订单的服务到期时间 * 根据订单ID更新该订单的服务到期时间异步更新食谱计划
* @param orderId * @param orderId 订单ID
* @param updatePlan 是否更新食谱
* @return * @return
*/ */
@Override @Override
public int updateOrderServerEndDate(Long orderId){ public int updateOrderServerEndDate(Long orderId, boolean updatePlan){
int row = 0;
//更新订单服务到期时间 //更新订单服务到期时间
SysOrder sysOrder = selectSysOrderById(orderId); SysOrder sysOrder = selectSysOrderById(orderId);
if(sysOrder != null){ if(sysOrder != null){
//设置服务到期时间 //设置服务到期时间
setOrderServerEndDate(sysOrder); setOrderServerEndDate(sysOrder);
sysOrder.setUpdateTime(new Date()); 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){ private void setOrderServerEndDate(SysOrder sysOrder){
sysOrder.setServerEndTime(DateUtils.localDateToDate(sysCommissionDayService.getServerEndDate(sysOrder))); sysOrder.setServerEndTime(DateUtils.localDateToDate(sysCommissionDayService.getServerEndDate(sysOrder)));
} }
/**
* 删除订单的同时删除暂停记录食谱计划安排
* @param orderIds 订单ID集合
*/
private void deletePauseAndPlan(Long[] orderIds){
//删除暂停记录
sysOrderPauseService.deletePauseByOrderId(orderIds);
//删除食谱计划
sysRecipesPlanService.delRecipesPlanByOrderId(orderIds);
}
} }

View File

@ -91,6 +91,8 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
public int updateSysRecipesPlan(SysRecipesPlan sysRecipesPlan) public int updateSysRecipesPlan(SysRecipesPlan sysRecipesPlan)
{ {
sysRecipesPlan.setUpdateTime(DateUtils.getNowDate()); sysRecipesPlan.setUpdateTime(DateUtils.getNowDate());
//目前只能修改发送状态所以修改时加上发送时间
sysRecipesPlan.setSendTime(DateUtils.getNowDate());
return sysRecipesPlanMapper.updateSysRecipesPlan(sysRecipesPlan); return sysRecipesPlanMapper.updateSysRecipesPlan(sysRecipesPlan);
} }
@ -119,40 +121,50 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
} }
/** /**
* 根据订单ID生成对应的食谱计划 * 异步方法根据订单ID生成对应的食谱计划退款订单不生成食谱计划
* *
* @param orderId 订单ID * @param orderId 订单ID
* @return 结果 * @return 结果
*/ */
@Override @Override
@Async("generateRecipesPlan") @Async
public void autoGenerateRecipesPlanByOrderId(Long orderId){ public void regenerateRecipesPlan(Long orderId){
if(orderId == null || orderId <= 0){ if(orderId == null || orderId <= 0){
return; return;
} }
SysOrder sysOrder = sysOrderService.selectSysOrderById(orderId); SysOrder sysOrder = sysOrderService.selectSysOrderById(orderId);
//订单为空金额小于0不进行食谱生成更新
if(sysOrder == null){ if(sysOrder == null){
return; return;
} }
try{ try{
//获取redis中该订单对应的锁 //获取redis中该订单对应的锁
if(synchrolockUtil.lock(String.format(generateRecipesPlanLockKey, orderId))){ if(synchrolockUtil.lock(String.format(generateRecipesPlanLockKey, orderId))){
SysRecipesPlan queryParam = new SysRecipesPlan();
queryParam.setOrderId(orderId);
List<SysRecipesPlan> oldRecipesPlanList = sysRecipesPlanMapper.selectSysRecipesPlanList(queryParam);
//判断是否已存在食谱
if(oldRecipesPlanList != null && oldRecipesPlanList.size() > 0){
Long[] orderIdArray = new Long[1];
orderIdArray[0] = orderId;
//删除该订单对于食谱 //删除该订单对于食谱
sysRecipesPlanMapper.delRecipesPlanByOrderId(orderId); delRecipesPlanByOrderId(orderIdArray);
//订单服务开始时间结束时间不能为空 }
if(sysOrder.getStartTime() != null && sysOrder.getServerEndTime() != null){ //判断订单金额开始时间结束时间为空则直接返回不重新生成食谱计划
if(sysOrder.getAmount().floatValue() <= 0 || sysOrder.getStartTime() == null || sysOrder.getServerEndTime() == null){
return;
}
SysOrderPause pauseParam = new SysOrderPause(); SysOrderPause pauseParam = new SysOrderPause();
pauseParam.setOrderId(sysOrder.getOrderId()); pauseParam.setOrderId(sysOrder.getOrderId());
//暂停记录列表 //暂停记录列表
List<SysOrderPause> pauseList = sysOrderPauseService.selectSysOrderPauseList(pauseParam); List<SysOrderPause> pauseList = sysOrderPauseService.selectSysOrderPauseList(pauseParam);
List<SysRecipesPlan> planList = generatePlan(orderId, DateUtils.dateToLocalDate(sysOrder.getStartTime()), DateUtils.dateToLocalDate(sysOrder.getServerEndTime()), pauseList); List<SysRecipesPlan> planList = generatePlan(orderId, oldRecipesPlanList, DateUtils.dateToLocalDate(sysOrder.getStartTime()), DateUtils.dateToLocalDate(sysOrder.getServerEndTime()), pauseList);
if(planList != null && planList.size() > 0){ if(planList != null && planList.size() > 0){
sysRecipesPlanMapper.insertBatch(planList); sysRecipesPlanMapper.insertBatch(planList);
} }
for (SysRecipesPlan sysRecipesPlan : planList) { /*for (SysRecipesPlan sysRecipesPlan : planList) {
getTestDate(sysRecipesPlan.getStartDate(), sysRecipesPlan.getEndDate()); getTestDate(sysRecipesPlan.getStartDate(), sysRecipesPlan.getEndDate());
} }*/
}
} }
} }
catch (Exception e) { catch (Exception e) {
@ -174,23 +186,21 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
/** /**
* 根据订单ID订单开始服务时间结束时间暂停列表生成食谱计划列表 * 根据订单ID订单开始服务时间结束时间暂停列表生成食谱计划列表
* @param orderId 订单ID * @param orderId 订单ID
* @param oldRecipesPlanList 旧的食谱计划
* @param serverStartDate 服务开始时间 * @param serverStartDate 服务开始时间
* @param serverEndDate 服务结束时间 * @param serverEndDate 服务结束时间
* @param pauseList 暂停列表 * @param pauseList 暂停列表
* @return * @return
*/ */
public List<SysRecipesPlan> generatePlan(Long orderId, LocalDate serverStartDate, LocalDate serverEndDate, List<SysOrderPause> pauseList){ public List<SysRecipesPlan> generatePlan(Long orderId, List<SysRecipesPlan> oldRecipesPlanList, LocalDate serverStartDate, LocalDate serverEndDate, List<SysOrderPause> pauseList){
List<SysRecipesPlan> planList = new ArrayList<>(); List<SysRecipesPlan> planList = new ArrayList<>();
boolean breakFlag = false; boolean breakFlag = false;
LocalDate planStartDate = serverStartDate; LocalDate planStartDate = serverStartDate;
LocalDate planEndDate = planStartDate.plusDays(6); LocalDate planEndDate = planStartDate.plusDays(6);
while (true){ while (true){
SysRecipesPlan sysRecipesPlan = new SysRecipesPlan(); SysRecipesPlan sysRecipesPlan = new SysRecipesPlan();
//判断是否大于服务到期时间 //判断是否大于服务到期时间
if(ChronoUnit.DAYS.between(planEndDate, serverEndDate) > 0){ if(ChronoUnit.DAYS.between(planEndDate, serverEndDate) <= 0){
}else{
planEndDate = serverEndDate; planEndDate = serverEndDate;
breakFlag = true; breakFlag = true;
} }
@ -200,6 +210,17 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
sysRecipesPlan.setStartDate(DateUtils.localDateToDate(planStartDate)); sysRecipesPlan.setStartDate(DateUtils.localDateToDate(planStartDate));
sysRecipesPlan.setEndDate(DateUtils.localDateToDate(planEndDate)); sysRecipesPlan.setEndDate(DateUtils.localDateToDate(planEndDate));
sysRecipesPlan.setOrderId(orderId); 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); planList.add(sysRecipesPlan);
planStartDate = planEndDate.plusDays(1); planStartDate = planEndDate.plusDays(1);
@ -240,4 +261,24 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
} }
return pauseDay; return pauseDay;
} }
/**
* 根据订单ID删除所有食谱安排计划
* @param orderIds 订单ID
* @return
*/
@Override
public int delRecipesPlanByOrderId(Long[] orderIds){
return sysRecipesPlanMapper.delRecipesPlanByOrderId(orderIds);
}
/**
* 多条件查询食谱计划列表
* @param sysRecipesPlan
* @return
*/
@Override
public List<SysRecipesPlan> selectPlanListByCondition(SysRecipesPlan sysRecipesPlan){
return sysRecipesPlanMapper.selectPlanListByCondition(sysRecipesPlan);
}
} }

View File

@ -213,4 +213,9 @@
select * from sys_physical_signs sps where FIND_IN_SET(id, #{physical_signs_id}) select * from sys_physical_signs sps where FIND_IN_SET(id, #{physical_signs_id})
</select> </select>
<!-- 根据手机号查询体征 -->
<select id="selectSysCustomerAndSignByPhone" parameterType="String" resultMap="SysCustomerSignResult">
<include refid="selectSysCustomerAndSign"/> where sc.del_flag = 0 and sc.phone = #{phone} limit 1
</select>
</mapper> </mapper>

View File

@ -112,4 +112,12 @@
order by id desc order by id desc
</select> </select>
<!-- 根据订单ID删除暂停记录 -->
<update id="deletePauseByOrderId" parameterType="String">
update sys_order_pause set del_flag = 1 where order_id in
<foreach item="orderId" collection="array" open="(" separator="," close=")">
#{orderId}
</foreach>
</update>
</mapper> </mapper>

View File

@ -17,6 +17,15 @@
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" /> <result property="delFlag" column="del_flag" />
<!-- 非持久化字段 -->
<result property="customer" column="customer" />
<result property="phone" column="phone" />
<result property="orderStartDate" column="order_start_date" />
<result property="orderEndDate" column="order_end_date" />
<result property="nutritionistId" column="nutritionist_id" />
<result property="nutritionist" column="nutritionist" />
<result property="nutritionistAssisId" column="nutritionist_assis_id" />
<result property="nutritionistAssis" column="nutritionist_assis" />
</resultMap> </resultMap>
<sql id="selectSysRecipesPlanVo"> <sql id="selectSysRecipesPlanVo">
@ -87,11 +96,11 @@
</update> </update>
<delete id="deleteSysRecipesPlanById" parameterType="Long"> <delete id="deleteSysRecipesPlanById" parameterType="Long">
update sys_recipes_plan set del_flag = 0 where id = #{id} update sys_recipes_plan set del_flag = 1 where id = #{id}
</delete> </delete>
<delete id="deleteSysRecipesPlanByIds" parameterType="String"> <delete id="deleteSysRecipesPlanByIds" parameterType="String">
update sys_recipes_plan set del_flag = 0 where id in update sys_recipes_plan 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>
@ -100,16 +109,34 @@
<!-- 批量插入食谱计划 --> <!-- 批量插入食谱计划 -->
<insert id="insertBatch"> <insert id="insertBatch">
INSERT INTO sys_recipes_plan INSERT INTO sys_recipes_plan
(order_id, start_date, end_date) (order_id, start_date, end_date, send_flag, send_time, recipes_id)
VALUES VALUES
<foreach collection ="list" item="plan" separator =","> <foreach collection ="list" item="plan" separator =",">
(#{plan.orderId}, #{plan.startDate}, #{plan.end_date}) (#{plan.orderId}, #{plan.startDate}, #{plan.endDate}, #{plan.sendFlag}, #{plan.sendTime}, #{plan.recipesId})
</foreach > </foreach >
</insert> </insert>
<!-- 根据订单ID删除对应食谱计划 --> <!-- 根据订单ID删除对应食谱计划 -->
<update id="delRecipesPlanByOrderId" parameterType="Long"> <update id="delRecipesPlanByOrderId" parameterType="String">
update sys_recipes_plan set del_flag = 0 and order_id = #{orderId} update sys_recipes_plan set del_flag = 1 where order_id in
<foreach item="orderId" collection="array" open="(" separator="," close=")">
#{orderId}
</foreach>
</update> </update>
<!-- 食谱计划、订单表联查 -->
<select id="selectPlanListByCondition" parameterType="SysRecipesPlan" resultMap="SysRecipesPlanResult">
SELECT srp.id,srp.order_id,sr.customer,sr.phone,su_nutritionist.nick_name nutritionist,su_nutritionist_assis.nick_name AS nutritionist_assis,sr.start_time,sr.server_end_time, srp.start_date,srp.end_date,srp.send_flag,srp.send_time
FROM sys_recipes_plan srp
LEFT JOIN sys_order sr ON sr.order_id = srp.order_id
LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = sr.nutritionist_id AND su_nutritionist.del_flag = 0
LEFT JOIN sys_user su_nutritionist_assis ON su_nutritionist_assis.user_id = sr.nutri_assis_id AND su_nutritionist_assis.del_flag = 0
WHERE srp.del_flag = 0
<if test="orderId != null">AND srp.order_id = #{orderId}</if>
<if test="customer != null and customer != ''">AND sr.customer like concat('%',#{customer},'%')</if>
<if test="nutritionistId != null">AND su_nutritionist.user_id = #{nutritionistId}</if>
<if test="nutritionistAssisId != null">AND su_nutritionist_assis.user_id = #{nutritionistAssisId}</if>
<if test="startDate != null and endDate != null ">AND srp.start_date BETWEEN date_format(#{startDate},'%y%m%d') AND date_format(#{endDate},'%y%m%d') </if>
ORDER BY srp.order_id DESC,srp.id ASC
</select>
</mapper> </mapper>

View File

@ -51,3 +51,13 @@ export function exportCustomer(query) {
params: query params: query
}) })
} }
// 查询客户信息详细
export function getCustomerAndSignByPhone(query) {
return request({
url: '/custom/customer/getCustomerAndSignByPhone',
method: 'get',
params: query
})
}

View File

@ -58,3 +58,12 @@ export function getOptions() {
method: 'get' method: 'get'
}) })
} }
// 查询销售订单详细
export function getInfoDetail(query) {
return request({
url: '/custom/order/getInfoDetail',
method: 'get',
params: query
})
}

View File

@ -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
})
}

View File

@ -0,0 +1,616 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" >
<el-form-item label="客户姓名" prop="customer">
<el-input
v-model="queryParams.customer"
placeholder="请输入客户姓名"
clearable
size="small"
/>
</el-form-item>
<el-form-item label="食谱开始日期范围" prop="planStartDateScope" label-width="150px">
<el-date-picker
v-model="planStartDateScope"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['recipes:recipesPlan:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['recipes:recipesPlan:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="recipesPlanList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="客户姓名" align="center" prop="customer" />
<el-table-column label="食谱日期范围" align="center" prop="scopeDate" width="200"/>
<el-table-column label="营养师" align="center" prop="nutritionist" />
<el-table-column label="营养师助理" align="center" prop="nutritionistAssis" />
<el-table-column label="食谱是否发送" align="center" prop="sendFlag">
<!--<template slot-scope="scope">
<span>{{ scope.row.sendFlag == 1 ? "已发送" : "未发送"}}</span>
</template>(.sendFlag == 1) ? 'success' : 'warning'-->
<template slot-scope="scope">
<el-tag
:type="getTagType(scope.row)"
disable-transitions>
{{scope.row.sendFlag == 1 ? "已发送" : "未发送"}}
</el-tag>
</template>
</el-table-column>
<el-table-column label="食谱发送时间" align="center" prop="sendTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.sendTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="300">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['recipes:recipesPlan:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="allRecipesPlanQueryParam.orderId = scope.row.orderId; getAllPlanByOrderId()"
>查看完整计划</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="getOrderDetail(scope.row)"
v-hasPermi="['custom:order:query']"
>查看订单</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="getCustomerSign(scope.row)"
v-hasPermi="['custom:customer:query']"
>查看体征</el-button>
<!--<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['recipes:recipesPlan:remove']"
>删除</el-button>-->
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改食谱计划对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="食谱是否已发送" prop="sendFlag" label-width="120px">
<el-select v-model="form.sendFlag" placeholder="请选择">
<el-option label="否" :value="parseInt('0')" />
<el-option label="是" :value="parseInt('1')" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 查看完整计划 -->
<el-dialog title="食谱计划表" v-if="allRecipesPlanOpen" :visible.sync="allRecipesPlanOpen" width="800px" append-to-body>
<el-table v-loading="loading" :data="allRecipesPlanList" width="700px">
<el-table-column label="客户姓名" align="center" prop="customer" />
<!--<el-table-column label="营养师名称" align="center" prop="nutritionist" />
<el-table-column label="营养师助理名称" align="center" prop="nutritionistAssis" />-->
<el-table-column label="食谱时间范围" align="center" prop="scopeDate" width="200"/>
<el-table-column label="食谱是否发送" align="center" prop="sendFlag">
<!--<template slot-scope="scope">
<span>{{ scope.row.sendFlag == 1 ? "已发送" : "未发送"}}</span>
</template>(.sendFlag == 1) ? 'success' : 'warning'-->
<template slot-scope="scope">
<el-tag
:type="getTagType(scope.row)"
disable-transitions>
{{scope.row.sendFlag == 1 ? "已发送" : "未发送"}}
</el-tag>
</template>
</el-table-column>
<el-table-column label="食谱发送时间" align="center" prop="sendTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.sendTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="allRecipesPlanTotal>0"
:total="allRecipesPlanTotal"
:page.sync="allRecipesPlanQueryParam.pageNum"
:limit.sync="allRecipesPlanQueryParam.pageSize"
@pagination="getAllPlanByOrderId"
/>
<div slot="footer" class="dialog-footer">
<el-button @click="allRecipesPlanOpen = false"> </el-button>
</div>
</el-dialog>
<!-- 查看体征 -->
<el-dialog title="客户体征" v-if="customerOpen" :visible.sync="customerOpen" width="1000px" append-to-body>
<el-table v-loading="loading" :data="customerSign" width="900px">
<el-table-column label="姓名" align="center" prop="name" />
<!--<el-table-column label="手机号" align="center" prop="phone" width="120" fixed="left"/>-->
<el-table-column label="性别" align="center" prop="sign.sex" >
<template slot-scope="scope">
{{scope.row.sign.sex == 0 ? `` : '女'}}
</template>
</el-table-column>
<el-table-column label="年龄(岁)" align="center" prop="sign.age" />
<el-table-column label="身高(厘米)" align="center" prop="sign.tall" />
<el-table-column label="体重(斤)" align="center" prop="sign.weight"/>
<el-table-column label="北方、南方" align="center" prop="sign.position">
<template slot-scope="scope">
{{scope.row.sign.position == 0 ? `南方` : '北方'}}
</template>
</el-table-column>
<el-table-column label="病史" align="center" prop="sign.signList">
<template slot-scope="scope">
<span>{{getSignString(scope.row.sign.signList)}}</span>
</template>
</el-table-column>
</el-table>
<el-table v-loading="loading" :data="customerSign" width="900px">
<el-table-column label="忌口或过敏源" align="center" prop="sign.dishesIngredientId" width="120"></el-table-column>
<el-table-column label="是否便秘" align="center" prop="sign.constipation">
<template slot-scope="scope">
{{scope.row.sign.constipation == 0 ? `` : '否'}}
</template>
</el-table-column>
<el-table-column label="是否熬夜失眠" align="center" prop="sign.staylate">
<template slot-scope="scope">
{{scope.row.sign.staylate == 0 ? `` : '否'}}
</template>
</el-table-column>
<el-table-column label="是否经常运动" align="center" prop="sign.motion">
<template slot-scope="scope">
{{scope.row.sign.motion == 0 ? `` : '否'}}
</template>
</el-table-column>
<el-table-column label="饮食方式" align="center" prop="sign.makeFoodType" >
<template slot-scope="scope">
{{scope.row.sign.makeFoodType == 0 ? `自己做` : '外面吃'}}
</template>
</el-table-column>
<el-table-column label="饮食备注" align="center" prop="sign.remarks"></el-table-column>
<el-table-column label="饮食特点" align="center" prop="sign.makeFoodTaste">
<template slot-scope="scope">
{{scope.row.sign.makeFoodTaste == 0 ? `清淡` : '重口味'}}
</template>
</el-table-column>
</el-table>
<el-table v-loading="loading" :data="customerSign" width="900px">
<el-table-column label="工作职业" align="center" prop="sign.vocation">
<template slot-scope="scope">
{{scope.row.sign.vocation}}
</template>
</el-table-column>
<el-table-column label="是否上夜班" align="center" prop="sign.night">
<template slot-scope="scope">
{{scope.row.sign.night == 0 ? `` : '否'}}
</template>
</el-table-column>
<el-table-column label="久坐多还是运动多" align="center" prop="sign.walk">
<template slot-scope="scope">
{{scope.row.sign.walk == 0 ? `久坐多` : '走动多'}}
</template>
</el-table-column>
<el-table-column label="是否浑身乏力" align="center" prop="sign.weakness">
<template slot-scope="scope">
{{scope.row.sign.weakness == 0 ? `` : '否'}}
</template>
</el-table-column>
<el-table-column label="是否减脂反弹" align="center" prop="sign.rebound">
<template slot-scope="scope">
{{scope.row.sign.rebound == 0 ? `` : '否'}}
</template>
</el-table-column>
<el-table-column label="意识到生活习惯是减脂关键" align="center" prop="sign.crux">
<template slot-scope="scope">
{{scope.row.sign.crux == 0 ? `` : '否'}}
</template>
</el-table-column>
<el-table-column label="睡觉时间" align="center" prop="sign.sleepTime">
<template slot-scope="scope">
{{scope.row.sign.sleepTime}}
</template>
</el-table-column>
</el-table>
<el-table v-loading="loading" :data="customerSign" width="900px">
<el-table-column label="起床时间" align="center" prop="sign.getupTime" >
<template slot-scope="scope">
{{scope.row.sign.getupTime}}
</template>
</el-table-column>
<el-table-column label="方便沟通时间" align="center" prop="sign.connectTime">
<template slot-scope="scope">
{{scope.row.sign.connectTime}}
</template>
</el-table-column>
<el-table-column label="湿气数据" align="center" prop="sign.bloodData">
<template slot-scope="scope">
{{scope.row.sign.bloodData}}
</template>
</el-table-column>
<el-table-column label="气血数据" align="center" prop="sign.moistureDate" >
<template slot-scope="scope">
{{scope.row.sign.moistureDate}}
</template>
</el-table-column>
<el-table-column label="减脂经历" align="center" prop="sign.experience" ></el-table-column>
<el-table-column label="减脂遇到的困难" align="center" prop="sign.difficulty" ></el-table-column>
<el-table-column label="备注" align="center" prop="sign.comments"></el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button @click="customerOpen = false"> </el-button>
</div>
</el-dialog>
<!-- 查看订单 -->
<el-dialog title="订单详情" v-if="orderDetailOpen" :visible.sync="orderDetailOpen" width="1000px" append-to-body>
<el-table v-loading="loading" :data="orderDetailList" >
<el-table-column label="订单状态" align="center" prop="orderId">
<template slot-scope="scope">
<el-tag
:type="scope.row.reviewStatus === '2' ? 'success' : scope.row.status ==='0'? '': 'danger'"
disable-transitions>
{{scope.row.reviewStatus === '2' ? '已完成': scope.row.status ==='0'? '进行中': '已暂停'}}
</el-tag>
</template>
</el-table-column>
<el-table-column label="审核状态" align="center" prop="reviewStatus">
<template slot-scope="scope">
<el-tag
:type="scope.row.reviewStatus === 'yes' ? 'success' : 'danger'"
disable-transitions>
{{scope.row.reviewStatus === 'yes' ? '已审核':'未审核'}}
</el-tag>
</template>
</el-table-column>
<el-table-column label="成交时间" align="center" prop="orderTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.orderTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="客户姓名" align="center" prop="customer"/>
<el-table-column label="金额" align="center" prop="amount">
<template slot-scope="scope">
{{toThousands(scope.row.amount)}}
</template>
</el-table-column>
<el-table-column label="体重" align="center" prop="weight">
<template slot-scope="scope">
{{scope.row.weight ? `${scope.row.weight}` : ''}}
</template>
</el-table-column>
</el-table>
<el-table v-loading="loading" :data="orderDetailList" >
<el-table-column label="手机号" align="center" prop="phone"/>
<el-table-column label="服务时长" align="center" prop="serveTime"/>
<el-table-column label="赠送时长" align="center" prop="giveServeDay">
<template slot-scope="scope">
{{scope.row.giveServeDay ? `${scope.row.giveServeDay}` : '0天'}}
</template>
</el-table-column>
<el-table-column label="调理项目" align="center" prop="conditioningProject"/>
<el-table-column label="收款方式" align="center" prop="payType"/>
<el-table-column label="售前" align="center" prop="preSale"/>
</el-table>
<el-table v-loading="loading" :data="orderDetailList" >
<el-table-column label="售后" align="center" prop="afterSale"/>
<el-table-column label="主营养师" align="center" prop="nutritionist"/>
<el-table-column label="助理营养师" align="center" prop="nutriAssis" />
<el-table-column label="账号" align="center" prop="account"/>
<el-table-column label="策划" align="center" prop="planner"/>
<el-table-column label="策划助理" align="center" prop="plannerAssis"/>
</el-table>
<el-table v-loading="loading" :data="orderDetailList" >
<el-table-column label="运营" align="center" prop="operator"/>
<el-table-column label="运营助理" align="center" prop="operatorAssis"/>
<!--<el-table-column label="推荐人" align="center" prop="recommender"/>-->
<el-table-column label="进粉时间" align="center" prop="becomeFanTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.becomeFanTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="开始时间" align="center" prop="startTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="结束时间" align="center" prop="serverEndTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.serverEndTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark"/>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button @click="orderDetailOpen = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listRecipesPlan, getRecipesPlan, updateRecipesPlan,exportRecipesPlan } from "@/api/custom/recipesPlan";
import { getCustomerAndSignByPhone } from "@/api/custom/customer";
import {getInfoDetail} from "@/api/custom/order";
import dayjs from 'dayjs';
const nextDate = dayjs().add(1, 'day').format("YYYY-MM-DD");
const weekDate = dayjs().add(6, 'day').format("YYYY-MM-DD");
export default {
name: "recipesPlan",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
recipesPlanList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
customer: null,
startDate: null,
endDate: null
},
//
form: {},
//
rules: {
},
//
planStartDateScope:[nextDate, nextDate],
//
customerSignList: [],
//
customerOpen: false,
//
allRecipesPlanList:[],
//
allRecipesPlanOpen: false,
//
allRecipesPlanQueryParam: {
pageNum: 1,
pageSize: 10,
orderId: null
},
//
allRecipesPlanTotal: 0,
//
orderDetailList:[],
//
orderDetailOpen:false
};
},
created() {
this.getList();
},
methods: {
/** 查询食谱计划列表 */
getList() {
this.loading = true;
if(this.planStartDateScope != null && this.planStartDateScope.length > 0){
this.queryParams.startDate = dayjs(this.planStartDateScope[0]).format('YYYY-MM-DD');
this.queryParams.endDate = dayjs(this.planStartDateScope[1]).format('YYYY-MM-DD');
}else{
this.queryParams.startDate = null;
this.queryParams.endDate = null;
}
listRecipesPlan(this.queryParams).then(response => {
this.recipesPlanList = response.rows;
this.recipesPlanList.forEach(function(item, index){
item.scopeDate = dayjs(item.startDate).format("YYYY-MM-DD")+" 到 "+dayjs(item.endDate).format("YYYY-MM-DD")
});
this.total = response.total;
this.loading = false;
});
},
/** 查询客户体征 */
getCustomerSign(row) {
this.customerSign = [];
let message = "未找到该客户,请检查订单手机号与客户体征手机号是否一致";
if(row.phone == null || row.phone == ""){
this.alert(message);
return;
}
getCustomerAndSignByPhone({"phone": row.phone}).then(response => {
this.customerSign[0] = response.data;
if(this.customerSign[0] == null){
this.alert(message);
}else{
this.customerOpen = true;
}
});
},
getAllPlanByOrderId(){
listRecipesPlan(this.allRecipesPlanQueryParam).then(response => {
this.allRecipesPlanList = response.rows;
this.allRecipesPlanList.forEach(function(item, index){
item.scopeDate = dayjs(item.startDate).format("YYYY-MM-DD")+" 到 "+dayjs(item.endDate).format("YYYY-MM-DD")
});
this.allRecipesPlanOpen = true;
this.allRecipesPlanTotal = response.total;
});
},
getOrderDetail(row){
this.orderDetailList = [];
getInfoDetail({'orderId': row.orderId}).then(response => {
this.orderDetailList[0] = response.data;
this.orderDetailOpen = true;
});
},
alert(value){
this.$alert(value, '提示', {confirmButtonText: '确定'});
},
getSignString(signList){
if(signList == null){
return "";
}
let signStr = "";
for(let i in signList){
signStr += ""+signList[i].name;
}
return signList.length > 0 ? signStr.substring(1) : signStr;
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
orderId: null,
startDate: null,
endDate: null,
recipesId: null,
sendFlag: null,
sendTime: null,
createTime: null,
createBy: null,
updateTime: null,
updateBy: null,
delFlag: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.planStartDateScope = [nextDate,nextDate];
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getRecipesPlan(id).then(response => {
this.form.id = response.data.id;
this.form.sendFlag = response.data.sendFlag;
this.open = true;
this.title = "修改食谱计划";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateRecipesPlan(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
}
}
});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有食谱计划数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportRecipesPlan(queryParams);
}).then(response => {
this.download(response.msg);
}).catch(function() {});
},
getTagType(row){
if(row.sendFlag == 1) {
return "success";
}
if(dayjs(row.startDate+"").diff(dayjs(),'day') <= 1){
return "danger";
}
return '';
}
}
};
</script>