fix: 提现排除处理中金额,选择报价改为重点提示
可提现额度扣除处理中提现,避免重复提现超总额;收到报价选择供应商时展示重点提示而非服务费提示。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+70
-28
@@ -8,15 +8,17 @@ module.exports = {
|
||||
* @param {String} accNo 账号
|
||||
* @param {String} reqDate 请求日期,格式:yyyyMMdd
|
||||
* @param {String} reqJournalNo 请求流水号
|
||||
* @param {String} logId 可选,流水ID,传入后会回写状态
|
||||
*/
|
||||
main: async (event) => {
|
||||
let { data = {}, util } = event;
|
||||
let { vk } = util;
|
||||
let { accNo, reqDate, reqJournalNo } = data;
|
||||
let { accNo, reqDate, reqJournalNo, logId } = data;
|
||||
|
||||
accNo = String(accNo || '').trim();
|
||||
reqDate = String(reqDate || '').trim();
|
||||
reqJournalNo = String(reqJournalNo || '').trim();
|
||||
logId = String(logId || '').trim();
|
||||
|
||||
if (!accNo) {
|
||||
return {
|
||||
@@ -46,43 +48,83 @@ module.exports = {
|
||||
};
|
||||
}
|
||||
|
||||
let res = await vk.request({
|
||||
url: 'http://jjx-union-pay.gxwebsoft.com/api/union-pay-jjx/getActionLog',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
header: {
|
||||
'content-type': 'application/json; charset=utf-8'
|
||||
},
|
||||
data: {
|
||||
accNo,
|
||||
reqDate,
|
||||
reqJournalNo
|
||||
},
|
||||
timeout: 60000
|
||||
let res = await balanceUtil.requestActionLog({
|
||||
vk,
|
||||
accNo,
|
||||
reqDate,
|
||||
reqJournalNo
|
||||
});
|
||||
|
||||
if (res && typeof res === 'object' && typeof res.code === 'undefined') {
|
||||
res.code = 0;
|
||||
}
|
||||
|
||||
const responseObjects = balanceUtil.getRemoteResponseObjects(res);
|
||||
const list = balanceUtil.pickFirstDefined([
|
||||
Array.isArray(res.list) ? res.list : undefined,
|
||||
Array.isArray(res.rows) ? res.rows : undefined,
|
||||
Array.isArray(res.data) ? res.data : undefined,
|
||||
Array.isArray(res.data && res.data.list) ? res.data.list : undefined,
|
||||
Array.isArray(res.data && res.data.rows) ? res.data.rows : undefined,
|
||||
Array.isArray(res.info && res.info.list) ? res.info.list : undefined,
|
||||
Array.isArray(res.info && res.info.rows) ? res.info.rows : undefined,
|
||||
Array.isArray(res.content && res.content.list) ? res.content.list : undefined,
|
||||
Array.isArray(res.content && res.content.rows) ? res.content.rows : undefined
|
||||
]) || [];
|
||||
const status = balanceUtil.getActionStatus(res);
|
||||
const statusText = balanceUtil.getActionStatusTextByStatus(status);
|
||||
|
||||
if (status !== null) {
|
||||
let logInfo = null;
|
||||
if (logId) {
|
||||
logInfo = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-balance-log',
|
||||
whereJson: {
|
||||
_id: logId
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!logInfo) {
|
||||
logInfo = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-balance-log',
|
||||
whereJson: {
|
||||
srcReqId: reqJournalNo,
|
||||
merchantId: accNo
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (logInfo && logInfo._id) {
|
||||
logId = logInfo._id;
|
||||
const prevStatus = Number(logInfo.status);
|
||||
const nextStatus = Number(status);
|
||||
const updateData = {
|
||||
status: nextStatus
|
||||
};
|
||||
|
||||
// 新提现单(balanceDeducted === false):成功时再扣减余额缓存
|
||||
// 旧提现单无该字段:创建时已扣减,这里只更新状态
|
||||
const needDeductOnSuccess = logInfo.balanceDeducted === false
|
||||
&& prevStatus === 1
|
||||
&& nextStatus === 2;
|
||||
|
||||
if (needDeductOnSuccess) {
|
||||
const amount = balanceUtil.normalizeAmount(logInfo.amount);
|
||||
await balanceUtil.applyMerchantBalanceDelta({
|
||||
vk,
|
||||
merchantId: accNo,
|
||||
delta: -amount,
|
||||
lastLogId: logId
|
||||
});
|
||||
updateData.balanceDeducted = true;
|
||||
}
|
||||
|
||||
await vk.baseDao.updateById({
|
||||
dbName: 'jjx-balance-log',
|
||||
id: logId,
|
||||
dataJson: updateData
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const responseObjects = balanceUtil.getRemoteResponseObjects(res);
|
||||
if (responseObjects.data && typeof responseObjects.data === 'object' && !Array.isArray(responseObjects.data)) {
|
||||
responseObjects.data.list = list;
|
||||
responseObjects.data.status = status;
|
||||
responseObjects.data.statusText = statusText;
|
||||
responseObjects.data.logId = logId;
|
||||
} else if (res && typeof res === 'object') {
|
||||
res.data = {
|
||||
list
|
||||
status,
|
||||
statusText,
|
||||
logId
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user