20261008
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* 申请合作
|
||||
* @url client/spot/goods/kh/addCooperate 前端调用的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, company, manager, person, accountType, goodsUserId, goodsId, remark, name, mobile, files} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const checkSheet = await vk.baseDao.findById({
|
||||
dbName: "jjx-spot-goods",
|
||||
id: goodsId
|
||||
})
|
||||
|
||||
if (checkSheet.status > 0) return {
|
||||
code: -1,
|
||||
msg: "该现货已关闭"
|
||||
}
|
||||
|
||||
let info = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-goods-cooperate",
|
||||
whereJson: {
|
||||
userId: uid,
|
||||
goodsId: goodsId
|
||||
}
|
||||
});
|
||||
|
||||
if (info != null) {
|
||||
return {
|
||||
code: -1,
|
||||
msg: '您已经申请过了'
|
||||
}
|
||||
}
|
||||
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "jjx-spot-goods",// 表名
|
||||
id: goodsId,
|
||||
dataJson: {
|
||||
quoteNum: _.inc(1)
|
||||
}
|
||||
});
|
||||
|
||||
for (const cate of checkSheet.categoryIds) {
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "jjx-spot-category",
|
||||
id: cate,
|
||||
dataJson: {
|
||||
quoteNum: _.inc(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 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-goods-cooperate",// 表名
|
||||
dataJson: { // 需要新增的数据 json格式
|
||||
userId: uid,
|
||||
goodsUserId: goodsUserId,
|
||||
goodsId: goodsId,
|
||||
// company,
|
||||
// manager,
|
||||
// person,
|
||||
accountType,
|
||||
status: 0,
|
||||
name,
|
||||
mobile,
|
||||
files,
|
||||
// managerName,
|
||||
// managerMobile,
|
||||
remark
|
||||
}
|
||||
});
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: checkSheet.userId,
|
||||
title: `现货合作申请:${checkSheet.name}`,
|
||||
content: `新的现货合作申请,赶紧去看看吧`,
|
||||
type: 'spot',
|
||||
hasRead: false,
|
||||
pk: checkSheet._id
|
||||
}
|
||||
});
|
||||
await pubFun.sendNotifySms(checkSheet.userId, 'SMS_474305480')
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user