'use strict'; module.exports = { /** * 同意合作 * @url client/enquiry/quote/kh/confirmQuote 前端调用的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, quoteId } = data; let res = { code: 0, msg: "" }; // 业务逻辑开始----------------------------------------------------------- // 修改报价单状态 const quote = await vk.baseDao.updateAndReturn({ dbName: 'jjx-old-quote', whereJson: { _id: quoteId, status: 0 }, dataJson: { status: 1 } }) if (!quote) { return { code: -1, msg: '请刷新页面' } } // 获取乙方信息 const quoteUser = await vk.baseDao.select({ dbName: dbName.user, getMain: true, getOne: true, whereJson: { _id: quote.userId } }) // 获取询价单信息 const sheet = await vk.baseDao.selects({ dbName: 'jjx-old', whereJson: {_id: quote.sheetId}, getMain: true, getOne: true }) // 获取商品信息 const productTitle = sheet.title const fadadaContractId = vk.pubfn.createOrderNo("E", 20) // 上传合同模板并填充 // if(sheet.signMethod == 0 && sheet.contractType == 0) { // pubFun.fadada('generate_contract.api', { // template_id: '20231120', // contract_id: fadadaContractId, // parameter_map: JSON.stringify({ // jiaName: userInfo.accountType == 1?userInfo.person.personName: userInfo.company.companyName, // jiaDate: '', // jiaPhone: '', // yiName: userInfo.accountType == 1?userInfo.person.personName: userInfo.company.companyName, // yiDate: '', // yiPhone: '', // sellerSupplement: '', // }), // }) // } // 新增合同记录 const contractId = await vk.baseDao.add({ dbName: 'jjx-contract', dataJson: { fadadaContractId: fadadaContractId, contractBase: '', // 原始合同 contractHistory: [], // 历史合同 contractFinal: '', // 归档合同 status: 0, userId: uid, type: 'old', quoteId: quoteId, sheetId: quote.sheetId, productList: [], productTitle, tradeMethod: quote.tradeMethod, partyCount: 2, signCount: 0, contractType: sheet.contractType, signMethod: sheet.signMethod, sellerSupplement: sheet.sellerSupplement, transactionId: vk.pubfn.createOrderNo("C", 20), amount: quote.totalPrice, } }) await vk.baseDao.updateById({ dbName: 'jjx-old', id: quote.sheetId, dataJson: { status: 1 } }) await vk.baseDao.updateById({ dbName: 'jjx-old-quote', id: quoteId, dataJson: { status: 1 } }) // 上传合同模板 //新增 用户与合同的关联记录 await vk.daoCenter.userContractDao.adds([ { transactionId: vk.pubfn.createOrderNo("E", 20), userId: uid, role: 'buyer', sign: false, contractId }, { transactionId: vk.pubfn.createOrderNo("E", 20), userId: quote.userId, role: 'seller', sign: false, contractId } ]) // 业务逻辑结束----------------------------------------------------------- return res; } }