新增老板专属私域运营概况与订单新老客户统计

This commit is contained in:
summer committed 2026-12-04 02:03:31 +08:00
1 parent 000a80af3c
commit d18089aaf6
21 files changed
+248 -79

No files matched your search

+3 -1
View File
@@ -58,7 +58,7 @@ function inputFor(order){
const converted=OrderCopy.inputs(order);
const allowed=['name','code','unit','quantity','pocket','stockCount','payer','costPayers','costFundings','cost','costParts','costMaterial','costLabor','sale','baseSale','charges','pricingMode','goldPrice','laborRate','laborMode','pieces','priceNote'];
const accounts=new Set(order.payments.filter(row=>row.amount>0&&row.kind==='receipt'&&!order.corrections.some(correction=>correction.type==='payment'&&correction.target===row.id)).map(row=>row.account));
return {id:order.id,date:order.date,customer:order.customer,salesperson:order.salesperson,note:order.note,internal_note:order.internal_note??'',
return {id:order.id,date:order.date,customer:order.customer,customer_type:order.customer_type??'unknown',salesperson:order.salesperson,note:order.note,internal_note:order.internal_note??'',
discount:converted.discount,rounding_mode:order.rounding_mode,fee_cost_mode:order.fee_cost_mode||'legacy',fees_date:order.fees_date||order.date,
payment_account:accounts.size===1?[...accounts][0]:order.payment_account,
lines:converted.lines.map((line,index)=>({...Object.fromEntries(allowed.filter(key=>Object.hasOwn(line,key)).map(key=>[key,line[key]])),...(order.lines[index]?.returnedStockId?{returnedStockId:order.lines[index].returnedStockId}:{}),...(Number.isSafeInteger(order.lines[index]?.stockCount)?{stockCount:order.lines[index].stockCount}:{})})),fee_items:feeInputs(order)};
@@ -328,6 +328,8 @@ function edit(ledger,id,input,actor,env){return atomic(ledger,()=>{
const customer=env.orderIdentity(Object.hasOwn(input,'customer')?input.customer:order.customer,'客户称呼/代号',60),salesperson=env.orderIdentity(Object.hasOwn(input,'salesperson')?input.salesperson:order.salesperson,'开单人',30);
const note=order.price_lock_id?PriceLocks.customerNote(ledger.priceLockDetail(order.price_lock_id),input.note??info.inputs.note,env):env.text(input.note??order.note,'客户单备注',240,true);
const internalNote=env.text(input.internal_note===undefined?order.internal_note:input.internal_note,'内部备注',500,true);
const customerType=require('./private-operations').customerType(input.customer_type===undefined?order.customer_type:input.customer_type);
if(customerType!==order.customer_type){ledger.run('UPDATE orders SET customer_type=? WHERE id=?',customerType,id);ledger.audit(id,'更正客户类型',actor,{before:order.customer_type??'unknown',after:customerType,reason});}
const metadata={customer,salesperson,note,internalNote,reason};
if(info.financialEditable&&order.price_lock_id)return editDeliveredLock(ledger,info,input,metadata,actor,env);
if(!info.financialEditable){