20261008
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
const dbName = 'jjx-enquiry-attributes'
|
||||
module.exports = {
|
||||
/**
|
||||
* 查询现货列表
|
||||
* @url client/spot/goods/kh/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 } = data;
|
||||
let res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const {pageIndex,pageSize,label } = data
|
||||
|
||||
let whereJson = {
|
||||
enable: true,
|
||||
label
|
||||
};
|
||||
|
||||
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName,
|
||||
getCount:false,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
// 主表where条件
|
||||
whereJson: whereJson,
|
||||
// 主表字段显示规则
|
||||
fieldJson:{},
|
||||
// 主表排序规则
|
||||
sortArr:[{ name:"sort", type:"asc" }],
|
||||
|
||||
});
|
||||
|
||||
res.rows.forEach(item => {
|
||||
item.options = item.values.map(citem => {
|
||||
return {
|
||||
label: citem,
|
||||
value: citem
|
||||
}
|
||||
})
|
||||
delete item.values
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
const dbName = 'jjx-enquiry-attributes'
|
||||
module.exports = {
|
||||
/**
|
||||
* 查询现货列表
|
||||
* @url client/spot/goods/kh/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 } = data;
|
||||
let res = { code: 0, msg: "",list: [] };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const {pageIndex,pageSize,label } = data
|
||||
|
||||
let whereJson = {
|
||||
enable: true,
|
||||
label
|
||||
};
|
||||
|
||||
|
||||
|
||||
const info = await vk.baseDao.findByWhereJson({
|
||||
dbName,
|
||||
getCount:false,
|
||||
whereJson: whereJson,
|
||||
});
|
||||
|
||||
if(info != null) {
|
||||
res.list = info.values.map(item => {
|
||||
return {
|
||||
label: item,
|
||||
value: item
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* 查询商品分类列表
|
||||
* @url client/product/category/pub/getAll 前端调用的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, whereJson } = data;
|
||||
let res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
let dbName = "jjx-enquiry-category";
|
||||
res.data = await vk.baseDao.selects({
|
||||
dbName,
|
||||
getMain: true,
|
||||
whereJson,
|
||||
pageSize: -1
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* 查询商品分类列表
|
||||
* @url client/product/category/pub/getAll 前端调用的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 dbName = "jjx-enquiry-category";
|
||||
res = await vk.baseDao.selects({
|
||||
dbName,
|
||||
pageIndex: 1,
|
||||
pageSize: 500,
|
||||
whereJson: {
|
||||
parent_id: _.in([null, ""]),
|
||||
_id: _.exists(true)
|
||||
},
|
||||
sortArr: [{name: "sort", type: "asc"}],
|
||||
// 树状结构参数
|
||||
treeProps: {
|
||||
id: "_id", // 唯一标识字段,默认为 _id
|
||||
parent_id: "parent_id", // 父级标识字段,默认为 parent_id
|
||||
children: "children", // 自定义返回的下级字段名,默认为 children
|
||||
level: 3, // 查询返回的树的最大层级。超过设定层级的节点不会返回。默认10级,最大15,最小1
|
||||
limit: 500, // 每一级最大返回的数据。
|
||||
whereJson: {}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* 获取我的合同列表
|
||||
* @url client/enquiry/contract/kh/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 } = data;
|
||||
let res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.getTableData({
|
||||
dbName: 'jjx-contract',
|
||||
data
|
||||
})
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
'use strict';
|
||||
const dayjs = require("dayjs");
|
||||
var isBetween = require('dayjs/plugin/isBetween')
|
||||
dayjs.extend(isBetween)
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* 新增报价
|
||||
* @url client/enquiry/quote/kh/addQuote 前端调用的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, totalPrice} = data;
|
||||
let {company, manager, person, accountType} = userInfo
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
let noQuoteNo = false
|
||||
if (parseInt(userInfo.userLevel) < 3) {
|
||||
if (parseInt(userInfo.remainQuoteNum) === 0 || !userInfo.remainQuoteNum) {
|
||||
const checkSheetQuoteNum = await vk.baseDao.findById({
|
||||
dbName: "jjx-enquiry-sheet",
|
||||
id: data.sheetId
|
||||
})
|
||||
if (checkSheetQuoteNum.quoteAmount) {
|
||||
const checkQuoteNum = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-user-quote-num",
|
||||
whereJson: {
|
||||
uid,
|
||||
type: 'enquiry',
|
||||
sheetId: data.sheetId,
|
||||
}
|
||||
});
|
||||
if (!checkQuoteNum || checkQuoteNum.num === 0) noQuoteNo = true
|
||||
} else noQuoteNo = true
|
||||
}
|
||||
noQuoteNo = !!(userInfo.quoteExpiredAt && dayjs(userInfo.quoteExpiredAt).isBefore(dayjs()));
|
||||
}
|
||||
if (noQuoteNo) {
|
||||
return {
|
||||
code: 1,
|
||||
msg: "您的报价次数已过期/用完"
|
||||
}
|
||||
}
|
||||
if (userInfo.remainQuoteNum && userInfo.remainQuoteNum > 0) {
|
||||
await vk.baseDao.update({
|
||||
dbName: "uni-id-users",
|
||||
whereJson: {
|
||||
uid
|
||||
},
|
||||
dataJson: {
|
||||
remainQuoteNum: _.inc(-1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
let subjectName = ''
|
||||
let subjectMobile = ''
|
||||
let managerName = ''
|
||||
let managerMobile = ''
|
||||
|
||||
const checkSheet = await vk.baseDao.findById({
|
||||
dbName: "jjx-enquiry-sheet",
|
||||
id: data.sheetId
|
||||
})
|
||||
|
||||
if (checkSheet.status > 0) return {
|
||||
code: -1,
|
||||
msg: "此询价单采购商已确认合作方,请您及时查看平台信息发布,及时报价,以免错过商机。"
|
||||
}
|
||||
|
||||
if (checkSheet.earnestMoney && checkSheet.earnestMoney > 0 && checkSheet.earnestMoney > userInfo.paidEnsure) {
|
||||
return {
|
||||
code: 12,
|
||||
msg: "您的保证金不足,请先缴纳保证金"
|
||||
}
|
||||
}
|
||||
|
||||
if (accountType === 1 && person.personName && person.mobile) {
|
||||
subjectName = person.personName
|
||||
subjectMobile = person.mobile
|
||||
} else {
|
||||
subjectName = company.companyName
|
||||
subjectMobile = company.mobile
|
||||
if (manager && manager.mobile && manager.personName) {
|
||||
managerName = manager.personName
|
||||
managerMobile = manager.mobile
|
||||
}
|
||||
}
|
||||
|
||||
// 添加报价单
|
||||
res.data = await vk.baseDao.add({
|
||||
dbName: "jjx-enquiry-quote",// 表名
|
||||
dataJson: { // 需要新增的数据 json格式
|
||||
...data,
|
||||
...{
|
||||
userId: data.uid,
|
||||
status: 0,
|
||||
subjectName,
|
||||
subjectMobile,
|
||||
managerName,
|
||||
managerMobile,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const sheet = await vk.baseDao.updateAndReturn({
|
||||
dbName: "jjx-enquiry-sheet",// 表名
|
||||
whereJson: {
|
||||
_id: data.sheetId,
|
||||
},
|
||||
dataJson: {
|
||||
quoteNum: _.inc(1)
|
||||
}
|
||||
})
|
||||
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "uni-id-users",// 表名
|
||||
id: data.uid,
|
||||
dataJson: {
|
||||
quoteTimes: _.inc(1)
|
||||
}
|
||||
})
|
||||
|
||||
const checkMessage = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-message-config",
|
||||
whereJson: {
|
||||
enquiry: true,
|
||||
uid: sheet.userId
|
||||
}
|
||||
})
|
||||
|
||||
if (checkMessage) {
|
||||
let send = true
|
||||
// if (checkMessage.doNotDisturbRange && checkMessage.doNotDisturbRange[0]) {
|
||||
// const date = dayjs().format("YYYY-MM-DD")
|
||||
// const doNotDisturbRangeStart = dayjs(checkMessage.doNotDisturbRange[0]).format("HH:mm")
|
||||
// const doNotDisturbRangeEnd = dayjs(checkMessage.doNotDisturbRange[1]).format("HH:mm")
|
||||
// if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
// send = false
|
||||
// }
|
||||
const date = dayjs().format("YYYY-MM-DD")
|
||||
if (checkMessage.doNotDisturbStart && checkMessage.doNotDisturbStart.length) {
|
||||
const doNotDisturbRangeStart = dayjs(`${date} ${checkMessage.doNotDisturbStart[0]}:${checkMessage.doNotDisturbStart[1]}`).format("HH:mm")
|
||||
const doNotDisturbRangeEnd = dayjs(`${date} ${checkMessage.doNotDisturbEnd[0]}:${checkMessage.doNotDisturbEnd[1]}`).format("HH:mm")
|
||||
if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
send = false
|
||||
}
|
||||
|
||||
if (checkMessage.tradeAmount && checkMessage.tradeAmount[0]) {
|
||||
if (sheet.totalPrice < checkMessage.tradeAmount[0] || sheet.totalPrice > checkMessage.tradeAmount[1])
|
||||
send = false
|
||||
}
|
||||
if (send) {
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: sheet.userId,
|
||||
title: `找供应:${sheet.title}报价`,
|
||||
content: `您的找供应信息有新的报价,赶紧去看看吧`,
|
||||
type: 'enquiry',
|
||||
hasRead: false,
|
||||
pk: data.sheetId
|
||||
}
|
||||
});
|
||||
await pubFun.sendNotifySms(sheet.userId, 'SMS_493290524')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,493 @@
|
||||
'use strict';
|
||||
|
||||
const dbName = require('../../../../../dao/config.js')
|
||||
const dayjs = require("dayjs");
|
||||
var isBetween = require('dayjs/plugin/isBetween')
|
||||
dayjs.extend(isBetween)
|
||||
|
||||
const PROCESS_PAY_METHOD = ['预付', '货到验收后付款', '提货付全款', '信誉采购,货到签单后账期:']
|
||||
const WRITE_INVOICE_TIME = ['付款当月(限20号之前付款,20号之后付款次月开票)', '付款后次月', '付款前']
|
||||
const INVOICE_TYPE = ['增值税专用发票13%', '增值税普通发票', '普通发票']
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* 同意合作
|
||||
* @url client/enquiry/quote/kh/confirmQuote 前端调用的url参数地址
|
||||
* data 请求参数
|
||||
* @param {String} params1 参数1
|
||||
*/
|
||||
main: async (event) => {
|
||||
let {
|
||||
data = {}, userInfo, util, filterResponse, originalParam
|
||||
} = event;
|
||||
let {
|
||||
pubFun,
|
||||
vk,
|
||||
} = util;
|
||||
let {
|
||||
uid,
|
||||
quoteId
|
||||
} = data;
|
||||
let res = {
|
||||
code: 0,
|
||||
msg: ""
|
||||
};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
// 修改报价单状态
|
||||
const quote = await vk.baseDao.updateAndReturn({
|
||||
dbName: 'jjx-enquiry-quote',
|
||||
whereJson: {
|
||||
_id: quoteId,
|
||||
status: 0
|
||||
},
|
||||
dataJson: {
|
||||
status: 1,
|
||||
}
|
||||
})
|
||||
|
||||
if (!quote) {
|
||||
return {
|
||||
code: -1,
|
||||
msg: '请刷新页面'
|
||||
}
|
||||
}
|
||||
// 获取乙方信息
|
||||
const quoteUser = await vk.baseDao.select({
|
||||
dbName: dbName.user,
|
||||
getMain: true,
|
||||
getOne: true,
|
||||
whereJson: {
|
||||
_id: quote.userId
|
||||
}
|
||||
})
|
||||
|
||||
// 获取询价单信息
|
||||
const sheet = await vk.baseDao.updateAndReturn({
|
||||
dbName: dbName.enquirySheet,
|
||||
whereJson: {_id: quote.sheetId},
|
||||
dataJson: {
|
||||
otherUid: quote.userId,
|
||||
status: 1
|
||||
}
|
||||
})
|
||||
|
||||
const checkMessage = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-message-config",
|
||||
whereJson: {
|
||||
enquiry: true,
|
||||
uid: quote.userId
|
||||
}
|
||||
})
|
||||
|
||||
if (checkMessage) {
|
||||
let send = true
|
||||
// if (checkMessage.doNotDisturbRange && checkMessage.doNotDisturbRange[0]) {
|
||||
// const date = dayjs().format("YYYY-MM-DD")
|
||||
// const doNotDisturbRangeStart = dayjs(checkMessage.doNotDisturbRange[0]).format("HH:mm")
|
||||
// const doNotDisturbRangeEnd = dayjs(checkMessage.doNotDisturbRange[1]).format("HH:mm")
|
||||
// if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
// send = false
|
||||
// }
|
||||
const date = dayjs().format("YYYY-MM-DD")
|
||||
if (checkMessage.doNotDisturbStart && checkMessage.doNotDisturbStart.length) {
|
||||
const doNotDisturbRangeStart = dayjs(`${date} ${checkMessage.doNotDisturbStart[0]}:${checkMessage.doNotDisturbStart[1]}`).format("HH:mm")
|
||||
const doNotDisturbRangeEnd = dayjs(`${date} ${checkMessage.doNotDisturbEnd[0]}:${checkMessage.doNotDisturbEnd[1]}`).format("HH:mm")
|
||||
if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
send = false
|
||||
}
|
||||
|
||||
if (send) {
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: quote.userId,
|
||||
title: `找买家:${sheet.title}被选商`,
|
||||
content: `您报价的找买家信息已被选商,赶紧去签合同吧`,
|
||||
type: 'contract',
|
||||
hasRead: false,
|
||||
pk: data.sheetId
|
||||
}
|
||||
});
|
||||
await pubFun.sendNotifySms(quote.userId, 'SMS_474250536')
|
||||
}
|
||||
}
|
||||
|
||||
// 获取商品信息
|
||||
const otherCate = sheet.otherCate ? String(sheet.otherCate).trim() : ''
|
||||
const sheetProductList = otherCate ? [{
|
||||
goodsName: otherCate,
|
||||
procureNumber: sheet.procureNumber,
|
||||
procureUnit: sheet.procureUnit,
|
||||
}] : (Array.isArray(sheet.productList) ? sheet.productList : [])
|
||||
const productTitle = sheetProductList.map(item => item.goodsName).filter(Boolean).join("/") || sheet.title
|
||||
|
||||
if (sheet.signMethod !== 1) {
|
||||
const fadadaContractId = vk.pubfn.createOrderNo("E", 20)
|
||||
// 上传合同模板并填充
|
||||
|
||||
// 新增合同记录
|
||||
let 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: 'enquiry',
|
||||
quoteId: quoteId,
|
||||
sheetId: quote.sheetId,
|
||||
productList: sheetProductList,
|
||||
productTitle,
|
||||
tradeMethod: sheet.tradeMethod,
|
||||
partyCount: 2,
|
||||
signCount: 0,
|
||||
contractType: sheet.contractType,
|
||||
signMethod: sheet.signMethod,
|
||||
sellerSupplement: sheet.sellerSupplement,
|
||||
transactionId: contractTransactionId,
|
||||
amount: quote.totalPrice,
|
||||
docTitle: productTitle
|
||||
}
|
||||
})
|
||||
|
||||
// await vk.baseDao.updateById({
|
||||
// dbName: 'jjx-enquiry-sheet',
|
||||
// id: quote.sheetId,
|
||||
// dataJson: {
|
||||
// status: 1
|
||||
// }
|
||||
// })
|
||||
// await vk.baseDao.updateById({
|
||||
// dbName: 'jjx-enquiry-quote',
|
||||
// id: quoteId,
|
||||
// dataJson: {
|
||||
// status: 1
|
||||
// }
|
||||
// })
|
||||
|
||||
// 上传合同模板
|
||||
|
||||
//新增 用户与合同的关联记录
|
||||
await vk.daoCenter.userContractDao.adds([
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("E", 20),
|
||||
userId: quote.userId,
|
||||
role: 'seller',
|
||||
sign: false,
|
||||
contractId
|
||||
},
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("E", 20),
|
||||
userId: uid,
|
||||
role: 'buyer',
|
||||
sign: false,
|
||||
contractId
|
||||
}
|
||||
])
|
||||
|
||||
if (sheet.signMethod === 0) {
|
||||
const templateId = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '80e3bed065a5560e075799d24532b14f'
|
||||
})
|
||||
const buyerKeyword = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '0b153f9a65a56a2007227cf5157133bf'
|
||||
})
|
||||
const sellerKeyword = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '09e7876865a56a320731cb244bbef818'
|
||||
})
|
||||
const signMaxDate = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '657d78958b0da41d311bd94c'
|
||||
})
|
||||
const signEndDate = vk.pubfn.getOffsetTime(new Date(), {
|
||||
day: parseInt(signMaxDate.content),
|
||||
mode: "after",
|
||||
});
|
||||
// const fieldList = await vk.baseDao.select({
|
||||
// dbName: 'jjx-contract-template',
|
||||
// whereJson: {
|
||||
// isOn: true
|
||||
// }
|
||||
// })
|
||||
const sellerUser = await vk.baseDao.findById({
|
||||
dbName: 'uni-id-users',
|
||||
id: quote.userId
|
||||
})
|
||||
const buyerUser = await vk.baseDao.findById({
|
||||
dbName: 'uni-id-users',
|
||||
id: uid
|
||||
})
|
||||
|
||||
const sellerUserBank = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-account',
|
||||
whereJson: {
|
||||
uid: quote.userId,
|
||||
isDefault: true
|
||||
}
|
||||
})
|
||||
const buyerUserBank = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-account',
|
||||
whereJson: {
|
||||
uid: uid,
|
||||
isDefault: true
|
||||
}
|
||||
})
|
||||
|
||||
let tradeInfo = PROCESS_PAY_METHOD[sheet.payMethod]
|
||||
if (sheet.payMethod === 0 && sheet.advancePayRate) tradeInfo += `${sheet.advancePayRate}%货到付全款`
|
||||
if (sheet.payMethod === 3 && sheet.reputationPayDay) tradeInfo += `${sheet.reputationPayDay}天`
|
||||
tradeInfo += `,发票要求:${sheet.invoice ? '含税' : '不含税'},开票时间:` + WRITE_INVOICE_TIME[sheet.writeInvoiceTime]
|
||||
if (sheet.invoiceOther) tradeInfo += `,其他要求:${sheet.invoiceOther ? sheet.invoiceOther : '无'}`
|
||||
else {
|
||||
if (sheet.invoice)
|
||||
tradeInfo += `,纳税人身份:${sheet.taxType},发票种类:${sheet.invoiceType},税率:${sheet.taxRate}`
|
||||
}
|
||||
let expressRequire = ''
|
||||
expressRequire += `随货资料:${sheet.transportDocuments.join()},其他要求:${sheet.otherTransportDocuments ? sheet.otherTransportDocuments : '无'}${sheet.transportLimit ? '' : ',运输限制要求:无'}`
|
||||
if (sheet.transportLimit && sheet.otherTransportRequest) expressRequire += `,运输限制说明:${sheet.otherTransportRequest}`
|
||||
let detail = ''
|
||||
if (sheet.fillType === 0) {
|
||||
sheet.productList.forEach((item, index) => {
|
||||
detail += `${item.goodsName}(${item.procureNumber}${item.procureUnit})`
|
||||
if (item.deliverService) detail += ` ,${item.deliverService}`
|
||||
if (item.pricingForm) detail += ` ,${item.pricingForm}`
|
||||
if (item.loadPaidBy) detail += ` ,${item.loadPaidBy}`
|
||||
item.model.forEach((model) => {
|
||||
detail += `,${model.label}:${model.value}`
|
||||
})
|
||||
if (index < sheet.productList.length - 1) detail += '\r\n'
|
||||
})
|
||||
} else {
|
||||
detail = productTitle
|
||||
}
|
||||
let info = sheet.remark ? `其他要求:${sheet.remark}` : ''
|
||||
if (quote.remark) {
|
||||
if (info) info += `,${quote.remark}`
|
||||
else info = quote.remark
|
||||
}
|
||||
if (info === '') info = '无'
|
||||
|
||||
const accountType = sheet.invoice ? 'company' : 'person'
|
||||
const buyerBank = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-account",
|
||||
whereJson: {
|
||||
uid: buyerUser._id,
|
||||
type: accountType
|
||||
}
|
||||
})
|
||||
let buyerBankName = buyerUser.accountType === 2 ? buyerUser.company.companyBankName : buyerUser.person.personBankName
|
||||
let buyerAccount = buyerUser.accountType === 2 ? buyerUser.company.companyAccount : buyerUser.person.personAccount
|
||||
let buyerBankAccountName = buyerUser.accountType === 2 ? buyerUser.company.companyAccount : buyerUser.person.personAccount
|
||||
let sellerBankName = sellerUser.accountType === 2 ? sellerUser.company.companyBankName : sellerUser.person.personBankName
|
||||
let sellerAccount = sellerUser.accountType === 2 ? sellerUser.company.companyAccount : sellerUser.person.personAccount
|
||||
let sellerBankAccountName = sellerUser.accountType === 2 ? sellerUser.company.companyAccount : sellerUser.person.personAccount
|
||||
if (buyerBank) {
|
||||
buyerBankName = buyerBank.bankName
|
||||
buyerAccount = buyerBank.account
|
||||
buyerBankAccountName = buyerBank.accountName
|
||||
}
|
||||
const sellerBank = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-account",
|
||||
whereJson: {
|
||||
uid: sellerUser._id,
|
||||
type: accountType
|
||||
}
|
||||
})
|
||||
if (sellerBank) {
|
||||
sellerBankName = sellerBank.bankName
|
||||
sellerAccount = sellerBank.account
|
||||
sellerBankAccountName = sellerBank.accountName
|
||||
}
|
||||
|
||||
const parameter = {
|
||||
seller: sellerUser.accountType === 2 ? sellerUser.company.companyName : sellerUser.person.personName,
|
||||
buyer: buyerUser.accountType === 2 ? buyerUser.company.companyName : buyerUser.person.personName,
|
||||
date: dayjs().format('YYYY年MM月DD日'),
|
||||
sellerSignDate: dayjs(signEndDate).format('YYYY年MM月DD日 HH时mm分'),
|
||||
buyerSignDate: dayjs(signEndDate).format('YYYY年MM月DD日 HH时mm分'),
|
||||
// time: dayjs().format('HH:mm'),
|
||||
contractNo: fadadaContractId,
|
||||
region: sheet.addressRegion.province.name + sheet.addressRegion.city.name + sheet.addressRegion.area.name,
|
||||
detail,
|
||||
info,
|
||||
// content: '无',
|
||||
tradeInfo,
|
||||
expressRequire,
|
||||
defaultDuty: '1.乙方所交产品品种、型号、规格、质量不符合规定的,如果甲方同意利用,应当按质论价;如果甲方不能利用的,应根据产品的具体情况,由乙方负责包换或包修,并承担修理、调换或退货而支付的实际费用;2.乙方不予供货违约责任为甲方的实际损失+违约金,如乙方材料符合订货标准,甲方不能退货和不收货,甲方无条件应按实际本合同订货数量支付100%货款,并支付乙方因此产生的实际费用。带有甲乙双方单位相关收货人和发货人签字的本合同的发货清单事项和内容均视为本合同的补充合同,与本合同有相同的法律效力,双方应共同遵照执行。',
|
||||
solve: '1、凡因本合同引起的或与本合同有关的任何争议,均可友好协商或仲裁解决,协商或仲裁不成的,双方协商同意在合同签订地人民法院管辖地起诉,违约一方或对合同争议承担主要责任的一方,应承担对方因仲裁和起诉而产生的全部律师代理费、鉴定(检验)费、诉讼保全费、诉讼保险费、公告费、差旅费、执行费、误工費和获取证据产生费用等其他相关费用。2、双方本合同相关权利放弃均应有双方书面作出并加盖公章或授权委托人签字后生效。',
|
||||
forceMajeure: '甲乙双方的任何一方由于不可抗力或突发公共事件的原因不能履行合同时,应及时向对方通报不能履行或不能完全履行的理由,以减轻可能给对方造成的损失,在取得有关机构证明以后,允许延期履行、部分履行或者不履行合同,并根据情况可部分或全部免予承担违约责任。',
|
||||
other: '本合同的全部内容由双方平等共同协商一致,共同起草制定,非一方事先拟定,不属于格式条款。本合同自双方签字盖章后生效(包括电子签字、盖章),按本合同内容地址、联系方式寄送的一切文书、函件送达与否,均为视为送达有法律效力,通知途径和本合同内联系方式或地址送达文件双方均予以验证。',
|
||||
buyerSupplement: sheet.supplementary ? sheet.supplementary : '无',
|
||||
sellerSupplement: quote.supplierExt ? quote.supplierExt : '无',
|
||||
buyerAddress: buyerUser.accountType === 2 ? buyerUser.company.mailAddress : buyerUser.person.address,
|
||||
sellerAddress: sellerUser.accountType === 2 ? sellerUser.company.mailAddress : sellerUser.person.address,
|
||||
buyerLegal: buyerUser.accountType === 2 ? buyerUser.company.legalName : '',
|
||||
sellerLegal: sellerUser.accountType === 2 ? sellerUser.company.legalName : '',
|
||||
// buyerAgent: buyerUser.accountType === 2 ? buyerUser.manager.personName : '',
|
||||
buyerAgent: sheet.businessName,
|
||||
sellerAgent: sellerUser.accountType === 2 ? sellerUser.manager.personName : '',
|
||||
// buyerMobile: buyerUser.accountType === 2 ? buyerUser.manager.mobile : buyerUser.person.mobile,
|
||||
buyerMobile: sheet.businessMobile,
|
||||
sellerMobile: sellerUser.accountType === 2 ? sellerUser.manager.mobile : sellerUser.person.mobile,
|
||||
buyerBankName,
|
||||
sellerBankName,
|
||||
buyerAccount,
|
||||
sellerAccount,
|
||||
buyerBankAccountName,
|
||||
sellerBankAccountName,
|
||||
signName: sheet.signName ? sheet.signName : '',
|
||||
signIdCard: sheet.signIdCard ? sheet.signIdCard : '',
|
||||
}
|
||||
// for (let i = 0; i < fieldList.length; i++) {
|
||||
//
|
||||
// const field = fieldList[i]
|
||||
// parameter[field.field] = ''
|
||||
// }
|
||||
const uploaddocs = await pubFun.fadada('generate_contract.api', {
|
||||
template_id: templateId.content,
|
||||
contract_id: contractTransactionId,
|
||||
parameter_map: JSON.stringify(parameter)
|
||||
})
|
||||
let otherFileResList = []
|
||||
// 存在附件则合并
|
||||
// if (sheet.files && sheet.files.length > 0) {
|
||||
// for (let i = 0; i < sheet.files.length; i++) {
|
||||
// otherFileResList.push(contractTransactionId + i.toString())
|
||||
// await pubFun.fadada('uploaddocs.api', {
|
||||
// contract_id: contractTransactionId + i.toString(),
|
||||
// doc_title: sheet.title + `:附件${i + 1}`,
|
||||
// doc_url: sheet.files[i],
|
||||
// doc_type: '.pdf'
|
||||
// })
|
||||
// }
|
||||
// otherFileResList.unshift(contractTransactionId)
|
||||
//
|
||||
// // 合并接口
|
||||
// contractTransactionId = vk.pubfn.createOrderNo("MC", 20)
|
||||
// const mergeRes = await pubFun.fadada('merge_contract.api', {
|
||||
// contract_id: contractTransactionId,
|
||||
// doc_title: sheet.title,
|
||||
// contract_ids: otherFileResList.join()
|
||||
// })
|
||||
// console.log('mergeRes', mergeRes)
|
||||
// console.log('otherFileResList', otherFileResList)
|
||||
// }
|
||||
// 存在附件则合并
|
||||
if (quote.files && quote.files.length > 0) {
|
||||
for (let i = 0; i < quote.files.length; i++) {
|
||||
otherFileResList.push(contractTransactionId + 'qf' + i.toString())
|
||||
await pubFun.fadada('uploaddocs.api', {
|
||||
contract_id: contractTransactionId + 'qf' + i.toString(),
|
||||
doc_title: sheet.title + `:附件${i + 1}`,
|
||||
doc_url: quote.files[i],
|
||||
doc_type: '.pdf'
|
||||
})
|
||||
}
|
||||
otherFileResList.unshift(contractTransactionId)
|
||||
|
||||
// 合并接口
|
||||
contractTransactionId = vk.pubfn.createOrderNo("MC", 20)
|
||||
const mergeRes = await pubFun.fadada('merge_contract.api', {
|
||||
contract_id: contractTransactionId,
|
||||
doc_title: sheet.title,
|
||||
contract_ids: otherFileResList.join()
|
||||
})
|
||||
console.log('quote mergeRes', mergeRes)
|
||||
console.log('quote otherFileResList', otherFileResList)
|
||||
}
|
||||
await vk.baseDao.update({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId
|
||||
},
|
||||
dataJson: {
|
||||
transactionId: contractTransactionId,
|
||||
}
|
||||
})
|
||||
if (parseInt(uploaddocs.code) === 1000) {
|
||||
await vk.baseDao.update({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId,
|
||||
userId: uid
|
||||
},
|
||||
dataJson: {
|
||||
status: 1,
|
||||
docTitle: sheet.title,
|
||||
signEndDate,
|
||||
otherFile: '',
|
||||
contractBase: null,
|
||||
buyerSignKeyword: buyerKeyword.content,
|
||||
sellerSignKeyword: sellerKeyword.content
|
||||
}
|
||||
})
|
||||
// await vk.baseDao.updateAndReturn({
|
||||
// dbName: 'jjx-enquiry-sheet',
|
||||
// whereJson: {
|
||||
// _id: quote.sheetId
|
||||
// },
|
||||
// dataJson: {
|
||||
// status: 2
|
||||
// }
|
||||
// })
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: quote.userId,
|
||||
title: `询价:${sheet.title}待签合同`,
|
||||
content: `您报价的询价信息已创建合同,赶紧去签订合同吧`,
|
||||
type: 'contract',
|
||||
hasRead: false,
|
||||
pk: quote.sheetId
|
||||
}
|
||||
});
|
||||
await pubFun.sendNotifySms(quote.userId, 'SMS_474455034')
|
||||
res.data = uploaddocs.result
|
||||
} else {
|
||||
return {
|
||||
code: -1,
|
||||
msg: uploaddocs.msg
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const orderId = await vk.baseDao.add({
|
||||
dbName: "jjx-order",
|
||||
dataJson: {
|
||||
orderNo: vk.pubfn.createOrderNo("39XU", 20),
|
||||
uid: uid,
|
||||
sellerUid: quote.userId,
|
||||
orderStatus: 0,
|
||||
payStatus: 0,
|
||||
type: 4,
|
||||
amount: quote.totalPrice,
|
||||
offAmount: quote.totalPrice,
|
||||
signMethod: 1,
|
||||
sheetId: quote.sheetId,
|
||||
}
|
||||
})
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-order-goods",
|
||||
dataJson: {
|
||||
orderId,
|
||||
goodsId: null,
|
||||
num: 1,
|
||||
goodsName: productTitle || '询价单',
|
||||
goodsPrice: quote.totalPrice,
|
||||
goodsCover: null,
|
||||
}
|
||||
})
|
||||
}
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* 上传合同
|
||||
* @url client/enquiry/quote/kh/uploadTemplate 前端调用的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, base64 } = data;
|
||||
let res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const file = pubFun.base64ToFile(base64, 'adv.pdf')
|
||||
|
||||
res.data = await pubFun.fadada('upload_template_docs.api', {
|
||||
contract_template_id: vk.pubfn.createOrderNo("Contract", 25),
|
||||
template_name: 'template_name',
|
||||
file: file
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/enquiry/sheet/kh/add 前端调用的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 amountItem, amount, goodsName, id, sheet, isSingleQuote = false
|
||||
if (data.buyQuoteMode === 'single') {
|
||||
switch (data.type) {
|
||||
case 'enquiry' : {
|
||||
sheet = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-enquiry-sheet",
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
}
|
||||
})
|
||||
}
|
||||
break;
|
||||
case 'old' : {
|
||||
sheet = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-old",
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
}
|
||||
})
|
||||
}
|
||||
break;
|
||||
case 'process' : {
|
||||
sheet = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-process-sheet",
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
}
|
||||
})
|
||||
}
|
||||
break;
|
||||
}
|
||||
id = '6587b034466d41a591df881c'
|
||||
amountItem = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id
|
||||
})
|
||||
if (sheet.quoteAmount) {
|
||||
amount = sheet.quoteAmount
|
||||
isSingleQuote = true
|
||||
} else {
|
||||
amount = amountItem.content
|
||||
}
|
||||
goodsName = '单次报价购买'
|
||||
} else {
|
||||
id = data.buyQuoteMode
|
||||
amountItem = await vk.baseDao.findById({
|
||||
dbName: 'jjx-quote-num-config',
|
||||
id
|
||||
})
|
||||
amount = amountItem.amount
|
||||
goodsName = `${amountItem.name}报价购买`
|
||||
}
|
||||
|
||||
let offAmount = amount
|
||||
let saveAmount = 0, offRate = 100
|
||||
if (userInfo.userLevel > 0) {
|
||||
const userLevel = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-user-level",
|
||||
whereJson: {
|
||||
level: userInfo.userLevel
|
||||
}
|
||||
})
|
||||
if (userLevel) {
|
||||
offRate = parseInt(userLevel.valueAddRate)
|
||||
offAmount = (amount * (parseInt(userLevel.valueAddRate) / 100)).toFixed(2)
|
||||
saveAmount = (amount - offAmount).toFixed(2)
|
||||
}
|
||||
}
|
||||
|
||||
const orderId = await vk.baseDao.add({
|
||||
dbName: "jjx-order",
|
||||
dataJson: {
|
||||
orderNo: vk.pubfn.createOrderNo("39XU", 20),
|
||||
uid,
|
||||
orderStatus: 0,
|
||||
type: 7,
|
||||
amount,
|
||||
offAmount,
|
||||
saveAmount,
|
||||
offRate,
|
||||
}
|
||||
})
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-order-goods",
|
||||
dataJson: {
|
||||
orderId,
|
||||
goodsId: id,
|
||||
mode: data.buyQuoteMode === 'single' ? 'single' : 'monthly',
|
||||
num: 1,
|
||||
goodsName,
|
||||
goodsPrice: amount,
|
||||
goodsCover: null,
|
||||
isSingleQuote,
|
||||
sheetId: data.id,
|
||||
type: data.type,
|
||||
}
|
||||
})
|
||||
|
||||
res.data = orderId
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
'use strict';
|
||||
const dayjs = require("dayjs");
|
||||
var isBetween = require('dayjs/plugin/isBetween')
|
||||
dayjs.extend(isBetween)
|
||||
|
||||
const DEFAULT_NOTARY_SERVICE_RATE = 0.1;
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/enquiry/sheet/kh/add 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
// 生成询价编号
|
||||
|
||||
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: '您的名片信息未审核,请耐心等待'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 这里需要把 params1 params2 params3 改成你数据库里允许用户添加的字段
|
||||
let dbName = "jjx-enquiry-sheet";
|
||||
const notaryServiceRate = data.tradeMethod === 1
|
||||
? ((data.notaryServiceRate === undefined || data.notaryServiceRate === null || data.notaryServiceRate === '') ? DEFAULT_NOTARY_SERVICE_RATE : data.notaryServiceRate)
|
||||
: null
|
||||
res.id = await vk.baseDao.add({
|
||||
dbName,
|
||||
dataJson: {
|
||||
...data,
|
||||
...{
|
||||
answerNumber: 0,
|
||||
userId: uid,
|
||||
status: 0,
|
||||
quoteNum: 0,
|
||||
isShow: 0,
|
||||
notaryServiceRate
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
'use strict';
|
||||
const dbName = require("../../../../../dao/config");
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/enquiry/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-enquiry-sheet",
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
},
|
||||
dataJson: {
|
||||
signMethod: 0,
|
||||
status: 1
|
||||
}
|
||||
});
|
||||
|
||||
const quote = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-enquiry-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: 'enquiry',
|
||||
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("E", 20),
|
||||
userId: quote.userId,
|
||||
role: 'seller',
|
||||
sign: false,
|
||||
contractId
|
||||
},
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("E", 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-enquiry-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: dbName.enquirySheet,
|
||||
id:_id
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
'use strict';
|
||||
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, isSeller} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
let dbName = "jjx-enquiry-sheet";
|
||||
|
||||
|
||||
let whereJson = {isShow: 1};
|
||||
|
||||
if (vk.pubfn.isNotNull(keyword)) whereJson.title = new RegExp(keyword)
|
||||
|
||||
if (vk.pubfn.isNotNull(isSeller) && isSeller) whereJson.otherUid = uid
|
||||
else whereJson.userId = uid
|
||||
|
||||
if (vk.pubfn.isNotNull(status) && status !== 'all') {
|
||||
if (status === 'noQuote') {
|
||||
whereJson.quoteNum = 0
|
||||
whereJson.status = 0
|
||||
}
|
||||
else if (status === 'notPick') {
|
||||
whereJson.quoteNum = _.gt(0)
|
||||
whereJson.status = 0
|
||||
}
|
||||
else if (status === 'picked') whereJson.status = _.in([1, 2])
|
||||
}
|
||||
|
||||
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.categoryIds = _.in(formData.categoryIds)
|
||||
}
|
||||
|
||||
// if (vk.pubfn.isNotNull(provinceCodes)) {
|
||||
// whereJson['address.province.code'] = _.in(provinceCodes)
|
||||
// }
|
||||
|
||||
// console.log('whereJson', whereJson)
|
||||
|
||||
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: "uni-id-users",
|
||||
localKey: "otherUid",
|
||||
foreignKey: "_id",
|
||||
as: "otherUser",
|
||||
limit: 1, // limit=1则以对象形式返回
|
||||
fieldJson: {
|
||||
_id: true,
|
||||
company: {
|
||||
companyName: true,
|
||||
mobile: true
|
||||
},
|
||||
person: {
|
||||
personName: true,
|
||||
mobile: true
|
||||
},
|
||||
businessCard: true,
|
||||
accountType: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
dbName: "jjx-enquiry-quote",
|
||||
localKey: "_id",
|
||||
foreignKey: "sheetId",
|
||||
as: "quoteList",
|
||||
limit: 500, // limit=1则以对象形式返回
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const rows = res.rows
|
||||
const rowIds = rows.map(item => item._id)
|
||||
const orderMap = {}
|
||||
if (rowIds.length > 0) {
|
||||
const orderRes = await vk.baseDao.select({
|
||||
dbName: 'jjx-order',
|
||||
whereJson: {
|
||||
sheetId: _.in(rowIds)
|
||||
},
|
||||
sortArr: [{name: "_add_time", type: "desc"}]
|
||||
})
|
||||
if (orderRes && orderRes.rows) {
|
||||
orderRes.rows.forEach(order => {
|
||||
if (!orderMap[order.sheetId]) orderMap[order.sheetId] = order
|
||||
})
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const row = rows[i];
|
||||
row.order = orderMap[row._id] || null
|
||||
for (let j = 0; j < row.productList.length; j++) {
|
||||
const product = rows[i].productList[j]
|
||||
if (product && product.goodsId) {
|
||||
rows[i].productList[j].template = await vk.baseDao.findById({
|
||||
dbName,
|
||||
id: product.goodsId
|
||||
});
|
||||
}
|
||||
}
|
||||
row.contract = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-contract',
|
||||
whereJson: {
|
||||
sheetId: row._id,
|
||||
type: 'enquiry',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
res.notPickNum = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
isShow: 1,
|
||||
userId: uid,
|
||||
status: 0,
|
||||
quoteNum: _.gt(0)
|
||||
},
|
||||
});
|
||||
|
||||
res.pickedNum = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
isShow: 1,
|
||||
userId: uid,
|
||||
status: _.in([1, 2])
|
||||
},
|
||||
});
|
||||
|
||||
res.noQuoteNum = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
isShow: 1,
|
||||
userId: uid,
|
||||
quoteNum: 0,
|
||||
status: 0
|
||||
},
|
||||
});
|
||||
|
||||
res.all = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
isShow: 1,
|
||||
userId: uid,
|
||||
},
|
||||
});
|
||||
|
||||
res.rows = rows
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
const dbName = 'jjx-enquiry-template'
|
||||
module.exports = {
|
||||
/**
|
||||
* 查询现货列表
|
||||
* @url client/spot/goods/kh/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} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const {pageIndex, pageSize} = data
|
||||
|
||||
let whereJson = {
|
||||
enable: true
|
||||
};
|
||||
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName,
|
||||
getCount: false,
|
||||
pageIndex,
|
||||
pageSize: 500,
|
||||
// 主表where条件
|
||||
whereJson: whereJson,
|
||||
// 主表字段显示规则
|
||||
fieldJson: {},
|
||||
// 主表排序规则
|
||||
sortArr: [{name: "sort", type: "asc"}, {"name": "_add_time", "type": "desc"}],
|
||||
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user