@pisell/pisellos 2.3.228 → 2.3.229

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.
@@ -295,6 +295,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
295
295
  private getCustomerContactOrderKey;
296
296
  replaceTempOrder(...args: Parameters<BaseSalesImpl['replaceTempOrder']>): Promise<import("../../modules/Order/types").OrderTempOrder>;
297
297
  private applyDefaultOrderCustomerContactInfo;
298
+ private withAccountNameFallback;
298
299
  private prefillOrderCustomerContactInfo;
299
300
  protected waitForOrderCustomerContactInfo(): Promise<void>;
300
301
  validateContactInfo(): Promise<void>;
@@ -373,7 +374,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
373
374
  * 获取当前的客户搜索条件
374
375
  * @returns 当前搜索条件
375
376
  */
376
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
377
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
377
378
  /**
378
379
  * 获取客户列表状态(包含滚动加载相关状态)
379
380
  * @returns 客户状态
@@ -2047,26 +2047,56 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2047
2047
  }
2048
2048
  return applyDefaultOrderCustomerContactInfo;
2049
2049
  }()
2050
+ }, {
2051
+ key: "withAccountNameFallback",
2052
+ value: function withAccountNameFallback(contact, customer) {
2053
+ var next = contact;
2054
+ // Saved booking contacts take precedence. Only missing name fields fall back
2055
+ // to the account profile; phone/email keep their existing contact-info source.
2056
+ var _iterator2 = _createForOfIteratorHelper(['first_name', 'last_name']),
2057
+ _step2;
2058
+ try {
2059
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2060
+ var field = _step2.value;
2061
+ if (typeof (contact === null || contact === void 0 ? void 0 : contact[field]) === 'string' && contact[field].trim()) continue;
2062
+ var name = customer[field];
2063
+ if (typeof name !== 'string' || !name.trim()) continue;
2064
+ if (next === contact) next = _objectSpread({}, contact);
2065
+ next[field] = name.trim();
2066
+ }
2067
+ } catch (err) {
2068
+ _iterator2.e(err);
2069
+ } finally {
2070
+ _iterator2.f();
2071
+ }
2072
+ return next;
2073
+ }
2050
2074
  }, {
2051
2075
  key: "prefillOrderCustomerContactInfo",
2052
2076
  value: function prefillOrderCustomerContactInfo(customer, customerChanged) {
2053
2077
  var _order$_extend2,
2078
+ _order$contacts_info,
2054
2079
  _this$otherParams9,
2055
2080
  _this5 = this;
2056
2081
  var order = this.getTempOrder();
2057
2082
  var customerId = Number(order === null || order === void 0 ? void 0 : order.customer_id);
2058
- if (!order || !Number.isInteger(customerId) || customerId <= 1 || order.contacts_info != null || (_order$_extend2 = order._extend) !== null && _order$_extend2 !== void 0 && _order$_extend2.contactInfoEdited) return;
2083
+ if (!order || !Number.isInteger(customerId) || customerId <= 1 || (_order$_extend2 = order._extend) !== null && _order$_extend2 !== void 0 && _order$_extend2.contactInfoEdited) return;
2059
2084
  // A restored new cart may already have its customer ID. Existing sales keep their snapshot,
2060
2085
  // even when it is empty; only an explicit customer switch replaces it.
2061
2086
  if (!customerChanged && order.order_id && !String(order.order_id).startsWith('local_order')) return;
2062
- var contact = extractCustomerContactInfo(customer);
2087
+ var contact = (_order$contacts_info = order.contacts_info) !== null && _order$contacts_info !== void 0 ? _order$contacts_info : extractCustomerContactInfo(customer);
2063
2088
  if (contact) {
2064
2089
  this.orderCustomerContactRequest = null;
2065
- void this.applyDefaultOrderCustomerContactInfo(contact);
2090
+ var next = this.withAccountNameFallback(contact, customer);
2091
+ if (next !== order.contacts_info) void this.applyDefaultOrderCustomerContactInfo(next);
2066
2092
  return;
2067
2093
  }
2068
2094
  // A relation explicitly returned as null is authoritative. Only a missing relation needs fetching.
2069
- if (customer.contacts_info !== undefined) return;
2095
+ if (customer.contacts_info !== undefined) {
2096
+ var _next3 = this.withAccountNameFallback(null, customer);
2097
+ if (_next3) void this.applyDefaultOrderCustomerContactInfo(_next3);
2098
+ return;
2099
+ }
2070
2100
  var userPlatform = isCustomerUserPlatform((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.platform);
2071
2101
  var getAuthenticatedCustomerId = function getAuthenticatedCustomerId() {
2072
2102
  var _this5$core, _this5$core$getPlugin, _this5$core$getPlugin2;
@@ -2112,7 +2142,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2112
2142
  return _this5.resolveCustomerById(customerId);
2113
2143
  case 9:
2114
2144
  resolved = _context30.sent;
2115
- return _context30.abrupt("return", Number(resolved === null || resolved === void 0 ? void 0 : resolved.id) === customerId ? extractCustomerContactInfo(resolved) : null);
2145
+ return _context30.abrupt("return", resolved && Number(resolved.id) === customerId ? _this5.withAccountNameFallback(extractCustomerContactInfo(resolved), resolved) : null);
2116
2146
  case 11:
2117
2147
  case "end":
2118
2148
  return _context30.stop();
@@ -2126,7 +2156,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2126
2156
  pending.promise = loadContact().then( /*#__PURE__*/function () {
2127
2157
  var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(value) {
2128
2158
  var _current$_extend;
2129
- var current;
2159
+ var current, next;
2130
2160
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2131
2161
  while (1) switch (_context31.prev = _context31.next) {
2132
2162
  case 0:
@@ -2137,13 +2167,14 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2137
2167
  }
2138
2168
  return _context31.abrupt("return");
2139
2169
  case 3:
2140
- if (!value) {
2141
- _context31.next = 6;
2170
+ next = _this5.withAccountNameFallback(value, customer);
2171
+ if (!next) {
2172
+ _context31.next = 7;
2142
2173
  break;
2143
2174
  }
2144
- _context31.next = 6;
2145
- return _this5.applyDefaultOrderCustomerContactInfo(value);
2146
- case 6:
2175
+ _context31.next = 7;
2176
+ return _this5.applyDefaultOrderCustomerContactInfo(next);
2177
+ case 7:
2147
2178
  case "end":
2148
2179
  return _context31.stop();
2149
2180
  }
@@ -3516,7 +3547,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3516
3547
  var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(input) {
3517
3548
  var _this13 = this,
3518
3549
  _input$bookingPatch;
3519
- var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator2, _step2, line;
3550
+ var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator3, _step3, line;
3520
3551
  return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3521
3552
  while (1) switch (_context46.prev = _context46.next) {
3522
3553
  case 0:
@@ -3553,15 +3584,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3553
3584
  return _context46.abrupt("return", this.store.order.addProductsToOrder(orderLines));
3554
3585
  case 11:
3555
3586
  result = [];
3556
- _iterator2 = _createForOfIteratorHelper(orderLines);
3587
+ _iterator3 = _createForOfIteratorHelper(orderLines);
3557
3588
  _context46.prev = 13;
3558
- _iterator2.s();
3589
+ _iterator3.s();
3559
3590
  case 15:
3560
- if ((_step2 = _iterator2.n()).done) {
3591
+ if ((_step3 = _iterator3.n()).done) {
3561
3592
  _context46.next = 29;
3562
3593
  break;
3563
3594
  }
3564
- line = _step2.value;
3595
+ line = _step3.value;
3565
3596
  _context46.t0 = result.splice;
3566
3597
  _context46.t1 = result;
3567
3598
  _context46.t2 = [0, result.length];
@@ -3582,10 +3613,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3582
3613
  case 31:
3583
3614
  _context46.prev = 31;
3584
3615
  _context46.t7 = _context46["catch"](13);
3585
- _iterator2.e(_context46.t7);
3616
+ _iterator3.e(_context46.t7);
3586
3617
  case 34:
3587
3618
  _context46.prev = 34;
3588
- _iterator2.f();
3619
+ _iterator3.f();
3589
3620
  return _context46.finish(34);
3590
3621
  case 37:
3591
3622
  return _context46.abrupt("return", result);
@@ -1,46 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
- enumerable: true,
8
- get: function () {
9
- return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
- }
11
- });
12
- Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
- enumerable: true,
14
- get: function () {
15
- return _examples.ITEM_REWARD_STRATEGY;
16
- }
17
- });
18
- Object.defineProperty(exports, "PromotionAdapter", {
19
- enumerable: true,
20
- get: function () {
21
- return _adapter.PromotionAdapter;
22
- }
23
- });
24
- Object.defineProperty(exports, "PromotionEvaluator", {
25
- enumerable: true,
26
- get: function () {
27
- return _evaluator.PromotionEvaluator;
28
- }
29
- });
30
- Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
- enumerable: true,
32
- get: function () {
33
- return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
- }
35
- });
36
- Object.defineProperty(exports, "default", {
37
- enumerable: true,
38
- get: function () {
39
- return _adapter.default;
40
- }
41
- });
42
- var _evaluator = require("./evaluator");
43
- var _adapter = _interopRequireWildcard(require("./adapter"));
44
- var _examples = require("./examples");
45
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
1
+ "use strict";
@@ -295,6 +295,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
295
295
  private getCustomerContactOrderKey;
