17b2d8f117
2、新增用户等级
81 lines
2.5 KiB
JavaScript
81 lines
2.5 KiB
JavaScript
'use strict';
|
|
module.exports = {
|
|
/**
|
|
* XXXnameXXX
|
|
* @url client/selfSupport/kh/addOrder 前端调用的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, contentList, amountList, type} = data;
|
|
let res = {code: 0, msg: ""};
|
|
// 业务逻辑开始-----------------------------------------------------------
|
|
|
|
const configList = await vk.baseDao.select({
|
|
dbName: "jjx-coop-config",
|
|
whereJson: {
|
|
type
|
|
}
|
|
})
|
|
|
|
const goodsList = []
|
|
let amount = 0
|
|
configList.rows.forEach(config => {
|
|
config.contents.forEach(content => {
|
|
if (content.amountList) {
|
|
content.amountList.forEach(amountItem => {
|
|
if (amountList.includes(amountItem._index)) {
|
|
amount += amountItem.amount
|
|
goodsList.push({
|
|
goodsName: `${config.name}-${content.title}-${amountItem.title}`,
|
|
num: 1,
|
|
goodsPrice: amountItem.amount,
|
|
goodsCover: null,
|
|
goodsId: null,
|
|
})
|
|
}
|
|
})
|
|
}
|
|
})
|
|
})
|
|
|
|
const orderId = await vk.baseDao.add({
|
|
dbName: "jjx-order",
|
|
dataJson: {
|
|
orderNo: vk.pubfn.createOrderNo("SP", 20),
|
|
uid,
|
|
orderStatus: 0,
|
|
type: 1,
|
|
amount: amount * contentList.length,
|
|
}
|
|
})
|
|
|
|
goodsList.forEach((item, index) => {
|
|
goodsList[index].orderId = orderId
|
|
})
|
|
|
|
await vk.baseDao.adds({
|
|
dbName: "jjx-order-goods",
|
|
dataJson: goodsList
|
|
})
|
|
|
|
contentList.forEach((item, index) => {
|
|
contentList[index].orderId = orderId
|
|
})
|
|
|
|
console.log('contentList', contentList)
|
|
|
|
await vk.baseDao.adds({
|
|
dbName: "jjx-order-self-product",
|
|
dataJson: contentList
|
|
})
|
|
|
|
res.data = orderId
|
|
|
|
// 业务逻辑结束-----------------------------------------------------------
|
|
return res;
|
|
}
|
|
}
|