@pisell/pisellos 2.3.4 → 2.3.6

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.
@@ -154,10 +154,21 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
154
154
  private calculatePaymentTotal;
155
155
  private getDepositAmount;
156
156
  private normalizeDepositAmount;
157
+ private getLastOrderDepositSnapshot;
158
+ private getLastOrderSubmitSnapshot;
157
159
  private applyDepositAmountToSummary;
160
+ private applyLastOrderDepositSnapshot;
158
161
  private isDepositOrder;
159
162
  private getOrderExpectedAmount;
160
163
  private isDepositCovered;
164
+ getPaymentCompletion(payments?: OrderPaymentSource[]): {
165
+ isFullyPaid: boolean;
166
+ isOrderFullyPaid: boolean;
167
+ isDepositFullyPaid: boolean;
168
+ paymentStage: 'deposit' | 'normal';
169
+ depositAmount: string;
170
+ orderExpectedAmount: string;
171
+ };
161
172
  private calculateDepositPaidAmount;
162
173
  private resolveNextOrderPaymentType;
163
174
  private normalizePaymentSource;
@@ -431,7 +442,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
431
442
  generateIdempotencyToken(): string;
432
443
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
433
444
  createOrder(params: CommitOrderParams['query']): {
434
- type: "appointment_booking" | "virtual";
445
+ type: "virtual" | "appointment_booking";
435
446
  platform: string;
436
447
  sales_channel: string;
437
448
  order_sales_channel: string;
@@ -1253,6 +1253,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1253
1253
  value: function normalizeDepositAmount(amount) {
1254
1254
  return Decimal.max(new Decimal(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
1255
1255
  }
1256
+ }, {
1257
+ key: "getLastOrderDepositSnapshot",
1258
+ value: function getLastOrderDepositSnapshot() {
1259
+ var _lastOrderInfo$deposi, _lastOrderInfo$summar;
1260
+ var lastOrderInfo = this.store.lastOrderInfo;
1261
+ if (!lastOrderInfo || _typeof(lastOrderInfo) !== 'object') return null;
1262
+ var rawDepositAmount = (_lastOrderInfo$deposi = lastOrderInfo.deposit_amount) !== null && _lastOrderInfo$deposi !== void 0 ? _lastOrderInfo$deposi : (_lastOrderInfo$summar = lastOrderInfo.summary) === null || _lastOrderInfo$summar === void 0 ? void 0 : _lastOrderInfo$summar.deposit_amount;
1263
+ var depositAmount = this.normalizeDepositAmount(rawDepositAmount !== null && rawDepositAmount !== void 0 ? rawDepositAmount : 0);
1264
+ var hasDepositAmount = new Decimal(depositAmount).gt(0);
1265
+ var isDeposit = Number(lastOrderInfo.is_deposit) === 1 || hasDepositAmount;
1266
+ if (!isDeposit || !hasDepositAmount) return null;
1267
+ return {
1268
+ isDeposit: 1,
1269
+ depositAmount: depositAmount
1270
+ };
1271
+ }
1272
+ }, {
1273
+ key: "getLastOrderSubmitSnapshot",
1274
+ value: function getLastOrderSubmitSnapshot() {
1275
+ var lastOrderInfo = this.store.lastOrderInfo;
1276
+ if (!lastOrderInfo || _typeof(lastOrderInfo) !== 'object') return {};
1277
+ var businessCode = lastOrderInfo.business_code;
1278
+ var type = lastOrderInfo.type;
1279
+ return _objectSpread(_objectSpread({}, typeof businessCode === 'string' && businessCode ? {
1280
+ businessCode: businessCode
1281
+ } : {}), typeof type === 'string' && type ? {
1282
+ type: type
1283
+ } : {});
1284
+ }
1256
1285
  }, {
1257
1286
  key: "applyDepositAmountToSummary",
1258
1287
  value: function applyDepositAmountToSummary(tempOrder, summary, amount) {
@@ -1271,6 +1300,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1271
1300
  tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
1272
1301
  return nextSummary;
1273
1302
  }
1303
+ }, {
1304
+ key: "applyLastOrderDepositSnapshot",
1305
+ value: function applyLastOrderDepositSnapshot(tempOrder, summary) {
1306
+ var snapshot = this.getLastOrderDepositSnapshot();
1307
+ if (!snapshot) return summary;
1308
+ var existedDeposit = summary.deposit && _typeof(summary.deposit) === 'object' ? summary.deposit : undefined;
1309
+ var nextSummary = _objectSpread(_objectSpread({}, summary), {}, {
1310
+ deposit_amount: snapshot.depositAmount,
1311
+ deposit: _objectSpread(_objectSpread({}, existedDeposit || {}), {}, {
1312
+ total: snapshot.depositAmount,
1313
+ deposit_policy_ids: (existedDeposit === null || existedDeposit === void 0 ? void 0 : existedDeposit.deposit_policy_ids) || [],
1314
+ hasDeposit: true
1315
+ })
1316
+ });
1317
+ tempOrder.deposit_amount = snapshot.depositAmount;
1318
+ tempOrder.is_deposit = snapshot.isDeposit;
1319
+ return nextSummary;
1320
+ }
1274
1321
  }, {
1275
1322
  key: "isDepositOrder",
1276
1323
  value: function isDepositOrder(tempOrder, depositAmount) {
@@ -1289,6 +1336,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1289
1336
  if (depositAmount.lte(0)) return false;
1290
1337
  return params.paidAmount.gte(depositAmount);
1291
1338
  }
1339
+ }, {
1340
+ key: "getPaymentCompletion",
1341
+ value: function getPaymentCompletion(payments) {
1342
+ var tempOrder = this.ensureTempOrder();
1343
+ var summary = this.store.summary || createEmptySummary();
1344
+ var paymentList = payments || tempOrder.payments || [];
1345
+ var refundAmount = this.getSummaryRefundAmount(summary);
1346
+ var netPaidAmount = Decimal.max(this.calculatePaymentTotal(paymentList).minus(refundAmount), 0);
1347
+ var depositAmount = this.getDepositAmount(tempOrder, summary);
1348
+ var orderExpectedAmount = this.getOrderExpectedAmount(summary);
1349
+ var isDepositFullyPaid = this.isDepositCovered({
1350
+ tempOrder: tempOrder,
1351
+ summary: summary,
1352
+ paidAmount: netPaidAmount
1353
+ });
1354
+ var isOrderFullyPaid = orderExpectedAmount.lte(0) ? true : netPaidAmount.gte(orderExpectedAmount);
1355
+ var paymentStage = this.isDepositOrder(tempOrder, depositAmount) && !isDepositFullyPaid ? 'deposit' : 'normal';
1356
+ return {
1357
+ isFullyPaid: isOrderFullyPaid,
1358
+ isOrderFullyPaid: isOrderFullyPaid,
1359
+ isDepositFullyPaid: isDepositFullyPaid,
1360
+ paymentStage: paymentStage,
1361
+ depositAmount: depositAmount.toFixed(2),
1362
+ orderExpectedAmount: orderExpectedAmount.toFixed(2)
1363
+ };
1364
+ }
1292
1365
  }, {
1293
1366
  key: "calculateDepositPaidAmount",
1294
1367
  value: function calculateDepositPaidAmount(payments) {
@@ -2494,7 +2567,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2494
2567
  });
2495
2568
  tempOrder.deposit_amount = depositAmount;
2496
2569
  tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
2497
- return nextSummary;
2570
+ return this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
2498
2571
  }
2499
2572
  }, {
2500
2573
  key: "recalculateSummary",
@@ -4267,8 +4340,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4267
4340
  key: "runSubmitTempOrder",
4268
4341
  value: function () {
4269
4342
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4270
- var _params$cacheId2, _this$otherParams5, _ref71, _params$businessCode2, _this$otherParams6, _this$otherParams7;
4271
- var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4343
+ var _params$cacheId2, _this$otherParams5, _ref71, _ref72, _submitSnapshot$busin, _this$otherParams6, _this$otherParams7, _submitSnapshot$type;
4344
+ var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4272
4345
  return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4273
4346
  while (1) switch (_context32.prev = _context32.next) {
4274
4347
  case 0:
@@ -4309,13 +4382,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4309
4382
  var enhancedPayload = params !== null && params !== void 0 && params.enhancePayload ? params.enhancePayload(nextPayload, ctx) : nextPayload;
4310
4383
  return enhancedPayload;
4311
4384
  } : undefined;
4385
+ submitSnapshot = this.getLastOrderSubmitSnapshot();
4312
4386
  payload = buildSubmitPayload({
4313
4387
  tempOrder: tempOrder,
4314
4388
  cacheId: effectiveCacheId,
4315
4389
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
4316
- businessCode: (_ref71 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref71 !== void 0 ? _ref71 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
4390
+ businessCode: (_ref71 = (_ref72 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref72 !== void 0 ? _ref72 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref71 !== void 0 ? _ref71 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
4317
4391
  channel: params === null || params === void 0 ? void 0 : params.channel,
4318
- type: params === null || params === void 0 ? void 0 : params.type,
4392
+ type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
4319
4393
  summary: latestSummary,
4320
4394
  request_unique_idempotency_token: params === null || params === void 0 ? void 0 : params.request_unique_idempotency_token,
4321
4395
  enhance: enhancePayload
@@ -4327,10 +4401,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4327
4401
  if (!payload.created_at) {
4328
4402
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4329
4403
  }
4330
- _context32.next = 21;
4404
+ _context32.next = 22;
4331
4405
  return this.saveDraft();
4332
- case 21:
4333
- _context32.prev = 21;
4406
+ case 22:
4407
+ _context32.prev = 22;
4334
4408
  this.logInfo('submitTempOrder calling sales checkout', {
4335
4409
  orderId: payload.order_id,
4336
4410
  externalSaleNumber: payload.external_sale_number,
@@ -4340,26 +4414,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4340
4414
  smallTicketDataFlag: payload.small_ticket_data_flag,
4341
4415
  syncMode: payload.sync_mode
4342
4416
  });
4343
- _context32.next = 25;
4417
+ _context32.next = 26;
4344
4418
  return this.submitSalesOrder({
4345
4419
  query: payload
4346
4420
  });
4347
- case 25:
4421
+ case 26:
4348
4422
  result = _context32.sent;
4349
- _context32.next = 38;
4423
+ _context32.next = 39;
4350
4424
  break;
4351
- case 28:
4352
- _context32.prev = 28;
4353
- _context32.t2 = _context32["catch"](21);
4425
+ case 29:
4426
+ _context32.prev = 29;
4427
+ _context32.t2 = _context32["catch"](22);
4354
4428
  backendErrorResponse = this.extractSubmitErrorResponse(_context32.t2);
4355
4429
  if (!backendErrorResponse) {
4356
- _context32.next = 35;
4430
+ _context32.next = 36;
4357
4431
  break;
4358
4432
  }
4359
4433
  this.store.syncState = 'failed';
4360
4434
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4361
4435
  return _context32.abrupt("return", backendErrorResponse);
4362
- case 35:
4436
+ case 36:
4363
4437
  this.store.syncState = 'failed';
4364
4438
  this.logError('submitTempOrder failed', {
4365
4439
  error: _context32.t2 instanceof Error ? _context32.t2.message : String(_context32.t2),
@@ -4369,15 +4443,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4369
4443
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4370
4444
  });
4371
4445
  throw _context32.t2;
4372
- case 38:
4446
+ case 39:
4373
4447
  if (!this.isSubmitResponseRejected(result)) {
4374
- _context32.next = 42;
4448
+ _context32.next = 43;
4375
4449
  break;
4376
4450
  }
4377
4451
  this.store.syncState = 'failed';
4378
4452
  this.logSubmitBackendRejected(result, payload);
4379
4453
  return _context32.abrupt("return", result);
4380
- case 42:
4454
+ case 43:
4381
4455
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4382
4456
  this.logInfo('runSubmitTempOrder: 提交成功', {
4383
4457
  submittedOrderId: submittedOrderId,
@@ -4385,29 +4459,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4385
4459
  tempOrder: tempOrder
4386
4460
  });
4387
4461
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4388
- _context32.next = 51;
4462
+ _context32.next = 52;
4389
4463
  break;
4390
4464
  }
4391
4465
  tempOrder.order_id = submittedOrderId;
4392
4466
  resultRecord = result;
4393
- _context32.next = 49;
4467
+ _context32.next = 50;
4394
4468
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4395
- case 49:
4396
- _context32.next = 52;
4469
+ case 50:
4470
+ _context32.next = 53;
4397
4471
  break;
4398
- case 51:
4472
+ case 52:
4399
4473
  if (this.isLocalPendingSubmitResult(result)) {
4400
4474
  this.store.syncState = 'local';
4401
4475
  } else {
4402
4476
  this.store.syncState = 'submitted';
4403
4477
  }
4404
- case 52:
4405
- return _context32.abrupt("return", result);
4406
4478
  case 53:
4479
+ return _context32.abrupt("return", result);
4480
+ case 54:
4407
4481
  case "end":
4408
4482
  return _context32.stop();
4409
4483
  }
4410
- }, _callee29, this, [[21, 28]]);
4484
+ }, _callee29, this, [[22, 29]]);
4411
4485
  }));
