|
@@ -29,19 +29,25 @@ class OrderService extends CrudService {
|
|
|
* 检查所有的票是否过期
|
|
|
*/
|
|
|
async checkTimeOut() {
|
|
|
- const tenantList = await this.ctx.model.System.Tenant.find();
|
|
|
+ const tenantList = await this.ctx.model.System.Tenant.find({ _tenant: { $ne: 'master' } });
|
|
|
for (const site of tenantList) {
|
|
|
- const { _tenant } = site;
|
|
|
+ const { _tenant, params } = site;
|
|
|
+ const pbe = params.find(f => f.key === 'breakfast_end');
|
|
|
+ const ple = params.find(f => f.key === 'lunch_end');
|
|
|
+ const pde = params.find(f => f.key === 'dinner_end');
|
|
|
+ if (!pbe) console.error('没有设置早餐结束时间');
|
|
|
+ if (!ple) console.error('没有设置午餐结束时间');
|
|
|
+ if (!ple) console.error('没有设置晚餐结束时间');
|
|
|
// 赋值全局的分站识别变量,然service,model都变成该分站=切换分站
|
|
|
this.ctx.tenant = _tenant;
|
|
|
// 查出所有订餐记录
|
|
|
const list = await this.ctx.model.Dining.Order.find();
|
|
|
for (const order of list) {
|
|
|
const { date } = order;
|
|
|
- // TODO 这三个时间点,应该是设置出来的,目前我写死了
|
|
|
- const breakfast_time = `${date} 10:00`;
|
|
|
- const lunch_time = `${date} 13:00`;
|
|
|
- const dinner_time = `${date} 19:00`;
|
|
|
+ // 这三个时间点,应该是设置出来的
|
|
|
+ const breakfast_time = `${date} ${pbe.value}`;
|
|
|
+ const lunch_time = `${date} ${ple.value}`;
|
|
|
+ const dinner_time = `${date} ${pde.value}`;
|
|
|
if (order.breakfast.list.length > 0 && moment().isSameOrAfter(breakfast_time)) order.breakfast.is_use = '3';
|
|
|
if (order.lunch.list.length > 0 && moment().isSameOrAfter(lunch_time)) order.lunch.is_use = '3';
|
|
|
if (order.dinner.list.length > 0 && moment().isSameOrAfter(dinner_time)) order.dinner.is_use = '3';
|