@pisell/pisellos 2.3.102 → 2.3.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
- package/dist/modules/Order/index.d.ts +15 -3
- package/dist/modules/Order/index.js +722 -569
- package/dist/modules/Order/types.d.ts +3 -3
- package/dist/modules/Order/types.js +1 -1
- package/dist/solution/BaseSales/index.js +79 -66
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
- package/lib/modules/Order/index.d.ts +15 -3
- package/lib/modules/Order/index.js +135 -40
- package/lib/modules/Order/types.d.ts +3 -3
- package/lib/modules/Order/types.js +1 -1
- package/lib/solution/BaseSales/index.js +17 -11
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -95,8 +95,10 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
95
95
|
promotionEvaluator = null;
|
|
96
96
|
/** 赠品选择 resolver;由 SDK host bridge 注入 */
|
|
97
97
|
giftSelectResolver = null;
|
|
98
|
-
/**
|
|
98
|
+
/** 促销评估递归保护 flag(写路径同步评估促销,禁止重入) */
|
|
99
99
|
isApplyingPromotion = false;
|
|
100
|
+
/** 保持旧事件语义:同步事件监听器内触发的订单写入不得递归评估促销。 */
|
|
101
|
+
isEmittingPromotionApplied = false;
|
|
100
102
|
/** 商品曾应用过客户券卡,客户变更剥离后需强制跑一次 calcDiscount 复位价格 */
|
|
101
103
|
hasActiveCustomerBoundDiscount = false;
|
|
102
104
|
/** 最近一次 applyPromotion 的未满足促销提示 */
|
|
@@ -713,7 +715,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
713
715
|
}
|
|
714
716
|
|
|
715
717
|
/**
|
|
716
|
-
*
|
|
718
|
+
* 只执行购物车促销评估与赠品写回,不发布稳定态事件。
|
|
717
719
|
*
|
|
718
720
|
* 调用时机:写路径(add/update/remove/clear/setCustomer)末尾自动触发;外部一般无需手动调。
|
|
719
721
|
*
|
|
@@ -721,26 +723,27 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
721
723
|
* - 不调用任何公开 CRUD API(如 removeProductFromOrder),全部内部 mutate tempOrder.products,避免事件风暴;
|
|
722
724
|
* - 用 `isApplyingPromotion` 防递归;
|
|
723
725
|
* - 多选项赠品依赖 giftSelectResolver,未注入则跳过且 console.warn;
|
|
724
|
-
* - 不主动调用 applyDiscount / recalculateSummary
|
|
726
|
+
* - 不主动调用 applyDiscount / recalculateSummary,调用方负责跟进;
|
|
727
|
+
* - 返回的 payload 只能在 applyDiscount(商品写路径还需 summary/persist)完成后发布。
|
|
725
728
|
*/
|
|
726
|
-
async
|
|
727
|
-
if (this.isApplyingPromotion) {
|
|
728
|
-
return;
|
|
729
|
+
async evaluatePromotion() {
|
|
730
|
+
if (this.isApplyingPromotion || this.isEmittingPromotionApplied) {
|
|
731
|
+
return null;
|
|
729
732
|
}
|
|
730
733
|
if (!this.promotionEvaluator) {
|
|
731
|
-
return;
|
|
734
|
+
return null;
|
|
732
735
|
}
|
|
733
736
|
const tempOrder = this.store.tempOrder;
|
|
734
737
|
if (!tempOrder) {
|
|
735
|
-
return;
|
|
738
|
+
return null;
|
|
736
739
|
}
|
|
737
740
|
if (this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
738
741
|
tempOrder.products = (0, _virtualSettlement.normalizeVirtualSettlementProducts)(tempOrder.products);
|
|
739
|
-
return;
|
|
742
|
+
return null;
|
|
740
743
|
}
|
|
741
744
|
const strategyConfigs = this.promotionEvaluator.getStrategyConfigs?.();
|
|
742
745
|
if (Array.isArray(strategyConfigs) && strategyConfigs.length === 0) {
|
|
743
|
-
return;
|
|
746
|
+
return null;
|
|
744
747
|
}
|
|
745
748
|
this.isApplyingPromotion = true;
|
|
746
749
|
try {
|
|
@@ -832,14 +835,46 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
832
835
|
})),
|
|
833
836
|
products: tempOrder.products
|
|
834
837
|
};
|
|
835
|
-
|
|
838
|
+
return payload;
|
|
836
839
|
} catch (error) {
|
|
837
840
|
console.error('[OrderModule] applyPromotion failed', error);
|
|
841
|
+
return null;
|
|
838
842
|
} finally {
|
|
839
843
|
this.isApplyingPromotion = false;
|
|
840
844
|
}
|
|
841
845
|
}
|
|
842
846
|
|
|
847
|
+
/** 发布促销稳定态;products 必须读取折扣计算后的当前数组。 */
|
|
848
|
+
emitPromotionApplied(payload) {
|
|
849
|
+
if (!payload) return;
|
|
850
|
+
const products = this.store.tempOrder?.products || payload.products;
|
|
851
|
+
this.isEmittingPromotionApplied = true;
|
|
852
|
+
try {
|
|
853
|
+
void this.effectsEmit('onPromotionApplied', {
|
|
854
|
+
...payload,
|
|
855
|
+
products
|
|
856
|
+
});
|
|
857
|
+
} finally {
|
|
858
|
+
// effectsEmit 同步调用监听器后返回 Promise;保持既有的非阻塞事件行为。
|
|
859
|
+
this.isEmittingPromotionApplied = false;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/** 公开入口:促销、折扣、summary 与持久化完成后发布稳定态事件。 */
|
|
864
|
+
async applyPromotion() {
|
|
865
|
+
const payload = await this.evaluatePromotion();
|
|
866
|
+
if (!payload) return;
|
|
867
|
+
const tempOrder = this.store.tempOrder;
|
|
868
|
+
if (!tempOrder) return;
|
|
869
|
+
this.applyDiscount();
|
|
870
|
+
this.sanitizeTempOrderProducts(tempOrder);
|
|
871
|
+
await this.recalculateSummary({
|
|
872
|
+
createIfMissing: true
|
|
873
|
+
});
|
|
874
|
+
this.persistTempOrder();
|
|
875
|
+
this.emitPromotionApplied(payload);
|
|
876
|
+
}
|
|
877
|
+
|
|
843
878
|
/** 最近一次 applyPromotion 输出的未满足促销列表 */
|
|
844
879
|
getUnfulfilledPromotions() {
|
|
845
880
|
return this.lastUnfulfilledPromotions;
|
|
@@ -3106,9 +3141,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3106
3141
|
if (!options?.skipEditDiscountConfigRefresh && !isVirtualSettlement) {
|
|
3107
3142
|
await this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
3108
3143
|
}
|
|
3109
|
-
|
|
3110
|
-
await this.applyPromotion();
|
|
3111
|
-
}
|
|
3144
|
+
const promotionPayload = !options?.skipDiscountRecalculation && !isVirtualSettlement ? await this.evaluatePromotion() : null;
|
|
3112
3145
|
if (!options?.skipDiscountRecalculation && !isVirtualSettlement) {
|
|
3113
3146
|
this.applyDiscount();
|
|
3114
3147
|
}
|
|
@@ -3117,6 +3150,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3117
3150
|
createIfMissing: true
|
|
3118
3151
|
});
|
|
3119
3152
|
this.persistTempOrder();
|
|
3153
|
+
this.emitPromotionApplied(promotionPayload);
|
|
3120
3154
|
}
|
|
3121
3155
|
|
|
3122
3156
|
/**
|
|
@@ -3263,6 +3297,67 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3263
3297
|
return commitProductLine(shouldMerge);
|
|
3264
3298
|
}
|
|
3265
3299
|
|
|
3300
|
+
/**
|
|
3301
|
+
* booking 数量拆行时,若 Holder 数量与拆行数严格一致,则按下标分配。
|
|
3302
|
+
* 数量不一致时保持旧数据,避免猜测 Holder 与商品份数的对应关系。
|
|
3303
|
+
*/
|
|
3304
|
+
createSplitBookingLine(product, booking, index, splitCount) {
|
|
3305
|
+
const singleLine = (0, _lodashEs.cloneDeep)(product);
|
|
3306
|
+
singleLine.num = 1;
|
|
3307
|
+
delete singleLine.product_quantity;
|
|
3308
|
+
const singleBooking = (0, _lodashEs.cloneDeep)(booking);
|
|
3309
|
+
const bookingHolder = booking?.holder && typeof booking.holder === 'object' ? booking.holder : null;
|
|
3310
|
+
const metadataHolder = booking?.metadata?.holder && typeof booking.metadata.holder === 'object' ? booking.metadata.holder : null;
|
|
3311
|
+
const rawHolderIds = bookingHolder?.form_record ?? booking?.metadata?.holder_id ?? metadataHolder?.form_record ?? product?.metadata?.holder_id;
|
|
3312
|
+
const holderIds = (Array.isArray(rawHolderIds) ? rawHolderIds : [rawHolderIds]).map(holderId => holderId && typeof holderId === 'object' ? holderId.form_record_id : holderId).filter(holderId => holderId !== undefined && holderId !== null && holderId !== '');
|
|
3313
|
+
if (holderIds.length !== splitCount) {
|
|
3314
|
+
return {
|
|
3315
|
+
product: singleLine,
|
|
3316
|
+
booking: singleBooking
|
|
3317
|
+
};
|
|
3318
|
+
}
|
|
3319
|
+
const holderId = holderIds[index];
|
|
3320
|
+
const rawHolderName = bookingHolder?.name ?? metadataHolder?.name;
|
|
3321
|
+
const holderNames = Array.isArray(rawHolderName) ? rawHolderName.map(name => String(name || '').trim()) : typeof rawHolderName === 'string' ? rawHolderName.split(',').map(name => name.trim()) : [];
|
|
3322
|
+
const holderName = holderNames.length === splitCount ? holderNames[index] : undefined;
|
|
3323
|
+
const splitHolder = holder => ({
|
|
3324
|
+
...holder,
|
|
3325
|
+
form_record: [holderId],
|
|
3326
|
+
...(holderName ? {
|
|
3327
|
+
name: holderName
|
|
3328
|
+
} : Object.prototype.hasOwnProperty.call(holder, 'name') ? {
|
|
3329
|
+
name: undefined
|
|
3330
|
+
} : {})
|
|
3331
|
+
});
|
|
3332
|
+
singleLine.metadata = {
|
|
3333
|
+
...(singleLine.metadata || {}),
|
|
3334
|
+
holder_id: [holderId]
|
|
3335
|
+
};
|
|
3336
|
+
if (singleLine._extend && typeof singleLine._extend === 'object') {
|
|
3337
|
+
singleLine._extend = {
|
|
3338
|
+
...singleLine._extend,
|
|
3339
|
+
holder_id: [holderId]
|
|
3340
|
+
};
|
|
3341
|
+
}
|
|
3342
|
+
if (singleBooking.holder && typeof singleBooking.holder === 'object') {
|
|
3343
|
+
singleBooking.holder = splitHolder(singleBooking.holder);
|
|
3344
|
+
}
|
|
3345
|
+
singleBooking.metadata = {
|
|
3346
|
+
...(singleBooking.metadata || {}),
|
|
3347
|
+
holder_id: [holderId],
|
|
3348
|
+
...(singleBooking.metadata?.holder && typeof singleBooking.metadata.holder === 'object' ? {
|
|
3349
|
+
holder: splitHolder(singleBooking.metadata.holder)
|
|
3350
|
+
} : {})
|
|
3351
|
+
};
|
|
3352
|
+
if (Object.prototype.hasOwnProperty.call(singleBooking, 'holder_id')) {
|
|
3353
|
+
singleBooking.holder_id = [holderId];
|
|
3354
|
+
}
|
|
3355
|
+
return {
|
|
3356
|
+
product: singleLine,
|
|
3357
|
+
booking: singleBooking
|
|
3358
|
+
};
|
|
3359
|
+
}
|
|
3360
|
+
|
|
3266
3361
|
/**
|
|
3267
3362
|
* 添加商品行。带 booking 时强制独立行;num>1 时拆成多条 num=1 的 product+booking(对齐 BookingByStep / ticketBooking addService)。
|
|
3268
3363
|
*
|
|
@@ -3321,29 +3416,26 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3321
3416
|
const splitCount = (0, _utils3.getSafeProductNum)(productRecord.num ?? productRecord.product_quantity ?? 1);
|
|
3322
3417
|
if (splitCount > 1) {
|
|
3323
3418
|
for (let i = 0; i < splitCount; i += 1) {
|
|
3324
|
-
const
|
|
3325
|
-
const singleBooking = (0, _lodashEs.cloneDeep)(booking);
|
|
3326
|
-
singleLine.num = 1;
|
|
3327
|
-
delete singleLine.product_quantity;
|
|
3419
|
+
const splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
3328
3420
|
if (i > 0) {
|
|
3329
|
-
delete
|
|
3330
|
-
delete
|
|
3331
|
-
if (
|
|
3332
|
-
|
|
3333
|
-
...
|
|
3421
|
+
delete splitLine.product.unique_identification_number;
|
|
3422
|
+
delete splitLine.product.identity_key;
|
|
3423
|
+
if (splitLine.product.metadata) {
|
|
3424
|
+
splitLine.product.metadata = {
|
|
3425
|
+
...splitLine.product.metadata
|
|
3334
3426
|
};
|
|
3335
|
-
delete
|
|
3336
|
-
delete
|
|
3427
|
+
delete splitLine.product.metadata.unique_identification_number;
|
|
3428
|
+
delete splitLine.product.metadata.identity_key;
|
|
3337
3429
|
}
|
|
3338
|
-
delete
|
|
3339
|
-
if (
|
|
3340
|
-
|
|
3341
|
-
...
|
|
3430
|
+
delete splitLine.booking.booking_uid;
|
|
3431
|
+
if (splitLine.booking.metadata) {
|
|
3432
|
+
splitLine.booking.metadata = {
|
|
3433
|
+
...splitLine.booking.metadata
|
|
3342
3434
|
};
|
|
3343
|
-
delete
|
|
3435
|
+
delete splitLine.booking.metadata.unique_identification_number;
|
|
3344
3436
|
}
|
|
3345
3437
|
}
|
|
3346
|
-
const committedProduct = await this.appendProductLineToTempOrder(tempOrder,
|
|
3438
|
+
const committedProduct = await this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
3347
3439
|
insertAtIndex,
|
|
3348
3440
|
disableMerge: options?.disableMerge
|
|
3349
3441
|
});
|
|
@@ -3399,10 +3491,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3399
3491
|
const splitCount = (0, _utils3.getSafeProductNum)(productRecord.num ?? productRecord.product_quantity ?? 1);
|
|
3400
3492
|
if (splitCount > 1) {
|
|
3401
3493
|
for (let i = 0; i < splitCount; i += 1) {
|
|
3402
|
-
const
|
|
3403
|
-
|
|
3404
|
-
delete singleLine.product_quantity;
|
|
3405
|
-
const appendResult = this.appendProductLineToTempOrder(tempOrder, singleLine, (0, _lodashEs.cloneDeep)(booking));
|
|
3494
|
+
const splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
3495
|
+
const appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking);
|
|
3406
3496
|
if (appendResult) await appendResult;
|
|
3407
3497
|
}
|
|
3408
3498
|
continue;
|
|
@@ -3658,7 +3748,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3658
3748
|
async updateOrderProduct(params) {
|
|
3659
3749
|
const tempOrder = this.ensureTempOrder();
|
|
3660
3750
|
const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
3661
|
-
await this.
|
|
3751
|
+
const promotionPayload = await this.evaluatePromotion();
|
|
3662
3752
|
this.applyDiscount({
|
|
3663
3753
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
3664
3754
|
});
|
|
@@ -3667,6 +3757,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3667
3757
|
createIfMissing: true
|
|
3668
3758
|
});
|
|
3669
3759
|
this.persistTempOrder();
|
|
3760
|
+
this.emitPromotionApplied(promotionPayload);
|
|
3670
3761
|
this.logInfo('updateOrderProduct success', {
|
|
3671
3762
|
params
|
|
3672
3763
|
});
|
|
@@ -3760,8 +3851,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3760
3851
|
}
|
|
3761
3852
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
3762
3853
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
3763
|
-
|
|
3764
|
-
|
|
3854
|
+
const isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
3855
|
+
const promotionPayload = !isVirtualSettlement ? await this.evaluatePromotion() : null;
|
|
3856
|
+
if (!isVirtualSettlement) {
|
|
3765
3857
|
this.applyDiscount();
|
|
3766
3858
|
}
|
|
3767
3859
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
@@ -3769,6 +3861,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3769
3861
|
createIfMissing: true
|
|
3770
3862
|
});
|
|
3771
3863
|
this.persistTempOrder();
|
|
3864
|
+
this.emitPromotionApplied(promotionPayload);
|
|
3772
3865
|
this.logInfo('updateOrderProductQuantity success', {
|
|
3773
3866
|
params
|
|
3774
3867
|
});
|
|
@@ -3813,7 +3906,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3813
3906
|
*/
|
|
3814
3907
|
async finalizeAfterProductsMutation(tempOrder, options) {
|
|
3815
3908
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3816
|
-
await this.
|
|
3909
|
+
const promotionPayload = await this.evaluatePromotion();
|
|
3817
3910
|
this.applyDiscount({
|
|
3818
3911
|
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids
|
|
3819
3912
|
});
|
|
@@ -3822,6 +3915,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3822
3915
|
createIfMissing: true
|
|
3823
3916
|
});
|
|
3824
3917
|
this.persistTempOrder();
|
|
3918
|
+
this.emitPromotionApplied(promotionPayload);
|
|
3825
3919
|
}
|
|
3826
3920
|
|
|
3827
3921
|
/**
|
|
@@ -3926,13 +4020,14 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3926
4020
|
productsByUid: {}
|
|
3927
4021
|
};
|
|
3928
4022
|
}
|
|
3929
|
-
await this.
|
|
4023
|
+
const promotionPayload = await this.evaluatePromotion();
|
|
3930
4024
|
this.applyDiscount();
|
|
3931
4025
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3932
4026
|
await this.recalculateSummary({
|
|
3933
4027
|
createIfMissing: true
|
|
3934
4028
|
});
|
|
3935
4029
|
this.persistTempOrder();
|
|
4030
|
+
this.emitPromotionApplied(promotionPayload);
|
|
3936
4031
|
this.logInfo('clearOrderCartLines success', {});
|
|
3937
4032
|
return tempOrder;
|
|
3938
4033
|
}
|
|
@@ -117,7 +117,7 @@ export interface OrderLastGiftActions {
|
|
|
117
117
|
}>;
|
|
118
118
|
toRemove: string[];
|
|
119
119
|
}
|
|
120
|
-
/** onPromotionApplied
|
|
120
|
+
/** onPromotionApplied 稳定态事件 payload(促销、折扣与 summary 均已完成)。 */
|
|
121
121
|
export interface OrderPromotionAppliedPayload {
|
|
122
122
|
unfulfilledPromotions: OrderUnfulfilledPromotion[];
|
|
123
123
|
giftActions: OrderLastGiftActions;
|
|
@@ -131,7 +131,7 @@ export interface OrderPromotionAppliedPayload {
|
|
|
131
131
|
product_variant_id: number;
|
|
132
132
|
}>;
|
|
133
133
|
}>;
|
|
134
|
-
/**
|
|
134
|
+
/** 折扣重算后的最终商品列表 */
|
|
135
135
|
products: OrderProduct[];
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
@@ -979,7 +979,7 @@ export interface OrderModuleAPI {
|
|
|
979
979
|
*/
|
|
980
980
|
appendPromotionTags: <T extends Record<string, any>>(products: T[]) => T[];
|
|
981
981
|
/**
|
|
982
|
-
* 应用购物车促销(评估 → 差异化赠品 →
|
|
982
|
+
* 应用购物车促销(评估 → 差异化赠品 → 折扣/summary 重算 → emit onPromotionApplied)。
|
|
983
983
|
*
|
|
984
984
|
* 自动在 addProductToOrder / updateOrderProductQuantity / removeProductFromOrder /
|
|
985
985
|
* clearOrderCartLines / setOrderCustomer 等写路径末尾触发,业务一般无需手动调用。
|
|
@@ -40,7 +40,7 @@ let OrderHooks = exports.OrderHooks = /*#__PURE__*/function (OrderHooks) {
|
|
|
40
40
|
*/
|
|
41
41
|
/** 未满足的促销策略(购物车底部 alert 渲染源) */
|
|
42
42
|
/** 上一次 applyPromotion 计算出的赠品操作(仅供调试/读取使用) */
|
|
43
|
-
/** onPromotionApplied
|
|
43
|
+
/** onPromotionApplied 稳定态事件 payload(促销、折扣与 summary 均已完成)。 */
|
|
44
44
|
/**
|
|
45
45
|
* tempOrder 上的下单客户协议字段视图。
|
|
46
46
|
* 这些字段会随订单提交到后端。
|
|
@@ -1823,7 +1823,12 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
1823
1823
|
const hasManualDiscountSelection = this.hasManualDiscountSelection || currentDiscountList.some(discount => discount.isManualSelect);
|
|
1824
1824
|
const discountAction = params?.action || (orderId ? 'edit' : 'create');
|
|
1825
1825
|
const discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
|
|
1826
|
-
|
|
1826
|
+
|
|
1827
|
+
// Walk-In 不请求 prepare config;当前搜索/扫码券必须继续参与本次重算。
|
|
1828
|
+
// current 优先于 original,保留搜索后的最新选择与可用状态。
|
|
1829
|
+
const searchedDiscountList = currentDiscountList.filter(discount => discount.isScan);
|
|
1830
|
+
const searchedDiscountIds = new Set(searchedDiscountList.map(discount => String(discount.id)));
|
|
1831
|
+
let preparedDiscountList = [...searchedDiscountList, ...originalDiscountList.filter(discount => !searchedDiscountIds.has(String(discount.id)))];
|
|
1827
1832
|
if (customerId && customerId !== 1) {
|
|
1828
1833
|
if (!params?.force && this.discountConfigCacheKey === discountConfigCacheKey) {
|
|
1829
1834
|
preparedDiscountList = originalDiscountList;
|
|
@@ -2783,7 +2788,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2783
2788
|
if (this.store.payment) {
|
|
2784
2789
|
const committed = this.getCommittedWalletAssets();
|
|
2785
2790
|
const state = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
2786
|
-
void this.publishWalletAssetsState(state);
|
|
2791
|
+
void this.publishWalletAssetsState(state, 'local');
|
|
2787
2792
|
}
|
|
2788
2793
|
return payments;
|
|
2789
2794
|
}
|
|
@@ -2929,9 +2934,10 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2929
2934
|
})
|
|
2930
2935
|
};
|
|
2931
2936
|
}
|
|
2932
|
-
async publishWalletAssetsState(state) {
|
|
2937
|
+
async publishWalletAssetsState(state, changeSource = 'derived') {
|
|
2933
2938
|
await this.effectsEmit(_types.BaseSalesHookNames.onWalletAssetsStateChanged, {
|
|
2934
|
-
state
|
|
2939
|
+
state,
|
|
2940
|
+
changeSource
|
|
2935
2941
|
});
|
|
2936
2942
|
return state;
|
|
2937
2943
|
}
|
|
@@ -3064,7 +3070,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3064
3070
|
source: params.source
|
|
3065
3071
|
});
|
|
3066
3072
|
await this.syncSelectedWalletAssets(state);
|
|
3067
|
-
return this.publishWalletAssetsState(state);
|
|
3073
|
+
return this.publishWalletAssetsState(state, 'local');
|
|
3068
3074
|
}
|
|
3069
3075
|
|
|
3070
3076
|
/** 更新已选钱包资产的手动使用金额,并同步 pending payment。 */
|
|
@@ -3072,7 +3078,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3072
3078
|
if (!this.store.payment) throw new Error('payment 模块未初始化');
|
|
3073
3079
|
const state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
|
|
3074
3080
|
await this.syncSelectedWalletAssets(state);
|
|
3075
|
-
return this.publishWalletAssetsState(state);
|
|
3081
|
+
return this.publishWalletAssetsState(state, 'local');
|
|
3076
3082
|
}
|
|
3077
3083
|
|
|
3078
3084
|
/** 扫码精确查券;仅可用资产会被自动选中。 */
|
|
@@ -3087,7 +3093,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3087
3093
|
const result = await wallet.scanWalletAssetAsync(code);
|
|
3088
3094
|
if (result.type === 'normalCode') {
|
|
3089
3095
|
await this.syncSelectedWalletAssets(result.state);
|
|
3090
|
-
await this.publishWalletAssetsState(result.state);
|
|
3096
|
+
await this.publishWalletAssetsState(result.state, 'local');
|
|
3091
3097
|
}
|
|
3092
3098
|
return result;
|
|
3093
3099
|
}
|
|
@@ -3097,7 +3103,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3097
3103
|
if (!this.store.payment) throw new Error('payment 模块未初始化');
|
|
3098
3104
|
const state = this.store.payment.wallet.clearWalletAssetSelection();
|
|
3099
3105
|
await this.syncSelectedWalletAssets(state);
|
|
3100
|
-
return this.publishWalletAssetsState(state);
|
|
3106
|
+
return this.publishWalletAssetsState(state, 'local');
|
|
3101
3107
|
}
|
|
3102
3108
|
|
|
3103
3109
|
/**
|
|
@@ -3227,7 +3233,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3227
3233
|
try {
|
|
3228
3234
|
const committed = this.getCommittedWalletAssets();
|
|
3229
3235
|
const walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
3230
|
-
await this.publishWalletAssetsState(walletState);
|
|
3236
|
+
await this.publishWalletAssetsState(walletState, 'local');
|
|
3231
3237
|
} catch (error) {
|
|
3232
3238
|
this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
|
|
3233
3239
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -3311,7 +3317,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3311
3317
|
if (this.store.payment) {
|
|
3312
3318
|
const committed = this.getCommittedWalletAssets();
|
|
3313
3319
|
const walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
3314
|
-
await this.publishWalletAssetsState(walletState);
|
|
3320
|
+
await this.publishWalletAssetsState(walletState, 'local');
|
|
3315
3321
|
}
|
|
3316
3322
|
return {
|
|
3317
3323
|
payment: payment || {},
|
|
@@ -3417,7 +3423,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3417
3423
|
if (this.store.payment) {
|
|
3418
3424
|
const committed = this.getCommittedWalletAssets();
|
|
3419
3425
|
const walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
3420
|
-
await this.publishWalletAssetsState(walletState);
|
|
3426
|
+
await this.publishWalletAssetsState(walletState, 'local');
|
|
3421
3427
|
}
|
|
3422
3428
|
return {
|
|
3423
3429
|
payment: payment || {},
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 |
|
|
329
|
+
weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -345,7 +345,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
345
345
|
count: number;
|
|
346
346
|
left: number;
|
|
347
347
|
summaryCount: number;
|
|
348
|
-
status: "
|
|
348
|
+
status: "sold_out" | "lots_of_space" | "filling_up_fast";
|
|
349
349
|
}[];
|
|
350
350
|
/**
|
|
351
351
|
* 找到多个资源的公共可用时间段
|