4412
4486
  function runSubmitTempOrder(_x32) {
4413
4487
  return _runSubmitTempOrder.apply(this, arguments);
@@ -4510,41 +4584,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4510
4584
  key: "syncPaymentsToOrder",
4511
4585
  value: function () {
4512
4586
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4513
- var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4587
+ var tempOrder, mappedPayments, completion, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4514
4588
  return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4515
4589
  while (1) switch (_context34.prev = _context34.next) {
4516
4590
  case 0:
4517
4591
  tempOrder = this.ensureTempOrder();
4518
4592
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
4519
- paymentTotal = this.calculatePaymentTotal(mappedPayments);
4520
- targetAmount = this.getPaymentTargetAmount();
4521
- isFullyPaid = targetAmount.lte(0) ? true : paymentTotal.gte(targetAmount);
4522
- paymentStatus = isFullyPaid ? params.paymentStatus || 'paid' : 'partially_paid';
4593
+ completion = this.getPaymentCompletion(mappedPayments);
4594
+ paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : 'partially_paid';
4523
4595
  tempOrder.payments = mappedPayments;
4524
4596
  tempOrder.payment_status = paymentStatus;
4525
4597
  this.persistTempOrder();
4526
- _context34.next = 11;
4598
+ _context34.next = 9;
4527
4599
  return this.saveDraft();
4528
- case 11:
4600
+ case 9:
4529
4601
  if (params.submitWhenPaid) {
4530
- _context34.next = 13;
4602
+ _context34.next = 11;
4531
4603
  break;
4532
4604
  }
4533
- return _context34.abrupt("return", {
4534
- isFullyPaid: isFullyPaid
4535
- });
4536
- case 13:
4605
+ return _context34.abrupt("return", completion);
4606
+ case 11:
4537
4607
  if (!(this.store.syncState === 'submitting')) {
4538
- _context34.next = 15;
4608
+ _context34.next = 13;
4539
4609
  break;
4540
4610
  }
4541
- return _context34.abrupt("return", {
4542
- isFullyPaid: isFullyPaid
4543
- });
4544
- case 15:
4611
+ return _context34.abrupt("return", completion);
4612
+ case 13:
4545
4613
  this.store.syncState = 'submitting';
4546
4614
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, mappedPayments);
4547
- _context34.next = 19;
4615
+ _context34.next = 17;
4548
4616
  return this.submitTempOrder({
4549
4617
  payments: mappedPayments,
4550
4618
  paymentStatus: paymentStatus,
@@ -4558,13 +4626,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4558
4626
  return nextPayload;
4559
4627
  }
4560
4628
  });
4561
- case 19:
4629
+ case 17:
4562
4630
  submitResult = _context34.sent;
4563
- return _context34.abrupt("return", {
4564
- isFullyPaid: isFullyPaid,
4631
+ return _context34.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
4565
4632
  submitResult: submitResult
4566
- });
4567
- case 21:
4633
+ }));
4634
+ case 19:
4568
4635
  case "end":
