feat(forum): P1 topic coupons, P2 plate follow gateway, cash creator revenue
- Topic_Pay: soft/hard coupon validate, payable amount, free-after-discount, paid burn - Creator_Revenue: settle content/topic/plate_follow cash (type=order), keep shop path - Plate VIP1/VIP2 meta + resolve_plate_follow_pay_price via aksrt_get_user_vip_level - New AKSRT_Plate_Follow_Pay REST multi-gateway; remove Credits×100 money bypass - Frontend: cms-download plate_follow apiKind + forum-governance money cashier bridge
This commit is contained in:
1 parent
1a15ae7cea
commit
78d3189f8f
14 files changed
+1189
-169
No files matched your search
@@ -367,7 +367,9 @@
|
||||
}
|
||||
|
||||
function payApiBase(apiKind) {
|
||||
return apiKind === 'topic' ? '/pay/topic/' : '/pay/content/';
|
||||
if (apiKind === 'topic') return '/pay/topic/';
|
||||
if (apiKind === 'plate_follow') return '/pay/plate-follow/';
|
||||
return '/pay/content/';
|
||||
}
|
||||
|
||||
function buildPreviewUrl(postId, priceType, couponCode, apiKind) {
|
||||
@@ -414,7 +416,7 @@
|
||||
renderError(r.json.message || '', data, returnFocusEl, 'aksrt_need_vip');
|
||||
return;
|
||||
}
|
||||
if (code === 'aksrt_already_paid') {
|
||||
if (code === 'aksrt_already_paid' || code === 'aksrt_already_followed') {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
@@ -446,15 +448,16 @@
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
// Free VIP topics still need a free-order unlock POST; content free can reload.
|
||||
if (preview.is_free && preview.pay_type !== 'topic') {
|
||||
// Free VIP topic/plate_follow still need a free-order unlock POST; content free can reload.
|
||||
if (preview.is_free && preview.pay_type !== 'topic' && preview.pay_type !== 'plate_follow') {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
const isPoints = preview.pay_modo === 'points';
|
||||
const priceType = (preview._price_type || preview.price_type || '');
|
||||
const apiKind = preview._api_kind || (preview.pay_type === 'topic' ? 'topic' : 'content');
|
||||
const apiKind = preview._api_kind
|
||||
|| (preview.pay_type === 'topic' ? 'topic' : (preview.pay_type === 'plate_follow' ? 'plate_follow' : 'content'));
|
||||
let amountLabel = escapeHtml(preview.amount_label || '');
|
||||
let baseLabel = escapeHtml(preview.base_label || '');
|
||||
const listLabel = escapeHtml(preview.list_amount_label || preview.amount_label || amountLabel);
|
||||
@@ -616,7 +619,7 @@
|
||||
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
||||
const code = r.json && r.json.code ? r.json.code : '';
|
||||
const data = (r.json && r.json.data) || {};
|
||||
if (code === 'aksrt_already_paid') {
|
||||
if (code === 'aksrt_already_paid' || code === 'aksrt_already_followed') {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
@@ -666,6 +669,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const plateFollowBuyBtn = e.target.closest('[data-aksrt-pay-plate-follow]');
|
||||
if (plateFollowBuyBtn) {
|
||||
e.preventDefault();
|
||||
const plateId = parseInt(plateFollowBuyBtn.getAttribute('data-aksrt-pay-plate-follow') || '0', 10);
|
||||
if (plateId) openCashier(plateId, plateFollowBuyBtn, '', '', 'plate_follow');
|
||||
return;
|
||||
}
|
||||
|
||||
const buyBtn = e.target.closest('[data-action="aksrt-need-purchase"], [data-aksrt-pay-content]');
|
||||
if (buyBtn) {
|
||||
e.preventDefault();
|
||||
@@ -696,6 +707,11 @@
|
||||
requestDownload(btn);
|
||||
});
|
||||
|
||||
// Bridge for forum-governance plate money cashier.
|
||||
window.aksrtOpenCashier = function (postId, returnFocusEl, priceType, couponCode, apiKind) {
|
||||
openCashier(postId, returnFocusEl || null, priceType || '', couponCode || '', apiKind || 'content');
|
||||
};
|
||||
|
||||
// ===== 注入 modal 基础样式(避免必须额外加载 CSS)=====
|
||||
const style = document.createElement('style');
|
||||
style.textContent =
|
||||
|
||||
@@ -690,10 +690,27 @@
|
||||
}
|
||||
|
||||
function purchasePlateFollow(plateId, button, payHint) {
|
||||
payHint = payHint || {};
|
||||
var modo = String(payHint.modo || 'money');
|
||||
|
||||
// Cash: multi-gateway cashier (no Credits×100 bypass).
|
||||
if (modo === 'money' && !payHint.is_free) {
|
||||
button.disabled = false;
|
||||
if (typeof window.aksrtOpenCashier === 'function') {
|
||||
window.aksrtOpenCashier(plateId, button, '', '', 'plate_follow');
|
||||
return;
|
||||
}
|
||||
var msgCashier = '收银台未加载,请刷新页面后重试';
|
||||
if (typeof window.aksrtToast === 'function') { window.aksrtToast(msgCashier, 'error'); }
|
||||
else { window.alert(msgCashier); }
|
||||
return;
|
||||
}
|
||||
|
||||
// Points / VIP free: keep AJAX purchase path.
|
||||
var confirmMsg = '确认付费关注该版块?';
|
||||
if (payHint && payHint.is_free) {
|
||||
if (payHint.is_free) {
|
||||
confirmMsg = '确认使用 VIP 免费关注该版块?';
|
||||
} else if (payHint) {
|
||||
} else {
|
||||
confirmMsg = '确认支付 ' + formatFollowPayLabel(payHint) + ' 关注该版块?';
|
||||
}
|
||||
if (!window.confirm(confirmMsg)) {
|
||||
@@ -712,14 +729,19 @@
|
||||
credentials: 'same-origin',
|
||||
}).then(function (r) { return r.json(); }).then(function (payload) {
|
||||
if (!payload.success) {
|
||||
throw new Error((payload.data && payload.data.message) || '支付失败');
|
||||
var errData = payload.data || {};
|
||||
// Server may redirect money path to cashier.
|
||||
if (errData.require_cashier && typeof window.aksrtOpenCashier === 'function') {
|
||||
button.disabled = false;
|
||||
window.aksrtOpenCashier(plateId, button, '', '', 'plate_follow');
|
||||
return;
|
||||
}
|
||||
throw new Error(errData.message || '支付失败');
|
||||
}
|
||||
var res = payload.data || {};
|
||||
button.setAttribute('data-followed', '1');
|
||||
button.classList.add('is-followed');
|
||||
var label = button.querySelector('span') || button;
|
||||
if (button.querySelector('i') && button.childNodes.length) {
|
||||
// keep icon, replace trailing text via last text-ish content
|
||||
button.innerHTML = '<i class="fas fa-heart"></i> 已关注';
|
||||
} else {
|
||||
button.textContent = '已关注';
|
||||
|
||||
Reference in new issue
Block a user