feat(admin-web): support offline settlement in batch create
When batch creating special deductions: - Amount empty or 0: auto-switch to offline settlement mode - Amount > 0: normal deduction mode (requires reason) - Add hint text in batch create modal for special deduction 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
21c8f1906a
commit
f94083df36
|
|
@ -376,7 +376,45 @@ export default function PendingActionsPage() {
|
|||
}
|
||||
|
||||
let actionParams: Record<string, unknown> | undefined;
|
||||
if (batchFormData.actionParams.trim()) {
|
||||
|
||||
// 特殊扣减的特殊处理
|
||||
if (batchFormData.actionCode === ACTION_CODES.SPECIAL_DEDUCTION) {
|
||||
// 尝试解析已有参数
|
||||
let parsedParams: Record<string, unknown> = {};
|
||||
if (batchFormData.actionParams.trim()) {
|
||||
try {
|
||||
parsedParams = JSON.parse(batchFormData.actionParams);
|
||||
} catch {
|
||||
toast.error('操作参数格式错误,请输入有效的 JSON');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const amount = typeof parsedParams.amount === 'number' ? parsedParams.amount : parseFloat(String(parsedParams.amount || '0'));
|
||||
const reason = String(parsedParams.reason || '').trim();
|
||||
|
||||
// 金额为空、NaN 或 <= 0 时,自动切换为全额线下结算模式
|
||||
if (isNaN(amount) || amount <= 0) {
|
||||
actionParams = {
|
||||
amount: 0,
|
||||
reason: reason || '该收益已由用户与上级间线下完成现金收付',
|
||||
createdBy: 'admin',
|
||||
isOfflineSettlement: true,
|
||||
};
|
||||
} else {
|
||||
// 普通模式需要填写原因
|
||||
if (!reason) {
|
||||
toast.error('特殊扣减必须填写原因/备注');
|
||||
return;
|
||||
}
|
||||
actionParams = {
|
||||
amount,
|
||||
reason,
|
||||
createdBy: 'admin',
|
||||
isOfflineSettlement: false,
|
||||
};
|
||||
}
|
||||
} else if (batchFormData.actionParams.trim()) {
|
||||
try {
|
||||
actionParams = JSON.parse(batchFormData.actionParams);
|
||||
} catch {
|
||||
|
|
@ -904,12 +942,28 @@ export default function PendingActionsPage() {
|
|||
</select>
|
||||
</div>
|
||||
|
||||
{/* 特殊扣减提示 */}
|
||||
{batchFormData.actionCode === ACTION_CODES.SPECIAL_DEDUCTION && (
|
||||
<div className={styles.pendingActions__modeHint}>
|
||||
<div className={styles.pendingActions__modeHintIcon}>ⓘ</div>
|
||||
<div className={styles.pendingActions__modeHintText}>
|
||||
<strong>特殊扣减参数说明</strong>
|
||||
<p>金额为空或0:全额线下结算模式,自动扣减用户所有已结算收益</p>
|
||||
<p>金额大于0:普通扣减模式,扣减指定金额(需填写原因)</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={styles.pendingActions__formGroup}>
|
||||
<label>操作参数 (JSON格式,可选)</label>
|
||||
<label>
|
||||
操作参数 (JSON格式{batchFormData.actionCode === ACTION_CODES.SPECIAL_DEDUCTION ? '' : ',可选'})
|
||||
</label>
|
||||
<textarea
|
||||
value={batchFormData.actionParams}
|
||||
onChange={(e) => setBatchFormData({ ...batchFormData, actionParams: e.target.value })}
|
||||
placeholder='{"key": "value"}'
|
||||
placeholder={batchFormData.actionCode === ACTION_CODES.SPECIAL_DEDUCTION
|
||||
? '{"amount": 0, "reason": "可选备注"}\n金额为0或留空=全额线下结算'
|
||||
: '{"key": "value"}'}
|
||||
rows={3}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue