@pisell/pisellos 0.0.229 → 0.0.231
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 +13 -2
- package/dist/modules/Order/index.js +84 -1
- package/dist/modules/Order/types.d.ts +43 -0
- package/dist/modules/Order/types.js +8 -0
- package/dist/modules/Payment/cash.d.ts +8 -0
- package/dist/modules/Payment/cash.js +20 -1
- package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
- package/dist/modules/Payment/cashRecommendationAlgorithm.js +423 -0
- package/dist/modules/Payment/eftpos.js +1 -1
- package/dist/modules/Payment/index.d.ts +57 -94
- package/dist/modules/Payment/index.js +810 -1109
- package/dist/modules/Payment/mx51.d.ts +0 -0
- package/dist/modules/Payment/mx51.js +0 -0
- package/dist/modules/Payment/types.d.ts +358 -50
- package/dist/modules/Payment/types.js +103 -4
- package/dist/modules/Payment/utils.d.ts +17 -0
- package/dist/modules/Payment/utils.js +62 -0
- package/dist/modules/Payment/walletpass.d.ts +96 -0
- package/dist/modules/Payment/walletpass.js +492 -0
- package/dist/modules/Schedule/index.d.ts +9 -0
- package/dist/modules/Schedule/index.js +60 -0
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/appointmentDemo.json +1 -0
- package/dist/solution/Checkout/index.d.ts +415 -0
- package/dist/solution/Checkout/index.js +3622 -0
- package/dist/solution/Checkout/types.d.ts +737 -0
- package/dist/solution/Checkout/types.js +137 -0
- package/dist/solution/Checkout/utils/index.d.ts +73 -0
- package/dist/{modules/Payment/wallet.js → solution/Checkout/utils/index.js} +363 -70
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/lib/modules/Order/index.d.ts +13 -2
- package/lib/modules/Order/index.js +58 -1
- package/lib/modules/Order/types.d.ts +43 -0
- package/lib/modules/Payment/cash.d.ts +8 -0
- package/lib/modules/Payment/cash.js +14 -1
- package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +342 -0
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.d.ts +57 -94
- package/lib/modules/Payment/index.js +363 -525
- package/lib/modules/Payment/mx51.d.ts +0 -0
- package/lib/modules/Payment/mx51.js +0 -0
- package/lib/modules/Payment/types.d.ts +358 -50
- package/lib/modules/Payment/types.js +37 -2
- package/lib/modules/Payment/utils.d.ts +17 -0
- package/lib/modules/Payment/utils.js +67 -0
- package/lib/modules/Payment/walletpass.d.ts +96 -0
- package/lib/modules/Payment/walletpass.js +304 -0
- package/lib/modules/Schedule/index.d.ts +9 -0
- package/lib/modules/Schedule/index.js +36 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/appointmentDemo.json +1 -0
- package/lib/solution/Checkout/index.d.ts +415 -0
- package/lib/solution/Checkout/index.js +2107 -0
- package/lib/solution/Checkout/types.d.ts +737 -0
- package/lib/solution/Checkout/types.js +80 -0
- package/lib/solution/Checkout/utils/index.d.ts +73 -0
- package/lib/solution/Checkout/utils/index.js +266 -0
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/package.json +1 -1
- package/dist/modules/Payment/wallet.d.ts +0 -11
- package/lib/modules/Payment/wallet.d.ts +0 -11
- package/lib/modules/Payment/wallet.js +0 -51
|
@@ -1,6 +1,6 @@
|
|
|
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;
|
|
@@ -11,7 +11,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
11
11
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
12
12
|
createOrder(params: CommitOrderParams['query']): {
|
|
13
13
|
type: "virtual" | "appointment_booking";
|
|
14
|
-
platform:
|
|
14
|
+
platform: "pc" | "h5";
|
|
15
15
|
sales_channel: string;
|
|
16
16
|
order_sales_channel: string;
|
|
17
17
|
bookings: any[];
|
|
@@ -26,4 +26,15 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
26
26
|
type: 'holder' | 'account';
|
|
27
27
|
}): boolean;
|
|
28
28
|
submitOrder(order: CommitOrderParams): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Checkout 专用:创建订单到后端
|
|
31
|
+
*
|
|
32
|
+
* 专门为 Checkout 模块设计的订单创建方法,
|
|
33
|
+
* 直接调用 /order/checkout 接口创建订单
|
|
34
|
+
* 接收已经处理好的订单数据,无需再处理购物车
|
|
35
|
+
*
|
|
36
|
+
* @param params Checkout 订单参数(已处理的订单数据)
|
|
37
|
+
* @returns 后端返回的订单数据(包含订单ID等)
|
|
38
|
+
*/
|
|
39
|
+
createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
|
|
29
40
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2
4
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
5
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
6
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -64,7 +66,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
64
66
|
var order = {
|
|
65
67
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
66
68
|
// 要从外面拿,virtual
|
|
67
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform)
|
|
69
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || 'pc',
|
|
68
70
|
sales_channel: 'my_pisel',
|
|
69
71
|
order_sales_channel: 'online_store',
|
|
70
72
|
bookings: [],
|
|
@@ -153,6 +155,87 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
153
155
|
}
|
|
154
156
|
return submitOrder;
|
|
155
157
|
}()
|
|
158
|
+
/**
|
|
159
|
+
* Checkout 专用:创建订单到后端
|
|
160
|
+
*
|
|
161
|
+
* 专门为 Checkout 模块设计的订单创建方法,
|
|
162
|
+
* 直接调用 /order/checkout 接口创建订单
|
|
163
|
+
* 接收已经处理好的订单数据,无需再处理购物车
|
|
164
|
+
*
|
|
165
|
+
* @param params Checkout 订单参数(已处理的订单数据)
|
|
166
|
+
* @returns 后端返回的订单数据(包含订单ID等)
|
|
167
|
+
*/
|
|
168
|
+
}, {
|
|
169
|
+
key: "createOrderByCheckout",
|
|
170
|
+
value: (function () {
|
|
171
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
172
|
+
var _params$bookings, _params$relation_prod, _params$payments;
|
|
173
|
+
var _orderData$bookings, _orderData$relation_p, _orderData$payments, _orderData$payments2, _response$data, orderData, response;
|
|
174
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
175
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
176
|
+
case 0:
|
|
177
|
+
console.log('[Order] createOrderByCheckout 开始创建订单:', {
|
|
178
|
+
type: params.type,
|
|
179
|
+
platform: params.platform,
|
|
180
|
+
is_deposit: params.is_deposit,
|
|
181
|
+
customer_id: params.customer_id,
|
|
182
|
+
bookingsCount: ((_params$bookings = params.bookings) === null || _params$bookings === void 0 ? void 0 : _params$bookings.length) || 0,
|
|
183
|
+
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
184
|
+
paymentsCount: ((_params$payments = params.payments) === null || _params$payments === void 0 ? void 0 : _params$payments.length) || 0
|
|
185
|
+
});
|
|
186
|
+
_context3.prev = 1;
|
|
187
|
+
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
188
|
+
orderData = _objectSpread({
|
|
189
|
+
sales_channel: 'my_pisel',
|
|
190
|
+
order_sales_channel: 'online_store',
|
|
191
|
+
shop_note: '',
|
|
192
|
+
schedule_date: '',
|
|
193
|
+
is_deposit: 0,
|
|
194
|
+
bookings: [],
|
|
195
|
+
relation_products: [],
|
|
196
|
+
relation_forms: [],
|
|
197
|
+
payments: []
|
|
198
|
+
}, params);
|
|
199
|
+
console.log('[Order] 调用后端接口创建订单:', {
|
|
200
|
+
url: '/order/checkout',
|
|
201
|
+
orderType: orderData.type,
|
|
202
|
+
platform: orderData.platform,
|
|
203
|
+
isDeposit: orderData.is_deposit,
|
|
204
|
+
customerId: orderData.customer_id,
|
|
205
|
+
bookingsCount: ((_orderData$bookings = orderData.bookings) === null || _orderData$bookings === void 0 ? void 0 : _orderData$bookings.length) || 0,
|
|
206
|
+
relationProductsCount: ((_orderData$relation_p = orderData.relation_products) === null || _orderData$relation_p === void 0 ? void 0 : _orderData$relation_p.length) || 0,
|
|
207
|
+
paymentsCount: ((_orderData$payments = orderData.payments) === null || _orderData$payments === void 0 ? void 0 : _orderData$payments.length) || 0,
|
|
208
|
+
paymentsMethods: ((_orderData$payments2 = orderData.payments) === null || _orderData$payments2 === void 0 ? void 0 : _orderData$payments2.map(function (p) {
|
|
209
|
+
return p.code;
|
|
210
|
+
})) || []
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// 调用后端接口
|
|
214
|
+
_context3.next = 6;
|
|
215
|
+
return this.request.post('/order/checkout', orderData);
|
|
216
|
+
case 6:
|
|
217
|
+
response = _context3.sent;
|
|
218
|
+
console.log('[Order] 订单创建成功,后端响应:', {
|
|
219
|
+
success: !!response,
|
|
220
|
+
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
221
|
+
});
|
|
222
|
+
return _context3.abrupt("return", response);
|
|
223
|
+
case 11:
|
|
224
|
+
_context3.prev = 11;
|
|
225
|
+
_context3.t0 = _context3["catch"](1);
|
|
226
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context3.t0);
|
|
227
|
+
throw _context3.t0;
|
|
228
|
+
case 15:
|
|
229
|
+
case "end":
|
|
230
|
+
return _context3.stop();
|
|
231
|
+
}
|
|
232
|
+
}, _callee3, this, [[1, 11]]);
|
|
233
|
+
}));
|
|
234
|
+
function createOrderByCheckout(_x4) {
|
|
235
|
+
return _createOrderByCheckout.apply(this, arguments);
|
|
236
|
+
}
|
|
237
|
+
return createOrderByCheckout;
|
|
238
|
+
}())
|
|
156
239
|
}]);
|
|
157
240
|
return OrderModule;
|
|
158
241
|
}(BaseModule);
|
|
@@ -18,6 +18,43 @@ 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
|
+
[key: string]: any;
|
|
57
|
+
}
|
|
21
58
|
/**
|
|
22
59
|
* 订单模块 API
|
|
23
60
|
*/
|
|
@@ -40,4 +77,10 @@ export interface OrderModuleAPI {
|
|
|
40
77
|
* @param params 订单信息
|
|
41
78
|
*/
|
|
42
79
|
submitOrder: (params: CommitOrderParams) => Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Checkout 专用:创建订单到后端
|
|
82
|
+
* @param params 订单参数
|
|
83
|
+
* @returns 后端返回的订单数据
|
|
84
|
+
*/
|
|
85
|
+
createOrderByCheckout: (params: CheckoutOrderParams) => Promise<any>;
|
|
43
86
|
}
|
|
@@ -8,4 +8,12 @@ export declare class CashPaymentImpl implements CashPayment {
|
|
|
8
8
|
constructor(paymentModule: PaymentModule);
|
|
9
9
|
processCashPayment(amount: number, orderUuid: string): Promise<void>;
|
|
10
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[];
|
|
11
19
|
}
|
|
@@ -7,6 +7,8 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
7
7
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
9
|
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); }
|
|
10
|
+
import { CURRENCY_DENOMINATIONS, recommendOptimalPayments } from "./cashRecommendationAlgorithm";
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* 现金支付实现
|
|
12
14
|
*/
|
|
@@ -42,7 +44,7 @@ export var CashPaymentImpl = /*#__PURE__*/function () {
|
|
|
42
44
|
voucher_id: ''
|
|
43
45
|
};
|
|
44
46
|
_context.next = 8;
|
|
45
|
-
return this.paymentModule.
|
|
47
|
+
return this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
|
|
46
48
|
case 8:
|
|
47
49
|
case "end":
|
|
48
50
|
return _context.stop();
|
|
@@ -73,6 +75,23 @@ export var CashPaymentImpl = /*#__PURE__*/function () {
|
|
|
73
75
|
}
|
|
74
76
|
return getCashBalance;
|
|
75
77
|
}()
|
|
78
|
+
/**
|
|
79
|
+
* 获取推荐支付金额
|
|
80
|
+
* 基于目标金额和货币类型,返回最优支付金额建议
|
|
81
|
+
* @param money 目标支付金额
|
|
82
|
+
* @param currency 货币代码 (如: 'CNY', 'USD', 'EUR' 等)
|
|
83
|
+
* @returns 推荐支付金额数组
|
|
84
|
+
*/
|
|
85
|
+
}, {
|
|
86
|
+
key: "getRecommendedAmount",
|
|
87
|
+
value: function getRecommendedAmount(money, currency) {
|
|
88
|
+
// 获取对应货币的面额配置
|
|
89
|
+
var upperCurrency = currency.toUpperCase();
|
|
90
|
+
var denominations = CURRENCY_DENOMINATIONS[upperCurrency] || CURRENCY_DENOMINATIONS['DEFAULT'];
|
|
91
|
+
|
|
92
|
+
// 直接调用算法,所有验证和容错处理都在算法内部
|
|
93
|
+
return recommendOptimalPayments(money, denominations);
|
|
94
|
+
}
|
|
76
95
|
}]);
|
|
77
96
|
return CashPaymentImpl;
|
|
78
97
|
}();
|
|
@@ -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[];
|