Browse Source

mohu

master
maochaoying 2 years ago
parent
commit
e78c8d1cbc
  1. 4
      src/controller/market.controller.js
  2. 17
      src/service/market.service.js

4
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);
}

17
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) => {

Loading…
Cancel
Save