296
296
  replaceTempOrder(...args: Parameters<BaseSalesImpl['replaceTempOrder']>): Promise<import("../../modules/Order/types").OrderTempOrder>;
297
297
  private applyDefaultOrderCustomerContactInfo;
298
+ private withAccountNameFallback;
298
299
  private prefillOrderCustomerContactInfo;
299
300
  protected waitForOrderCustomerContactInfo(): Promise<void>;
300
301
  validateContactInfo(): Promise<void>;
@@ -373,7 +374,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
373
374
  * 获取当前的客户搜索条件
374
375
  * @returns 当前搜索条件
375
376
  */
376
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
377
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
377
378
  /**
378
379
  * 获取客户列表状态(包含滚动加载相关状态)
379
380
  * @returns 客户状态
@@ -1168,21 +1168,41 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1168
1168
  tempOrder: this.getTempOrder()
1169
1169
  });
1170
1170
  }
1171
+ withAccountNameFallback(contact, customer) {
1172
+ let next = contact;
1173
+ // Saved booking contacts take precedence. Only missing name fields fall back
1174
+ // to the account profile; phone/email keep their existing contact-info source.
1175
+ for (const field of ['first_name', 'last_name']) {
1176
+ if (typeof contact?.[field] === 'string' && contact[field].trim()) continue;
1177
+ const name = customer[field];
1178
+ if (typeof name !== 'string' || !name.trim()) continue;
1179
+ if (next === contact) next = {
1180
+ ...contact
1181
+ };
1182
+ next[field] = name.trim();
1183
+ }
1184
+ return next;
1185
+ }
1171
1186
  prefillOrderCustomerContactInfo(customer, customerChanged) {
1172
1187
  const order = this.getTempOrder();
1173
1188
  const customerId = Number(order?.customer_id);
1174
- if (!order || !Number.isInteger(customerId) || customerId <= 1 || order.contacts_info != null || order._extend?.contactInfoEdited) return;
1189
+ if (!order || !Number.isInteger(customerId) || customerId <= 1 || order._extend?.contactInfoEdited) return;
1175
1190
  // A restored new cart may already have its customer ID. Existing sales keep their snapshot,
1176
1191
  // even when it is empty; only an explicit customer switch replaces it.
1177
1192
  if (!customerChanged && order.order_id && !String(order.order_id).startsWith('local_order')) return;
1178
- const contact = (0, _contactInfo.extractCustomerContactInfo)(customer);
1193
+ const contact = order.contacts_info ?? (0, _contactInfo.extractCustomerContactInfo)(customer);
1179
1194
  if (contact) {
1180
1195
  this.orderCustomerContactRequest = null;
1181
- void this.applyDefaultOrderCustomerContactInfo(contact);
1196
+ const next = this.withAccountNameFallback(contact, customer);
1197
+ if (next !== order.contacts_info) void this.applyDefaultOrderCustomerContactInfo(next);
1182
1198
  return;
1183
1199
  }
1184
1200
  // A relation explicitly returned as null is authoritative. Only a missing relation needs fetching.
1185
- if (customer.contacts_info !== undefined) return;
1201
+ if (customer.contacts_info !== undefined) {
1202
+ const next = this.withAccountNameFallback(null, customer);
1203
+ if (next) void this.applyDefaultOrderCustomerContactInfo(next);
1204
+ return;
1205
+ }
1186
1206
  const userPlatform = (0, _platform.isCustomerUserPlatform)(this.otherParams?.platform);
1187
1207
  const getAuthenticatedCustomerId = () => Number(this.core?.getPlugin?.('user')?.get?.()?.id);
1188
1208
  if (userPlatform && getAuthenticatedCustomerId() !== customerId) return;
@@ -1208,12 +1228,13 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1208
1228
  }
1209
1229
  // POS and physical Kiosk share the /shop request plugin and current-shop customer resolver.
1210
1230
  const resolved = await this.resolveCustomerById(customerId);
1211
- return Number(resolved?.id) === customerId ? (0, _contactInfo.extractCustomerContactInfo)(resolved) : null;
1231
+ return resolved && Number(resolved.id) === customerId ? this.withAccountNameFallback((0, _contactInfo.extractCustomerContactInfo)(resolved), resolved) : null;
1212
1232
  };
1213
1233
  pending.promise = loadContact().then(async value => {
1214
1234
  const current = this.getTempOrder();
1215
1235
  if (this.orderCustomerContactRequest !== pending || this.getCustomerContactOrderKey() !== orderKey || Number(current?.customer_id) !== customerId || scope !== this.getCustomerContactScope() || current?._extend?.contactInfoEdited || current?.contacts_info != null || userPlatform && getAuthenticatedCustomerId() !== customerId) return;
1216
- if (value) await this.applyDefaultOrderCustomerContactInfo(value);
1236
+ const next = this.withAccountNameFallback(value, customer);
1237
+ if (next) await this.applyDefaultOrderCustomerContactInfo(next);
1217
1238
  }).catch(() => {
1218
1239
  // A failed default does not prevent manual entry; a subsequent sync can retry.
1219
1240
  if (this.orderCustomerContactRequest === pending) this.orderCustomerContactRequest = null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.228",
4
+ "version": "2.3.229",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",