From e78c8d1cbc7144543a4cbb19b77452926e0c636f Mon Sep 17 00:00:00 2001 From: maochaoying <925670706@qq.com> Date: Thu, 23 Mar 2023 17:27:25 +0800 Subject: [PATCH] mohu --- src/controller/market.controller.js | 4 ++-- src/service/market.service.js | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/controller/market.controller.js b/src/controller/market.controller.js index 5a23648..20d69fb 100644 --- a/src/controller/market.controller.js +++ b/src/controller/market.controller.js @@ -25,8 +25,8 @@ class MarketController { } async list(ctx, next) { - const { house_id } = ctx.request.body; - const res = await getAllMarketList(house_id); + const { house_id, out_time, batch_id } = ctx.request.body; + const res = await getAllMarketList(house_id, out_time, batch_id); ctx.body = Response(0, "查询出栏记录成功", res); } diff --git a/src/service/market.service.js b/src/service/market.service.js index a787e25..86f59c0 100644 --- a/src/service/market.service.js +++ b/src/service/market.service.js @@ -4,6 +4,8 @@ const { getBatchCoopByIds } = require("./coop.service"); const { getVarietyById } = require("./variety.service"); const { getAccountInfo } = require("./account.service"); const { getDayLife } = require("../utils/common"); +const { Op } = require("sequelize"); +const { DATE_FILTER } = require("../constant/constant"); class MarketService { async addNewMarket( batch_id, @@ -22,11 +24,18 @@ class MarketService { return res ? res.dataValues : null; } - async getAllMarketList(house_id) { - const res = await Market.findAll({ - where: { - house_id, + async getAllMarketList(house_id, out_time = "0", batch_id = "") { + // 模糊查询 + let selectObj = { + batch_id: { + [Op.like]: `%${batch_id}%`, }, + }; + house_id && Object.assign(selectObj, { house_id }); + DATE_FILTER[out_time] && + Object.assign(selectObj, { out_time: DATE_FILTER[out_time] }); + const res = await Market.findAll({ + where: selectObj, }); const arr = res?.map((item) => item.dataValues); const p = arr.map(async (item) => {