feat: 新增AI客服/积分管理/合同审查/我的报告页面,完善.sign.vue入口与积分显示

This commit is contained in:
2026-10-16 21:09:21 +08:00
parent 8a1da677e4
commit ae97c5d2be
476 changed files with 35618 additions and 540 deletions
@@ -0,0 +1,55 @@
//积分充值
module.exports = {
main: async (event) => {
let { data = {}, userInfo, util } = event;
let { db, _ } = util;
const { order_id } = data;
if (!order_id) {
return { code: -1, msg: '缺少订单ID' };
}
// 查订单
const orderRes = await db.collection('vk-pay-orders').doc(order_id).get();
if (!orderRes.data.length) {
return { code: -1, msg: '订单不存在' };
}
const order = orderRes.data[0];
if (order.status !== 1) {
return { code: -1, msg: '订单未支付' };
}
// 解析充值积分数量
const attachedData = JSON.parse(order.attached_data || '{}');
const points = attachedData.points;
if (!points) {
return { code: -1, msg: '订单数据异常' };
}
// 增加余额
await db.collection('jjx-user-points').doc(userInfo.uid).update({
balance: _.inc(points),
total_earned: _.inc(points),
update_time: new Date()
});
// 查最新余额
const userRes = await db.collection('jjx-user-points').doc(userInfo.uid).get();
const balance = userRes.data[0].balance;
// 记录流水
await db.collection('jjx-points-log').add({
user_id: userInfo.uid,
type: 'earn',
amount: points,
balance_after: balance,
reason: '积分充值(' + (order.total_fee / 100) + '元)',
biz_type: 'recharge',
biz_id: order_id,
_add_time: new Date()
});
return { code: 0, msg: 'ok', data: { balance, points_added: points } };
}
};