@pisell/pisellos 2.2.224 → 2.2.226

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.
@@ -419,7 +419,9 @@ function getProductLineNoteSignature(product) {
419
419
  var note = product === null || product === void 0 ? void 0 : product.note;
420
420
  if (typeof note !== 'string') return '';
421
421
  var normalizedNote = note.trim();
422
- return normalizedNote ? "note:".concat(normalizedNote) : '';
422
+ if (!normalizedNote) return '';
423
+ var uid = getOrderProductUid(product);
424
+ return uid ? "note:".concat(uid) : "note:".concat(normalizedNote);
423
425
  }
424
426
  function isPersistedGeneratedVoucher(product) {
425
427
  var _product$order_detail;
@@ -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 | 2 | 1 | 6 | 3 | 4 | 5;
314
+ weekNum: 0 | 2 | 1 | 3 | 6 | 4 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -312,7 +312,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
312
312
  * 获取当前的客户搜索条件
313
313
  * @returns 当前搜索条件
314
314
  */
315
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
315
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
316
316
  /**
317
317
  * 获取客户列表状态(包含滚动加载相关状态)
318
318
  * @returns 客户状态
@@ -300,7 +300,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
300
300
  console.warn('[BookingTicket] idGenerator 插件不可用,跳过配置');
301
301
  return _context4.abrupt("return");
302
302
  case 15:
303
- receiptSequenceLength = this.normalizePositiveInteger((_openDataConfig = openDataConfig) === null || _openDataConfig === void 0 ? void 0 : _openDataConfig['sale.short_number_digits'], 2);
303
+ receiptSequenceLength = this.normalizePositiveInteger((_openDataConfig = openDataConfig) === null || _openDataConfig === void 0 ? void 0 : _openDataConfig['sale.short_number_digits'], 5);
304
304
  receiptSequenceStart = this.normalizePositiveInteger((_openDataConfig2 = openDataConfig) === null || _openDataConfig2 === void 0 ? void 0 : _openDataConfig2['sale.short_number_start_number'], 1);
305
305
  prefix = this.normalizeIdPrefix((_openDataConfig3 = openDataConfig) === null || _openDataConfig3 === void 0 ? void 0 : _openDataConfig3['sale.short_number_prefix'], '');
306
306
  shopOrderPrefix = this.normalizeIdPrefix((_openDataConfig4 = openDataConfig) === null || _openDataConfig4 === void 0 ? void 0 : _openDataConfig4['sale.sale_number_prefix'], '');
@@ -318,7 +318,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
318
318
  prefix: prefix,
319
319
  deviceCode: deviceId,
320
320
  // TODO 现在 picoding 没这个配置的 key
321
- padReceiptSequence: true,
321
+ padReceiptSequence: false,
322
322
  receiptSequenceLength: receiptSequenceLength,
323
323
  resetReceiptSequenceDaily: resetReceiptSequenceDaily,
324
324
  receiptSequenceResetTime: operatingDayBoundary.time,
@@ -1,49 +0,0 @@
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
- });
@@ -294,6 +294,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
294
294
  */
295
295
  updateVoucherOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
296
296
  private shouldMergeProductToOrder;
297
+ private hasOrderProductLineNote;
297
298
  /**
298
299
  * 预约商品加车后的统一收尾:促销、折扣、summary 重算与持久化(批量拆行时只调用一次)。
299
300
  *
@@ -2109,6 +2109,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2109
2109
  }
2110
2110
  return true;
2111
2111
  }
2112
+ hasOrderProductLineNote(product) {
2113
+ return typeof (product == null ? void 0 : product.note) === "string" && product.note.trim().length > 0;
2114
+ }
2112
2115
  // ─── TempOrder: 商品 CRUD ───
2113
2116
  /**
2114
2117
  * 预约商品加车后的统一收尾:促销、折扣、summary 重算与持久化(批量拆行时只调用一次)。
@@ -2150,11 +2153,13 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2150
2153
  const hasIncomingGoodPass = this.hasGoodPassDiscount(
2151
2154
  normalizedIncoming
2152
2155
  );
2153
- const hasIncomingProductNote = typeof normalizedIncoming.note === "string" && normalizedIncoming.note.trim().length > 0;
2156
+ const hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
2154
2157
  const shouldForceNewLine = !!booking || hasIncomingProductNote;
2155
2158
  const matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex((item) => {
2156
2159
  if (this.hasGoodPassDiscount(item))
2157
2160
  return false;
2161
+ if (this.hasOrderProductLineNote(item))
2162
+ return false;
2158
2163
  if (item.order_detail_id !== void 0 && item.order_detail_id !== null)
2159
2164
  return false;
2160
2165
  if (item.product_id !== productToAdd.product_id)
@@ -388,6 +388,9 @@ declare class Server {
388
388
  private taskTimeout;
389
389
  private getShortNumberOrDeviceId;
390
390
  private buildCheckoutTaskIdempotencyKey;
391
+ private isBlankCheckoutValue;
392
+ private isLocalCheckoutOrderId;
393
+ private normalizeCheckoutSubmitData;
391
394
  private ensureCheckoutOrderNumbers;
392
395
  private dispatchCheckoutSyncTask;
393
396
  private dispatchPrintOtherReceiptTask;
@@ -453,6 +456,9 @@ declare class Server {
453
456
  private isMergeableCheckoutOrder;
454
457
  private normalizeCheckoutResponse;
455
458
  private isCheckoutResponseRejected;
459
+ private getUnknownErrorMessage;
460
+ private normalizeUnknownError;
461
+ private safeJsonClone;
456
462
  private extractBackendErrorResponse;
457
463
  private isExplicitBackendErrorResponse;
458
464
  /**
@@ -1249,10 +1249,11 @@ var Server = class {
1249
1249
  });
1250
1250
  return this.taskFail("BACKEND_REJECTED", message, backendError);
1251
1251
  }
1252
- const errorMessage = error instanceof Error ? error.message : String(error);
1252
+ const errorMessage = this.getUnknownErrorMessage(error);
1253
1253
  this.logError(`${title}: sync_sales 请求未明确成功`, {
1254
1254
  backendPath,
1255
- error: errorMessage
1255
+ error: errorMessage,
1256
+ error_detail: this.normalizeUnknownError(error)
1256
1257
  });
1257
1258
  return this.taskTimeout(errorMessage);
1258
1259
  }
@@ -2358,6 +2359,74 @@ var Server = class {
2358
2359
  return void 0;
2359
2360
  return `sync_sales:${identity}`;
2360
2361
  }
2362
+ isBlankCheckoutValue(value) {
2363
+ return value === void 0 || value === null || value === "";
2364
+ }
2365
+ isLocalCheckoutOrderId(orderId) {
2366
+ return typeof orderId === "string" && orderId.startsWith("LOCAL_");
2367
+ }
2368
+ async normalizeCheckoutSubmitData(data, title) {
2369
+ if (!data || typeof data !== "object")
2370
+ return data;
2371
+ const next = { ...data };
2372
+ const externalSaleNumber = next.external_sale_number;
2373
+ const shouldClearLocalOrderId = this.isLocalCheckoutOrderId(next.order_id);
2374
+ if (shouldClearLocalOrderId)
2375
+ next.order_id = null;
2376
+ if (this.isBlankCheckoutValue(externalSaleNumber)) {
2377
+ if (shouldClearLocalOrderId) {
2378
+ this.logInfo(`${title}: checkout 本地订单号已清理`, {
2379
+ original_order_id: data.order_id,
2380
+ order_id: next.order_id
2381
+ });
2382
+ }
2383
+ return next;
2384
+ }
2385
+ if (!this.order || typeof this.order.getLocalOrderByLookup !== "function") {
2386
+ if (shouldClearLocalOrderId) {
2387
+ this.logInfo(`${title}: checkout 本地订单号已清理`, {
2388
+ original_order_id: data.order_id,
2389
+ external_sale_number: externalSaleNumber
2390
+ });
2391
+ }
2392
+ return next;
2393
+ }
2394
+ try {
2395
+ const localOrder = await this.order.getLocalOrderByLookup(externalSaleNumber);
2396
+ if (!localOrder) {
2397
+ if (shouldClearLocalOrderId) {
2398
+ this.logInfo(`${title}: checkout 本地订单号已清理`, {
2399
+ original_order_id: data.order_id,
2400
+ external_sale_number: externalSaleNumber,
2401
+ localOrderFound: false
2402
+ });
2403
+ }
2404
+ return next;
2405
+ }
2406
+ if (this.isBlankCheckoutValue(next.shop_order_number)) {
2407
+ next.shop_order_number = localOrder.shop_order_number;
2408
+ }
2409
+ if (this.isBlankCheckoutValue(next.shop_full_order_number)) {
2410
+ next.shop_full_order_number = localOrder.shop_full_order_number;
2411
+ }
2412
+ this.logInfo(`${title}: checkout 已复用本地订单号`, {
2413
+ original_order_id: data.order_id,
2414
+ order_id: next.order_id,
2415
+ external_sale_number: externalSaleNumber,
2416
+ local_order_id: localOrder.order_id,
2417
+ shop_order_number: next.shop_order_number,
2418
+ shop_full_order_number: next.shop_full_order_number
2419
+ });
2420
+ return next;
2421
+ } catch (error) {
2422
+ this.logWarning(`${title}: checkout 查找本地订单失败`, {
2423
+ external_sale_number: externalSaleNumber,
2424
+ error: this.getUnknownErrorMessage(error),
2425
+ error_detail: this.normalizeUnknownError(error)
2426
+ });
2427
+ return next;
2428
+ }
2429
+ }
2361
2430
  async ensureCheckoutOrderNumbers(data, title) {
2362
2431
  if (!data || typeof data !== "object")
2363
2432
  return data;
@@ -2523,7 +2592,8 @@ var Server = class {
2523
2592
  external_sale_number: data == null ? void 0 : data.external_sale_number,
2524
2593
  order_number: data == null ? void 0 : data.order_number
2525
2594
  });
2526
- const checkoutData = await this.ensureCheckoutOrderNumbers(data, title);
2595
+ const normalizedData = await this.normalizeCheckoutSubmitData(data, title);
2596
+ const checkoutData = await this.ensureCheckoutOrderNumbers(normalizedData, title);
2527
2597
  const pendingResult = await this.handlePendingSyncCheckoutOrder({
2528
2598
  backendPath,
2529
2599
  data: checkoutData,
@@ -3143,6 +3213,69 @@ var Server = class {
3143
3213
  const isErrorSuccess = (normalized == null ? void 0 : normalized.success) === false;
3144
3214
  return isErrorCode || isErrorStatus || isErrorSuccess;
3145
3215
  }
3216
+ getUnknownErrorMessage(error) {
3217
+ var _a, _b, _c, _d, _e, _f;
3218
+ if (error instanceof Error && error.message)
3219
+ return error.message;
3220
+ if (typeof error === "string")
3221
+ return error;
3222
+ const candidates = [
3223
+ error == null ? void 0 : error.message,
3224
+ (_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message,
3225
+ (_c = error == null ? void 0 : error.data) == null ? void 0 : _c.message,
3226
+ (_e = (_d = error == null ? void 0 : error.response) == null ? void 0 : _d.body) == null ? void 0 : _e.message,
3227
+ (_f = error == null ? void 0 : error.body) == null ? void 0 : _f.message
3228
+ ];
3229
+ const message = candidates.find((candidate) => typeof candidate === "string" && candidate !== "");
3230
+ if (message)
3231
+ return message;
3232
+ const normalized = this.normalizeUnknownError(error);
3233
+ if (typeof normalized === "string")
3234
+ return normalized;
3235
+ try {
3236
+ return JSON.stringify(normalized);
3237
+ } catch {
3238
+ return String(error);
3239
+ }
3240
+ }
3241
+ normalizeUnknownError(error) {
3242
+ var _a, _b;
3243
+ if (error instanceof Error) {
3244
+ const normalized = {
3245
+ name: error.name,
3246
+ message: error.message,
3247
+ stack: error.stack
3248
+ };
3249
+ const record = error;
3250
+ if (((_a = record.response) == null ? void 0 : _a.data) !== void 0)
3251
+ normalized.responseData = record.response.data;
3252
+ if (record.data !== void 0)
3253
+ normalized.data = record.data;
3254
+ if (((_b = record.response) == null ? void 0 : _b.body) !== void 0)
3255
+ normalized.responseBody = record.response.body;
3256
+ if (record.body !== void 0)
3257
+ normalized.body = record.body;
3258
+ return this.safeJsonClone(normalized);
3259
+ }
3260
+ if (!error || typeof error !== "object")
3261
+ return String(error);
3262
+ return this.safeJsonClone(error);
3263
+ }
3264
+ safeJsonClone(value) {
3265
+ const seen = /* @__PURE__ */ new WeakSet();
3266
+ try {
3267
+ return JSON.parse(JSON.stringify(value, (_key, current) => {
3268
+ if (!current || typeof current !== "object")
3269
+ return current;
3270
+ if (seen.has(current))
3271
+ return "[Circular]";
3272
+ seen.add(current);
3273
+ return current;
3274
+ }));
3275
+ } catch {
3276
+ return String(value);
3277
+ }
3278
+ }
3146
3279
  extractBackendErrorResponse(error) {
3147
3280
  var _a, _b;
3148
3281
  const candidates = [
@@ -324,7 +324,10 @@ function getProductLineNoteSignature(product) {
324
324
  if (typeof note !== "string")
325
325
  return "";
326
326
  const normalizedNote = note.trim();
327
- return normalizedNote ? `note:${normalizedNote}` : "";
327
+ if (!normalizedNote)
328
+ return "";
329
+ const uid = getOrderProductUid(product);
330
+ return uid ? `note:${uid}` : `note:${normalizedNote}`;
328
331
  }
329
332
  function isPersistedGeneratedVoucher(product) {
330
333
  const orderDetailId = (product == null ? void 0 : product.order_detail_id) ?? (product == null ? void 0 : product.orderDetailId);
@@ -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 | 2 | 1 | 6 | 3 | 4 | 5;
314
+ weekNum: 0 | 2 | 1 | 3 | 6 | 4 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -312,7 +312,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
312
312
  * 获取当前的客户搜索条件
313
313
  * @returns 当前搜索条件
314
314
  */
315
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
315
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
316
316
  /**
317
317
  * 获取客户列表状态(包含滚动加载相关状态)
318
318
  * @returns 客户状态
@@ -185,7 +185,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
185
185
  }
186
186
  const receiptSequenceLength = this.normalizePositiveInteger(
187
187
  openDataConfig == null ? void 0 : openDataConfig["sale.short_number_digits"],
188
- 2
188
+ 5
189
189
  );
190
190
  const receiptSequenceStart = this.normalizePositiveInteger(
191
191
  openDataConfig == null ? void 0 : openDataConfig["sale.short_number_start_number"],
@@ -209,7 +209,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
209
209
  prefix,
210
210
  deviceCode: deviceId,
211
211
  // TODO 现在 picoding 没这个配置的 key
212
- padReceiptSequence: true,
212
+ padReceiptSequence: false,
213
213
  receiptSequenceLength,
214
214
  resetReceiptSequenceDaily,
215
215
  receiptSequenceResetTime: operatingDayBoundary.time,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.224",
4
+ "version": "2.2.226",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",