@pisell/pisellos 2.3.166 → 2.3.167
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/Order/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/ScanOrder/index.js +36 -28
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/ScanOrder/index.js +31 -18
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/package.json +1 -1
|
@@ -595,7 +595,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
595
595
|
generateIdempotencyToken(): string;
|
|
596
596
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
597
597
|
createOrder(params: CommitOrderParams['query']): {
|
|
598
|
-
type: "
|
|
598
|
+
type: "virtual" | "appointment_booking";
|
|
599
599
|
platform: string;
|
|
600
600
|
sales_channel: string;
|
|
601
601
|
order_sales_channel: string;
|
|
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
328
328
|
date: string;
|
|
329
329
|
status: string;
|
|
330
330
|
week: string;
|
|
331
|
-
weekNum: 0 |
|
|
331
|
+
weekNum: 0 | 5 | 1 | 2 | 4 | 3 | 6;
|
|
332
332
|
}[]>;
|
|
333
333
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
334
334
|
private getScheduleDataByIds;
|
|
@@ -347,7 +347,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
347
347
|
count: number;
|
|
348
348
|
left: number;
|
|
349
349
|
summaryCount: number;
|
|
350
|
-
status: "
|
|
350
|
+
status: "sold_out" | "lots_of_space" | "filling_up_fast";
|
|
351
351
|
}[];
|
|
352
352
|
/**
|
|
353
353
|
* 找到多个资源的公共可用时间段
|
|
@@ -2168,7 +2168,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2168
2168
|
key: "applyPrefillByItemRule",
|
|
2169
2169
|
value: function () {
|
|
2170
2170
|
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2171
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator6, _step6, _prefillItem$product_, _origin2, _origin3, _origin4, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
|
|
2171
|
+
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator6, _step6, _prefillItem$product_, _origin2, _origin3, _origin4, prefillItem, productId, productVariantId, targetQuantity, sourceItem, sourceTitle, productTitle, displayFields, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasTitleChanged, hasOriginChanged;
|
|
2172
2172
|
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2173
2173
|
while (1) switch (_context30.prev = _context30.next) {
|
|
2174
2174
|
case 0:
|
|
@@ -2218,7 +2218,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2218
2218
|
_iterator6.s();
|
|
2219
2219
|
case 22:
|
|
2220
2220
|
if ((_step6 = _iterator6.n()).done) {
|
|
2221
|
-
_context30.next =
|
|
2221
|
+
_context30.next = 51;
|
|
2222
2222
|
break;
|
|
2223
2223
|
}
|
|
2224
2224
|
prefillItem = _step6.value;
|
|
@@ -2229,25 +2229,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2229
2229
|
_context30.next = 29;
|
|
2230
2230
|
break;
|
|
2231
2231
|
}
|
|
2232
|
-
return _context30.abrupt("continue",
|
|
2232
|
+
return _context30.abrupt("continue", 49);
|
|
2233
2233
|
case 29:
|
|
2234
2234
|
if (!Number.isNaN(productVariantId)) {
|
|
2235
2235
|
_context30.next = 31;
|
|
2236
2236
|
break;
|
|
2237
2237
|
}
|
|
2238
|
-
return _context30.abrupt("continue",
|
|
2238
|
+
return _context30.abrupt("continue", 49);
|
|
2239
2239
|
case 31:
|
|
2240
2240
|
sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
|
|
2241
|
+
sourceTitle = (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.product_title) || (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.title) || (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.name);
|
|
2242
|
+
productTitle = typeof sourceTitle === 'string' ? {
|
|
2243
|
+
auto: sourceTitle
|
|
2244
|
+
} : sourceTitle; // 标准标题在归一化后补入,供购物车展示,并由 Order 在折扣重算时保留。
|
|
2245
|
+
displayFields = productTitle ? {
|
|
2246
|
+
product_title: productTitle
|
|
2247
|
+
} : {};
|
|
2241
2248
|
productIndex = getProductIdentityIndex(tempOrder.products, {
|
|
2242
2249
|
product_id: productId,
|
|
2243
2250
|
product_variant_id: productVariantId
|
|
2244
2251
|
});
|
|
2245
2252
|
if (!(productIndex === -1)) {
|
|
2246
|
-
_context30.next =
|
|
2253
|
+
_context30.next = 41;
|
|
2247
2254
|
break;
|
|
2248
2255
|
}
|
|
2249
2256
|
sellingPrice = toPriceString((_sourceItem$price = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _sourceItem$price !== void 0 ? _sourceItem$price : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.selling_price, '0.00');
|
|
2250
|
-
tempOrder.products.push(normalizeOrderProduct(_objectSpread(_objectSpread({}, sourceItem), {}, {
|
|
2257
|
+
tempOrder.products.push(_objectSpread(_objectSpread({}, normalizeOrderProduct(_objectSpread(_objectSpread({}, sourceItem), {}, {
|
|
2251
2258
|
product_id: productId,
|
|
2252
2259
|
product_variant_id: productVariantId,
|
|
2253
2260
|
num: targetQuantity,
|
|
@@ -2261,14 +2268,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2261
2268
|
item_rule_prefill: true,
|
|
2262
2269
|
item_rule_id: prefillItem.ruleId
|
|
2263
2270
|
})
|
|
2264
|
-
})));
|
|
2271
|
+
}))), displayFields));
|
|
2265
2272
|
hasChanges = true;
|
|
2266
|
-
return _context30.abrupt("continue",
|
|
2267
|
-
case
|
|
2273
|
+
return _context30.abrupt("continue", 49);
|
|
2274
|
+
case 41:
|
|
2268
2275
|
targetProduct = tempOrder.products[productIndex];
|
|
2269
2276
|
existedQuantity = toNonNegativeInt(targetProduct.num);
|
|
2270
2277
|
delta = targetQuantity - existedQuantity;
|
|
2271
|
-
nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), delta > 0 ? {
|
|
2278
|
+
nextProduct = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, targetProduct), displayFields), delta > 0 ? {
|
|
2272
2279
|
num: getSafeProductNum(existedQuantity + delta)
|
|
2273
2280
|
} : {}), {}, {
|
|
2274
2281
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
@@ -2278,52 +2285,53 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2278
2285
|
_origin: sourceItem ? _objectSpread(_objectSpread({}, targetProduct._origin || {}), sourceItem) : targetProduct._origin
|
|
2279
2286
|
});
|
|
2280
2287
|
hasQuantityChanged = delta > 0;
|
|
2288
|
+
hasTitleChanged = Boolean(productTitle && JSON.stringify(targetProduct.product_title) !== JSON.stringify(productTitle));
|
|
2281
2289
|
hasOriginChanged = Boolean(sourceItem && (!targetProduct._origin || ((_origin2 = targetProduct._origin) === null || _origin2 === void 0 ? void 0 : _origin2.name) !== (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.name) || ((_origin3 = targetProduct._origin) === null || _origin3 === void 0 ? void 0 : _origin3.title) !== (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.title) || ((_origin4 = targetProduct._origin) === null || _origin4 === void 0 ? void 0 : _origin4.price) !== (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price)));
|
|
2282
|
-
if (hasQuantityChanged || hasOriginChanged) {
|
|
2290
|
+
if (hasQuantityChanged || hasTitleChanged || hasOriginChanged) {
|
|
2283
2291
|
tempOrder.products[productIndex] = nextProduct;
|
|
2284
2292
|
hasChanges = true;
|
|
2285
2293
|
}
|
|
2286
|
-
case
|
|
2294
|
+
case 49:
|
|
2287
2295
|
_context30.next = 22;
|
|
2288
2296
|
break;
|
|
2289
|
-
case
|
|
2290
|
-
_context30.next =
|
|
2297
|
+
case 51:
|
|
2298
|
+
_context30.next = 56;
|
|
2291
2299
|
break;
|
|
2292
|
-
case
|
|
2293
|
-
_context30.prev =
|
|
2300
|
+
case 53:
|
|
2301
|
+
_context30.prev = 53;
|
|
2294
2302
|
_context30.t0 = _context30["catch"](20);
|
|
2295
2303
|
_iterator6.e(_context30.t0);
|
|
2296
|
-
case
|
|
2297
|
-
_context30.prev =
|
|
2304
|
+
case 56:
|
|
2305
|
+
_context30.prev = 56;
|
|
2298
2306
|
_iterator6.f();
|
|
2299
|
-
return _context30.finish(
|
|
2300
|
-
case
|
|
2307
|
+
return _context30.finish(56);
|
|
2308
|
+
case 59:
|
|
2301
2309
|
if (!hasChanges) {
|
|
2302
|
-
_context30.next =
|
|
2310
|
+
_context30.next = 64;
|
|
2303
2311
|
break;
|
|
2304
2312
|
}
|
|
2305
2313
|
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
2306
2314
|
this.store.order.applyDiscount();
|
|
2307
|
-
_context30.next =
|
|
2315
|
+
_context30.next = 63;
|
|
2308
2316
|
return this.store.order.recalculateSummary({
|
|
2309
2317
|
createIfMissing: true
|
|
2310
2318
|
});
|
|
2311
|
-
case
|
|
2319
|
+
case 63:
|
|
2312
2320
|
this.store.order.persistTempOrder();
|
|
2313
|
-
case
|
|
2314
|
-
_context30.next =
|
|
2321
|
+
case 64:
|
|
2322
|
+
_context30.next = 66;
|
|
2315
2323
|
return this.refreshItemRuleQuantityLimits();
|
|
2316
|
-
case
|
|
2324
|
+
case 66:
|
|
2317
2325
|
this.itemRulePrefillApplied = true;
|
|
2318
2326
|
this.logMethodSuccess('applyPrefillByItemRule', {
|
|
2319
2327
|
prefillCount: prefillItems.length,
|
|
2320
2328
|
hasChanges: hasChanges
|
|
2321
2329
|
});
|
|
2322
|
-
case
|
|
2330
|
+
case 68:
|
|
2323
2331
|
case "end":
|
|
2324
2332
|
return _context30.stop();
|
|
2325
2333
|
}
|
|
2326
|
-
}, _callee30, this, [[20,
|
|
2334
|
+
}, _callee30, this, [[20, 53, 56, 59]]);
|
|
2327
2335
|
}));
|
|
2328
2336
|
function applyPrefillByItemRule() {
|
|
2329
2337
|
return _applyPrefillByItemRule.apply(this, arguments);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLogInput, ScanOrderLoggerModule, ScanOrderLoggerProviderConfig, ScanOrderLoggerProviderType, ScheduleModule } from '../../modules';
|
|
2
2
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
3
|
+
import type { OrderLocalizedText } from '../../modules/Order/types';
|
|
3
4
|
/**
|
|
4
5
|
* 扫码下单流程 hook
|
|
5
6
|
*/
|
|
@@ -43,6 +44,8 @@ export interface ScanOrderProductSku {
|
|
|
43
44
|
}
|
|
44
45
|
export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
|
|
45
46
|
order_detail_id: number | null;
|
|
47
|
+
/** 与 Order 一致的商品展示名称。 */
|
|
48
|
+
product_title?: OrderLocalizedText;
|
|
46
49
|
num: number;
|
|
47
50
|
/** Product 或当前 Variant 的生产编码 */
|
|
48
51
|
production_code?: string;
|
|
@@ -595,7 +595,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
595
595
|
generateIdempotencyToken(): string;
|
|
596
596
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
597
597
|
createOrder(params: CommitOrderParams['query']): {
|
|
598
|
-
type: "
|
|
598
|
+
type: "virtual" | "appointment_booking";
|
|
599
599
|
platform: string;
|
|
600
600
|
sales_channel: string;
|
|
601
601
|
order_sales_channel: string;
|
|
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
328
328
|
date: string;
|
|
329
329
|
status: string;
|
|
330
330
|
week: string;
|
|
331
|
-
weekNum: 0 |
|
|
331
|
+
weekNum: 0 | 5 | 1 | 2 | 4 | 3 | 6;
|
|
332
332
|
}[]>;
|
|
333
333
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
334
334
|
private getScheduleDataByIds;
|
|
@@ -347,7 +347,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
347
347
|
count: number;
|
|
348
348
|
left: number;
|
|
349
349
|
summaryCount: number;
|
|
350
|
-
status: "
|
|
350
|
+
status: "sold_out" | "lots_of_space" | "filling_up_fast";
|
|
351
351
|
}[];
|
|
352
352
|
/**
|
|
353
353
|
* 找到多个资源的公共可用时间段
|
|
@@ -1299,29 +1299,40 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1299
1299
|
if (!Number.isFinite(productId) || targetQuantity <= 0) continue;
|
|
1300
1300
|
if (Number.isNaN(productVariantId)) continue;
|
|
1301
1301
|
const sourceItem = productSourceMap.get((0, _utils.buildProductKey)(productId, productVariantId)) || productSourceMap.get((0, _utils.buildProductKey)(productId, 0)) || null;
|
|
1302
|
+
const sourceTitle = sourceItem?.product_title || sourceItem?.title || sourceItem?.name;
|
|
1303
|
+
const productTitle = typeof sourceTitle === 'string' ? {
|
|
1304
|
+
auto: sourceTitle
|
|
1305
|
+
} : sourceTitle;
|
|
1306
|
+
// 标准标题在归一化后补入,供购物车展示,并由 Order 在折扣重算时保留。
|
|
1307
|
+
const displayFields = productTitle ? {
|
|
1308
|
+
product_title: productTitle
|
|
1309
|
+
} : {};
|
|
1302
1310
|
const productIndex = (0, _utils.getProductIdentityIndex)(tempOrder.products, {
|
|
1303
1311
|
product_id: productId,
|
|
1304
1312
|
product_variant_id: productVariantId
|
|
1305
1313
|
});
|
|
1306
1314
|
if (productIndex === -1) {
|
|
1307
1315
|
const sellingPrice = (0, _utils.toPriceString)(sourceItem?.price ?? sourceItem?.selling_price, '0.00');
|
|
1308
|
-
tempOrder.products.push(
|
|
1309
|
-
...
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1316
|
+
tempOrder.products.push({
|
|
1317
|
+
...(0, _utils.normalizeOrderProduct)({
|
|
1318
|
+
...sourceItem,
|
|
1319
|
+
product_id: productId,
|
|
1320
|
+
product_variant_id: productVariantId,
|
|
1321
|
+
num: targetQuantity,
|
|
1322
|
+
selling_price: sellingPrice,
|
|
1323
|
+
original_price: sellingPrice,
|
|
1324
|
+
metadata: {
|
|
1325
|
+
item_rule_prefill: true,
|
|
1326
|
+
item_rule_id: prefillItem.ruleId
|
|
1327
|
+
},
|
|
1328
|
+
_origin: {
|
|
1329
|
+
...(sourceItem || {}),
|
|
1330
|
+
item_rule_prefill: true,
|
|
1331
|
+
item_rule_id: prefillItem.ruleId
|
|
1332
|
+
}
|
|
1333
|
+
}),
|
|
1334
|
+
...displayFields
|
|
1335
|
+
});
|
|
1325
1336
|
hasChanges = true;
|
|
1326
1337
|
continue;
|
|
1327
1338
|
}
|
|
@@ -1330,6 +1341,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1330
1341
|
const delta = targetQuantity - existedQuantity;
|
|
1331
1342
|
const nextProduct = {
|
|
1332
1343
|
...targetProduct,
|
|
1344
|
+
...displayFields,
|
|
1333
1345
|
...(delta > 0 ? {
|
|
1334
1346
|
num: (0, _utils.getSafeProductNum)(existedQuantity + delta)
|
|
1335
1347
|
} : {}),
|
|
@@ -1344,8 +1356,9 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1344
1356
|
} : targetProduct._origin
|
|
1345
1357
|
};
|
|
1346
1358
|
const hasQuantityChanged = delta > 0;
|
|
1359
|
+
const hasTitleChanged = Boolean(productTitle && JSON.stringify(targetProduct.product_title) !== JSON.stringify(productTitle));
|
|
1347
1360
|
const hasOriginChanged = Boolean(sourceItem && (!targetProduct._origin || targetProduct._origin?.name !== sourceItem?.name || targetProduct._origin?.title !== sourceItem?.title || targetProduct._origin?.price !== sourceItem?.price));
|
|
1348
|
-
if (hasQuantityChanged || hasOriginChanged) {
|
|
1361
|
+
if (hasQuantityChanged || hasTitleChanged || hasOriginChanged) {
|
|
1349
1362
|
tempOrder.products[productIndex] = nextProduct;
|
|
1350
1363
|
hasChanges = true;
|
|
1351
1364
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLogInput, ScanOrderLoggerModule, ScanOrderLoggerProviderConfig, ScanOrderLoggerProviderType, ScheduleModule } from '../../modules';
|
|
2
2
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
3
|
+
import type { OrderLocalizedText } from '../../modules/Order/types';
|
|
3
4
|
/**
|
|
4
5
|
* 扫码下单流程 hook
|
|
5
6
|
*/
|
|
@@ -43,6 +44,8 @@ export interface ScanOrderProductSku {
|
|
|
43
44
|
}
|
|
44
45
|
export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
|
|
45
46
|
order_detail_id: number | null;
|
|
47
|
+
/** 与 Order 一致的商品展示名称。 */
|
|
48
|
+
product_title?: OrderLocalizedText;
|
|
46
49
|
num: number;
|
|
47
50
|
/** Product 或当前 Variant 的生产编码 */
|
|
48
51
|
production_code?: string;
|