新增老板专属私域运营概况与订单新老客户统计
This commit is contained in:
1 parent
000a80af3c
commit
d18089aaf6
21 files changed
+248
-79
No files matched your search
@@ -162,7 +162,7 @@ function replaceJournal(l,row,after){
|
||||
if(after){const order=l.detail(id);l.journal(id,after.date,'回收专用更正补记',after.receivable,order.goodsCost??order.knownGoodsCost,order.directCost);}
|
||||
l.touch(id);
|
||||
}
|
||||
function financialInput(value){const {customer,salesperson,note,...rest}=value;return rest;}
|
||||
function financialInput(value){const {customer,customer_type,salesperson,note,...rest}=value;return rest;}
|
||||
function inventoryOnlyInput(value){const {old_pocket,old_stock_count,...rest}=financialInput(value);if(rest.exchange?.items)rest.exchange={...rest.exchange,items:rest.exchange.items.map(({old_pocket,old_stock_count,...item})=>item)};return rest;}
|
||||
function metadataChangeOnly(row,after){return !!after&&hash(financialInput(Recoveries.inputFor(JSON.parse(row.data))))===hash(financialInput(Recoveries.inputFor(after)));}
|
||||
function legacyCountInfo(l,row){
|
||||
@@ -176,7 +176,7 @@ function execute(l,row,after,actor,reason,env,input={}){return Rolling.withHisto
|
||||
verifyLegacyCount(l,row,after,input,env);
|
||||
require('./customer-materials').apply(l,row.id,after,actor,env);
|
||||
const deltas=metadataOnly?[]:movements(l,row,after);validateInventory(l,deltas,env);
|
||||
const changed=l.run('UPDATE recoveries SET date=?,customer=?,salesperson=?,note=?,old_lines=?,data=?,status=?,cancelled_at=?,updated=?,revision=revision+1 WHERE id=? AND revision=?',after?.date??row.date,after?.customer??row.customer,after?.salesperson??row.salesperson,after?.note??row.note,JSON.stringify(after?.old_lines??old.old_lines),JSON.stringify(metadataOnly?{...old,customer:after.customer,salesperson:after.salesperson,note:after.note}:after??old),after?'active':'cancelled',after?'':env.now(),env.now(),row.id,row.revision);
|
||||
const changed=l.run('UPDATE recoveries SET date=?,customer=?,salesperson=?,note=?,old_lines=?,data=?,status=?,cancelled_at=?,updated=?,revision=revision+1 WHERE id=? AND revision=?',after?.date??row.date,after?.customer??row.customer,after?.salesperson??row.salesperson,after?.note??row.note,JSON.stringify(after?.old_lines??old.old_lines),JSON.stringify(metadataOnly?{...old,customer:after.customer,customer_type:after.customer_type,salesperson:after.salesperson,note:after.note}:after??old),after?'active':'cancelled',after?'':env.now(),env.now(),row.id,row.revision);
|
||||
if(changed.changes!==1)env.fail('回收记录已有其他更正,请刷新',409);
|
||||
if(metadataOnly){if(row.order_id){l.run('UPDATE orders SET customer=?,salesperson=?,note=?,reviewed_revision=0 WHERE id=?',after.customer,after.salesperson,after.note,row.order_id);l.touch(row.order_id);}}
|
||||
else{
|
||||
@@ -192,6 +192,7 @@ function execute(l,row,after,actor,reason,env,input={}){return Rolling.withHisto
|
||||
if(!inventoryOnly){replaceJournal(l,row,after);const hook=materialHook();hook?.recoveryUpdated?.(l,row.id,actor,env);}
|
||||
else if(row.order_id&&(old.customer!==after.customer||old.salesperson!==after.salesperson||old.note!==after.note)){l.run('UPDATE orders SET customer=?,salesperson=?,note=?,reviewed_revision=0 WHERE id=?',after.customer,after.salesperson,after.note,row.order_id);l.touch(row.order_id);}
|
||||
}
|
||||
if(after&&row.order_id)l.run('UPDATE orders SET customer_type=? WHERE id=?',after.customer_type??'unknown',row.order_id);
|
||||
if(metadataOnly)l.run('UPDATE closes SET stale=1 WHERE date IN (?,?)',row.date,after.date);
|
||||
else l.dirtyInventory([row.date,after?.date,...before.movements.map(r=>r.date)].filter(Boolean).sort()[0]);
|
||||
l.syncTeamFunds(actor);
|
||||
|
||||
Reference in new issue
Block a user