处理暂停日期
This commit is contained in:
parent
6fe95722e2
commit
8f94c50d22
@ -2,6 +2,8 @@ package com.stdiet.web.controller.custom;
|
|||||||
|
|
||||||
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;
|
||||||
|
import com.stdiet.custom.domain.SysOrderPause;
|
||||||
|
import com.stdiet.custom.service.ISysOrderPauseService;
|
||||||
import com.stdiet.custom.service.ISysRecipesService;
|
import com.stdiet.custom.service.ISysRecipesService;
|
||||||
import com.stdiet.custom.service.ISysWapServices;
|
import com.stdiet.custom.service.ISysWapServices;
|
||||||
import com.stdiet.system.service.ISysDictTypeService;
|
import com.stdiet.system.service.ISysDictTypeService;
|
||||||
@ -11,9 +13,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/wap")
|
@RequestMapping("/wap")
|
||||||
@ -27,6 +27,9 @@ public class SysWapController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
ISysDictTypeService iSysDictTypeService;
|
ISysDictTypeService iSysDictTypeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ISysOrderPauseService iSysOrderPauseService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户食谱详情
|
* 客户食谱详情
|
||||||
*
|
*
|
||||||
@ -38,6 +41,17 @@ public class SysWapController extends BaseController {
|
|||||||
return AjaxResult.success(iSysWapServices.getRecipesPlanListInfo(outId));
|
return AjaxResult.success(iSysWapServices.getRecipesPlanListInfo(outId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/recipes/plan/pause/{outId}")
|
||||||
|
public AjaxResult planPauses(@PathVariable String outId) {
|
||||||
|
SysOrderPause sysOrderPause = new SysOrderPause();
|
||||||
|
sysOrderPause.setOutId(outId);
|
||||||
|
List<SysOrderPause> list = iSysOrderPauseService.selectSysOrderPauseList(sysOrderPause);
|
||||||
|
for (SysOrderPause pause : list) {
|
||||||
|
pause.setCusId(null);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
*
|
*
|
||||||
|
@ -29,6 +29,8 @@ public class SysOrderPause {
|
|||||||
|
|
||||||
private Long cusId;
|
private Long cusId;
|
||||||
|
|
||||||
|
private String outId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务暂停开始时间
|
* 服务暂停开始时间
|
||||||
*/
|
*/
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<result property="id" column="id"/>
|
<result property="id" column="id"/>
|
||||||
<result property="orderId" column="order_id"/>
|
<result property="orderId" column="order_id"/>
|
||||||
<result property="cusId" column="cus_id"/>
|
<result property="cusId" column="cus_id"/>
|
||||||
|
<result property="outId" column="out_id"/>
|
||||||
<result property="pauseStartDate" column="pause_start_date"/>
|
<result property="pauseStartDate" column="pause_start_date"/>
|
||||||
<result property="pauseEndDate" column="pause_end_date"/>
|
<result property="pauseEndDate" column="pause_end_date"/>
|
||||||
<result property="reason" column="reason"/>
|
<result property="reason" column="reason"/>
|
||||||
@ -24,7 +25,7 @@
|
|||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="selectSysOrderPauseVo">
|
<sql id="selectSysOrderPauseVo">
|
||||||
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
|
select id, order_id, cus_id, out_id, pause_start_date, pause_end_date, reason, remarks, create_time, create_by, update_time, update_by, del_flag from sys_recipes_pause sop
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectSysOrderPauseList" parameterType="SysOrderPause" resultMap="SysOrderPauseResult">
|
<select id="selectSysOrderPauseList" parameterType="SysOrderPause" resultMap="SysOrderPauseResult">
|
||||||
@ -36,6 +37,7 @@
|
|||||||
where sop.del_flag = 0
|
where sop.del_flag = 0
|
||||||
<if test="orderId != null ">and sop.order_id = #{orderId}</if>
|
<if test="orderId != null ">and sop.order_id = #{orderId}</if>
|
||||||
<if test="cusId != null ">and sop.cus_id = #{cusId}</if>
|
<if test="cusId != null ">and sop.cus_id = #{cusId}</if>
|
||||||
|
<if test="outId != null ">and sop.out_id = #{outId}</if>
|
||||||
<if test="pauseStartDate != null ">and sop.pause_start_date = #{pauseStartDate}</if>
|
<if test="pauseStartDate != null ">and sop.pause_start_date = #{pauseStartDate}</if>
|
||||||
<if test="pauseEndDate != null ">and sop.pause_end_date = #{pauseEndDate}</if>
|
<if test="pauseEndDate != null ">and sop.pause_end_date = #{pauseEndDate}</if>
|
||||||
<if test="reason != null and reason != ''">and sop.reason = #{reason}</if>
|
<if test="reason != null and reason != ''">and sop.reason = #{reason}</if>
|
||||||
@ -52,6 +54,7 @@
|
|||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="orderId != null">order_id,</if>
|
<if test="orderId != null">order_id,</if>
|
||||||
<if test="cusId != null">cus_id,</if>
|
<if test="cusId != null">cus_id,</if>
|
||||||
|
<if test="cusId != null">out_id,</if>
|
||||||
<if test="pauseStartDate != null">pause_start_date,</if>
|
<if test="pauseStartDate != null">pause_start_date,</if>
|
||||||
<if test="pauseEndDate != null">pause_end_date,</if>
|
<if test="pauseEndDate != null">pause_end_date,</if>
|
||||||
<if test="reason != null">reason,</if>
|
<if test="reason != null">reason,</if>
|
||||||
@ -65,6 +68,7 @@
|
|||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="orderId != null">#{orderId},</if>
|
<if test="orderId != null">#{orderId},</if>
|
||||||
<if test="cusId != null">#{cusId},</if>
|
<if test="cusId != null">#{cusId},</if>
|
||||||
|
<if test="cusId != null">md5(#{cusId}),</if>
|
||||||
<if test="pauseStartDate != null">#{pauseStartDate},</if>
|
<if test="pauseStartDate != null">#{pauseStartDate},</if>
|
||||||
<if test="pauseEndDate != null">#{pauseEndDate},</if>
|
<if test="pauseEndDate != null">#{pauseEndDate},</if>
|
||||||
<if test="reason != null">#{reason},</if>
|
<if test="reason != null">#{reason},</if>
|
||||||
@ -82,6 +86,7 @@
|
|||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="orderId != null">order_id = #{orderId},</if>
|
<if test="orderId != null">order_id = #{orderId},</if>
|
||||||
<if test="cusId != null">cus_id = #{cusId},</if>
|
<if test="cusId != null">cus_id = #{cusId},</if>
|
||||||
|
<if test="outId != null">out_id = #{outId},</if>
|
||||||
<if test="pauseStartDate != null">pause_start_date = #{pauseStartDate},</if>
|
<if test="pauseStartDate != null">pause_start_date = #{pauseStartDate},</if>
|
||||||
<if test="pauseEndDate != null">pause_end_date = #{pauseEndDate},</if>
|
<if test="pauseEndDate != null">pause_end_date = #{pauseEndDate},</if>
|
||||||
<if test="reason != null">reason = #{reason},</if>
|
<if test="reason != null">reason = #{reason},</if>
|
||||||
|
@ -49,3 +49,14 @@ export function getRecipesFullInfo(id) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getPlanPause(id) {
|
||||||
|
return request({
|
||||||
|
url: "/wap/recipes/plan/pause/" + id,
|
||||||
|
method: "get",
|
||||||
|
headers: {
|
||||||
|
isToken: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -166,14 +166,13 @@ export default {
|
|||||||
fetchOrderList() {
|
fetchOrderList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
listOrder({ cusId: this.data.id }).then((res) => {
|
listOrder({ cusId: this.data.id }).then((res) => {
|
||||||
this.orderList = res.rows.reduce((arr, cur) => {
|
this.orderList = res.rows.reduce((arr, cur, idx) => {
|
||||||
const tarOrder = arr.find((ord) => ord.startTime === cur.startTime);
|
const tarOrder = arr.find((ord) => ord.startTime === cur.startTime);
|
||||||
if (tarOrder) {
|
if (tarOrder) {
|
||||||
if (!tarOrder.children) {
|
if (!tarOrder.children) {
|
||||||
const firstObj = JSON.parse(JSON.stringify(tarOrder));
|
const firstObj = JSON.parse(JSON.stringify(tarOrder));
|
||||||
tarOrder.children = [{ ...firstObj, type: "main" }];
|
tarOrder.children = [{ ...firstObj, type: "main" }];
|
||||||
}
|
}
|
||||||
tarOrder.amount += cur.afterSaleCommissOrder == 0 ? cur.amount : 0;
|
|
||||||
tarOrder.orderId += cur.orderId;
|
tarOrder.orderId += cur.orderId;
|
||||||
tarOrder.type = "virtual";
|
tarOrder.type = "virtual";
|
||||||
tarOrder.children.push({ ...cur, type: "main" });
|
tarOrder.children.push({ ...cur, type: "main" });
|
||||||
@ -181,6 +180,13 @@ export default {
|
|||||||
cur.type = "main";
|
cur.type = "main";
|
||||||
arr.push(cur);
|
arr.push(cur);
|
||||||
}
|
}
|
||||||
|
if (idx === res.rows.length - 1 && arr.children) {
|
||||||
|
arr.forEach((obj) => {
|
||||||
|
obj.amount = arr.children.reduce((a, c) => {
|
||||||
|
return a + c.afterSaleCommissOrder === 0 ? c.amount : 0;
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}, []);
|
}, []);
|
||||||
// console.log(this.orderList);
|
// console.log(this.orderList);
|
||||||
|
@ -39,6 +39,7 @@ import {
|
|||||||
getRecipesPlans,
|
getRecipesPlans,
|
||||||
getHealthyInfo,
|
getHealthyInfo,
|
||||||
getRecipesMenuInfoApi,
|
getRecipesMenuInfoApi,
|
||||||
|
getPlanPause,
|
||||||
} from "@/api/custom/recipesShow";
|
} from "@/api/custom/recipesShow";
|
||||||
import { dealHealthy } from "@/utils/healthyData";
|
import { dealHealthy } from "@/utils/healthyData";
|
||||||
import UserInfoDrawer from "./UserInfoDrawer";
|
import UserInfoDrawer from "./UserInfoDrawer";
|
||||||
@ -76,64 +77,86 @@ export default {
|
|||||||
data: {},
|
data: {},
|
||||||
},
|
},
|
||||||
menuData: [],
|
menuData: [],
|
||||||
|
pauseDays: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
async created() {
|
||||||
//
|
//
|
||||||
this.init();
|
this.init();
|
||||||
//
|
//
|
||||||
getRecipesPlans(this.id).then((response) => {
|
const planPauseRes = await getPlanPause(this.id);
|
||||||
if (response.code === 200) {
|
// console.log(planPauseRes.data);
|
||||||
let curPlanId, curMenuId, curDate;
|
if (planPauseRes.code === 200) {
|
||||||
const toDay = dayjs().format("YYYY-MM-DD");
|
this.pauseDays = planPauseRes.data.reduce((arr, cur) => {
|
||||||
this.planList = response.data.reduce((arr, plan) => {
|
let startDate = cur.pauseStartDate;
|
||||||
if (plan.menus) {
|
while (dayjs(startDate) <= dayjs(cur.pauseEndDate)) {
|
||||||
arr.push({
|
arr.push(startDate);
|
||||||
menus: plan.menus.map((menu, idx) => {
|
startDate = dayjs(startDate).add(1, "days").format("YYYY-MM-DD");
|
||||||
const date = dayjs(plan.startDate)
|
|
||||||
.add(idx, "day")
|
|
||||||
.format("YYYY-MM-DD");
|
|
||||||
if (toDay === date) {
|
|
||||||
curPlanId = plan.id;
|
|
||||||
curMenuId = menu.id;
|
|
||||||
curDate = date;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
date,
|
|
||||||
id: menu.id,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
recipesId: plan.recipesId,
|
|
||||||
label: `第${plan.startNumDay} 至 ${plan.endNumDay}天`,
|
|
||||||
id: plan.id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}, []);
|
|
||||||
if (!curMenuId) {
|
|
||||||
curMenuId = this.planList[0].menus[0].id;
|
|
||||||
curPlanId = this.planList[0].id;
|
|
||||||
curDate = this.planList[0].menus[0].date;
|
|
||||||
}
|
}
|
||||||
this.curMenuId = curMenuId;
|
return arr;
|
||||||
this.curPlanId = curPlanId;
|
}, []);
|
||||||
this.curDate = curDate;
|
// console.log(this.pauseDays);
|
||||||
|
}
|
||||||
|
|
||||||
// console.log({
|
const plansRes = await getRecipesPlans(this.id);
|
||||||
// planList: this.planList,
|
|
||||||
// });
|
|
||||||
|
|
||||||
this.fetchRecipesInfo(this.curMenuId);
|
if (plansRes.code === 200) {
|
||||||
|
let curPlanId, curMenuId, curDate;
|
||||||
|
const toDay = dayjs().format("YYYY-MM-DD");
|
||||||
|
this.planList = plansRes.data.reduce((arr, plan) => {
|
||||||
|
if (plan.menus) {
|
||||||
|
let tmpDate = dayjs(plan.startDate).subtract(1, "days");
|
||||||
|
arr.push({
|
||||||
|
menus: plan.menus.map((menu) => {
|
||||||
|
tmpDate = tmpDate.add(1, "days");
|
||||||
|
// 跳过暂停日子
|
||||||
|
while (
|
||||||
|
this.pauseDays.includes(tmpDate.clone().format("YYYY-MM-DD"))
|
||||||
|
) {
|
||||||
|
tmpDate = tmpDate.add(1, "days");
|
||||||
|
}
|
||||||
|
|
||||||
|
const date = tmpDate.format("YYYY-MM-DD");
|
||||||
|
if (toDay === date) {
|
||||||
|
curPlanId = plan.id;
|
||||||
|
curMenuId = menu.id;
|
||||||
|
curDate = date;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
date,
|
||||||
|
id: menu.id,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
recipesId: plan.recipesId,
|
||||||
|
label: `第${plan.startNumDay} 至 ${plan.endNumDay}天`,
|
||||||
|
id: plan.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}, []);
|
||||||
|
if (!curMenuId) {
|
||||||
|
curMenuId = this.planList[0].menus[0].id;
|
||||||
|
curPlanId = this.planList[0].id;
|
||||||
|
curDate = this.planList[0].menus[0].date;
|
||||||
}
|
}
|
||||||
});
|
this.curMenuId = curMenuId;
|
||||||
getHealthyInfo(this.id).then((response) => {
|
this.curPlanId = curPlanId;
|
||||||
if (response.code === 200) {
|
this.curDate = curDate;
|
||||||
this.healthyData = {
|
|
||||||
type: response.data.type,
|
// console.log({
|
||||||
data: dealHealthy(response.data.customerHealthy),
|
// planList: this.planList,
|
||||||
};
|
// });
|
||||||
}
|
|
||||||
});
|
this.fetchRecipesInfo(this.curMenuId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const healthyRes = await getHealthyInfo(this.id);
|
||||||
|
if (healthyRes.code === 200) {
|
||||||
|
this.healthyData = {
|
||||||
|
type: healthyRes.data.type,
|
||||||
|
data: dealHealthy(healthyRes.data.customerHealthy),
|
||||||
|
};
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleOnPlanClick() {
|
handleOnPlanClick() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user