feat: 签约提示/赠送次数/自动划付提醒,自营支付成功弹窗,隐藏微信登录

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-27 03:28:31 +08:00
parent 85cddfbf8d
commit 683a9411fd
19 changed files with 469 additions and 99 deletions
@@ -0,0 +1,143 @@
'use strict';
const notaryPay = require('../../order/kh/util/notaryPay');
/** 短信模板字典 ID,content 填阿里云模板号,如 SMS_xxxxx;模板变量为 time */
const AUTO_TRANSFER_REMIND_SMS_DICT_ID = 'auto_transfer_remind_sms_template';
/** 兜底短信模板 ID(模板变量:time),上线前请替换为已审核通过的阿里云模板 */
const AUTO_TRANSFER_REMIND_SMS_TEMPLATE_ID = '';
function formatZhDateTime(vk, timestamp) {
const date = new Date(Number(timestamp) || Date.now());
return vk.pubfn.timeFormat(date, 'yyyy年MM月dd日hh:mm');
}
function buildRemindContent(autoConfirmTimeText) {
return `重要提示:您在金久信公正交易项下待确认业务的系统自动确认时间为${autoConfirmTimeText},该期限即将届满;若到期未完成相关处理,系统将依据本平台交易规则自动确认收货或处理申请金额,请您及时登录平台完成对应操作,避免产生利益损失。若您已完成相关处理,可忽略本提示,如有疑问请联系客服咨询。`;
}
async function getRemindSmsTemplateId(vk) {
try {
const config = await vk.baseDao.findByWhereJson({
dbName: 'jjx-dict',
whereJson: {
_id: AUTO_TRANSFER_REMIND_SMS_DICT_ID
}
});
if (config && config.content) return String(config.content).trim();
const configByKey = await vk.baseDao.findByWhereJson({
dbName: 'jjx-dict',
whereJson: {
key: AUTO_TRANSFER_REMIND_SMS_DICT_ID
}
});
if (configByKey && configByKey.content) return String(configByKey.content).trim();
} catch (err) {
console.error('getRemindSmsTemplateId error:', err);
}
return AUTO_TRANSFER_REMIND_SMS_TEMPLATE_ID;
}
module.exports = {
/**
* 距离自动划付不足 24 小时时,发送短信 + 站内信提醒(每笔申请仅提醒一次)
* @url client/timedTask/pub/remindAutoTransferPayList
*/
main: async (event) => {
let { data = {}, util } = event;
let { vk, _, pubFun } = util;
let res = { code: 0, msg: '', data: [] };
if (data.key !== 'lsgjoksdjf') return { code: 1, msg: '非法请求' };
const now = Date.now();
const deadline = now + 24 * 60 * 60 * 1000;
const smsTemplateId = await getRemindSmsTemplateId(vk);
const payList = await vk.baseDao.select({
dbName: 'jjx-order-pay-list',
whereJson: _.and([
{
isNotaryPay: true,
isNotaryApply: true,
hasPaid: true,
buyerRefuse: false,
sellerConfirm: false,
autoTransferRemindSent: _.neq(true)
},
{ autoTransferTimestamp: _.gt(now) },
{ autoTransferTimestamp: _.lte(deadline) }
]),
sortArr: [{ name: 'autoTransferTimestamp', type: 'asc' }],
pageIndex: 1,
pageSize: 200
});
for (const payRecord of payList.rows || []) {
const itemRes = {
_id: payRecord._id,
orderId: payRecord.orderId,
buyerUid: payRecord.buyerUid,
message: false,
sms: false,
msg: ''
};
try {
if (!payRecord.buyerUid) {
itemRes.msg = '缺少买家用户';
res.data.push(itemRes);
continue;
}
const autoConfirmTimeText = payRecord.autoTransferAt
? String(payRecord.autoTransferAt).replace(
/^(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}).*$/,
'$1年$2月$3日$4:$5'
)
: formatZhDateTime(vk, payRecord.autoTransferTimestamp);
const content = buildRemindContent(autoConfirmTimeText);
await notaryPay.addMessage(vk, {
uid: payRecord.buyerUid,
title: '重要提示',
content,
type: 'notary-auto-transfer-remind',
pk: payRecord.orderId
});
itemRes.message = true;
if (smsTemplateId) {
try {
if (typeof pubFun.sendNotifySms === 'function') {
await pubFun.sendNotifySms(payRecord.buyerUid, smsTemplateId, {
time: autoConfirmTimeText
});
itemRes.sms = true;
}
} catch (smsErr) {
console.error('remindAutoTransferPayList sms error:', payRecord._id, smsErr);
itemRes.msg = smsErr.message || '短信发送失败';
}
} else {
itemRes.msg = '未配置短信模板';
}
await vk.baseDao.updateById({
dbName: 'jjx-order-pay-list',
id: payRecord._id,
dataJson: {
autoTransferRemindSent: true,
autoTransferRemindAt: vk.pubfn.timeFormat(new Date(), 'yyyy-MM-dd hh:mm:ss'),
autoTransferRemindTimestamp: Date.now()
}
});
} catch (err) {
console.error('remindAutoTransferPayList error:', payRecord._id, err);
itemRes.msg = err.message || '提醒失败';
}
res.data.push(itemRes);
}
res.msg = `已处理${res.data.length}笔即将自动划付提醒`;
return res;
}
};