整合公共店铺配置与动态员工管理,保留最新订单功能及历史账兼容

This commit is contained in:
summer committed 2026-12-04 00:53:53 +08:00
commit b87f774386
84 files changed
+1622 -715

No files matched your search

+3 -3
View File
@@ -30,11 +30,11 @@ function quote(l,input,actor,env,options,R){
const total=subtotal===q.discount?{total:0,rounding_adjustment:0}:Calc.orderTotal([subtotal],q.discount,q.rounding_mode);q.receivable=total.total;q.rounding_adjustment=total.rounding_adjustment;
const fee_items=l.validateFees((input.exchange.fee_items??[]).map(f=>({...f,status:'estimated'})));if(fee_items.some(f=>f.amount===null))env.fail('请补齐实际费用');
q.exchange={...first.exchange,fee_items};q.netSettlement=q.receivable-q.purchaseAmount;q.cashReceipt=Math.max(0,q.netSettlement);q.cashPayment=Math.max(0,-q.netSettlement);q.offsetAmount=Math.min(q.receivable,q.purchaseAmount);
q.payment_account=env.paymentAccount(q.payment_account);if(q.cashPayment&&q.payment_account.endsWith('信用卡'))env.fail('回收付款不支持信用卡');
if(options.creating&&q.cashPayment&&require('./team-funds').accountMember(q.payment_account)!==q.payer)env.fail('实际付款账户须与回收付款人一致');
q.payment_account=env.paymentAccount(q.payment_account,{original:options.existingRecovery?.payment_account});if(q.cashPayment&&q.payment_account.endsWith('信用卡'))env.fail('回收付款不支持信用卡');
if(options.creating&&q.cashPayment&&require('./team-funds').accountMember(q.payment_account,l)!==q.payer)env.fail('实际付款账户须与回收付款人一致');
q.cardFee=q.cashReceipt&&q.payment_account.endsWith('信用卡')?env.cardFee(q.cashReceipt,q.credit_card_rate_permille):0;q.directCost=sum(fee_items,'amount')+q.cardFee;q.profit=q.goodsCost===null?null:q.receivable-q.goodsCost-q.directCost;
q.actualBuyRate=q.purchaseMg?Number((BigInt(q.purchaseAmount)*1000n+BigInt(q.purchaseMg)/2n)/BigInt(q.purchaseMg)):null;
q.paymentMethods=q.cashReceipt||q.cashPayment?[q.payment_account.replace(/^(助理2|助理1|助理|麦麦)/,'')]:[];
q.paymentMethods=q.cashReceipt||q.cashPayment?[require('./team-funds').accountChannel(q.payment_account)]:[];
for(const key of ['oldMg','newMg','differenceMg','purchaseAmount','receivable','directCost','goodsCost','netSettlement'])if(q[key]!==null&&(!Number.isSafeInteger(q[key])||Math.abs(q[key])>100000000000))env.fail('置换汇总超出范围');
require('./customer-materials').validate(l,q,env,{orderId:options.orderId});
return q;