68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
'use strict';
|
|
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, sheet, totalPrice } = data;
|
|
let { company,manager,person,accountType} = userInfo
|
|
let res = { code: 0, msg: "" };
|
|
// 业务逻辑开始-----------------------------------------------------------
|
|
|
|
let subjectName = ''
|
|
let subjectMobile = ''
|
|
let managerName = ''
|
|
let managerMobile = ''
|
|
|
|
if(accountType == 1) {
|
|
subjectName = person.personName
|
|
subjectMobile = person.mobile
|
|
}else {
|
|
subjectName = company.companyName
|
|
subjectMobile = company.legalMobile
|
|
if(manager.mobile && manager.personName){
|
|
managerName = manager.personName
|
|
managerMobile = manager.mobile
|
|
}
|
|
}
|
|
|
|
// 添加报价单
|
|
res.data = await vk.baseDao.add({
|
|
dbName:"jjx-enquiry-quote",// 表名
|
|
dataJson:{ // 需要新增的数据 json格式
|
|
userId: uid,
|
|
productList: sheet.productList,
|
|
sheetId: sheet._id,
|
|
sheetUserId: sheet.userId,
|
|
subjectName,
|
|
subjectMobile,
|
|
managerName,
|
|
managerMobile,
|
|
accountType,
|
|
totalPrice,
|
|
status: 0
|
|
}
|
|
});
|
|
|
|
// 更新用户数据
|
|
|
|
vk.baseDao.update({
|
|
dbName:"jjx-enquiry-sheet",// 表名
|
|
whereJson: {
|
|
_id: sheet._id,
|
|
},
|
|
dataJson: {
|
|
answerNumber: _.inc(1)
|
|
}
|
|
})
|
|
|
|
// 业务逻辑结束-----------------------------------------------------------
|
|
return res;
|
|
}
|
|
}
|