4569
4636
  return _context34.stop();
4570
4637
  }
@@ -5200,7 +5267,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5200
5267
  _step22;
5201
5268
  try {
5202
5269
  for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
5203
- var _product$metadata8, _ref72, _ref73, _existed$origin, _rawProduct$metadata;
5270
+ var _product$metadata8, _ref73, _ref74, _existed$origin, _rawProduct$metadata;
5204
5271
  var _step22$value = _slicedToArray(_step22.value, 2),
5205
5272
  index = _step22$value[0],
5206
5273
  product = _step22$value[1];
@@ -5208,7 +5275,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5208
5275
  if (!uid) continue;
5209
5276
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
5210
5277
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
5211
- var origin = (_ref72 = (_ref73 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref73 !== void 0 ? _ref73 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref72 !== void 0 ? _ref72 : rawProduct;
5278
+ var origin = (_ref73 = (_ref74 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref74 !== void 0 ? _ref74 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref73 !== void 0 ? _ref73 : rawProduct;
5212
5279
  var originSnapshot = cloneDeep(origin);
5213
5280
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
5214
5281
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -5318,10 +5385,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5318
5385
  }, {
5319
5386
  key: "normalizeHydratedProductOptionItem",
5320
5387
  value: function normalizeHydratedProductOptionItem(optionItem) {
5321
- var _ref74, _optionItem$num, _ref75, _optionItem$add_price;
5322
- var rawNum = (_ref74 = (_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 && _ref74 !== void 0 ? _ref74 : 1;
5388
+ var _ref75, _optionItem$num, _ref76, _optionItem$add_price;
5389
+ var rawNum = (_ref75 = (_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 && _ref75 !== void 0 ? _ref75 : 1;
5323
5390
  var parsedNum = Number(rawNum);
5324
- var rawPrice = (_ref75 = (_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 && _ref75 !== void 0 ? _ref75 : 0;
5391
+ var rawPrice = (_ref76 = (_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 && _ref76 !== void 0 ? _ref76 : 0;
5325
5392
  var parsedPrice = Number(rawPrice);
5326
5393
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
5327
5394
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -5448,10 +5515,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5448
5515
  _step27;
5449
5516
  try {
5450
5517
  for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
5451
- var _ref76, _bundle$num3;
5518
+ var _ref77, _bundle$num3;
5452
5519
  var bundle = _step27.value;
5453
5520
  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));
5454
- var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref76 = (_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 && _ref76 !== void 0 ? _ref76 : 1) || 1).toNumber();
5521
+ var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref77 = (_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 && _ref77 !== void 0 ? _ref77 : 1) || 1).toNumber();
5455
5522
  var _iterator28 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
5456
5523
  _step28;
5457
5524
  try {
@@ -540,6 +540,11 @@ export interface SyncPaymentsToOrderParams {
540
540
  }
541
541
  export interface SyncPaymentsToOrderResult<T = any> {
542
542
  isFullyPaid: boolean;
543
+ isOrderFullyPaid: boolean;
544
+ isDepositFullyPaid: boolean;
545
+ paymentStage: 'deposit' | 'normal';
546
+ depositAmount: string;
547
+ orderExpectedAmount: string;
543
548
  submitResult?: T;
544
549
  }
545
550
  export interface OrderIdentitySnapshot {
@@ -318,6 +318,13 @@ declare class Server {
318
318
  * this.extractQueryDate('2026-04-15 09:58:00') // => '2026-04-15'
319
319
  */
320
320
  private extractQueryDate;
321
+ /**
322
+ * 判断时间范围是否完整落在今天。
323
+ *
324
+ * @example
325
+ * this.isRangeFullyToday('2026-04-15', '2026-04-15') // => true
326
+ */
327
+ private isRangeFullyToday;
321
328
  /**
322
329
  * 判断时间范围是否「开始和结束都不是今天」。
323
330
  *
@@ -327,8 +334,8 @@ declare class Server {
327
334
  private isRangeBothNotToday;
328
335
  /**
329
336
  * 订单查询是否走本地:
330
- * - start_time 与 end_time 都不是今天时,走远端;
331
- * - 其余情况走本地。
337
+ * - 仅当 start_time 与 end_time 都是今天时,走本地;
338
+ * - 任意一端不是今天时,走云端,确保跨天查询能拉取非本地窗口数据。
332
339
  */
333
340
  private shouldUseLocalOrderQuery;
334
341
  /**
@@ -1205,7 +1205,7 @@ var Server = /*#__PURE__*/function () {
1205
1205
  _context17.prev = 41;
1206
1206
  _context17.t0 = _context17["catch"](21);
1207
1207
  errorMessage = _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0);
1208
- _this.logError('handleOrderSalesDetail: 请求失败', {
1208
+ _this.logInfo('handleOrderSalesDetail: 请求失败', {
1209
1209
  lookup: lookup,
1210
1210
  backendPath: backendPath,
1211
1211
  error: errorMessage
@@ -3247,6 +3247,22 @@ var Server = /*#__PURE__*/function () {
3247
3247
  return text.split('T')[0].split(' ')[0] || null;
3248
3248
  }
3249
3249
 
3250
+ /**
3251
+ * 判断时间范围是否完整落在今天。
3252
+ *
3253
+ * @example
3254
+ * this.isRangeFullyToday('2026-04-15', '2026-04-15') // => true
3255
+ */
3256
+ }, {
3257
+ key: "isRangeFullyToday",
3258
+ value: function isRangeFullyToday(startRaw, endRaw) {
3259
+ var startDate = this.extractQueryDate(startRaw);
3260
+ var endDate = this.extractQueryDate(endRaw);
3261
+ if (!startDate || !endDate) return false;
3262
+ var today = dayjs().format('YYYY-MM-DD');
3263
+ return startDate === today && endDate === today;
3264
+ }
3265
+
3250
3266
  /**
3251
3267
  * 判断时间范围是否「开始和结束都不是今天」。
3252
3268
  *
@@ -3265,13 +3281,13 @@ var Server = /*#__PURE__*/function () {
3265
3281
 
3266
3282
  /**
3267
3283
  * 订单查询是否走本地:
3268
- * - start_time 与 end_time 都不是今天时,走远端;
3269
- * - 其余情况走本地。
3284
+ * - 仅当 start_time 与 end_time 都是今天时,走本地;
3285
+ * - 任意一端不是今天时,走云端,确保跨天查询能拉取非本地窗口数据。
3270
3286
  */
3271
3287
  }, {
3272
3288
  key: "shouldUseLocalOrderQuery",
3273
3289
  value: function shouldUseLocalOrderQuery(data) {
3274
- return !this.isRangeBothNotToday(data === null || data === void 0 ? void 0 : data.start_time, data === null || data === void 0 ? void 0 : data.end_time);
3290
+ return this.isRangeFullyToday(data === null || data === void 0 ? void 0 : data.start_time, data === null || data === void 0 ? void 0 : data.end_time);
3275
3291
  }
3276
3292
 
3277
3293
  /**
@@ -4668,9 +4684,9 @@ var Server = /*#__PURE__*/function () {
4668
4684
  }, {
4669
4685
  key: "shouldBuildSmallTicketData",
4670
4686
  value: function shouldBuildSmallTicketData(order) {
4671
- var _order$payment_info, _ref54, _order$small_ticket_d;
4687
+ var _ref54, _order$small_ticket_d;
4672
4688
  if (!order || _typeof(order) !== 'object') return false;
4673
- if (hasSmallTicketData((_order$payment_info = order.payment_info) === null || _order$payment_info === void 0 ? void 0 : _order$payment_info.small_ticket_data)) return false;
4689
+ // if (hasSmallTicketData(order.payment_info?.small_ticket_data)) return false;
4674
4690
  return Number((_ref54 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref54 !== void 0 ? _ref54 : 0) === 1;
4675
4691
  }
4676
4692
  }, {
@@ -2261,7 +2261,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2261
2261
  value: function () {
2262
2262
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2263
2263
  var _ref18, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
2264
- var businessCode, channel, syncParams, syncState, payments, syncResult;
2264
+ var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
2265
2265
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2266
2266
  while (1) switch (_context24.prev = _context24.next) {
2267
2267
  case 0:
@@ -2299,21 +2299,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2299
2299
  return this.store.order.syncPaymentsToOrder(syncParams);
2300
2300
  case 14:
2301
2301
  syncResult = _context24.sent;
2302
- _context24.next = 17;
2303
- return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
2302
+ latestPayments = this.store.order.getOrderPayments();
2303
+ amountSnapshot = this.store.order.getOrderAmountSnapshot();
2304
+ orderSnapshot = this.store.order.getOrderSnapshot();
2305
+ syncPayload = {
2304
2306
  ok: true,
2305
2307
  syncResult: syncResult,
2306
- payments: this.store.order.getOrderPayments(),
2308
+ payments: latestPayments,
2307
2309
  params: syncParams,
2308
- amountSnapshot: this.store.order.getOrderAmountSnapshot(),
2309
- orderSnapshot: this.store.order.getOrderSnapshot()
2310
- });
2311
- case 17:
2310
+ amountSnapshot: amountSnapshot,
2311
+ orderSnapshot: orderSnapshot,
2312
+ isFullyPaid: syncResult.isFullyPaid,
2313
+ isOrderFullyPaid: syncResult.isOrderFullyPaid,
2314
+ isDepositFullyPaid: syncResult.isDepositFullyPaid,
2315
+ paymentStage: syncResult.paymentStage,
2316
+ depositAmount: syncResult.depositAmount,
2317
+ orderExpectedAmount: syncResult.orderExpectedAmount
2318
+ };
2319
+ _context24.next = 21;
2320
+ return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
2321
+ case 21:
2322
+ if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
2323
+ _context24.next = 24;
2324
+ break;
2325
+ }
2326
+ _context24.next = 24;
2327
+ return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
2328
+ case 24:
2312
2329
  return _context24.abrupt("return", syncResult);
2313
- case 20:
2314
- _context24.prev = 20;
2330
+ case 27:
2331
+ _context24.prev = 27;
2315
2332
  _context24.t0 = _context24["catch"](11);
2316
- _context24.next = 24;
2333
+ _context24.next = 31;
2317
2334
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
2318
2335
  ok: false,
2319
2336
  error: _context24.t0,
@@ -2322,13 +2339,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2322
2339
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
2323
2340
  orderSnapshot: this.store.order.getOrderSnapshot()
2324
2341
  });
2325
- case 24:
2342
+ case 31:
2326
2343
  throw _context24.t0;
2327
- case 25:
2344
+ case 32:
2328
2345
  case "end":
2329
2346
  return _context24.stop();
2330
2347
  }
2331
- }, _callee24, this, [[11, 20]]);
2348
+ }, _callee24, this, [[11, 27]]);
2332
2349
  }));
2333
2350
  function syncPaymentsToOrder(_x20) {
2334
2351
  return _syncPaymentsToOrder.apply(this, arguments);
@@ -2393,7 +2410,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2393
2410
  var amountSnapshot = this.store.order.getOrderAmountSnapshot();
2394
2411
  var syncState = this.store.order.getOrderSyncState();
2395
2412
  if (amountSnapshot && syncState !== 'submitting') {
2396
- var paymentStatus = Number(amountSnapshot.amountGap || 0) <= 0 ? 'paid' : 'partially_paid';
2413
+ var completion = this.store.order.getPaymentCompletion(payments);
2414
+ var paymentStatus = completion.isOrderFullyPaid ? 'paid' : 'partially_paid';
2397
2415
  void this.syncPaymentsToOrder({
2398
2416
  payments: payments,
2399
2417
  paymentStatus: paymentStatus,
@@ -14,6 +14,7 @@ export declare const BaseSalesHookNames: {
14
14
  readonly onCartValidationChanged: "onCartValidationChanged";
15
15
  readonly onPaymentSyncStart: "onPaymentSyncStart";
16
16
  readonly onPaymentSyncEnd: "onPaymentSyncEnd";
17
+ readonly onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd";
17
18
  };
18
19
  export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSalesHookNames];
19
20
  export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
@@ -9,7 +9,8 @@ export var BaseSalesHookNames = {
9
9
  onRefresh: 'onRefresh',
10
10
  onCartValidationChanged: 'onCartValidationChanged',
11
11
  onPaymentSyncStart: 'onPaymentSyncStart',
12
- onPaymentSyncEnd: 'onPaymentSyncEnd'
12
+ onPaymentSyncEnd: 'onPaymentSyncEnd',
13
+ onDepositPaymentSyncEnd: 'onDepositPaymentSyncEnd'
13
14
  };
14
15
  export function createBaseSalesHook(moduleName, hookName) {
15
16
  return "".concat(moduleName, ":").concat(hookName);
@@ -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 | 5 | 3 | 4 | 6;
314
+ weekNum: 0 | 1 | 2 | 6 | 3 | 4 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -154,10 +154,21 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
154
154
  private calculatePaymentTotal;
155
155
  private getDepositAmount;
156
156
  private normalizeDepositAmount;
157
+ private getLastOrderDepositSnapshot;
158
+ private getLastOrderSubmitSnapshot;
157
159
  private applyDepositAmountToSummary;
160
+ private applyLastOrderDepositSnapshot;
158
161
  private isDepositOrder;
159
162
  private getOrderExpectedAmount;
160
163
  private isDepositCovered;
164
+ getPaymentCompletion(payments?: OrderPaymentSource[]): {
165
+ isFullyPaid: boolean;
166
+ isOrderFullyPaid: boolean;
167
+ isDepositFullyPaid: boolean;
168
+ paymentStage: 'deposit' | 'normal';
169
+ depositAmount: string;
170
+ orderExpectedAmount: string;
171
+ };
161
172
  private calculateDepositPaidAmount;
162
173
  private resolveNextOrderPaymentType;
163
174
  private normalizePaymentSource;
@@ -431,7 +442,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
431
442
  generateIdempotencyToken(): string;
432
443
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
433
444
  createOrder(params: CommitOrderParams['query']): {
434
- type: "appointment_booking" | "virtual";
445
+ type: "virtual" | "appointment_booking";
435
446
  platform: string;
436
447
  sales_channel: string;
437
448
  order_sales_channel: string;
@@ -825,6 +825,33 @@ var OrderModule = class extends import_BaseModule.BaseModule {
825
825
  normalizeDepositAmount(amount) {
826
826
  return import_decimal.default.max(new import_decimal.default(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
827
827
  }
828
+ getLastOrderDepositSnapshot() {
829
+ var _a;
830
+ const lastOrderInfo = this.store.lastOrderInfo;
831
+ if (!lastOrderInfo || typeof lastOrderInfo !== "object")
832
+ return null;
833
+ const rawDepositAmount = lastOrderInfo.deposit_amount ?? ((_a = lastOrderInfo.summary) == null ? void 0 : _a.deposit_amount);
834
+ const depositAmount = this.normalizeDepositAmount(rawDepositAmount ?? 0);
835
+ const hasDepositAmount = new import_decimal.default(depositAmount).gt(0);
836
+ const isDeposit = Number(lastOrderInfo.is_deposit) === 1 || hasDepositAmount;
837
+ if (!isDeposit || !hasDepositAmount)
838
+ return null;
839
+ return {
840
+ isDeposit: 1,
841
+ depositAmount
842
+ };
843
+ }
844
+ getLastOrderSubmitSnapshot() {
845
+ const lastOrderInfo = this.store.lastOrderInfo;
846
+ if (!lastOrderInfo || typeof lastOrderInfo !== "object")
847
+ return {};
848
+ const businessCode = lastOrderInfo.business_code;
849
+ const type = lastOrderInfo.type;
850
+ return {
851
+ ...typeof businessCode === "string" && businessCode ? { businessCode } : {},
852
+ ...typeof type === "string" && type ? { type } : {}
853
+ };
854
+ }
828
855
  applyDepositAmountToSummary(tempOrder, summary, amount) {
829
856
  const depositAmount = this.normalizeDepositAmount(amount);
830
857
  const hasDepositAmount = new import_decimal.default(depositAmount).gt(0);
@@ -843,6 +870,25 @@ var OrderModule = class extends import_BaseModule.BaseModule {
843
870
  tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
844
871
  return nextSummary;
845
872
  }
873
+ applyLastOrderDepositSnapshot(tempOrder, summary) {
874
+ const snapshot = this.getLastOrderDepositSnapshot();
875
+ if (!snapshot)
876
+ return summary;
877
+ const existedDeposit = summary.deposit && typeof summary.deposit === "object" ? summary.deposit : void 0;
878
+ const nextSummary = {
879
+ ...summary,
880
+ deposit_amount: snapshot.depositAmount,
881
+ deposit: {
882
+ ...existedDeposit || {},
883
+ total: snapshot.depositAmount,
884
+ deposit_policy_ids: (existedDeposit == null ? void 0 : existedDeposit.deposit_policy_ids) || [],
885
+ hasDeposit: true
886
+ }
887
+ };
888
+ tempOrder.deposit_amount = snapshot.depositAmount;
889
+ tempOrder.is_deposit = snapshot.isDeposit;
890
+ return nextSummary;
891
+ }
846
892
  isDepositOrder(tempOrder, depositAmount) {
847
893
  return tempOrder.is_deposit === 1 || depositAmount.gt(0);
848
894
  }
@@ -857,6 +903,33 @@ var OrderModule = class extends import_BaseModule.BaseModule {
857
903
  return false;
858
904
  return params.paidAmount.gte(depositAmount);
859
905
  }
906
+ getPaymentCompletion(payments) {
907
+ const tempOrder = this.ensureTempOrder();
908
+ const summary = this.store.summary || (0, import_utils.createEmptySummary)();
909
+ const paymentList = payments || tempOrder.payments || [];
910
+ const refundAmount = this.getSummaryRefundAmount(summary);
911
+ const netPaidAmount = import_decimal.default.max(
912
+ this.calculatePaymentTotal(paymentList).minus(refundAmount),
913
+ 0
914
+ );
915
+ const depositAmount = this.getDepositAmount(tempOrder, summary);
916
+ const orderExpectedAmount = this.getOrderExpectedAmount(summary);
917
+ const isDepositFullyPaid = this.isDepositCovered({
918
+ tempOrder,
919
+ summary,
920
+ paidAmount: netPaidAmount
921
+ });
922
+ const isOrderFullyPaid = orderExpectedAmount.lte(0) ? true : netPaidAmount.gte(orderExpectedAmount);
923
+ const paymentStage = this.isDepositOrder(tempOrder, depositAmount) && !isDepositFullyPaid ? "deposit" : "normal";
924
+ return {
925
+ isFullyPaid: isOrderFullyPaid,
926
+ isOrderFullyPaid,
927
+ isDepositFullyPaid,
928
+ paymentStage,
929
+ depositAmount: depositAmount.toFixed(2),
930
+ orderExpectedAmount: orderExpectedAmount.toFixed(2)
931
+ };
932
+ }
860
933
  calculateDepositPaidAmount(payments) {
861
934
  return (payments || []).reduce((sum, payment) => {
862
935
  const paymentRecord = payment;
@@ -1802,7 +1875,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1802
1875
  };
1803
1876
  tempOrder.deposit_amount = depositAmount;
1804
1877
  tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
1805
- return nextSummary;
1878
+ return this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
1806
1879
  }
1807
1880
  async recalculateSummary(options) {
1808
1881
  const tempOrder = (options == null ? void 0 : options.createIfMissing) ? this.ensureTempOrder() : this.store.tempOrder;
@@ -3128,13 +3201,14 @@ var OrderModule = class extends import_BaseModule.BaseModule {
3128
3201
  const enhancedPayload = (params == null ? void 0 : params.enhancePayload) ? params.enhancePayload(nextPayload, ctx) : nextPayload;
3129
3202
  return enhancedPayload;
3130
3203
  } : void 0;
3204
+ const submitSnapshot = this.getLastOrderSubmitSnapshot();
3131
3205
  const payload = (0, import_utils.buildSubmitPayload)({
3132
3206
  tempOrder,
3133
3207
  cacheId: effectiveCacheId,
3134
3208
  platform: (params == null ? void 0 : params.platform) || ((_a = this.otherParams) == null ? void 0 : _a.platform),
3135
- businessCode: (params == null ? void 0 : params.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code),
3209
+ businessCode: submitSnapshot.businessCode ?? (params == null ? void 0 : params.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code),
3136
3210
  channel: params == null ? void 0 : params.channel,
3137
- type: params == null ? void 0 : params.type,
3211
+ type: submitSnapshot.type ?? (params == null ? void 0 : params.type),
3138
3212
  summary: latestSummary,
3139
3213
  request_unique_idempotency_token: params == null ? void 0 : params.request_unique_idempotency_token,
3140
3214
  enhance: enhancePayload
@@ -3272,19 +3346,17 @@ var OrderModule = class extends import_BaseModule.BaseModule {
3272
3346
  const mappedPayments = (0, import_utils.mapPaymentItemsToOrderPayments)(
3273
3347
  params.payments || []
3274
3348
  );
3275
- const paymentTotal = this.calculatePaymentTotal(mappedPayments);
3276
- const targetAmount = this.getPaymentTargetAmount();
3277
- const isFullyPaid = targetAmount.lte(0) ? true : paymentTotal.gte(targetAmount);
3278
- const paymentStatus = isFullyPaid ? params.paymentStatus || "paid" : "partially_paid";
3349
+ const completion = this.getPaymentCompletion(mappedPayments);
3350
+ const paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || "paid" : "partially_paid";
3279
3351
  tempOrder.payments = mappedPayments;
3280
3352
  tempOrder.payment_status = paymentStatus;
3281
3353
  this.persistTempOrder();
3282
3354
  await this.saveDraft();
3283
3355
  if (!params.submitWhenPaid) {
3284
- return { isFullyPaid };
3356
+ return completion;
3285
3357
  }
3286
3358
  if (this.store.syncState === "submitting") {
3287
- return { isFullyPaid };
3359
+ return completion;
3288
3360
  }
3289
3361
  this.store.syncState = "submitting";
3290
3362
  const paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(
@@ -3305,7 +3377,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
3305
3377
  return nextPayload;
3306
3378
  }
3307
3379
  });
3308
- return { isFullyPaid, submitResult };
3380
+ return { ...completion, submitResult };
3309
3381
  }
3310
3382
  createOrder(params) {
3311
3383
  var _a;
@@ -540,6 +540,11 @@ export interface SyncPaymentsToOrderParams {
540
540
  }
541
541
  export interface SyncPaymentsToOrderResult<T = any> {
542
542
  isFullyPaid: boolean;
543
+ isOrderFullyPaid: boolean;
544
+ isDepositFullyPaid: boolean;
545
+ paymentStage: 'deposit' | 'normal';
546
+ depositAmount: string;
547
+ orderExpectedAmount: string;
543
548
  submitResult?: T;
544
549
  }
545
550
  export interface OrderIdentitySnapshot {
@@ -318,6 +318,13 @@ declare class Server {
318
318
  * this.extractQueryDate('2026-04-15 09:58:00') // => '2026-04-15'
319
319
  */
320
320
  private extractQueryDate;
321
+ /**
322
+ * 判断时间范围是否完整落在今天。
323
+ *
324
+ * @example
325
+ * this.isRangeFullyToday('2026-04-15', '2026-04-15') // => true
326
+ */
327
+ private isRangeFullyToday;
321
328
  /**
322
329
  * 判断时间范围是否「开始和结束都不是今天」。
323
330
  *
@@ -327,8 +334,8 @@ declare class Server {
327
334
  private isRangeBothNotToday;
328
335
  /**
329
336
  * 订单查询是否走本地:
330
- * - start_time 与 end_time 都不是今天时,走远端;
331
- * - 其余情况走本地。
337
+ * - 仅当 start_time 与 end_time 都是今天时,走本地;
338
+ * - 任意一端不是今天时,走云端,确保跨天查询能拉取非本地窗口数据。
332
339
  */
333
340
  private shouldUseLocalOrderQuery;
334
341
  /**
@@ -737,7 +737,7 @@ var Server = class {
737
737
  };
738
738
  } catch (error) {
739
739
  const errorMessage = error instanceof Error ? error.message : String(error);
740
- this.logError("handleOrderSalesDetail: 请求失败", {
740
+ this.logInfo("handleOrderSalesDetail: 请求失败", {
741
741
  lookup,
742
742
  backendPath,
743
743
  error: errorMessage
@@ -1988,6 +1988,20 @@ var Server = class {
1988
1988
  return null;
1989
1989
  return text.split("T")[0].split(" ")[0] || null;
1990
1990
  }
1991
+ /**
1992
+ * 判断时间范围是否完整落在今天。
1993
+ *
1994
+ * @example
1995
+ * this.isRangeFullyToday('2026-04-15', '2026-04-15') // => true
1996
+ */
1997
+ isRangeFullyToday(startRaw, endRaw) {
1998
+ const startDate = this.extractQueryDate(startRaw);
1999
+ const endDate = this.extractQueryDate(endRaw);
2000
+ if (!startDate || !endDate)
2001
+ return false;
2002
+ const today = (0, import_dayjs.default)().format("YYYY-MM-DD");
2003
+ return startDate === today && endDate === today;
2004
+ }
1991
2005
  /**
1992
2006
  * 判断时间范围是否「开始和结束都不是今天」。
1993
2007
  *
@@ -2004,11 +2018,11 @@ var Server = class {
2004
2018
  }
2005
2019
  /**
2006
2020
  * 订单查询是否走本地:
2007
- * - start_time 与 end_time 都不是今天时,走远端;
2008
- * - 其余情况走本地。
2021
+ * - 仅当 start_time 与 end_time 都是今天时,走本地;
2022
+ * - 任意一端不是今天时,走云端,确保跨天查询能拉取非本地窗口数据。
2009
2023
  */
2010
2024
  shouldUseLocalOrderQuery(data) {
2011
- return !this.isRangeBothNotToday(data == null ? void 0 : data.start_time, data == null ? void 0 : data.end_time);
2025
+ return this.isRangeFullyToday(data == null ? void 0 : data.start_time, data == null ? void 0 : data.end_time);
2012
2026
  }
2013
2027
  /**
2014
2028
  * 预约查询是否走本地:
@@ -2911,11 +2925,8 @@ var Server = class {
2911
2925
  );
2912
2926
  }
2913
2927
  shouldBuildSmallTicketData(order) {
2914
- var _a;
2915
2928
  if (!order || typeof order !== "object")
2916
2929
  return false;
2917
- if ((0, import_small_ticket.hasSmallTicketData)((_a = order.payment_info) == null ? void 0 : _a.small_ticket_data))
2918
- return false;
2919
2930
  return Number(order.small_ticket_data_flag ?? order.smallTicketDataFlag ?? 0) === 1;
2920
2931
  }
2921
2932
  shouldPrintSyncedOrder(params) {
@@ -1480,14 +1480,27 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1480
1480
  });
1481
1481
  try {
1482
1482
  const syncResult = await this.store.order.syncPaymentsToOrder(syncParams);
1483
- await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
1483
+ const latestPayments = this.store.order.getOrderPayments();
1484
+ const amountSnapshot = this.store.order.getOrderAmountSnapshot();
1485
+ const orderSnapshot = this.store.order.getOrderSnapshot();
1486
+ const syncPayload = {
1484
1487
  ok: true,
1485
1488
  syncResult,
1486
- payments: this.store.order.getOrderPayments(),
1489
+ payments: latestPayments,
1487
1490
  params: syncParams,
1488
- amountSnapshot: this.store.order.getOrderAmountSnapshot(),
1489
- orderSnapshot: this.store.order.getOrderSnapshot()
1490
- });
1491
+ amountSnapshot,
1492
+ orderSnapshot,
1493
+ isFullyPaid: syncResult.isFullyPaid,
1494
+ isOrderFullyPaid: syncResult.isOrderFullyPaid,
1495
+ isDepositFullyPaid: syncResult.isDepositFullyPaid,
1496
+ paymentStage: syncResult.paymentStage,
1497
+ depositAmount: syncResult.depositAmount,
1498
+ orderExpectedAmount: syncResult.orderExpectedAmount
1499
+ };
1500
+ await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
1501
+ if (syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid) {
1502
+ await this.effectsEmit(import_types.BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
1503
+ }
1491
1504
  return syncResult;
1492
1505
  } catch (error) {
1493
1506
  await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
@@ -1550,7 +1563,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1550
1563
  const amountSnapshot = this.store.order.getOrderAmountSnapshot();
1551
1564
  const syncState = this.store.order.getOrderSyncState();
1552
1565
  if (amountSnapshot && syncState !== "submitting") {
1553
- const paymentStatus = Number(amountSnapshot.amountGap || 0) <= 0 ? "paid" : "partially_paid";
1566
+ const completion = this.store.order.getPaymentCompletion(payments);
1567
+ const paymentStatus = completion.isOrderFullyPaid ? "paid" : "partially_paid";
1554
1568
  void this.syncPaymentsToOrder({
1555
1569
  payments,
1556
1570
  paymentStatus,
@@ -14,6 +14,7 @@ export declare const BaseSalesHookNames: {
14
14
  readonly onCartValidationChanged: "onCartValidationChanged";
15
15
  readonly onPaymentSyncStart: "onPaymentSyncStart";
16
16
  readonly onPaymentSyncEnd: "onPaymentSyncEnd";
17
+ readonly onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd";
17
18
  };
18
19
  export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSalesHookNames];
19
20
  export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
@@ -30,7 +30,8 @@ var BaseSalesHookNames = {
30
30
  onRefresh: "onRefresh",
31
31
  onCartValidationChanged: "onCartValidationChanged",
32
32
  onPaymentSyncStart: "onPaymentSyncStart",
33
- onPaymentSyncEnd: "onPaymentSyncEnd"
33
+ onPaymentSyncEnd: "onPaymentSyncEnd",
34
+ onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd"
34
35
  };
35
36
  function createBaseSalesHook(moduleName, hookName) {
36
37
  return `${moduleName}:${hookName}`;
@@ -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 | 5 | 3 | 4 | 6;
314
+ weekNum: 0 | 1 | 2 | 6 | 3 | 4 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.4",
4
+ "version": "2.3.6",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",