@pisell/pisellos 2.1.3 → 2.1.5
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/core/index.js +2 -1
- package/dist/effects/index.d.ts +4 -3
- package/dist/effects/index.js +15 -6
- package/dist/modules/AccountList/index.d.ts +7 -1
- package/dist/modules/AccountList/index.js +81 -14
- package/dist/modules/AccountList/types.d.ts +28 -0
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/Cart/index.js +1 -1
- package/dist/modules/Customer/constants.d.ts +7 -0
- package/dist/modules/Customer/constants.js +12 -0
- package/dist/modules/Customer/index.d.ts +122 -0
- package/dist/modules/Customer/index.js +697 -0
- package/dist/modules/Customer/types.d.ts +146 -0
- package/dist/modules/Customer/types.js +41 -0
- package/dist/modules/Date/index.d.ts +17 -0
- package/dist/modules/Date/index.js +92 -4
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Order/index.d.ts +25 -1
- package/dist/modules/Order/index.js +224 -2
- package/dist/modules/Order/types.d.ts +45 -0
- package/dist/modules/Order/types.js +8 -0
- package/dist/modules/Payment/cash.d.ts +19 -0
- package/dist/modules/Payment/cash.js +97 -0
- package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
- package/dist/modules/Payment/cashRecommendationAlgorithm.js +423 -0
- package/dist/modules/Payment/eftpos.d.ts +11 -0
- package/dist/modules/Payment/eftpos.js +80 -0
- package/dist/modules/Payment/index.d.ts +184 -9
- package/dist/modules/Payment/index.js +2012 -108
- package/dist/modules/Payment/mx51.d.ts +0 -0
- package/dist/modules/Payment/mx51.js +0 -0
- package/dist/modules/Payment/types.d.ts +750 -30
- package/dist/modules/Payment/types.js +236 -12
- package/dist/modules/Payment/utils.d.ts +17 -0
- package/dist/modules/Payment/utils.js +62 -0
- package/dist/modules/Payment/walletpass.d.ts +99 -0
- package/dist/modules/Payment/walletpass.js +701 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.d.ts +12 -1
- package/dist/modules/ProductList/index.js +27 -3
- package/dist/modules/Rules/index.d.ts +2 -0
- package/dist/modules/Rules/index.js +39 -17
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +9 -0
- package/dist/modules/Schedule/index.js +68 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/app-types/app/app.d.ts +83 -0
- package/dist/plugins/app-types/app/const.d.ts +4 -0
- package/dist/plugins/app-types/app/index.d.ts +14 -0
- package/dist/plugins/app-types/applicationManager/application.d.ts +50 -0
- package/dist/plugins/app-types/applicationManager/index.d.ts +13 -0
- package/dist/plugins/app-types/config.d.ts +3 -0
- package/dist/plugins/app-types/cookie/index.d.ts +13 -0
- package/dist/plugins/app-types/data/index.d.ts +8 -0
- package/dist/plugins/app-types/history/config.d.ts +24 -0
- package/dist/plugins/app-types/history/index.d.ts +20 -0
- package/dist/plugins/app-types/history/type.d.ts +2 -0
- package/dist/plugins/app-types/hooks/index.d.ts +12 -0
- package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
- package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
- package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
- package/dist/plugins/app-types/hooks/useStore/index.d.ts +6 -0
- package/dist/plugins/app-types/index.d.ts +6 -0
- package/dist/plugins/app-types/indexDB/index.d.ts +178 -0
- package/dist/plugins/app-types/locales/en.d.ts +3 -0
- package/dist/plugins/app-types/locales/index.d.ts +37 -0
- package/dist/plugins/app-types/locales/original.d.ts +3 -0
- package/dist/plugins/app-types/locales/type.d.ts +19 -0
- package/dist/plugins/app-types/locales/zh-CN.d.ts +3 -0
- package/dist/plugins/app-types/locales/zh-HK.d.ts +3 -0
- package/dist/plugins/app-types/logger/feishu.d.ts +11 -0
- package/dist/plugins/app-types/logger/index.d.ts +122 -0
- package/dist/plugins/app-types/menuManager/hooks.d.ts +17 -0
- package/dist/plugins/app-types/menuManager/index.d.ts +28 -0
- package/dist/plugins/app-types/models/global.d.ts +32 -0
- package/dist/plugins/app-types/models/index.d.ts +45 -0
- package/dist/plugins/app-types/models/type.d.ts +2 -0
- package/dist/plugins/app-types/package.json +15 -0
- package/dist/plugins/app-types/plugin/index.d.ts +0 -0
- package/dist/plugins/app-types/pubsub/example.d.ts +5 -0
- package/dist/plugins/app-types/pubsub/index.d.ts +63 -0
- package/dist/plugins/app-types/request/cache.d.ts +46 -0
- package/dist/plugins/app-types/request/cancelToken.d.ts +38 -0
- package/dist/plugins/app-types/request/config.d.ts +3 -0
- package/dist/plugins/app-types/request/constants.d.ts +2 -0
- package/dist/plugins/app-types/request/index.d.ts +24 -0
- package/dist/plugins/app-types/request/pisell2Request.d.ts +6 -0
- package/dist/plugins/app-types/request/type.d.ts +41 -0
- package/dist/plugins/app-types/request/utils.d.ts +46 -0
- package/dist/plugins/app-types/routes/config.d.ts +7 -0
- package/dist/plugins/app-types/routes/index.d.ts +28 -0
- package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
- package/dist/plugins/app-types/socket/components/index.d.ts +2 -0
- package/dist/plugins/app-types/socket/constants.d.ts +33 -0
- package/dist/plugins/app-types/socket/events.d.ts +31 -0
- package/dist/plugins/app-types/socket/heartbeat.d.ts +66 -0
- package/dist/plugins/app-types/socket/index.d.ts +61 -0
- package/dist/plugins/app-types/socket/monitor.d.ts +169 -0
- package/dist/plugins/app-types/socket/reconnect.d.ts +61 -0
- package/dist/plugins/app-types/socket/socket.d.ts +129 -0
- package/dist/plugins/app-types/socket/types.d.ts +85 -0
- package/dist/plugins/app-types/storage/index.d.ts +17 -0
- package/dist/plugins/app-types/tasks/index.d.ts +77 -0
- package/dist/plugins/app-types/tasks/type.d.ts +62 -0
- package/dist/plugins/app-types/tasks/useTasks.d.ts +5 -0
- package/dist/plugins/app-types/type.d.ts +2 -0
- package/dist/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
- package/dist/plugins/app-types/variables/config.d.ts +3 -0
- package/dist/plugins/app-types/variables/index.d.ts +6 -0
- package/dist/plugins/app-types/variables/type.d.ts +2 -0
- package/dist/plugins/app-types/website/index.d.ts +6 -0
- package/dist/plugins/app.d.ts +8 -0
- package/dist/plugins/app.js +1 -0
- package/dist/plugins/window.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +1 -1
- package/dist/solution/BookingTicket/index.d.ts +180 -0
- package/dist/solution/BookingTicket/index.js +689 -0
- package/dist/solution/BookingTicket/types.d.ts +68 -0
- package/dist/solution/BookingTicket/types.js +43 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +159 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +22 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +189 -0
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +81 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +285 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
- package/dist/solution/Checkout/appointmentDemo.json +1 -0
- package/dist/solution/Checkout/index.d.ts +509 -0
- package/dist/solution/Checkout/index.js +4874 -0
- package/dist/solution/Checkout/types.d.ts +923 -0
- package/dist/solution/Checkout/types.js +148 -0
- package/dist/solution/Checkout/utils/index.d.ts +117 -0
- package/dist/solution/Checkout/utils/index.js +549 -0
- package/dist/solution/ShopDiscount/index.d.ts +4 -9
- package/dist/solution/ShopDiscount/index.js +106 -54
- package/dist/solution/ShopDiscount/types.d.ts +10 -1
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/utils/task.d.ts +40 -0
- package/dist/utils/task.js +171 -0
- package/dist/utils/watch.d.ts +102 -0
- package/dist/utils/watch.js +294 -0
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +4 -3
- package/lib/effects/index.js +4 -1
- package/lib/modules/AccountList/index.d.ts +7 -1
- package/lib/modules/AccountList/index.js +27 -0
- package/lib/modules/AccountList/types.d.ts +28 -0
- package/lib/modules/Cart/index.js +1 -1
- package/lib/modules/Customer/constants.d.ts +7 -0
- package/lib/modules/Customer/constants.js +39 -0
- package/lib/modules/Customer/index.d.ts +122 -0
- package/lib/modules/Customer/index.js +440 -0
- package/lib/modules/Customer/types.d.ts +146 -0
- package/lib/modules/Customer/types.js +37 -0
- package/lib/modules/Date/index.d.ts +17 -0
- package/lib/modules/Date/index.js +64 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Order/index.d.ts +25 -1
- package/lib/modules/Order/index.js +182 -0
- package/lib/modules/Order/types.d.ts +45 -0
- package/lib/modules/Payment/cash.d.ts +19 -0
- package/lib/modules/Payment/cash.js +64 -0
- package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +342 -0
- package/lib/modules/Payment/eftpos.d.ts +11 -0
- package/lib/modules/Payment/eftpos.js +51 -0
- package/lib/modules/Payment/index.d.ts +184 -9
- package/lib/modules/Payment/index.js +1044 -50
- package/lib/modules/Payment/mx51.d.ts +0 -0
- package/lib/modules/Payment/mx51.js +0 -0
- package/lib/modules/Payment/types.d.ts +750 -30
- package/lib/modules/Payment/types.js +79 -6
- package/lib/modules/Payment/utils.d.ts +17 -0
- package/lib/modules/Payment/utils.js +67 -0
- package/lib/modules/Payment/walletpass.d.ts +99 -0
- package/lib/modules/Payment/walletpass.js +468 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.d.ts +12 -1
- package/lib/modules/ProductList/index.js +29 -2
- package/lib/modules/Rules/index.d.ts +2 -0
- package/lib/modules/Rules/index.js +32 -15
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +9 -0
- package/lib/modules/Schedule/index.js +51 -0
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +2 -0
- package/lib/plugins/app-types/app/app.d.ts +83 -0
- package/lib/plugins/app-types/app/const.d.ts +4 -0
- package/lib/plugins/app-types/app/index.d.ts +14 -0
- package/lib/plugins/app-types/applicationManager/application.d.ts +50 -0
- package/lib/plugins/app-types/applicationManager/index.d.ts +13 -0
- package/lib/plugins/app-types/config.d.ts +3 -0
- package/lib/plugins/app-types/cookie/index.d.ts +13 -0
- package/lib/plugins/app-types/data/index.d.ts +8 -0
- package/lib/plugins/app-types/history/config.d.ts +24 -0
- package/lib/plugins/app-types/history/index.d.ts +20 -0
- package/lib/plugins/app-types/history/type.d.ts +2 -0
- package/lib/plugins/app-types/hooks/index.d.ts +12 -0
- package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
- package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
- package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
- package/lib/plugins/app-types/hooks/useStore/index.d.ts +6 -0
- package/lib/plugins/app-types/index.d.ts +6 -0
- package/lib/plugins/app-types/indexDB/index.d.ts +178 -0
- package/lib/plugins/app-types/locales/en.d.ts +3 -0
- package/lib/plugins/app-types/locales/index.d.ts +37 -0
- package/lib/plugins/app-types/locales/original.d.ts +3 -0
- package/lib/plugins/app-types/locales/type.d.ts +19 -0
- package/lib/plugins/app-types/locales/zh-CN.d.ts +3 -0
- package/lib/plugins/app-types/locales/zh-HK.d.ts +3 -0
- package/lib/plugins/app-types/logger/feishu.d.ts +11 -0
- package/lib/plugins/app-types/logger/index.d.ts +122 -0
- package/lib/plugins/app-types/menuManager/hooks.d.ts +17 -0
- package/lib/plugins/app-types/menuManager/index.d.ts +28 -0
- package/lib/plugins/app-types/models/global.d.ts +32 -0
- package/lib/plugins/app-types/models/index.d.ts +45 -0
- package/lib/plugins/app-types/models/type.d.ts +2 -0
- package/lib/plugins/app-types/package.json +15 -0
- package/lib/plugins/app-types/plugin/index.d.ts +0 -0
- package/lib/plugins/app-types/pubsub/example.d.ts +5 -0
- package/lib/plugins/app-types/pubsub/index.d.ts +63 -0
- package/lib/plugins/app-types/request/cache.d.ts +46 -0
- package/lib/plugins/app-types/request/cancelToken.d.ts +38 -0
- package/lib/plugins/app-types/request/config.d.ts +3 -0
- package/lib/plugins/app-types/request/constants.d.ts +2 -0
- package/lib/plugins/app-types/request/index.d.ts +24 -0
- package/lib/plugins/app-types/request/pisell2Request.d.ts +6 -0
- package/lib/plugins/app-types/request/type.d.ts +41 -0
- package/lib/plugins/app-types/request/utils.d.ts +46 -0
- package/lib/plugins/app-types/routes/config.d.ts +7 -0
- package/lib/plugins/app-types/routes/index.d.ts +28 -0
- package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/plugins/app-types/socket/components/index.d.ts +2 -0
- package/lib/plugins/app-types/socket/constants.d.ts +33 -0
- package/lib/plugins/app-types/socket/events.d.ts +31 -0
- package/lib/plugins/app-types/socket/heartbeat.d.ts +66 -0
- package/lib/plugins/app-types/socket/index.d.ts +61 -0
- package/lib/plugins/app-types/socket/monitor.d.ts +169 -0
- package/lib/plugins/app-types/socket/reconnect.d.ts +61 -0
- package/lib/plugins/app-types/socket/socket.d.ts +129 -0
- package/lib/plugins/app-types/socket/types.d.ts +85 -0
- package/lib/plugins/app-types/storage/index.d.ts +17 -0
- package/lib/plugins/app-types/tasks/index.d.ts +77 -0
- package/lib/plugins/app-types/tasks/type.d.ts +62 -0
- package/lib/plugins/app-types/tasks/useTasks.d.ts +5 -0
- package/lib/plugins/app-types/type.d.ts +2 -0
- package/lib/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
- package/lib/plugins/app-types/variables/config.d.ts +3 -0
- package/lib/plugins/app-types/variables/index.d.ts +6 -0
- package/lib/plugins/app-types/variables/type.d.ts +2 -0
- package/lib/plugins/app-types/website/index.d.ts +6 -0
- package/lib/plugins/app.d.ts +8 -0
- package/lib/plugins/app.js +17 -0
- package/lib/plugins/window.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1 -2
- package/lib/solution/BookingTicket/index.d.ts +180 -0
- package/lib/solution/BookingTicket/index.js +420 -0
- package/lib/solution/BookingTicket/types.d.ts +68 -0
- package/lib/solution/BookingTicket/types.js +72 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +117 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +22 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +132 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +81 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +210 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
- package/lib/solution/Checkout/appointmentDemo.json +1 -0
- package/lib/solution/Checkout/index.d.ts +509 -0
- package/lib/solution/Checkout/index.js +3002 -0
- package/lib/solution/Checkout/types.d.ts +923 -0
- package/lib/solution/Checkout/types.js +87 -0
- package/lib/solution/Checkout/utils/index.d.ts +117 -0
- package/lib/solution/Checkout/utils/index.js +403 -0
- package/lib/solution/ShopDiscount/index.d.ts +4 -9
- package/lib/solution/ShopDiscount/index.js +41 -13
- package/lib/solution/ShopDiscount/types.d.ts +10 -1
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/lib/types/index.d.ts +3 -1
- package/lib/utils/task.d.ts +40 -0
- package/lib/utils/task.js +109 -0
- package/lib/utils/watch.d.ts +102 -0
- package/lib/utils/watch.js +217 -0
- package/package.json +4 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/modules/Customer/types.ts
|
|
20
|
+
var types_exports = {};
|
|
21
|
+
__export(types_exports, {
|
|
22
|
+
CustomerHooks: () => CustomerHooks
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(types_exports);
|
|
25
|
+
var CustomerHooks = /* @__PURE__ */ ((CustomerHooks2) => {
|
|
26
|
+
CustomerHooks2["OnCustomerListUpdate"] = "customer:onUpdate";
|
|
27
|
+
CustomerHooks2["OnCustomerListError"] = "customer:onError";
|
|
28
|
+
CustomerHooks2["OnCustomerSelected"] = "customer:onSelected";
|
|
29
|
+
CustomerHooks2["OnPaginationChange"] = "customer:onPaginationChange";
|
|
30
|
+
CustomerHooks2["OnScrollLoadMore"] = "customer:onScrollLoadMore";
|
|
31
|
+
CustomerHooks2["OnScrollLoadComplete"] = "customer:onScrollLoadComplete";
|
|
32
|
+
return CustomerHooks2;
|
|
33
|
+
})(CustomerHooks || {});
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
CustomerHooks
|
|
37
|
+
});
|
|
@@ -17,6 +17,23 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
17
17
|
getDateList(): ITime[];
|
|
18
18
|
setDateList(dateList: ITime[]): void;
|
|
19
19
|
fetchResourceDates(params: IGetAvailableTimeListParams): Promise<any>;
|
|
20
|
+
/**
|
|
21
|
+
* 将时间向上取整到下一个10分钟整数
|
|
22
|
+
*
|
|
23
|
+
* @param time dayjs 时间对象
|
|
24
|
+
* @returns 向上取整后的时间字符串 (YYYY-MM-DD HH:mm 格式)
|
|
25
|
+
*/
|
|
26
|
+
private roundUpToNext10Minutes;
|
|
27
|
+
/**
|
|
28
|
+
* 校正资源时间段数据
|
|
29
|
+
*
|
|
30
|
+
* 如果时间段的 start_at 早于资源的 start_time,将其同步为 start_time 的下一个10分钟整数
|
|
31
|
+
* 如果修正后 end_at 也早于修正后的 start_time,则删除该时间段
|
|
32
|
+
*
|
|
33
|
+
* @param resourcesData 资源数据数组
|
|
34
|
+
* @returns 校正后的资源数据数组
|
|
35
|
+
*/
|
|
36
|
+
private correctResourceTimeSlots;
|
|
20
37
|
getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
21
38
|
clearDateRange(): void;
|
|
22
39
|
storeChange(): void;
|
|
@@ -32,6 +32,7 @@ __export(Date_exports, {
|
|
|
32
32
|
DateModule: () => DateModule
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(Date_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
35
36
|
var import_BaseModule = require("../BaseModule");
|
|
36
37
|
var import_utils = require("./utils");
|
|
37
38
|
var import_cloneDeep = __toESM(require("lodash-es/cloneDeep"));
|
|
@@ -138,11 +139,74 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
138
139
|
}, {
|
|
139
140
|
useCache
|
|
140
141
|
});
|
|
142
|
+
if ((res == null ? void 0 : res.data) && Array.isArray(res.data)) {
|
|
143
|
+
res.data = this.correctResourceTimeSlots(res.data);
|
|
144
|
+
}
|
|
141
145
|
return res;
|
|
142
146
|
} catch (error) {
|
|
143
147
|
console.error(error);
|
|
144
148
|
}
|
|
145
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* 将时间向上取整到下一个10分钟整数
|
|
152
|
+
*
|
|
153
|
+
* @param time dayjs 时间对象
|
|
154
|
+
* @returns 向上取整后的时间字符串 (YYYY-MM-DD HH:mm 格式)
|
|
155
|
+
*/
|
|
156
|
+
roundUpToNext10Minutes(time) {
|
|
157
|
+
const minutes = time.minute();
|
|
158
|
+
const remainder = minutes % 10;
|
|
159
|
+
if (remainder === 0) {
|
|
160
|
+
return time.format("YYYY-MM-DD HH:mm");
|
|
161
|
+
} else {
|
|
162
|
+
const minutesToAdd = 10 - remainder;
|
|
163
|
+
const roundedTime = time.add(minutesToAdd, "minute");
|
|
164
|
+
return roundedTime.format("YYYY-MM-DD HH:mm");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* 校正资源时间段数据
|
|
169
|
+
*
|
|
170
|
+
* 如果时间段的 start_at 早于资源的 start_time,将其同步为 start_time 的下一个10分钟整数
|
|
171
|
+
* 如果修正后 end_at 也早于修正后的 start_time,则删除该时间段
|
|
172
|
+
*
|
|
173
|
+
* @param resourcesData 资源数据数组
|
|
174
|
+
* @returns 校正后的资源数据数组
|
|
175
|
+
*/
|
|
176
|
+
correctResourceTimeSlots(resourcesData) {
|
|
177
|
+
return resourcesData.map((resource) => {
|
|
178
|
+
if (!resource.times || !Array.isArray(resource.times) || !resource.start_time) {
|
|
179
|
+
return resource;
|
|
180
|
+
}
|
|
181
|
+
const resourceStartTime = (0, import_dayjs.default)(resource.start_time);
|
|
182
|
+
const correctedTimes = resource.times.map((timeSlot) => {
|
|
183
|
+
if (!timeSlot.start_at || !timeSlot.end_at) {
|
|
184
|
+
return timeSlot;
|
|
185
|
+
}
|
|
186
|
+
const startAt = (0, import_dayjs.default)(timeSlot.start_at);
|
|
187
|
+
const endAt = (0, import_dayjs.default)(timeSlot.end_at);
|
|
188
|
+
if (startAt.isBefore(resourceStartTime)) {
|
|
189
|
+
const roundedStartTime = this.roundUpToNext10Minutes(resourceStartTime);
|
|
190
|
+
const roundedStartTimeDayjs = (0, import_dayjs.default)(roundedStartTime);
|
|
191
|
+
console.log(`[DateModule] 修正时间段开始时间: ${timeSlot.start_at} -> ${roundedStartTime} (资源ID: ${resource.id}, 原始start_time: ${resource.start_time})`);
|
|
192
|
+
const correctedTimeSlot = {
|
|
193
|
+
...timeSlot,
|
|
194
|
+
start_at: roundedStartTime
|
|
195
|
+
};
|
|
196
|
+
if (endAt.isBefore(roundedStartTimeDayjs)) {
|
|
197
|
+
console.log(`[DateModule] 时间段无效,将被删除: ${timeSlot.start_at} - ${timeSlot.end_at} (资源ID: ${resource.id}, 修正后start_time: ${roundedStartTime})`);
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
return correctedTimeSlot;
|
|
201
|
+
}
|
|
202
|
+
return timeSlot;
|
|
203
|
+
}).filter((timeSlot) => timeSlot !== null);
|
|
204
|
+
return {
|
|
205
|
+
...resource,
|
|
206
|
+
times: correctedTimes
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
}
|
|
146
210
|
async getResourceAvailableTimeList(params) {
|
|
147
211
|
var _a;
|
|
148
212
|
const { query, rules, type } = params;
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { OrderModuleAPI, CommitOrderParams } from './types';
|
|
3
|
+
import { OrderModuleAPI, CommitOrderParams, CheckoutOrderParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
8
8
|
private store;
|
|
9
9
|
private request;
|
|
10
|
+
private logger;
|
|
10
11
|
constructor(name?: string, version?: string);
|
|
11
12
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* 记录信息日志
|
|
15
|
+
*/
|
|
16
|
+
private logInfo;
|
|
17
|
+
/**
|
|
18
|
+
* 记录警告日志
|
|
19
|
+
*/
|
|
20
|
+
private logWarning;
|
|
21
|
+
/**
|
|
22
|
+
* 记录错误日志
|
|
23
|
+
*/
|
|
24
|
+
private logError;
|
|
12
25
|
createOrder(params: CommitOrderParams['query']): {
|
|
13
26
|
type: "virtual" | "appointment_booking";
|
|
14
27
|
platform: string;
|
|
@@ -26,4 +39,15 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
26
39
|
type: 'holder' | 'account';
|
|
27
40
|
}): boolean;
|
|
28
41
|
submitOrder(order: CommitOrderParams): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Checkout 专用:创建订单到后端
|
|
44
|
+
*
|
|
45
|
+
* 专门为 Checkout 模块设计的订单创建方法,
|
|
46
|
+
* 直接调用 /order/checkout 接口创建订单
|
|
47
|
+
* 接收已经处理好的订单数据,无需再处理购物车
|
|
48
|
+
*
|
|
49
|
+
* @param params Checkout 订单参数(已处理的订单数据)
|
|
50
|
+
* @returns 后端返回的订单数据(包含订单ID等)
|
|
51
|
+
*/
|
|
52
|
+
createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
|
|
29
53
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
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
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/modules/Order/index.ts
|
|
@@ -25,7 +35,9 @@ module.exports = __toCommonJS(Order_exports);
|
|
|
25
35
|
var import_BaseModule = require("../BaseModule");
|
|
26
36
|
var import_utils = require("./utils");
|
|
27
37
|
var import_utils2 = require("../Product/utils");
|
|
38
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
28
39
|
var OrderModule = class extends import_BaseModule.BaseModule {
|
|
40
|
+
// LoggerManager 实例
|
|
29
41
|
constructor(name, version) {
|
|
30
42
|
super(name, version);
|
|
31
43
|
this.defaultName = "order";
|
|
@@ -35,6 +47,49 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
35
47
|
this.core = core;
|
|
36
48
|
this.store = options.store;
|
|
37
49
|
this.request = this.core.getPlugin("request");
|
|
50
|
+
const appPlugin = this.core.getPlugin("app");
|
|
51
|
+
if (!appPlugin) {
|
|
52
|
+
throw new Error("Order 模块需要 app 插件支持");
|
|
53
|
+
}
|
|
54
|
+
const app = appPlugin.getApp();
|
|
55
|
+
this.logger = app.logger;
|
|
56
|
+
this.logInfo("OrderModule initialized successfully");
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 记录信息日志
|
|
60
|
+
*/
|
|
61
|
+
logInfo(title, metadata) {
|
|
62
|
+
if (this.logger) {
|
|
63
|
+
this.logger.addLog({
|
|
64
|
+
type: "info",
|
|
65
|
+
title: `[OrderModule] ${title}`,
|
|
66
|
+
metadata: metadata || {}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 记录警告日志
|
|
72
|
+
*/
|
|
73
|
+
logWarning(title, metadata) {
|
|
74
|
+
if (this.logger) {
|
|
75
|
+
this.logger.addLog({
|
|
76
|
+
type: "warning",
|
|
77
|
+
title: `[OrderModule] ${title}`,
|
|
78
|
+
metadata: metadata || {}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 记录错误日志
|
|
84
|
+
*/
|
|
85
|
+
logError(title, metadata) {
|
|
86
|
+
if (this.logger) {
|
|
87
|
+
this.logger.addLog({
|
|
88
|
+
type: "error",
|
|
89
|
+
title: `[OrderModule] ${title}`,
|
|
90
|
+
metadata: metadata || {}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
38
93
|
}
|
|
39
94
|
createOrder(params) {
|
|
40
95
|
var _a;
|
|
@@ -86,6 +141,11 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
86
141
|
return order;
|
|
87
142
|
}
|
|
88
143
|
checkBeforeSubmitOrder(params) {
|
|
144
|
+
var _a;
|
|
145
|
+
this.logInfo("checkBeforeSubmitOrder called", {
|
|
146
|
+
cartItemsCount: ((_a = params.cartItems) == null ? void 0 : _a.length) || 0,
|
|
147
|
+
type: params.type
|
|
148
|
+
});
|
|
89
149
|
const { cartItems, type } = params;
|
|
90
150
|
if (type === "holder") {
|
|
91
151
|
const hasNoHolderId = cartItems.some((item) => !item.holder_id);
|
|
@@ -96,11 +156,133 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
96
156
|
return true;
|
|
97
157
|
}
|
|
98
158
|
async submitOrder(order) {
|
|
159
|
+
var _a, _b, _c;
|
|
160
|
+
this.logInfo("submitOrder called", {
|
|
161
|
+
url: order.url,
|
|
162
|
+
orderType: order.query.type,
|
|
163
|
+
platform: order.query.platform,
|
|
164
|
+
cartItemsCount: ((_a = order.query.cartItems) == null ? void 0 : _a.length) || 0
|
|
165
|
+
});
|
|
99
166
|
const { url, query } = order;
|
|
100
167
|
const fetchUrl = url || "/order/appointment";
|
|
101
168
|
const params = this.createOrder(query);
|
|
169
|
+
this.logInfo("Calling backend order API", {
|
|
170
|
+
url: fetchUrl,
|
|
171
|
+
orderType: params.type,
|
|
172
|
+
platform: params.platform,
|
|
173
|
+
isDeposit: params.is_deposit,
|
|
174
|
+
bookingsCount: ((_b = params.bookings) == null ? void 0 : _b.length) || 0,
|
|
175
|
+
relationProductsCount: ((_c = params.relation_products) == null ? void 0 : _c.length) || 0,
|
|
176
|
+
scheduleDate: params.schedule_date
|
|
177
|
+
});
|
|
102
178
|
return this.request.post(fetchUrl, params);
|
|
103
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Checkout 专用:创建订单到后端
|
|
182
|
+
*
|
|
183
|
+
* 专门为 Checkout 模块设计的订单创建方法,
|
|
184
|
+
* 直接调用 /order/checkout 接口创建订单
|
|
185
|
+
* 接收已经处理好的订单数据,无需再处理购物车
|
|
186
|
+
*
|
|
187
|
+
* @param params Checkout 订单参数(已处理的订单数据)
|
|
188
|
+
* @returns 后端返回的订单数据(包含订单ID等)
|
|
189
|
+
*/
|
|
190
|
+
async createOrderByCheckout(params) {
|
|
191
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
192
|
+
this.logInfo("createOrderByCheckout called", {
|
|
193
|
+
type: params.type,
|
|
194
|
+
platform: params.platform,
|
|
195
|
+
is_deposit: params.is_deposit,
|
|
196
|
+
customer_id: params.customer_id,
|
|
197
|
+
bookingsCount: ((_a = params.bookings) == null ? void 0 : _a.length) || 0,
|
|
198
|
+
relationProductsCount: ((_b = params.relation_products) == null ? void 0 : _b.length) || 0,
|
|
199
|
+
paymentsCount: ((_c = params.payments) == null ? void 0 : _c.length) || 0,
|
|
200
|
+
depositAmount: params.deposit_amount,
|
|
201
|
+
productTaxFee: params.product_tax_fee,
|
|
202
|
+
note: params.note,
|
|
203
|
+
scheduleDate: params.schedule_date,
|
|
204
|
+
hasOrderId: !!params.order_id,
|
|
205
|
+
orderIdIncluded: params.order_id,
|
|
206
|
+
paymentMethods: ((_d = params.payments) == null ? void 0 : _d.map((p) => p.code)) || []
|
|
207
|
+
});
|
|
208
|
+
console.log("[Order] createOrderByCheckout 开始创建订单:", {
|
|
209
|
+
type: params.type,
|
|
210
|
+
platform: params.platform,
|
|
211
|
+
is_deposit: params.is_deposit,
|
|
212
|
+
customer_id: params.customer_id,
|
|
213
|
+
bookingsCount: ((_e = params.bookings) == null ? void 0 : _e.length) || 0,
|
|
214
|
+
relationProductsCount: ((_f = params.relation_products) == null ? void 0 : _f.length) || 0,
|
|
215
|
+
paymentsCount: ((_g = params.payments) == null ? void 0 : _g.length) || 0
|
|
216
|
+
});
|
|
217
|
+
try {
|
|
218
|
+
const orderData = {
|
|
219
|
+
sales_channel: "my_pisel",
|
|
220
|
+
order_sales_channel: "online_store",
|
|
221
|
+
shop_note: "",
|
|
222
|
+
schedule_date: "",
|
|
223
|
+
is_deposit: 0,
|
|
224
|
+
bookings: [],
|
|
225
|
+
relation_products: [],
|
|
226
|
+
relation_forms: [],
|
|
227
|
+
payments: [],
|
|
228
|
+
...params
|
|
229
|
+
// 使用传入的参数覆盖默认值
|
|
230
|
+
};
|
|
231
|
+
if ((_h = orderData.payments) == null ? void 0 : _h.length) {
|
|
232
|
+
orderData.small_ticket_data_flag = 1;
|
|
233
|
+
}
|
|
234
|
+
if (params.order_id) {
|
|
235
|
+
orderData.bookings = [];
|
|
236
|
+
orderData.relation_products = [];
|
|
237
|
+
}
|
|
238
|
+
if (!params.order_id && !orderData.schedule_date) {
|
|
239
|
+
orderData.schedule_date = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
240
|
+
}
|
|
241
|
+
console.log("[Order] 调用后端接口创建订单:", {
|
|
242
|
+
url: "/order/checkout",
|
|
243
|
+
orderType: orderData.type,
|
|
244
|
+
platform: orderData.platform,
|
|
245
|
+
isDeposit: orderData.is_deposit,
|
|
246
|
+
customerId: orderData.customer_id,
|
|
247
|
+
bookingsCount: ((_i = orderData.bookings) == null ? void 0 : _i.length) || 0,
|
|
248
|
+
relationProductsCount: ((_j = orderData.relation_products) == null ? void 0 : _j.length) || 0,
|
|
249
|
+
paymentsCount: ((_k = orderData.payments) == null ? void 0 : _k.length) || 0,
|
|
250
|
+
paymentsMethods: ((_l = orderData.payments) == null ? void 0 : _l.map((p) => p.code)) || []
|
|
251
|
+
});
|
|
252
|
+
this.logInfo("Calling backend checkout API", {
|
|
253
|
+
url: "/order/checkout",
|
|
254
|
+
orderType: orderData.type,
|
|
255
|
+
platform: orderData.platform,
|
|
256
|
+
isDeposit: orderData.is_deposit,
|
|
257
|
+
customerId: orderData.customer_id,
|
|
258
|
+
depositAmount: orderData.deposit_amount,
|
|
259
|
+
bookingsCount: ((_m = orderData.bookings) == null ? void 0 : _m.length) || 0,
|
|
260
|
+
relationProductsCount: ((_n = orderData.relation_products) == null ? void 0 : _n.length) || 0,
|
|
261
|
+
paymentsCount: ((_o = orderData.payments) == null ? void 0 : _o.length) || 0,
|
|
262
|
+
paymentMethods: ((_p = orderData.payments) == null ? void 0 : _p.map((p) => ({
|
|
263
|
+
code: p.code,
|
|
264
|
+
amount: p.amount,
|
|
265
|
+
type: p.type,
|
|
266
|
+
hasVoucherId: !!p.voucher_id,
|
|
267
|
+
orderPaymentType: p.order_payment_type
|
|
268
|
+
}))) || [],
|
|
269
|
+
productTaxFee: orderData.product_tax_fee,
|
|
270
|
+
note: orderData.note,
|
|
271
|
+
scheduleDate: orderData.schedule_date,
|
|
272
|
+
hasOrderId: !!orderData.order_id,
|
|
273
|
+
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
274
|
+
});
|
|
275
|
+
const response = await this.request.post("/order/checkout", orderData);
|
|
276
|
+
console.log("[Order] 订单创建成功,后端响应:", {
|
|
277
|
+
success: !!response,
|
|
278
|
+
hasOrderId: !!(((_q = response == null ? void 0 : response.data) == null ? void 0 : _q.order_id) || (response == null ? void 0 : response.order_id))
|
|
279
|
+
});
|
|
280
|
+
return response;
|
|
281
|
+
} catch (error) {
|
|
282
|
+
console.error("[Order] createOrderByCheckout 创建订单失败:", error);
|
|
283
|
+
throw error;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
104
286
|
};
|
|
105
287
|
// Annotate the CommonJS export names for ESM import in node:
|
|
106
288
|
0 && (module.exports = {
|
|
@@ -18,6 +18,45 @@ export interface CommitOrderParams {
|
|
|
18
18
|
platform?: 'pc' | 'h5';
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* 支付项数据
|
|
23
|
+
*/
|
|
24
|
+
export interface PaymentItemData {
|
|
25
|
+
/** 当前支付项的唯一 ID */
|
|
26
|
+
uuid: string;
|
|
27
|
+
/** 当前支付方式付出去多少钱 */
|
|
28
|
+
amount: string;
|
|
29
|
+
/** 支付类型代码 */
|
|
30
|
+
code: string;
|
|
31
|
+
/** 支付类型id */
|
|
32
|
+
id: number;
|
|
33
|
+
/** 支付类型名称 */
|
|
34
|
+
name: string;
|
|
35
|
+
/** 支付类型 */
|
|
36
|
+
type: string;
|
|
37
|
+
/** 是否已同步到后端 */
|
|
38
|
+
isSynced?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Checkout 专用订单创建参数
|
|
42
|
+
*/
|
|
43
|
+
export interface CheckoutOrderParams {
|
|
44
|
+
type: 'virtual' | 'appointment_booking';
|
|
45
|
+
platform: 'PC' | 'H5';
|
|
46
|
+
sales_channel?: string;
|
|
47
|
+
order_sales_channel?: string;
|
|
48
|
+
bookings?: any[];
|
|
49
|
+
shop_note?: string;
|
|
50
|
+
schedule_date?: string;
|
|
51
|
+
is_deposit?: number;
|
|
52
|
+
relation_products?: any[];
|
|
53
|
+
relation_forms?: any[];
|
|
54
|
+
payments?: PaymentItemData[];
|
|
55
|
+
customer_id?: string;
|
|
56
|
+
/** 小票数据标记,当有支付项时设置为1 */
|
|
57
|
+
small_ticket_data_flag?: number;
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
}
|
|
21
60
|
/**
|
|
22
61
|
* 订单模块 API
|
|
23
62
|
*/
|
|
@@ -40,4 +79,10 @@ export interface OrderModuleAPI {
|
|
|
40
79
|
* @param params 订单信息
|
|
41
80
|
*/
|
|
42
81
|
submitOrder: (params: CommitOrderParams) => Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Checkout 专用:创建订单到后端
|
|
84
|
+
* @param params 订单参数
|
|
85
|
+
* @returns 后端返回的订单数据
|
|
86
|
+
*/
|
|
87
|
+
createOrderByCheckout: (params: CheckoutOrderParams) => Promise<any>;
|
|
43
88
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CashPayment } from './types';
|
|
2
|
+
import type { PaymentModule } from './index';
|
|
3
|
+
/**
|
|
4
|
+
* 现金支付实现
|
|
5
|
+
*/
|
|
6
|
+
export declare class CashPaymentImpl implements CashPayment {
|
|
7
|
+
private paymentModule;
|
|
8
|
+
constructor(paymentModule: PaymentModule);
|
|
9
|
+
processCashPayment(amount: number, orderUuid: string): Promise<void>;
|
|
10
|
+
getCashBalance(): Promise<number>;
|
|
11
|
+
/**
|
|
12
|
+
* 获取推荐支付金额
|
|
13
|
+
* 基于目标金额和货币类型,返回最优支付金额建议
|
|
14
|
+
* @param money 目标支付金额
|
|
15
|
+
* @param currency 货币代码 (如: 'CNY', 'USD', 'EUR' 等)
|
|
16
|
+
* @returns 推荐支付金额数组
|
|
17
|
+
*/
|
|
18
|
+
getRecommendedAmount(money: number, currency: string): number[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/modules/Payment/cash.ts
|
|
20
|
+
var cash_exports = {};
|
|
21
|
+
__export(cash_exports, {
|
|
22
|
+
CashPaymentImpl: () => CashPaymentImpl
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(cash_exports);
|
|
25
|
+
var import_cashRecommendationAlgorithm = require("./cashRecommendationAlgorithm");
|
|
26
|
+
var CashPaymentImpl = class {
|
|
27
|
+
constructor(paymentModule) {
|
|
28
|
+
this.paymentModule = paymentModule;
|
|
29
|
+
}
|
|
30
|
+
async processCashPayment(amount, orderUuid) {
|
|
31
|
+
const cashMethod = await this.paymentModule.getCashPaymentMethod();
|
|
32
|
+
if (!cashMethod) {
|
|
33
|
+
throw new Error("现金支付方式未找到");
|
|
34
|
+
}
|
|
35
|
+
const paymentItem = {
|
|
36
|
+
amount: amount.toString(),
|
|
37
|
+
code: cashMethod.code,
|
|
38
|
+
id: cashMethod.id,
|
|
39
|
+
name: cashMethod.name,
|
|
40
|
+
type: cashMethod.type,
|
|
41
|
+
voucher_id: ""
|
|
42
|
+
};
|
|
43
|
+
await this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
|
|
44
|
+
}
|
|
45
|
+
async getCashBalance() {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 获取推荐支付金额
|
|
50
|
+
* 基于目标金额和货币类型,返回最优支付金额建议
|
|
51
|
+
* @param money 目标支付金额
|
|
52
|
+
* @param currency 货币代码 (如: 'CNY', 'USD', 'EUR' 等)
|
|
53
|
+
* @returns 推荐支付金额数组
|
|
54
|
+
*/
|
|
55
|
+
getRecommendedAmount(money, currency) {
|
|
56
|
+
const upperCurrency = currency.toUpperCase();
|
|
57
|
+
const denominations = import_cashRecommendationAlgorithm.CURRENCY_DENOMINATIONS[upperCurrency] || import_cashRecommendationAlgorithm.CURRENCY_DENOMINATIONS["DEFAULT"];
|
|
58
|
+
return (0, import_cashRecommendationAlgorithm.recommendOptimalPayments)(money, denominations);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
CashPaymentImpl
|
|
64
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 现金支付推荐算法
|
|
3
|
+
*
|
|
4
|
+
* 核心原理:
|
|
5
|
+
* 1. 每个推荐金额都应该是独立的最优组合
|
|
6
|
+
* 2. 不推荐在已有最优解基础上添加额外面额的组合
|
|
7
|
+
* 3. 优先推荐使用不同数量币种的组合
|
|
8
|
+
* 4. 根据组合判断去重,避免扩展组合
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 常见国家货币面额配置
|
|
12
|
+
*/
|
|
13
|
+
export declare const CURRENCY_DENOMINATIONS: Record<string, number[]>;
|
|
14
|
+
/**
|
|
15
|
+
* 最优支付金额推荐算法
|
|
16
|
+
* 推荐通过不同数量面额组合刚好足够支付的最小金额
|
|
17
|
+
*
|
|
18
|
+
* @param targetAmount 目标金额
|
|
19
|
+
* @param denominations 币种面值数组
|
|
20
|
+
* @returns 推荐支付金额数组
|
|
21
|
+
*/
|
|
22
|
+
export declare function recommendOptimalPayments(targetAmount: number, denominations: number[]): number[];
|