|
@@ -108,6 +108,29 @@ class OrderService extends CrudService {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据id获取某餐
|
|
|
+ * @param {Object} params
|
|
|
+ * @property {String} id 某餐的id
|
|
|
+ */
|
|
|
+ async getMeal({ id }) {
|
|
|
+ id = ObjectId(id);
|
|
|
+ const query = {
|
|
|
+ $or: [
|
|
|
+ { 'breakfast._id': id },
|
|
|
+ { 'lunch._id': id },
|
|
|
+ { 'dinner._id': id },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ const order = await this.model.findOne(query);
|
|
|
+ if (!order) return;
|
|
|
+ let meal = {};
|
|
|
+ if (ObjectId(id).equals(order.breakfast._id)) meal = order.breakfast;
|
|
|
+ else if (ObjectId(id).equals(order.lunch._id)) meal = order.lunch;
|
|
|
+ else if (ObjectId(id).equals(order.dinner._id)) meal = order.dinner;
|
|
|
+ if (meal) return meal;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 扫码领餐
|
|
|
* @param {Object} query 参数
|
|
@@ -115,7 +138,6 @@ class OrderService extends CrudService {
|
|
|
*/
|
|
|
async useMeal({ id }) {
|
|
|
id = ObjectId(id);
|
|
|
- console.log(this.ctx.tenant);
|
|
|
const query = {
|
|
|
$or: [
|
|
|
{ 'breakfast._id': id },
|