feat: 补齐客户端/管理端服务模块与数据库 schema,完善登录短信、法大大签署及公共函数
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/factory/kh/addUpdate 前端调用的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, _id, bankName, accountName, account, type, isDefault} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
if (isDefault) {
|
||||
await vk.baseDao.update({
|
||||
dbName: 'jjx-account',
|
||||
whereJson: {
|
||||
uid
|
||||
},
|
||||
dataJson: {
|
||||
isDefault: false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(_id)) {
|
||||
await vk.baseDao.update({
|
||||
dbName: 'jjx-account',
|
||||
whereJson: {
|
||||
_id,
|
||||
uid
|
||||
},
|
||||
dataJson: {
|
||||
bankName, accountName, account, type, isDefault
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const check = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-account',
|
||||
whereJson: {
|
||||
uid,
|
||||
account
|
||||
}
|
||||
})
|
||||
if (check) {
|
||||
res.code = -1;
|
||||
res.msg = '账户已存在';
|
||||
return res;
|
||||
}
|
||||
const count = await vk.baseDao.count({
|
||||
dbName: 'jjx-account',
|
||||
whereJson: {
|
||||
uid
|
||||
}
|
||||
})
|
||||
if (count === 0) isDefault = true
|
||||
await vk.baseDao.add({
|
||||
dbName: 'jjx-account',
|
||||
dataJson: {
|
||||
uid,
|
||||
bankName, accountName, account, type, isDefault
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/factory/kh/addUpdate 前端调用的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, _id} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const info = await vk.baseDao.findById({
|
||||
dbName: "jjx-account",
|
||||
id: _id
|
||||
})
|
||||
await vk.baseDao.del({
|
||||
dbName: "jjx-account",
|
||||
whereJson: {
|
||||
uid, _id
|
||||
}
|
||||
});
|
||||
|
||||
if (info.isDefault) {
|
||||
const firstOne = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-account",
|
||||
whereJson: {
|
||||
uid
|
||||
}
|
||||
})
|
||||
if (firstOne) {
|
||||
await vk.baseDao.update({
|
||||
dbName: "jjx-account",
|
||||
whereJson:{
|
||||
_id: firstOne._id
|
||||
},
|
||||
dataJson: {
|
||||
isDefault: true
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/factory/kh/addUpdate 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName: "jjx-account",
|
||||
whereJson: {
|
||||
uid
|
||||
}
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url admin/article/category/sys/list 前端调用的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, adKey} = data;
|
||||
let res = {code: 0, msg: "", data: null};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const ad = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-ad',
|
||||
whereJson: {adKey},
|
||||
});
|
||||
if (ad) {
|
||||
res.data = ad
|
||||
}
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
// return res;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url admin/article/category/sys/list 前端调用的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,
|
||||
adKey,
|
||||
region,
|
||||
spotGoodsId,
|
||||
categoryId,
|
||||
categoryIds,
|
||||
categoryName,
|
||||
categoryNames,
|
||||
} = data;
|
||||
let res = {code: 0, msg: "", data: null};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const baseWhereJson = {adKey};
|
||||
const categoryFilterAdKeys = [9, 10, 11, 12, 13, 14, 112, 122];
|
||||
let whereJson = {adKey};
|
||||
const emptyToNull = value => (value === '' || value === undefined || value === null) ? null : value
|
||||
const appendRegionWhere = (target, provinceCode, cityCode, areaCode) => {
|
||||
if (areaCode) {
|
||||
target['region.area.code'] = areaCode;
|
||||
} else if (cityCode) {
|
||||
target['region.city.code'] = cityCode;
|
||||
} else if (provinceCode) {
|
||||
target['region.province.code'] = provinceCode;
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
if (!vk.pubfn.isNull(spotGoodsId)) {
|
||||
whereJson = {
|
||||
...baseWhereJson,
|
||||
spotGoodsId
|
||||
};
|
||||
} else {
|
||||
let provinceCode = null
|
||||
let cityCode = null
|
||||
let areaCode = null
|
||||
const categoryIdList = Array.isArray(categoryIds) ? categoryIds.filter(Boolean) : (vk.pubfn.isNotNull(categoryId) ? [categoryId] : [])
|
||||
const categoryNameList = Array.isArray(categoryNames) ? categoryNames.filter(Boolean) : (vk.pubfn.isNotNull(categoryName) ? [categoryName] : [])
|
||||
const categoryWhereList = []
|
||||
|
||||
if (!vk.pubfn.isNull(region)) {
|
||||
if (typeof region === 'string' || typeof region === 'number') {
|
||||
provinceCode = region
|
||||
} else if (Array.isArray(region)) {
|
||||
provinceCode = emptyToNull(region[0])
|
||||
cityCode = emptyToNull(region[1])
|
||||
areaCode = emptyToNull(region[2])
|
||||
} else if (typeof region === 'object') {
|
||||
provinceCode = emptyToNull(region.provinceCode || (region.province && region.province.code) || region.province)
|
||||
cityCode = emptyToNull(region.cityCode || (region.city && region.city.code) || region.city)
|
||||
areaCode = emptyToNull(region.areaCode || (region.area && region.area.code) || region.area)
|
||||
}
|
||||
}
|
||||
|
||||
const hasRegion = !!(provinceCode || cityCode || areaCode)
|
||||
const hasCategoryFilter = categoryIdList.length > 0 || categoryNameList.length > 0
|
||||
|
||||
if (hasRegion && categoryIdList.length > 0) {
|
||||
categoryWhereList.push(appendRegionWhere({
|
||||
...baseWhereJson,
|
||||
filterMode: 'category',
|
||||
categoryId: _.in(categoryIdList)
|
||||
}, provinceCode, cityCode, areaCode))
|
||||
categoryWhereList.push(appendRegionWhere({
|
||||
...baseWhereJson,
|
||||
filterMode: 'category',
|
||||
categoryIds: _.in(categoryIdList)
|
||||
}, provinceCode, cityCode, areaCode))
|
||||
}
|
||||
|
||||
if (hasRegion && categoryNameList.length > 0) {
|
||||
categoryWhereList.push(appendRegionWhere({
|
||||
...baseWhereJson,
|
||||
filterMode: 'category',
|
||||
categoryName: _.in(categoryNameList)
|
||||
}, provinceCode, cityCode, areaCode))
|
||||
categoryWhereList.push(appendRegionWhere({
|
||||
...baseWhereJson,
|
||||
filterMode: 'category',
|
||||
categoryNames: _.in(categoryNameList)
|
||||
}, provinceCode, cityCode, areaCode))
|
||||
}
|
||||
|
||||
if (categoryFilterAdKeys.includes(parseInt(adKey)) && (hasRegion || categoryWhereList.length > 0)) {
|
||||
const whereJsonList = []
|
||||
if (hasRegion) {
|
||||
const regionWhereJson = {
|
||||
...baseWhereJson,
|
||||
filterMode: _.or(_.eq('region'), _.exists(false))
|
||||
}
|
||||
|
||||
appendRegionWhere(regionWhereJson, provinceCode, cityCode, areaCode)
|
||||
whereJsonList.push(regionWhereJson)
|
||||
}
|
||||
whereJsonList.push(...categoryWhereList)
|
||||
whereJson = whereJsonList.length === 1 ? whereJsonList[0] : _.or(whereJsonList)
|
||||
} else if (hasRegion) {
|
||||
whereJson = {...baseWhereJson}
|
||||
appendRegionWhere(whereJson, provinceCode, cityCode, areaCode)
|
||||
} else if (categoryFilterAdKeys.includes(parseInt(adKey)) && hasCategoryFilter) {
|
||||
whereJson = {
|
||||
...baseWhereJson,
|
||||
filterMode: _.or(_.eq('region'), _.exists(false))
|
||||
}
|
||||
} else {
|
||||
whereJson = baseWhereJson
|
||||
}
|
||||
}
|
||||
console.log('whereJson', whereJson)
|
||||
const ad = await vk.baseDao.select({
|
||||
dbName: 'jjx-ad',
|
||||
whereJson,
|
||||
});
|
||||
res.data = ad.rows
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
module.exports = {
|
||||
main: async (event) => {
|
||||
let { data = {}, userInfo } = event;
|
||||
|
||||
const COZE_TOKEN = 'sat_OiXlI4Da5Q99fxmul6pNfExmA6hR898UbxBDwrvjZ638APxRSlFnXbz6zyFedKNG';
|
||||
// 从前端传入 bot_id,不同项目用不同智能体
|
||||
const BOT_ID = data.bot_id || '7680345813062680618';
|
||||
|
||||
const res = await uniCloud.httpclient.request('https://api.coze.cn/v3/chat', {
|
||||
method: 'POST',
|
||||
dataType: 'text',
|
||||
contentType: 'json',
|
||||
timeout: 120000,
|
||||
headers: { 'Authorization': 'Bearer ' + COZE_TOKEN },
|
||||
data: {
|
||||
bot_id: BOT_ID,
|
||||
user_id: (userInfo && userInfo.uid) || 'anonymous',
|
||||
stream: true,
|
||||
auto_save_history: true,
|
||||
additional_messages: [{
|
||||
role: 'user',
|
||||
content: data.message,
|
||||
content_type: 'text'
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
let answer = '';
|
||||
let conversationId = '';
|
||||
const text = res.data || '';
|
||||
const lines = text.split('\n');
|
||||
for (const line of lines) {
|
||||
if (!line.startsWith('data:')) continue;
|
||||
const d = line.slice(5).trim();
|
||||
if (d === '[DONE]' || d === '"[DONE]"') continue;
|
||||
try {
|
||||
const p = JSON.parse(d);
|
||||
if (p.conversation_id) conversationId = p.conversation_id;
|
||||
if (p.type === 'answer' && p.content) {
|
||||
answer += p.content; // 拼接,不是覆盖
|
||||
}
|
||||
} catch (e) { /* 跳过 */ }
|
||||
}
|
||||
if (!answer) answer = '暂时无法回复,请拨打 400-686-5559 咨询';
|
||||
|
||||
return {
|
||||
code: 0,
|
||||
msg: 'ok',
|
||||
data: { answer, conversation_id: conversationId }
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
// client/ai/pub/doReviewTimer.js
|
||||
module.exports = {
|
||||
main: async (event) => {
|
||||
let { data = {} } = event;
|
||||
const { record_id, file_id, user_id, file_name, file_size } = data;
|
||||
|
||||
if (!record_id || !file_id) return { code: -1, msg: '参数错误' };
|
||||
|
||||
const db = uniCloud.database();
|
||||
|
||||
// 检查是否已经在审查中(防止重复触发)
|
||||
const record = await db.collection('jjx-review-records').doc(record_id).get();
|
||||
if (record.data.length && record.data[0].status === 'reviewing') {
|
||||
// 检查是否刚触发(5分钟内不重复触发)
|
||||
const lastUpdate = record.data[0].update_time;
|
||||
if (lastUpdate && (Date.now() - new Date(lastUpdate).getTime() < 5 * 60 * 1000)) {
|
||||
return { code: 0, msg: '已在审查中,跳过' };
|
||||
}
|
||||
}
|
||||
|
||||
// 更新状态为审查中
|
||||
await db.collection('jjx-review-records').doc(record_id).update({
|
||||
status: 'reviewing',
|
||||
review_started_at: new Date(),
|
||||
update_time: new Date()
|
||||
});
|
||||
|
||||
// 调用实际的审查逻辑
|
||||
try {
|
||||
const doReview = require('./jjxDoReview.js');
|
||||
await doReview.main({
|
||||
data: {
|
||||
record_id,
|
||||
file_id,
|
||||
user_id: user_id || 'anonymous',
|
||||
file_name: file_name || '',
|
||||
file_size: file_size || 0
|
||||
}
|
||||
});
|
||||
return { code: 0, msg: '审查完成' };
|
||||
} catch (e) {
|
||||
console.error('审查失败:', e);
|
||||
// 更新状态为失败
|
||||
await db.collection('jjx-review-records').doc(record_id).update({
|
||||
status: 'failed',
|
||||
result: '审查失败: ' + e.message,
|
||||
error: e.message,
|
||||
update_time: new Date()
|
||||
});
|
||||
return { code: -1, msg: '审查失败: ' + e.message };
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
module.exports = {
|
||||
main: async (event) => {
|
||||
let { data = {}, userInfo, util } = event;
|
||||
let { db } = util;
|
||||
const { pageIndex = 1, pageSize = 50 } = data;
|
||||
|
||||
const uid = (data && data.uid) || '';
|
||||
if (!uid) return { code: -1, msg: '未登录' };
|
||||
|
||||
const where = { user_id: uid };
|
||||
|
||||
const countRes = await db.collection('jjx-review-records').where(where).count();
|
||||
|
||||
const listRes = await db.collection('jjx-review-records')
|
||||
.where(where)
|
||||
.orderBy('_add_time', 'desc')
|
||||
.skip((pageIndex - 1) * pageSize)
|
||||
.limit(pageSize)
|
||||
.get();
|
||||
|
||||
return {
|
||||
code: 0,
|
||||
msg: 'ok',
|
||||
data: {
|
||||
total: countRes.total,
|
||||
rows: listRes.data
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
// 云函数:client/ai/pub/getReviewResult
|
||||
module.exports = {
|
||||
main: async (event) => {
|
||||
let { data = {}, userInfo, util } = event;
|
||||
let { db } = util;
|
||||
const { record_id } = data;
|
||||
|
||||
if (!record_id) return { code: -1, msg: '缺少 record_id' };
|
||||
|
||||
const record = await db.collection('jjx-review-records').doc(record_id).get();
|
||||
if (!record.data.length) return { code: -1, msg: '记录不存在' };
|
||||
|
||||
const rec = record.data[0];
|
||||
|
||||
return {
|
||||
code: 0,
|
||||
data: {
|
||||
status: rec.status,
|
||||
result: rec.result || '',
|
||||
points_used: rec.points_used || 0,
|
||||
html_url: rec.html_url || '',
|
||||
contract_info: rec.contract_info || {},
|
||||
error: rec.error || ''
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,217 @@
|
||||
// client/ai/pub/jjxDoReview.js
|
||||
module.exports = {
|
||||
main: async (event) => {
|
||||
let { data = {}, userInfo } = event;
|
||||
const { record_id, file_id, user_id, file_name, file_size } = data;
|
||||
|
||||
if (!record_id || !file_id) return { code: -1, msg: '参数错误' };
|
||||
|
||||
const COZE_TOKEN = 'sat_OiXlI4Da5Q99fxmul6pNfExmA6hR898UbxBDwrvjZ638APxRSlFnXbz6zyFedKNG';
|
||||
const BOT_ID = '7689821072762011698';
|
||||
const db = uniCloud.database();
|
||||
const _ = db.command;
|
||||
|
||||
try {
|
||||
// 构造请求
|
||||
const objectString = JSON.stringify([
|
||||
{ type: 'file', file_id: file_id },
|
||||
{ type: 'text', text: '请审查这份合同' }
|
||||
]);
|
||||
|
||||
// 调用 Coze 接口(流式模式)
|
||||
const chatRes = await uniCloud.httpclient.request('https://api.coze.cn/v3/chat', {
|
||||
method: 'POST',
|
||||
dataType: 'stream', // 关键:改成 stream
|
||||
contentType: 'json',
|
||||
timeout: 300000, // 5分钟超时
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + COZE_TOKEN,
|
||||
'Accept': 'text/event-stream'
|
||||
},
|
||||
data: {
|
||||
bot_id: BOT_ID,
|
||||
user_id: user_id || 'anonymous',
|
||||
stream: true,
|
||||
auto_save_history: true,
|
||||
additional_messages: [{
|
||||
role: 'user',
|
||||
content: objectString,
|
||||
content_type: 'object_string'
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
// 从流中逐步解析
|
||||
const stream = chatRes.data || chatRes.res;
|
||||
let buffer = '';
|
||||
let answer = '';
|
||||
let conversationId = '';
|
||||
let lastUpdateLen = 0;
|
||||
|
||||
// 返回 Promise,等待流结束
|
||||
return await new Promise((resolve, reject) => {
|
||||
|
||||
stream.on('data', (chunk) => {
|
||||
buffer += chunk.toString();
|
||||
const blocks = buffer.split('\n\n');
|
||||
buffer = blocks.pop();
|
||||
|
||||
for (const block of blocks) {
|
||||
const lines = block.split('\n');
|
||||
let eventName = '';
|
||||
let dataStr = '';
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.startsWith('event:')) eventName = line.slice(6).trim();
|
||||
if (line.startsWith('data:')) dataStr = line.slice(5).trim();
|
||||
}
|
||||
|
||||
if (!dataStr || dataStr === '[DONE]' || dataStr === '"[DONE]"') continue;
|
||||
|
||||
try {
|
||||
const p = JSON.parse(dataStr);
|
||||
if (p.conversation_id) conversationId = p.conversation_id;
|
||||
|
||||
// 处理回答内容
|
||||
if (p.type === 'answer' && p.content) {
|
||||
answer += p.content;
|
||||
|
||||
// 每积累 200 字更新一次数据库(前端轮询能看到进度)
|
||||
if (answer.length - lastUpdateLen >= 200) {
|
||||
lastUpdateLen = answer.length;
|
||||
db.collection('jjx-review-records').doc(record_id).update({
|
||||
result: answer,
|
||||
status: 'reviewing',
|
||||
update_time: new Date()
|
||||
}).catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
// 处理工具响应(报告下载链接)
|
||||
if (p.type === 'tool_response' && p.content) {
|
||||
try {
|
||||
const toolData = JSON.parse(p.content);
|
||||
if (toolData.url) answer += '\n\n📎 报告下载:' + toolData.url;
|
||||
} catch (e) {
|
||||
const urlMatch = p.content.match(/https?:\/\/[^\s\)\]\"\<]+\.pdf[^\s\)\]\"\<]*/i);
|
||||
if (urlMatch) answer += '\n\n📎 报告下载:' + urlMatch[0];
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
});
|
||||
|
||||
stream.on('end', async () => {
|
||||
if (!answer) {
|
||||
answer = '审查未能获取结果,请稍后重试';
|
||||
}
|
||||
|
||||
try {
|
||||
// 计算消耗积分
|
||||
const pointsUsed = Math.max(150, Math.ceil((file_size || 0) / (100 * 1024)) * 150);
|
||||
|
||||
// 扣积分
|
||||
const userPoints = await db.collection('jjx-user-points').doc(user_id).get();
|
||||
if (userPoints.data.length && userPoints.data[0].balance >= pointsUsed) {
|
||||
await db.collection('jjx-user-points').doc(user_id).update({
|
||||
balance: _.inc(-pointsUsed),
|
||||
total_spent: _.inc(pointsUsed),
|
||||
update_time: new Date()
|
||||
});
|
||||
|
||||
const updatedPoints = await db.collection('jjx-user-points').doc(user_id).get();
|
||||
await db.collection('jjx-points-log').add({
|
||||
user_id: user_id,
|
||||
type: 'spend',
|
||||
amount: -pointsUsed,
|
||||
balance_after: updatedPoints.data[0] ? updatedPoints.data[0].balance : 0,
|
||||
reason: '合同审查 — ' + (file_name || ''),
|
||||
biz_type: 'contract_review',
|
||||
biz_id: record_id,
|
||||
_add_time: new Date()
|
||||
});
|
||||
}
|
||||
|
||||
// 保存 HTML 报告到云存储
|
||||
let htmlUrl = '';
|
||||
try {
|
||||
// 如果回复本身就是 HTML(包含 <!DOCTYPE html> 或 <html>)
|
||||
let htmlContent = answer;
|
||||
const htmlMatch = answer.match(/```html\s*([\s\S]*?)```/);
|
||||
if (htmlMatch && htmlMatch[1]) {
|
||||
htmlContent = htmlMatch[1].trim();
|
||||
}
|
||||
|
||||
if (htmlContent.includes('<!DOCTYPE') || htmlContent.includes('<html')) {
|
||||
const cloudPath = 'review-reports/' + Date.now() + '_' + (file_name || 'report').replace(/\.[^.]+$/, '') + '.html';
|
||||
const uploadRes = await uniCloud.uploadFile({
|
||||
cloudPath: cloudPath,
|
||||
fileContent: Buffer.from(htmlContent, 'utf-8')
|
||||
});
|
||||
if (uploadRes.fileID) {
|
||||
const urlRes = await uniCloud.getTempFileURL({ fileList: [uploadRes.fileID] });
|
||||
if (urlRes.fileList && urlRes.fileList[0]) {
|
||||
htmlUrl = urlRes.fileList[0].tempFileURL;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('HTML报告上传失败:', e.message);
|
||||
}
|
||||
|
||||
// 解析 JSON 结构化数据(如果有的话)
|
||||
let contractInfo = {};
|
||||
try {
|
||||
const jsonMatch = answer.match(/```json\s*([\s\S]*?)```/);
|
||||
if (jsonMatch) contractInfo = JSON.parse(jsonMatch[1].trim());
|
||||
} catch (e) {}
|
||||
|
||||
// 更新审查记录为完成
|
||||
await db.collection('jjx-review-records').doc(record_id).update({
|
||||
status: 'completed',
|
||||
result: answer,
|
||||
html_url: htmlUrl,
|
||||
contract_info: contractInfo,
|
||||
points_used: pointsUsed,
|
||||
conversation_id: conversationId || '',
|
||||
update_time: new Date()
|
||||
});
|
||||
|
||||
resolve({ code: 0, msg: '审查完成' });
|
||||
|
||||
} catch (e) {
|
||||
// 更新为失败
|
||||
await db.collection('jjx-review-records').doc(record_id).update({
|
||||
status: 'failed',
|
||||
result: '审查失败: ' + e.message,
|
||||
error: e.message,
|
||||
update_time: new Date()
|
||||
});
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
|
||||
stream.on('error', async (err) => {
|
||||
await db.collection('jjx-review-records').doc(record_id).update({
|
||||
status: 'failed',
|
||||
result: '审查失败: ' + err.message,
|
||||
error: err.message,
|
||||
update_time: new Date()
|
||||
});
|
||||
reject(err);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
// 审查失败,更新记录
|
||||
await db.collection('jjx-review-records').doc(record_id).update({
|
||||
status: 'failed',
|
||||
result: '审查失败: ' + e.message,
|
||||
error: e.message,
|
||||
update_time: new Date()
|
||||
});
|
||||
return { code: -1, msg: '审查失败: ' + e.message };
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,252 @@
|
||||
// client/ai/pub/review.js
|
||||
// Markdown 转 HTML
|
||||
function mdToHtml(md) {
|
||||
if (!md) return '';
|
||||
let html = md;
|
||||
// 标题
|
||||
html = html.replace(/^####\s+(.+)$/gm, '<h5>$1</h5>');
|
||||
html = html.replace(/^###\s+(.+)$/gm, '<h4>$1</h4>');
|
||||
html = html.replace(/^##\s+(.+)$/gm, '<h3>$1</h3>');
|
||||
html = html.replace(/^#\s+(.+)$/gm, '<h2>$1</h2>');
|
||||
// 加粗
|
||||
html = html.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
|
||||
// 链接
|
||||
html = html.replace(/(https?:\/\/[^\s\)\]\"\<]+)/g, '<a href="$1" target="_blank">$1</a>');
|
||||
// 代码块
|
||||
html = html.replace(/```[\w]*\n([\s\S]*?)```/g, '<pre class="code-block">$1</pre>');
|
||||
// 行内代码
|
||||
html = html.replace(/`([^`]+)`/g, '<code>$1</code>');
|
||||
// 列表
|
||||
html = html.replace(/^[\-\•]\s+(.+)$/gm, '<li>$1</li>');
|
||||
html = html.replace(/^(\d+)\.\s+(.+)$/gm, '<li>$1. $2</li>');
|
||||
// 换行
|
||||
html = html.replace(/\n\n/g, '</p><p>');
|
||||
html = html.replace(/\n/g, '<br>');
|
||||
html = '<p>' + html + '</p>';
|
||||
// 清理空段落
|
||||
html = html.replace(/<p>\s*<\/p>/g, '');
|
||||
return html;
|
||||
}
|
||||
|
||||
// 生成精美 HTML 报告
|
||||
function generateHtmlReport(markdown, fileName, reportDate, info) {
|
||||
const riskLevel = info.risk_level || '待评估';
|
||||
const riskSummary = info.risk_summary || '';
|
||||
const riskCount = info.risk_count || { high: 0, medium: 0, low: 0 };
|
||||
const contractName = info.contract_name || fileName || '合同审查报告';
|
||||
const contractType = info.contract_type || '';
|
||||
|
||||
// 风险等级颜色
|
||||
let riskColor = '#67c23a';
|
||||
if (riskLevel.includes('高')) riskColor = '#f56c6c';
|
||||
else if (riskLevel.includes('中高')) riskColor = '#e6a23c';
|
||||
else if (riskLevel.includes('中')) riskColor = '#e6a23c';
|
||||
else if (riskLevel.includes('中低')) riskColor = '#409eff';
|
||||
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>${contractName} - 审查报告</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: #f5f7fa; color: #333; line-height: 1.8; }
|
||||
.container { max-width: 900px; margin: 0 auto; padding: 20px; }
|
||||
.header { background: linear-gradient(135deg, #a92924, #d4574e); color: #fff; padding: 40px; border-radius: 12px 12px 0 0; }
|
||||
.header h1 { font-size: 24px; margin-bottom: 8px; }
|
||||
.header .subtitle { opacity: 0.85; font-size: 14px; }
|
||||
.summary-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 24px 40px; background: #fff; border-bottom: 1px solid #eee; }
|
||||
.summary-card { text-align: center; padding: 16px; border-radius: 8px; background: #f9f9f9; }
|
||||
.summary-card .label { font-size: 12px; color: #999; margin-bottom: 4px; }
|
||||
.summary-card .value { font-size: 20px; font-weight: 700; }
|
||||
.body { background: #fff; padding: 32px 40px; border-radius: 0 0 12px 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
|
||||
.body h2 { font-size: 18px; color: #222; margin: 28px 0 12px; padding-bottom: 8px; border-bottom: 2px solid #a92924; }
|
||||
.body h3 { font-size: 16px; color: #333; margin: 20px 0 8px; }
|
||||
.body h4 { font-size: 14px; color: #444; margin: 16px 0 6px; }
|
||||
.body p { margin: 8px 0; font-size: 14px; }
|
||||
.body li { margin: 4px 0 4px 20px; font-size: 14px; }
|
||||
.body strong { color: #a92924; }
|
||||
.body a { color: #a92924; text-decoration: underline; }
|
||||
.risk-badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; color: #fff; }
|
||||
.risk-high { background: #f56c6c; }
|
||||
.risk-medium { background: #e6a23c; }
|
||||
.risk-low { background: #67c23a; }
|
||||
.code-block { background: #f6f8fa; border: 1px solid #e1e4e8; border-radius: 6px; padding: 12px 16px; font-size: 13px; overflow-x: auto; margin: 8px 0; font-family: "SFMono-Regular", Consolas, monospace; }
|
||||
.disclaimer { margin-top: 32px; padding: 16px 20px; background: #fff8e1; border-left: 4px solid #e6a23c; border-radius: 4px; font-size: 12px; color: #b8860b; }
|
||||
.footer { text-align: center; padding: 24px; font-size: 12px; color: #999; }
|
||||
@media print { body { background: #fff; } .container { padding: 0; } .header { border-radius: 0; } .body { box-shadow: none; } }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>📋 合同审查报告</h1>
|
||||
<div class="subtitle">${contractName} | ${reportDate}</div>
|
||||
</div>
|
||||
<div class="summary-cards">
|
||||
<div class="summary-card">
|
||||
<div class="label">综合风险等级</div>
|
||||
<div class="value" style="color:${riskColor}">${riskLevel}</div>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<div class="label">风险统计</div>
|
||||
<div class="value"><span style="color:#f56c6c">${riskCount.high||0}</span> / <span style="color:#e6a23c">${riskCount.medium||0}</span> / <span style="color:#67c23a">${riskCount.low||0}</span></div>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<div class="label">合同类型</div>
|
||||
<div class="value" style="font-size:14px">${contractType || '待识别'}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="body">
|
||||
<h2>总体评估</h2>
|
||||
<p>${riskSummary || '暂无总体评估'}</p>
|
||||
<h2>详细审查意见</h2>
|
||||
${mdToHtml(markdown.replace(/```json[\s\S]*?```/, ''))}
|
||||
<div class="disclaimer">
|
||||
⚠️ <strong>免责声明</strong>:本报告由 AI 系统自动生成,仅供参考,不构成正式法律意见。涉及重大金额或复杂交易的合同,建议咨询执业律师。
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
金久信签约宝 · AI 合同审查服务 | 报告生成时间:${new Date().toLocaleString('zh-CN')}
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
main: async (event) => {
|
||||
let { data = {}, userInfo } = event;
|
||||
const COZE_TOKEN = 'sat_OiXlI4Da5Q99fxmul6pNfExmA6hR898UbxBDwrvjZ638APxRSlFnXbz6zyFedKNG';
|
||||
const BOT_ID = '7689821072762011698';
|
||||
const db = uniCloud.database();
|
||||
const _ = db.command;
|
||||
|
||||
let fileId = data.file_id;
|
||||
|
||||
// ===== 模式1:上传文件 + 创建待审查记录 =====
|
||||
if (data.upload_only && data.file_base64) {
|
||||
const fileBuffer = Buffer.from(data.file_base64, 'base64');
|
||||
const boundary = '----FormBoundary' + Date.now();
|
||||
const header = Buffer.from(
|
||||
'--' + boundary + '\r\n' +
|
||||
'Content-Disposition: form-data; name="file"; filename="' + (data.file_name || 'file') + '"\r\n' +
|
||||
'Content-Type: application/octet-stream\r\n\r\n'
|
||||
);
|
||||
const footer = Buffer.from('\r\n--' + boundary + '--\r\n');
|
||||
const uploadBody = Buffer.concat([header, fileBuffer, footer]);
|
||||
|
||||
try {
|
||||
const uploadRes = await uniCloud.httpclient.request('https://api.coze.cn/v1/files/upload', {
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + COZE_TOKEN,
|
||||
'Content-Type': 'multipart/form-data; boundary=' + boundary,
|
||||
'Content-Length': uploadBody.length.toString()
|
||||
},
|
||||
content: uploadBody,
|
||||
timeout: 600000
|
||||
});
|
||||
if (uploadRes.data.code !== 0) {
|
||||
return { code: -1, msg: '文件上传失败: ' + uploadRes.data.msg };
|
||||
}
|
||||
fileId = uploadRes.data.data.id;
|
||||
|
||||
// 同时上传到 uniCloud 云存储(用于查看/下载)
|
||||
let fileUrl = '';
|
||||
try {
|
||||
const cloudPath = 'review-files/' + Date.now() + '_' + (data.file_name || 'file');
|
||||
const uploadFileRes = await uniCloud.uploadFile({
|
||||
cloudPath: cloudPath,
|
||||
fileContent: fileBuffer
|
||||
});
|
||||
if (uploadFileRes.fileID) {
|
||||
const urlRes = await uniCloud.getTempFileURL({
|
||||
fileList: [uploadFileRes.fileID]
|
||||
});
|
||||
if (urlRes.fileList && urlRes.fileList[0]) {
|
||||
fileUrl = urlRes.fileList[0].tempFileURL;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('云存储上传失败(不影响审查):', e.message);
|
||||
}
|
||||
|
||||
// 创建待审查记录
|
||||
const recordRes = await db.collection('jjx-review-records').add({
|
||||
user_id: (data && data.uid) || 'anonymous',
|
||||
file_name: data.file_name || '',
|
||||
file_size: data.file_size || 0,
|
||||
file_id: fileId,
|
||||
file_url: fileUrl,
|
||||
chat_id: '',
|
||||
conversation_id: '',
|
||||
status: 'uploaded',
|
||||
result: '',
|
||||
points_used: 0,
|
||||
_add_time: new Date(),
|
||||
update_time: new Date()
|
||||
});
|
||||
|
||||
return { code: 0, msg: 'ok', data: { file_id: fileId, record_id: recordRes.id, file_url: fileUrl } };
|
||||
} catch (e) {
|
||||
return { code: -1, msg: '上传异常: ' + e.message };
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 模式2:发起审查(只更新状态,立即返回)=====
|
||||
if (!fileId) return { code: -1, msg: '缺少 file_id' };
|
||||
|
||||
const recordId = data.record_id;
|
||||
if (!recordId) return { code: -1, msg: '缺少 record_id' };
|
||||
|
||||
// 检查当前状态
|
||||
const record = await db.collection('jjx-review-records').doc(recordId).get();
|
||||
if (record.data.length) {
|
||||
const rec = record.data[0];
|
||||
|
||||
// 已完成,直接返回结果
|
||||
if (rec.status === 'completed') {
|
||||
return {
|
||||
code: 0, msg: 'ok',
|
||||
data: {
|
||||
record_id: recordId,
|
||||
status: 'completed',
|
||||
result: rec.result,
|
||||
points_used: rec.points_used,
|
||||
html_url: rec.html_url || '',
|
||||
contract_info: rec.contract_info || {}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 正在审查中,直接返回
|
||||
if (rec.status === 'reviewing') {
|
||||
return { code: 0, msg: 'ok', data: { record_id: recordId, status: 'reviewing' } };
|
||||
}
|
||||
|
||||
// 失败,返回错误
|
||||
if (rec.status === 'failed') {
|
||||
return { code: 0, msg: 'ok', data: { record_id: recordId, status: 'failed', result: rec.result || '审查失败' } };
|
||||
}
|
||||
}
|
||||
|
||||
// 更新状态为审查中
|
||||
await db.collection('jjx-review-records').doc(recordId).update({
|
||||
file_id: fileId,
|
||||
file_name: data.file_name || '',
|
||||
file_size: data.file_size || 0,
|
||||
status: 'reviewing',
|
||||
review_started_at: new Date(),
|
||||
update_time: new Date()
|
||||
});
|
||||
|
||||
// ===== 立即返回,审查由定时任务触发 =====
|
||||
return {
|
||||
code: 0, msg: 'ok',
|
||||
data: { record_id: recordId, status: 'reviewing' }
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url admin/article/category/sys/list 前端调用的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, page} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
res = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-album',
|
||||
whereJson: {page},
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/category/pub/getList 前端调用的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: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.getTableData({
|
||||
dbName: 'jjx-article-category',
|
||||
sortArr: [
|
||||
{ name: "sort", type: "asc" },
|
||||
{ name: "_id", type: "desc" },
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/collect/kh/changeCollect 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const collect = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-article-collect',
|
||||
whereJson: {
|
||||
uid,
|
||||
articleId: data.articleId
|
||||
}
|
||||
})
|
||||
|
||||
if (collect) {
|
||||
await vk.baseDao.deleteById({
|
||||
dbName: "jjx-article-collect",
|
||||
id: collect._id
|
||||
});
|
||||
} else {
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-article-collect",
|
||||
dataJson: {
|
||||
uid,
|
||||
articleId: data.articleId
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/collect/kh/check 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const collect = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-article-collect',
|
||||
whereJson: {
|
||||
uid,
|
||||
articleId: data.articleId
|
||||
}
|
||||
})
|
||||
|
||||
res.data = !!collect
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/collect/kh/getList 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName: 'jjx-article-collect',
|
||||
getCount: true,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
whereJson: {
|
||||
uid
|
||||
},
|
||||
sortArr: [
|
||||
{name: "_id", type: "desc"}
|
||||
],
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "jjx-article",
|
||||
localKey: "articleId",
|
||||
foreignKey: "_id",
|
||||
as: "article",
|
||||
limit: 1
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/list/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 res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: 'jjx-article',
|
||||
dataJson: {
|
||||
...data, ...{
|
||||
viewNum: 0,
|
||||
downloadNum: 0,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/list/kh/addDownload 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
if (userInfo.userLevel < 0) return {code: 1, msg: "非会员,无法下载"};
|
||||
if (userInfo.userLevel === 0 && userInfo.remainArticleDownloadNum === 0) return {code: 1, msg: "无下载次数,无法下载"};
|
||||
// if (userInfo.userLevel === 0 && userInfo.remainArticleDownloadNum > 0) {
|
||||
// await vk.baseDao.update({
|
||||
// dbName: 'uni-id-users',
|
||||
// whereJson: {
|
||||
// _id: uid,
|
||||
// },
|
||||
// dataJson: {
|
||||
// remainArticleDownloadNum: _.inc(-1)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
const check = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-article-download",
|
||||
whereJson: {
|
||||
uid,
|
||||
articleId: data.id
|
||||
}
|
||||
});
|
||||
|
||||
if (!check) {
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-article-download",
|
||||
dataJson: {
|
||||
uid,
|
||||
articleId: data.id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/list/kh/check 前端调用的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: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res.data = !!await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-article-download",
|
||||
whereJson: {
|
||||
uid,
|
||||
articleId: data.id
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/list/kh/addDownload 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName: "jjx-article-download",
|
||||
getCount: true,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
whereJson: {
|
||||
uid,
|
||||
},
|
||||
sortArr: [
|
||||
{name: "_id", type: "desc"}
|
||||
],
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "jjx-article",
|
||||
localKey: "articleId",
|
||||
foreignKey: "_id",
|
||||
as: "article",
|
||||
limit: 1
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/list/kh/getUserList 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.select({
|
||||
dbName: 'jjx-article',
|
||||
getCount: true,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
whereJson: {
|
||||
uid
|
||||
},
|
||||
sortArr: [
|
||||
{name: "_id", type: "desc"}
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/list/pub/addDownload 前端调用的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.updateById({
|
||||
dbName: "jjx-article",
|
||||
id: data.id,
|
||||
dataJson: {
|
||||
downloadNum: _.inc(1)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/list/pub/addView 前端调用的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.updateById({
|
||||
dbName: "jjx-article",
|
||||
id: data.id,
|
||||
dataJson: {
|
||||
viewNum: _.inc(1)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/otherArticle/list/pub/getDetail 前端调用的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.update({
|
||||
// dbName: "uni-id-users",
|
||||
// whereJson:{
|
||||
// remainArticleDownloadNum: 0
|
||||
// },
|
||||
// dataJson:{
|
||||
// remainArticleDownloadNum: 3
|
||||
// },
|
||||
// })
|
||||
|
||||
res = await vk.baseDao.findById({
|
||||
dbName: "jjx-article",
|
||||
id: data.id,
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/list/pub/getList 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const {pageIndex, pageSize, parentId, keyword} = data
|
||||
const whereJson = {parentId}
|
||||
if (vk.pubfn.isNotNull(keyword)) {
|
||||
whereJson.name = new RegExp(keyword)
|
||||
}
|
||||
res = await vk.baseDao.select({
|
||||
dbName: 'jjx-article',
|
||||
getCount: true,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
whereJson,
|
||||
sortArr: [
|
||||
{name: "_id", type: "desc"}
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/factory/kh/addUpdate 前端调用的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, _id, position, phone, name, email, idCard} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
if (vk.pubfn.isNotNull(_id)) {
|
||||
await vk.baseDao.update({
|
||||
dbName: 'jjx-business-contact',
|
||||
whereJson: {
|
||||
_id,
|
||||
uid
|
||||
},
|
||||
dataJson: {
|
||||
position, phone, name, email, idCard
|
||||
}
|
||||
})
|
||||
}else {
|
||||
await vk.baseDao.add({
|
||||
dbName: 'jjx-business-contact',
|
||||
dataJson: {
|
||||
uid,
|
||||
position, phone, name, email, idCard
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/factory/kh/addUpdate 前端调用的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, _id} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
await vk.baseDao.del({
|
||||
dbName: "jjx-business-contact",
|
||||
whereJson: {
|
||||
uid, _id
|
||||
}
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/factory/kh/addUpdate 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName: "jjx-business-contact",
|
||||
whereJson: {
|
||||
uid
|
||||
}
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/cart/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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const inCart = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-cart",
|
||||
whereJson: {
|
||||
uid,
|
||||
goodsId: data.goodsId,
|
||||
skuId: data.skuId,
|
||||
}
|
||||
});
|
||||
console.log('inCart', inCart)
|
||||
if (inCart) {
|
||||
const res = await vk.baseDao.updateById({
|
||||
dbName: "jjx-cart",
|
||||
id: inCart._id,
|
||||
dataJson: {
|
||||
num: _.inc(1)
|
||||
}
|
||||
})
|
||||
console.log('res2', res)
|
||||
} else {
|
||||
const res = await vk.baseDao.add({
|
||||
dbName: "jjx-cart",
|
||||
dataJson: {
|
||||
num: data.num,
|
||||
goodsId: data.goodsId,
|
||||
skuId: data.skuId,
|
||||
uid
|
||||
}
|
||||
})
|
||||
console.log('res1', res)
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/cart/kh/changeNum 前端调用的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.updateById({
|
||||
dbName: "jjx-cart",
|
||||
id: data.id,
|
||||
dataJson: {
|
||||
num: data.num,
|
||||
}
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/cart/kh/delete 前端调用的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.del({
|
||||
dbName: "jjx-cart",
|
||||
whereJson: {
|
||||
uid,
|
||||
_id: _.in(data.ids)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/cart/kh/getList 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName: "jjx-cart",
|
||||
getCount: true,
|
||||
whereJson: {
|
||||
uid
|
||||
},
|
||||
pageIndex: 1,
|
||||
pageSize: 500
|
||||
})
|
||||
|
||||
// ,
|
||||
// foreignDB: [
|
||||
// {
|
||||
// dbName: "jjx-goods",
|
||||
// localKey: "goodsId",
|
||||
// foreignKey: "_id",
|
||||
// as: "goods",
|
||||
// limit: 1
|
||||
// }
|
||||
// ]
|
||||
|
||||
for (let i in res.rows) {
|
||||
res.rows[i].goods = await vk.baseDao.findById({
|
||||
dbName: 'jjx-goods',
|
||||
id: res.rows[i].goodsId
|
||||
})
|
||||
|
||||
res.rows[i].sku = res.rows[i].goods.sku.find(item => item._index === res.rows[i].skuId)
|
||||
}
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/cart/kh/getNum 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res.data = await vk.baseDao.count({
|
||||
dbName: "jjx-cart",
|
||||
getCount: true,
|
||||
whereJson: {
|
||||
uid
|
||||
}
|
||||
})
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
'use strict';
|
||||
const dbName = require("../../../../dao/config");
|
||||
const dayjs = require("dayjs");
|
||||
var isBetween = require('dayjs/plugin/isBetween')
|
||||
dayjs.extend(isBetween)
|
||||
|
||||
const PROCESS_PAY_METHOD = ['预付', '货到验收后付款', '提货付全款', '信誉采购,货到签单后账期:']
|
||||
const WRITE_INVOICE_TIME = ['付款当月(限20号之前付款,20号之后付款次月开票)', '付款后次月', '付款前']
|
||||
const INVOICE_TYPE = ['增值税专用发票13%', '增值税普通发票', '普通发票']
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* 新增合同
|
||||
* @url client/contract/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.updateById({
|
||||
// dbName: 'jjx-process-sheet',
|
||||
// id: data.sheetId,
|
||||
// dataJson: {
|
||||
// status: 1
|
||||
// }
|
||||
// })
|
||||
const quote = await vk.baseDao.updateAndReturn({
|
||||
dbName: 'jjx-process-quote',
|
||||
whereJson: {
|
||||
_id: data.quoteId
|
||||
},
|
||||
dataJson: {
|
||||
status: 1
|
||||
}
|
||||
})
|
||||
|
||||
// const quote = await vk.baseDao.findById({
|
||||
// dbName: 'jjx-process-quote',
|
||||
// id: data.quoteId
|
||||
// })
|
||||
|
||||
const sheet = await vk.baseDao.updateAndReturn({
|
||||
dbName: 'jjx-process-sheet',
|
||||
whereJson: {
|
||||
_id: quote.sheetId
|
||||
},
|
||||
dataJson: {
|
||||
otherUid: data.seller,
|
||||
status: 1
|
||||
}
|
||||
})
|
||||
|
||||
const checkMessage = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-message-config",
|
||||
whereJson: {
|
||||
process: true,
|
||||
uid: quote.userId
|
||||
}
|
||||
})
|
||||
|
||||
if (checkMessage && sheet) {
|
||||
let send = true
|
||||
if (checkMessage) {
|
||||
// if (checkMessage.doNotDisturbRange && checkMessage.doNotDisturbRange[0]) {
|
||||
// const date = dayjs().format("YYYY-MM-DD")
|
||||
// const doNotDisturbRangeStart = dayjs(checkMessage.doNotDisturbRange[0]).format("HH:mm")
|
||||
// const doNotDisturbRangeEnd = dayjs(checkMessage.doNotDisturbRange[1]).format("HH:mm")
|
||||
// if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
// send = false
|
||||
// }
|
||||
const date = dayjs().format("YYYY-MM-DD")
|
||||
if (checkMessage.doNotDisturbStart && checkMessage.doNotDisturbStart.length) {
|
||||
const doNotDisturbRangeStart = dayjs(`${date} ${checkMessage.doNotDisturbStart[0]}:${checkMessage.doNotDisturbStart[1]}`).format("HH:mm")
|
||||
const doNotDisturbRangeEnd = dayjs(`${date} ${checkMessage.doNotDisturbEnd[0]}:${checkMessage.doNotDisturbEnd[1]}`).format("HH:mm")
|
||||
if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
send = false
|
||||
}
|
||||
}
|
||||
if (send) {
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: quote.userId,
|
||||
title: `加工:${sheet.title}被选商`,
|
||||
content: `您报价的加工信息已被选商,赶紧去签合同吧`,
|
||||
type: 'contract',
|
||||
hasRead: false,
|
||||
pk: quote.sheetId
|
||||
}
|
||||
});
|
||||
await pubFun.sendNotifySms(quote.userId, 'SMS_474210523')
|
||||
}
|
||||
}
|
||||
|
||||
if (sheet.signMethod !== 1) {
|
||||
const fadadaContractId = vk.pubfn.createOrderNo("P", 20)
|
||||
let contractTransactionId = vk.pubfn.createOrderNo("C", 20)
|
||||
data.transactionId = contractTransactionId
|
||||
const contractId = await vk.baseDao.add({
|
||||
dbName: 'jjx-contract',
|
||||
dataJson: {
|
||||
...data, ...{
|
||||
fadadaContractId,
|
||||
status: 0,
|
||||
userId: uid,
|
||||
changeNum: 0,
|
||||
tradeMethod: sheet.tradeMethod
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
await vk.daoCenter.userContractDao.adds([
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("P", 20),
|
||||
userId: uid,
|
||||
role: 'buyer',
|
||||
sign: false,
|
||||
contractId,
|
||||
},
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("P", 20),
|
||||
userId: data.seller,
|
||||
role: 'seller',
|
||||
sign: false,
|
||||
contractId,
|
||||
}
|
||||
])
|
||||
|
||||
// 标准合同
|
||||
if (sheet.signMethod === 0) {
|
||||
|
||||
const templateId = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '80e3bed065a5560e075799d24532b14f'
|
||||
})
|
||||
const buyerSignKeyword = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '0b153f9a65a56a2007227cf5157133bf'
|
||||
})
|
||||
const sellerSignKeyword = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '09e7876865a56a320731cb244bbef818'
|
||||
})
|
||||
const signMaxDate = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '657d78958b0da41d311bd94c'
|
||||
})
|
||||
const signEndDate = vk.pubfn.getOffsetTime(new Date(), {
|
||||
day: parseInt(signMaxDate.content),
|
||||
mode: "after",
|
||||
});
|
||||
// const fieldList = await vk.baseDao.select({
|
||||
// dbName: 'jjx-contract-template',
|
||||
// whereJson: {
|
||||
// isOn: true
|
||||
// }
|
||||
// })
|
||||
const sellerUser = await vk.baseDao.findById({
|
||||
dbName: 'uni-id-users',
|
||||
id: quote.userId
|
||||
})
|
||||
const buyerUser = await vk.baseDao.findById({
|
||||
dbName: 'uni-id-users',
|
||||
id: uid
|
||||
})
|
||||
|
||||
let tradeInfo = PROCESS_PAY_METHOD[sheet.payMethod]
|
||||
if (sheet.payMethod === 0) tradeInfo += `${sheet.advancePayRate}%货到付全款`
|
||||
if (sheet.payMethod === 3) tradeInfo += `${sheet.reputationPayDay}天`
|
||||
tradeInfo += `,${sheet.invoice ? '含税' : '不含税'},`
|
||||
if (sheet.invoiceOther) tradeInfo += `,${sheet.invoiceOther}`
|
||||
else {
|
||||
if (sheet.taxType && sheet.invoiceType && sheet.taxRate) tradeInfo += `,${sheet.taxType},${sheet.invoiceType},${sheet.taxRate}`
|
||||
}
|
||||
// tradeInfo += `,${INVOICE_TYPE[sheet.invoiceType]}${sheet.invoiceOther ? sheet.invoiceOther : '无'}`
|
||||
let expressRequire = ''
|
||||
expressRequire += `随货资料:${sheet.transportDocuments.join()},其他要求:${sheet.otherTransportDocuments ? sheet.otherTransportDocuments : '无'},运输限制要求:${sheet.transportLimit ? '有' : '无'}`
|
||||
if (sheet.transportLimit && sheet.otherTransportRequest) expressRequire += `运输限制说明:${sheet.otherTransportRequest}`
|
||||
let region = sheet.addressRegion.province.name + sheet.addressRegion.city.name + sheet.addressRegion.area.name
|
||||
// if (sheet.type === 'process') {
|
||||
if (buyerUser.accountType === 2 && buyerUser.company && buyerUser.company.addressRegion && buyerUser.company.addressRegion.province) {
|
||||
region = buyerUser.company.addressRegion.province.name + buyerUser.company.addressRegion.city.name + buyerUser.company.addressRegion.area.name
|
||||
}
|
||||
if (buyerUser.accountType === 1 && buyerUser.person && buyerUser.person.addressRegion && buyerUser.person.addressRegion.province) {
|
||||
region = buyerUser.person.addressRegion.province.name + buyerUser.person.addressRegion.city.name + buyerUser.person.addressRegion.area.name
|
||||
}
|
||||
|
||||
// }
|
||||
// console.log(buyerUser)
|
||||
const accountType = sheet.invoice ? 'company' : 'person'
|
||||
const buyerBank = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-account",
|
||||
whereJson: {
|
||||
uid: buyerUser._id,
|
||||
type: accountType
|
||||
}
|
||||
})
|
||||
let buyerBankName = buyerUser.accountType === 2 ? buyerUser.company.companyBankName : buyerUser.person.personBankName
|
||||
let buyerAccount = buyerUser.accountType === 2 ? buyerUser.company.companyAccount : buyerUser.person.personAccount
|
||||
let buyerBankAccountName = buyerUser.accountType === 2 ? buyerUser.company.companyAccount : buyerUser.person.personAccount
|
||||
let sellerBankName = sellerUser.accountType === 2 ? sellerUser.company.companyBankName : sellerUser.person.personBankName
|
||||
let sellerAccount = sellerUser.accountType === 2 ? sellerUser.company.companyAccount : sellerUser.person.personAccount
|
||||
let sellerBankAccountName = sellerUser.accountType === 2 ? sellerUser.company.companyAccount : sellerUser.person.personAccount
|
||||
if (buyerBank) {
|
||||
buyerBankName = buyerBank.bankName
|
||||
buyerAccount = buyerBank.account
|
||||
buyerBankAccountName = buyerBank.accountName
|
||||
}
|
||||
const sellerBank = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-account",
|
||||
whereJson: {
|
||||
uid: sellerUser._id,
|
||||
type: accountType
|
||||
}
|
||||
})
|
||||
if (sellerBank) {
|
||||
sellerBankName = sellerBank.bankName
|
||||
sellerAccount = sellerBank.account
|
||||
sellerBankAccountName = sellerBank.accountName
|
||||
}
|
||||
|
||||
const parameter = {
|
||||
seller: sellerUser.accountType === 2 ? sellerUser.company.companyName : sellerUser.person.personName,
|
||||
buyer: buyerUser.accountType === 2 ? buyerUser.company.companyName : buyerUser.person.personName,
|
||||
date: dayjs().format('YYYY年MM月DD日'),
|
||||
sellerSignDate: dayjs(signEndDate).format('YYYY年MM月DD日 HH时mm分'),
|
||||
buyerSignDate: dayjs(signEndDate).format('YYYY年MM月DD日 HH时mm分'),
|
||||
contractNo: fadadaContractId,
|
||||
region,
|
||||
detail: sheet.title,
|
||||
info: sheet.remark ? sheet.remark : '无',
|
||||
tradeInfo,
|
||||
expressRequire,
|
||||
defaultDuty: '1.乙方所交产品品种、型号、规格、质量不符合规定的,如果甲方同意利用,应当按质论价;如果甲方不能利用的,应根据产品的具体情况,由乙方负责包换或包修,并承担修理、调换或退货而支付的实际费用;2.乙方不予供货违约责任为甲方的实际损失+违约金,如乙方材料符合订货标准,甲方不能退货和不收货,甲方无条件应按实际本合同订货数量支付100%货款,并支付乙方因此产生的实际费用。带有甲乙双方单位相关收货人和发货人签字的本合同的发货清单事项和内容均视为本合同的补充合同,与本合同有相同的法律效力,双方应共同遵照执行。',
|
||||
solve: '1、凡因本合同引起的或与本合同有关的任何争议,均可友好协商或仲裁解决,协商或仲裁不成的,双方协商同意在合同签订地人民法院管辖地起诉,违约一方或对合同争议承担主要责任的一方,应承担对方因仲裁和起诉而产生的全部律师代理费、鉴定(检验)费、诉讼保全费、诉讼保险费、公告费、差旅费、执行费、误工費和获取证据产生费用等其他相关费用。2、双方本合同相关权利放弃均应有双方书面作出并加盖公章或授权委托人签字后生效。',
|
||||
forceMajeure: '甲乙双方的任何一方由于不可抗力或突发公共事件的原因不能履行合同时,应及时向对方通报不能履行或不能完全履行的理由,以减轻可能给对方造成的损失,在取得有关机构证明以后,允许延期履行、部分履行或者不履行合同,并根据情况可部分或全部免予承担违约责任。',
|
||||
other: '本合同的全部内容由双方平等共同协商一致,共同起草制定,非一方事先拟定,不属于格式条款。本合同自双方签字盖章后生效(包括电子签字、盖章),按本合同内容地址、联系方式寄送的一切文书、函件送达与否,均为视为送达有法律效力,通知途径和本合同内联系方式或地址送达文件双方均予以验证。',
|
||||
buyerSupplement: sheet.supplementary ? sheet.supplementary : '无',
|
||||
sellerSupplement: sheet.supplierExt ? sheet.supplierExt : (quote.remark ? quote.remark : '无'),
|
||||
buyerAddress: buyerUser.accountType === 2 ? buyerUser.company.mailAddress : buyerUser.person.address,
|
||||
sellerAddress: sellerUser.accountType === 2 ? sellerUser.company.mailAddress : sellerUser.person.address,
|
||||
buyerLegal: buyerUser.accountType === 2 ? buyerUser.company.legalName : '',
|
||||
sellerLegal: sellerUser.accountType === 2 ? sellerUser.company.legalName : '',
|
||||
buyerAgent: buyerUser.accountType === 2 ? buyerUser.manager.personName : '',
|
||||
sellerAgent: sellerUser.accountType === 2 ? sellerUser.manager.personName : '',
|
||||
buyerMobile: buyerUser.accountType === 2 ? buyerUser.manager.mobile : buyerUser.mobile,
|
||||
sellerMobile: sellerUser.accountType === 2 ? sellerUser.manager.mobile : sellerUser.mobile,
|
||||
buyerBankName,
|
||||
sellerBankName,
|
||||
buyerAccount,
|
||||
sellerAccount,
|
||||
buyerBankAccountName,
|
||||
sellerBankAccountName,
|
||||
}
|
||||
// for (let i = 0; i < fieldList.length; i++) {
|
||||
//
|
||||
// const field = fieldList[i]
|
||||
// parameter[field.field] = ''
|
||||
// }
|
||||
const uploaddocs = await pubFun.fadada('generate_contract.api', {
|
||||
template_id: templateId.content,
|
||||
contract_id: contractTransactionId,
|
||||
parameter_map: JSON.stringify(parameter)
|
||||
})
|
||||
let otherFileResList = []
|
||||
if (sheet.files && sheet.files.length > 0) {
|
||||
for (let i = 0; i < sheet.files.length; i++) {
|
||||
otherFileResList.push(contractTransactionId + 'f' + i.toString())
|
||||
await pubFun.fadada('uploaddocs.api', {
|
||||
contract_id: contractTransactionId + 'f' + i.toString(),
|
||||
doc_title: sheet.title + `:附件${i + 1}`,
|
||||
doc_url: sheet.files[i],
|
||||
doc_type: '.pdf'
|
||||
})
|
||||
}
|
||||
}
|
||||
if (sheet.multiFiles && sheet.multiFiles.length > 0) {
|
||||
for (let i = 0; i < sheet.multiFiles.length; i++) {
|
||||
otherFileResList.push(contractTransactionId + 'mf' + i.toString())
|
||||
await pubFun.fadada('uploaddocs.api', {
|
||||
contract_id: contractTransactionId + 'mf' + i.toString(),
|
||||
doc_title: sheet.title + `:加工商附件${i + 1}`,
|
||||
doc_url: sheet.multiFiles[i],
|
||||
doc_type: '.pdf'
|
||||
})
|
||||
}
|
||||
// otherFileResList.unshift(contractTransactionId)
|
||||
|
||||
// 合并接口
|
||||
// contractTransactionId = vk.pubfn.createOrderNo("MC", 20)
|
||||
// const mergeRes = await pubFun.fadada('merge_contract.api', {
|
||||
// contract_id: contractTransactionId,
|
||||
// doc_title: sheet.title,
|
||||
// contract_ids: otherFileResList.join()
|
||||
// })
|
||||
// console.log('mergeRes', mergeRes)
|
||||
// console.log('otherFileResList', otherFileResList)
|
||||
}
|
||||
// 存在附件则合并
|
||||
|
||||
if (quote.files && quote.files.length > 0) {
|
||||
for (let i = 0; i < quote.files.length; i++) {
|
||||
otherFileResList.push(contractTransactionId + 'qf' + i.toString())
|
||||
await pubFun.fadada('uploaddocs.api', {
|
||||
contract_id: contractTransactionId + 'qf' + i.toString(),
|
||||
doc_title: sheet.title + `:报价附件${i + 1}`,
|
||||
doc_url: quote.files[i],
|
||||
doc_type: '.pdf'
|
||||
})
|
||||
}
|
||||
// otherFileResList.unshift(contractTransactionId)
|
||||
|
||||
// 合并接口
|
||||
// contractTransactionId = vk.pubfn.createOrderNo("MC", 20)
|
||||
// const mergeRes = await pubFun.fadada('merge_contract.api', {
|
||||
// contract_id: contractTransactionId,
|
||||
// doc_title: sheet.title,
|
||||
// contract_ids: otherFileResList.join()
|
||||
// })
|
||||
// console.log('quote mergeRes', mergeRes)
|
||||
// console.log('quote otherFileResList', otherFileResList)
|
||||
}
|
||||
if (otherFileResList.length) {
|
||||
otherFileResList.unshift(contractTransactionId)
|
||||
// 合并接口
|
||||
contractTransactionId = vk.pubfn.createOrderNo("MC", 20)
|
||||
const mergeRes = await pubFun.fadada('merge_contract.api', {
|
||||
contract_id: contractTransactionId,
|
||||
doc_title: sheet.title,
|
||||
contract_ids: otherFileResList.join()
|
||||
})
|
||||
console.log('mergeRes', mergeRes)
|
||||
console.log('otherFileResList', otherFileResList)
|
||||
}
|
||||
await vk.baseDao.update({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId
|
||||
},
|
||||
dataJson: {
|
||||
transactionId: contractTransactionId,
|
||||
}
|
||||
})
|
||||
if (parseInt(uploaddocs.code) === 1000) {
|
||||
await vk.baseDao.updateAndReturn({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId,
|
||||
userId: uid
|
||||
},
|
||||
dataJson: {
|
||||
status: 1,
|
||||
docTitle: sheet.title,
|
||||
signEndDate,
|
||||
otherFile: '',
|
||||
contractBase: null,
|
||||
buyerSignKeyword: buyerSignKeyword.content,
|
||||
sellerSignKeyword: sellerSignKeyword.content
|
||||
}
|
||||
})
|
||||
// await vk.baseDao.updateAndReturn({
|
||||
// dbName: 'jjx-process-sheet',
|
||||
// whereJson: {
|
||||
// _id: data.sheetId
|
||||
// },
|
||||
// dataJson: {
|
||||
// status: 2
|
||||
// }
|
||||
// })
|
||||
|
||||
res.data = uploaddocs.result
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: quote.userId,
|
||||
title: `加工:${sheet.title}待签合同`,
|
||||
content: `您报价的加工信息已创建合同,赶紧去签订合同吧`,
|
||||
type: 'contract',
|
||||
hasRead: false,
|
||||
pk: quote.sheetId
|
||||
}
|
||||
});
|
||||
await pubFun.sendNotifySms(quote.userId, 'SMS_474295535')
|
||||
} else {
|
||||
return {
|
||||
code: -1,
|
||||
msg: uploaddocs.msg
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const orderId = await vk.baseDao.add({
|
||||
dbName: "jjx-order",
|
||||
dataJson: {
|
||||
orderNo: vk.pubfn.createOrderNo("39XU", 20),
|
||||
uid: uid,
|
||||
sellerUid: quote.userId,
|
||||
orderStatus: 0,
|
||||
payStatus: 0,
|
||||
type: 5,
|
||||
amount: quote.totalPrice,
|
||||
offAmount: quote.totalPrice,
|
||||
signMethod: 1,
|
||||
sheetId: quote.sheetId
|
||||
}
|
||||
})
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-order-goods",
|
||||
dataJson: {
|
||||
orderId,
|
||||
goodsId: null,
|
||||
num: 1,
|
||||
goodsName: '加工单',
|
||||
goodsPrice: quote.totalPrice,
|
||||
goodsCover: null,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* 新增签约宝合同
|
||||
* @url client/contract/kh/addSign 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
let payByUser = userInfo;
|
||||
|
||||
const otherUser = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'uni-id-users',
|
||||
whereJson: {
|
||||
mobile: data.phone
|
||||
}
|
||||
})
|
||||
if (JSON.stringify(otherUser) === '{}' || !otherUser) return {
|
||||
code: -1,
|
||||
msg: '签约接收方账号不存在'
|
||||
}
|
||||
if (data.payBy === undefined || data.payBy === null || data.payBy === '')
|
||||
return {
|
||||
code: -1,
|
||||
msg: `请选择费用承担方`
|
||||
}
|
||||
if (data.payBy === 1) payByUser = otherUser
|
||||
// console.log('data.thirdList', data.thirdList, data.thirdList && data.thirdList.length > 0, data.thirdList.length > 0)
|
||||
if (data.thirdList && data.thirdList.length > 0) {
|
||||
// let inThird = false
|
||||
for (let i = 0; i < data.thirdList.length; i++) {
|
||||
const thirdUser = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'uni-id-users',
|
||||
whereJson: {
|
||||
mobile: data.thirdList[i].phone
|
||||
}
|
||||
})
|
||||
if (!thirdUser) return {
|
||||
code: -1,
|
||||
msg: `该用户:${data.thirdList[i].phone}不存在`
|
||||
}
|
||||
if (!thirdUser.fadadaConfirm) return {
|
||||
code: -1,
|
||||
msg: `该用户:${data.thirdList[i].phone}未通过法大大认证,无法签约`
|
||||
}
|
||||
if (thirdUser.uid === uid) return {
|
||||
code: -1,
|
||||
msg: '第三方不能为自己'
|
||||
}
|
||||
if (thirdUser.uid === otherUser._id) return {
|
||||
code: -1,
|
||||
msg: '第三方不能与对方为相同账号'
|
||||
}
|
||||
if (data.payBy === 2 && i === 0) {
|
||||
payByUser = thirdUser
|
||||
}
|
||||
}
|
||||
// if (data.payBy === 2 && !inThird) return {
|
||||
// code: -1,
|
||||
// msg: '该承担方不在第三方名单中'
|
||||
// }
|
||||
}
|
||||
|
||||
if (!otherUser.fadadaConfirm) return {
|
||||
code: -1,
|
||||
msg: '签约接收方账号未通过法大大认证,无法签约'
|
||||
}
|
||||
|
||||
if (otherUser._id === uid) return {
|
||||
code: -1,
|
||||
msg: '无法与自己签约'
|
||||
}
|
||||
if (payByUser.qybNum <= 0) return {
|
||||
code: -1,
|
||||
msg: '费用承担方已无签约宝次数,无法继续签约'
|
||||
}
|
||||
data.payerUid = payByUser._id
|
||||
data.transactionId = vk.pubfn.createOrderNo("C", 20)
|
||||
let doc_url = data.contractFile
|
||||
if (Array.isArray(doc_url)) doc_url = doc_url[doc_url.length - 1]
|
||||
const uploaddocs = await pubFun.fadada('uploaddocs.api', {
|
||||
contract_id: data.transactionId,
|
||||
doc_title: data.title,
|
||||
doc_url,
|
||||
// file: doc_url,
|
||||
doc_type: '.pdf'
|
||||
})
|
||||
if (parseInt(uploaddocs.code) === 1000) {
|
||||
let partyCount = 2
|
||||
if (data.thirdList && data.thirdList.length > 0) partyCount += data.thirdList.length
|
||||
// 对方是甲方
|
||||
const buyerSignKeyword = data.buyerSignKeyword // 签约发起方
|
||||
const sellerSignKeyword = data.sellerSignKeyword // 签约被邀请方
|
||||
data.buyerSignKeyword = data.userType % 2 === 1 ? sellerSignKeyword : buyerSignKeyword
|
||||
data.sellerSignKeyword = data.userType % 2 === 1 ? buyerSignKeyword : sellerSignKeyword
|
||||
const contractId = await vk.baseDao.add({
|
||||
dbName: 'jjx-contract',
|
||||
dataJson: {
|
||||
...data, ...{
|
||||
status: 1,
|
||||
userId: uid,
|
||||
changeNum: 0,
|
||||
productTitle: data.title,
|
||||
docTitle: data.title,
|
||||
type: 'sign',
|
||||
contractBase: data.contractFile,
|
||||
partyCount,
|
||||
signCount: 0,
|
||||
tradeMethod: data.tradeMethod
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
await vk.daoCenter.userContractDao.adds([
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("S", 20),
|
||||
userId: uid,
|
||||
role: data.userType === 1 ? 'seller' : 'buyer',
|
||||
sign: false,
|
||||
contractId,
|
||||
},
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("S", 20),
|
||||
userId: otherUser._id,
|
||||
role: data.userType === 1 ? 'buyer' : 'seller',
|
||||
sign: false,
|
||||
contractId,
|
||||
}
|
||||
])
|
||||
|
||||
if (data.thirdList && data.thirdList.length > 0) {
|
||||
for (let i = 0; i < data.thirdList.length; i++) {
|
||||
const thirdUser = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'uni-id-users',
|
||||
whereJson: {
|
||||
mobile: data.thirdList[i].phone
|
||||
}
|
||||
})
|
||||
console.log('thirdUser', thirdUser)
|
||||
if (thirdUser) {
|
||||
await vk.daoCenter.userContractDao.adds([
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("ST", 20),
|
||||
userId: thirdUser._id,
|
||||
role: 'third',
|
||||
sign: false,
|
||||
contractId,
|
||||
keyword: data.thirdList[i].signKeyword,
|
||||
},
|
||||
])
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: thirdUser._id,
|
||||
title: `金久信签约宝`,
|
||||
content: `您有签约宝邀请,赶紧去签订合同吧`,
|
||||
type: 'contract',
|
||||
hasRead: false,
|
||||
}
|
||||
});
|
||||
}
|
||||
// await pubFun.sendNotifySms(thirdUser._id, 'SMS_474570002', {
|
||||
// name: thirdUser.accountType === 2 ? thirdUser.company.companyName : thirdUser.person.personName,
|
||||
// name2: userInfo.accountType === 2 ? userInfo.company.companyName : userInfo.person.personName,
|
||||
// })
|
||||
}
|
||||
}
|
||||
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "uni-id-users",
|
||||
id: payByUser._id,
|
||||
dataJson: {
|
||||
qybNum: _.inc(-1)
|
||||
}
|
||||
});
|
||||
|
||||
// 签约宝扣费记录
|
||||
const remainNum = payByUser.qybNum - 1
|
||||
const addSignLog = await vk.baseDao.add({
|
||||
dbName: "jjx-sign-pay_list",
|
||||
dataJson: {
|
||||
userId: payByUser._id,
|
||||
remainNum,
|
||||
contractId,
|
||||
payBy: data.payBy
|
||||
}
|
||||
});
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: otherUser._id,
|
||||
title: `金久信签约宝`,
|
||||
content: `您有金久信签约宝邀请,赶紧去签订合同吧`,
|
||||
type: 'contract',
|
||||
hasRead: false,
|
||||
}
|
||||
});
|
||||
// await pubFun.sendNotifySms(otherUser._id, 'SMS_474570002', {
|
||||
// name: otherUser.accountType === 2 ? otherUser.company.companyName : otherUser.person.personName,
|
||||
// name2: userInfo.accountType === 2 ? userInfo.company.companyName : userInfo.person.personName,
|
||||
// })
|
||||
|
||||
}
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/qyb/list/kh/buy 前端调用的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, contractId, contractNo, amount} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const amountDict = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: 'ded3e568662e5817000026633aad1e69'
|
||||
})
|
||||
|
||||
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: 12,
|
||||
amount,
|
||||
offAmount,
|
||||
saveAmount,
|
||||
offRate,
|
||||
}
|
||||
})
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-order-goods",
|
||||
dataJson: {
|
||||
orderId,
|
||||
goodsId: contractId,
|
||||
num: 1,
|
||||
goodsName: `合同:${contractNo}司法调证`,
|
||||
goodsPrice: amount,
|
||||
goodsCover: null,
|
||||
}
|
||||
})
|
||||
|
||||
res.data = orderId
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
const dbName = require('../../../../dao/config.js')
|
||||
module.exports = {
|
||||
/**
|
||||
* 添加司法调证服务申请
|
||||
* @url client/contract/certificate/add 前端调用的url参数地址
|
||||
* data 请求参数
|
||||
*/
|
||||
main: async (event) => {
|
||||
let { data = {}, userInfo, util, filterResponse, originalParam } = event;
|
||||
let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
|
||||
let { uid } = userInfo;
|
||||
let res = { code: 0, msg: "申请提交成功" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
// 生成交易编号
|
||||
const orderNo = vk.pubfn.createOrderNo("C", 20);
|
||||
|
||||
// 添加司法调证服务记录
|
||||
const certificateId = await vk.baseDao.add({
|
||||
dbName: "jjx-certificate",
|
||||
dataJson: {
|
||||
userId: uid,
|
||||
status: 0, // 0-待支付 1-已支付 2-处理中 3-已完成 4-已取消
|
||||
...data
|
||||
}
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const pdfParse = require('pdf-parse');
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const fileUrl = data.fileUrl
|
||||
const keywords = data.keywords
|
||||
|
||||
const dataBuffer = fs.readFileSync(fileUrl);
|
||||
const { text } = await pdfParse(dataBuffer);
|
||||
console.log('PDF全文:', text);
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
'use strict';
|
||||
const dbName = require("../../../../dao/config");
|
||||
const dayjs = require("dayjs");
|
||||
const PROCESS_PAY_METHOD = ['预付', '货到验收后付款', '提货付全款', '信誉采购,货到签单后账期:']
|
||||
const WRITE_INVOICE_TIME = ['付款当月(限20号之前付款,20号之后付款次月开票)', '付款后次月', '付款前']
|
||||
const INVOICE_TYPE = ['增值税专用发票13%', '增值税普通发票', '普通发票']
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* 删除合同
|
||||
* @url client/contract/kh/del 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const contract = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-contract',
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
},
|
||||
})
|
||||
|
||||
if (contract && contract.type === 'sign') {
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "uni-id-users",
|
||||
id: contract.payerUid,
|
||||
dataJson: {
|
||||
qybNum: _.inc(1)
|
||||
}
|
||||
});
|
||||
// await vk.baseDao.add({
|
||||
// dbName: "jjx-sign-pay_list",
|
||||
// dataJson: {
|
||||
// userId: contract.userId,
|
||||
// contractId,
|
||||
// payBy: data.payBy
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
await vk.baseDao.del({
|
||||
dbName: 'jjx-contract',
|
||||
whereJson: {
|
||||
_id: data.id,
|
||||
uid
|
||||
}
|
||||
})
|
||||
|
||||
await vk.baseDao.del({
|
||||
dbName: 'jjx-user-contract',
|
||||
whereJson: {
|
||||
contractId: data.id
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
'use strict';
|
||||
const dbName = require("../../../../dao/config.js")
|
||||
const dayjs = require("dayjs");
|
||||
module.exports = {
|
||||
/**
|
||||
* 签署合同
|
||||
* @url client/enquiry/quote/kh/extSign 前端调用的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, contractId } = data;
|
||||
let res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
// 获取用户ID
|
||||
const {fadadaCustomerId, fadadaSealId} = userInfo
|
||||
|
||||
// if(!fadadaSealId) {
|
||||
// return {
|
||||
// code: -1,
|
||||
// msg: '请在个人中心上传印章'
|
||||
// }
|
||||
// }
|
||||
|
||||
const contract = await vk.baseDao.findByWhereJson({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId,
|
||||
}
|
||||
})
|
||||
|
||||
// 时间判断
|
||||
if (contract.signEndDate && dayjs(contract.signEndDate).isBefore(dayjs())) {
|
||||
return {
|
||||
code: -1,
|
||||
msg: '合同已过期'
|
||||
}
|
||||
}
|
||||
|
||||
// 获取合同信息
|
||||
const userContract = await vk.baseDao.selects({
|
||||
dbName: dbName.userContract,
|
||||
getMain: true,
|
||||
getOne: true,
|
||||
whereJson: {
|
||||
contractId: contractId,
|
||||
userId: uid
|
||||
},
|
||||
foreignDB:[
|
||||
{
|
||||
dbName: dbName.contract,
|
||||
localKey:"contractId", // 主表外键字段名
|
||||
foreignKey: "_id", // 副表外键字段名
|
||||
as: "contract",
|
||||
limit: 1, // 当limit = 1时,以对象形式返回,否则以数组形式返回
|
||||
}
|
||||
],
|
||||
})
|
||||
console.log('userContract: ',userContract);
|
||||
|
||||
let sign_keyword = '';
|
||||
if(userContract.role === 'buyer') {
|
||||
sign_keyword = userContract.contract.buyerSignKeyword
|
||||
}else if(userContract.role === 'seller') {
|
||||
sign_keyword = userContract.contract.sellerSignKeyword
|
||||
}else if(userContract.role === 'third') {
|
||||
sign_keyword = userContract.keyword
|
||||
}
|
||||
let return_url = 'https://www.jinjiuxinzg.cn/#/pages/contract/index?tab=1'
|
||||
if (!data.isSignOnly) {
|
||||
if (!!data.isWap) return_url = 'https://m.jinjiuxinzg.cn/#/pages/public/contract?tab=1'
|
||||
}else {
|
||||
if (!!data.isWap) return_url = 'https://m.jinjiuxinzg.cn/signOnly/#/pages/public/contract?tab=1'
|
||||
else return_url = 'https://www.jinjiuxinzg.cn/signOnly/#/pages/contract/index?tab=1'
|
||||
}
|
||||
res.data = await pubFun.fadadaUrl('extsign.api', {
|
||||
transaction_id: userContract.transactionId,
|
||||
contract_id: contract.transactionId,
|
||||
customer_id: fadadaCustomerId,
|
||||
acrosspage_customer_id: fadadaCustomerId,
|
||||
doc_title: userContract.contract.docTitle,
|
||||
sign_keyword,
|
||||
// notify_url: 'https://fc-mp-0737e52b-fffa-4223-bcdf-d4ad3d9968a5.next.bspapp.com/fadada_contract_notify',
|
||||
// return_url: 'https://static-mp-0737e52b-fffa-4223-bcdf-d4ad3d9968a5.next.bspapp.com/#/pages/contract/index?tab=1'
|
||||
notify_url: 'https://tcb-n44byxi8bmrfrki-d4bn1c4a206d.service.tcloudbase.com/fadada_contract_notify',
|
||||
// return_url: 'https://tcb-nnexmh3j3i5hwh5-7caw62c422be-1252168680.tcloudbaseapp.com/#/pages/contract/index?tab=1'
|
||||
return_url
|
||||
})
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
'use strict';
|
||||
const dbName = require('../../../../dao/config.js')
|
||||
module.exports = {
|
||||
/**
|
||||
* 发起/创建合同
|
||||
* @url client/contract/kh/launch 前端调用的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, contractId,title,contractFile,otherFile,signEndDate,buyerSignKeyword, sellerSignKeyword } = data;
|
||||
let res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const contract = await vk.baseDao.findByWhereJson({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId,
|
||||
userId: uid
|
||||
}
|
||||
})
|
||||
console.log('contract: ',dbName.contract,uid);
|
||||
// 上传合同模板并填充
|
||||
pubFun.fadada('generate_contract.api', {
|
||||
template_id: '20231120',
|
||||
contract_id: contract.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: contract.sellerSupplement,
|
||||
}),
|
||||
})
|
||||
|
||||
|
||||
const uploaddocs = await pubFun.fadada('uploaddocs.api', {
|
||||
contract_id: contract.fadadaContractId,
|
||||
doc_title: title,
|
||||
doc_url: contractFile,
|
||||
// file: doc_url,
|
||||
doc_type: '.pdf'
|
||||
})
|
||||
|
||||
if(uploaddocs.code == 1000) {
|
||||
await vk.baseDao.update({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId,
|
||||
userId: uid
|
||||
},
|
||||
dataJson: {
|
||||
status: 1,
|
||||
docTitle: title,
|
||||
signEndDate,
|
||||
otherFile,
|
||||
contractBase: contractFile,
|
||||
buyerSignKeyword,
|
||||
sellerSignKeyword
|
||||
}
|
||||
})
|
||||
|
||||
res.data = uploaddocs.result
|
||||
}else {
|
||||
return {
|
||||
code: -1,
|
||||
msg: uploaddocs.msg
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
const dbName = require("../../../../dao/config");
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/contract/kh/getDetail 前端调用的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, contractId } = data;
|
||||
let res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res.data = await vk.baseDao.findByWhereJson({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId,
|
||||
userId: uid
|
||||
}
|
||||
})
|
||||
|
||||
const partyList = await vk.baseDao.selects({
|
||||
dbName: dbName.userContract,
|
||||
whereJson: {
|
||||
contractId
|
||||
},
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "uni-id-users",
|
||||
localKey: "userId",
|
||||
foreignKey: "_id",
|
||||
as: "user",
|
||||
limit: 1, // limit=1则以对象形式返回
|
||||
fieldJson: {
|
||||
_id: true,
|
||||
mobile: true,
|
||||
},
|
||||
}
|
||||
]
|
||||
});
|
||||
res.data.partyList = partyList.rows
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/contract/kh/report 前端调用的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 {contract_id} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
await pubFun.fadada('contractFiling.api', {
|
||||
contract_id
|
||||
})
|
||||
const result = await pubFun.fadada('downLoadContract.api', {
|
||||
contract_id
|
||||
})
|
||||
console.log(result)
|
||||
if (parseInt(result.code) === 1000) {
|
||||
res.data = result
|
||||
}
|
||||
return res
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
'use strict';
|
||||
const dbName = require('../../../../dao/config.js')
|
||||
module.exports = {
|
||||
/**
|
||||
* 获取我的合同列表
|
||||
* @url client/enquiry/contract/kh/getList 前端调用的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, tradeMethod, status, type, signType} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const lastWhereJson = {}
|
||||
const whereJson = {
|
||||
userId: uid
|
||||
}
|
||||
if (vk.pubfn.isNotNull(tradeMethod) && tradeMethod != null) lastWhereJson['contract.tradeMethod'] = tradeMethod
|
||||
|
||||
if (vk.pubfn.isNotNull(status) && status != null) lastWhereJson['contract.status'] = status
|
||||
if (vk.pubfn.isNotNull(type) && type != null) lastWhereJson['contract.type'] = type
|
||||
if (vk.pubfn.isNotNull(signType) && signType != null && status !== 1) {
|
||||
if (signType === '1') lastWhereJson['contract.signType'] = signType
|
||||
else {
|
||||
lastWhereJson['contract.signType'] = _.in(['2', undefined])
|
||||
}
|
||||
}
|
||||
|
||||
res = await vk.daoCenter.userContractDao.selects({
|
||||
// data: {
|
||||
// pageIndex,
|
||||
// pageSize
|
||||
// },
|
||||
whereJson: whereJson,
|
||||
sortArr: [{"name": "_add_time", "type": "desc"}],
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: dbName.contract,
|
||||
localKey: "contractId", // 主表外键字段名
|
||||
foreignKey: "_id", // 副表外键字段名
|
||||
as: "contract",
|
||||
limit: 1, // 当limit = 1时,以对象形式返回,否则以数组形式返回
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: dbName.userContract,
|
||||
localKey: "_id", // 主表外键字段名
|
||||
foreignKey: "contractId", // 副表外键字段名
|
||||
as: "partyList",
|
||||
limit: 100,
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: dbName.user,
|
||||
localKey: "userId", // 主表外键字段名
|
||||
foreignKey: "_id", // 副表外键字段名
|
||||
as: "user",
|
||||
limit: 1,
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: 'uni-id-users',
|
||||
localKey: "_id", // 主表外键字段名
|
||||
foreignKey: "userId", // 副表外键字段名
|
||||
company: {
|
||||
companyName: true
|
||||
},
|
||||
person: {
|
||||
personName: true
|
||||
},
|
||||
businessCard: true,
|
||||
accountType: true,
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
dbName: 'jjx-sign-pay_list',
|
||||
localKey: "_id", // 主表外键字段名
|
||||
foreignKey: "contractId", // 副表外键字段名
|
||||
as: "payUser",
|
||||
limit: 1,
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: dbName.user,
|
||||
localKey: "userId", // 主表外键字段名
|
||||
foreignKey: "_id", // 副表外键字段名
|
||||
as: "user",
|
||||
limit: 1
|
||||
},
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
dbName: 'jjx-certificate',
|
||||
localKey: "_id", // 主表外键字段名
|
||||
foreignKey: "contractId", // 副表外键字段名
|
||||
as: "certificate",
|
||||
limit: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
lastWhereJson: lastWhereJson
|
||||
})
|
||||
|
||||
let result = {
|
||||
rows: [],
|
||||
total: 0,
|
||||
hasMore: false,
|
||||
code: 0,
|
||||
msg: "查询成功",
|
||||
}
|
||||
console.log("rows", res.rows)
|
||||
if (vk.pubfn.isNotNull(data.keyword) && data.keyword != null && data.keyword) {
|
||||
const userList = await vk.baseDao.select({
|
||||
dbName: "uni-id-users",
|
||||
getCount: true,
|
||||
whereJson: _.or([
|
||||
{
|
||||
mobile: data.keyword
|
||||
},
|
||||
{
|
||||
'person.personName': data.keyword
|
||||
},
|
||||
{
|
||||
'company.companyName': data.keyword
|
||||
}
|
||||
])
|
||||
});
|
||||
console.log("userList", userList)
|
||||
if (userList.total > 0) {
|
||||
for (let i in res.rows) {
|
||||
const row = res.rows[i]
|
||||
for (let j in row.contract.partyList) {
|
||||
const party = row.contract.partyList[j]
|
||||
for (let k in userList.rows) {
|
||||
const user = userList.rows[k]
|
||||
if (party.user._id === user._id) {
|
||||
result.rows.push(row)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result.total = result.rows.length
|
||||
} else {
|
||||
result = res
|
||||
}
|
||||
|
||||
for (let i in result.rows) {
|
||||
const row = result.rows[i]
|
||||
let sheet = null, order = null
|
||||
if (row.contract) {
|
||||
row.contract.isMine = row.contract.userId === uid
|
||||
if (row.contract.type === 'enquiry' && row.contract.sheetId) {
|
||||
sheet = await vk.baseDao.findById({
|
||||
dbName: 'jjx-enquiry-sheet',
|
||||
id: row.contract.sheetId
|
||||
})
|
||||
} else if (row.contract.type === 'process' && row.contract.sheetId) {
|
||||
sheet = await vk.baseDao.findById({
|
||||
dbName: 'jjx-process-sheet',
|
||||
id: row.contract.sheetId
|
||||
})
|
||||
} else if (row.contract.type === 'old' && row.contract.sheetId) {
|
||||
sheet = await vk.baseDao.findById({
|
||||
dbName: 'jjx-old',
|
||||
id: row.contract.sheetId
|
||||
})
|
||||
}
|
||||
order = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-order',
|
||||
whereJson: {
|
||||
contractId: row.contract._id
|
||||
}
|
||||
})
|
||||
if (row.contract.certificate) {
|
||||
const orderGoods = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-order-goods",
|
||||
whereJson: {
|
||||
goodsId: row.contract._id
|
||||
}
|
||||
})
|
||||
if (orderGoods) {
|
||||
row.contract.certificate.orderId = orderGoods.orderId
|
||||
}
|
||||
}
|
||||
}
|
||||
result.rows[i].sheet = sheet
|
||||
result.rows[i].order = order
|
||||
}
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
'use strict';
|
||||
const dbName = require('../../../../dao/config.js')
|
||||
module.exports = {
|
||||
/**
|
||||
* 发起/创建合同
|
||||
* @url client/contract/kh/launch 前端调用的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, contractId, title, contractFile, otherFile, signEndDate, buyerSignKeyword, sellerSignKeyword} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const otherUser = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-user-contract',
|
||||
whereJson: {
|
||||
contractId: contractId,
|
||||
userId: _.neq(uid)
|
||||
}
|
||||
})
|
||||
if (data.thirdList && data.thirdList.length > 0) {
|
||||
for (let i = 0; i < data.thirdList.length; i++) {
|
||||
if (data.thirdList[i].phone) {
|
||||
const thirdUser = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'uni-id-users',
|
||||
whereJson: {
|
||||
mobile: data.thirdList[i].phone
|
||||
}
|
||||
})
|
||||
if (!thirdUser) return {
|
||||
code: -1,
|
||||
msg: `该用户:${data.thirdList[i].phone}不存在`
|
||||
}
|
||||
if (!thirdUser.fadadaConfirm) return {
|
||||
code: -1,
|
||||
msg: `该用户:${data.thirdList[i].phone}未通过法大大认证,无法签约`
|
||||
}
|
||||
if (thirdUser.uid === uid) return {
|
||||
code: -1,
|
||||
msg: '第三方不能为自己'
|
||||
}
|
||||
if (thirdUser.uid === otherUser._id) return {
|
||||
code: -1,
|
||||
msg: '第三方不能与对方为相同账号'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const contract = await vk.baseDao.findByWhereJson({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId,
|
||||
userId: uid
|
||||
}
|
||||
})
|
||||
console.log('contract: ', contract);
|
||||
let newTransactionId = vk.pubfn.createOrderNo("C", 20)
|
||||
let doc_url = contractFile
|
||||
if (Array.isArray(doc_url)) doc_url = doc_url[doc_url.length - 1]
|
||||
const uploaddocs = await pubFun.fadada('uploaddocs.api', {
|
||||
contract_id: newTransactionId,
|
||||
doc_title: title,
|
||||
doc_url,
|
||||
// file: doc_url,
|
||||
doc_type: '.pdf'
|
||||
})
|
||||
let otherFileResList = []
|
||||
// 存在附件则合并
|
||||
if (otherFile && otherFile.length > 0) {
|
||||
for (let i = 0; i < otherFile.length; i++) {
|
||||
otherFileResList.push(newTransactionId + i.toString())
|
||||
await pubFun.fadada('uploaddocs.api', {
|
||||
contract_id: newTransactionId + i.toString(),
|
||||
doc_title: title + `:附件${i + 1}`,
|
||||
doc_url: otherFile[i],
|
||||
doc_type: '.pdf'
|
||||
})
|
||||
}
|
||||
otherFileResList.unshift(newTransactionId)
|
||||
|
||||
// 合并接口
|
||||
newTransactionId = vk.pubfn.createOrderNo("MC", 20)
|
||||
const mergeRes = await pubFun.fadada('merge_contract.api', {
|
||||
contract_id: newTransactionId,
|
||||
doc_title: title,
|
||||
contract_ids: otherFileResList.join()
|
||||
})
|
||||
console.log('mergeRes', mergeRes)
|
||||
console.log('otherFileResList', otherFileResList)
|
||||
}
|
||||
await vk.baseDao.update({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId
|
||||
},
|
||||
dataJson: {
|
||||
transactionId: newTransactionId,
|
||||
}
|
||||
})
|
||||
if (parseInt(uploaddocs.code) === 1000) {
|
||||
let partyCount = 2
|
||||
if (data.thirdList && data.thirdList.length > 0) partyCount += data.thirdList.filter(item => !!item.phone).length
|
||||
const contract = await vk.baseDao.updateAndReturn({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId,
|
||||
userId: uid
|
||||
},
|
||||
dataJson: {
|
||||
status: 1,
|
||||
docTitle: title,
|
||||
signEndDate,
|
||||
otherFile,
|
||||
partyCount,
|
||||
contractBase: contractFile,
|
||||
buyerSignKeyword,
|
||||
sellerSignKeyword
|
||||
}
|
||||
})
|
||||
if (contract.type === 'enquiry') {
|
||||
await vk.baseDao.update({
|
||||
dbName: 'jjx-enquiry-sheet',
|
||||
whereJson: {
|
||||
_id: contract.sheetId
|
||||
},
|
||||
dataJson: {
|
||||
status: 2,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// const otherUser = await vk.baseDao.findByWhereJson({
|
||||
// dbName: 'jjx-user-contract',
|
||||
// whereJson: {
|
||||
// contractId: contractId,
|
||||
// userId: _.neq(uid)
|
||||
// }
|
||||
// })
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: otherUser.userId,
|
||||
title: `您有新的合同待签署`,
|
||||
content: `您有新的合同待签署,赶紧去签合同吧`,
|
||||
type: 'contract',
|
||||
hasRead: false,
|
||||
}
|
||||
});
|
||||
// await pubFun.sendNotifySms(otherUser.userId, 'SMS_474525001')
|
||||
await vk.baseDao.del({
|
||||
dbName: 'jjx-user-contract',
|
||||
whereJson: {
|
||||
contractId,
|
||||
role: 'third',
|
||||
}
|
||||
})
|
||||
await vk.baseDao.del({
|
||||
dbName: 'jjx-message',
|
||||
whereJson: {
|
||||
contractId,
|
||||
type: 'contract',
|
||||
isThird: true
|
||||
}
|
||||
})
|
||||
if (data.thirdList && data.thirdList.length > 0) {
|
||||
console.log('data.thirdList', data.thirdList)
|
||||
for (let i = 0; i < data.thirdList.length; i++) {
|
||||
if (data.thirdList[i].phone) {
|
||||
|
||||
const thirdUser = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'uni-id-users',
|
||||
whereJson: {
|
||||
mobile: data.thirdList[i].phone
|
||||
}
|
||||
})
|
||||
if (thirdUser) {
|
||||
await vk.daoCenter.userContractDao.adds([
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("ST", 20),
|
||||
userId: thirdUser.uid,
|
||||
role: 'third',
|
||||
sign: false,
|
||||
contractId,
|
||||
keyword: data.thirdList[i].signKeyword,
|
||||
},
|
||||
])
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: thirdUser.uid,
|
||||
title: `合同`,
|
||||
content: `您有合同待签署,赶紧去签订合同吧`,
|
||||
type: 'contract',
|
||||
hasRead: false,
|
||||
contractId,
|
||||
isThird: true
|
||||
}
|
||||
});
|
||||
}
|
||||
// await pubFun.sendNotifySms(thirdUser._id, 'SMS_474525001')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res.data = uploaddocs.result
|
||||
} else {
|
||||
return {
|
||||
code: -1,
|
||||
msg: uploaddocs.msg
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/contract/kh/report 前端调用的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 {contractNum, evidenceType} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const url = 'https://tczapi.fadada.com/czapi/api/compliance-contract-report'
|
||||
// const url = 'https://czapi-test.fadada.com/evidence-api/api/compliance-contract-report'
|
||||
const result = await pubFun.fadada(url, {
|
||||
contractNum,
|
||||
evidenceType
|
||||
}, true)
|
||||
if (parseInt(result.code) === 1000) {
|
||||
res.data = result.data
|
||||
}
|
||||
return res
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/contract/kh/stopContract 前端调用的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.updateById({
|
||||
dbName: "jjx-contract",
|
||||
id: data.id,
|
||||
dataJson: {
|
||||
// status:
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
const dbName = require('../../../../dao/config.js')
|
||||
module.exports = {
|
||||
/**
|
||||
* 查看合同
|
||||
* @url client/contract/kh/view 前端调用的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, contractId } = data;
|
||||
let res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const contract = await vk.daoCenter.contractDao.selects({
|
||||
whereJson: {
|
||||
_id: contractId
|
||||
},
|
||||
getOne: true,
|
||||
getMain: true
|
||||
})
|
||||
|
||||
const viewRes = pubFun.fadadaUrl('viewContract.api', {
|
||||
contract_id: contract.transactionId
|
||||
})
|
||||
|
||||
res.data = viewRes
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/contract/kh/report 前端调用的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 {contract_id} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
// const fileContent = await pubFun.fadada('downLoadContract.api', {
|
||||
// contract_id
|
||||
// })
|
||||
// const {fileID} = await uniCloud.uploadFile({
|
||||
// cloudPath: md5(contract_id) + '.pdf',
|
||||
// fileContent
|
||||
// })
|
||||
// const {fileList} = await uniCloud.getTempFileURL({
|
||||
// fileList: [fileID]
|
||||
// })
|
||||
// res.data = fileList[0].tempFileURL
|
||||
const timestamp = vk.pubfn.timeFormat(new Date(), "yyyyMMddhhmmss");
|
||||
return {
|
||||
code: 0,
|
||||
msg: "",
|
||||
data: {
|
||||
msg_digest: pubFun.getFadadaSign('downLoadContract.api', {contract_id}, timestamp),
|
||||
timestamp,
|
||||
app_id: 502704
|
||||
}
|
||||
}
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/coop/config/pub/getList 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.select({
|
||||
dbName: 'jjx-coop-config',
|
||||
whereJson: {
|
||||
type: data.type,
|
||||
},
|
||||
sortArr: [
|
||||
{name: "sort", type: "asc"},
|
||||
{name: "_id", type: "desc"},
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/dict/pub/getDetail 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.findById({
|
||||
dbName: "jjx-dict",
|
||||
id: data.id
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
const dbName = 'jjx-enquiry-attributes'
|
||||
module.exports = {
|
||||
/**
|
||||
* 查询现货列表
|
||||
* @url client/spot/goods/kh/getList 前端调用的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: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const {pageIndex,pageSize,label } = data
|
||||
|
||||
let whereJson = {
|
||||
enable: true,
|
||||
label
|
||||
};
|
||||
|
||||
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName,
|
||||
getCount:false,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
// 主表where条件
|
||||
whereJson: whereJson,
|
||||
// 主表字段显示规则
|
||||
fieldJson:{},
|
||||
// 主表排序规则
|
||||
sortArr:[{ name:"sort", type:"asc" }],
|
||||
|
||||
});
|
||||
|
||||
res.rows.forEach(item => {
|
||||
item.options = item.values.map(citem => {
|
||||
return {
|
||||
label: citem,
|
||||
value: citem
|
||||
}
|
||||
})
|
||||
delete item.values
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
const dbName = 'jjx-enquiry-attributes'
|
||||
module.exports = {
|
||||
/**
|
||||
* 查询现货列表
|
||||
* @url client/spot/goods/kh/getList 前端调用的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: "",list: [] };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const {pageIndex,pageSize,label } = data
|
||||
|
||||
let whereJson = {
|
||||
enable: true,
|
||||
label
|
||||
};
|
||||
|
||||
|
||||
|
||||
const info = await vk.baseDao.findByWhereJson({
|
||||
dbName,
|
||||
getCount:false,
|
||||
whereJson: whereJson,
|
||||
});
|
||||
|
||||
if(info != null) {
|
||||
res.list = info.values.map(item => {
|
||||
return {
|
||||
label: item,
|
||||
value: item
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* 查询商品分类列表
|
||||
* @url client/product/category/pub/getAll 前端调用的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, whereJson } = data;
|
||||
let res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
let dbName = "jjx-enquiry-category";
|
||||
res.data = await vk.baseDao.selects({
|
||||
dbName,
|
||||
getMain: true,
|
||||
whereJson,
|
||||
pageSize: -1
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* 查询商品分类列表
|
||||
* @url client/product/category/pub/getAll 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
let dbName = "jjx-enquiry-category";
|
||||
res = await vk.baseDao.selects({
|
||||
dbName,
|
||||
pageIndex: 1,
|
||||
pageSize: 500,
|
||||
whereJson: {
|
||||
parent_id: _.in([null, ""]),
|
||||
_id: _.exists(true)
|
||||
},
|
||||
sortArr: [{name: "sort", type: "asc"}],
|
||||
// 树状结构参数
|
||||
treeProps: {
|
||||
id: "_id", // 唯一标识字段,默认为 _id
|
||||
parent_id: "parent_id", // 父级标识字段,默认为 parent_id
|
||||
children: "children", // 自定义返回的下级字段名,默认为 children
|
||||
level: 3, // 查询返回的树的最大层级。超过设定层级的节点不会返回。默认10级,最大15,最小1
|
||||
limit: 500, // 每一级最大返回的数据。
|
||||
whereJson: {}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* 获取我的合同列表
|
||||
* @url client/enquiry/contract/kh/getList 前端调用的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: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.getTableData({
|
||||
dbName: 'jjx-contract',
|
||||
data
|
||||
})
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
'use strict';
|
||||
const dayjs = require("dayjs");
|
||||
var isBetween = require('dayjs/plugin/isBetween')
|
||||
dayjs.extend(isBetween)
|
||||
|
||||
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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
let noQuoteNo = false
|
||||
if (parseInt(userInfo.userLevel) < 3) {
|
||||
if (parseInt(userInfo.remainQuoteNum) === 0 || !userInfo.remainQuoteNum) {
|
||||
const checkSheetQuoteNum = await vk.baseDao.findById({
|
||||
dbName: "jjx-enquiry-sheet",
|
||||
id: data.sheetId
|
||||
})
|
||||
if (checkSheetQuoteNum.quoteAmount) {
|
||||
const checkQuoteNum = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-user-quote-num",
|
||||
whereJson: {
|
||||
uid,
|
||||
type: 'enquiry',
|
||||
sheetId: data.sheetId,
|
||||
}
|
||||
});
|
||||
if (!checkQuoteNum || checkQuoteNum.num === 0) noQuoteNo = true
|
||||
} else noQuoteNo = true
|
||||
}
|
||||
noQuoteNo = !!(userInfo.quoteExpiredAt && dayjs(userInfo.quoteExpiredAt).isBefore(dayjs()));
|
||||
}
|
||||
if (noQuoteNo) {
|
||||
return {
|
||||
code: 1,
|
||||
msg: "您的报价次数已过期/用完"
|
||||
}
|
||||
}
|
||||
if (userInfo.remainQuoteNum && userInfo.remainQuoteNum > 0) {
|
||||
await vk.baseDao.update({
|
||||
dbName: "uni-id-users",
|
||||
whereJson: {
|
||||
uid
|
||||
},
|
||||
dataJson: {
|
||||
remainQuoteNum: _.inc(-1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
let subjectName = ''
|
||||
let subjectMobile = ''
|
||||
let managerName = ''
|
||||
let managerMobile = ''
|
||||
|
||||
const checkSheet = await vk.baseDao.findById({
|
||||
dbName: "jjx-enquiry-sheet",
|
||||
id: data.sheetId
|
||||
})
|
||||
|
||||
if (checkSheet.status > 0) return {
|
||||
code: -1,
|
||||
msg: "此询价单采购商已确认合作方,请您及时查看平台信息发布,及时报价,以免错过商机。"
|
||||
}
|
||||
|
||||
if (checkSheet.earnestMoney && checkSheet.earnestMoney > 0 && checkSheet.earnestMoney > userInfo.paidEnsure) {
|
||||
return {
|
||||
code: 12,
|
||||
msg: "您的保证金不足,请先缴纳保证金"
|
||||
}
|
||||
}
|
||||
|
||||
if (accountType === 1 && person.personName && person.mobile) {
|
||||
subjectName = person.personName
|
||||
subjectMobile = person.mobile
|
||||
} else {
|
||||
subjectName = company.companyName
|
||||
subjectMobile = company.mobile
|
||||
if (manager && manager.mobile && manager.personName) {
|
||||
managerName = manager.personName
|
||||
managerMobile = manager.mobile
|
||||
}
|
||||
}
|
||||
|
||||
// 添加报价单
|
||||
res.data = await vk.baseDao.add({
|
||||
dbName: "jjx-enquiry-quote",// 表名
|
||||
dataJson: { // 需要新增的数据 json格式
|
||||
...data,
|
||||
...{
|
||||
userId: data.uid,
|
||||
status: 0,
|
||||
subjectName,
|
||||
subjectMobile,
|
||||
managerName,
|
||||
managerMobile,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const sheet = await vk.baseDao.updateAndReturn({
|
||||
dbName: "jjx-enquiry-sheet",// 表名
|
||||
whereJson: {
|
||||
_id: data.sheetId,
|
||||
},
|
||||
dataJson: {
|
||||
quoteNum: _.inc(1)
|
||||
}
|
||||
})
|
||||
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "uni-id-users",// 表名
|
||||
id: data.uid,
|
||||
dataJson: {
|
||||
quoteTimes: _.inc(1)
|
||||
}
|
||||
})
|
||||
|
||||
const checkMessage = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-message-config",
|
||||
whereJson: {
|
||||
enquiry: true,
|
||||
uid: sheet.userId
|
||||
}
|
||||
})
|
||||
|
||||
if (checkMessage) {
|
||||
let send = true
|
||||
// if (checkMessage.doNotDisturbRange && checkMessage.doNotDisturbRange[0]) {
|
||||
// const date = dayjs().format("YYYY-MM-DD")
|
||||
// const doNotDisturbRangeStart = dayjs(checkMessage.doNotDisturbRange[0]).format("HH:mm")
|
||||
// const doNotDisturbRangeEnd = dayjs(checkMessage.doNotDisturbRange[1]).format("HH:mm")
|
||||
// if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
// send = false
|
||||
// }
|
||||
const date = dayjs().format("YYYY-MM-DD")
|
||||
if (checkMessage.doNotDisturbStart && checkMessage.doNotDisturbStart.length) {
|
||||
const doNotDisturbRangeStart = dayjs(`${date} ${checkMessage.doNotDisturbStart[0]}:${checkMessage.doNotDisturbStart[1]}`).format("HH:mm")
|
||||
const doNotDisturbRangeEnd = dayjs(`${date} ${checkMessage.doNotDisturbEnd[0]}:${checkMessage.doNotDisturbEnd[1]}`).format("HH:mm")
|
||||
if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
send = false
|
||||
}
|
||||
|
||||
if (checkMessage.tradeAmount && checkMessage.tradeAmount[0]) {
|
||||
if (sheet.totalPrice < checkMessage.tradeAmount[0] || sheet.totalPrice > checkMessage.tradeAmount[1])
|
||||
send = false
|
||||
}
|
||||
if (send) {
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: sheet.userId,
|
||||
title: `找供应:${sheet.title}报价`,
|
||||
content: `您的找供应信息有新的报价,赶紧去看看吧`,
|
||||
type: 'enquiry',
|
||||
hasRead: false,
|
||||
pk: data.sheetId
|
||||
}
|
||||
});
|
||||
await pubFun.sendNotifySms(sheet.userId, 'SMS_493290524')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,493 @@
|
||||
'use strict';
|
||||
|
||||
const dbName = require('../../../../../dao/config.js')
|
||||
const dayjs = require("dayjs");
|
||||
var isBetween = require('dayjs/plugin/isBetween')
|
||||
dayjs.extend(isBetween)
|
||||
|
||||
const PROCESS_PAY_METHOD = ['预付', '货到验收后付款', '提货付全款', '信誉采购,货到签单后账期:']
|
||||
const WRITE_INVOICE_TIME = ['付款当月(限20号之前付款,20号之后付款次月开票)', '付款后次月', '付款前']
|
||||
const INVOICE_TYPE = ['增值税专用发票13%', '增值税普通发票', '普通发票']
|
||||
|
||||
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 {
|
||||
pubFun,
|
||||
vk,
|
||||
} = util;
|
||||
let {
|
||||
uid,
|
||||
quoteId
|
||||
} = data;
|
||||
let res = {
|
||||
code: 0,
|
||||
msg: ""
|
||||
};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
// 修改报价单状态
|
||||
const quote = await vk.baseDao.updateAndReturn({
|
||||
dbName: 'jjx-enquiry-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.updateAndReturn({
|
||||
dbName: dbName.enquirySheet,
|
||||
whereJson: {_id: quote.sheetId},
|
||||
dataJson: {
|
||||
otherUid: quote.userId,
|
||||
status: 1
|
||||
}
|
||||
})
|
||||
|
||||
const checkMessage = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-message-config",
|
||||
whereJson: {
|
||||
enquiry: true,
|
||||
uid: quote.userId
|
||||
}
|
||||
})
|
||||
|
||||
if (checkMessage) {
|
||||
let send = true
|
||||
// if (checkMessage.doNotDisturbRange && checkMessage.doNotDisturbRange[0]) {
|
||||
// const date = dayjs().format("YYYY-MM-DD")
|
||||
// const doNotDisturbRangeStart = dayjs(checkMessage.doNotDisturbRange[0]).format("HH:mm")
|
||||
// const doNotDisturbRangeEnd = dayjs(checkMessage.doNotDisturbRange[1]).format("HH:mm")
|
||||
// if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
// send = false
|
||||
// }
|
||||
const date = dayjs().format("YYYY-MM-DD")
|
||||
if (checkMessage.doNotDisturbStart && checkMessage.doNotDisturbStart.length) {
|
||||
const doNotDisturbRangeStart = dayjs(`${date} ${checkMessage.doNotDisturbStart[0]}:${checkMessage.doNotDisturbStart[1]}`).format("HH:mm")
|
||||
const doNotDisturbRangeEnd = dayjs(`${date} ${checkMessage.doNotDisturbEnd[0]}:${checkMessage.doNotDisturbEnd[1]}`).format("HH:mm")
|
||||
if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
send = false
|
||||
}
|
||||
|
||||
if (send) {
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: quote.userId,
|
||||
title: `找买家:${sheet.title}被选商`,
|
||||
content: `您报价的找买家信息已被选商,赶紧去签合同吧`,
|
||||
type: 'contract',
|
||||
hasRead: false,
|
||||
pk: data.sheetId
|
||||
}
|
||||
});
|
||||
await pubFun.sendNotifySms(quote.userId, 'SMS_474250536')
|
||||
}
|
||||
}
|
||||
|
||||
// 获取商品信息
|
||||
const otherCate = sheet.otherCate ? String(sheet.otherCate).trim() : ''
|
||||
const sheetProductList = otherCate ? [{
|
||||
goodsName: otherCate,
|
||||
procureNumber: sheet.procureNumber,
|
||||
procureUnit: sheet.procureUnit,
|
||||
}] : (Array.isArray(sheet.productList) ? sheet.productList : [])
|
||||
const productTitle = sheetProductList.map(item => item.goodsName).filter(Boolean).join("/") || sheet.title
|
||||
|
||||
if (sheet.signMethod !== 1) {
|
||||
const fadadaContractId = vk.pubfn.createOrderNo("E", 20)
|
||||
// 上传合同模板并填充
|
||||
|
||||
// 新增合同记录
|
||||
let contractTransactionId = vk.pubfn.createOrderNo("C", 20)
|
||||
const contractId = await vk.baseDao.add({
|
||||
dbName: 'jjx-contract',
|
||||
dataJson: {
|
||||
fadadaContractId,
|
||||
contractBase: '', // 原始合同
|
||||
contractHistory: [], // 历史合同
|
||||
contractFinal: '', // 归档合同
|
||||
status: 0,
|
||||
userId: uid,
|
||||
type: 'enquiry',
|
||||
quoteId: quoteId,
|
||||
sheetId: quote.sheetId,
|
||||
productList: sheetProductList,
|
||||
productTitle,
|
||||
tradeMethod: sheet.tradeMethod,
|
||||
partyCount: 2,
|
||||
signCount: 0,
|
||||
contractType: sheet.contractType,
|
||||
signMethod: sheet.signMethod,
|
||||
sellerSupplement: sheet.sellerSupplement,
|
||||
transactionId: contractTransactionId,
|
||||
amount: quote.totalPrice,
|
||||
docTitle: productTitle
|
||||
}
|
||||
})
|
||||
|
||||
// await vk.baseDao.updateById({
|
||||
// dbName: 'jjx-enquiry-sheet',
|
||||
// id: quote.sheetId,
|
||||
// dataJson: {
|
||||
// status: 1
|
||||
// }
|
||||
// })
|
||||
// await vk.baseDao.updateById({
|
||||
// dbName: 'jjx-enquiry-quote',
|
||||
// id: quoteId,
|
||||
// dataJson: {
|
||||
// status: 1
|
||||
// }
|
||||
// })
|
||||
|
||||
// 上传合同模板
|
||||
|
||||
//新增 用户与合同的关联记录
|
||||
await vk.daoCenter.userContractDao.adds([
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("E", 20),
|
||||
userId: quote.userId,
|
||||
role: 'seller',
|
||||
sign: false,
|
||||
contractId
|
||||
},
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("E", 20),
|
||||
userId: uid,
|
||||
role: 'buyer',
|
||||
sign: false,
|
||||
contractId
|
||||
}
|
||||
])
|
||||
|
||||
if (sheet.signMethod === 0) {
|
||||
const templateId = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '80e3bed065a5560e075799d24532b14f'
|
||||
})
|
||||
const buyerKeyword = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '0b153f9a65a56a2007227cf5157133bf'
|
||||
})
|
||||
const sellerKeyword = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '09e7876865a56a320731cb244bbef818'
|
||||
})
|
||||
const signMaxDate = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '657d78958b0da41d311bd94c'
|
||||
})
|
||||
const signEndDate = vk.pubfn.getOffsetTime(new Date(), {
|
||||
day: parseInt(signMaxDate.content),
|
||||
mode: "after",
|
||||
});
|
||||
// const fieldList = await vk.baseDao.select({
|
||||
// dbName: 'jjx-contract-template',
|
||||
// whereJson: {
|
||||
// isOn: true
|
||||
// }
|
||||
// })
|
||||
const sellerUser = await vk.baseDao.findById({
|
||||
dbName: 'uni-id-users',
|
||||
id: quote.userId
|
||||
})
|
||||
const buyerUser = await vk.baseDao.findById({
|
||||
dbName: 'uni-id-users',
|
||||
id: uid
|
||||
})
|
||||
|
||||
const sellerUserBank = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-account',
|
||||
whereJson: {
|
||||
uid: quote.userId,
|
||||
isDefault: true
|
||||
}
|
||||
})
|
||||
const buyerUserBank = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-account',
|
||||
whereJson: {
|
||||
uid: uid,
|
||||
isDefault: true
|
||||
}
|
||||
})
|
||||
|
||||
let tradeInfo = PROCESS_PAY_METHOD[sheet.payMethod]
|
||||
if (sheet.payMethod === 0 && sheet.advancePayRate) tradeInfo += `${sheet.advancePayRate}%货到付全款`
|
||||
if (sheet.payMethod === 3 && sheet.reputationPayDay) tradeInfo += `${sheet.reputationPayDay}天`
|
||||
tradeInfo += `,发票要求:${sheet.invoice ? '含税' : '不含税'},开票时间:` + WRITE_INVOICE_TIME[sheet.writeInvoiceTime]
|
||||
if (sheet.invoiceOther) tradeInfo += `,其他要求:${sheet.invoiceOther ? sheet.invoiceOther : '无'}`
|
||||
else {
|
||||
if (sheet.invoice)
|
||||
tradeInfo += `,纳税人身份:${sheet.taxType},发票种类:${sheet.invoiceType},税率:${sheet.taxRate}`
|
||||
}
|
||||
let expressRequire = ''
|
||||
expressRequire += `随货资料:${sheet.transportDocuments.join()},其他要求:${sheet.otherTransportDocuments ? sheet.otherTransportDocuments : '无'}${sheet.transportLimit ? '' : ',运输限制要求:无'}`
|
||||
if (sheet.transportLimit && sheet.otherTransportRequest) expressRequire += `,运输限制说明:${sheet.otherTransportRequest}`
|
||||
let detail = ''
|
||||
if (sheet.fillType === 0) {
|
||||
sheet.productList.forEach((item, index) => {
|
||||
detail += `${item.goodsName}(${item.procureNumber}${item.procureUnit})`
|
||||
if (item.deliverService) detail += ` ,${item.deliverService}`
|
||||
if (item.pricingForm) detail += ` ,${item.pricingForm}`
|
||||
if (item.loadPaidBy) detail += ` ,${item.loadPaidBy}`
|
||||
item.model.forEach((model) => {
|
||||
detail += `,${model.label}:${model.value}`
|
||||
})
|
||||
if (index < sheet.productList.length - 1) detail += '\r\n'
|
||||
})
|
||||
} else {
|
||||
detail = productTitle
|
||||
}
|
||||
let info = sheet.remark ? `其他要求:${sheet.remark}` : ''
|
||||
if (quote.remark) {
|
||||
if (info) info += `,${quote.remark}`
|
||||
else info = quote.remark
|
||||
}
|
||||
if (info === '') info = '无'
|
||||
|
||||
const accountType = sheet.invoice ? 'company' : 'person'
|
||||
const buyerBank = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-account",
|
||||
whereJson: {
|
||||
uid: buyerUser._id,
|
||||
type: accountType
|
||||
}
|
||||
})
|
||||
let buyerBankName = buyerUser.accountType === 2 ? buyerUser.company.companyBankName : buyerUser.person.personBankName
|
||||
let buyerAccount = buyerUser.accountType === 2 ? buyerUser.company.companyAccount : buyerUser.person.personAccount
|
||||
let buyerBankAccountName = buyerUser.accountType === 2 ? buyerUser.company.companyAccount : buyerUser.person.personAccount
|
||||
let sellerBankName = sellerUser.accountType === 2 ? sellerUser.company.companyBankName : sellerUser.person.personBankName
|
||||
let sellerAccount = sellerUser.accountType === 2 ? sellerUser.company.companyAccount : sellerUser.person.personAccount
|
||||
let sellerBankAccountName = sellerUser.accountType === 2 ? sellerUser.company.companyAccount : sellerUser.person.personAccount
|
||||
if (buyerBank) {
|
||||
buyerBankName = buyerBank.bankName
|
||||
buyerAccount = buyerBank.account
|
||||
buyerBankAccountName = buyerBank.accountName
|
||||
}
|
||||
const sellerBank = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-account",
|
||||
whereJson: {
|
||||
uid: sellerUser._id,
|
||||
type: accountType
|
||||
}
|
||||
})
|
||||
if (sellerBank) {
|
||||
sellerBankName = sellerBank.bankName
|
||||
sellerAccount = sellerBank.account
|
||||
sellerBankAccountName = sellerBank.accountName
|
||||
}
|
||||
|
||||
const parameter = {
|
||||
seller: sellerUser.accountType === 2 ? sellerUser.company.companyName : sellerUser.person.personName,
|
||||
buyer: buyerUser.accountType === 2 ? buyerUser.company.companyName : buyerUser.person.personName,
|
||||
date: dayjs().format('YYYY年MM月DD日'),
|
||||
sellerSignDate: dayjs(signEndDate).format('YYYY年MM月DD日 HH时mm分'),
|
||||
buyerSignDate: dayjs(signEndDate).format('YYYY年MM月DD日 HH时mm分'),
|
||||
// time: dayjs().format('HH:mm'),
|
||||
contractNo: fadadaContractId,
|
||||
region: sheet.addressRegion.province.name + sheet.addressRegion.city.name + sheet.addressRegion.area.name,
|
||||
detail,
|
||||
info,
|
||||
// content: '无',
|
||||
tradeInfo,
|
||||
expressRequire,
|
||||
defaultDuty: '1.乙方所交产品品种、型号、规格、质量不符合规定的,如果甲方同意利用,应当按质论价;如果甲方不能利用的,应根据产品的具体情况,由乙方负责包换或包修,并承担修理、调换或退货而支付的实际费用;2.乙方不予供货违约责任为甲方的实际损失+违约金,如乙方材料符合订货标准,甲方不能退货和不收货,甲方无条件应按实际本合同订货数量支付100%货款,并支付乙方因此产生的实际费用。带有甲乙双方单位相关收货人和发货人签字的本合同的发货清单事项和内容均视为本合同的补充合同,与本合同有相同的法律效力,双方应共同遵照执行。',
|
||||
solve: '1、凡因本合同引起的或与本合同有关的任何争议,均可友好协商或仲裁解决,协商或仲裁不成的,双方协商同意在合同签订地人民法院管辖地起诉,违约一方或对合同争议承担主要责任的一方,应承担对方因仲裁和起诉而产生的全部律师代理费、鉴定(检验)费、诉讼保全费、诉讼保险费、公告费、差旅费、执行费、误工費和获取证据产生费用等其他相关费用。2、双方本合同相关权利放弃均应有双方书面作出并加盖公章或授权委托人签字后生效。',
|
||||
forceMajeure: '甲乙双方的任何一方由于不可抗力或突发公共事件的原因不能履行合同时,应及时向对方通报不能履行或不能完全履行的理由,以减轻可能给对方造成的损失,在取得有关机构证明以后,允许延期履行、部分履行或者不履行合同,并根据情况可部分或全部免予承担违约责任。',
|
||||
other: '本合同的全部内容由双方平等共同协商一致,共同起草制定,非一方事先拟定,不属于格式条款。本合同自双方签字盖章后生效(包括电子签字、盖章),按本合同内容地址、联系方式寄送的一切文书、函件送达与否,均为视为送达有法律效力,通知途径和本合同内联系方式或地址送达文件双方均予以验证。',
|
||||
buyerSupplement: sheet.supplementary ? sheet.supplementary : '无',
|
||||
sellerSupplement: quote.supplierExt ? quote.supplierExt : '无',
|
||||
buyerAddress: buyerUser.accountType === 2 ? buyerUser.company.mailAddress : buyerUser.person.address,
|
||||
sellerAddress: sellerUser.accountType === 2 ? sellerUser.company.mailAddress : sellerUser.person.address,
|
||||
buyerLegal: buyerUser.accountType === 2 ? buyerUser.company.legalName : '',
|
||||
sellerLegal: sellerUser.accountType === 2 ? sellerUser.company.legalName : '',
|
||||
// buyerAgent: buyerUser.accountType === 2 ? buyerUser.manager.personName : '',
|
||||
buyerAgent: sheet.businessName,
|
||||
sellerAgent: sellerUser.accountType === 2 ? sellerUser.manager.personName : '',
|
||||
// buyerMobile: buyerUser.accountType === 2 ? buyerUser.manager.mobile : buyerUser.person.mobile,
|
||||
buyerMobile: sheet.businessMobile,
|
||||
sellerMobile: sellerUser.accountType === 2 ? sellerUser.manager.mobile : sellerUser.person.mobile,
|
||||
buyerBankName,
|
||||
sellerBankName,
|
||||
buyerAccount,
|
||||
sellerAccount,
|
||||
buyerBankAccountName,
|
||||
sellerBankAccountName,
|
||||
signName: sheet.signName ? sheet.signName : '',
|
||||
signIdCard: sheet.signIdCard ? sheet.signIdCard : '',
|
||||
}
|
||||
// for (let i = 0; i < fieldList.length; i++) {
|
||||
//
|
||||
// const field = fieldList[i]
|
||||
// parameter[field.field] = ''
|
||||
// }
|
||||
const uploaddocs = await pubFun.fadada('generate_contract.api', {
|
||||
template_id: templateId.content,
|
||||
contract_id: contractTransactionId,
|
||||
parameter_map: JSON.stringify(parameter)
|
||||
})
|
||||
let otherFileResList = []
|
||||
// 存在附件则合并
|
||||
// if (sheet.files && sheet.files.length > 0) {
|
||||
// for (let i = 0; i < sheet.files.length; i++) {
|
||||
// otherFileResList.push(contractTransactionId + i.toString())
|
||||
// await pubFun.fadada('uploaddocs.api', {
|
||||
// contract_id: contractTransactionId + i.toString(),
|
||||
// doc_title: sheet.title + `:附件${i + 1}`,
|
||||
// doc_url: sheet.files[i],
|
||||
// doc_type: '.pdf'
|
||||
// })
|
||||
// }
|
||||
// otherFileResList.unshift(contractTransactionId)
|
||||
//
|
||||
// // 合并接口
|
||||
// contractTransactionId = vk.pubfn.createOrderNo("MC", 20)
|
||||
// const mergeRes = await pubFun.fadada('merge_contract.api', {
|
||||
// contract_id: contractTransactionId,
|
||||
// doc_title: sheet.title,
|
||||
// contract_ids: otherFileResList.join()
|
||||
// })
|
||||
// console.log('mergeRes', mergeRes)
|
||||
// console.log('otherFileResList', otherFileResList)
|
||||
// }
|
||||
// 存在附件则合并
|
||||
if (quote.files && quote.files.length > 0) {
|
||||
for (let i = 0; i < quote.files.length; i++) {
|
||||
otherFileResList.push(contractTransactionId + 'qf' + i.toString())
|
||||
await pubFun.fadada('uploaddocs.api', {
|
||||
contract_id: contractTransactionId + 'qf' + i.toString(),
|
||||
doc_title: sheet.title + `:附件${i + 1}`,
|
||||
doc_url: quote.files[i],
|
||||
doc_type: '.pdf'
|
||||
})
|
||||
}
|
||||
otherFileResList.unshift(contractTransactionId)
|
||||
|
||||
// 合并接口
|
||||
contractTransactionId = vk.pubfn.createOrderNo("MC", 20)
|
||||
const mergeRes = await pubFun.fadada('merge_contract.api', {
|
||||
contract_id: contractTransactionId,
|
||||
doc_title: sheet.title,
|
||||
contract_ids: otherFileResList.join()
|
||||
})
|
||||
console.log('quote mergeRes', mergeRes)
|
||||
console.log('quote otherFileResList', otherFileResList)
|
||||
}
|
||||
await vk.baseDao.update({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId
|
||||
},
|
||||
dataJson: {
|
||||
transactionId: contractTransactionId,
|
||||
}
|
||||
})
|
||||
if (parseInt(uploaddocs.code) === 1000) {
|
||||
await vk.baseDao.update({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId,
|
||||
userId: uid
|
||||
},
|
||||
dataJson: {
|
||||
status: 1,
|
||||
docTitle: sheet.title,
|
||||
signEndDate,
|
||||
otherFile: '',
|
||||
contractBase: null,
|
||||
buyerSignKeyword: buyerKeyword.content,
|
||||
sellerSignKeyword: sellerKeyword.content
|
||||
}
|
||||
})
|
||||
// await vk.baseDao.updateAndReturn({
|
||||
// dbName: 'jjx-enquiry-sheet',
|
||||
// whereJson: {
|
||||
// _id: quote.sheetId
|
||||
// },
|
||||
// dataJson: {
|
||||
// status: 2
|
||||
// }
|
||||
// })
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: quote.userId,
|
||||
title: `询价:${sheet.title}待签合同`,
|
||||
content: `您报价的询价信息已创建合同,赶紧去签订合同吧`,
|
||||
type: 'contract',
|
||||
hasRead: false,
|
||||
pk: quote.sheetId
|
||||
}
|
||||
});
|
||||
await pubFun.sendNotifySms(quote.userId, 'SMS_474455034')
|
||||
res.data = uploaddocs.result
|
||||
} else {
|
||||
return {
|
||||
code: -1,
|
||||
msg: uploaddocs.msg
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const orderId = await vk.baseDao.add({
|
||||
dbName: "jjx-order",
|
||||
dataJson: {
|
||||
orderNo: vk.pubfn.createOrderNo("39XU", 20),
|
||||
uid: uid,
|
||||
sellerUid: quote.userId,
|
||||
orderStatus: 0,
|
||||
payStatus: 0,
|
||||
type: 4,
|
||||
amount: quote.totalPrice,
|
||||
offAmount: quote.totalPrice,
|
||||
signMethod: 1,
|
||||
sheetId: quote.sheetId,
|
||||
}
|
||||
})
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-order-goods",
|
||||
dataJson: {
|
||||
orderId,
|
||||
goodsId: null,
|
||||
num: 1,
|
||||
goodsName: productTitle || '询价单',
|
||||
goodsPrice: quote.totalPrice,
|
||||
goodsCover: null,
|
||||
}
|
||||
})
|
||||
}
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* 获取用户发布的询价单
|
||||
* @url client/enquiry/sheet/pub/getList 前端调用的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, keyword, categoryIds, provinceCodes, formData, status, isSeller} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
let dbName = "jjx-enquiry-quote";
|
||||
|
||||
let whereJson = {userId: uid};
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
getCount: true,
|
||||
whereJson,
|
||||
sortArr: [{name: "_add_time", type: "desc"}],
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "jjx-enquiry-sheet",
|
||||
localKey: "sheetId",
|
||||
foreignKey: "_id",
|
||||
as: "sheet",
|
||||
limit: 1,
|
||||
},
|
||||
]
|
||||
});
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* 上传合同
|
||||
* @url client/enquiry/quote/kh/uploadTemplate 前端调用的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, base64 } = data;
|
||||
let res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const file = pubFun.base64ToFile(base64, 'adv.pdf')
|
||||
|
||||
res.data = await pubFun.fadada('upload_template_docs.api', {
|
||||
contract_template_id: vk.pubfn.createOrderNo("Contract", 25),
|
||||
template_name: 'template_name',
|
||||
file: file
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/enquiry/sheet/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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
// 生成询价编号
|
||||
|
||||
let amountItem, amount, goodsName, id, sheet, isSingleQuote = false
|
||||
if (data.buyQuoteMode === 'single') {
|
||||
switch (data.type) {
|
||||
case 'enquiry' : {
|
||||
sheet = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-enquiry-sheet",
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
}
|
||||
})
|
||||
}
|
||||
break;
|
||||
case 'old' : {
|
||||
sheet = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-old",
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
}
|
||||
})
|
||||
}
|
||||
break;
|
||||
case 'process' : {
|
||||
sheet = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-process-sheet",
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
}
|
||||
})
|
||||
}
|
||||
break;
|
||||
}
|
||||
id = '6587b034466d41a591df881c'
|
||||
amountItem = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id
|
||||
})
|
||||
if (sheet.quoteAmount) {
|
||||
amount = sheet.quoteAmount
|
||||
isSingleQuote = true
|
||||
} else {
|
||||
amount = amountItem.content
|
||||
}
|
||||
goodsName = '单次报价购买'
|
||||
} else {
|
||||
id = data.buyQuoteMode
|
||||
amountItem = await vk.baseDao.findById({
|
||||
dbName: 'jjx-quote-num-config',
|
||||
id
|
||||
})
|
||||
amount = amountItem.amount
|
||||
goodsName = `${amountItem.name}报价购买`
|
||||
}
|
||||
|
||||
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: 7,
|
||||
amount,
|
||||
offAmount,
|
||||
saveAmount,
|
||||
offRate,
|
||||
}
|
||||
})
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-order-goods",
|
||||
dataJson: {
|
||||
orderId,
|
||||
goodsId: id,
|
||||
mode: data.buyQuoteMode === 'single' ? 'single' : 'monthly',
|
||||
num: 1,
|
||||
goodsName,
|
||||
goodsPrice: amount,
|
||||
goodsCover: null,
|
||||
isSingleQuote,
|
||||
sheetId: data.id,
|
||||
type: data.type,
|
||||
}
|
||||
})
|
||||
|
||||
res.data = orderId
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
'use strict';
|
||||
const dayjs = require("dayjs");
|
||||
var isBetween = require('dayjs/plugin/isBetween')
|
||||
dayjs.extend(isBetween)
|
||||
|
||||
const DEFAULT_NOTARY_SERVICE_RATE = 0.1;
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/enquiry/sheet/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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
// 生成询价编号
|
||||
|
||||
if (!userInfo.fadadaConfirm && userInfo.authStatus === 1) {
|
||||
return {
|
||||
code: 1,
|
||||
msg: '请先完成认证'
|
||||
}
|
||||
} else if (!userInfo.businessCard) {
|
||||
return {
|
||||
code: 1,
|
||||
msg: '请完善名片信息'
|
||||
}
|
||||
} else {
|
||||
if (userInfo.businessCard.status !== 1) {
|
||||
return {
|
||||
code: 1,
|
||||
msg: '您的名片信息未审核,请耐心等待'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 这里需要把 params1 params2 params3 改成你数据库里允许用户添加的字段
|
||||
let dbName = "jjx-enquiry-sheet";
|
||||
const notaryServiceRate = data.tradeMethod === 1
|
||||
? ((data.notaryServiceRate === undefined || data.notaryServiceRate === null || data.notaryServiceRate === '') ? DEFAULT_NOTARY_SERVICE_RATE : data.notaryServiceRate)
|
||||
: null
|
||||
res.id = await vk.baseDao.add({
|
||||
dbName,
|
||||
dataJson: {
|
||||
...data,
|
||||
...{
|
||||
answerNumber: 0,
|
||||
userId: uid,
|
||||
status: 0,
|
||||
quoteNum: 0,
|
||||
isShow: 0,
|
||||
notaryServiceRate
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
'use strict';
|
||||
const dbName = require("../../../../../dao/config");
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/enquiry/sheet/kh/changeToOnlineSign 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const sheet = await vk.baseDao.updateAndReturn({
|
||||
dbName: "jjx-enquiry-sheet",
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
},
|
||||
dataJson: {
|
||||
signMethod: 0,
|
||||
status: 1
|
||||
}
|
||||
});
|
||||
|
||||
const quote = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-enquiry-quote",
|
||||
whereJson: {
|
||||
sheetId: data.id,
|
||||
status: 1
|
||||
}
|
||||
});
|
||||
|
||||
if (quote) {
|
||||
|
||||
|
||||
const fadadaContractId = vk.pubfn.createOrderNo("E", 20)
|
||||
const contractTransactionId = vk.pubfn.createOrderNo("C", 20)
|
||||
|
||||
const contractId = await vk.baseDao.add({
|
||||
dbName: 'jjx-contract',
|
||||
dataJson: {
|
||||
fadadaContractId,
|
||||
contractBase: '', // 原始合同
|
||||
contractHistory: [], // 历史合同
|
||||
contractFinal: '', // 归档合同
|
||||
status: 0,
|
||||
userId: uid,
|
||||
type: 'enquiry',
|
||||
quoteId: quote.id,
|
||||
sheetId: quote.sheetId,
|
||||
productList: quote.productList,
|
||||
productTitle: sheet.title,
|
||||
tradeMethod: 0,
|
||||
partyCount: 2,
|
||||
signCount: 0,
|
||||
contractType: sheet.contractType,
|
||||
signMethod: sheet.signMethod,
|
||||
sellerSupplement: sheet.sellerSupplement,
|
||||
transactionId: contractTransactionId,
|
||||
amount: quote.totalPrice,
|
||||
docTitle: sheet.title
|
||||
}
|
||||
})
|
||||
|
||||
// 上传合同模板
|
||||
|
||||
//新增 用户与合同的关联记录
|
||||
await vk.daoCenter.userContractDao.adds([
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("E", 20),
|
||||
userId: quote.userId,
|
||||
role: 'seller',
|
||||
sign: false,
|
||||
contractId
|
||||
},
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("E", 20),
|
||||
userId: uid,
|
||||
role: 'buyer',
|
||||
sign: false,
|
||||
contractId
|
||||
}
|
||||
])
|
||||
}
|
||||
// const contractFile = await vk.baseDao.findById({
|
||||
// dbName: 'jjx-dict',
|
||||
// id: '657d36befe975f63af1f24e7'
|
||||
// })
|
||||
// const signMaxDate = await vk.baseDao.findById({
|
||||
// dbName: 'jjx-dict',
|
||||
// id: '657d78958b0da41d311bd94c'
|
||||
// })
|
||||
// const buyerSignKeyword = await vk.baseDao.findById({
|
||||
// dbName: 'jjx-dict',
|
||||
// id: '657d37972139294200fc9a01'
|
||||
// })
|
||||
// const sellerSignKeyword = await vk.baseDao.findById({
|
||||
// dbName: 'jjx-dict',
|
||||
// id: '657d37a609664c4f4a5c4afb'
|
||||
// })
|
||||
// const signEndDate = vk.pubfn.getOffsetTime(new Date(), {
|
||||
// day: parseInt(signMaxDate.content),
|
||||
// mode: "after",
|
||||
// });
|
||||
//
|
||||
// const uploaddocs = await pubFun.fadada('uploaddocs.api', {
|
||||
// contract_id: contractTransactionId,
|
||||
// doc_title: sheet.title,
|
||||
// doc_url: contractFile.content,
|
||||
// // file: doc_url,
|
||||
// doc_type: '.pdf'
|
||||
// })
|
||||
// if (parseInt(uploaddocs.code) === 1000) {
|
||||
// await vk.baseDao.updateAndReturn({
|
||||
// dbName: dbName.contract,
|
||||
// whereJson: {
|
||||
// _id: contractId,
|
||||
// userId: uid
|
||||
// },
|
||||
// dataJson: {
|
||||
// status: 1,
|
||||
// docTitle: sheet.title,
|
||||
// signEndDate,
|
||||
// otherFile: '',
|
||||
// contractBase: contractFile.content,
|
||||
// buyerSignKeyword: buyerSignKeyword.content,
|
||||
// sellerSignKeyword: sellerSignKeyword.content
|
||||
// }
|
||||
// })
|
||||
// await vk.baseDao.updateAndReturn({
|
||||
// dbName: 'jjx-enquiry-sheet',
|
||||
// whereJson: {
|
||||
// _id: data.id
|
||||
// },
|
||||
// dataJson: {
|
||||
// status: 2
|
||||
// }
|
||||
// })
|
||||
//
|
||||
// res.data = uploaddocs.result
|
||||
// } else {
|
||||
// return {
|
||||
// code: -1,
|
||||
// msg: uploaddocs.msg
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
const dbName = require('../../../../../dao/config.js')
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/enquiry/sheet/kh/delete 前端调用的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: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
let { _id } = data;
|
||||
if(vk.pubfn.isNull(_id)){
|
||||
return { code : -1, msg : 'id不能为空' };
|
||||
}
|
||||
await vk.baseDao.deleteById({
|
||||
dbName: dbName.enquirySheet,
|
||||
id:_id
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* 获取用户发布的询价单
|
||||
* @url client/enquiry/sheet/pub/getList 前端调用的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, keyword, categoryIds, provinceCodes, formData, status, isSeller} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
let dbName = "jjx-enquiry-sheet";
|
||||
|
||||
|
||||
let whereJson = {isShow: 1};
|
||||
|
||||
if (vk.pubfn.isNotNull(keyword)) whereJson.title = new RegExp(keyword)
|
||||
|
||||
if (vk.pubfn.isNotNull(isSeller) && isSeller) whereJson.otherUid = uid
|
||||
else whereJson.userId = uid
|
||||
|
||||
if (vk.pubfn.isNotNull(status) && status !== 'all') {
|
||||
if (status === 'noQuote') {
|
||||
whereJson.quoteNum = 0
|
||||
whereJson.status = 0
|
||||
}
|
||||
else if (status === 'notPick') {
|
||||
whereJson.quoteNum = _.gt(0)
|
||||
whereJson.status = 0
|
||||
}
|
||||
else if (status === 'picked') whereJson.status = _.in([1, 2])
|
||||
}
|
||||
|
||||
if (formData && formData.hasOwnProperty('companyList') && vk.pubfn.isNotNull(formData.companyList)) {
|
||||
whereJson.userId = _.in(formData.companyList)
|
||||
}
|
||||
|
||||
if (formData && formData.hasOwnProperty('categoryIds') && vk.pubfn.isNotNull(formData.categoryIds)) {
|
||||
whereJson.categoryIds = _.in(formData.categoryIds)
|
||||
}
|
||||
|
||||
// if (vk.pubfn.isNotNull(provinceCodes)) {
|
||||
// whereJson['address.province.code'] = _.in(provinceCodes)
|
||||
// }
|
||||
|
||||
// console.log('whereJson', whereJson)
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
getCount: true,
|
||||
whereJson,
|
||||
sortArr: [{name: "_add_time", type: "desc"}],
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "uni-id-users",
|
||||
localKey: "userId",
|
||||
foreignKey: "_id",
|
||||
as: "user",
|
||||
limit: 1, // limit=1则以对象形式返回
|
||||
fieldJson: {
|
||||
_id: true,
|
||||
company: {
|
||||
companyName: true
|
||||
},
|
||||
person: {
|
||||
personName: true
|
||||
},
|
||||
businessCard: true,
|
||||
accountType: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
dbName: "uni-id-users",
|
||||
localKey: "otherUid",
|
||||
foreignKey: "_id",
|
||||
as: "otherUser",
|
||||
limit: 1, // limit=1则以对象形式返回
|
||||
fieldJson: {
|
||||
_id: true,
|
||||
company: {
|
||||
companyName: true,
|
||||
mobile: true
|
||||
},
|
||||
person: {
|
||||
personName: true,
|
||||
mobile: true
|
||||
},
|
||||
businessCard: true,
|
||||
accountType: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
dbName: "jjx-enquiry-quote",
|
||||
localKey: "_id",
|
||||
foreignKey: "sheetId",
|
||||
as: "quoteList",
|
||||
limit: 500, // limit=1则以对象形式返回
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const rows = res.rows
|
||||
const rowIds = rows.map(item => item._id)
|
||||
const orderMap = {}
|
||||
if (rowIds.length > 0) {
|
||||
const orderRes = await vk.baseDao.select({
|
||||
dbName: 'jjx-order',
|
||||
whereJson: {
|
||||
sheetId: _.in(rowIds)
|
||||
},
|
||||
sortArr: [{name: "_add_time", type: "desc"}]
|
||||
})
|
||||
if (orderRes && orderRes.rows) {
|
||||
orderRes.rows.forEach(order => {
|
||||
if (!orderMap[order.sheetId]) orderMap[order.sheetId] = order
|
||||
})
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const row = rows[i];
|
||||
row.order = orderMap[row._id] || null
|
||||
for (let j = 0; j < row.productList.length; j++) {
|
||||
const product = rows[i].productList[j]
|
||||
if (product && product.goodsId) {
|
||||
rows[i].productList[j].template = await vk.baseDao.findById({
|
||||
dbName,
|
||||
id: product.goodsId
|
||||
});
|
||||
}
|
||||
}
|
||||
row.contract = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-contract',
|
||||
whereJson: {
|
||||
sheetId: row._id,
|
||||
type: 'enquiry',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
res.notPickNum = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
isShow: 1,
|
||||
userId: uid,
|
||||
status: 0,
|
||||
quoteNum: _.gt(0)
|
||||
},
|
||||
});
|
||||
|
||||
res.pickedNum = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
isShow: 1,
|
||||
userId: uid,
|
||||
status: _.in([1, 2])
|
||||
},
|
||||
});
|
||||
|
||||
res.noQuoteNum = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
isShow: 1,
|
||||
userId: uid,
|
||||
quoteNum: 0,
|
||||
status: 0
|
||||
},
|
||||
});
|
||||
|
||||
res.all = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
isShow: 1,
|
||||
userId: uid,
|
||||
},
|
||||
});
|
||||
|
||||
res.rows = rows
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* 获取报价单详情
|
||||
* @url client/enquiry/sheet/pub/getDetail 前端调用的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, _id } = data;
|
||||
let res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
let dbName = "jjx-enquiry-sheet";
|
||||
res.data = await vk.baseDao.findByWhereJson({
|
||||
dbName,
|
||||
whereJson: {
|
||||
_id: _id
|
||||
},
|
||||
// foreignDB: [
|
||||
// {
|
||||
// dbName:"uni-id-users",
|
||||
// localKey:"userId",
|
||||
// foreignKey:"_id",
|
||||
// as:"user",
|
||||
// limit:1, // limit=1则以对象形式返回
|
||||
// fieldJson:{
|
||||
// _id: true,
|
||||
// company: {
|
||||
// companyName: true,
|
||||
// mobile: true,
|
||||
// },
|
||||
// person: {
|
||||
// personName: true,
|
||||
// mobile: true,
|
||||
// },
|
||||
// businessCard: true,
|
||||
// accountType: true,
|
||||
// },
|
||||
// }
|
||||
// ]
|
||||
});
|
||||
|
||||
res.data.user = await vk.baseDao.findByWhereJson({
|
||||
dbName:"uni-id-users",
|
||||
whereJson: {
|
||||
_id: res.data.userId
|
||||
}
|
||||
})
|
||||
if (res.data.user && (res.data.user.isNotaryBusiness === undefined || res.data.user.isNotaryBusiness === null)) {
|
||||
res.data.user.isNotaryBusiness = res.data.user.notaryUnionPayProfile && res.data.user.notaryUnionPayProfile.status === 1 ? 1 : 0
|
||||
}
|
||||
|
||||
res.data.quoteList = []
|
||||
const quoteList = await vk.baseDao.select({
|
||||
dbName: "jjx-enquiry-quote",
|
||||
whereJson: {
|
||||
sheetId: _id
|
||||
}
|
||||
})
|
||||
|
||||
res.data.hasQuote = false
|
||||
res.data.isMine = res.data.userId === uid
|
||||
quoteList.rows.forEach(quote => {
|
||||
if (quote.userId === uid) res.data.hasQuote = true
|
||||
})
|
||||
|
||||
if (quoteList.rows.length > 0) res.data.quoteList = quoteList.rows
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
'use strict';
|
||||
const dayjs = require("dayjs");
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* 获取用户发布的询价单
|
||||
* @url client/enquiry/sheet/pub/getList 前端调用的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,
|
||||
keyword,
|
||||
categoryIds,
|
||||
provinceCodes,
|
||||
formData,
|
||||
status,
|
||||
companyList,
|
||||
cateList,
|
||||
material,
|
||||
area,
|
||||
latest,
|
||||
} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
let dbName = "jjx-enquiry-sheet";
|
||||
|
||||
|
||||
// const andArr = [];
|
||||
let whereJson = {isShow: 1}
|
||||
if (data.userId && vk.pubfn.isNotNull(data.userId)) {
|
||||
// andArr.push({userId: data.userId})
|
||||
whereJson.userId = data.userId
|
||||
} else {
|
||||
// andArr.push({status: 0})
|
||||
whereJson.status = 0
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(keyword)) {
|
||||
whereJson.title = new RegExp(keyword)
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(area)) {
|
||||
console.log(area.length)
|
||||
if (area.length === 3) whereJson['addressRegion.area.code'] = area[2]
|
||||
if (area.length === 2) whereJson['addressRegion.city.code'] = area[1]
|
||||
if (area.length === 1) whereJson['addressRegion.province.code'] = area[0]
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(latest)) {
|
||||
whereJson['answerStartTime'] = _.gte(dayjs().format('YYYY-MM-DD HH:mm:ss'))
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(status) && status !== 'all') {
|
||||
// if (status === 'noQuote') andArr.push({quoteNum: 0})
|
||||
// else if (status === 'notPick') andArr.push({status: 0})
|
||||
// else if (status === 'picked') andArr.push({status: 1})
|
||||
if (status === 'noQuote') whereJson.quoteNum = 0
|
||||
else if (status === 'notPick') whereJson.status = 0
|
||||
else if (status === 'picked') whereJson.status = 1
|
||||
}
|
||||
|
||||
if (formData && formData.hasOwnProperty('companyList') && vk.pubfn.isNotNull(formData.companyList)) {
|
||||
// andArr.push({userId: _.in(formData.companyList)})
|
||||
whereJson.stealFactory = _.in(formData.companyList)
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(companyList)) {
|
||||
// andArr.push({userId: _.in(companyList)})
|
||||
whereJson.stealFactory = _.in(companyList)
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(cateList)) {
|
||||
// andArr.push({userId: _.in(companyList)})
|
||||
if (cateList.length === 1 && cateList[0] === 0) {
|
||||
whereJson.otherCate = _.exists(true)
|
||||
whereJson.otherCate = _.neq(null)
|
||||
}
|
||||
else whereJson.nameList = _.in(cateList)
|
||||
}
|
||||
|
||||
console.log(whereJson)
|
||||
|
||||
if (vk.pubfn.isNotNull(material)) {
|
||||
// andArr.push({userId: _.in(companyList)})
|
||||
whereJson.material = _.in(material)
|
||||
}
|
||||
|
||||
// if (vk.pubfn.isNotNull(categoryIds)) {
|
||||
// whereJson.userId = _.in(categoryIds)
|
||||
// }
|
||||
|
||||
// if (formData && formData.hasOwnProperty('categoryIds') && vk.pubfn.isNotNull(formData.categoryIds)) {
|
||||
// whereJson.categoryIds = _.in(formData.categoryIds)
|
||||
// }
|
||||
|
||||
// if (vk.pubfn.isNotNull(provinceCodes)) {
|
||||
// whereJson['address.province.code'] = _.in(provinceCodes)
|
||||
// }
|
||||
// const cateFilterList = []
|
||||
// if (vk.pubfn.isNotNull(cateList)) {
|
||||
// cateList.forEach(item => {
|
||||
// cateFilterList.push({
|
||||
// nameList: item,
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
getCount: true,
|
||||
whereJson,
|
||||
sortArr: [{name: "_add_time", type: "desc"}],
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "uni-id-users",
|
||||
localKey: "userId",
|
||||
foreignKey: "_id",
|
||||
as: "user",
|
||||
limit: 1, // limit=1则以对象形式返回
|
||||
fieldJson: {
|
||||
_id: true,
|
||||
company: {
|
||||
companyName: true
|
||||
},
|
||||
person: {
|
||||
personName: true
|
||||
},
|
||||
businessCard: true,
|
||||
accountType: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
dbName: "jjx-enquiry-quote",
|
||||
localKey: "_id",
|
||||
foreignKey: "sheetId",
|
||||
as: "quoteList",
|
||||
limit: 500, // limit=1则以对象形式返回
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const rows = res.rows
|
||||
rows.forEach((row, rowIndex) => {
|
||||
row.productList.forEach(async (product, productIndex) => {
|
||||
rows[rowIndex].productList[productIndex].template = await vk.baseDao.findById({
|
||||
dbName,
|
||||
id: product.goodsId
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
res.notPickNum = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
userId: uid,
|
||||
status: 0
|
||||
},
|
||||
});
|
||||
|
||||
res.pickedNum = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
userId: uid,
|
||||
status: 1
|
||||
},
|
||||
});
|
||||
|
||||
res.noQuoteNum = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
userId: uid,
|
||||
quoteNum: 0
|
||||
},
|
||||
});
|
||||
|
||||
res.all = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
userId: uid,
|
||||
},
|
||||
});
|
||||
|
||||
res.rows = rows
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
const dbName = 'jjx-enquiry-template'
|
||||
module.exports = {
|
||||
/**
|
||||
* 查询现货列表
|
||||
* @url client/spot/goods/kh/getList 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const {pageIndex, pageSize} = data
|
||||
|
||||
let whereJson = {
|
||||
enable: true
|
||||
};
|
||||
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName,
|
||||
getCount: false,
|
||||
pageIndex,
|
||||
pageSize: 500,
|
||||
// 主表where条件
|
||||
whereJson: whereJson,
|
||||
// 主表字段显示规则
|
||||
fieldJson: {},
|
||||
// 主表排序规则
|
||||
sortArr: [{name: "sort", type: "asc"}, {"name": "_add_time", "type": "desc"}],
|
||||
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url admin/old/sys/getList 前端调用的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 { pageIndex, pageSize } = data;
|
||||
let res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName: "jjx-ensure-config",
|
||||
pageIndex,
|
||||
pageSize,
|
||||
sortArr: [{"name": "sort", "type":"asc" }, {"name": "_add_time", "type":"desc" }],
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/factory/kh/addUpdate 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const check = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-factory",
|
||||
whereJson: {
|
||||
uid
|
||||
}
|
||||
});
|
||||
|
||||
if (check && check.status === 0) {
|
||||
return {
|
||||
code: 1,
|
||||
msg: "审核中,请勿重复提交"
|
||||
}
|
||||
}
|
||||
|
||||
if (!check) {
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-factory",
|
||||
dataJson: {...data, uid, status: 0, refuseReason: null}
|
||||
});
|
||||
|
||||
} else {
|
||||
await vk.baseDao.update({
|
||||
dbName: "jjx-factory",
|
||||
whereJson: {uid},
|
||||
dataJson: {...data, status: 0}
|
||||
});
|
||||
}
|
||||
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "uni-id-users",
|
||||
id: uid,
|
||||
dataJson: {
|
||||
factoryStatus: 0
|
||||
}
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/factory/kh/addUpdate 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-factory",
|
||||
whereJson: {
|
||||
uid
|
||||
}
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/factory/kh/addUpdate 前端调用的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 {userId} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const resData = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-factory",
|
||||
whereJson: {
|
||||
uid: userId
|
||||
}
|
||||
});
|
||||
res.data = resData
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
'use strict';
|
||||
const dbName = require("../../../../dao/config");
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/factory/kh/addUpdate 前端调用的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 {pageSize, pageIndex, area} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
let companyList = []
|
||||
if (!vk.pubfn.isNull(data.keyword)) {
|
||||
companyList = await vk.baseDao.select({
|
||||
dbName: dbName.user,
|
||||
pageSize: 9999,
|
||||
pageIndex: 1,
|
||||
getMain: true,
|
||||
whereJson: {
|
||||
// accountType: 2,
|
||||
"company.companyName": new RegExp(data.keyword)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const whereJson = {
|
||||
status: 1,
|
||||
isShow: true
|
||||
}
|
||||
if (companyList && companyList.length > 0) {
|
||||
whereJson['uid'] = _.in(companyList.map(v => v.uid))
|
||||
}
|
||||
if (vk.pubfn.isNotNull(data.mainSpotCategory)) {
|
||||
whereJson['mainSpotCategory'] = _.in([data.mainSpotCategory])
|
||||
}
|
||||
if (vk.pubfn.isNotNull(area)) {
|
||||
if (area.length === 3) whereJson['addressRegion.area.code'] = area[2]
|
||||
if (area.length === 2) whereJson['addressRegion.city.code'] = area[1]
|
||||
if (area.length === 1) whereJson['addressRegion.province.code'] = area[0]
|
||||
} else if (vk.pubfn.isNotNull(data.province)) {
|
||||
whereJson['addressRegion.province.code'] = data.province
|
||||
}
|
||||
console.log('factory whereJson', whereJson)
|
||||
|
||||
const resData = await vk.baseDao.selects({
|
||||
dbName: "jjx-factory",
|
||||
whereJson,
|
||||
pageSize,
|
||||
pageIndex,
|
||||
getCount: true,
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "uni-id-users",
|
||||
localKey: "uid",
|
||||
foreignKey: "_id",
|
||||
as: "user",
|
||||
limit: 1, // limit=1则以对象形式返回
|
||||
fieldJson: {
|
||||
_id: true,
|
||||
company: {
|
||||
companyName: true,
|
||||
mobile: true,
|
||||
},
|
||||
person: {
|
||||
personName: true,
|
||||
mobile: true,
|
||||
},
|
||||
businessCard: true,
|
||||
accountType: true,
|
||||
},
|
||||
}
|
||||
]
|
||||
});
|
||||
res.data = resData
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,623 @@
|
||||
'use strict';
|
||||
const {
|
||||
verify
|
||||
} = require("crypto");
|
||||
var CryptoJS = require("crypto-js");
|
||||
var vk; // 全局vk实例
|
||||
// 涉及的表名
|
||||
const dbName = require("../../dao/config.js")
|
||||
|
||||
var db = uniCloud.database(); // 全局数据库引用
|
||||
var _ = db.command; // 数据库操作符
|
||||
var $ = _.aggregate; // 聚合查询操作符
|
||||
/**
|
||||
* 权限注意:访问以下链接查看
|
||||
* 文档地址:https://vkdoc.fsq.pub/client/uniCloud/cloudfunctions/cloudObject.html#内置权限
|
||||
*/
|
||||
var cloudObject = {
|
||||
isCloudObject: true, // 标记为云对象模式
|
||||
/**
|
||||
* 请求前处理,主要用于调用方法之前进行预处理,一般用于拦截器、统一的身份验证、参数校验、定义全局对象等。
|
||||
* 文档地址:https://vkdoc.fsq.pub/client/uniCloud/cloudfunctions/cloudObject.html#before-预处理
|
||||
*/
|
||||
_before: async function () {
|
||||
vk = this.vk; // 将vk定义为全局对象
|
||||
// let { customUtil, uniID, config, pubFun } = this.getUtil(); // 获取工具包
|
||||
},
|
||||
/**
|
||||
* 请求后处理,主要用于处理本次调用方法的返回结果或者抛出的错误
|
||||
* 文档地址:https://vkdoc.fsq.pub/client/uniCloud/cloudfunctions/cloudObject.html#after-后处理
|
||||
*/
|
||||
_after: async function (options) {
|
||||
let {
|
||||
err,
|
||||
res
|
||||
} = options;
|
||||
if (err) {
|
||||
return; // 如果方法抛出错误,直接return;不处理
|
||||
}
|
||||
return res;
|
||||
},
|
||||
/**
|
||||
* 获取列表
|
||||
* @url client/fadada.getList 前端调用的url参数地址
|
||||
*/
|
||||
getList: async function (data) {
|
||||
let res = {
|
||||
code: 0,
|
||||
msg: ''
|
||||
};
|
||||
let {
|
||||
uid
|
||||
} = this.getClientInfo(); // 获取客户端信息
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
},
|
||||
/**
|
||||
* 模板函数
|
||||
* @url client/fadada.test 前端调用的url参数地址
|
||||
*/
|
||||
test: async function (data) {
|
||||
|
||||
},
|
||||
/**
|
||||
* 实名认证异步通知回调
|
||||
* @param {Object} data
|
||||
*/
|
||||
async pub_verifyNotify(data) {
|
||||
let {
|
||||
customUtil,
|
||||
uniID,
|
||||
config,
|
||||
pubFun
|
||||
} = this.getUtil(); // 获取工具包
|
||||
console.log('fadada res:', data)
|
||||
const {
|
||||
customerId
|
||||
} = data;
|
||||
// 查询认证结果
|
||||
let user = await vk.baseDao.findByWhereJson({
|
||||
dbName: "uni-id-users",
|
||||
whereJson: {
|
||||
fadadaCustomerId: customerId,
|
||||
}
|
||||
});
|
||||
let res, fadadaConfirm = false
|
||||
let authStatus = 1
|
||||
if (user.accountType === 1) {
|
||||
res = await pubFun.fadada('find_personCertInfo.api', {
|
||||
verified_serialno: user.fadadaVerify.transactionNo
|
||||
})
|
||||
console.log('fadada check res:', res)
|
||||
// 认证结果
|
||||
const {person} = res.data
|
||||
if (res.code !== 1 || ![2, 3].includes(parseInt(person.status))) {
|
||||
return
|
||||
}
|
||||
fadadaConfirm = parseInt(person.status) === 2
|
||||
} else {
|
||||
res = await pubFun.fadada('find_companyCertInfo.api', {
|
||||
verified_serialno: user.fadadaVerify.transactionNo
|
||||
})
|
||||
console.log('fadada check res:', res)
|
||||
// 认证结果
|
||||
const {company, manager} = res.data
|
||||
if (res.code !== 1 || ![3, 4].includes(parseInt(company.status)) || ![2, 3].includes(parseInt(manager.status))) {
|
||||
return
|
||||
}
|
||||
fadadaConfirm = parseInt(company.status) === 4 && parseInt(manager.status) === 2
|
||||
if (parseInt(company.status) === 3) authStatus = 0
|
||||
}
|
||||
|
||||
|
||||
// 认证成功
|
||||
await vk.baseDao.setById({
|
||||
dbName: "fadada-verify-record",
|
||||
dataJson: {
|
||||
_id: user._id,
|
||||
...res.data
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "uni-id-users",
|
||||
id: user._id,
|
||||
dataJson: {
|
||||
person: {
|
||||
...res.data.person,
|
||||
addressRegion: {
|
||||
province: {},
|
||||
city: {},
|
||||
area: {},
|
||||
}
|
||||
},
|
||||
company: {
|
||||
...res.data.company, ...{
|
||||
mainSpotCategoryIds: [],
|
||||
addressRegion: {
|
||||
province: {},
|
||||
city: {},
|
||||
area: {},
|
||||
}
|
||||
}
|
||||
},
|
||||
manager: res.data.manager,
|
||||
bankCard: res.data.bankCard,
|
||||
fadadaConfirm,
|
||||
// status: 1,
|
||||
authType: 1,
|
||||
// authStatus: 0,
|
||||
userLevel: 0,
|
||||
userGrade: 0,
|
||||
authSubmitTime: vk.pubfn.timeFormat(new Date(), "yyyy-MM-dd hh:mm:ss")
|
||||
}
|
||||
});
|
||||
|
||||
if (user.inviter_uid && user.inviter_uid.length > 0) {
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "uni-id-users",
|
||||
id: user.inviter_uid[0],
|
||||
dataJson: {
|
||||
inviteNum: _.inc(1)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return res
|
||||
},
|
||||
/**
|
||||
* 合同签署回调处理
|
||||
* @param {Object} data
|
||||
*/
|
||||
async pub_contractNotify(data) {
|
||||
let {
|
||||
customUtil,
|
||||
uniID,
|
||||
config,
|
||||
pubFun
|
||||
} = this.getUtil(); // 获取工具包
|
||||
// 开启事务
|
||||
const transaction = await vk.baseDao.startTransaction();
|
||||
|
||||
const {
|
||||
transaction_id,
|
||||
contract_id,
|
||||
timestamp,
|
||||
result_code,
|
||||
download_url,
|
||||
viewpdf_url
|
||||
} = data
|
||||
try {
|
||||
if (parseInt(result_code) == 3000) {
|
||||
// 获取用户信息
|
||||
const userContract = await vk.daoCenter.userContractDao.updateAndReturn({
|
||||
db: transaction,
|
||||
whereJson: {
|
||||
transactionId: transaction_id,
|
||||
sign: false
|
||||
},
|
||||
dataJson: {
|
||||
sign: true,
|
||||
signedAt: timestamp,
|
||||
}
|
||||
})
|
||||
|
||||
let contract = await vk.daoCenter.contractDao.updateAndReturn({
|
||||
db: transaction,
|
||||
whereJson: {
|
||||
_id: userContract.contractId,
|
||||
status: 1,
|
||||
},
|
||||
dataJson: {
|
||||
signCount: _.inc(1),
|
||||
contractHistory: _.push(download_url)
|
||||
}
|
||||
})
|
||||
|
||||
if (userContract.userId === contract.userId) {
|
||||
const userInfo = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'uni-id-users',
|
||||
whereJson: {
|
||||
_id: userContract.userId
|
||||
}
|
||||
})
|
||||
let otherList = await vk.daoCenter.userContractDao.selects({
|
||||
whereJson: {
|
||||
contractId: userContract.contractId,
|
||||
}
|
||||
}
|
||||
)
|
||||
otherList.rows = otherList.rows.filter(item => item.userId !== userContract.userId)
|
||||
for (let i = 0; i < otherList.rows.length; i++) {
|
||||
const thirdUserItem = otherList.rows[i]
|
||||
const thirdUser = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'uni-id-users',
|
||||
whereJson: {
|
||||
_id: thirdUserItem.userId
|
||||
}
|
||||
})
|
||||
if (thirdUser !== null) {
|
||||
await pubFun.sendNotifySms(thirdUser._id, 'SMS_474570002', {
|
||||
name: thirdUser.accountType === 2 ? thirdUser.company.companyName : thirdUser.person.personName,
|
||||
name2: userInfo.accountType === 2 ? userInfo.company.companyName : userInfo.person.personName,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (contract.type !== 'sign') {
|
||||
// 用户交易额
|
||||
const user = await vk.baseDao.updateAndReturn({
|
||||
dbName: "uni-id-users",
|
||||
whereJson: {
|
||||
_id: userContract.userId
|
||||
},
|
||||
dataJson: {
|
||||
transactionAmount: _.inc(parseFloat(contract.amount))
|
||||
}
|
||||
})
|
||||
|
||||
if (user.userLevel > -1) {
|
||||
const userLevel = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-user-level',
|
||||
whereJson: {
|
||||
level: user.userLevel
|
||||
},
|
||||
})
|
||||
await vk.baseDao.update({
|
||||
dbName: "uni-id-users",
|
||||
whereJson: {
|
||||
_id: userContract.userId
|
||||
},
|
||||
dataJson: {
|
||||
userGrade: Math.floor(user.transactionAmount / parseFloat(userLevel.upgradeAmount))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (contract.signCount == contract.partyCount) {
|
||||
let sheetId = null
|
||||
contract = await vk.daoCenter.contractDao.updateAndReturn({
|
||||
db: transaction,
|
||||
whereJson: {
|
||||
_id: userContract.contractId,
|
||||
status: 1
|
||||
},
|
||||
dataJson: {
|
||||
status: 2
|
||||
}
|
||||
})
|
||||
|
||||
console.log('contract.type', contract.type)
|
||||
|
||||
// 合同归档
|
||||
const contractFilingRes = await pubFun.fadada('contractFiling.api', {
|
||||
contract_id: contract.transactionId
|
||||
})
|
||||
// console.log('contractFilingRes', contractFilingRes)
|
||||
|
||||
// 添加订单
|
||||
// type 4: 询价 -- enquiry
|
||||
// type 5: 加工 -- process
|
||||
// type 6: 旧货 -- old
|
||||
const otherContract = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-user-contract',
|
||||
whereJson: {
|
||||
contractId: userContract.contractId,
|
||||
role: userContract.role === 'seller' ? 'buyer' : 'seller'
|
||||
}
|
||||
})
|
||||
let sellerUid = null, buyerUid = null
|
||||
if (userContract.role === 'seller') {
|
||||
sellerUid = userContract.userId
|
||||
buyerUid = otherContract.userId
|
||||
} else {
|
||||
sellerUid = otherContract.userId
|
||||
buyerUid = userContract.userId
|
||||
}
|
||||
let type = null, goodsName = null, makeOrder = false, sheet = null
|
||||
if (contract.type === 'enquiry') {
|
||||
type = 4
|
||||
goodsName = '询价单'
|
||||
sheet = await vk.baseDao.updateAndReturn({
|
||||
dbName: "jjx-enquiry-sheet",
|
||||
whereJson: {
|
||||
_id: contract.sheetId
|
||||
},
|
||||
dataJson: {
|
||||
status: 2
|
||||
}
|
||||
})
|
||||
sheetId = contract.sheetId
|
||||
if (sheet.tradeMethod === 1) makeOrder = true
|
||||
} else if (contract.type === 'process') {
|
||||
type = 5
|
||||
goodsName = '加工单'
|
||||
sheet = await vk.baseDao.updateAndReturn({
|
||||
dbName: "jjx-process-sheet",
|
||||
whereJson: {
|
||||
_id: contract.sheetId
|
||||
},
|
||||
dataJson: {
|
||||
status: 2
|
||||
}
|
||||
})
|
||||
sheetId = contract.sheetId
|
||||
if (sheet.tradeMethod === 1) makeOrder = true
|
||||
} else if (contract.type === 'old') {
|
||||
await vk.baseDao.updateAndReturn({
|
||||
dbName: "jjx-old",
|
||||
whereJson: {
|
||||
_id: contract.sheetId
|
||||
},
|
||||
dataJson: {
|
||||
status: 2
|
||||
}
|
||||
})
|
||||
} else if (contract.type === 'sign') {
|
||||
if (contract.tradeMethod === 1) {
|
||||
makeOrder = true
|
||||
type = 14
|
||||
goodsName = '金久信签约宝'
|
||||
}
|
||||
} else if (contract.type === 'self-support') {
|
||||
makeOrder = true
|
||||
type = 15
|
||||
goodsName = '金久信自营询价'
|
||||
sheetId = contract.sheetId
|
||||
}
|
||||
if (makeOrder) {
|
||||
const orderId = await vk.baseDao.add({
|
||||
dbName: "jjx-order",
|
||||
dataJson: {
|
||||
orderNo: vk.pubfn.createOrderNo("39XU", 20),
|
||||
uid: buyerUid,
|
||||
sellerUid,
|
||||
orderStatus: 0,
|
||||
payStatus: 0,
|
||||
type,
|
||||
amount: contract.amount,
|
||||
offAmount: contract.amount,
|
||||
signMethod: 0,
|
||||
contractId: contract._id,
|
||||
sheetId
|
||||
}
|
||||
})
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-order-goods",
|
||||
dataJson: {
|
||||
orderId,
|
||||
goodsId: null,
|
||||
num: 1,
|
||||
goodsName,
|
||||
goodsPrice: contract.amount,
|
||||
goodsCover: null,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
await transaction.commit();
|
||||
} catch (e) {
|
||||
await transaction.rollback();
|
||||
console.log('fadada err:', e)
|
||||
return false
|
||||
}
|
||||
return data;
|
||||
},
|
||||
/**
|
||||
* 获取用户认证结果
|
||||
*/
|
||||
async getVerifyResult() {
|
||||
let {
|
||||
customUtil,
|
||||
uniID,
|
||||
config,
|
||||
pubFun
|
||||
} = this.getUtil(); // 获取工具包
|
||||
let res = {
|
||||
code: 0,
|
||||
msg: ''
|
||||
};
|
||||
let {
|
||||
uid
|
||||
} = this.getClientInfo(); // 获取客户端信息
|
||||
let {
|
||||
accountType,
|
||||
fadadaCustomerId
|
||||
} = await this.getUserInfo();
|
||||
|
||||
res.data = await vk.baseDao.findById({
|
||||
dbName: "fadada-verify-record",
|
||||
id: uid
|
||||
});
|
||||
|
||||
return res
|
||||
},
|
||||
/**
|
||||
* 获取实名认证地址
|
||||
*/
|
||||
async getVerifyUrl(event) {
|
||||
let {
|
||||
customUtil,
|
||||
uniID,
|
||||
config,
|
||||
pubFun
|
||||
} = this.getUtil(); // 获取工具包
|
||||
let res = {
|
||||
code: 0,
|
||||
msg: ''
|
||||
};
|
||||
let {
|
||||
uid
|
||||
} = this.getClientInfo(); // 获取客户端信息
|
||||
let {
|
||||
accountType,
|
||||
fadadaCustomerId,
|
||||
fadadaVerify
|
||||
} = await this.getUserInfo();
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
if (fadadaVerify && !event.reset) {
|
||||
res.data = fadadaVerify
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
let verify_url_res;
|
||||
|
||||
let return_url = event.isMobile ? 'https://m.jinjiuxinzg.cn/pages/user/user' : 'https://www.jinjiuxinzg.cn/#/pages/user/user?menu=fadada'
|
||||
if (event.isSignOnly) {
|
||||
return_url = event.isMobile ? 'https://m.jinjiuxinzg.cn/signOnly/#/' : 'https://www.jinjiuxinzg.cn/signOnly/#/pages/user/user?menu=fadada'
|
||||
}
|
||||
let notify_url = 'https://tcb-n44byxi8bmrfrki-d4bn1c4a206d.service.tcloudbase.com/fadada_verify_notify'
|
||||
if (accountType === 1) {
|
||||
verify_url_res = await pubFun.fadada('get_person_verify_url.api', {
|
||||
customer_id: fadadaCustomerId,
|
||||
verified_way: 2,
|
||||
page_modify: 1,
|
||||
cert_flag: 1,
|
||||
// notify_url: 'https://fc-mp-0737e52b-fffa-4223-bcdf-d4ad3d9968a5.next.bspapp.com/fadada_verify_notify',
|
||||
// return_url: 'https://static-mp-0737e52b-fffa-4223-bcdf-d4ad3d9968a5.next.bspapp.com/#/pages/user/user?menu=fadada'
|
||||
notify_url,
|
||||
return_url
|
||||
|
||||
})
|
||||
} else {
|
||||
verify_url_res = await pubFun.fadada('get_company_verify_url.api', {
|
||||
customer_id: fadadaCustomerId,
|
||||
page_modify: 1,
|
||||
cert_flag: 1,
|
||||
// notify_url: 'https://fc-mp-0737e52b-fffa-4223-bcdf-d4ad3d9968a5.next.bspapp.com/fadada_verify_notify',
|
||||
// return_url: 'https://static-mp-0737e52b-fffa-4223-bcdf-d4ad3d9968a5.next.bspapp.com/#/pages/user/user?menu=fadada'
|
||||
notify_url,
|
||||
return_url
|
||||
})
|
||||
}
|
||||
|
||||
console.log('verify_url_data: ', {
|
||||
customer_id: fadadaCustomerId,
|
||||
verified_way: 2,
|
||||
page_modify: 1,
|
||||
cert_flag: 1,
|
||||
// notify_url: 'https://fc-mp-0737e52b-fffa-4223-bcdf-d4ad3d9968a5.next.bspapp.com/fadada_verify_notify',
|
||||
// return_url: 'https://static-mp-0737e52b-fffa-4223-bcdf-d4ad3d9968a5.next.bspapp.com/#/pages/user/user?menu=fadada'
|
||||
notify_url,
|
||||
return_url
|
||||
|
||||
});
|
||||
console.log('verify_url_res: ', verify_url_res);
|
||||
let {
|
||||
transactionNo,
|
||||
url
|
||||
} = verify_url_res.data
|
||||
var parsedWordArray = CryptoJS.enc.Base64.parse(url);
|
||||
url = parsedWordArray.toString(CryptoJS.enc.Utf8);
|
||||
|
||||
await vk.baseDao.update({
|
||||
dbName: "uni-id-users",
|
||||
whereJson: {
|
||||
_id: uid
|
||||
},
|
||||
dataJson: {
|
||||
fadadaVerify: {
|
||||
transactionNo,
|
||||
url
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
res.data = {
|
||||
transactionNo,
|
||||
url
|
||||
}
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
|
||||
},
|
||||
/**
|
||||
* 调用此接口将customer_id与实名交易号进行绑定,
|
||||
* 绑定成功后该customer_id无法再次绑定其它不同主体认证交易号。
|
||||
* 必须绑定成功后续才可发起签署
|
||||
*/
|
||||
async applyCert({
|
||||
customerId,
|
||||
transactionNo
|
||||
}) {
|
||||
let {
|
||||
customUtil,
|
||||
uniID,
|
||||
config,
|
||||
pubFun
|
||||
} = this.getUtil(); // 获取工具包
|
||||
},
|
||||
async generateContract() {
|
||||
let {
|
||||
customUtil,
|
||||
uniID,
|
||||
config,
|
||||
pubFun
|
||||
} = this.getUtil(); // 获取工具包
|
||||
let res = {
|
||||
code: 0,
|
||||
msg: ''
|
||||
};
|
||||
let {
|
||||
uid
|
||||
} = this.getClientInfo(); // 获取客户端信息
|
||||
const contract_id = vk.pubfn.createOrderNo("Contract", 25);
|
||||
const parameter_map = {
|
||||
saler: '网宿科技'
|
||||
};
|
||||
const dynamic_tables = [{
|
||||
headers: ["采购商品", "采购数量", "商品单位"], //表头,
|
||||
datas: [
|
||||
["螺纹钢", "200", "米"]
|
||||
],
|
||||
pageBegin: -1
|
||||
}]
|
||||
const params = {
|
||||
template_id: 'sale',
|
||||
doc_title: '测试买卖合同',
|
||||
contract_id: contract_id,
|
||||
fill_type: 0, // 填充类型 0 pdf 模板、1 在线填充模板
|
||||
parameter_map: JSON.stringify(parameter_map), //填充内容
|
||||
dynamic_tables: JSON.stringify(dynamic_tables), //填充表格
|
||||
}
|
||||
console.log(params);
|
||||
res.data = await pubFun.fadada('generate_contract.api', params)
|
||||
return res;
|
||||
},
|
||||
async getFile({uuid}) {
|
||||
let {
|
||||
customUtil,
|
||||
uniID,
|
||||
config,
|
||||
pubFun
|
||||
} = this.getUtil();
|
||||
const res = {
|
||||
code: 0,
|
||||
msg: ''
|
||||
}
|
||||
const file = await pubFun.fadada('get_file.api', {
|
||||
uuid
|
||||
})
|
||||
res.msg = await vk.uploadFile({
|
||||
title: "上传中...",
|
||||
file,
|
||||
needSave: true,
|
||||
});
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = cloudObject;
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/goods/category/pub/getList 前端调用的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: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.getTableData({
|
||||
dbName: 'jjx-goods-category',
|
||||
sortArr: [
|
||||
{ name: "sort", type: "asc" },
|
||||
{ name: "_id", type: "desc" },
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/article/list/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 res = { code: 0, msg: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: 'jjx-article',
|
||||
dataJson: {
|
||||
...data, ...{
|
||||
viewNum: 0,
|
||||
downloadNum: 0,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/goods/list/pub/getDetail 前端调用的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: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.findById({
|
||||
dbName: "jjx-goods",
|
||||
id: data.id
|
||||
});
|
||||
|
||||
if (!res.sales) {
|
||||
res.sales = 0;
|
||||
}
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/goods/list/pub/getList 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const {pageIndex, pageSize, parentId, keyword, city, } = data
|
||||
const whereJson = {}
|
||||
if (vk.pubfn.isNotNull(keyword)) {
|
||||
whereJson.name = new RegExp(keyword)
|
||||
}
|
||||
if (vk.pubfn.isNotNull(city)) {
|
||||
whereJson['address.city.code'] = city
|
||||
}
|
||||
if (vk.pubfn.isNotNull(parentId)) {
|
||||
whereJson.parentId = parentId
|
||||
}
|
||||
|
||||
res = await vk.baseDao.select({
|
||||
dbName: 'jjx-goods',
|
||||
getCount: true,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
whereJson,
|
||||
sortArr: [
|
||||
{name: "recommend", type: "desc"},
|
||||
{name: "sort", type: "asc"},
|
||||
{name: "_add_time", type: "desc"},
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url admin/old/sys/getList 前端调用的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 res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName: "jjx-industry",
|
||||
pageIndex: 1,
|
||||
pageSize: 500,
|
||||
getCount: true,
|
||||
sortArr: [
|
||||
{"name": "sort", "type": "asc"},
|
||||
{"name": "_add_time", "type": "desc"},
|
||||
],
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/message/config/kh/getConfig 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const messageConfig = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-message-config",
|
||||
whereJson: {
|
||||
uid
|
||||
}
|
||||
});
|
||||
|
||||
if (!messageConfig) {
|
||||
const id = await vk.baseDao.add({
|
||||
dbName: "jjx-message-config",
|
||||
dataJson: {
|
||||
uid,
|
||||
article: true,
|
||||
process: true,
|
||||
old: true,
|
||||
enquiry: true,
|
||||
productList: [],
|
||||
addressRegion: {}
|
||||
}
|
||||
})
|
||||
|
||||
res = await vk.baseDao.findById({
|
||||
dbName: "jjx-message-config",
|
||||
id: id
|
||||
});
|
||||
} else res = messageConfig
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/message/config/kh/setConfig 前端调用的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: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/message/config/kh/update 前端调用的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.update({
|
||||
dbName: "jjx-message-config",
|
||||
whereJson: {uid},
|
||||
dataJson: {
|
||||
...data
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/message/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: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
console.log('here is message', data)
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid,
|
||||
title: data.title,
|
||||
content: data.content,
|
||||
type: data.type,
|
||||
hasRead: false
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/message/kh/delete 前端调用的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.deleteById({
|
||||
dbName: "jjx-message",
|
||||
id: data.id
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/message/kh/getList 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.select({
|
||||
dbName: "jjx-message",
|
||||
getCount: true,
|
||||
whereJson: {
|
||||
uid,
|
||||
},
|
||||
sortArr: [{"name": "_add_time", "type": "desc"}],
|
||||
pageIndex,
|
||||
pageSize
|
||||
})
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/message/kh/getUnreadCount 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res.data = await vk.baseDao.count({
|
||||
dbName: "jjx-message",
|
||||
whereJson: {
|
||||
uid,
|
||||
hasRead: false
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/message/kh/setAllRead 前端调用的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.update({
|
||||
dbName: "jjx-message",
|
||||
whereJson: {
|
||||
uid: uid,
|
||||
hasRead: false
|
||||
},
|
||||
dataJson: {
|
||||
hasRead: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/message/kh/setRead 前端调用的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.updateById({
|
||||
dbName: "jjx-message",
|
||||
id: data.id,
|
||||
dataJson: {
|
||||
hasRead: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/notice/list/pub/getDetail 前端调用的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: "" };
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.findById({
|
||||
dbName: "jjx-notice",
|
||||
id: data.id,
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/notice/list/pub/getList 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const {pageIndex, pageSize, parentId, keyword} = data
|
||||
const whereJson = {parentId}
|
||||
if (vk.pubfn.isNotNull(keyword)) {
|
||||
whereJson.name = new RegExp(keyword)
|
||||
}
|
||||
res = await vk.baseDao.select({
|
||||
dbName: 'jjx-notice',
|
||||
getCount: true,
|
||||
pageIndex,
|
||||
pageSize: 12,
|
||||
whereJson,
|
||||
sortArr: [
|
||||
{name: "_id", type: "desc"}
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/old/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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
if (!userInfo.fadadaConfirm && userInfo.authStatus === 1) {
|
||||
return {
|
||||
code: 1,
|
||||
msg: '请先完成认证'
|
||||
}
|
||||
} else if (!userInfo.businessCard) {
|
||||
return {
|
||||
code: 1,
|
||||
msg: '请完善名片信息'
|
||||
}
|
||||
} else {
|
||||
if (userInfo.businessCard.status !== 1) {
|
||||
return {
|
||||
code: 1,
|
||||
msg: '您的名片信息未审核,请耐心等待'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!userInfo.remainOldNum || parseInt(userInfo.remainOldNum) === 0) return {
|
||||
code: 1,
|
||||
msg: '本月旧货发布次数已用完'
|
||||
}
|
||||
|
||||
const isUrgent = data.isUrgent
|
||||
delete data.isUrgent
|
||||
const pk = await vk.baseDao.add({
|
||||
dbName: "jjx-old",
|
||||
dataJson: {
|
||||
...data, ...{
|
||||
quoteNum: 0,
|
||||
status: 0,
|
||||
isUrgent: false,
|
||||
isShow: 0,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const messageUserList = await vk.baseDao.select({
|
||||
dbName: "jjx-message-config",
|
||||
whereJson: {
|
||||
old: true
|
||||
}
|
||||
})
|
||||
const messageList = []
|
||||
for (let i = 0; i < messageUserList.rows.length; i++) {
|
||||
if (messageUserList.rows[i].uid !== uid) {
|
||||
messageList.push({
|
||||
uid: messageUserList.rows[i].uid,
|
||||
title: `旧货:${data.title}`,
|
||||
content: `新的旧货信息发布,赶紧去看看吧`,
|
||||
type: 'old',
|
||||
hasRead: false,
|
||||
pk
|
||||
})
|
||||
await pubFun.sendNotifySms(messageUserList.rows[i].uid, 'SMS_474130452')
|
||||
}
|
||||
}
|
||||
if (messageList.length > 0) {
|
||||
await vk.baseDao.adds({
|
||||
dbName: "jjx-message",
|
||||
dataJson: messageList
|
||||
});
|
||||
}
|
||||
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "uni-id-users",
|
||||
id: uid,
|
||||
dataJson: {
|
||||
remainOldNum: _.inc(-1)
|
||||
}
|
||||
});
|
||||
|
||||
if (isUrgent) {
|
||||
const amountItem = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '6587dd2fe0ec19027452c5b5'
|
||||
})
|
||||
|
||||
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: 9,
|
||||
amount,
|
||||
offAmount,
|
||||
saveAmount,
|
||||
offRate,
|
||||
}
|
||||
})
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-order-goods",
|
||||
dataJson: {
|
||||
orderId,
|
||||
goodsId: pk,
|
||||
num: 1,
|
||||
goodsName: '旧货信息加急',
|
||||
goodsPrice: amount,
|
||||
goodsCover: null,
|
||||
}
|
||||
})
|
||||
res.data = orderId
|
||||
}
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
'use strict';
|
||||
const dayjs = require("dayjs");
|
||||
var isBetween = require('dayjs/plugin/isBetween')
|
||||
dayjs.extend(isBetween)
|
||||
|
||||
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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
let noQuoteNo = false
|
||||
|
||||
if (parseInt(userInfo.userLevel) < 3) {
|
||||
if (parseInt(userInfo.remainQuoteNum) === 0 || !userInfo.remainQuoteNum) {
|
||||
|
||||
const checkSheetQuoteNum = await vk.baseDao.findById({
|
||||
dbName: "jjx-old",
|
||||
id: data.sheetId
|
||||
})
|
||||
if (checkSheetQuoteNum.quoteAmount) {
|
||||
const checkQuoteNum = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-user-quote-num",
|
||||
whereJson: {
|
||||
uid,
|
||||
type: 'old',
|
||||
sheetId: data.sheetId,
|
||||
}
|
||||
});
|
||||
if (!checkQuoteNum || checkQuoteNum.num === 0) noQuoteNo = true
|
||||
} else noQuoteNo = true
|
||||
}
|
||||
noQuoteNo = !!(userInfo.quoteExpiredAt && dayjs(userInfo.quoteExpiredAt).isBefore(dayjs()));
|
||||
}
|
||||
|
||||
if (noQuoteNo) {
|
||||
return {
|
||||
code: 1,
|
||||
msg: "您的报价次数已过期/用完"
|
||||
}
|
||||
}
|
||||
if (userInfo.remainQuoteNum && userInfo.remainQuoteNum > 0) {
|
||||
await vk.baseDao.update({
|
||||
dbName: "uni-id-users",
|
||||
whereJson: {
|
||||
uid
|
||||
},
|
||||
dataJson: {
|
||||
remainQuoteNum: _.inc(-1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
let subjectName = ''
|
||||
let subjectMobile = ''
|
||||
let managerName = ''
|
||||
let managerMobile = ''
|
||||
|
||||
const checkSheet = await vk.baseDao.findById({
|
||||
dbName: "jjx-old",
|
||||
id: data.sheetId
|
||||
})
|
||||
|
||||
if (checkSheet.status > 0) return {
|
||||
code: -1,
|
||||
msg: "该旧货交易已关闭"
|
||||
}
|
||||
|
||||
if (accountType === 1 && person.personName && person.mobile) {
|
||||
subjectName = person.personName
|
||||
subjectMobile = person.mobile
|
||||
} else {
|
||||
subjectName = company.companyName
|
||||
subjectMobile = company.companyMobile
|
||||
// if (manager && manager.mobile && manager.personName) {
|
||||
// managerName = manager.personName
|
||||
// managerMobile = manager.mobile
|
||||
// }
|
||||
}
|
||||
|
||||
// 添加报价单
|
||||
res.data = await vk.baseDao.add({
|
||||
dbName: "jjx-old-quote",// 表名
|
||||
dataJson: { // 需要新增的数据 json格式
|
||||
...data,
|
||||
...{
|
||||
userId: data.uid,
|
||||
status: 0,
|
||||
subjectName,
|
||||
subjectMobile,
|
||||
managerName,
|
||||
managerMobile,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const sheet = vk.baseDao.updateAndReturn({
|
||||
dbName: "jjx-old",// 表名
|
||||
whereJson: {
|
||||
_id: data.sheetId,
|
||||
},
|
||||
dataJson: {
|
||||
quoteNum: _.inc(1)
|
||||
}
|
||||
})
|
||||
|
||||
const checkMessage = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-message-config",
|
||||
whereJson: {
|
||||
old: true,
|
||||
uid: sheet.userId
|
||||
}
|
||||
})
|
||||
|
||||
if (checkMessage) {
|
||||
let send = true
|
||||
// if (checkMessage.doNotDisturbRange && checkMessage.doNotDisturbRange[0]) {
|
||||
// const date = dayjs().format("YYYY-MM-DD")
|
||||
// const doNotDisturbRangeStart = dayjs(checkMessage.doNotDisturbRange[0]).format("HH:mm")
|
||||
// const doNotDisturbRangeEnd = dayjs(checkMessage.doNotDisturbRange[1]).format("HH:mm")
|
||||
// if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
// send = false
|
||||
// }
|
||||
const date = dayjs().format("YYYY-MM-DD")
|
||||
if (checkMessage.doNotDisturbStart && checkMessage.doNotDisturbStart.length) {
|
||||
const doNotDisturbRangeStart = dayjs(`${date} ${checkMessage.doNotDisturbStart[0]}:${checkMessage.doNotDisturbStart[1]}`).format("HH:mm")
|
||||
const doNotDisturbRangeEnd = dayjs(`${date} ${checkMessage.doNotDisturbEnd[0]}:${checkMessage.doNotDisturbEnd[1]}`).format("HH:mm")
|
||||
if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
send = false
|
||||
}
|
||||
|
||||
if (checkMessage.tradeAmount && checkMessage.tradeAmount[0]) {
|
||||
if (sheet.totalPrice < checkMessage.tradeAmount[0] || sheet.totalPrice > checkMessage.tradeAmount[1])
|
||||
send = false
|
||||
}
|
||||
|
||||
if (send) {
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: sheet.userId,
|
||||
title: `旧货:${sheet.title}报价`,
|
||||
content: `您的旧货信息有新的报价,赶紧去看看吧`,
|
||||
type: 'old',
|
||||
hasRead: false,
|
||||
pk: data.sheetId
|
||||
}
|
||||
});
|
||||
await pubFun.sendNotifySms(sheet.userId, 'SMS_474185570')
|
||||
}
|
||||
}
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
'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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/enquiry/sheet/kh/changeToOnlineSign 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const sheet = await vk.baseDao.updateAndReturn({
|
||||
dbName: "jjx-old",
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
},
|
||||
dataJson: {
|
||||
signMethod: 0,
|
||||
status: 1
|
||||
}
|
||||
});
|
||||
|
||||
const quote = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-old-quote",
|
||||
whereJson: {
|
||||
sheetId: data.id,
|
||||
status: 1
|
||||
}
|
||||
});
|
||||
|
||||
if (quote) {
|
||||
|
||||
const fadadaContractId = vk.pubfn.createOrderNo("OL", 20)
|
||||
const contractTransactionId = vk.pubfn.createOrderNo("C", 20)
|
||||
|
||||
const contractId = await vk.baseDao.add({
|
||||
dbName: 'jjx-contract',
|
||||
dataJson: {
|
||||
fadadaContractId,
|
||||
contractBase: '', // 原始合同
|
||||
contractHistory: [], // 历史合同
|
||||
contractFinal: '', // 归档合同
|
||||
status: 0,
|
||||
userId: uid,
|
||||
type: 'old',
|
||||
quoteId: quote.id,
|
||||
sheetId: quote.sheetId,
|
||||
productList: quote.productList,
|
||||
productTitle: sheet.title,
|
||||
tradeMethod: 0,
|
||||
partyCount: 2,
|
||||
signCount: 0,
|
||||
contractType: sheet.contractType,
|
||||
signMethod: sheet.signMethod,
|
||||
sellerSupplement: sheet.sellerSupplement,
|
||||
transactionId: contractTransactionId,
|
||||
amount: quote.totalPrice,
|
||||
docTitle: sheet.title,
|
||||
}
|
||||
})
|
||||
|
||||
// 上传合同模板
|
||||
|
||||
//新增 用户与合同的关联记录
|
||||
await vk.daoCenter.userContractDao.adds([
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("E", 20),
|
||||
userId: quote.userId,
|
||||
role: 'seller',
|
||||
sign: false,
|
||||
contractId
|
||||
},
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("E", 20),
|
||||
userId: uid,
|
||||
role: 'buyer',
|
||||
sign: false,
|
||||
contractId
|
||||
}
|
||||
])
|
||||
}
|
||||
// const contractFile = await vk.baseDao.findById({
|
||||
// dbName: 'jjx-dict',
|
||||
// id: '657d36befe975f63af1f24e7'
|
||||
// })
|
||||
// const signMaxDate = await vk.baseDao.findById({
|
||||
// dbName: 'jjx-dict',
|
||||
// id: '657d78958b0da41d311bd94c'
|
||||
// })
|
||||
// const buyerSignKeyword = await vk.baseDao.findById({
|
||||
// dbName: 'jjx-dict',
|
||||
// id: '657d37972139294200fc9a01'
|
||||
// })
|
||||
// const sellerSignKeyword = await vk.baseDao.findById({
|
||||
// dbName: 'jjx-dict',
|
||||
// id: '657d37a609664c4f4a5c4afb'
|
||||
// })
|
||||
// const signEndDate = vk.pubfn.getOffsetTime(new Date(), {
|
||||
// day: parseInt(signMaxDate.content),
|
||||
// mode: "after",
|
||||
// });
|
||||
//
|
||||
// const uploaddocs = await pubFun.fadada('uploaddocs.api', {
|
||||
// contract_id: contractTransactionId,
|
||||
// doc_title: sheet.title,
|
||||
// doc_url: contractFile.content,
|
||||
// // file: doc_url,
|
||||
// doc_type: '.pdf'
|
||||
// })
|
||||
// if (parseInt(uploaddocs.code) === 1000) {
|
||||
// await vk.baseDao.updateAndReturn({
|
||||
// dbName: dbName.contract,
|
||||
// whereJson: {
|
||||
// _id: contractId,
|
||||
// userId: uid
|
||||
// },
|
||||
// dataJson: {
|
||||
// status: 1,
|
||||
// docTitle: sheet.title,
|
||||
// signEndDate,
|
||||
// otherFile: '',
|
||||
// contractBase: contractFile.content,
|
||||
// buyerSignKeyword: buyerSignKeyword.content,
|
||||
// sellerSignKeyword: sellerSignKeyword.content
|
||||
// }
|
||||
// })
|
||||
// await vk.baseDao.updateAndReturn({
|
||||
// dbName: 'jjx-old',
|
||||
// whereJson: {
|
||||
// _id: data.id
|
||||
// },
|
||||
// dataJson: {
|
||||
// status: 2
|
||||
// }
|
||||
// })
|
||||
//
|
||||
// res.data = uploaddocs.result
|
||||
// } else {
|
||||
// return {
|
||||
// code: -1,
|
||||
// msg: uploaddocs.msg
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,414 @@
|
||||
'use strict';
|
||||
|
||||
const dbName = require("../../../../dao/config");
|
||||
const dayjs = require("dayjs");
|
||||
var isBetween = require('dayjs/plugin/isBetween')
|
||||
dayjs.extend(isBetween)
|
||||
|
||||
const PROCESS_PAY_METHOD = ['预付', '货到验收后付款', '提货付全款', '信誉采购,货到签单后账期:']
|
||||
const WRITE_INVOICE_TIME = ['付款当月(限20号之前付款,20号之后付款次月开票)', '付款后次月', '付款前']
|
||||
const INVOICE_TYPE = ['增值税专用发票13%', '增值税普通发票', '普通发票']
|
||||
|
||||
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: 'uni-id-users',
|
||||
getMain: true,
|
||||
getOne: true,
|
||||
whereJson: {
|
||||
_id: quote.userId
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// 获取询价单信息
|
||||
const sheet = await vk.baseDao.updateAndReturn({
|
||||
dbName: 'jjx-old',
|
||||
whereJson: {_id: quote.sheetId},
|
||||
dataJson: {
|
||||
status: 1,
|
||||
quoteUid: quote.userId
|
||||
}
|
||||
})
|
||||
|
||||
// 获取商品信息
|
||||
const productTitle = sheet.title
|
||||
if (sheet.type !== 3 && sheet.signMethod !== 1) {
|
||||
|
||||
const fadadaContractId = vk.pubfn.createOrderNo("E", 20)
|
||||
// 新增合同记录
|
||||
let contractTransactionId = vk.pubfn.createOrderNo("C", 20)
|
||||
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: 0,
|
||||
partyCount: 2,
|
||||
signCount: 0,
|
||||
contractType: sheet.contractType,
|
||||
signMethod: sheet.signMethod,
|
||||
sellerSupplement: sheet.sellerSupplement,
|
||||
transactionId: contractTransactionId,
|
||||
amount: quote.totalPrice,
|
||||
docTitle: sheet.title
|
||||
}
|
||||
})
|
||||
|
||||
await vk.baseDao.updateById({
|
||||
dbName: 'jjx-old',
|
||||
id: quote.sheetId,
|
||||
dataJson: {
|
||||
status: 1
|
||||
}
|
||||
})
|
||||
|
||||
const checkMessage = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-message-config",
|
||||
whereJson: {
|
||||
old: true,
|
||||
uid: quote.userId
|
||||
}
|
||||
})
|
||||
|
||||
if (checkMessage) {
|
||||
if (checkMessage.doNotDisturbRange) {
|
||||
if (dayjs().isBetween(checkMessage.doNotDisturbRange[0], checkMessage.doNotDisturbRange[1])) return
|
||||
}
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: quote.userId,
|
||||
title: `旧货:${sheet.title}被选商`,
|
||||
content: `您报价的旧货信息已被选商,赶紧去签合同吧`,
|
||||
type: 'contract',
|
||||
hasRead: false,
|
||||
pk: quote.sheetId
|
||||
}
|
||||
});
|
||||
await pubFun.sendNotifySms(quote.userId, 'SMS_474130453')
|
||||
}
|
||||
|
||||
// 上传合同模板
|
||||
|
||||
//新增 用户与合同的关联记录
|
||||
let buyerUid = uid
|
||||
let sellerUid = quote.userId
|
||||
if (sheet.type === 0) {
|
||||
buyerUid = quote.userId
|
||||
sellerUid = uid
|
||||
}
|
||||
await vk.daoCenter.userContractDao.adds([
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("E", 20),
|
||||
userId: buyerUid,
|
||||
role: 'buyer',
|
||||
sign: false,
|
||||
contractId
|
||||
},
|
||||
{
|
||||
transactionId: vk.pubfn.createOrderNo("E", 20),
|
||||
userId: sellerUid,
|
||||
role: 'seller',
|
||||
sign: false,
|
||||
contractId
|
||||
}
|
||||
])
|
||||
|
||||
if (sheet.signMethod === 0) {
|
||||
const templateId = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '80e3bed065a5560e075799d24532b14f'
|
||||
})
|
||||
const buyerSignKeyword = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '0b153f9a65a56a2007227cf5157133bf'
|
||||
})
|
||||
const sellerSignKeyword = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '09e7876865a56a320731cb244bbef818'
|
||||
})
|
||||
const signMaxDate = await vk.baseDao.findById({
|
||||
dbName: 'jjx-dict',
|
||||
id: '657d78958b0da41d311bd94c'
|
||||
})
|
||||
const signEndDate = vk.pubfn.getOffsetTime(new Date(), {
|
||||
day: parseInt(signMaxDate.content),
|
||||
mode: "after",
|
||||
});
|
||||
// const fieldList = await vk.baseDao.select({
|
||||
// dbName: 'jjx-contract-template',
|
||||
// whereJson: {
|
||||
// isOn: true
|
||||
// }
|
||||
// })
|
||||
let buyerSupplement = sheet.supplementary ? sheet.supplementary : ''
|
||||
let sellerSupplement = quote.remark ? quote.remark : ''
|
||||
if (quote.supplierExt) sellerSupplement += `${quote.remark ? ',' : ''}${quote.supplierExt}`
|
||||
let sellerUser = await vk.baseDao.findById({
|
||||
dbName: 'uni-id-users',
|
||||
id: quote.userId
|
||||
})
|
||||
let buyerUser = await vk.baseDao.findById({
|
||||
dbName: 'uni-id-users',
|
||||
id: uid
|
||||
})
|
||||
if (sheet.type === 0) {
|
||||
sellerUser = await vk.baseDao.findById({
|
||||
dbName: 'uni-id-users',
|
||||
id: uid
|
||||
})
|
||||
buyerUser = await vk.baseDao.findById({
|
||||
dbName: 'uni-id-users',
|
||||
id: quote.userId
|
||||
})
|
||||
buyerSupplement = quote.remark ? quote.remark : ''
|
||||
if (quote.supplierExt) buyerSupplement += `,${quote.supplierExt}`
|
||||
sellerSupplement = sheet.supplementary ? sheet.supplementary : ''
|
||||
}
|
||||
let detail = sheet.title
|
||||
if (sheet.otherCate) detail += `,${sheet.otherCateName}`
|
||||
if (sheet.type === 0 && sheet.unit) {
|
||||
detail += `,计价单位: ${sheet.unit},人民币单价: ${quote.totalPrice}元`
|
||||
}
|
||||
|
||||
let tradeInfo = ''
|
||||
if (sheet.type === 0) tradeInfo = `${sheet.payMethod}`
|
||||
else tradeInfo = `报价:${quote.totalPrice}元,${sheet.payMethod}`
|
||||
if (sheet.payMethod === '预付' && sheet.prePayRate) tradeInfo += `,${sheet.prePayRate}%货到付全款`
|
||||
if (sheet.payMethod === '其他付款方式描述') tradeInfo += `:${sheet.otherPayMethodDesc}`
|
||||
|
||||
if (sheet.type === 2) {
|
||||
tradeInfo += (sheet.invoice ? ',含税' : ',不含税')
|
||||
if (sheet.invoice) tradeInfo += (',开票时间:' + (sheet.writeInvoiceTime ? WRITE_INVOICE_TIME[sheet.writeInvoiceTime] : '无'))
|
||||
// tradeInfo += (',发票种类:' + (sheet.invoiceType ? INVOICE_TYPE[sheet.invoiceType] : '无'))
|
||||
// tradeInfo += (',其他要求:' + (sheet.invoiceOther ? sheet.invoiceOther : '无'))
|
||||
if (sheet.invoiceOther) tradeInfo += (',其他要求:' + sheet.invoiceOther)
|
||||
else {
|
||||
if (sheet.taxType && sheet.invoiceType && sheet.taxRate) tradeInfo += (`,纳税人身份:${sheet.taxType},发票种类:${sheet.invoiceType},税率:${sheet.taxRate}`)
|
||||
}
|
||||
tradeInfo += (',报价明细:' + (sheet.invoiceDetail ? sheet.invoiceDetail : '无'))
|
||||
} else if ([0, 1].includes(sheet.type)) {
|
||||
if (sheet.invoiceOther) tradeInfo += (',其他要求:' + sheet.invoiceOther)
|
||||
else {
|
||||
if (sheet.taxType && sheet.invoiceType && sheet.taxRate) tradeInfo += (`,纳税人身份:${sheet.taxType},发票种类:${sheet.invoiceType},税率:${sheet.taxRate}`)
|
||||
}
|
||||
}
|
||||
let expressRequire = '无'
|
||||
// expressRequire += `随货资料:${sheet.transportDocuments.join()},其他要求:${sheet.otherTransportDocuments ? sheet.otherTransportDocuments : '无'},运输限制要求:${sheet.transportLimit ? '有' : '无'}`
|
||||
// if (sheet.transportLimit && sheet.otherTransportRequest) expressRequire += `运输限制说明:${sheet.otherTransportRequest}`
|
||||
let region = ''
|
||||
if (sheet.type === 1) region = sheet.deliverAddressRegion.province.name + ' ' + sheet.deliverAddressRegion.city.name + ' ' + sheet.deliverAddressRegion.area.name
|
||||
else region = sheet.addressRegion.province.name + ' ' + sheet.addressRegion.city.name + ' ' + sheet.addressRegion.area.name
|
||||
const parameter = {
|
||||
seller: sellerUser.accountType === 2 ? sellerUser.company.companyName : sellerUser.person.personName,
|
||||
buyer: buyerUser.accountType === 2 ? buyerUser.company.companyName : buyerUser.person.personName,
|
||||
date: dayjs().format('YYYY年MM月DD日'),
|
||||
sellerSignDate: dayjs().format('YYYY年MM月DD日 HH时mm'),
|
||||
buyerSignDate: dayjs().format('YYYY年MM月DD日 HH时mm'),
|
||||
contractNo: fadadaContractId,
|
||||
region,
|
||||
detail,
|
||||
info: '无',
|
||||
tradeInfo,
|
||||
expressRequire,
|
||||
defaultDuty: '1.乙方所交产品品种、型号、规格、质量不符合规定的,如果甲方同意利用,应当按质论价;如果甲方不能利用的,应根据产品的具体情况,由乙方负责包换或包修,并承担修理、调换或退货而支付的实际费用;2.乙方不予供货违约责任为甲方的实际损失+违约金,如乙方材料符合订货标准,甲方不能退货和不收货,甲方无条件应按实际本合同订货数量支付100%货款,并支付乙方因此产生的实际费用。带有甲乙双方单位相关收货人和发货人签字的本合同的发货清单事项和内容均视为本合同的补充合同,与本合同有相同的法律效力,双方应共同遵照执行。',
|
||||
solve: '1、凡因本合同引起的或与本合同有关的任何争议,均可友好协商或仲裁解决,协商或仲裁不成的,双方协商同意在合同签订地人民法院管辖地起诉,违约一方或对合同争议承担主要责任的一方,应承担对方因仲裁和起诉而产生的全部律师代理费、鉴定(检验)费、诉讼保全费、诉讼保险费、公告费、差旅费、执行费、误工費和获取证据产生费用等其他相关费用。2、双方本合同相关权利放弃均应有双方书面作出并加盖公章或授权委托人签字后生效。',
|
||||
forceMajeure: '甲乙双方的任何一方由于不可抗力或突发公共事件的原因不能履行合同时,应及时向对方通报不能履行或不能完全履行的理由,以减轻可能给对方造成的损失,在取得有关机构证明以后,允许延期履行、部分履行或者不履行合同,并根据情况可部分或全部免予承担违约责任。',
|
||||
other: '本合同的全部内容由双方平等共同协商一致,共同起草制定,非一方事先拟定,不属于格式条款。本合同自双方签字盖章后生效(包括电子签字、盖章),按本合同内容地址、联系方式寄送的一切文书、函件送达与否,均为视为送达有法律效力,通知途径和本合同内联系方式或地址送达文件双方均予以验证。',
|
||||
buyerSupplement,
|
||||
sellerSupplement,
|
||||
buyerAddress: buyerUser.accountType === 2 ? buyerUser.company.mailAddress : buyerUser.person.address,
|
||||
sellerAddress: sellerUser.accountType === 2 ? sellerUser.company.mailAddress : sellerUser.person.address,
|
||||
buyerLegal: buyerUser.accountType === 2 ? buyerUser.company.legalName : '',
|
||||
sellerLegal: sellerUser.accountType === 2 ? sellerUser.company.legalName : '',
|
||||
buyerAgent: buyerUser.accountType === 2 ? buyerUser.manager.personName : '',
|
||||
sellerAgent: sellerUser.accountType === 2 ? sellerUser.manager.personName : '',
|
||||
buyerMobile: buyerUser.accountType === 2 ? buyerUser.manager.mobile : buyerUser.mobile,
|
||||
sellerMobile: sellerUser.accountType === 2 ? sellerUser.manager.mobile : sellerUser.mobile,
|
||||
buyerBankName: buyerUser.accountType === 2 ? buyerUser.company.companyBankName : buyerUser.person.personBankName,
|
||||
sellerBankName: sellerUser.accountType === 2 ? sellerUser.company.companyBankName : sellerUser.person.personBankName,
|
||||
buyerAccount: buyerUser.accountType === 2 ? buyerUser.company.companyAccount : buyerUser.person.personAccount,
|
||||
sellerAccount: sellerUser.accountType === 2 ? sellerUser.company.companyAccount : sellerUser.person.personAccount,
|
||||
}
|
||||
// for (let i = 0; i < fieldList.length; i++) {
|
||||
//
|
||||
// const field = fieldList[i]
|
||||
// parameter[field.field] = ''
|
||||
// }
|
||||
const uploaddocs = await pubFun.fadada('generate_contract.api', {
|
||||
template_id: templateId.content,
|
||||
contract_id: contractTransactionId,
|
||||
parameter_map: JSON.stringify(parameter)
|
||||
})
|
||||
let otherFileResList = []
|
||||
if (quote.files && quote.files.length > 0) {
|
||||
for (let i = 0; i < quote.files.length; i++) {
|
||||
otherFileResList.push(contractTransactionId + 'qf' + i.toString())
|
||||
await pubFun.fadada('uploaddocs.api', {
|
||||
contract_id: contractTransactionId + 'qf' + i.toString(),
|
||||
doc_title: sheet.title + `:报价附件${i + 1}`,
|
||||
doc_url: quote.files[i],
|
||||
doc_type: '.pdf'
|
||||
})
|
||||
}
|
||||
}
|
||||
if (otherFileResList.length) {
|
||||
otherFileResList.unshift(contractTransactionId)
|
||||
// 合并接口
|
||||
contractTransactionId = vk.pubfn.createOrderNo("MC", 20)
|
||||
const mergeRes = await pubFun.fadada('merge_contract.api', {
|
||||
contract_id: contractTransactionId,
|
||||
doc_title: sheet.title,
|
||||
contract_ids: otherFileResList.join()
|
||||
})
|
||||
console.log('mergeRes', mergeRes)
|
||||
console.log('otherFileResList', otherFileResList)
|
||||
}
|
||||
await vk.baseDao.update({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId
|
||||
},
|
||||
dataJson: {
|
||||
transactionId: contractTransactionId,
|
||||
}
|
||||
})
|
||||
if (parseInt(uploaddocs.code) === 1000) {
|
||||
await vk.baseDao.updateAndReturn({
|
||||
dbName: dbName.contract,
|
||||
whereJson: {
|
||||
_id: contractId,
|
||||
userId: uid
|
||||
},
|
||||
dataJson: {
|
||||
status: 1,
|
||||
docTitle: sheet.title,
|
||||
signEndDate,
|
||||
otherFile: '',
|
||||
contractBase: null,
|
||||
buyerSignKeyword: buyerSignKeyword.content,
|
||||
sellerSignKeyword: sellerSignKeyword.content
|
||||
}
|
||||
})
|
||||
await vk.baseDao.updateAndReturn({
|
||||
dbName: 'jjx-old',
|
||||
whereJson: {
|
||||
_id: quote.sheetId
|
||||
},
|
||||
dataJson: {
|
||||
status: 2
|
||||
}
|
||||
})
|
||||
|
||||
res.data = uploaddocs.result
|
||||
|
||||
await vk.baseDao.add({
|
||||
dbName: "jjx-message",
|
||||
dataJson: {
|
||||
uid: quote.userId,
|
||||
title: `旧货:${sheet.title}待签合同`,
|
||||
content: `您报价的旧货信息已创建合同,赶紧去签订合同吧`,
|
||||
type: 'contract',
|
||||
hasRead: false,
|
||||
pk: quote.sheetId
|
||||
}
|
||||
});
|
||||
await pubFun.sendNotifySms(quote.userId, 'SMS_474195497')
|
||||
} else {
|
||||
return {
|
||||
code: -1,
|
||||
msg: uploaddocs.msg
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// else {
|
||||
// const orderId = await vk.baseDao.add({
|
||||
// dbName: "jjx-order",
|
||||
// dataJson: {
|
||||
// orderNo: vk.pubfn.createOrderNo("CO", 20),
|
||||
// uid: uid,
|
||||
// sellerUid: quote.userId,
|
||||
// orderStatus: 0,
|
||||
// type: 4,
|
||||
// amount: quote.totalPrice,
|
||||
// offAmount: quote.totalPrice,
|
||||
// signMethod: 1
|
||||
// }
|
||||
// })
|
||||
//
|
||||
// await vk.baseDao.add({
|
||||
// dbName: "jjx-order-goods",
|
||||
// dataJson: {
|
||||
// orderId,
|
||||
// goodsId: null,
|
||||
// num: 1,
|
||||
// goodsName: '旧货交易',
|
||||
// goodsPrice: quote.totalPrice,
|
||||
// goodsCover: null,
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/enquiry/sheet/kh/delete 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
let {id} = data;
|
||||
if (vk.pubfn.isNull(id)) {
|
||||
return {code: -1, msg: 'id不能为空'};
|
||||
}
|
||||
await vk.baseDao.deleteById({
|
||||
dbName: 'jjx-old',
|
||||
id
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/old/kh/getList 前端调用的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 = -1} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
let whereJson = {}
|
||||
if (vk.pubfn.isNotNull(data.sellerOnly)) {
|
||||
// whereJson.uid = data.uid
|
||||
// whereJson.type = _.in([0, 2, 3])
|
||||
whereJson = _.or([
|
||||
_.and({
|
||||
uid: data.uid,
|
||||
type: _.in([0, 3]),
|
||||
}),
|
||||
_.and([
|
||||
{
|
||||
uid: data.uid,
|
||||
type: 2,
|
||||
rentType: 0
|
||||
}
|
||||
])
|
||||
])
|
||||
if (vk.pubfn.isNotNull(data.signMethod)) {
|
||||
if (parseInt(data.signMethod) === 1) whereJson[0].push({
|
||||
signMethod: parseInt(data.signMethod
|
||||
)
|
||||
})
|
||||
else whereJson.signMethod = whereJson.push({
|
||||
signMethod: _.neq(1)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
if (vk.pubfn.isNotNull(data.buyerOnly)) {
|
||||
// whereJson.uid = data.uid
|
||||
// whereJson.type = _.in([0, 2, 3])
|
||||
const orArr = [
|
||||
_.and({
|
||||
uid: data.uid,
|
||||
type: _.in([1]),
|
||||
}),
|
||||
_.and([
|
||||
{
|
||||
uid: data.uid,
|
||||
type: 2,
|
||||
rentType: 0
|
||||
}
|
||||
]),
|
||||
_.and({
|
||||
quoteUid: data.quoteUid,
|
||||
type: _.in([0, 3]),
|
||||
}),
|
||||
_.and([
|
||||
{
|
||||
quoteUid: data.quoteUid,
|
||||
type: 2,
|
||||
rentType: 1
|
||||
}
|
||||
]),
|
||||
]
|
||||
if (vk.pubfn.isNotNull(data.signMethod)) {
|
||||
if (parseInt(data.signMethod) === 1) orArr.push(_.and({
|
||||
|
||||
signMethod: parseInt(data.signMethod)
|
||||
}))
|
||||
else {
|
||||
orArr.push(_.and({
|
||||
signMethod: _.neq(1)
|
||||
}))
|
||||
}
|
||||
}
|
||||
whereJson = _.or([
|
||||
...orArr
|
||||
])
|
||||
} else {
|
||||
if (vk.pubfn.isNotNull(data.quoteUid)) {
|
||||
whereJson.quoteUid = data.quoteUid;
|
||||
} else whereJson.uid = data.uid;
|
||||
if (vk.pubfn.isNotNull(data.signMethod)) {
|
||||
if (parseInt(data.signMethod) === 1) whereJson.signMethod = parseInt(data.signMethod);
|
||||
else whereJson.signMethod = _.neq(1)
|
||||
}
|
||||
}
|
||||
console.log('whereJson', whereJson)
|
||||
|
||||
// console.log(whereJson)
|
||||
res = await vk.baseDao.selects({
|
||||
dbName: "jjx-old",
|
||||
getCount: true,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
whereJson,
|
||||
sortArr: [{"name": "_add_time", "type": "desc"}],
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "jjx-old-quote",
|
||||
localKey: "_id",
|
||||
foreignKey: "sheetId",
|
||||
as: "quoteList",
|
||||
limit: 500,
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "uni-id-users",
|
||||
localKey: "uid",
|
||||
foreignKey: "_id",
|
||||
as: "user",
|
||||
limit: 1
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
})
|
||||
for (let i = 0; i < res.rows.length; i++) {
|
||||
if (res.rows[i].quoteUid) {
|
||||
res.rows[i].otherUser = await vk.baseDao.findById({
|
||||
dbName: "uni-id-users",
|
||||
id: res.rows[i].quoteUid
|
||||
})
|
||||
}
|
||||
res.rows[i].user = await vk.baseDao.findById({
|
||||
dbName: "uni-id-users",
|
||||
id: res.rows[i].uid
|
||||
})
|
||||
|
||||
res.rows[i].contract = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-contract",
|
||||
whereJson: {
|
||||
sheetId: res.rows[i]._id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/old/kh/getList 前端调用的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 = -1} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
let dbName = "jjx-old-quote";
|
||||
|
||||
let whereJson = {userId: uid};
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
getCount: true,
|
||||
whereJson,
|
||||
sortArr: [{name: "_add_time", type: "desc"}],
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "jjx-old",
|
||||
localKey: "sheetId",
|
||||
foreignKey: "_id",
|
||||
as: "sheet",
|
||||
limit: 1,
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
'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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/old/pub/getDetail 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
res = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-old",
|
||||
getOne: true,
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
},
|
||||
});
|
||||
if (res) {
|
||||
const {rows} = await vk.baseDao.select({
|
||||
dbName: "jjx-old-quote",
|
||||
whereJson: {
|
||||
sheetId: data.id
|
||||
},
|
||||
limit: 500,
|
||||
sortArr: [{"name": "_add_time", "type": "desc"}],
|
||||
})
|
||||
for(let i = 0; i< rows.length; i++){
|
||||
rows[i].user = await vk.baseDao.findByWhereJson({
|
||||
dbName: "uni-id-users",
|
||||
getOne: true,
|
||||
whereJson: {
|
||||
_id: rows[i].userId
|
||||
},
|
||||
})
|
||||
}
|
||||
res.quoteList = rows
|
||||
|
||||
res.hasQuote = false
|
||||
res.isMine = res.uid === uid
|
||||
res.quoteList.forEach(quote => {
|
||||
if (quote.userId === uid) res.hasQuote = true
|
||||
})
|
||||
|
||||
res.user = await vk.baseDao.findByWhereJson({
|
||||
dbName: "uni-id-users",
|
||||
getOne: true,
|
||||
whereJson: {
|
||||
_id: res.uid
|
||||
},
|
||||
})
|
||||
|
||||
}else {
|
||||
return {
|
||||
code: -1,
|
||||
msg: "未找到该旧货信息"
|
||||
}
|
||||
}
|
||||
// res = result.rows
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user