20261008
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/selfSupport/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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-self-support",
|
||||
dataJson: {...data, ...{status: 0, dealName: ''}}
|
||||
})
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
'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,
|
||||
receiveAddressRegion,
|
||||
email,
|
||||
wechat,
|
||||
receiveAddress,
|
||||
requestName,
|
||||
contactName,
|
||||
contact,
|
||||
remark,
|
||||
} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const configList = await vk.baseDao.select({
|
||||
dbName: "jjx-coop-config",
|
||||
whereJson: {
|
||||
type
|
||||
}
|
||||
})
|
||||
|
||||
let orderId = null
|
||||
const goodsList = []
|
||||
let amount = 0
|
||||
configList.rows.forEach(config => {
|
||||
config.contents.forEach(content => {
|
||||
if (content.amountList) {
|
||||
content.amountList.forEach(amountItem => {
|
||||
amountList.forEach(amountTmp => {
|
||||
const [contentIndex, amountIndex, costNum] = amountTmp.split(',')
|
||||
if (contentIndex === content._index && amountIndex === amountItem._index) {
|
||||
amount += amountItem.amount
|
||||
goodsList.push({
|
||||
goodsName: `${config.name}-${content.title}-${amountItem.title}`,
|
||||
num: contentList.length,
|
||||
goodsPrice: amountItem.amount,
|
||||
goodsCover: null,
|
||||
goodsId: null,
|
||||
costNum,
|
||||
contentIndex,
|
||||
amountIndex,
|
||||
configId: config._id
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
amount *= contentList.length
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 2) {
|
||||
amount = saveAmount = offAmount = offRate = 0
|
||||
}
|
||||
|
||||
orderId = await vk.baseDao.add({
|
||||
dbName: "jjx-order",
|
||||
dataJson: {
|
||||
orderNo: vk.pubfn.createOrderNo("39XU", 20),
|
||||
uid,
|
||||
orderStatus: type === 2 ? 10 : 0,
|
||||
type: 1,
|
||||
subType: type,
|
||||
amount,
|
||||
saveAmount,
|
||||
offAmount,
|
||||
offRate,
|
||||
addressRegion: contentList[0].addressRegion
|
||||
}
|
||||
})
|
||||
|
||||
goodsList.forEach((item, index) => {
|
||||
goodsList[index].orderId = orderId
|
||||
})
|
||||
|
||||
await vk.baseDao.adds({
|
||||
dbName: "jjx-order-goods",
|
||||
dataJson: goodsList
|
||||
})
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-order-selfProduct",
|
||||
dataJson: {
|
||||
orderId,
|
||||
type,
|
||||
receiveAddressRegion,
|
||||
email,
|
||||
wechat,
|
||||
receiveAddress,
|
||||
requestName,
|
||||
contactName,
|
||||
contact,
|
||||
remark,
|
||||
contentList,
|
||||
uid,
|
||||
}
|
||||
})
|
||||
|
||||
if (type < 2) res.data = orderId
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/selfSupport/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, pageIndex, pageSize} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const whereJson = {uid}
|
||||
if (vk.pubfn.isNotNull(data.status)) {
|
||||
whereJson.status = parseInt(data.status)
|
||||
}
|
||||
res = await vk.baseDao.select({
|
||||
dbName: "jjx-self-support",
|
||||
whereJson,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
sortArr: [
|
||||
{name: "_add_time", type: "desc"},
|
||||
],
|
||||
})
|
||||
|
||||
for (let i in res.rows) {
|
||||
const row = res.rows[i]
|
||||
const quoteList = await vk.baseDao.select({
|
||||
dbName: 'jjx-self-support-quote-list',
|
||||
whereJson: {
|
||||
quoteId: row._id
|
||||
},
|
||||
})
|
||||
if (quoteList.rows && quoteList.rows.length > 0) {
|
||||
for (let j = 0; j < quoteList.rows.length; j++){
|
||||
quoteList.rows[j].user = await vk.baseDao.findById({
|
||||
dbName: "uni-id-users",
|
||||
id: quoteList.rows[j].userId
|
||||
})
|
||||
}
|
||||
res.rows[i].quoteList = quoteList.rows
|
||||
}
|
||||
if (row.status === 2) {
|
||||
const quote = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-self-support-quote-list',
|
||||
whereJson: {
|
||||
quoteId: row._id,
|
||||
status: 1
|
||||
}
|
||||
})
|
||||
res.rows[i].quote = quote
|
||||
res.rows[i].otherUser = await vk.baseDao.findById({
|
||||
dbName: "uni-id-users",
|
||||
id: quote.userId,
|
||||
fieldJson: {
|
||||
_id: true,
|
||||
company: true,
|
||||
person: true,
|
||||
businessCard: true,
|
||||
accountType: true,
|
||||
}
|
||||
})
|
||||
|
||||
res.rows[i].contract = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-contract',
|
||||
whereJson: {
|
||||
sheetId: row._id,
|
||||
type: 'self-support',
|
||||
},
|
||||
})
|
||||
}
|
||||
res.rows[i].user = await vk.baseDao.findById({
|
||||
dbName: "uni-id-users",
|
||||
id: res.rows[i].uid,
|
||||
fieldJson: {
|
||||
_id: true,
|
||||
company: true,
|
||||
person: true,
|
||||
businessCard: true,
|
||||
accountType: true,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user