20261008
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url admin/old/sys/changeField 前端调用的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: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
// todo 订单退款成功处理
|
||||
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "jjx-order",
|
||||
id: data.id,
|
||||
dataJson: {
|
||||
[data.field]: data.value
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
'use strict';
|
||||
const normalizeSortRule = require('../../utils/sortRule.js');
|
||||
|
||||
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, formData, sortRule} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const whereJson = {}
|
||||
const setInvoiceWhere = (value) => {
|
||||
const invoiceStatus = Number(value)
|
||||
if (invoiceStatus === 1) {
|
||||
whereJson.isInvoice = _.or(_.eq(1), _.exists(false), _.eq(null), _.eq(''))
|
||||
} else {
|
||||
whereJson.isInvoice = Number.isNaN(invoiceStatus) ? value : invoiceStatus
|
||||
}
|
||||
}
|
||||
if (vk.pubfn.isNotNull(data.type)) {
|
||||
whereJson.type = data.type
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(data.orderNo)) {
|
||||
whereJson.orderNo = new RegExp(data.orderNo)
|
||||
}
|
||||
if (vk.pubfn.isNotNull(data.status)) {
|
||||
whereJson.status = data.status
|
||||
}
|
||||
if (vk.pubfn.isNotNull(data.orderStatus)) whereJson.orderStatus = data.orderStatus
|
||||
else whereJson.orderStatus = _.neq(-1)
|
||||
|
||||
if (vk.pubfn.isNotNull(data._add_time)) {
|
||||
whereJson.userId = data.userId
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(data.isInvoice)) {
|
||||
setInvoiceWhere(data.isInvoice)
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(formData)) {
|
||||
if (vk.pubfn.isNotNull(formData.orderStatus)) {
|
||||
if (Array.isArray(formData.orderStatus)) whereJson.orderStatus = _.in(formData.orderStatus)
|
||||
else whereJson.orderStatus = formData.orderStatus
|
||||
} else whereJson.orderStatus = _.neq(-1)
|
||||
if (vk.pubfn.isNotNull(formData.type)) whereJson.type = formData.type
|
||||
if (vk.pubfn.isNotNull(formData.subType)) whereJson.subType = formData.subType
|
||||
if (vk.pubfn.isNotNull(formData.orderNo)) whereJson.orderNo = new RegExp(formData.orderNo)
|
||||
if (vk.pubfn.isNotNull(formData.isInvoice)) setInvoiceWhere(formData.isInvoice)
|
||||
if (vk.pubfn.isNotNull(formData._add_time)) {
|
||||
whereJson._add_time = _.gte(formData._add_time[0])
|
||||
whereJson._add_time = _.lte(formData._add_time[1])
|
||||
}
|
||||
}
|
||||
|
||||
// 区域限制
|
||||
if (whereJson.type === 1 && userInfo.allowArea && userInfo.allowArea.length > 0) {
|
||||
whereJson['addressRegion.city.code'] = _.in(userInfo.allowArea.map(item => item.area.city.code));
|
||||
}
|
||||
|
||||
|
||||
res = await vk.baseDao.selects({
|
||||
dbName: "jjx-order",
|
||||
getCount: true,
|
||||
whereJson,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
sortArr: normalizeSortRule(sortRule, [{"name": "_add_time", "type": "desc"}], ["_add_time"]),
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "uni-id-users",
|
||||
localKey: "uid",
|
||||
foreignKey: "_id",
|
||||
as: "user",
|
||||
limit: 1, // limit=1则以对象形式返回
|
||||
},
|
||||
{
|
||||
dbName: "jjx-order-goods",
|
||||
localKey: "_id",
|
||||
foreignKey: "orderId",
|
||||
as: "goods",
|
||||
limit: 100, // limit=1则以对象形式返回
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "uni-id-users",
|
||||
localKey: "companyId",
|
||||
foreignKey: "_id",
|
||||
as: "company",
|
||||
limit: 1, // limit=1则以对象形式返回
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
});
|
||||
|
||||
for (let i = 0; i < res.rows.length; i++) {
|
||||
if (vk.pubfn.isNull(res.rows[i].isInvoice)) {
|
||||
res.rows[i].isInvoice = 1
|
||||
}
|
||||
|
||||
if (res.rows[i].type === 14) {
|
||||
res.rows[i].amount = 0
|
||||
const payList = await vk.baseDao.select({
|
||||
dbName: "jjx-order-pay-list",
|
||||
whereJson: {
|
||||
orderId: res.rows[i]._id,
|
||||
hasPaid: true,
|
||||
sellerConfirm: true,
|
||||
buyerRefuse: false,
|
||||
}
|
||||
})
|
||||
for (const payRow of payList.rows) {
|
||||
res.rows[i].amount += parseFloat(payRow.amount)
|
||||
}
|
||||
}
|
||||
|
||||
if (res.rows[i].type === 0) {
|
||||
for (const goodsItem of res.rows[i].goods) {
|
||||
const goods = await vk.baseDao.findById({
|
||||
dbName: "jjx-goods",
|
||||
id: goodsItem.goodsId
|
||||
});
|
||||
if (goods && goods.sku && goods.sku.length > 0) {
|
||||
goodsItem.sku = goods.sku.find(item => item._index === goodsItem.skuId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (res.rows[i].type === 1 && res.rows[i].subType === 2) {
|
||||
const configList = await vk.baseDao.select({
|
||||
dbName: "jjx-coop-config",
|
||||
whereJson: {
|
||||
type: 2
|
||||
}
|
||||
})
|
||||
for (let j in res.rows[i].goods) {
|
||||
const goods = res.rows[i].goods[j]
|
||||
configList.rows.forEach(config => {
|
||||
if (config._id === goods.configId) {
|
||||
config.contents.forEach(content => {
|
||||
if (content._index === goods.contentIndex) {
|
||||
content.amountList.forEach(amountItem => {
|
||||
if (amountItem._index === goods.amountIndex) {
|
||||
res.rows[i].goods[j].amountItem = amountItem
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (res.rows[i].type === 7) {
|
||||
for (let j in res.rows[i].goods) {
|
||||
if (res.rows[i].goods[j].isSingleQuote) {
|
||||
switch(res.rows[i].goods[j].type){
|
||||
case 'enquiry' : {
|
||||
res.rows[i].goods[j].sheet = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-enquiry-sheet",
|
||||
whereJson: {
|
||||
_id: res.rows[i].goods[j].sheetId
|
||||
}
|
||||
})
|
||||
}
|
||||
break;
|
||||
case 'old' : {
|
||||
res.rows[i].goods[j].sheet = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-old",
|
||||
whereJson: {
|
||||
_id: res.rows[i].goods[j].sheetId
|
||||
}
|
||||
})
|
||||
}
|
||||
break;
|
||||
case 'process' : {
|
||||
res.rows[i].goods[j].sheet = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-process-sheet",
|
||||
whereJson: {
|
||||
_id: res.rows[i].goods[j].sheetId
|
||||
}
|
||||
})
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
'use strict';
|
||||
const dayjs = require("dayjs");
|
||||
const OpenSdk = require('../../../../util/base').default;
|
||||
|
||||
const sdk = new OpenSdk({
|
||||
appId: '8a81c1db8fc5238d01910b9e312d0692',
|
||||
appKey: 'a15ceac60f5b464eb758c4fe7800ee9f'
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url admin/old/sys/refund 前端调用的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, orderStatus, refundRefuseReason} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "jjx-order",
|
||||
id: data.id,
|
||||
dataJson: {
|
||||
orderStatus,
|
||||
refundRefuseReason
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const order = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-order",
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
}
|
||||
})
|
||||
|
||||
let refundData = {
|
||||
queryUrl: 'https://api-mop.chinaums.com/v1/netpay/bills/refund',
|
||||
timestamp: dayjs().format('YYYYMMDDHHmmss'),
|
||||
nonce: 'rp84ufhfn20yneo3tp',
|
||||
content: {
|
||||
requestTimestamp: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
// mid: '8984501521190CF',
|
||||
// tid: '20713432',
|
||||
mid: '898450100002303',
|
||||
tid: 'G5SBN2XJ',
|
||||
instMid: 'QRPAYDEFAULT',
|
||||
billNo: order.orderNo,
|
||||
billDate: dayjs(order.payTime).format('YYYY-MM-DD'),
|
||||
refundAmount: order.payAmount * 100
|
||||
}
|
||||
}
|
||||
|
||||
console.log('退款数据', refundData)
|
||||
|
||||
if (orderStatus === 6) {
|
||||
console.log('退款执行')
|
||||
sdk.exec(refundData).then(res => {
|
||||
const result = JSON.parse(res);
|
||||
console.log('退款结果', result)
|
||||
// if (result.errCode === 'SUCCESS') {
|
||||
// }
|
||||
}).catch(err => {
|
||||
console.log('退款失败', err)
|
||||
}).finally(() => {
|
||||
console.log('退款最后执行')
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
const dayjs = require("dayjs");
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url client/order/kh/setExpress 前端调用的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, expressName, expressNo, remark, expressPhoto,} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "jjx-order",
|
||||
id,
|
||||
dataJson: {
|
||||
expressName,
|
||||
expressNo,
|
||||
remark,
|
||||
expressPhoto,
|
||||
orderStatus: 2,
|
||||
expressTime: dayjs().valueOf(),
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user