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,57 @@
'use strict';
const dbName = require('../../../../../dao/config.js')
const dayjs = require("dayjs");
var isBetween = require('dayjs/plugin/isBetween')
dayjs.extend(isBetween)
module.exports = {
/**
* 新增加工单
* @url client/process/kh/add 前端调用的url参数地址
* data 请求参数
* @param event
*/
main: async (event) => {
let {data = {}, userInfo, util, filterResponse, originalParam} = event;
let {customUtil, uniID, config, pubFun, vk, db, _} = util;
let res = {code: 0, msg: ""};
// 业务逻辑开始-----------------------------------------------------------
if (!userInfo.fadadaConfirm && userInfo.authStatus === 1) {
return {
code: 1,
msg: '请先完成认证'
}
} else if (!userInfo.businessCard) {
return {
code: 1,
msg: '请完善名片信息'
}
} else {
if (userInfo.businessCard.status !== 1) {
return {
code: 1,
msg: '您的名片信息未审核,请耐心等待'
}
}
}
let dbName = "jjx-process-sheet";
res.id = await vk.baseDao.add({
dbName,
dataJson: {
...data,
...{
userId: data.uid,
quoteNum: 0,
status: 0,
isShow: 0,
showInAdmin: 1,
}
}
});
// 业务逻辑结束-----------------------------------------------------------
return res;
}
}
@@ -0,0 +1,156 @@
'use strict';
const dbName = require("../../../../../dao/config");
module.exports = {
/**
* XXXnameXXX
* @url client/process/sheet/kh/changeToOnlineSign 前端调用的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} = data;
let res = {code: 0, msg: ""};
// 业务逻辑开始-----------------------------------------------------------
const sheet = await vk.baseDao.updateAndReturn({
dbName: "jjx-process-sheet",
whereJson: {
_id: data.id
},
dataJson: {
signMethod: 0,
status: 1
}
});
const quote = await vk.baseDao.findByWhereJson({
dbName: "jjx-process-quote",
whereJson: {
sheetId: data.id,
status: 1
}
});
if (quote) {
const fadadaContractId = vk.pubfn.createOrderNo("E", 20)
const contractTransactionId = vk.pubfn.createOrderNo("C", 20)
const contractId = await vk.baseDao.add({
dbName: 'jjx-contract',
dataJson: {
fadadaContractId,
contractBase: '', // 原始合同
contractHistory: [], // 历史合同
contractFinal: '', // 归档合同
status: 0,
userId: uid,
type: 'process',
quoteId: quote.id,
sheetId: quote.sheetId,
productList: quote.productList,
productTitle: sheet.title,
tradeMethod: 0,
partyCount: 2,
signCount: 0,
contractType: sheet.contractType,
signMethod: sheet.signMethod,
sellerSupplement: sheet.sellerSupplement,
transactionId: contractTransactionId,
amount: quote.totalPrice,
docTitle: sheet.title
}
})
// 上传合同模板
//新增 用户与合同的关联记录
await vk.daoCenter.userContractDao.adds([
{
transactionId: vk.pubfn.createOrderNo("P", 20),
userId: quote.userId,
role: 'seller',
sign: false,
contractId
},
{
transactionId: vk.pubfn.createOrderNo("P", 20),
userId: uid,
role: 'buyer',
sign: false,
contractId
}
])
}
// const contractFile = await vk.baseDao.findById({
// dbName: 'jjx-dict',
// id: '657d36befe975f63af1f24e7'
// })
// const signMaxDate = await vk.baseDao.findById({
// dbName: 'jjx-dict',
// id: '657d78958b0da41d311bd94c'
// })
// const buyerSignKeyword = await vk.baseDao.findById({
// dbName: 'jjx-dict',
// id: '657d37972139294200fc9a01'
// })
// const sellerSignKeyword = await vk.baseDao.findById({
// dbName: 'jjx-dict',
// id: '657d37a609664c4f4a5c4afb'
// })
// const signEndDate = vk.pubfn.getOffsetTime(new Date(), {
// day: parseInt(signMaxDate.content),
// mode: "after",
// });
//
// const uploaddocs = await pubFun.fadada('uploaddocs.api', {
// contract_id: contractTransactionId,
// doc_title: sheet.title,
// doc_url: contractFile.content,
// // file: doc_url,
// doc_type: '.pdf'
// })
// if (parseInt(uploaddocs.code) === 1000) {
// await vk.baseDao.updateAndReturn({
// dbName: dbName.contract,
// whereJson: {
// _id: contractId,
// userId: uid
// },
// dataJson: {
// status: 1,
// docTitle: sheet.title,
// signEndDate,
// otherFile: '',
// contractBase: contractFile.content,
// buyerSignKeyword: buyerSignKeyword.content,
// sellerSignKeyword: sellerSignKeyword.content
// }
// })
// await vk.baseDao.updateAndReturn({
// dbName: 'jjx-process-sheet',
// whereJson: {
// _id: data.id
// },
// dataJson: {
// status: 2
// }
// })
//
// res.data = uploaddocs.result
// } else {
// return {
// code: -1,
// msg: uploaddocs.msg
// }
// }
// 业务逻辑结束-----------------------------------------------------------
return res;
}
}
@@ -0,0 +1,28 @@
'use strict';
const dbName = require('../../../../../dao/config.js')
module.exports = {
/**
* XXXnameXXX
* @url client/enquiry/sheet/kh/delete 前端调用的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 } = data;
let res = { code: 0, msg: "" };
// 业务逻辑开始-----------------------------------------------------------
let { _id } = data;
if(vk.pubfn.isNull(_id)){
return { code : -1, msg : 'id不能为空' };
}
await vk.baseDao.deleteById({
dbName: 'jjx-process-sheet',
id:_id
});
// 业务逻辑结束-----------------------------------------------------------
return res;
}
}
@@ -0,0 +1,62 @@
'use strict';
module.exports = {
/**
* 加工详情
* @url client/process/sheet/pub/getInfo 前端调用的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} = data;
let res = {code: 0, msg: ""};
// 业务逻辑开始-----------------------------------------------------------
const dbName = "jjx-process-sheet";
const quoteDbName = "jjx-process-quote";
const userDbName = "uni-id-users";
res = await vk.baseDao.findById({
dbName, id: data.id
})
res.quoteList = await vk.baseDao.selects({
dbName: quoteDbName,
whereJson: {
sheetId: data.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.user = await vk.baseDao.findById({
dbName: userDbName,
id: res.userId
})
// 业务逻辑结束-----------------------------------------------------------
return res;
}
}
@@ -0,0 +1,175 @@
'use strict';
const dbName = require('../../../../../dao/config.js')
module.exports = {
/**
* 获取加工单
* @url client/process/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, userId, pageIndex, pageSize, keyword, categoryIds, provinceCodes, area, formData, status, isUser} = data;
let res = {code: 0, msg: ""};
// 业务逻辑开始-----------------------------------------------------------
const dbName = "jjx-process-sheet";
const whereJson = {isShow: 1};
if (vk.pubfn.isNotNull(keyword)) {
whereJson.title = new RegExp(keyword)
}
if (vk.pubfn.isNotNull(isUser)) {
if (data.otherUid) whereJson.otherUid = data.otherUid;
else whereJson.userId = userId;
} else {
if (vk.pubfn.isNotNull(data.status)) {
whereJson.status = data.status
}else whereJson.status = 0
}
if (formData && formData.hasOwnProperty('companyList') && vk.pubfn.isNotNull(formData.companyList)) {
whereJson.userId = _.in(formData.companyList)
}
if (formData && formData.hasOwnProperty('categoryIds') && vk.pubfn.isNotNull(formData.categoryIds)) {
whereJson.productList = _.in(formData.categoryIds)
}
if (vk.pubfn.isNotNull(categoryIds)) {
whereJson.productList = _.in(categoryIds)
}
if (vk.pubfn.isNotNull(area)) {
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]
} else if (vk.pubfn.isNotNull(provinceCodes)) {
whereJson['addressRegion.province.code'] = _.in(provinceCodes)
}
if (vk.pubfn.isNotNull(status) && status !== 'all') {
if (status === 'noQuote') whereJson.quoteNum = 0
else if (status === 'notPick') whereJson.status = 0
else if (status === 'picked') whereJson.status = 1
}
console.log('where', whereJson)
res = await vk.baseDao.selects({
dbName,
pageIndex,
pageSize,
whereJson,
getCount: true,
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,
},
},
]
});
for (const item of res.rows) {
item.quoteList = await vk.baseDao.selects({
dbName: 'jjx-process-quote',
whereJson: {
sheetId: item._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,
},
}
]
})
item.contract = await vk.baseDao.findByWhereJson({
dbName: 'jjx-contract',
whereJson: {
sheetId: item._id,
type: 'process',
},
})
if (vk.pubfn.isNotNull(isUser)) {
item.otherUser = await vk.baseDao.findByWhereJson({
dbName: 'uni-id-users',
whereJson: {
_id: !data.otherUid ? item.otherUid : item.userId,
}
})
}
}
res.notPickNum = await vk.baseDao.count({
dbName,
whereJson: {
userId: uid,
status: 0,
isShow: 1
},
});
res.pickedNum = await vk.baseDao.count({
dbName,
whereJson: {
userId: uid,
status: 1,
isShow: 1
},
});
res.noQuoteNum = await vk.baseDao.count({
dbName,
whereJson: {
userId: uid,
quoteNum: 0,
isShow: 1
},
});
res.all = await vk.baseDao.count({
dbName,
whereJson: {
userId: uid,
isShow: 1
},
});
// 业务逻辑结束-----------------------------------------------------------
return res;
}
}