@pisell/pisellos 2.2.166 → 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 +28 -14
- package/dist/solution/BaseSales/index.js +70 -6
- 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/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +15 -7
- package/lib/solution/BaseSales/index.js +54 -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/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;
|
|
@@ -829,6 +829,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
829
829
|
this.store.tempOrder = freshTempOrder;
|
|
830
830
|
this.store.summary = createEmptySummary();
|
|
831
831
|
this.store.lastOrderInfo = undefined;
|
|
832
|
+
this.store.syncState = undefined;
|
|
832
833
|
void ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList([]));
|
|
833
834
|
void ((_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 ? void 0 : _this$store$discount10.setDiscountList([]));
|
|
834
835
|
this.persistTempOrder();
|
|
@@ -1411,6 +1412,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1411
1412
|
}, {
|
|
1412
1413
|
key: "addOrderPayment",
|
|
1413
1414
|
value: function addOrderPayment(payment) {
|
|
1415
|
+
this.logInfo('addOrderPayment', {
|
|
1416
|
+
payment: payment
|
|
1417
|
+
});
|
|
1414
1418
|
var tempOrder = this.ensureTempOrder();
|
|
1415
1419
|
var mapped = mapPaymentItemsToOrderPayments([payment]);
|
|
1416
1420
|
tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
|
|
@@ -2115,43 +2119,53 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2115
2119
|
key: "syncPaymentsToOrder",
|
|
2116
2120
|
value: function () {
|
|
2117
2121
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2118
|
-
var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, submitResult;
|
|
2122
|
+
var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, submitResult;
|
|
2119
2123
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2120
2124
|
while (1) switch (_context22.prev = _context22.next) {
|
|
2121
2125
|
case 0:
|
|
2122
2126
|
tempOrder = this.ensureTempOrder();
|
|
2123
2127
|
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
2124
|
-
tempOrder.payments = mappedPayments;
|
|
2125
|
-
if (params.paymentStatus) tempOrder.payment_status = params.paymentStatus;
|
|
2126
|
-
this.persistTempOrder();
|
|
2127
|
-
_context22.next = 7;
|
|
2128
|
-
return this.saveDraft();
|
|
2129
|
-
case 7:
|
|
2130
2128
|
paymentTotal = this.calculatePaymentTotal(mappedPayments);
|
|
2131
2129
|
targetAmount = this.getPaymentTargetAmount();
|
|
2132
2130
|
isFullyPaid = targetAmount.lte(0) ? false : paymentTotal.gte(targetAmount);
|
|
2133
|
-
|
|
2134
|
-
|
|
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;
|
|
2135
2140
|
break;
|
|
2136
2141
|
}
|
|
2137
2142
|
return _context22.abrupt("return", {
|
|
2138
2143
|
isFullyPaid: isFullyPaid
|
|
2139
2144
|
});
|
|
2140
|
-
case
|
|
2141
|
-
|
|
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;
|
|
2142
2156
|
return this.submitTempOrder({
|
|
2143
2157
|
payments: mappedPayments,
|
|
2144
|
-
paymentStatus:
|
|
2158
|
+
paymentStatus: paymentStatus,
|
|
2145
2159
|
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
2146
2160
|
channel: params.channel
|
|
2147
2161
|
});
|
|
2148
|
-
case
|
|
2162
|
+
case 18:
|
|
2149
2163
|
submitResult = _context22.sent;
|
|
2150
2164
|
return _context22.abrupt("return", {
|
|
2151
2165
|
isFullyPaid: isFullyPaid,
|
|
2152
2166
|
submitResult: submitResult
|
|
2153
2167
|
});
|
|
2154
|
-
case
|
|
2168
|
+
case 20:
|
|
2155
2169
|
case "end":
|
|
2156
2170
|
return _context22.stop();
|
|
2157
2171
|
}
|
|
@@ -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";
|
|
@@ -1500,7 +1501,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1500
1501
|
value: function () {
|
|
1501
1502
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
1502
1503
|
var _params$channel;
|
|
1503
|
-
var channel;
|
|
1504
|
+
var channel, syncParams, syncState, payments, syncResult;
|
|
1504
1505
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1505
1506
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1506
1507
|
case 0:
|
|
@@ -1511,14 +1512,60 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1511
1512
|
throw new Error('order 模块未初始化');
|
|
1512
1513
|
case 2:
|
|
1513
1514
|
channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
|
|
1514
|
-
|
|
1515
|
+
syncParams = _objectSpread(_objectSpread({}, params), channel !== undefined ? {
|
|
1515
1516
|
channel: channel
|
|
1516
|
-
} : {})
|
|
1517
|
-
|
|
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:
|
|
1518
1565
|
case "end":
|
|
1519
1566
|
return _context18.stop();
|
|
1520
1567
|
}
|
|
1521
|
-
}, _callee18, this);
|
|
1568
|
+
}, _callee18, this, [[10, 19]]);
|
|
1522
1569
|
}));
|
|
1523
1570
|
function syncPaymentsToOrder(_x13) {
|
|
1524
1571
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
@@ -1544,8 +1591,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1544
1591
|
}, {
|
|
1545
1592
|
key: "addOrderPayment",
|
|
1546
1593
|
value: function addOrderPayment(payment) {
|
|
1594
|
+
var _this5 = this;
|
|
1547
1595
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1548
|
-
|
|
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;
|
|
1549
1613
|
}
|
|
1550
1614
|
|
|
1551
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;
|
|
@@ -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;
|
|
@@ -570,6 +570,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
570
570
|
this.store.tempOrder = freshTempOrder;
|
|
571
571
|
this.store.summary = (0, import_utils.createEmptySummary)();
|
|
572
572
|
this.store.lastOrderInfo = void 0;
|
|
573
|
+
this.store.syncState = void 0;
|
|
573
574
|
void ((_a = this.store.discount) == null ? void 0 : _a.setOriginalDiscountList([]));
|
|
574
575
|
void ((_b = this.store.discount) == null ? void 0 : _b.setDiscountList([]));
|
|
575
576
|
this.persistTempOrder();
|
|
@@ -988,6 +989,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
988
989
|
}
|
|
989
990
|
/** 追加单个支付项,并立即持久化当前 tempOrder。 */
|
|
990
991
|
addOrderPayment(payment) {
|
|
992
|
+
this.logInfo("addOrderPayment", {
|
|
993
|
+
payment
|
|
994
|
+
});
|
|
991
995
|
const tempOrder = this.ensureTempOrder();
|
|
992
996
|
const mapped = (0, import_utils.mapPaymentItemsToOrderPayments)([payment]);
|
|
993
997
|
tempOrder.payments = [...tempOrder.payments || [], ...mapped];
|
|
@@ -1556,20 +1560,24 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1556
1560
|
const mappedPayments = (0, import_utils.mapPaymentItemsToOrderPayments)(
|
|
1557
1561
|
params.payments || []
|
|
1558
1562
|
);
|
|
1559
|
-
tempOrder.payments = mappedPayments;
|
|
1560
|
-
if (params.paymentStatus)
|
|
1561
|
-
tempOrder.payment_status = params.paymentStatus;
|
|
1562
|
-
this.persistTempOrder();
|
|
1563
|
-
await this.saveDraft();
|
|
1564
1563
|
const paymentTotal = this.calculatePaymentTotal(mappedPayments);
|
|
1565
1564
|
const targetAmount = this.getPaymentTargetAmount();
|
|
1566
1565
|
const isFullyPaid = targetAmount.lte(0) ? false : paymentTotal.gte(targetAmount);
|
|
1567
|
-
|
|
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") {
|
|
1568
1575
|
return { isFullyPaid };
|
|
1569
1576
|
}
|
|
1577
|
+
this.store.syncState = "submitting";
|
|
1570
1578
|
const submitResult = await this.submitTempOrder({
|
|
1571
1579
|
payments: mappedPayments,
|
|
1572
|
-
paymentStatus
|
|
1580
|
+
paymentStatus,
|
|
1573
1581
|
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
1574
1582
|
channel: params.channel
|
|
1575
1583
|
});
|
|
@@ -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;
|
|
@@ -844,10 +845,43 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
844
845
|
if (!this.store.order)
|
|
845
846
|
throw new Error("order 模块未初始化");
|
|
846
847
|
const channel = params.channel ?? this.getSubmitOrderSalesChannel();
|
|
847
|
-
|
|
848
|
+
const syncParams = {
|
|
848
849
|
...params,
|
|
849
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()
|
|
850
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
|
+
}
|
|
851
885
|
}
|
|
852
886
|
/** 读取当前 BaseSales 订单上下文中的 Sales 协议支付项。 */
|
|
853
887
|
getOrderPayments() {
|
|
@@ -865,7 +899,23 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
865
899
|
addOrderPayment(payment) {
|
|
866
900
|
if (!this.store.order)
|
|
867
901
|
throw new Error("order 模块未初始化");
|
|
868
|
-
|
|
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;
|
|
869
919
|
}
|
|
870
920
|
/** 更新当前订单中的指定支付项。 */
|
|
871
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;
|