|
|
@ -1,6 +1,6 @@ |
|
|
|
const Market = require("../model/market.model"); |
|
|
|
const Chicken = require("../model/chicken.model"); |
|
|
|
const { getChickenByBatchId } = require("./chicken.service"); |
|
|
|
const { getAllChickenByBatchId } = require("./chicken.service"); |
|
|
|
const { getBatchCoopByIds } = require("./coop.service"); |
|
|
|
const { getVarietyById } = require("./variety.service"); |
|
|
|
const { getAccountInfo } = require("./account.service"); |
|
|
@ -23,6 +23,17 @@ class MarketService { |
|
|
|
house_id, |
|
|
|
out_time, |
|
|
|
}); |
|
|
|
// 新增后 将chicken表中该batch_number对应的row中is_marketed改为1
|
|
|
|
const updateRes = await Chicken.update( |
|
|
|
{ |
|
|
|
is_marketed: 1, |
|
|
|
}, |
|
|
|
{ |
|
|
|
where: { |
|
|
|
batch_number: batch_id, |
|
|
|
}, |
|
|
|
} |
|
|
|
); |
|
|
|
return res ? res.dataValues : null; |
|
|
|
} |
|
|
|
|
|
|
@ -41,11 +52,13 @@ class MarketService { |
|
|
|
}); |
|
|
|
const arr = res?.map((item) => item.dataValues); |
|
|
|
const p = arr.map(async (item) => { |
|
|
|
const childrenInfo = await getChickenByBatchId(item.batch_id); |
|
|
|
const coop_ids = childrenInfo.coop_id.split(","); |
|
|
|
const childrenInfo = await getAllChickenByBatchId(item.batch_id); |
|
|
|
const coop_ids = childrenInfo?.coop_id?.split(","); |
|
|
|
// // 根据coop_id批量查询
|
|
|
|
const coopInfo = await getBatchCoopByIds(coop_ids); |
|
|
|
item.coopInfo = coopInfo; |
|
|
|
if (coop_ids) { |
|
|
|
const coopInfo = await getBatchCoopByIds(coop_ids); |
|
|
|
item.coopInfo = coopInfo; |
|
|
|
} |
|
|
|
return item; |
|
|
|
}); |
|
|
|
const real = await Promise.all(p); |
|
|
@ -59,7 +72,7 @@ class MarketService { |
|
|
|
}, |
|
|
|
}); |
|
|
|
// 根据当前的batch_id查询基本信息
|
|
|
|
const chickenInfo = await getChickenByBatchId(batch_id); |
|
|
|
const chickenInfo = await getAllChickenByBatchId(batch_id); |
|
|
|
const log_user_id = chickenInfo.log_user_id; |
|
|
|
const variety_id = chickenInfo.variety_id; |
|
|
|
const userInfo = await getAccountInfo({ id: log_user_id }); |
|
|
|