@pisell/pisellos 2.3.34 → 2.3.35
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/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +84 -34
- package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +10 -2
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +75 -11
- package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +5 -3
- package/package.json +1 -1
|
@@ -48,7 +48,7 @@ export interface BookingResourceInput {
|
|
|
48
48
|
capacity?: number;
|
|
49
49
|
like_status?: string;
|
|
50
50
|
metadata?: Record<string, any>;
|
|
51
|
-
children?:
|
|
51
|
+
children?: BookingResourceInput[];
|
|
52
52
|
}
|
|
53
53
|
/** custom / package 人数维度快照,与 info2 `_extend.capacity` / `metadata.capacity` 对齐。 */
|
|
54
54
|
export interface BookingCapacityMetadataItem {
|
|
@@ -76,6 +76,33 @@ function resolveDurationMinutes(value) {
|
|
|
76
76
|
return Number.isNaN(n) ? undefined : n;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* 将组合资源子项收敛为 checkout resources 协议。
|
|
81
|
+
*
|
|
82
|
+
* resourcesOriginMap 中的子资源是 UI 运行态结构,通常只有 id / main_field / form_id,
|
|
83
|
+
* 不保证携带后端必填的 relation_type。这里不能原样透传,否则会触发
|
|
84
|
+
* `bookings.*.resources.*.children.*.relation_type` 校验错误。
|
|
85
|
+
*/
|
|
86
|
+
function normalizeChildResource(child, parentFormId) {
|
|
87
|
+
var _child$form_id, _child$relation_id;
|
|
88
|
+
var item = {
|
|
89
|
+
form_id: (_child$form_id = child === null || child === void 0 ? void 0 : child.form_id) !== null && _child$form_id !== void 0 ? _child$form_id : parentFormId,
|
|
90
|
+
relation_type: (child === null || child === void 0 ? void 0 : child.relation_type) || 'form',
|
|
91
|
+
relation_id: (_child$relation_id = child === null || child === void 0 ? void 0 : child.relation_id) !== null && _child$relation_id !== void 0 ? _child$relation_id : child === null || child === void 0 ? void 0 : child.id,
|
|
92
|
+
capacity: child === null || child === void 0 ? void 0 : child.capacity,
|
|
93
|
+
like_status: (child === null || child === void 0 ? void 0 : child.like_status) || 'common'
|
|
94
|
+
};
|
|
95
|
+
if ((child === null || child === void 0 ? void 0 : child.metadata) !== undefined) {
|
|
96
|
+
item.metadata = _objectSpread({}, child.metadata);
|
|
97
|
+
}
|
|
98
|
+
if (Array.isArray(child === null || child === void 0 ? void 0 : child.children)) {
|
|
99
|
+
item.children = child.children.map(function (nestedChild) {
|
|
100
|
+
return normalizeChildResource(nestedChild, item.form_id);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return item;
|
|
104
|
+
}
|
|
105
|
+
|
|
79
106
|
/**
|
|
80
107
|
* cacheItem._extend.resource 形如 `{ [form_id]: [{ relation_id, form_id, like_status, metadata, children }] }`。
|
|
81
108
|
* 这里扁平化为符合协议的 resources[] 数组;id=0 的「无资源」占位行**保留**(与 info2 业务等价;协议 `relation_id=0` 合法)。
|
|
@@ -101,7 +128,11 @@ function flattenResources(cacheItem) {
|
|
|
101
128
|
// 协议允许 metadata 自由透传;为了与 info2 行为等价,把 form_name / resource_name / combined_resource 一并保留。
|
|
102
129
|
item.metadata = _objectSpread({}, r.metadata);
|
|
103
130
|
}
|
|
104
|
-
if ((r === null || r === void 0 ? void 0 : r.children)
|
|
131
|
+
if (Array.isArray(r === null || r === void 0 ? void 0 : r.children)) {
|
|
132
|
+
item.children = r.children.map(function (child) {
|
|
133
|
+
return normalizeChildResource(child, item.form_id);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
105
136
|
result.push(item);
|
|
106
137
|
});
|
|
107
138
|
});
|
|
@@ -485,7 +485,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
485
485
|
generateIdempotencyToken(): string;
|
|
486
486
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
487
487
|
createOrder(params: CommitOrderParams['query']): {
|
|
488
|
-
type: "
|
|
488
|
+
type: "virtual" | "appointment_booking";
|
|
489
489
|
platform: string;
|
|
490
490
|
sales_channel: string;
|
|
491
491
|
order_sales_channel: string;
|
|
@@ -3852,9 +3852,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3852
3852
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3853
3853
|
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
|
|
3854
3854
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3855
|
+
var _item$metadata3;
|
|
3855
3856
|
if (_this26.hasGoodPassDiscount(item)) return false;
|
|
3856
3857
|
if (_this26.hasOrderProductLineNote(item)) return false;
|
|
3857
3858
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3859
|
+
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
3858
3860
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
3859
3861
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
3860
3862
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -4177,7 +4179,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4177
4179
|
}, {
|
|
4178
4180
|
key: "applyOrderProductUpdateToTempOrder",
|
|
4179
4181
|
value: function applyOrderProductUpdateToTempOrder(tempOrder, params) {
|
|
4180
|
-
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _nextProduct$metadata, _targetProduct$
|
|
4182
|
+
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _metadata8, _metadata9, _metadata10, _nextProduct$metadata, _targetProduct$metada15, _tempOrder$products$p, _tempOrder$products$p2;
|
|
4181
4183
|
var product_id = params.product_id,
|
|
4182
4184
|
product_variant_id = params.product_variant_id,
|
|
4183
4185
|
updates = params.updates,
|
|
@@ -4205,8 +4207,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4205
4207
|
if (unique_identification_number !== undefined) {
|
|
4206
4208
|
var targetUid = String(unique_identification_number);
|
|
4207
4209
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
4208
|
-
var _item$
|
|
4209
|
-
return String(((_item$
|
|
4210
|
+
var _item$metadata4;
|
|
4211
|
+
return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
4210
4212
|
});
|
|
4211
4213
|
}
|
|
4212
4214
|
if (productIndex === -1) {
|
|
@@ -4237,9 +4239,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4237
4239
|
// 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
|
|
4238
4240
|
var callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
|
|
4239
4241
|
var callerUpdatesMainMeta = (updates === null || updates === void 0 || (_metadata2 = updates.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.main_product_selling_price) !== undefined || (updates === null || updates === void 0 || (_metadata3 = updates.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.main_product_original_price) !== undefined || (updates === null || updates === void 0 || (_metadata4 = updates.metadata) === null || _metadata4 === void 0 ? void 0 : _metadata4.source_product_price) !== undefined;
|
|
4242
|
+
var callerUpdatesSourcePrice = (updates === null || updates === void 0 || (_metadata5 = updates.metadata) === null || _metadata5 === void 0 ? void 0 : _metadata5.source_product_price) !== undefined;
|
|
4243
|
+
var callerUpdatesMainSellingPrice = (updates === null || updates === void 0 || (_metadata6 = updates.metadata) === null || _metadata6 === void 0 ? void 0 : _metadata6.main_product_selling_price) !== undefined;
|
|
4244
|
+
var callerUpdatesMainOriginalPrice = (updates === null || updates === void 0 || (_metadata7 = updates.metadata) === null || _metadata7 === void 0 ? void 0 : _metadata7.main_product_original_price) !== undefined;
|
|
4245
|
+
var previousLineFingerprint = buildProductLineFingerprint(getProductSkuOptions(targetProduct), targetProduct.product_bundle);
|
|
4246
|
+
var nextLineFingerprint = buildProductLineFingerprint(getProductSkuOptions(nextProduct), nextProduct.product_bundle);
|
|
4247
|
+
var callerChangesVariant = Number(product_variant_id || 0) !== Number(targetProduct.product_variant_id || 0);
|
|
4248
|
+
var callerChangesLineConfiguration = callerChangesVariant || previousLineFingerprint !== nextLineFingerprint;
|
|
4240
4249
|
var isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
4241
4250
|
var callerChangesDiscountList = Array.isArray(updates === null || updates === void 0 ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
|
|
4242
|
-
var callerUpdatesManualPrice = (updates === null || updates === void 0 || (
|
|
4251
|
+
var callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata8 = updates.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata9 = updates.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata10 = updates.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_discount_reason) !== undefined || callerChangesDiscountList;
|
|
4243
4252
|
var callerAllowsBookingReprice = function () {
|
|
4244
4253
|
if (params.allow_booking_reprice !== true || !booking || !callerUpdatesTopPrice || !callerUpdatesMainMeta) {
|
|
4245
4254
|
return false;
|
|
@@ -4252,7 +4261,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4252
4261
|
};
|
|
4253
4262
|
return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
|
|
4254
4263
|
}();
|
|
4255
|
-
if (isPersistedOrderLine && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
4264
|
+
if (isPersistedOrderLine && !callerChangesLineConfiguration && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
4256
4265
|
var _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7;
|
|
4257
4266
|
nextProduct.selling_price = targetProduct.selling_price;
|
|
4258
4267
|
nextProduct.original_price = targetProduct.original_price;
|
|
@@ -4264,19 +4273,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4264
4273
|
price_schema_version: (_targetProduct$metada6 = (_targetProduct$metada7 = targetProduct.metadata) === null || _targetProduct$metada7 === void 0 ? void 0 : _targetProduct$metada7.price_schema_version) !== null && _targetProduct$metada6 !== void 0 ? _targetProduct$metada6 : 2
|
|
4265
4274
|
});
|
|
4266
4275
|
nextProduct.product_bundle = this.preservePersistedBundlePriceFields(targetProduct.product_bundle, nextProduct.product_bundle);
|
|
4267
|
-
} else if (
|
|
4276
|
+
} else if (callerChangesLineConfiguration && callerUpdatesSourcePrice && (!callerUpdatesMainSellingPrice || !callerUpdatesMainOriginalPrice)) {
|
|
4277
|
+
var _targetProduct$metada8, _targetProduct$metada9;
|
|
4278
|
+
// 新配置只传了 source 时,不能把未传的 main_product_* 从旧行继承下来。
|
|
4279
|
+
// 以新 source + 新 option 重建券前价;券后价未显式提供时保留旧主商品折扣额。
|
|
4280
|
+
var previousMainOriginal = new Decimal(Number((_targetProduct$metada8 = targetProduct.metadata) === null || _targetProduct$metada8 === void 0 ? void 0 : _targetProduct$metada8.main_product_original_price) || 0);
|
|
4281
|
+
var previousMainSelling = new Decimal(Number((_targetProduct$metada9 = targetProduct.metadata) === null || _targetProduct$metada9 === void 0 ? void 0 : _targetProduct$metada9.main_product_selling_price) || previousMainOriginal.toNumber());
|
|
4282
|
+
var preservedDiscount = previousMainOriginal.minus(previousMainSelling);
|
|
4283
|
+
var nextMainOriginal = new Decimal(Number(updates.metadata.source_product_price) || 0).plus(sumOptionUnitPrice(getProductSkuOptions(nextProduct)));
|
|
4284
|
+
nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
|
|
4285
|
+
source_product_price: String(updates.metadata.source_product_price),
|
|
4286
|
+
main_product_original_price: callerUpdatesMainOriginalPrice ? String(updates.metadata.main_product_original_price) : nextMainOriginal.toDecimalPlaces(2).toFixed(2),
|
|
4287
|
+
main_product_selling_price: callerUpdatesMainSellingPrice ? String(updates.metadata.main_product_selling_price) : nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
4288
|
+
price_schema_version: 2
|
|
4289
|
+
});
|
|
4290
|
+
} else if (callerChangesVariant && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4291
|
+
// variant 已变化但 caller 没有显式报价时,旧 v2 metadata 不能继续充当权威价格源。
|
|
4292
|
+
// 清理后由 normalize 优先读取 metadata.origin.variant 中新 variant 的目录价;
|
|
4293
|
+
// 顶层 original/selling 的旧差额仍会作为 legacy discount 迁移到新价格。
|
|
4268
4294
|
var existedMeta = nextProduct.metadata || {};
|
|
4269
4295
|
nextProduct.metadata = _objectSpread({}, existedMeta);
|
|
4270
4296
|
delete nextProduct.metadata.source_product_price;
|
|
4271
4297
|
delete nextProduct.metadata.main_product_selling_price;
|
|
4272
4298
|
delete nextProduct.metadata.main_product_original_price;
|
|
4273
4299
|
delete nextProduct.metadata.price_schema_version;
|
|
4300
|
+
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4301
|
+
var _ref68, _targetProduct$metada10, _targetProduct$metada11, _ref69, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
4302
|
+
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
4303
|
+
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
4304
|
+
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
4305
|
+
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
4306
|
+
var _previousMainOriginal = new Decimal(Number((_ref68 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref68 !== void 0 ? _ref68 : 0) || 0);
|
|
4307
|
+
var _previousMainSelling = new Decimal(Number((_ref69 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref69 !== void 0 ? _ref69 : _previousMainOriginal.toNumber()) || 0);
|
|
4308
|
+
var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
4309
|
+
var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
|
|
4310
|
+
var _nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
4311
|
+
nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
|
|
4312
|
+
source_product_price: previousSource.toDecimalPlaces(2).toFixed(2),
|
|
4313
|
+
main_product_original_price: _nextMainOriginal.toDecimalPlaces(2).toFixed(2),
|
|
4314
|
+
main_product_selling_price: _nextMainOriginal.minus(_preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
4315
|
+
price_schema_version: 2
|
|
4316
|
+
});
|
|
4317
|
+
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4318
|
+
var _existedMeta = nextProduct.metadata || {};
|
|
4319
|
+
nextProduct.metadata = _objectSpread({}, _existedMeta);
|
|
4320
|
+
delete nextProduct.metadata.source_product_price;
|
|
4321
|
+
delete nextProduct.metadata.main_product_selling_price;
|
|
4322
|
+
delete nextProduct.metadata.main_product_original_price;
|
|
4323
|
+
delete nextProduct.metadata.price_schema_version;
|
|
4274
4324
|
}
|
|
4275
4325
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
4276
4326
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
4277
4327
|
var normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
|
|
4278
4328
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4279
|
-
var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$
|
|
4329
|
+
var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada15 = targetProduct.metadata) === null || _targetProduct$metada15 === void 0 ? void 0 : _targetProduct$metada15.booking_uid);
|
|
4280
4330
|
if (!booking && preservedBookingUid) {
|
|
4281
4331
|
normalizedProduct.booking_uid = preservedBookingUid;
|
|
4282
4332
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
@@ -4284,8 +4334,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4284
4334
|
});
|
|
4285
4335
|
}
|
|
4286
4336
|
if (booking) {
|
|
4287
|
-
var _normalizedProduct$me, _targetProduct$
|
|
4288
|
-
var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$
|
|
4337
|
+
var _normalizedProduct$me, _targetProduct$metada16;
|
|
4338
|
+
var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada16 = targetProduct.metadata) === null || _targetProduct$metada16 === void 0 ? void 0 : _targetProduct$metada16.unique_identification_number) || unique_identification_number || createUuidV4());
|
|
4289
4339
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
4290
4340
|
unique_identification_number: productUid
|
|
4291
4341
|
});
|
|
@@ -4396,7 +4446,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4396
4446
|
key: "updateOrderProductQuantity",
|
|
4397
4447
|
value: function () {
|
|
4398
4448
|
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
4399
|
-
var _targetProduct$
|
|
4449
|
+
var _targetProduct$metada17;
|
|
4400
4450
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
4401
4451
|
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
4402
4452
|
while (1) switch (_context27.prev = _context27.next) {
|
|
@@ -4420,8 +4470,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4420
4470
|
if (unique_identification_number !== undefined) {
|
|
4421
4471
|
targetUid = String(unique_identification_number);
|
|
4422
4472
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
4423
|
-
var _item$
|
|
4424
|
-
return String(((_item$
|
|
4473
|
+
var _item$metadata5;
|
|
4474
|
+
return String(((_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
4425
4475
|
});
|
|
4426
4476
|
}
|
|
4427
4477
|
if (productIndex === -1) {
|
|
@@ -4437,7 +4487,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4437
4487
|
normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
4438
4488
|
num: getSafeProductNum(num),
|
|
4439
4489
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
4440
|
-
unique_identification_number: ((_targetProduct$
|
|
4490
|
+
unique_identification_number: ((_targetProduct$metada17 = targetProduct.metadata) === null || _targetProduct$metada17 === void 0 ? void 0 : _targetProduct$metada17.unique_identification_number) || unique_identification_number
|
|
4441
4491
|
})
|
|
4442
4492
|
}));
|
|
4443
4493
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
@@ -4579,15 +4629,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4579
4629
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4580
4630
|
_context30.prev = 11;
|
|
4581
4631
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4582
|
-
var
|
|
4632
|
+
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4583
4633
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4584
4634
|
return _regeneratorRuntime().wrap(function _loop3$(_context29) {
|
|
4585
4635
|
while (1) switch (_context29.prev = _context29.next) {
|
|
4586
4636
|
case 0:
|
|
4587
4637
|
product = _step21.value;
|
|
4588
|
-
productUid = (product === null || product === void 0 || (
|
|
4589
|
-
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (
|
|
4590
|
-
isAddTimeProduct = (product === null || product === void 0 || (
|
|
4638
|
+
productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
4639
|
+
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
|
|
4640
|
+
isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
|
|
4591
4641
|
if (!isAddTimeProduct) {
|
|
4592
4642
|
_context29.next = 6;
|
|
4593
4643
|
break;
|
|
@@ -4734,23 +4784,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4734
4784
|
}, {
|
|
4735
4785
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
4736
4786
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
4737
|
-
var _params$cacheId, _this$otherParams3,
|
|
4787
|
+
var _params$cacheId, _this$otherParams3, _ref70, _params$businessCode, _this$otherParams4, _this$otherParams5;
|
|
4738
4788
|
var tempOrder = this.ensureTempOrder();
|
|
4739
4789
|
this.persistTempOrder();
|
|
4740
4790
|
var payload = buildSubmitPayload({
|
|
4741
4791
|
tempOrder: tempOrder,
|
|
4742
4792
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
4743
4793
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform),
|
|
4744
|
-
businessCode: (
|
|
4794
|
+
businessCode: (_ref70 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref70 !== void 0 ? _ref70 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
|
|
4745
4795
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4746
4796
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
4747
4797
|
summary: this.store.summary || createEmptySummary(),
|
|
4748
4798
|
enhance: function enhance(nextPayload) {
|
|
4749
|
-
var
|
|
4799
|
+
var _ref71, _tempOrder$order_numb, _ref72, _tempOrder$shop_order, _ref73, _tempOrder$shop_full_;
|
|
4750
4800
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
4751
|
-
order_number: (
|
|
4752
|
-
shop_order_number: (
|
|
4753
|
-
shop_full_order_number: (
|
|
4801
|
+
order_number: (_ref71 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
|
|
4802
|
+
shop_order_number: (_ref72 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
|
|
4803
|
+
shop_full_order_number: (_ref73 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref73 !== void 0 ? _ref73 : null,
|
|
4754
4804
|
small_ticket_data_flag: 1
|
|
4755
4805
|
});
|
|
4756
4806
|
}
|
|
@@ -4801,7 +4851,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4801
4851
|
key: "saveTempOrderAsDraft",
|
|
4802
4852
|
value: function () {
|
|
4803
4853
|
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
4804
|
-
var _params$cacheId2, _this$otherParams6,
|
|
4854
|
+
var _params$cacheId2, _this$otherParams6, _ref74, _params$businessCode2, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
|
|
4805
4855
|
var tempOrder, latestSummary, payload;
|
|
4806
4856
|
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4807
4857
|
while (1) switch (_context34.prev = _context34.next) {
|
|
@@ -4833,7 +4883,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4833
4883
|
tempOrder: tempOrder,
|
|
4834
4884
|
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
4835
4885
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4836
|
-
businessCode: (
|
|
4886
|
+
businessCode: (_ref74 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
|
|
4837
4887
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4838
4888
|
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
|
|
4839
4889
|
summary: latestSummary,
|
|
@@ -4914,7 +4964,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4914
4964
|
key: "runSubmitTempOrder",
|
|
4915
4965
|
value: function () {
|
|
4916
4966
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
4917
|
-
var _params$cacheId3, _this$otherParams10,
|
|
4967
|
+
var _params$cacheId3, _this$otherParams10, _ref75, _ref76, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
|
|
4918
4968
|
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
4919
4969
|
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
4920
4970
|
while (1) switch (_context37.prev = _context37.next) {
|
|
@@ -4976,7 +5026,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4976
5026
|
tempOrder: tempOrder,
|
|
4977
5027
|
cacheId: effectiveCacheId,
|
|
4978
5028
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
|
|
4979
|
-
businessCode: (
|
|
5029
|
+
businessCode: (_ref75 = (_ref76 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref76 !== void 0 ? _ref76 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
|
|
4980
5030
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4981
5031
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
4982
5032
|
summary: latestSummary,
|
|
@@ -6008,7 +6058,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6008
6058
|
_step24;
|
|
6009
6059
|
try {
|
|
6010
6060
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
6011
|
-
var _product$metadata11,
|
|
6061
|
+
var _product$metadata11, _ref77, _ref78, _existed$origin, _rawProduct$metadata;
|
|
6012
6062
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
6013
6063
|
index = _step24$value[0],
|
|
6014
6064
|
product = _step24$value[1];
|
|
@@ -6016,7 +6066,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6016
6066
|
if (!uid) continue;
|
|
6017
6067
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
6018
6068
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
6019
|
-
var origin = (
|
|
6069
|
+
var origin = (_ref77 = (_ref78 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref78 !== void 0 ? _ref78 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref77 !== void 0 ? _ref77 : rawProduct;
|
|
6020
6070
|
var originSnapshot = cloneDeep(origin);
|
|
6021
6071
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
6022
6072
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -6145,10 +6195,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6145
6195
|
}, {
|
|
6146
6196
|
key: "normalizeHydratedProductOptionItem",
|
|
6147
6197
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
6148
|
-
var
|
|
6149
|
-
var rawNum = (
|
|
6198
|
+
var _ref79, _optionItem$num, _ref80, _optionItem$add_price;
|
|
6199
|
+
var rawNum = (_ref79 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref79 !== void 0 ? _ref79 : 1;
|
|
6150
6200
|
var parsedNum = Number(rawNum);
|
|
6151
|
-
var rawPrice = (
|
|
6201
|
+
var rawPrice = (_ref80 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref80 !== void 0 ? _ref80 : 0;
|
|
6152
6202
|
var parsedPrice = Number(rawPrice);
|
|
6153
6203
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
6154
6204
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -6289,10 +6339,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6289
6339
|
_step29;
|
|
6290
6340
|
try {
|
|
6291
6341
|
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
6292
|
-
var
|
|
6342
|
+
var _ref81, _bundle$num3;
|
|
6293
6343
|
var bundle = _step29.value;
|
|
6294
6344
|
var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
|
|
6295
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
6345
|
+
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref81 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref81 !== void 0 ? _ref81 : 1) || 1).toNumber();
|
|
6296
6346
|
var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
6297
6347
|
_step30;
|
|
6298
6348
|
try {
|
|
@@ -245,9 +245,10 @@ export function mergeIdenticalPromotionCartLines(products) {
|
|
|
245
245
|
var unitPrice = String((_ref2 = (_line$metadata$source = (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.source_product_price) !== null && _line$metadata$source !== void 0 ? _line$metadata$source : line.selling_price) !== null && _ref2 !== void 0 ? _ref2 : '');
|
|
246
246
|
var promoUnitPrice = String((_ref3 = (_promotion$finalPrice = promotion.finalPrice) !== null && _promotion$finalPrice !== void 0 ? _promotion$finalPrice : (_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.main_product_selling_price) !== null && _ref3 !== void 0 ? _ref3 : '');
|
|
247
247
|
var noteSignature = getProductLineNoteSignature(line);
|
|
248
|
+
var lineMergeBoundary = getPromotionLineMergeBoundary(line);
|
|
248
249
|
var bookingUid = (_line$booking_uid = line === null || line === void 0 ? void 0 : line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : line === null || line === void 0 || (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.booking_uid;
|
|
249
250
|
var orderDetailId = (_line$order_detail_id = line === null || line === void 0 ? void 0 : line.order_detail_id) !== null && _line$order_detail_id !== void 0 ? _line$order_detail_id : line === null || line === void 0 ? void 0 : line.orderDetailId;
|
|
250
|
-
var mergeKey = [line.product_id, (_line$product_variant = line.product_variant_id) !== null && _line$product_variant !== void 0 ? _line$product_variant : 0, fingerprint, noteSignature, bookingUid ? String(bookingUid) : '', orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '' ? String(orderDetailId) : '', promotion.strategyId, unitPrice, promoUnitPrice].join('#');
|
|
251
|
+
var mergeKey = [line.product_id, (_line$product_variant = line.product_variant_id) !== null && _line$product_variant !== void 0 ? _line$product_variant : 0, fingerprint, noteSignature, lineMergeBoundary, bookingUid ? String(bookingUid) : '', orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '' ? String(orderDetailId) : '', promotion.strategyId, unitPrice, promoUnitPrice].join('#');
|
|
251
252
|
var hitIndex = indexByKey.get(mergeKey);
|
|
252
253
|
if (hitIndex === undefined) {
|
|
253
254
|
indexByKey.set(mergeKey, merged.length);
|
|
@@ -423,6 +424,16 @@ function getProductLineNoteSignature(product) {
|
|
|
423
424
|
var uid = getOrderProductUid(product);
|
|
424
425
|
return uid ? "note:".concat(uid) : "note:".concat(normalizedNote);
|
|
425
426
|
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* 编辑订单时,历史行仍参与整车促销评估,但不能与本次新增行合并。
|
|
430
|
+
* 以历史行 uid 作为促销前后的行边界;新增行返回空边界,仍保留原有合并语义。
|
|
431
|
+
*/
|
|
432
|
+
function getPromotionLineMergeBoundary(product) {
|
|
433
|
+
var _product$metadata3;
|
|
434
|
+
if ((product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.is_edit_for_runtime) !== true) return '';
|
|
435
|
+
return "edit:".concat(getOrderProductUid(product));
|
|
436
|
+
}
|
|
426
437
|
function isPersistedGeneratedVoucher(product) {
|
|
427
438
|
var _product$order_detail;
|
|
428
439
|
var orderDetailId = (_product$order_detail = product === null || product === void 0 ? void 0 : product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : product === null || product === void 0 ? void 0 : product.orderDetailId;
|
|
@@ -463,17 +474,18 @@ export function buildConsolidateKeyForPromotion(item) {
|
|
|
463
474
|
var _item$booking_uid, _item$metadata, _item$order_detail_id, _item$product_variant3;
|
|
464
475
|
var fingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
465
476
|
var noteSignature = getProductLineNoteSignature(item);
|
|
477
|
+
var lineMergeBoundary = getPromotionLineMergeBoundary(item);
|
|
466
478
|
var bookingUid = (_item$booking_uid = item === null || item === void 0 ? void 0 : item.booking_uid) !== null && _item$booking_uid !== void 0 ? _item$booking_uid : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.booking_uid;
|
|
467
479
|
var orderDetailId = (_item$order_detail_id = item === null || item === void 0 ? void 0 : item.order_detail_id) !== null && _item$order_detail_id !== void 0 ? _item$order_detail_id : item === null || item === void 0 ? void 0 : item.orderDetailId;
|
|
468
480
|
if (orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '') {
|
|
469
481
|
var _item$product_variant;
|
|
470
|
-
return [item.product_id, (_item$product_variant = item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0, fingerprint, noteSignature, String(orderDetailId)].join('#');
|
|
482
|
+
return [item.product_id, (_item$product_variant = item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0, fingerprint, noteSignature, lineMergeBoundary, String(orderDetailId)].join('#');
|
|
471
483
|
}
|
|
472
484
|
if (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '') {
|
|
473
485
|
var _item$product_variant2;
|
|
474
|
-
return [item.product_id, (_item$product_variant2 = item.product_variant_id) !== null && _item$product_variant2 !== void 0 ? _item$product_variant2 : 0, fingerprint, noteSignature, String(bookingUid)].join('#');
|
|
486
|
+
return [item.product_id, (_item$product_variant2 = item.product_variant_id) !== null && _item$product_variant2 !== void 0 ? _item$product_variant2 : 0, fingerprint, noteSignature, lineMergeBoundary, String(bookingUid)].join('#');
|
|
475
487
|
}
|
|
476
|
-
return [item.product_id, (_item$product_variant3 = item.product_variant_id) !== null && _item$product_variant3 !== void 0 ? _item$product_variant3 : 0, fingerprint, noteSignature].join('#');
|
|
488
|
+
return [item.product_id, (_item$product_variant3 = item.product_variant_id) !== null && _item$product_variant3 !== void 0 ? _item$product_variant3 : 0, fingerprint, noteSignature, lineMergeBoundary].join('#');
|
|
477
489
|
}
|
|
478
490
|
function consolidateMainProductsForPromotion(entries) {
|
|
479
491
|
if (!Array.isArray(entries) || entries.length <= 1) {
|
|
@@ -838,13 +850,13 @@ export function resolveStrategyEligibleProducts(matched) {
|
|
|
838
850
|
export function calculateUnfulfilledPromotions(processedProducts, applicableStrategiesResult, mainProducts) {
|
|
839
851
|
var unfulfilledMap = new Map();
|
|
840
852
|
var _loop2 = function _loop2() {
|
|
841
|
-
var _product$
|
|
853
|
+
var _product$metadata4, _ref13, _product$_originalPro, _product$metadata5, _product$num2;
|
|
842
854
|
var product = processedProducts[i];
|
|
843
|
-
var promotion = product === null || product === void 0 || (_product$
|
|
855
|
+
var promotion = product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4._promotion;
|
|
844
856
|
if (!promotion || promotion.inPromotion !== false) return 0; // continue
|
|
845
857
|
var strategyId = promotion.strategyId;
|
|
846
858
|
if (!strategyId) return 0; // continue
|
|
847
|
-
var lookupUid = String((_ref13 = (_product$_originalPro = product === null || product === void 0 ? void 0 : product._originalProductUid) !== null && _product$_originalPro !== void 0 ? _product$_originalPro : product === null || product === void 0 || (_product$
|
|
859
|
+
var lookupUid = String((_ref13 = (_product$_originalPro = product === null || product === void 0 ? void 0 : product._originalProductUid) !== null && _product$_originalPro !== void 0 ? _product$_originalPro : product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) !== null && _ref13 !== void 0 ? _ref13 : '');
|
|
848
860
|
var originalIndex = mainProducts.findIndex(function (item) {
|
|
849
861
|
return getOrderProductUid(item) === lookupUid;
|
|
850
862
|
});
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
322
322
|
* 获取当前的客户搜索条件
|
|
323
323
|
* @returns 当前搜索条件
|
|
324
324
|
*/
|
|
325
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
325
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
326
326
|
/**
|
|
327
327
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
328
328
|
* @returns 客户状态
|
|
@@ -83,6 +83,7 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
83
83
|
private getBookingAppointmentStatus;
|
|
84
84
|
private isBookingIncludedInStats;
|
|
85
85
|
private getBookingOrderPaymentStatus;
|
|
86
|
+
private isUnpaidBooking;
|
|
86
87
|
private countBookingOrders;
|
|
87
88
|
private countCompletedBookings;
|
|
88
89
|
private groupBookingsByResource;
|
|
@@ -29,6 +29,7 @@ import dayjs from 'dayjs';
|
|
|
29
29
|
import { BaseModule } from "../../modules/BaseModule";
|
|
30
30
|
import { SalesHooks } from "./types";
|
|
31
31
|
export * from "./types";
|
|
32
|
+
var UNPAID_PAYMENT_STATUSES = new Set(['unpaid', 'partially_paid', 'payment_processing']);
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Sales 解决方案基础骨架
|
|
@@ -415,6 +416,11 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
415
416
|
var _booking$order$paymen, _booking$order;
|
|
416
417
|
return String((_booking$order$paymen = (_booking$order = booking.order) === null || _booking$order === void 0 ? void 0 : _booking$order.payment_status) !== null && _booking$order$paymen !== void 0 ? _booking$order$paymen : '');
|
|
417
418
|
}
|
|
419
|
+
}, {
|
|
420
|
+
key: "isUnpaidBooking",
|
|
421
|
+
value: function isUnpaidBooking(booking) {
|
|
422
|
+
return UNPAID_PAYMENT_STATUSES.has(this.getBookingOrderPaymentStatus(booking));
|
|
423
|
+
}
|
|
418
424
|
}, {
|
|
419
425
|
key: "countBookingOrders",
|
|
420
426
|
value: function countBookingOrders(bookings) {
|
|
@@ -895,9 +901,11 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
895
901
|
});
|
|
896
902
|
completedBookingList = matchedBookingList.filter(function (booking) {
|
|
897
903
|
return _this7.getBookingAppointmentStatus(booking) === 'completed';
|
|
898
|
-
});
|
|
904
|
+
}); // const unpaidBookingList = matchedBookingList.filter(
|
|
905
|
+
// (booking) => this.getBookingOrderPaymentStatus(booking) === 'unpaid' || this.getBookingOrderPaymentStatus(booking) === 'payment_processing',
|
|
906
|
+
// );
|
|
899
907
|
unpaidBookingList = matchedBookingList.filter(function (booking) {
|
|
900
|
-
return _this7.
|
|
908
|
+
return _this7.isUnpaidBooking(booking);
|
|
901
909
|
});
|
|
902
910
|
bookings = this.pickBookingsForCurrentPoint(current, this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList));
|
|
903
911
|
completedBookings = completedBookingList.map(function (booking) {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
+
var promotion_exports = {};
|
|
31
|
+
__export(promotion_exports, {
|
|
32
|
+
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
+
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
+
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
+
default: () => import_adapter2.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
+
var import_evaluator = require("./evaluator");
|
|
40
|
+
var import_adapter = require("./adapter");
|
|
41
|
+
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
+
var import_examples = require("./examples");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
+
PromotionAdapter,
|
|
47
|
+
PromotionEvaluator,
|
|
48
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
+
});
|
|
@@ -48,7 +48,7 @@ export interface BookingResourceInput {
|
|
|
48
48
|
capacity?: number;
|
|
49
49
|
like_status?: string;
|
|
50
50
|
metadata?: Record<string, any>;
|
|
51
|
-
children?:
|
|
51
|
+
children?: BookingResourceInput[];
|
|
52
52
|
}
|
|
53
53
|
/** custom / package 人数维度快照,与 info2 `_extend.capacity` / `metadata.capacity` 对齐。 */
|
|
54
54
|
export interface BookingCapacityMetadataItem {
|
|
@@ -88,6 +88,24 @@ function resolveDurationMinutes(value) {
|
|
|
88
88
|
const n = Number(value);
|
|
89
89
|
return Number.isNaN(n) ? void 0 : n;
|
|
90
90
|
}
|
|
91
|
+
function normalizeChildResource(child, parentFormId) {
|
|
92
|
+
const item = {
|
|
93
|
+
form_id: (child == null ? void 0 : child.form_id) ?? parentFormId,
|
|
94
|
+
relation_type: (child == null ? void 0 : child.relation_type) || "form",
|
|
95
|
+
relation_id: (child == null ? void 0 : child.relation_id) ?? (child == null ? void 0 : child.id),
|
|
96
|
+
capacity: child == null ? void 0 : child.capacity,
|
|
97
|
+
like_status: (child == null ? void 0 : child.like_status) || "common"
|
|
98
|
+
};
|
|
99
|
+
if ((child == null ? void 0 : child.metadata) !== void 0) {
|
|
100
|
+
item.metadata = { ...child.metadata };
|
|
101
|
+
}
|
|
102
|
+
if (Array.isArray(child == null ? void 0 : child.children)) {
|
|
103
|
+
item.children = child.children.map(
|
|
104
|
+
(nestedChild) => normalizeChildResource(nestedChild, item.form_id)
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return item;
|
|
108
|
+
}
|
|
91
109
|
function flattenResources(cacheItem) {
|
|
92
110
|
var _a;
|
|
93
111
|
const resourceMap = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource) || {};
|
|
@@ -107,8 +125,11 @@ function flattenResources(cacheItem) {
|
|
|
107
125
|
if ((r == null ? void 0 : r.metadata) !== void 0) {
|
|
108
126
|
item.metadata = { ...r.metadata };
|
|
109
127
|
}
|
|
110
|
-
if ((r == null ? void 0 : r.children)
|
|
111
|
-
item.children = r.children
|
|
128
|
+
if (Array.isArray(r == null ? void 0 : r.children)) {
|
|
129
|
+
item.children = r.children.map(
|
|
130
|
+
(child) => normalizeChildResource(child, item.form_id)
|
|
131
|
+
);
|
|
132
|
+
}
|
|
112
133
|
result.push(item);
|
|
113
134
|
});
|
|
114
135
|
});
|
|
@@ -485,7 +485,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
485
485
|
generateIdempotencyToken(): string;
|
|
486
486
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
487
487
|
createOrder(params: CommitOrderParams['query']): {
|
|
488
|
-
type: "
|
|
488
|
+
type: "virtual" | "appointment_booking";
|
|
489
489
|
platform: string;
|
|
490
490
|
sales_channel: string;
|
|
491
491
|
order_sales_channel: string;
|
|
@@ -2872,12 +2872,15 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2872
2872
|
const hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
2873
2873
|
const shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
|
|
2874
2874
|
const matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex((item) => {
|
|
2875
|
+
var _a2;
|
|
2875
2876
|
if (this.hasGoodPassDiscount(item))
|
|
2876
2877
|
return false;
|
|
2877
2878
|
if (this.hasOrderProductLineNote(item))
|
|
2878
2879
|
return false;
|
|
2879
2880
|
if (item.order_detail_id !== void 0 && item.order_detail_id !== null)
|
|
2880
2881
|
return false;
|
|
2882
|
+
if ((_a2 = item.metadata) == null ? void 0 : _a2.is_edit_for_runtime)
|
|
2883
|
+
return false;
|
|
2881
2884
|
if (item.product_id !== productToAdd.product_id)
|
|
2882
2885
|
return false;
|
|
2883
2886
|
if (item.product_variant_id !== productToAdd.product_variant_id)
|
|
@@ -3119,7 +3122,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3119
3122
|
});
|
|
3120
3123
|
}
|
|
3121
3124
|
applyOrderProductUpdateToTempOrder(tempOrder, params) {
|
|
3122
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3125
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
3123
3126
|
const {
|
|
3124
3127
|
product_id,
|
|
3125
3128
|
product_variant_id,
|
|
@@ -3183,9 +3186,22 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3183
3186
|
nextProduct.num = (0, import_utils3.getSafeProductNum)(nextProduct.num);
|
|
3184
3187
|
const callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, "selling_price") || Object.prototype.hasOwnProperty.call(updates || {}, "original_price");
|
|
3185
3188
|
const callerUpdatesMainMeta = ((_c = updates == null ? void 0 : updates.metadata) == null ? void 0 : _c.main_product_selling_price) !== void 0 || ((_d = updates == null ? void 0 : updates.metadata) == null ? void 0 : _d.main_product_original_price) !== void 0 || ((_e = updates == null ? void 0 : updates.metadata) == null ? void 0 : _e.source_product_price) !== void 0;
|
|
3189
|
+
const callerUpdatesSourcePrice = ((_f = updates == null ? void 0 : updates.metadata) == null ? void 0 : _f.source_product_price) !== void 0;
|
|
3190
|
+
const callerUpdatesMainSellingPrice = ((_g = updates == null ? void 0 : updates.metadata) == null ? void 0 : _g.main_product_selling_price) !== void 0;
|
|
3191
|
+
const callerUpdatesMainOriginalPrice = ((_h = updates == null ? void 0 : updates.metadata) == null ? void 0 : _h.main_product_original_price) !== void 0;
|
|
3192
|
+
const previousLineFingerprint = (0, import_utils3.buildProductLineFingerprint)(
|
|
3193
|
+
(0, import_utils.getProductSkuOptions)(targetProduct),
|
|
3194
|
+
targetProduct.product_bundle
|
|
3195
|
+
);
|
|
3196
|
+
const nextLineFingerprint = (0, import_utils3.buildProductLineFingerprint)(
|
|
3197
|
+
(0, import_utils.getProductSkuOptions)(nextProduct),
|
|
3198
|
+
nextProduct.product_bundle
|
|
3199
|
+
);
|
|
3200
|
+
const callerChangesVariant = Number(product_variant_id || 0) !== Number(targetProduct.product_variant_id || 0);
|
|
3201
|
+
const callerChangesLineConfiguration = callerChangesVariant || previousLineFingerprint !== nextLineFingerprint;
|
|
3186
3202
|
const isPersistedOrderLine = targetProduct.order_detail_id !== void 0 && targetProduct.order_detail_id !== null;
|
|
3187
3203
|
const callerChangesDiscountList = Array.isArray(updates == null ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
|
|
3188
|
-
const callerUpdatesManualPrice = ((
|
|
3204
|
+
const callerUpdatesManualPrice = ((_i = updates == null ? void 0 : updates.metadata) == null ? void 0 : _i.price_override) !== void 0 || ((_j = updates == null ? void 0 : updates.metadata) == null ? void 0 : _j.is_manual_discount) !== void 0 || ((_k = updates == null ? void 0 : updates.metadata) == null ? void 0 : _k.product_discount_reason) !== void 0 || callerChangesDiscountList;
|
|
3189
3205
|
const callerAllowsBookingReprice = (() => {
|
|
3190
3206
|
if (params.allow_booking_reprice !== true || !booking || !callerUpdatesTopPrice || !callerUpdatesMainMeta) {
|
|
3191
3207
|
return false;
|
|
@@ -3200,21 +3216,69 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3200
3216
|
};
|
|
3201
3217
|
return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
|
|
3202
3218
|
})();
|
|
3203
|
-
if (isPersistedOrderLine && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
3219
|
+
if (isPersistedOrderLine && !callerChangesLineConfiguration && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
3204
3220
|
nextProduct.selling_price = targetProduct.selling_price;
|
|
3205
3221
|
nextProduct.original_price = targetProduct.original_price;
|
|
3206
3222
|
nextProduct.payment_price = targetProduct.payment_price;
|
|
3207
3223
|
nextProduct.metadata = {
|
|
3208
3224
|
...nextProduct.metadata || {},
|
|
3209
|
-
source_product_price: (
|
|
3210
|
-
main_product_selling_price: (
|
|
3211
|
-
main_product_original_price: (
|
|
3212
|
-
price_schema_version: ((
|
|
3225
|
+
source_product_price: (_l = targetProduct.metadata) == null ? void 0 : _l.source_product_price,
|
|
3226
|
+
main_product_selling_price: (_m = targetProduct.metadata) == null ? void 0 : _m.main_product_selling_price,
|
|
3227
|
+
main_product_original_price: (_n = targetProduct.metadata) == null ? void 0 : _n.main_product_original_price,
|
|
3228
|
+
price_schema_version: ((_o = targetProduct.metadata) == null ? void 0 : _o.price_schema_version) ?? 2
|
|
3213
3229
|
};
|
|
3214
3230
|
nextProduct.product_bundle = this.preservePersistedBundlePriceFields(
|
|
3215
3231
|
targetProduct.product_bundle,
|
|
3216
3232
|
nextProduct.product_bundle
|
|
3217
3233
|
);
|
|
3234
|
+
} else if (callerChangesLineConfiguration && callerUpdatesSourcePrice && (!callerUpdatesMainSellingPrice || !callerUpdatesMainOriginalPrice)) {
|
|
3235
|
+
const previousMainOriginal = new import_decimal.default(
|
|
3236
|
+
Number((_p = targetProduct.metadata) == null ? void 0 : _p.main_product_original_price) || 0
|
|
3237
|
+
);
|
|
3238
|
+
const previousMainSelling = new import_decimal.default(
|
|
3239
|
+
Number((_q = targetProduct.metadata) == null ? void 0 : _q.main_product_selling_price) || previousMainOriginal.toNumber()
|
|
3240
|
+
);
|
|
3241
|
+
const preservedDiscount = previousMainOriginal.minus(previousMainSelling);
|
|
3242
|
+
const nextMainOriginal = new import_decimal.default(
|
|
3243
|
+
Number(updates.metadata.source_product_price) || 0
|
|
3244
|
+
).plus((0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(nextProduct)));
|
|
3245
|
+
nextProduct.metadata = {
|
|
3246
|
+
...nextProduct.metadata || {},
|
|
3247
|
+
source_product_price: String(updates.metadata.source_product_price),
|
|
3248
|
+
main_product_original_price: callerUpdatesMainOriginalPrice ? String(updates.metadata.main_product_original_price) : nextMainOriginal.toDecimalPlaces(2).toFixed(2),
|
|
3249
|
+
main_product_selling_price: callerUpdatesMainSellingPrice ? String(updates.metadata.main_product_selling_price) : nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
3250
|
+
price_schema_version: 2
|
|
3251
|
+
};
|
|
3252
|
+
} else if (callerChangesVariant && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
3253
|
+
const existedMeta = nextProduct.metadata || {};
|
|
3254
|
+
nextProduct.metadata = { ...existedMeta };
|
|
3255
|
+
delete nextProduct.metadata.source_product_price;
|
|
3256
|
+
delete nextProduct.metadata.main_product_selling_price;
|
|
3257
|
+
delete nextProduct.metadata.main_product_original_price;
|
|
3258
|
+
delete nextProduct.metadata.price_schema_version;
|
|
3259
|
+
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
3260
|
+
const previousOptionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(targetProduct));
|
|
3261
|
+
const nextOptionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(nextProduct));
|
|
3262
|
+
const previousMainOriginal = new import_decimal.default(
|
|
3263
|
+
Number(
|
|
3264
|
+
((_r = targetProduct.metadata) == null ? void 0 : _r.main_product_original_price) ?? targetProduct.original_price ?? 0
|
|
3265
|
+
) || 0
|
|
3266
|
+
);
|
|
3267
|
+
const previousMainSelling = new import_decimal.default(
|
|
3268
|
+
Number(
|
|
3269
|
+
((_s = targetProduct.metadata) == null ? void 0 : _s.main_product_selling_price) ?? targetProduct.selling_price ?? previousMainOriginal.toNumber()
|
|
3270
|
+
) || 0
|
|
3271
|
+
);
|
|
3272
|
+
const preservedDiscount = previousMainOriginal.minus(previousMainSelling);
|
|
3273
|
+
const previousSource = ((_t = targetProduct.metadata) == null ? void 0 : _t.source_product_price) != null ? new import_decimal.default(Number(targetProduct.metadata.source_product_price) || 0) : previousMainOriginal.minus(previousOptionSum);
|
|
3274
|
+
const nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
3275
|
+
nextProduct.metadata = {
|
|
3276
|
+
...nextProduct.metadata || {},
|
|
3277
|
+
source_product_price: previousSource.toDecimalPlaces(2).toFixed(2),
|
|
3278
|
+
main_product_original_price: nextMainOriginal.toDecimalPlaces(2).toFixed(2),
|
|
3279
|
+
main_product_selling_price: nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
3280
|
+
price_schema_version: 2
|
|
3281
|
+
};
|
|
3218
3282
|
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
3219
3283
|
const existedMeta = nextProduct.metadata || {};
|
|
3220
3284
|
nextProduct.metadata = { ...existedMeta };
|
|
@@ -3230,7 +3294,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3230
3294
|
normalizedProduct.discount_list = (0, import_utils.normalizeOrderProductDiscountList)(
|
|
3231
3295
|
normalizedProduct.discount_list
|
|
3232
3296
|
);
|
|
3233
|
-
const preservedBookingUid = nextProduct.booking_uid || ((
|
|
3297
|
+
const preservedBookingUid = nextProduct.booking_uid || ((_u = nextProduct.metadata) == null ? void 0 : _u.booking_uid) || targetProduct.booking_uid || ((_v = targetProduct.metadata) == null ? void 0 : _v.booking_uid);
|
|
3234
3298
|
if (!booking && preservedBookingUid) {
|
|
3235
3299
|
normalizedProduct.booking_uid = preservedBookingUid;
|
|
3236
3300
|
normalizedProduct.metadata = {
|
|
@@ -3240,7 +3304,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3240
3304
|
}
|
|
3241
3305
|
if (booking) {
|
|
3242
3306
|
const productUid = String(
|
|
3243
|
-
((
|
|
3307
|
+
((_w = normalizedProduct.metadata) == null ? void 0 : _w.unique_identification_number) || ((_x = targetProduct.metadata) == null ? void 0 : _x.unique_identification_number) || unique_identification_number || (0, import_utils.createUuidV4)()
|
|
3244
3308
|
);
|
|
3245
3309
|
normalizedProduct.metadata = {
|
|
3246
3310
|
...normalizedProduct.metadata || {},
|
|
@@ -3271,9 +3335,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3271
3335
|
tempOrder,
|
|
3272
3336
|
updates,
|
|
3273
3337
|
tempOrder.products[productIndex],
|
|
3274
|
-
(
|
|
3338
|
+
(_y = tempOrder.products[productIndex].metadata) == null ? void 0 : _y.unique_identification_number
|
|
3275
3339
|
);
|
|
3276
|
-
return (
|
|
3340
|
+
return (_z = tempOrder.products[productIndex].metadata) == null ? void 0 : _z.unique_identification_number;
|
|
3277
3341
|
}
|
|
3278
3342
|
async updateOrderProduct(params) {
|
|
3279
3343
|
const tempOrder = this.ensureTempOrder();
|
|
@@ -179,6 +179,7 @@ function mergeIdenticalPromotionCartLines(products) {
|
|
|
179
179
|
promotion.finalPrice ?? ((_c = line.metadata) == null ? void 0 : _c.main_product_selling_price) ?? ""
|
|
180
180
|
);
|
|
181
181
|
const noteSignature = getProductLineNoteSignature(line);
|
|
182
|
+
const lineMergeBoundary = getPromotionLineMergeBoundary(line);
|
|
182
183
|
const bookingUid = (line == null ? void 0 : line.booking_uid) ?? ((_d = line == null ? void 0 : line.metadata) == null ? void 0 : _d.booking_uid);
|
|
183
184
|
const orderDetailId = (line == null ? void 0 : line.order_detail_id) ?? (line == null ? void 0 : line.orderDetailId);
|
|
184
185
|
const mergeKey = [
|
|
@@ -186,6 +187,7 @@ function mergeIdenticalPromotionCartLines(products) {
|
|
|
186
187
|
line.product_variant_id ?? 0,
|
|
187
188
|
fingerprint,
|
|
188
189
|
noteSignature,
|
|
190
|
+
lineMergeBoundary,
|
|
189
191
|
bookingUid ? String(bookingUid) : "",
|
|
190
192
|
orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "" ? String(orderDetailId) : "",
|
|
191
193
|
promotion.strategyId,
|
|
@@ -329,6 +331,12 @@ function getProductLineNoteSignature(product) {
|
|
|
329
331
|
const uid = getOrderProductUid(product);
|
|
330
332
|
return uid ? `note:${uid}` : `note:${normalizedNote}`;
|
|
331
333
|
}
|
|
334
|
+
function getPromotionLineMergeBoundary(product) {
|
|
335
|
+
var _a;
|
|
336
|
+
if (((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.is_edit_for_runtime) !== true)
|
|
337
|
+
return "";
|
|
338
|
+
return `edit:${getOrderProductUid(product)}`;
|
|
339
|
+
}
|
|
332
340
|
function isPersistedGeneratedVoucher(product) {
|
|
333
341
|
const orderDetailId = (product == null ? void 0 : product.order_detail_id) ?? (product == null ? void 0 : product.orderDetailId);
|
|
334
342
|
if (orderDetailId === void 0 || orderDetailId === null || orderDetailId === "") {
|
|
@@ -356,6 +364,7 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
356
364
|
item.product_bundle
|
|
357
365
|
);
|
|
358
366
|
const noteSignature = getProductLineNoteSignature(item);
|
|
367
|
+
const lineMergeBoundary = getPromotionLineMergeBoundary(item);
|
|
359
368
|
const bookingUid = (item == null ? void 0 : item.booking_uid) ?? ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.booking_uid);
|
|
360
369
|
const orderDetailId = (item == null ? void 0 : item.order_detail_id) ?? (item == null ? void 0 : item.orderDetailId);
|
|
361
370
|
if (orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "") {
|
|
@@ -364,6 +373,7 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
364
373
|
item.product_variant_id ?? 0,
|
|
365
374
|
fingerprint,
|
|
366
375
|
noteSignature,
|
|
376
|
+
lineMergeBoundary,
|
|
367
377
|
String(orderDetailId)
|
|
368
378
|
].join("#");
|
|
369
379
|
}
|
|
@@ -373,6 +383,7 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
373
383
|
item.product_variant_id ?? 0,
|
|
374
384
|
fingerprint,
|
|
375
385
|
noteSignature,
|
|
386
|
+
lineMergeBoundary,
|
|
376
387
|
String(bookingUid)
|
|
377
388
|
].join("#");
|
|
378
389
|
}
|
|
@@ -380,7 +391,8 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
380
391
|
item.product_id,
|
|
381
392
|
item.product_variant_id ?? 0,
|
|
382
393
|
fingerprint,
|
|
383
|
-
noteSignature
|
|
394
|
+
noteSignature,
|
|
395
|
+
lineMergeBoundary
|
|
384
396
|
].join("#");
|
|
385
397
|
}
|
|
386
398
|
function consolidateMainProductsForPromotion(entries) {
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
322
322
|
* 获取当前的客户搜索条件
|
|
323
323
|
* @returns 当前搜索条件
|
|
324
324
|
*/
|
|
325
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
325
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
326
326
|
/**
|
|
327
327
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
328
328
|
* @returns 客户状态
|
|
@@ -83,6 +83,7 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
83
83
|
private getBookingAppointmentStatus;
|
|
84
84
|
private isBookingIncludedInStats;
|
|
85
85
|
private getBookingOrderPaymentStatus;
|
|
86
|
+
private isUnpaidBooking;
|
|
86
87
|
private countBookingOrders;
|
|
87
88
|
private countCompletedBookings;
|
|
88
89
|
private groupBookingsByResource;
|
|
@@ -39,6 +39,7 @@ var import_dayjs = __toESM(require("dayjs"));
|
|
|
39
39
|
var import_BaseModule = require("../../modules/BaseModule");
|
|
40
40
|
var import_types = require("./types");
|
|
41
41
|
__reExport(Sales_exports, require("./types"), module.exports);
|
|
42
|
+
var UNPAID_PAYMENT_STATUSES = /* @__PURE__ */ new Set(["unpaid", "partially_paid", "payment_processing"]);
|
|
42
43
|
var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
43
44
|
// LoggerManager 实例
|
|
44
45
|
constructor(name, version) {
|
|
@@ -258,6 +259,9 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
258
259
|
var _a;
|
|
259
260
|
return String(((_a = booking.order) == null ? void 0 : _a.payment_status) ?? "");
|
|
260
261
|
}
|
|
262
|
+
isUnpaidBooking(booking) {
|
|
263
|
+
return UNPAID_PAYMENT_STATUSES.has(this.getBookingOrderPaymentStatus(booking));
|
|
264
|
+
}
|
|
261
265
|
countBookingOrders(bookings) {
|
|
262
266
|
const orderIds = /* @__PURE__ */ new Set();
|
|
263
267
|
bookings.forEach((booking) => {
|
|
@@ -631,9 +635,7 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
631
635
|
const completedBookingList = matchedBookingList.filter(
|
|
632
636
|
(booking) => this.getBookingAppointmentStatus(booking) === "completed"
|
|
633
637
|
);
|
|
634
|
-
const unpaidBookingList = matchedBookingList.filter(
|
|
635
|
-
(booking) => this.getBookingOrderPaymentStatus(booking) === "unpaid" || this.getBookingOrderPaymentStatus(booking) === "payment_processing"
|
|
636
|
-
);
|
|
638
|
+
const unpaidBookingList = matchedBookingList.filter((booking) => this.isUnpaidBooking(booking));
|
|
637
639
|
const bookings = this.pickBookingsForCurrentPoint(
|
|
638
640
|
current,
|
|
639
641
|
this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList)
|