@pisell/pisellos 2.2.165 → 2.2.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/modules/Order/index.js +31 -14
- package/dist/modules/Order/types.d.ts +0 -5
- package/dist/modules/Order/utils.d.ts +5 -2
- package/dist/modules/Order/utils.js +6 -4
- package/dist/solution/BaseSales/index.js +79 -7
- package/dist/solution/BaseSales/types.d.ts +2 -0
- package/dist/solution/BaseSales/types.js +3 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +23 -8
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +4 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.js +22 -12
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +18 -7
- package/lib/modules/Order/types.d.ts +0 -5
- package/lib/modules/Order/utils.d.ts +5 -2
- package/lib/modules/Order/utils.js +1 -2
- package/lib/solution/BaseSales/index.js +60 -4
- package/lib/solution/BaseSales/types.d.ts +2 -0
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +9 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +4 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.js +13 -5
- package/package.json +1 -1
|
@@ -190,7 +190,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
190
190
|
private logSubmitBackendRejected;
|
|
191
191
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
192
192
|
createOrder(params: CommitOrderParams['query']): {
|
|
193
|
-
type: "
|
|
193
|
+
type: "virtual" | "appointment_booking";
|
|
194
194
|
platform: string;
|
|
195
195
|
sales_channel: string;
|
|
196
196
|
order_sales_channel: string;
|
|
@@ -823,11 +823,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
823
823
|
}, {
|
|
824
824
|
key: "restoreOrder",
|
|
825
825
|
value: function restoreOrder() {
|
|
826
|
+
var _this$store$discount9, _this$store$discount10;
|
|
826
827
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
827
828
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
828
829
|
this.store.tempOrder = freshTempOrder;
|
|
829
830
|
this.store.summary = createEmptySummary();
|
|
830
831
|
this.store.lastOrderInfo = undefined;
|
|
832
|
+
this.store.syncState = undefined;
|
|
833
|
+
void ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList([]));
|
|
834
|
+
void ((_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 ? void 0 : _this$store$discount10.setDiscountList([]));
|
|
831
835
|
this.persistTempOrder();
|
|
832
836
|
return freshTempOrder;
|
|
833
837
|
}
|
|
@@ -1408,6 +1412,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1408
1412
|
}, {
|
|
1409
1413
|
key: "addOrderPayment",
|
|
1410
1414
|
value: function addOrderPayment(payment) {
|
|
1415
|
+
this.logInfo('addOrderPayment', {
|
|
1416
|
+
payment: payment
|
|
1417
|
+
});
|
|
1411
1418
|
var tempOrder = this.ensureTempOrder();
|
|
1412
1419
|
var mapped = mapPaymentItemsToOrderPayments([payment]);
|
|
1413
1420
|
tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
|
|
@@ -2112,43 +2119,53 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2112
2119
|
key: "syncPaymentsToOrder",
|
|
2113
2120
|
value: function () {
|
|
2114
2121
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2115
|
-
var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, submitResult;
|
|
2122
|
+
var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, submitResult;
|
|
2116
2123
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2117
2124
|
while (1) switch (_context22.prev = _context22.next) {
|
|
2118
2125
|
case 0:
|
|
2119
2126
|
tempOrder = this.ensureTempOrder();
|
|
2120
2127
|
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
2121
|
-
tempOrder.payments = mappedPayments;
|
|
2122
|
-
if (params.paymentStatus) tempOrder.payment_status = params.paymentStatus;
|
|
2123
|
-
this.persistTempOrder();
|
|
2124
|
-
_context22.next = 7;
|
|
2125
|
-
return this.saveDraft();
|
|
2126
|
-
case 7:
|
|
2127
2128
|
paymentTotal = this.calculatePaymentTotal(mappedPayments);
|
|
2128
2129
|
targetAmount = this.getPaymentTargetAmount();
|
|
2129
2130
|
isFullyPaid = targetAmount.lte(0) ? false : paymentTotal.gte(targetAmount);
|
|
2130
|
-
|
|
2131
|
-
|
|
2131
|
+
paymentStatus = isFullyPaid ? params.paymentStatus || 'paid' : 'partially_paid';
|
|
2132
|
+
tempOrder.payments = mappedPayments;
|
|
2133
|
+
tempOrder.payment_status = paymentStatus;
|
|
2134
|
+
this.persistTempOrder();
|
|
2135
|
+
_context22.next = 11;
|
|
2136
|
+
return this.saveDraft();
|
|
2137
|
+
case 11:
|
|
2138
|
+
if (params.submitWhenPaid) {
|
|
2139
|
+
_context22.next = 13;
|
|
2132
2140
|
break;
|
|
2133
2141
|
}
|
|
2134
2142
|
return _context22.abrupt("return", {
|
|
2135
2143
|
isFullyPaid: isFullyPaid
|
|
2136
2144
|
});
|
|
2137
|
-
case
|
|
2138
|
-
|
|
2145
|
+
case 13:
|
|
2146
|
+
if (!(this.store.syncState === 'submitting')) {
|
|
2147
|
+
_context22.next = 15;
|
|
2148
|
+
break;
|
|
2149
|
+
}
|
|
2150
|
+
return _context22.abrupt("return", {
|
|
2151
|
+
isFullyPaid: isFullyPaid
|
|
2152
|
+
});
|
|
2153
|
+
case 15:
|
|
2154
|
+
this.store.syncState = 'submitting';
|
|
2155
|
+
_context22.next = 18;
|
|
2139
2156
|
return this.submitTempOrder({
|
|
2140
2157
|
payments: mappedPayments,
|
|
2141
|
-
paymentStatus:
|
|
2158
|
+
paymentStatus: paymentStatus,
|
|
2142
2159
|
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
2143
2160
|
channel: params.channel
|
|
2144
2161
|
});
|
|
2145
|
-
case
|
|
2162
|
+
case 18:
|
|
2146
2163
|
submitResult = _context22.sent;
|
|
2147
2164
|
return _context22.abrupt("return", {
|
|
2148
2165
|
isFullyPaid: isFullyPaid,
|
|
2149
2166
|
submitResult: submitResult
|
|
2150
2167
|
});
|
|
2151
|
-
case
|
|
2168
|
+
case 20:
|
|
2152
2169
|
case "end":
|
|
2153
2170
|
return _context22.stop();
|
|
2154
2171
|
}
|
|
@@ -491,11 +491,6 @@ export interface OrderModuleAPI {
|
|
|
491
491
|
updateOrderProductQuantity: (params: UpdateOrderProductQuantityParams) => Promise<OrderProduct[]>;
|
|
492
492
|
updateOrderBooking: (params: UpdateOrderBookingParams) => any[];
|
|
493
493
|
removeProductFromOrder: (identity: OrderProductIdentity) => Promise<OrderProduct[]>;
|
|
494
|
-
/**
|
|
495
|
-
* 仅清空购物车行:products / bookings / discount_list(保留客户、备注、支付等其它 tempOrder 字段)。
|
|
496
|
-
* 内部会 applyDiscount + recalculateSummary + persist。
|
|
497
|
-
*/
|
|
498
|
-
clearOrderCartLines: () => Promise<OrderTempOrder>;
|
|
499
494
|
persistTempOrder: () => void;
|
|
500
495
|
submitTempOrder: <T = any>(params?: {
|
|
501
496
|
cacheId?: string;
|
|
@@ -68,8 +68,11 @@ export declare function sumOptionUnitPrice(options?: Array<{
|
|
|
68
68
|
/** Rules calcDiscount 用手动价标记;undefined 表示交给 Rules 用 total/origin_total 推断 */
|
|
69
69
|
export declare function resolveRulesManualDiscountFlag(metadata: Record<string, any> | null | undefined): boolean | undefined;
|
|
70
70
|
/**
|
|
71
|
-
* 手动改价(price_override)时行级 original_price
|
|
72
|
-
*
|
|
71
|
+
* 手动改价(price_override)时行级 original_price(composite 单价):
|
|
72
|
+
* 购物车划线价应对齐 metadata.origin._extend.origin_total(改价前单价 composite,如 40),
|
|
73
|
+
* 而非 bundle 子项 catalog 原价合成的 composedOriginalPrice(如 30)。
|
|
74
|
+
*
|
|
75
|
+
* origin_total 与 SkuDetailModal / cacheItem._extend 一致,为单价语义,不再除以 num。
|
|
73
76
|
*/
|
|
74
77
|
export declare function resolveManualOverrideLineOriginalPrice(params: {
|
|
75
78
|
num?: number;
|
|
@@ -128,8 +128,11 @@ export function resolveRulesManualDiscountFlag(metadata) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
|
-
* 手动改价(price_override)时行级 original_price
|
|
132
|
-
*
|
|
131
|
+
* 手动改价(price_override)时行级 original_price(composite 单价):
|
|
132
|
+
* 购物车划线价应对齐 metadata.origin._extend.origin_total(改价前单价 composite,如 40),
|
|
133
|
+
* 而非 bundle 子项 catalog 原价合成的 composedOriginalPrice(如 30)。
|
|
134
|
+
*
|
|
135
|
+
* origin_total 与 SkuDetailModal / cacheItem._extend 一致,为单价语义,不再除以 num。
|
|
133
136
|
*/
|
|
134
137
|
export function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOriginal) {
|
|
135
138
|
var _metadata$origin;
|
|
@@ -146,8 +149,7 @@ export function resolveManualOverrideLineOriginalPrice(params, fallbackComposite
|
|
|
146
149
|
if (!Number.isFinite(parsed)) {
|
|
147
150
|
return fallbackCompositeOriginal;
|
|
148
151
|
}
|
|
149
|
-
|
|
150
|
-
return new Decimal(parsed).dividedBy(num).toDecimalPlaces(2).toFixed(2);
|
|
152
|
+
return new Decimal(parsed).toDecimalPlaces(2).toFixed(2);
|
|
151
153
|
}
|
|
152
154
|
export function createDefaultOrderRulesHooks() {
|
|
153
155
|
var toUnitPriceString = function toUnitPriceString(totalLike, num) {
|
|
@@ -27,6 +27,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
27
27
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
28
28
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
29
29
|
import { BaseModule } from "../../modules/BaseModule";
|
|
30
|
+
import { BaseSalesHookNames } from "./types";
|
|
30
31
|
import { OrderModule } from "../../modules/Order";
|
|
31
32
|
import Decimal from 'decimal.js';
|
|
32
33
|
import { createModule } from "../BookingByStep/types";
|
|
@@ -1041,11 +1042,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1041
1042
|
});
|
|
1042
1043
|
case 28:
|
|
1043
1044
|
this.store.order.persistTempOrder();
|
|
1045
|
+
_context11.next = 31;
|
|
1046
|
+
return this.effectsEmit('onDiscountApplied', {
|
|
1047
|
+
productList: tempOrder.products || [],
|
|
1048
|
+
discountList: nextDiscountList,
|
|
1049
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
1050
|
+
tempOrder: tempOrder
|
|
1051
|
+
});
|
|
1052
|
+
case 31:
|
|
1044
1053
|
return _context11.abrupt("return", {
|
|
1045
1054
|
productList: tempOrder.products || [],
|
|
1046
1055
|
discountList: nextDiscountList
|
|
1047
1056
|
});
|
|
1048
|
-
case
|
|
1057
|
+
case 32:
|
|
1049
1058
|
case "end":
|
|
1050
1059
|
return _context11.stop();
|
|
1051
1060
|
}
|
|
@@ -1492,7 +1501,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1492
1501
|
value: function () {
|
|
1493
1502
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
1494
1503
|
var _params$channel;
|
|
1495
|
-
var channel;
|
|
1504
|
+
var channel, syncParams, syncState, payments, syncResult;
|
|
1496
1505
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1497
1506
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1498
1507
|
case 0:
|
|
@@ -1503,14 +1512,60 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1503
1512
|
throw new Error('order 模块未初始化');
|
|
1504
1513
|
case 2:
|
|
1505
1514
|
channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
|
|
1506
|
-
|
|
1515
|
+
syncParams = _objectSpread(_objectSpread({}, params), channel !== undefined ? {
|
|
1507
1516
|
channel: channel
|
|
1508
|
-
} : {})
|
|
1509
|
-
|
|
1517
|
+
} : {});
|
|
1518
|
+
syncState = this.store.order.getOrderSyncState();
|
|
1519
|
+
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
1520
|
+
_context18.next = 7;
|
|
1521
|
+
break;
|
|
1522
|
+
}
|
|
1523
|
+
return _context18.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
1524
|
+
case 7:
|
|
1525
|
+
payments = params.payments || [];
|
|
1526
|
+
_context18.next = 10;
|
|
1527
|
+
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
1528
|
+
payments: payments,
|
|
1529
|
+
params: syncParams,
|
|
1530
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1531
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1532
|
+
});
|
|
1533
|
+
case 10:
|
|
1534
|
+
_context18.prev = 10;
|
|
1535
|
+
_context18.next = 13;
|
|
1536
|
+
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
1537
|
+
case 13:
|
|
1538
|
+
syncResult = _context18.sent;
|
|
1539
|
+
_context18.next = 16;
|
|
1540
|
+
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
1541
|
+
ok: true,
|
|
1542
|
+
syncResult: syncResult,
|
|
1543
|
+
payments: this.store.order.getOrderPayments(),
|
|
1544
|
+
params: syncParams,
|
|
1545
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1546
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1547
|
+
});
|
|
1548
|
+
case 16:
|
|
1549
|
+
return _context18.abrupt("return", syncResult);
|
|
1550
|
+
case 19:
|
|
1551
|
+
_context18.prev = 19;
|
|
1552
|
+
_context18.t0 = _context18["catch"](10);
|
|
1553
|
+
_context18.next = 23;
|
|
1554
|
+
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
1555
|
+
ok: false,
|
|
1556
|
+
error: _context18.t0,
|
|
1557
|
+
payments: this.store.order.getOrderPayments(),
|
|
1558
|
+
params: syncParams,
|
|
1559
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1560
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1561
|
+
});
|
|
1562
|
+
case 23:
|
|
1563
|
+
throw _context18.t0;
|
|
1564
|
+
case 24:
|
|
1510
1565
|
case "end":
|
|
1511
1566
|
return _context18.stop();
|
|
1512
1567
|
}
|
|
1513
|
-
}, _callee18, this);
|
|
1568
|
+
}, _callee18, this, [[10, 19]]);
|
|
1514
1569
|
}));
|
|
1515
1570
|
function syncPaymentsToOrder(_x13) {
|
|
1516
1571
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
@@ -1536,8 +1591,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1536
1591
|
}, {
|
|
1537
1592
|
key: "addOrderPayment",
|
|
1538
1593
|
value: function addOrderPayment(payment) {
|
|
1594
|
+
var _this5 = this;
|
|
1539
1595
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1540
|
-
|
|
1596
|
+
var payments = this.store.order.addOrderPayment(payment);
|
|
1597
|
+
var amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1598
|
+
var syncState = this.store.order.getOrderSyncState();
|
|
1599
|
+
if (amountSnapshot && syncState !== 'submitting') {
|
|
1600
|
+
var paymentStatus = Number(amountSnapshot.amountGap || 0) <= 0 ? 'paid' : 'partially_paid';
|
|
1601
|
+
void this.syncPaymentsToOrder({
|
|
1602
|
+
payments: payments,
|
|
1603
|
+
paymentStatus: paymentStatus,
|
|
1604
|
+
submitWhenPaid: true,
|
|
1605
|
+
smallTicketDataFlag: 1
|
|
1606
|
+
}).catch(function (error) {
|
|
1607
|
+
_this5.logError('auto sync payments failed', {
|
|
1608
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1609
|
+
});
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
return payments;
|
|
1541
1613
|
}
|
|
1542
1614
|
|
|
1543
1615
|
/** 更新当前订单中的指定支付项。 */
|
|
@@ -11,6 +11,8 @@ export declare const BaseSalesHookNames: {
|
|
|
11
11
|
readonly onRetryInit: "onRetryInit";
|
|
12
12
|
readonly onRefresh: "onRefresh";
|
|
13
13
|
readonly onCartValidationChanged: "onCartValidationChanged";
|
|
14
|
+
readonly onPaymentSyncStart: "onPaymentSyncStart";
|
|
15
|
+
readonly onPaymentSyncEnd: "onPaymentSyncEnd";
|
|
14
16
|
};
|
|
15
17
|
export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSalesHookNames];
|
|
16
18
|
export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
|
|
@@ -7,7 +7,9 @@ export var BaseSalesHookNames = {
|
|
|
7
7
|
onDestroy: 'onDestroy',
|
|
8
8
|
onRetryInit: 'onRetryInit',
|
|
9
9
|
onRefresh: 'onRefresh',
|
|
10
|
-
onCartValidationChanged: 'onCartValidationChanged'
|
|
10
|
+
onCartValidationChanged: 'onCartValidationChanged',
|
|
11
|
+
onPaymentSyncStart: 'onPaymentSyncStart',
|
|
12
|
+
onPaymentSyncEnd: 'onPaymentSyncEnd'
|
|
11
13
|
};
|
|
12
14
|
export function createBaseSalesHook(moduleName, hookName) {
|
|
13
15
|
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 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 6 | 3 | 5 | 4;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -723,7 +723,22 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
723
723
|
}, {
|
|
724
724
|
key: "clearOrderCustomer",
|
|
725
725
|
value: function clearOrderCustomer() {
|
|
726
|
+
var _discountModule$setOr,
|
|
727
|
+
_discountModule$setDi,
|
|
728
|
+
_this2 = this;
|
|
726
729
|
this.store.order.clearOrderCustomer();
|
|
730
|
+
var orderStore = this.store.order.store || {};
|
|
731
|
+
var discountModule = orderStore.discount;
|
|
732
|
+
void (discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, []));
|
|
733
|
+
void (discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []));
|
|
734
|
+
this.store.order.applyDiscount();
|
|
735
|
+
void this.store.order.recalculateSummary({
|
|
736
|
+
createIfMissing: true
|
|
737
|
+
}).then(function () {
|
|
738
|
+
return _this2.store.order.persistTempOrder();
|
|
739
|
+
}).catch(function (error) {
|
|
740
|
+
console.error('Failed to recalculate summary after clearing customer:', error);
|
|
741
|
+
});
|
|
727
742
|
this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), null);
|
|
728
743
|
}
|
|
729
744
|
|
|
@@ -776,7 +791,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
776
791
|
}, {
|
|
777
792
|
key: "refreshDiscountConfigAfterOrderCustomerChange",
|
|
778
793
|
value: function refreshDiscountConfigAfterOrderCustomerChange(customerId) {
|
|
779
|
-
var
|
|
794
|
+
var _this3 = this;
|
|
780
795
|
if (!customerId || customerId === 1) return;
|
|
781
796
|
if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
|
|
782
797
|
return;
|
|
@@ -796,7 +811,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
796
811
|
return undefined;
|
|
797
812
|
});
|
|
798
813
|
case 3:
|
|
799
|
-
currentCustomer =
|
|
814
|
+
currentCustomer = _this3.store.order.getOrderCustomer();
|
|
800
815
|
if (!(!currentCustomer || Number(currentCustomer.customer_id) !== customerId)) {
|
|
801
816
|
_context12.next = 6;
|
|
802
817
|
break;
|
|
@@ -804,7 +819,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
804
819
|
return _context12.abrupt("return");
|
|
805
820
|
case 6:
|
|
806
821
|
_context12.next = 8;
|
|
807
|
-
return
|
|
822
|
+
return _this3.loadDiscountConfig({
|
|
808
823
|
customerId: customerId
|
|
809
824
|
});
|
|
810
825
|
case 8:
|
|
@@ -818,9 +833,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
818
833
|
refreshTask.catch(function (error) {
|
|
819
834
|
console.error('Failed to load discount config after customer change:', error);
|
|
820
835
|
}).finally(function () {
|
|
821
|
-
if (
|
|
822
|
-
|
|
823
|
-
|
|
836
|
+
if (_this3.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
|
|
837
|
+
_this3.orderCustomerDiscountRefreshInFlight = null;
|
|
838
|
+
_this3.orderCustomerDiscountRefreshCustomerId = null;
|
|
824
839
|
});
|
|
825
840
|
}
|
|
826
841
|
|
|
@@ -1005,9 +1020,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1005
1020
|
}, {
|
|
1006
1021
|
key: "scanGlobalListener",
|
|
1007
1022
|
value: function scanGlobalListener(callback) {
|
|
1008
|
-
var
|
|
1023
|
+
var _this4 = this;
|
|
1009
1024
|
var localSearch = function localSearch(v) {
|
|
1010
|
-
return
|
|
1025
|
+
return _this4.store.products.findProductsByCodeOrBarcode(v);
|
|
1011
1026
|
};
|
|
1012
1027
|
var scanCallback = handleGlobalScan(this.request, localSearch);
|
|
1013
1028
|
var safeCallback = function safeCallback(d) {
|
|
@@ -89,8 +89,10 @@ export declare function buildRequiresDetailPayload(item: any, ctx?: AddProductDe
|
|
|
89
89
|
*/
|
|
90
90
|
export declare function buildCacheItemFromCartDetail(item: any, ctx?: AddProductDecideContext): any;
|
|
91
91
|
/**
|
|
92
|
-
* 用 Info2 callback 的 (e, extension_type, detail)
|
|
93
|
-
*
|
|
92
|
+
* 用 Info2 callback 的 (e, extension_type, detail) 拼装 cacheItem。
|
|
93
|
+
*
|
|
94
|
+
* 保留 detail._extend 中的 pricing / note(规格弹窗改价、备注等),
|
|
95
|
+
* 再叠加 session 时间、ctx.quantity 等运行态字段;other 以 callback `e` 为准。
|
|
94
96
|
*/
|
|
95
97
|
export declare function buildCacheItemFromDetail(item: any, detailResult: {
|
|
96
98
|
e: any;
|
|
@@ -239,34 +239,44 @@ export function buildCacheItemFromCartDetail(item, ctx) {
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
/**
|
|
242
|
-
* 用 Info2 callback 的 (e, extension_type, detail)
|
|
243
|
-
*
|
|
242
|
+
* 用 Info2 callback 的 (e, extension_type, detail) 拼装 cacheItem。
|
|
243
|
+
*
|
|
244
|
+
* 保留 detail._extend 中的 pricing / note(规格弹窗改价、备注等),
|
|
245
|
+
* 再叠加 session 时间、ctx.quantity 等运行态字段;other 以 callback `e` 为准。
|
|
244
246
|
*/
|
|
245
247
|
export function buildCacheItemFromDetail(item, detailResult, ctx) {
|
|
246
|
-
var _detailResult$e, _currentItem$id, _detail$extension_typ, _ref2, _ctx$quantity2, _detailResult$e2, _detailResult$e3;
|
|
248
|
+
var _detailResult$e, _currentItem$id, _detail$extension_typ, _ref2, _ref3, _ctx$quantity2, _detailResult$e2, _ref4, _detailExtend$price, _currentItem$title, _detailExtend$note, _detailResult$e3;
|
|
247
249
|
var _currentItem = detailResult.detail || item;
|
|
248
250
|
var _detail = _currentItem;
|
|
251
|
+
var detailExtend = (_detail === null || _detail === void 0 ? void 0 : _detail._extend) || {};
|
|
249
252
|
var other = JSON.parse(JSON.stringify(detailResult.e || {}));
|
|
250
253
|
other.session = (_detailResult$e = detailResult.e) === null || _detailResult$e === void 0 ? void 0 : _detailResult$e.session;
|
|
251
254
|
var resolvedId = (_currentItem$id = _currentItem.id) !== null && _currentItem$id !== void 0 ? _currentItem$id : _currentItem.product_id;
|
|
252
255
|
var mergedItem = _objectSpread(_objectSpread(_objectSpread({}, item), _detail), {}, {
|
|
253
256
|
extension_type: (_detail$extension_typ = _detail.extension_type) !== null && _detail$extension_typ !== void 0 ? _detail$extension_typ : item.extension_type
|
|
254
257
|
});
|
|
255
|
-
var
|
|
256
|
-
start_date: (ctx === null || ctx === void 0 ? void 0 : ctx.date) || undefined,
|
|
257
|
-
quantity: (_ref2 = (_ctx$quantity2 = ctx === null || ctx === void 0 ? void 0 : ctx.quantity) !== null && _ctx$quantity2 !== void 0 ? _ctx$quantity2 : (_detailResult$e2 = detailResult.e) === null || _detailResult$e2 === void 0 ? void 0 : _detailResult$e2.quantity) !== null && _ref2 !== void 0 ? _ref2 : 1,
|
|
258
|
-
price: _detail === null || _detail === void 0 ? void 0 : _detail.price,
|
|
259
|
-
product_name: _currentItem.title,
|
|
258
|
+
var runtimeExtend = applySessionTimesToExtend(mergedItem, {
|
|
259
|
+
start_date: (ctx === null || ctx === void 0 ? void 0 : ctx.date) || detailExtend.start_date || undefined,
|
|
260
|
+
quantity: (_ref2 = (_ref3 = (_ctx$quantity2 = ctx === null || ctx === void 0 ? void 0 : ctx.quantity) !== null && _ctx$quantity2 !== void 0 ? _ctx$quantity2 : (_detailResult$e2 = detailResult.e) === null || _detailResult$e2 === void 0 ? void 0 : _detailResult$e2.quantity) !== null && _ref3 !== void 0 ? _ref3 : detailExtend.quantity) !== null && _ref2 !== void 0 ? _ref2 : 1,
|
|
261
|
+
price: (_ref4 = (_detailExtend$price = detailExtend.price) !== null && _detailExtend$price !== void 0 ? _detailExtend$price : _detail === null || _detail === void 0 ? void 0 : _detail.price) !== null && _ref4 !== void 0 ? _ref4 : item === null || item === void 0 ? void 0 : item.price,
|
|
262
|
+
product_name: (_currentItem$title = _currentItem.title) !== null && _currentItem$title !== void 0 ? _currentItem$title : detailExtend.product_name,
|
|
260
263
|
other: other,
|
|
261
264
|
isNormalProduct: !isBookingProduct(mergedItem)
|
|
262
265
|
}, {
|
|
263
266
|
date: ctx === null || ctx === void 0 ? void 0 : ctx.date
|
|
264
267
|
});
|
|
265
|
-
|
|
268
|
+
var extend = _objectSpread(_objectSpread(_objectSpread({}, detailExtend), runtimeExtend), {}, {
|
|
269
|
+
other: other
|
|
270
|
+
});
|
|
271
|
+
var note = (_detailExtend$note = detailExtend.note) !== null && _detailExtend$note !== void 0 ? _detailExtend$note : _detail === null || _detail === void 0 ? void 0 : _detail.note;
|
|
272
|
+
return _objectSpread(_objectSpread(_objectSpread({}, _detail), {}, {
|
|
266
273
|
id: resolvedId,
|
|
267
274
|
product_id: resolvedId,
|
|
268
275
|
extension_type: mergedItem.extension_type,
|
|
269
|
-
_key: (_detailResult$e3 = detailResult.e) === null || _detailResult$e3 === void 0 ? void 0 : _detailResult$e3.key
|
|
276
|
+
_key: (_detailResult$e3 = detailResult.e) === null || _detailResult$e3 === void 0 ? void 0 : _detailResult$e3.key
|
|
277
|
+
}, note != null && note !== '' ? {
|
|
278
|
+
note: String(note)
|
|
279
|
+
} : {}), {}, {
|
|
270
280
|
_extend: extend,
|
|
271
281
|
new: 1
|
|
272
282
|
});
|
|
@@ -307,7 +317,7 @@ export function transformDetailToProductAndBooking(cacheItem, ctx) {
|
|
|
307
317
|
* 把 cacheItem._extend.other 中的字段 + 顶层运行态拼成 `BaseProductDetailPayload`。
|
|
308
318
|
*/
|
|
309
319
|
function buildBasePayloadFromCacheItem(cacheItem, ctx) {
|
|
310
|
-
var _cacheItem$_extend, _cacheItem$_extend$qu, _cacheItem$_extend2, _cacheItem$product_id, _cacheItem$id,
|
|
320
|
+
var _cacheItem$_extend, _cacheItem$_extend$qu, _cacheItem$_extend2, _cacheItem$product_id, _cacheItem$id, _ref5, _other$product_varian, _extend$skuValue, _extend$_skuValue, _extend$price, _extend$price2;
|
|
311
321
|
var other = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.other) || {};
|
|
312
322
|
var quantity = (ctx === null || ctx === void 0 ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : (_cacheItem$_extend$qu = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.quantity) !== null && _cacheItem$_extend$qu !== void 0 ? _cacheItem$_extend$qu : 1;
|
|
313
323
|
var resolvedPid = (_cacheItem$product_id = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_id) !== null && _cacheItem$product_id !== void 0 ? _cacheItem$product_id : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.id;
|
|
@@ -315,7 +325,7 @@ function buildBasePayloadFromCacheItem(cacheItem, ctx) {
|
|
|
315
325
|
return {
|
|
316
326
|
id: (_cacheItem$id = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.id) !== null && _cacheItem$id !== void 0 ? _cacheItem$id : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_id,
|
|
317
327
|
product_id: resolvedPid,
|
|
318
|
-
variant_id: (
|
|
328
|
+
variant_id: (_ref5 = (_other$product_varian = other === null || other === void 0 ? void 0 : other.product_variant_id) !== null && _other$product_varian !== void 0 ? _other$product_varian : other === null || other === void 0 ? void 0 : other.variant_id) !== null && _ref5 !== void 0 ? _ref5 : 0,
|
|
319
329
|
quantity: quantity,
|
|
320
330
|
option: (other === null || other === void 0 ? void 0 : other.option) || [],
|
|
321
331
|
bundle: (other === null || other === void 0 ? void 0 : other.bundle) || (extend === null || extend === void 0 || (_extend$skuValue = extend.skuValue) === null || _extend$skuValue === void 0 ? void 0 : _extend$skuValue.bundle) || (extend === null || extend === void 0 || (_extend$_skuValue = extend._skuValue) === null || _extend$_skuValue === void 0 ? void 0 : _extend$_skuValue.bundle) || [],
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
+
var promotion_exports = {};
|
|
31
|
+
__export(promotion_exports, {
|
|
32
|
+
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
+
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
+
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
+
default: () => import_adapter2.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
+
var import_evaluator = require("./evaluator");
|
|
40
|
+
var import_adapter = require("./adapter");
|
|
41
|
+
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
+
var import_examples = require("./examples");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
+
PromotionAdapter,
|
|
47
|
+
PromotionEvaluator,
|
|
48
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
+
});
|
|
@@ -190,7 +190,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
190
190
|
private logSubmitBackendRejected;
|
|
191
191
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
192
192
|
createOrder(params: CommitOrderParams['query']): {
|
|
193
|
-
type: "
|
|
193
|
+
type: "virtual" | "appointment_booking";
|
|
194
194
|
platform: string;
|
|
195
195
|
sales_channel: string;
|
|
196
196
|
order_sales_channel: string;
|
|
@@ -564,11 +564,15 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
564
564
|
return newOrder;
|
|
565
565
|
}
|
|
566
566
|
restoreOrder() {
|
|
567
|
+
var _a, _b;
|
|
567
568
|
const freshTempOrder = this.createDefaultTempOrderInstance();
|
|
568
569
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
569
570
|
this.store.tempOrder = freshTempOrder;
|
|
570
571
|
this.store.summary = (0, import_utils.createEmptySummary)();
|
|
571
572
|
this.store.lastOrderInfo = void 0;
|
|
573
|
+
this.store.syncState = void 0;
|
|
574
|
+
void ((_a = this.store.discount) == null ? void 0 : _a.setOriginalDiscountList([]));
|
|
575
|
+
void ((_b = this.store.discount) == null ? void 0 : _b.setDiscountList([]));
|
|
572
576
|
this.persistTempOrder();
|
|
573
577
|
return freshTempOrder;
|
|
574
578
|
}
|
|
@@ -985,6 +989,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
985
989
|
}
|
|
986
990
|
/** 追加单个支付项,并立即持久化当前 tempOrder。 */
|
|
987
991
|
addOrderPayment(payment) {
|
|
992
|
+
this.logInfo("addOrderPayment", {
|
|
993
|
+
payment
|
|
994
|
+
});
|
|
988
995
|
const tempOrder = this.ensureTempOrder();
|
|
989
996
|
const mapped = (0, import_utils.mapPaymentItemsToOrderPayments)([payment]);
|
|
990
997
|
tempOrder.payments = [...tempOrder.payments || [], ...mapped];
|
|
@@ -1553,20 +1560,24 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1553
1560
|
const mappedPayments = (0, import_utils.mapPaymentItemsToOrderPayments)(
|
|
1554
1561
|
params.payments || []
|
|
1555
1562
|
);
|
|
1556
|
-
tempOrder.payments = mappedPayments;
|
|
1557
|
-
if (params.paymentStatus)
|
|
1558
|
-
tempOrder.payment_status = params.paymentStatus;
|
|
1559
|
-
this.persistTempOrder();
|
|
1560
|
-
await this.saveDraft();
|
|
1561
1563
|
const paymentTotal = this.calculatePaymentTotal(mappedPayments);
|
|
1562
1564
|
const targetAmount = this.getPaymentTargetAmount();
|
|
1563
1565
|
const isFullyPaid = targetAmount.lte(0) ? false : paymentTotal.gte(targetAmount);
|
|
1564
|
-
|
|
1566
|
+
const paymentStatus = isFullyPaid ? params.paymentStatus || "paid" : "partially_paid";
|
|
1567
|
+
tempOrder.payments = mappedPayments;
|
|
1568
|
+
tempOrder.payment_status = paymentStatus;
|
|
1569
|
+
this.persistTempOrder();
|
|
1570
|
+
await this.saveDraft();
|
|
1571
|
+
if (!params.submitWhenPaid) {
|
|
1572
|
+
return { isFullyPaid };
|
|
1573
|
+
}
|
|
1574
|
+
if (this.store.syncState === "submitting") {
|
|
1565
1575
|
return { isFullyPaid };
|
|
1566
1576
|
}
|
|
1577
|
+
this.store.syncState = "submitting";
|
|
1567
1578
|
const submitResult = await this.submitTempOrder({
|
|
1568
1579
|
payments: mappedPayments,
|
|
1569
|
-
paymentStatus
|
|
1580
|
+
paymentStatus,
|
|
1570
1581
|
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
1571
1582
|
channel: params.channel
|
|
1572
1583
|
});
|
|
@@ -491,11 +491,6 @@ export interface OrderModuleAPI {
|
|
|
491
491
|
updateOrderProductQuantity: (params: UpdateOrderProductQuantityParams) => Promise<OrderProduct[]>;
|
|
492
492
|
updateOrderBooking: (params: UpdateOrderBookingParams) => any[];
|
|
493
493
|
removeProductFromOrder: (identity: OrderProductIdentity) => Promise<OrderProduct[]>;
|
|
494
|
-
/**
|
|
495
|
-
* 仅清空购物车行:products / bookings / discount_list(保留客户、备注、支付等其它 tempOrder 字段)。
|
|
496
|
-
* 内部会 applyDiscount + recalculateSummary + persist。
|
|
497
|
-
*/
|
|
498
|
-
clearOrderCartLines: () => Promise<OrderTempOrder>;
|
|
499
494
|
persistTempOrder: () => void;
|
|
500
495
|
submitTempOrder: <T = any>(params?: {
|
|
501
496
|
cacheId?: string;
|
|
@@ -68,8 +68,11 @@ export declare function sumOptionUnitPrice(options?: Array<{
|
|
|
68
68
|
/** Rules calcDiscount 用手动价标记;undefined 表示交给 Rules 用 total/origin_total 推断 */
|
|
69
69
|
export declare function resolveRulesManualDiscountFlag(metadata: Record<string, any> | null | undefined): boolean | undefined;
|
|
70
70
|
/**
|
|
71
|
-
* 手动改价(price_override)时行级 original_price
|
|
72
|
-
*
|
|
71
|
+
* 手动改价(price_override)时行级 original_price(composite 单价):
|
|
72
|
+
* 购物车划线价应对齐 metadata.origin._extend.origin_total(改价前单价 composite,如 40),
|
|
73
|
+
* 而非 bundle 子项 catalog 原价合成的 composedOriginalPrice(如 30)。
|
|
74
|
+
*
|
|
75
|
+
* origin_total 与 SkuDetailModal / cacheItem._extend 一致,为单价语义,不再除以 num。
|
|
73
76
|
*/
|
|
74
77
|
export declare function resolveManualOverrideLineOriginalPrice(params: {
|
|
75
78
|
num?: number;
|
|
@@ -109,8 +109,7 @@ function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOrigina
|
|
|
109
109
|
if (!Number.isFinite(parsed)) {
|
|
110
110
|
return fallbackCompositeOriginal;
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
return new import_decimal.default(parsed).dividedBy(num).toDecimalPlaces(2).toFixed(2);
|
|
112
|
+
return new import_decimal.default(parsed).toDecimalPlaces(2).toFixed(2);
|
|
114
113
|
}
|
|
115
114
|
function createDefaultOrderRulesHooks() {
|
|
116
115
|
const toUnitPriceString = (totalLike, num) => {
|
|
@@ -34,9 +34,10 @@ __export(BaseSales_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(BaseSales_exports);
|
|
36
36
|
var import_BaseModule = require("../../modules/BaseModule");
|
|
37
|
+
var import_types = require("./types");
|
|
37
38
|
var import_Order = require("../../modules/Order");
|
|
38
39
|
var import_decimal = __toESM(require("decimal.js"));
|
|
39
|
-
var
|
|
40
|
+
var import_types2 = require("../BookingByStep/types");
|
|
40
41
|
var import_utils = require("../../modules/Order/utils");
|
|
41
42
|
var import_dayjs = __toESM(require("dayjs"));
|
|
42
43
|
__reExport(BaseSales_exports, require("./types"), module.exports);
|
|
@@ -147,7 +148,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
147
148
|
if (moduleName === "quotation") {
|
|
148
149
|
return new import_Quotation.QuotationModule(`${this.name}_quotation`);
|
|
149
150
|
}
|
|
150
|
-
return (0,
|
|
151
|
+
return (0, import_types2.createModule)(moduleName, this.name);
|
|
151
152
|
}
|
|
152
153
|
getSubModuleHooks(moduleName) {
|
|
153
154
|
var _a, _b;
|
|
@@ -610,6 +611,12 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
610
611
|
}
|
|
611
612
|
}
|
|
612
613
|
this.store.order.persistTempOrder();
|
|
614
|
+
await this.effectsEmit("onDiscountApplied", {
|
|
615
|
+
productList: tempOrder.products || [],
|
|
616
|
+
discountList: nextDiscountList,
|
|
617
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
618
|
+
tempOrder
|
|
619
|
+
});
|
|
613
620
|
return {
|
|
614
621
|
productList: tempOrder.products || [],
|
|
615
622
|
discountList: nextDiscountList
|
|
@@ -838,10 +845,43 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
838
845
|
if (!this.store.order)
|
|
839
846
|
throw new Error("order 模块未初始化");
|
|
840
847
|
const channel = params.channel ?? this.getSubmitOrderSalesChannel();
|
|
841
|
-
|
|
848
|
+
const syncParams = {
|
|
842
849
|
...params,
|
|
843
850
|
...channel !== void 0 ? { channel } : {}
|
|
851
|
+
};
|
|
852
|
+
const syncState = this.store.order.getOrderSyncState();
|
|
853
|
+
if (params.submitWhenPaid && syncState === "submitting") {
|
|
854
|
+
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
855
|
+
}
|
|
856
|
+
const payments = params.payments || [];
|
|
857
|
+
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncStart, {
|
|
858
|
+
payments,
|
|
859
|
+
params: syncParams,
|
|
860
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
861
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
844
862
|
});
|
|
863
|
+
try {
|
|
864
|
+
const syncResult = await this.store.order.syncPaymentsToOrder(syncParams);
|
|
865
|
+
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
866
|
+
ok: true,
|
|
867
|
+
syncResult,
|
|
868
|
+
payments: this.store.order.getOrderPayments(),
|
|
869
|
+
params: syncParams,
|
|
870
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
871
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
872
|
+
});
|
|
873
|
+
return syncResult;
|
|
874
|
+
} catch (error) {
|
|
875
|
+
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
876
|
+
ok: false,
|
|
877
|
+
error,
|
|
878
|
+
payments: this.store.order.getOrderPayments(),
|
|
879
|
+
params: syncParams,
|
|
880
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
881
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
882
|
+
});
|
|
883
|
+
throw error;
|
|
884
|
+
}
|
|
845
885
|
}
|
|
846
886
|
/** 读取当前 BaseSales 订单上下文中的 Sales 协议支付项。 */
|
|
847
887
|
getOrderPayments() {
|
|
@@ -859,7 +899,23 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
859
899
|
addOrderPayment(payment) {
|
|
860
900
|
if (!this.store.order)
|
|
861
901
|
throw new Error("order 模块未初始化");
|
|
862
|
-
|
|
902
|
+
const payments = this.store.order.addOrderPayment(payment);
|
|
903
|
+
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
904
|
+
const syncState = this.store.order.getOrderSyncState();
|
|
905
|
+
if (amountSnapshot && syncState !== "submitting") {
|
|
906
|
+
const paymentStatus = Number(amountSnapshot.amountGap || 0) <= 0 ? "paid" : "partially_paid";
|
|
907
|
+
void this.syncPaymentsToOrder({
|
|
908
|
+
payments,
|
|
909
|
+
paymentStatus,
|
|
910
|
+
submitWhenPaid: true,
|
|
911
|
+
smallTicketDataFlag: 1
|
|
912
|
+
}).catch((error) => {
|
|
913
|
+
this.logError("auto sync payments failed", {
|
|
914
|
+
error: error instanceof Error ? error.message : String(error)
|
|
915
|
+
});
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
return payments;
|
|
863
919
|
}
|
|
864
920
|
/** 更新当前订单中的指定支付项。 */
|
|
865
921
|
updateOrderPayment(paymentIdentity, updates) {
|
|
@@ -11,6 +11,8 @@ export declare const BaseSalesHookNames: {
|
|
|
11
11
|
readonly onRetryInit: "onRetryInit";
|
|
12
12
|
readonly onRefresh: "onRefresh";
|
|
13
13
|
readonly onCartValidationChanged: "onCartValidationChanged";
|
|
14
|
+
readonly onPaymentSyncStart: "onPaymentSyncStart";
|
|
15
|
+
readonly onPaymentSyncEnd: "onPaymentSyncEnd";
|
|
14
16
|
};
|
|
15
17
|
export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSalesHookNames];
|
|
16
18
|
export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
|
|
@@ -28,7 +28,9 @@ var BaseSalesHookNames = {
|
|
|
28
28
|
onDestroy: "onDestroy",
|
|
29
29
|
onRetryInit: "onRetryInit",
|
|
30
30
|
onRefresh: "onRefresh",
|
|
31
|
-
onCartValidationChanged: "onCartValidationChanged"
|
|
31
|
+
onCartValidationChanged: "onCartValidationChanged",
|
|
32
|
+
onPaymentSyncStart: "onPaymentSyncStart",
|
|
33
|
+
onPaymentSyncEnd: "onPaymentSyncEnd"
|
|
32
34
|
};
|
|
33
35
|
function createBaseSalesHook(moduleName, hookName) {
|
|
34
36
|
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 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 6 | 3 | 5 | 4;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -431,7 +431,16 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
431
431
|
* 清空下单客户(协议字段 + snapshot)。
|
|
432
432
|
*/
|
|
433
433
|
clearOrderCustomer() {
|
|
434
|
+
var _a, _b;
|
|
434
435
|
this.store.order.clearOrderCustomer();
|
|
436
|
+
const orderStore = this.store.order.store || {};
|
|
437
|
+
const discountModule = orderStore.discount;
|
|
438
|
+
void ((_a = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _a.call(discountModule, []));
|
|
439
|
+
void ((_b = discountModule == null ? void 0 : discountModule.setDiscountList) == null ? void 0 : _b.call(discountModule, []));
|
|
440
|
+
this.store.order.applyDiscount();
|
|
441
|
+
void this.store.order.recalculateSummary({ createIfMissing: true }).then(() => this.store.order.persistTempOrder()).catch((error) => {
|
|
442
|
+
console.error("Failed to recalculate summary after clearing customer:", error);
|
|
443
|
+
});
|
|
435
444
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
|
|
436
445
|
}
|
|
437
446
|
/**
|
|
@@ -89,8 +89,10 @@ export declare function buildRequiresDetailPayload(item: any, ctx?: AddProductDe
|
|
|
89
89
|
*/
|
|
90
90
|
export declare function buildCacheItemFromCartDetail(item: any, ctx?: AddProductDecideContext): any;
|
|
91
91
|
/**
|
|
92
|
-
* 用 Info2 callback 的 (e, extension_type, detail)
|
|
93
|
-
*
|
|
92
|
+
* 用 Info2 callback 的 (e, extension_type, detail) 拼装 cacheItem。
|
|
93
|
+
*
|
|
94
|
+
* 保留 detail._extend 中的 pricing / note(规格弹窗改价、备注等),
|
|
95
|
+
* 再叠加 session 时间、ctx.quantity 等运行态字段;other 以 callback `e` 为准。
|
|
94
96
|
*/
|
|
95
97
|
export declare function buildCacheItemFromDetail(item: any, detailResult: {
|
|
96
98
|
e: any;
|
|
@@ -222,28 +222,36 @@ function buildCacheItemFromDetail(item, detailResult, ctx) {
|
|
|
222
222
|
var _a, _b, _c;
|
|
223
223
|
const _currentItem = detailResult.detail || item;
|
|
224
224
|
const _detail = _currentItem;
|
|
225
|
+
const detailExtend = (_detail == null ? void 0 : _detail._extend) || {};
|
|
225
226
|
const other = JSON.parse(JSON.stringify(detailResult.e || {}));
|
|
226
227
|
other.session = (_a = detailResult.e) == null ? void 0 : _a.session;
|
|
227
228
|
const resolvedId = _currentItem.id ?? _currentItem.product_id;
|
|
228
229
|
const mergedItem = { ...item, ..._detail, extension_type: _detail.extension_type ?? item.extension_type };
|
|
229
|
-
const
|
|
230
|
+
const runtimeExtend = (0, import_BookingContext.applySessionTimesToExtend)(
|
|
230
231
|
mergedItem,
|
|
231
232
|
{
|
|
232
|
-
start_date: (ctx == null ? void 0 : ctx.date) || void 0,
|
|
233
|
-
quantity: (ctx == null ? void 0 : ctx.quantity) ?? ((_b = detailResult.e) == null ? void 0 : _b.quantity) ?? 1,
|
|
234
|
-
price: _detail == null ? void 0 : _detail.price,
|
|
235
|
-
product_name: _currentItem.title,
|
|
233
|
+
start_date: (ctx == null ? void 0 : ctx.date) || detailExtend.start_date || void 0,
|
|
234
|
+
quantity: (ctx == null ? void 0 : ctx.quantity) ?? ((_b = detailResult.e) == null ? void 0 : _b.quantity) ?? detailExtend.quantity ?? 1,
|
|
235
|
+
price: detailExtend.price ?? (_detail == null ? void 0 : _detail.price) ?? (item == null ? void 0 : item.price),
|
|
236
|
+
product_name: _currentItem.title ?? detailExtend.product_name,
|
|
236
237
|
other,
|
|
237
238
|
isNormalProduct: !(0, import_BookingContext.isBookingProduct)(mergedItem)
|
|
238
239
|
},
|
|
239
240
|
{ date: ctx == null ? void 0 : ctx.date }
|
|
240
241
|
);
|
|
242
|
+
const extend = {
|
|
243
|
+
...detailExtend,
|
|
244
|
+
...runtimeExtend,
|
|
245
|
+
other
|
|
246
|
+
};
|
|
247
|
+
const note = detailExtend.note ?? (_detail == null ? void 0 : _detail.note);
|
|
241
248
|
return {
|
|
242
249
|
..._detail,
|
|
243
250
|
id: resolvedId,
|
|
244
251
|
product_id: resolvedId,
|
|
245
252
|
extension_type: mergedItem.extension_type,
|
|
246
253
|
_key: (_c = detailResult.e) == null ? void 0 : _c.key,
|
|
254
|
+
...note != null && note !== "" ? { note: String(note) } : {},
|
|
247
255
|
_extend: extend,
|
|
248
256
|
new: 1
|
|
249
257
|
};
|