@pisell/pisellos 0.0.320 → 0.0.324
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/effects/index.d.ts +2 -2
- package/dist/modules/Customer/types.d.ts +1 -1
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +67 -35
- package/dist/modules/Discount/types.d.ts +5 -0
- package/dist/modules/Payment/types.d.ts +7 -7
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +9 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ShopDiscount/index.d.ts +4 -0
- package/dist/solution/ShopDiscount/index.js +190 -101
- package/dist/solution/ShopDiscount/types.d.ts +5 -2
- package/dist/solution/ShopDiscount/utils.d.ts +48 -0
- package/dist/solution/ShopDiscount/utils.js +281 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.d.ts +2 -2
- package/dist/utils/watch.d.ts +2 -2
- package/lib/core/index.js +27 -28
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +3 -7
- package/lib/modules/Account/index.js +9 -10
- package/lib/modules/AccountList/index.js +14 -11
- package/lib/modules/BaseModule.js +6 -3
- package/lib/modules/Cart/index.js +14 -9
- package/lib/modules/Cart/utils/cartProduct.js +3 -6
- package/lib/modules/Customer/constants.js +1 -1
- package/lib/modules/Customer/index.js +18 -15
- package/lib/modules/Customer/types.d.ts +1 -1
- package/lib/modules/Date/index.js +10 -6
- package/lib/modules/Date/types.js +1 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +28 -9
- package/lib/modules/Discount/types.d.ts +5 -0
- package/lib/modules/Guests/index.js +10 -15
- package/lib/modules/Order/index.js +11 -9
- package/lib/modules/Payment/cash.js +1 -1
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.js +80 -69
- package/lib/modules/Payment/types.d.ts +7 -7
- package/lib/modules/Payment/utils.js +3 -6
- package/lib/modules/Payment/walletpass.js +31 -31
- package/lib/modules/Product/index.js +6 -5
- package/lib/modules/ProductList/index.js +7 -4
- package/lib/modules/Resource/index.js +8 -12
- package/lib/modules/Rules/index.js +12 -17
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.js +8 -5
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +9 -9
- package/lib/modules/Schedule/utils.js +2 -4
- package/lib/modules/Step/index.js +7 -4
- package/lib/modules/Summary/index.js +9 -4
- package/lib/plugins/request.js +34 -33
- package/lib/plugins/window.js +101 -113
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +70 -104
- package/lib/solution/BookingByStep/utils/capacity.js +10 -15
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +4 -8
- package/lib/solution/BookingByStep/utils/stock.js +3 -6
- package/lib/solution/BookingByStep/utils/timeslots.js +24 -27
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +19 -14
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
- package/lib/solution/BookingTicket/utils/scan/index.js +3 -1
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +10 -9
- package/lib/solution/BuyTickets/index.js +15 -15
- package/lib/solution/Checkout/index.js +206 -199
- package/lib/solution/Checkout/utils/index.js +18 -22
- package/lib/solution/ShopDiscount/index.d.ts +4 -0
- package/lib/solution/ShopDiscount/index.js +59 -16
- package/lib/solution/ShopDiscount/types.d.ts +5 -2
- package/lib/solution/ShopDiscount/utils.d.ts +48 -0
- package/lib/solution/ShopDiscount/utils.js +172 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/utils/task.d.ts +2 -2
- package/lib/utils/task.js +3 -3
- package/lib/utils/watch.d.ts +2 -2
- package/lib/utils/watch.js +5 -7
- package/package.json +1 -1
|
@@ -218,8 +218,7 @@ var getProductOriginTotalPrice = (params) => {
|
|
|
218
218
|
return price;
|
|
219
219
|
};
|
|
220
220
|
var formatOptions = (options) => {
|
|
221
|
-
if (!(options == null ? void 0 : options.length))
|
|
222
|
-
return [];
|
|
221
|
+
if (!(options == null ? void 0 : options.length)) return [];
|
|
223
222
|
return options.map((item) => {
|
|
224
223
|
return {
|
|
225
224
|
id: item == null ? void 0 : item.id,
|
|
@@ -244,8 +243,7 @@ var formatOptionsToOrigin = (options) => {
|
|
|
244
243
|
});
|
|
245
244
|
};
|
|
246
245
|
var formatBundle = (bundle) => {
|
|
247
|
-
if (!(bundle == null ? void 0 : bundle.length))
|
|
248
|
-
return [];
|
|
246
|
+
if (!(bundle == null ? void 0 : bundle.length)) return [];
|
|
249
247
|
return bundle.map((item) => {
|
|
250
248
|
return {
|
|
251
249
|
id: item == null ? void 0 : item.id,
|
|
@@ -261,8 +259,7 @@ var formatBundle = (bundle) => {
|
|
|
261
259
|
});
|
|
262
260
|
};
|
|
263
261
|
var formatBundleToOrigin = (bundle) => {
|
|
264
|
-
if (!(bundle == null ? void 0 : bundle.length))
|
|
265
|
-
return [];
|
|
262
|
+
if (!(bundle == null ? void 0 : bundle.length)) return [];
|
|
266
263
|
return bundle.map((d) => {
|
|
267
264
|
return {
|
|
268
265
|
bundle_group_id: d.group_id,
|
|
@@ -29,7 +29,7 @@ var DEFAULT_PAGE_SIZE = 20;
|
|
|
29
29
|
var DEFAULT_CUSTOMER = {
|
|
30
30
|
"id": 1,
|
|
31
31
|
"nickname": "Select a customer",
|
|
32
|
-
"name": "
|
|
32
|
+
"name": "\u9009\u62E9\u4E00\u4E2A\u5BA2\u6237"
|
|
33
33
|
};
|
|
34
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
35
|
0 && (module.exports = {
|
|
@@ -29,23 +29,26 @@ var import_types = require("./types");
|
|
|
29
29
|
var import_constants = require("./constants");
|
|
30
30
|
__reExport(Customer_exports, require("./types"), module.exports);
|
|
31
31
|
var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
32
|
+
defaultName = "customer";
|
|
33
|
+
defaultVersion = "1.0.0";
|
|
34
|
+
store = {
|
|
35
|
+
customerList: [],
|
|
36
|
+
selectedCustomer: null,
|
|
37
|
+
total: 0,
|
|
38
|
+
currentPage: 1,
|
|
39
|
+
pageSize: import_constants.DEFAULT_PAGE_SIZE,
|
|
40
|
+
loading: false,
|
|
41
|
+
error: null,
|
|
42
|
+
hasMore: true,
|
|
43
|
+
loadingMore: false,
|
|
44
|
+
searchParams: {}
|
|
45
|
+
};
|
|
46
|
+
request;
|
|
47
|
+
cacheId;
|
|
48
|
+
openCache = false;
|
|
49
|
+
fatherModule;
|
|
32
50
|
constructor(name, version) {
|
|
33
51
|
super(name, version);
|
|
34
|
-
this.defaultName = "customer";
|
|
35
|
-
this.defaultVersion = "1.0.0";
|
|
36
|
-
this.store = {
|
|
37
|
-
customerList: [],
|
|
38
|
-
selectedCustomer: null,
|
|
39
|
-
total: 0,
|
|
40
|
-
currentPage: 1,
|
|
41
|
-
pageSize: import_constants.DEFAULT_PAGE_SIZE,
|
|
42
|
-
loading: false,
|
|
43
|
-
error: null,
|
|
44
|
-
hasMore: true,
|
|
45
|
-
loadingMore: false,
|
|
46
|
-
searchParams: {}
|
|
47
|
-
};
|
|
48
|
-
this.openCache = false;
|
|
49
52
|
}
|
|
50
53
|
async initialize(core, options) {
|
|
51
54
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
@@ -33,7 +33,7 @@ export interface ShopCustomer extends ICustomer {
|
|
|
33
33
|
* walletDetails.wallet: 用户所有wallet
|
|
34
34
|
* latestWalletDetail.wallet: 用户最新wallet
|
|
35
35
|
*/
|
|
36
|
-
type CustomerWith = 'formRecord' | 'walletDetails.wallet' | 'latestWalletDetail.wallet';
|
|
36
|
+
declare type CustomerWith = 'formRecord' | 'walletDetails.wallet' | 'latestWalletDetail.wallet';
|
|
37
37
|
/**
|
|
38
38
|
* 获取客户列表参数
|
|
39
39
|
*/
|
|
@@ -37,11 +37,15 @@ var import_BaseModule = require("../BaseModule");
|
|
|
37
37
|
var import_utils = require("./utils");
|
|
38
38
|
var import_cloneDeep = __toESM(require("lodash-es/cloneDeep"));
|
|
39
39
|
var DateModule = class extends import_BaseModule.BaseModule {
|
|
40
|
+
defaultName = "date";
|
|
41
|
+
defaultVersion = "1.0.0";
|
|
42
|
+
store;
|
|
43
|
+
request;
|
|
44
|
+
cacheId;
|
|
45
|
+
openCache = false;
|
|
46
|
+
fatherModule;
|
|
40
47
|
constructor(name, version) {
|
|
41
48
|
super(name, version);
|
|
42
|
-
this.defaultName = "date";
|
|
43
|
-
this.defaultVersion = "1.0.0";
|
|
44
|
-
this.openCache = false;
|
|
45
49
|
}
|
|
46
50
|
async initialize(core, options) {
|
|
47
51
|
var _a, _b;
|
|
@@ -53,7 +57,7 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
53
57
|
this.store.dateList = options.initialState.dateList;
|
|
54
58
|
}
|
|
55
59
|
if (!this.request) {
|
|
56
|
-
throw new Error("DateModule
|
|
60
|
+
throw new Error("DateModule \u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
|
|
57
61
|
}
|
|
58
62
|
if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
|
|
59
63
|
this.openCache = options.otherParams.openCache;
|
|
@@ -191,13 +195,13 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
191
195
|
if (startAt.isBefore(resourceStartTime)) {
|
|
192
196
|
const roundedStartTime = this.roundUpToNext10Minutes(resourceStartTime);
|
|
193
197
|
const roundedStartTimeDayjs = (0, import_dayjs.default)(roundedStartTime);
|
|
194
|
-
console.log(`[DateModule]
|
|
198
|
+
console.log(`[DateModule] \u4FEE\u6B63\u65F6\u95F4\u6BB5\u5F00\u59CB\u65F6\u95F4: ${timeSlot.start_at} -> ${roundedStartTime} (\u8D44\u6E90ID: ${resource.id}, \u539F\u59CBstart_time: ${resource.start_time})`);
|
|
195
199
|
const correctedTimeSlot = {
|
|
196
200
|
...timeSlot,
|
|
197
201
|
start_at: roundedStartTime
|
|
198
202
|
};
|
|
199
203
|
if (endAt.isBefore(roundedStartTimeDayjs)) {
|
|
200
|
-
console.log(`[DateModule]
|
|
204
|
+
console.log(`[DateModule] \u65F6\u95F4\u6BB5\u65E0\u6548\uFF0C\u5C06\u88AB\u5220\u9664: ${timeSlot.start_at} - ${timeSlot.end_at} (\u8D44\u6E90ID: ${resource.id}, \u4FEE\u6B63\u540Estart_time: ${roundedStartTime})`);
|
|
201
205
|
return null;
|
|
202
206
|
}
|
|
203
207
|
return correctedTimeSlot;
|
|
@@ -23,6 +23,7 @@ __export(types_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(types_exports);
|
|
25
25
|
var DateHooks = /* @__PURE__ */ ((DateHooks2) => {
|
|
26
|
+
return DateHooks2;
|
|
26
27
|
})(DateHooks || {});
|
|
27
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
29
|
0 && (module.exports = {
|
|
@@ -14,6 +14,8 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
14
14
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
15
15
|
setDiscountList(discountList: Discount[]): Promise<void>;
|
|
16
16
|
getDiscountList(): Discount[];
|
|
17
|
+
setOriginalDiscountList(originalDiscountList: Discount[]): Promise<void>;
|
|
18
|
+
getOriginalDiscountList(): Discount[];
|
|
17
19
|
loadPrepareConfig(params: {
|
|
18
20
|
action?: 'create';
|
|
19
21
|
with_good_pass: 0 | 1;
|
|
@@ -37,14 +37,19 @@ var import_BaseModule = require("../BaseModule");
|
|
|
37
37
|
var import_types = require("./types");
|
|
38
38
|
var import_decimal = __toESM(require("decimal.js"));
|
|
39
39
|
var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
40
|
+
defaultName = "discount";
|
|
41
|
+
defaultVersion = "1.0.0";
|
|
42
|
+
request;
|
|
43
|
+
window;
|
|
44
|
+
store;
|
|
45
|
+
cacheId;
|
|
46
|
+
openCache = false;
|
|
47
|
+
fatherModule;
|
|
40
48
|
constructor(name, version) {
|
|
41
49
|
super(name, version);
|
|
42
|
-
this.defaultName = "discount";
|
|
43
|
-
this.defaultVersion = "1.0.0";
|
|
44
|
-
this.openCache = false;
|
|
45
50
|
}
|
|
46
51
|
async initialize(core, options) {
|
|
47
|
-
var _a, _b, _c;
|
|
52
|
+
var _a, _b, _c, _d;
|
|
48
53
|
this.core = core;
|
|
49
54
|
this.store = options == null ? void 0 : options.store;
|
|
50
55
|
if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.discountList)) {
|
|
@@ -52,20 +57,25 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
52
57
|
} else {
|
|
53
58
|
this.store.discountList = [];
|
|
54
59
|
}
|
|
55
|
-
if ((_b = options == null ? void 0 : options.
|
|
60
|
+
if (Array.isArray((_b = options == null ? void 0 : options.initialState) == null ? void 0 : _b.originalDiscountList)) {
|
|
61
|
+
this.store.originalDiscountList = options == null ? void 0 : options.initialState.originalDiscountList;
|
|
62
|
+
} else {
|
|
63
|
+
this.store.originalDiscountList = [];
|
|
64
|
+
}
|
|
65
|
+
if ((_c = options == null ? void 0 : options.otherParams) == null ? void 0 : _c.cacheId) {
|
|
56
66
|
this.openCache = options.otherParams.openCache;
|
|
57
67
|
this.cacheId = options.otherParams.cacheId;
|
|
58
68
|
}
|
|
59
|
-
if ((
|
|
69
|
+
if ((_d = options == null ? void 0 : options.otherParams) == null ? void 0 : _d.fatherModule) {
|
|
60
70
|
this.fatherModule = options.otherParams.fatherModule;
|
|
61
71
|
}
|
|
62
72
|
this.request = core.getPlugin("request");
|
|
63
73
|
this.window = core.getPlugin("window");
|
|
64
74
|
if (!this.request) {
|
|
65
|
-
throw new Error("discount
|
|
75
|
+
throw new Error("discount\u6A21\u5757\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
|
|
66
76
|
}
|
|
67
77
|
if (!this.window) {
|
|
68
|
-
throw new Error("discount
|
|
78
|
+
throw new Error("discount\u6A21\u5757\u9700\u8981 window \u63D2\u4EF6\u652F\u6301");
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
81
|
async setDiscountList(discountList) {
|
|
@@ -78,6 +88,14 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
78
88
|
getDiscountList() {
|
|
79
89
|
return this.store.discountList;
|
|
80
90
|
}
|
|
91
|
+
// 设置原始优惠券列表
|
|
92
|
+
async setOriginalDiscountList(originalDiscountList) {
|
|
93
|
+
this.store.originalDiscountList = originalDiscountList;
|
|
94
|
+
}
|
|
95
|
+
// 获取原始优惠券列表
|
|
96
|
+
getOriginalDiscountList() {
|
|
97
|
+
return this.store.originalDiscountList || [];
|
|
98
|
+
}
|
|
81
99
|
async loadPrepareConfig(params) {
|
|
82
100
|
var _a, _b;
|
|
83
101
|
const prepareConfig = await this.request.post(
|
|
@@ -172,10 +190,11 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
172
190
|
this.store.discountList = [];
|
|
173
191
|
this.core.effects.offByModuleDestroy(this.name);
|
|
174
192
|
await this.core.effects.emit(import_types.DiscountHooks.OnDestroy, {});
|
|
175
|
-
console.log("[Discount]
|
|
193
|
+
console.log("[Discount] \u5DF2\u9500\u6BC1");
|
|
176
194
|
}
|
|
177
195
|
async clear() {
|
|
178
196
|
this.store.discountList = [];
|
|
197
|
+
this.store.originalDiscountList = [];
|
|
179
198
|
console.log("[Discount] clear");
|
|
180
199
|
}
|
|
181
200
|
storeChange() {
|
|
@@ -72,6 +72,7 @@ export interface Discount {
|
|
|
72
72
|
format_title: Formattitle;
|
|
73
73
|
metadata?: {
|
|
74
74
|
discount_card_type?: 'fixed_amount' | 'percent';
|
|
75
|
+
validity_type?: "custom_schedule_validity" | "fixed_validity";
|
|
75
76
|
};
|
|
76
77
|
product: Product;
|
|
77
78
|
type: "product" | 'good_pass';
|
|
@@ -98,9 +99,13 @@ export interface Discount {
|
|
|
98
99
|
week_order_behavior_count?: number;
|
|
99
100
|
month_order_behavior_count?: number;
|
|
100
101
|
customer_order_behavior_count?: number;
|
|
102
|
+
custom_schedule_snapshot?: {
|
|
103
|
+
data: any[];
|
|
104
|
+
};
|
|
101
105
|
}
|
|
102
106
|
export interface DiscountState {
|
|
103
107
|
discountList: Discount[];
|
|
108
|
+
originalDiscountList?: Discount[];
|
|
104
109
|
}
|
|
105
110
|
export interface DiscountModuleAPI {
|
|
106
111
|
setDiscountList: (discountList: Discount[]) => Promise<void>;
|
|
@@ -25,13 +25,13 @@ module.exports = __toCommonJS(Guests_exports);
|
|
|
25
25
|
var import_BaseModule = require("../BaseModule");
|
|
26
26
|
var import_types = require("./types");
|
|
27
27
|
var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
28
|
+
defaultName = "guestList";
|
|
29
|
+
defaultVersion = "1.0.0";
|
|
30
|
+
state = {
|
|
31
|
+
list: []
|
|
32
|
+
};
|
|
28
33
|
constructor(name, version) {
|
|
29
34
|
super(name, version);
|
|
30
|
-
this.defaultName = "guestList";
|
|
31
|
-
this.defaultVersion = "1.0.0";
|
|
32
|
-
this.state = {
|
|
33
|
-
list: []
|
|
34
|
-
};
|
|
35
35
|
}
|
|
36
36
|
async initialize(core, options) {
|
|
37
37
|
this.core = core;
|
|
@@ -46,8 +46,7 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
|
46
46
|
}
|
|
47
47
|
async updateGuest(id, updates) {
|
|
48
48
|
const index = this.state.list.findIndex((g) => g.id === id);
|
|
49
|
-
if (index === -1)
|
|
50
|
-
return;
|
|
49
|
+
if (index === -1) return;
|
|
51
50
|
this.state.list[index] = {
|
|
52
51
|
...this.state.list[index],
|
|
53
52
|
...updates
|
|
@@ -60,8 +59,7 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
|
60
59
|
}
|
|
61
60
|
async removeGuest(id) {
|
|
62
61
|
const index = this.state.list.findIndex((g) => g.id === id);
|
|
63
|
-
if (index === -1)
|
|
64
|
-
return;
|
|
62
|
+
if (index === -1) return;
|
|
65
63
|
const [removed] = this.state.list.splice(index, 1);
|
|
66
64
|
await this.core.effects.emit(import_types.GuestHooks.OnGuestRemove, removed);
|
|
67
65
|
await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
|
|
@@ -74,19 +72,16 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
|
74
72
|
}
|
|
75
73
|
async addItemToGuest(guestId, item) {
|
|
76
74
|
const guest = this.state.list.find((g) => g.id === guestId);
|
|
77
|
-
if (!guest)
|
|
78
|
-
return;
|
|
75
|
+
if (!guest) return;
|
|
79
76
|
guest.items.push(item);
|
|
80
77
|
await this.core.effects.emit(import_types.GuestHooks.OnGuestUpdate, guest);
|
|
81
78
|
await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
|
|
82
79
|
}
|
|
83
80
|
async removeItemFromGuest(guestId, itemId) {
|
|
84
81
|
const guest = this.state.list.find((g) => g.id === guestId);
|
|
85
|
-
if (!guest)
|
|
86
|
-
return;
|
|
82
|
+
if (!guest) return;
|
|
87
83
|
const index = guest.items.findIndex((i) => i.id === itemId);
|
|
88
|
-
if (index === -1)
|
|
89
|
-
return;
|
|
84
|
+
if (index === -1) return;
|
|
90
85
|
guest.items.splice(index, 1);
|
|
91
86
|
await this.core.effects.emit(import_types.GuestHooks.OnGuestUpdate, guest);
|
|
92
87
|
await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
|
|
@@ -37,11 +37,14 @@ var import_utils = require("./utils");
|
|
|
37
37
|
var import_utils2 = require("../Product/utils");
|
|
38
38
|
var import_dayjs = __toESM(require("dayjs"));
|
|
39
39
|
var OrderModule = class extends import_BaseModule.BaseModule {
|
|
40
|
+
defaultName = "order";
|
|
41
|
+
defaultVersion = "1.0.0";
|
|
42
|
+
store;
|
|
43
|
+
request;
|
|
44
|
+
logger;
|
|
40
45
|
// LoggerManager 实例
|
|
41
46
|
constructor(name, version) {
|
|
42
47
|
super(name, version);
|
|
43
|
-
this.defaultName = "order";
|
|
44
|
-
this.defaultVersion = "1.0.0";
|
|
45
48
|
}
|
|
46
49
|
async initialize(core, options) {
|
|
47
50
|
this.core = core;
|
|
@@ -49,11 +52,10 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
49
52
|
this.request = this.core.getPlugin("request");
|
|
50
53
|
const appPlugin = this.core.getPlugin("app");
|
|
51
54
|
if (!appPlugin) {
|
|
52
|
-
console.warn("Order
|
|
55
|
+
console.warn("Order \u6A21\u5757\u9700\u8981 app \u63D2\u4EF6\u652F\u6301");
|
|
53
56
|
}
|
|
54
57
|
const app = appPlugin == null ? void 0 : appPlugin.getApp();
|
|
55
|
-
if (app)
|
|
56
|
-
this.logger = app.logger;
|
|
58
|
+
if (app) this.logger = app.logger;
|
|
57
59
|
this.logInfo("OrderModule initialized successfully");
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
@@ -206,7 +208,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
206
208
|
orderIdIncluded: params.order_id,
|
|
207
209
|
paymentMethods: ((_d = params.payments) == null ? void 0 : _d.map((p) => p.code)) || []
|
|
208
210
|
});
|
|
209
|
-
console.log("[Order] createOrderByCheckout
|
|
211
|
+
console.log("[Order] createOrderByCheckout \u5F00\u59CB\u521B\u5EFA\u8BA2\u5355:", {
|
|
210
212
|
type: params.type,
|
|
211
213
|
platform: params.platform,
|
|
212
214
|
is_deposit: params.is_deposit,
|
|
@@ -236,7 +238,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
236
238
|
if (!params.order_id && !orderData.schedule_date) {
|
|
237
239
|
orderData.schedule_date = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
238
240
|
}
|
|
239
|
-
console.log("[Order]
|
|
241
|
+
console.log("[Order] \u8C03\u7528\u540E\u7AEF\u63A5\u53E3\u521B\u5EFA\u8BA2\u5355:", {
|
|
240
242
|
url: "/order/checkout",
|
|
241
243
|
orderType: orderData.type,
|
|
242
244
|
platform: orderData.platform,
|
|
@@ -274,13 +276,13 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
274
276
|
this.logInfo("Order API called successfully", {
|
|
275
277
|
response
|
|
276
278
|
});
|
|
277
|
-
console.log("[Order]
|
|
279
|
+
console.log("[Order] \u8BA2\u5355\u521B\u5EFA\u6210\u529F\uFF0C\u540E\u7AEF\u54CD\u5E94:", {
|
|
278
280
|
success: !!response,
|
|
279
281
|
hasOrderId: !!(((_q = response == null ? void 0 : response.data) == null ? void 0 : _q.order_id) || (response == null ? void 0 : response.order_id))
|
|
280
282
|
});
|
|
281
283
|
return response;
|
|
282
284
|
} catch (error) {
|
|
283
|
-
console.error("[Order] createOrderByCheckout
|
|
285
|
+
console.error("[Order] createOrderByCheckout \u521B\u5EFA\u8BA2\u5355\u5931\u8D25:", error);
|
|
284
286
|
this.logInfo("Order API called failed", {
|
|
285
287
|
error: error instanceof Error ? error.message : String(error)
|
|
286
288
|
});
|
|
@@ -30,7 +30,7 @@ var CashPaymentImpl = class {
|
|
|
30
30
|
async processCashPayment(amount, orderUuid) {
|
|
31
31
|
const cashMethod = await this.paymentModule.getCashPaymentMethod();
|
|
32
32
|
if (!cashMethod) {
|
|
33
|
-
throw new Error("
|
|
33
|
+
throw new Error("\u73B0\u91D1\u652F\u4ED8\u65B9\u5F0F\u672A\u627E\u5230");
|
|
34
34
|
}
|
|
35
35
|
const paymentItem = {
|
|
36
36
|
amount: amount.toString(),
|
|
@@ -213,7 +213,7 @@ function recommendOptimalPayments(targetAmount, denominations) {
|
|
|
213
213
|
}
|
|
214
214
|
return finalResults.sort((a, b) => a - b);
|
|
215
215
|
} catch (error) {
|
|
216
|
-
console.warn("
|
|
216
|
+
console.warn("\u63A8\u8350\u652F\u4ED8\u91D1\u989D\u8BA1\u7B97\u51FA\u9519:", error);
|
|
217
217
|
const safeAmount = Math.ceil(targetAmount);
|
|
218
218
|
return [targetAmount, safeAmount];
|
|
219
219
|
}
|
|
@@ -29,7 +29,7 @@ var EftposPaymentImpl = class {
|
|
|
29
29
|
async processEftposPayment(amount, orderUuid) {
|
|
30
30
|
const eftposMethod = await this.paymentModule.getEftposPaymentMethod();
|
|
31
31
|
if (!eftposMethod) {
|
|
32
|
-
throw new Error("Eftpos
|
|
32
|
+
throw new Error("Eftpos\u652F\u4ED8\u65B9\u5F0F\u672A\u627E\u5230");
|
|
33
33
|
}
|
|
34
34
|
const paymentItem = {
|
|
35
35
|
amount: amount.toString(),
|