71 lines
2.2 KiB
JavaScript
71 lines
2.2 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, totalPrice} = data;
|
|
let {company, manager, person, accountType} = userInfo
|
|
let res = {code: 0, msg: ""};
|
|
// 业务逻辑开始-----------------------------------------------------------
|
|
|
|
const amountItem = await vk.baseDao.findById({
|
|
dbName: 'jjx-dict',
|
|
id: '6587dd54189f86d49b3d5ff5'
|
|
})
|
|
|
|
const amount = amountItem.content
|
|
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: 10,
|
|
amount,
|
|
offAmount,
|
|
saveAmount,
|
|
offRate,
|
|
}
|
|
})
|
|
|
|
await vk.baseDao.add({
|
|
dbName: "jjx-order-goods",
|
|
dataJson: {
|
|
orderId,
|
|
goodsId: null,
|
|
num: 1,
|
|
goodsName: '旧货发布次数购买',
|
|
goodsPrice: amount,
|
|
goodsCover: null,
|
|
}
|
|
})
|
|
|
|
res.data = orderId
|
|
|
|
// 业务逻辑结束-----------------------------------------------------------
|
|
return res;
|
|
}
|
|
}
|