This commit is contained in:
2026-10-08 18:18:21 +08:00
parent 9cc1ff546c
commit 1e3095c05e
1911 changed files with 349551 additions and 0 deletions
@@ -0,0 +1,74 @@
'use strict';
module.exports = {
/**
* 获取报价单详情
* @url client/enquiry/sheet/pub/getDetail 前端调用的url参数地址
* data 请求参数
* @param {String} params1 参数1
*/
main: async (event) => {
let { data = {}, userInfo, util, filterResponse, originalParam } = event;
let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
let { uid, _id } = data;
let res = { code: 0, msg: "" };
// 业务逻辑开始-----------------------------------------------------------
let dbName = "jjx-enquiry-sheet";
res.data = await vk.baseDao.findByWhereJson({
dbName,
whereJson: {
_id: _id
},
// foreignDB: [
// {
// dbName:"uni-id-users",
// localKey:"userId",
// foreignKey:"_id",
// as:"user",
// limit:1, // limit=1则以对象形式返回
// fieldJson:{
// _id: true,
// company: {
// companyName: true,
// mobile: true,
// },
// person: {
// personName: true,
// mobile: true,
// },
// businessCard: true,
// accountType: true,
// },
// }
// ]
});
res.data.user = await vk.baseDao.findByWhereJson({
dbName:"uni-id-users",
whereJson: {
_id: res.data.userId
}
})
if (res.data.user && (res.data.user.isNotaryBusiness === undefined || res.data.user.isNotaryBusiness === null)) {
res.data.user.isNotaryBusiness = res.data.user.notaryUnionPayProfile && res.data.user.notaryUnionPayProfile.status === 1 ? 1 : 0
}
res.data.quoteList = []
const quoteList = await vk.baseDao.select({
dbName: "jjx-enquiry-quote",
whereJson: {
sheetId: _id
}
})
res.data.hasQuote = false
res.data.isMine = res.data.userId === uid
quoteList.rows.forEach(quote => {
if (quote.userId === uid) res.data.hasQuote = true
})
if (quoteList.rows.length > 0) res.data.quoteList = quoteList.rows
// 业务逻辑结束-----------------------------------------------------------
return res;
}
}
@@ -0,0 +1,195 @@
'use strict';
const dayjs = require("dayjs");
module.exports = {
/**
* 获取用户发布的询价单
* @url client/enquiry/sheet/pub/getList 前端调用的url参数地址
* data 请求参数
* @param {String} params1 参数1
*/
main: async (event) => {
let {data = {}, userInfo, util, filterResponse, originalParam} = event;
let {customUtil, uniID, config, pubFun, vk, db, _} = util;
let {
uid,
pageIndex,
pageSize,
keyword,
categoryIds,
provinceCodes,
formData,
status,
companyList,
cateList,
material,
area,
latest,
} = data;
let res = {code: 0, msg: ""};
// 业务逻辑开始-----------------------------------------------------------
let dbName = "jjx-enquiry-sheet";
// const andArr = [];
let whereJson = {isShow: 1}
if (data.userId && vk.pubfn.isNotNull(data.userId)) {
// andArr.push({userId: data.userId})
whereJson.userId = data.userId
} else {
// andArr.push({status: 0})
whereJson.status = 0
}
if (vk.pubfn.isNotNull(keyword)) {
whereJson.title = new RegExp(keyword)
}
if (vk.pubfn.isNotNull(area)) {
console.log(area.length)
if (area.length === 3) whereJson['addressRegion.area.code'] = area[2]
if (area.length === 2) whereJson['addressRegion.city.code'] = area[1]
if (area.length === 1) whereJson['addressRegion.province.code'] = area[0]
}
if (vk.pubfn.isNotNull(latest)) {
whereJson['answerStartTime'] = _.gte(dayjs().format('YYYY-MM-DD HH:mm:ss'))
}
if (vk.pubfn.isNotNull(status) && status !== 'all') {
// if (status === 'noQuote') andArr.push({quoteNum: 0})
// else if (status === 'notPick') andArr.push({status: 0})
// else if (status === 'picked') andArr.push({status: 1})
if (status === 'noQuote') whereJson.quoteNum = 0
else if (status === 'notPick') whereJson.status = 0
else if (status === 'picked') whereJson.status = 1
}
if (formData && formData.hasOwnProperty('companyList') && vk.pubfn.isNotNull(formData.companyList)) {
// andArr.push({userId: _.in(formData.companyList)})
whereJson.stealFactory = _.in(formData.companyList)
}
if (vk.pubfn.isNotNull(companyList)) {
// andArr.push({userId: _.in(companyList)})
whereJson.stealFactory = _.in(companyList)
}
if (vk.pubfn.isNotNull(cateList)) {
// andArr.push({userId: _.in(companyList)})
if (cateList.length === 1 && cateList[0] === 0) {
whereJson.otherCate = _.exists(true)
whereJson.otherCate = _.neq(null)
}
else whereJson.nameList = _.in(cateList)
}
console.log(whereJson)
if (vk.pubfn.isNotNull(material)) {
// andArr.push({userId: _.in(companyList)})
whereJson.material = _.in(material)
}
// if (vk.pubfn.isNotNull(categoryIds)) {
// whereJson.userId = _.in(categoryIds)
// }
// if (formData && formData.hasOwnProperty('categoryIds') && vk.pubfn.isNotNull(formData.categoryIds)) {
// whereJson.categoryIds = _.in(formData.categoryIds)
// }
// if (vk.pubfn.isNotNull(provinceCodes)) {
// whereJson['address.province.code'] = _.in(provinceCodes)
// }
// const cateFilterList = []
// if (vk.pubfn.isNotNull(cateList)) {
// cateList.forEach(item => {
// cateFilterList.push({
// nameList: item,
// })
// })
// }
res = await vk.baseDao.selects({
dbName,
pageIndex,
pageSize,
getCount: true,
whereJson,
sortArr: [{name: "_add_time", type: "desc"}],
foreignDB: [
{
dbName: "uni-id-users",
localKey: "userId",
foreignKey: "_id",
as: "user",
limit: 1, // limit=1则以对象形式返回
fieldJson: {
_id: true,
company: {
companyName: true
},
person: {
personName: true
},
businessCard: true,
accountType: true,
},
},
{
dbName: "jjx-enquiry-quote",
localKey: "_id",
foreignKey: "sheetId",
as: "quoteList",
limit: 500, // limit=1则以对象形式返回
}
]
});
const rows = res.rows
rows.forEach((row, rowIndex) => {
row.productList.forEach(async (product, productIndex) => {
rows[rowIndex].productList[productIndex].template = await vk.baseDao.findById({
dbName,
id: product.goodsId
});
})
})
res.notPickNum = await vk.baseDao.count({
dbName,
whereJson: {
userId: uid,
status: 0
},
});
res.pickedNum = await vk.baseDao.count({
dbName,
whereJson: {
userId: uid,
status: 1
},
});
res.noQuoteNum = await vk.baseDao.count({
dbName,
whereJson: {
userId: uid,
quoteNum: 0
},
});
res.all = await vk.baseDao.count({
dbName,
whereJson: {
userId: uid,
},
});
res.rows = rows
// 业务逻辑结束-----------------------------------------------------------
return res;
}
}