@pisell/pisellos 2.2.276 → 2.2.800
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.d.ts +0 -2
- package/dist/core/index.js +0 -7
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/modules/OpenData/index.d.ts +0 -2
- package/dist/modules/OpenData/index.js +0 -8
- package/dist/modules/Order/index.d.ts +8 -28
- package/dist/modules/Order/index.js +496 -808
- package/dist/modules/Order/types.d.ts +1 -35
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.js +6 -10
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +49 -78
- package/dist/modules/Payment/types.d.ts +25 -104
- package/dist/modules/Payment/types.js +0 -17
- package/dist/modules/Payment/walletpass.d.ts +1 -38
- package/dist/modules/Payment/walletpass.js +114 -917
- package/dist/modules/Rules/index.d.ts +0 -3
- package/dist/modules/Rules/index.js +70 -100
- package/dist/server/index.d.ts +0 -25
- package/dist/server/index.js +1069 -2001
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +4 -70
- package/dist/server/modules/order/index.js +728 -1816
- package/dist/server/modules/order/types.d.ts +3 -25
- package/dist/server/modules/order/types.js +1 -7
- package/dist/server/utils/small-ticket.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +5 -104
- package/dist/solution/BaseSales/index.js +436 -1767
- package/dist/solution/BaseSales/types.d.ts +1 -55
- package/dist/solution/BaseSales/types.js +1 -2
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +31 -90
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -7
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +5 -21
- package/dist/solution/BookingTicket/index.js +56 -139
- package/dist/solution/BookingTicket/types.d.ts +0 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +83 -173
- package/dist/solution/Sales/index.d.ts +0 -2
- package/dist/solution/Sales/index.js +4 -26
- package/dist/solution/ScanOrder/index.js +20 -31
- package/dist/solution/VenueBooking/index.d.ts +0 -1
- package/dist/solution/VenueBooking/index.js +19 -30
- package/dist/types/index.d.ts +0 -1
- package/lib/core/index.d.ts +0 -2
- package/lib/core/index.js +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -2
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/modules/OpenData/index.d.ts +0 -2
- package/lib/modules/OpenData/index.js +0 -5
- package/lib/modules/Order/index.d.ts +8 -28
- package/lib/modules/Order/index.js +69 -231
- package/lib/modules/Order/types.d.ts +1 -35
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.js +4 -11
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +12 -33
- package/lib/modules/Payment/types.d.ts +25 -104
- package/lib/modules/Payment/types.js +0 -1
- package/lib/modules/Payment/walletpass.d.ts +1 -38
- package/lib/modules/Payment/walletpass.js +21 -730
- package/lib/modules/Rules/index.d.ts +0 -3
- package/lib/modules/Rules/index.js +9 -38
- package/lib/server/index.d.ts +0 -25
- package/lib/server/index.js +31 -726
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +4 -70
- package/lib/server/modules/order/index.js +69 -818
- package/lib/server/modules/order/types.d.ts +3 -25
- package/lib/server/modules/order/types.js +0 -1
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +5 -104
- package/lib/solution/BaseSales/index.js +27 -858
- package/lib/solution/BaseSales/types.d.ts +1 -55
- package/lib/solution/BaseSales/types.js +1 -2
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +5 -21
- package/lib/solution/BookingTicket/index.js +13 -64
- package/lib/solution/BookingTicket/types.d.ts +0 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +5 -37
- package/lib/solution/Sales/index.d.ts +0 -2
- package/lib/solution/Sales/index.js +6 -20
- package/lib/solution/ScanOrder/index.js +0 -8
- package/lib/solution/VenueBooking/index.d.ts +0 -1
- package/lib/solution/VenueBooking/index.js +0 -8
- package/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/modules/Order/payment-utils.d.ts +0 -26
- package/dist/modules/Order/payment-utils.js +0 -225
- package/dist/utils/payment-number.d.ts +0 -9
- package/dist/utils/payment-number.js +0 -69
- package/lib/modules/Order/payment-utils.d.ts +0 -26
- package/lib/modules/Order/payment-utils.js +0 -224
- package/lib/utils/payment-number.d.ts +0 -9
- package/lib/utils/payment-number.js +0 -64
|
@@ -165,8 +165,6 @@ export interface OrderCustomerChangePayload {
|
|
|
165
165
|
}
|
|
166
166
|
export interface OrderScanCodeResult {
|
|
167
167
|
isAvailable: boolean;
|
|
168
|
-
/** 卡券已加入当前订单折扣列表,但不一定能立即应用。 */
|
|
169
|
-
isAccepted?: boolean;
|
|
170
168
|
discountList: Discount[];
|
|
171
169
|
scannedDiscountList: Discount[];
|
|
172
170
|
type: 'server' | 'clientCalc';
|
|
@@ -488,8 +486,6 @@ export interface SubmitSalesOrderParams {
|
|
|
488
486
|
export interface PaymentItemData {
|
|
489
487
|
/** 当前支付项的唯一 ID */
|
|
490
488
|
uuid: string;
|
|
491
|
-
/** 支付项稳定唯一号 */
|
|
492
|
-
payment_number?: string;
|
|
493
489
|
/** 当前支付方式付出去多少钱 */
|
|
494
490
|
amount: string;
|
|
495
491
|
/** 支付类型代码 */
|
|
@@ -512,22 +508,13 @@ export interface PaymentItemData {
|
|
|
512
508
|
export interface OrderPaymentMetadata {
|
|
513
509
|
rounding_rule?: Record<string, any>;
|
|
514
510
|
unique_payment_number?: string;
|
|
515
|
-
/** 刷卡机设备快照;OS 不解析内部字段,仅透传并持久化 */
|
|
516
|
-
card_reader_snapshot?: Record<string, unknown>;
|
|
517
511
|
shop_wallet_pass_id?: number | string;
|
|
518
512
|
actual_paid_amount?: number | string;
|
|
519
513
|
change_given_amount?: number | string;
|
|
520
|
-
transactions?: OrderPaymentTransaction[];
|
|
521
514
|
[key: string]: any;
|
|
522
515
|
}
|
|
523
|
-
export interface OrderPaymentTransaction {
|
|
524
|
-
number: string;
|
|
525
|
-
status: 'success' | 'fail';
|
|
526
|
-
}
|
|
527
516
|
export interface OrderPaymentData {
|
|
528
517
|
order_payment_id?: number | string;
|
|
529
|
-
/** 支付项稳定唯一号;历史支付项允许缺失 */
|
|
530
|
-
payment_number?: string;
|
|
531
518
|
amount: string;
|
|
532
519
|
code: string;
|
|
533
520
|
custom_payment_id: number;
|
|
@@ -554,15 +541,6 @@ export interface OrderPaymentData {
|
|
|
554
541
|
created_at?: string;
|
|
555
542
|
updated_at?: string;
|
|
556
543
|
}
|
|
557
|
-
export interface OrderPaymentUpdateOptions {
|
|
558
|
-
matchBy?: 'payment_number' | 'compat' | 'legacy';
|
|
559
|
-
}
|
|
560
|
-
export interface OrderPaymentUpdateResult {
|
|
561
|
-
updated: boolean;
|
|
562
|
-
payment: OrderPaymentData | null;
|
|
563
|
-
payments: OrderPaymentData[];
|
|
564
|
-
summary: OrderSummary | null;
|
|
565
|
-
}
|
|
566
544
|
export type OrderPaymentSource = PaymentItem | OrderPaymentData | Record<string, any>;
|
|
567
545
|
export interface MapOrderPaymentsOptions {
|
|
568
546
|
includeVoided?: boolean;
|
|
@@ -713,14 +691,6 @@ export interface OrderModuleAPI {
|
|
|
713
691
|
channel?: string;
|
|
714
692
|
type?: string;
|
|
715
693
|
}) => OrderSubmitPayload;
|
|
716
|
-
saveTempOrderAsDraft: <T = any>(params?: {
|
|
717
|
-
cacheId?: string;
|
|
718
|
-
platform?: string;
|
|
719
|
-
businessCode?: string;
|
|
720
|
-
channel?: string;
|
|
721
|
-
type?: string;
|
|
722
|
-
enhancePayload?: SubmitPayloadEnhancer;
|
|
723
|
-
}) => Promise<T>;
|
|
724
694
|
applyLocalPrintOrderNumbers: (order?: Record<string, any> | null) => Promise<OrderTempOrder>;
|
|
725
695
|
getTempOrderNote: () => string;
|
|
726
696
|
updateTempOrderNote: {
|
|
@@ -778,15 +748,11 @@ export interface OrderModuleAPI {
|
|
|
778
748
|
getOrderPayments: () => OrderPaymentData[];
|
|
779
749
|
setOrderPayments: (payments: OrderPaymentSource[]) => OrderPaymentData[];
|
|
780
750
|
addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
|
|
781
|
-
|
|
782
|
-
updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>, options?: OrderPaymentUpdateOptions) => Promise<OrderPaymentUpdateResult>;
|
|
751
|
+
updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>) => OrderPaymentData[];
|
|
783
752
|
deleteOrderPayment: (paymentIdentity: string | number) => OrderPaymentData[];
|
|
784
753
|
updateVoucherOrderPayments: (payments: OrderPaymentSource[], options?: {
|
|
785
754
|
status?: 'paid' | 'payment_pending';
|
|
786
755
|
}) => OrderPaymentData[];
|
|
787
|
-
updateVoucherOrderPaymentsAsync: (payments: OrderPaymentSource[], options?: {
|
|
788
|
-
status?: 'paid' | 'payment_pending';
|
|
789
|
-
}) => Promise<OrderPaymentData[]>;
|
|
790
756
|
confirmPendingVoucherPayments: (options?: {
|
|
791
757
|
persist?: boolean;
|
|
792
758
|
recalculateSummary?: boolean;
|
|
@@ -209,11 +209,6 @@ export function normalizeOrderCollection(kind, items, options) {
|
|
|
209
209
|
var persistentId = getOrderCollectionPersistentId(kind, item);
|
|
210
210
|
var uid = getOrderCollectionUid(kind, item);
|
|
211
211
|
if (!uid) {
|
|
212
|
-
var _item;
|
|
213
|
-
if (kind === 'payment' && !isBlankOrderCollectionIdentity((_item = item) === null || _item === void 0 ? void 0 : _item.payment_number)) {
|
|
214
|
-
// payment_number 已提供稳定身份,不占用真实交易流水字段作为内部 UID。
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
212
|
uid = persistentId ? buildOrderCollectionFallbackUid(kind, persistentId) : allocateAnonymousUid(occupiedUids, createAnonymousUid);
|
|
218
213
|
item = setOrderCollectionUid(kind, item, uid);
|
|
219
214
|
result[index] = item;
|
|
@@ -221,7 +216,7 @@ export function normalizeOrderCollection(kind, items, options) {
|
|
|
221
216
|
if (!persistentId) stats.anonymousRowCount += 1;
|
|
222
217
|
}
|
|
223
218
|
if (occupiedUids.has(uid)) {
|
|
224
|
-
var _item2, _item3, _item4
|
|
219
|
+
var _item, _item2, _item3, _item4;
|
|
225
220
|
var replacementUid = persistentId ? allocatePersistentConflictUid(kind, persistentId, occupiedUids) : allocateAnonymousUid(occupiedUids, createAnonymousUid);
|
|
226
221
|
result[index] = setOrderCollectionUid(kind, item, replacementUid);
|
|
227
222
|
uidRemaps.push({
|
|
@@ -230,7 +225,7 @@ export function normalizeOrderCollection(kind, items, options) {
|
|
|
230
225
|
to: replacementUid,
|
|
231
226
|
persistentId: persistentId,
|
|
232
227
|
scope: 'linked-owner',
|
|
233
|
-
referenceOwnerUid: kind === 'product' ? String(((
|
|
228
|
+
referenceOwnerUid: kind === 'product' ? String(((_item = item) === null || _item === void 0 ? void 0 : _item.booking_uid) || ((_item2 = item) === null || _item2 === void 0 || (_item2 = _item2.metadata) === null || _item2 === void 0 ? void 0 : _item2.booking_uid) || '') || null : kind === 'booking' ? String(((_item3 = item) === null || _item3 === void 0 ? void 0 : _item3.product_uid) || ((_item4 = item) === null || _item4 === void 0 || (_item4 = _item4.metadata) === null || _item4 === void 0 ? void 0 : _item4.product_uid) || '') || null : null
|
|
234
229
|
});
|
|
235
230
|
uid = replacementUid;
|
|
236
231
|
stats.uidConflictCount += 1;
|
|
@@ -533,8 +533,7 @@ export function resolveEffectivePerUnitDiscount(product) {
|
|
|
533
533
|
return sum + Number((discount === null || discount === void 0 ? void 0 : discount.amount) || 0);
|
|
534
534
|
}, 0);
|
|
535
535
|
var hasPromoDiscountItem = discountList.some(function (item) {
|
|
536
|
-
|
|
537
|
-
return (item === null || item === void 0 ? void 0 : item.type) === 'promotion' || (item === null || item === void 0 ? void 0 : item.type) === 'product' && (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.source) === 'promotion' && (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.actionType) === 'ITEM_REWARD';
|
|
536
|
+
return (item === null || item === void 0 ? void 0 : item.type) === 'promotion';
|
|
538
537
|
});
|
|
539
538
|
if (hasPromoDiscountItem) return fromList;
|
|
540
539
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
@@ -1048,7 +1047,7 @@ export function createDefaultTempOrder(params) {
|
|
|
1048
1047
|
};
|
|
1049
1048
|
}
|
|
1050
1049
|
export function buildSubmitPayload(params) {
|
|
1051
|
-
var _tempOrder$customer_i, _tempOrder$
|
|
1050
|
+
var _tempOrder$customer_i, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref30, _tempOrder$is_price_i, _tempOrder$is_deposit, _enhancedPayload$summ;
|
|
1052
1051
|
var tempOrder = params.tempOrder,
|
|
1053
1052
|
cacheId = params.cacheId,
|
|
1054
1053
|
_params$now = params.now,
|
|
@@ -1094,9 +1093,6 @@ export function buildSubmitPayload(params) {
|
|
|
1094
1093
|
var payload = _objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
1095
1094
|
customer_id: (_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : 1,
|
|
1096
1095
|
customer_name: tempOrder.customer_name || 'Walk-In',
|
|
1097
|
-
country_calling_code: String((_tempOrder$country_ca = tempOrder.country_calling_code) !== null && _tempOrder$country_ca !== void 0 ? _tempOrder$country_ca : ''),
|
|
1098
|
-
phone: String((_tempOrder$phone = tempOrder.phone) !== null && _tempOrder$phone !== void 0 ? _tempOrder$phone : ''),
|
|
1099
|
-
email: String((_tempOrder$email = tempOrder.email) !== null && _tempOrder$email !== void 0 ? _tempOrder$email : ''),
|
|
1100
1096
|
order_number: (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : null,
|
|
1101
1097
|
shop_order_number: (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : null,
|
|
1102
1098
|
shop_full_order_number: (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : null,
|
|
@@ -1156,7 +1152,9 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
1156
1152
|
var item = paymentItem;
|
|
1157
1153
|
var customPaymentId = (_item$custom_payment_ = item.custom_payment_id) !== null && _item$custom_payment_ !== void 0 ? _item$custom_payment_ : item.id;
|
|
1158
1154
|
var metadata = item.metadata && _typeof(item.metadata) === 'object' ? _objectSpread({}, item.metadata) : {};
|
|
1159
|
-
|
|
1155
|
+
if (item.uuid && !metadata.unique_payment_number) {
|
|
1156
|
+
metadata.unique_payment_number = String(item.uuid);
|
|
1157
|
+
}
|
|
1160
1158
|
var paymentMetadataKeys = ['rounding_rule', 'shop_wallet_pass_id', 'actual_paid_amount', 'change_given_amount'];
|
|
1161
1159
|
for (var _i3 = 0, _paymentMetadataKeys = paymentMetadataKeys; _i3 < _paymentMetadataKeys.length; _i3++) {
|
|
1162
1160
|
var key = _paymentMetadataKeys[_i3];
|
|
@@ -1167,10 +1165,8 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
1167
1165
|
var timestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
1168
1166
|
var paymentTime = (_item$payment_time = item.payment_time) !== null && _item$payment_time !== void 0 ? _item$payment_time : timestamp;
|
|
1169
1167
|
var createdAt = (_item$created_at = item.created_at) !== null && _item$created_at !== void 0 ? _item$created_at : timestamp;
|
|
1170
|
-
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(
|
|
1168
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, item.order_payment_id !== undefined ? {
|
|
1171
1169
|
order_payment_id: item.order_payment_id
|
|
1172
|
-
} : {}), paymentNumber !== undefined && paymentNumber !== null && paymentNumber !== '' ? {
|
|
1173
|
-
payment_number: String(paymentNumber)
|
|
1174
1170
|
} : {}), {}, {
|
|
1175
1171
|
amount: String((_item$amount = item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0.00'),
|
|
1176
1172
|
code: String(item.code || ''),
|
|
@@ -20,7 +20,6 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
20
20
|
protected defaultVersion: string;
|
|
21
21
|
request: RequestPlugin;
|
|
22
22
|
private app;
|
|
23
|
-
private appPlugin;
|
|
24
23
|
private store;
|
|
25
24
|
window: WindowPlugin;
|
|
26
25
|
private dbManager;
|
|
@@ -41,7 +40,6 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
41
40
|
* paymentModule.updateOtherParams({ fatherModule: 'bookingTicket' });
|
|
42
41
|
*/
|
|
43
42
|
updateOtherParams(params: Record<string, any>): void;
|
|
44
|
-
private getPaymentNumberAppData;
|
|
45
43
|
/**
|
|
46
44
|
* 记录信息日志
|
|
47
45
|
*/
|
|
@@ -27,9 +27,6 @@ import { CashPaymentImpl } from "./cash";
|
|
|
27
27
|
import { EftposPaymentImpl } from "./eftpos";
|
|
28
28
|
import { WalletPassPaymentImpl } from "./walletpass";
|
|
29
29
|
import { Decimal } from 'decimal.js';
|
|
30
|
-
import { ensureOrderPaymentNumber } from "../Order/payment-utils";
|
|
31
|
-
import { createUuidV4 } from "../Order/utils";
|
|
32
|
-
import { resolvePaymentNumberDevicePrefix } from "../../utils/payment-number";
|
|
33
30
|
export * from "./types";
|
|
34
31
|
export { generateRequestUniqueId };
|
|
35
32
|
|
|
@@ -105,7 +102,6 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
105
102
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
106
103
|
_defineProperty(_assertThisInitialized(_this), "app", void 0);
|
|
107
104
|
// App instance
|
|
108
|
-
_defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
|
|
109
105
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
110
106
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
111
107
|
// WindowPlugin 实例
|
|
@@ -172,6 +168,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
172
168
|
key: "initialize",
|
|
173
169
|
value: function () {
|
|
174
170
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
171
|
+
var appPlugin;
|
|
175
172
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
176
173
|
while (1) switch (_context.prev = _context.next) {
|
|
177
174
|
case 0:
|
|
@@ -181,7 +178,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
181
178
|
|
|
182
179
|
// 获取依赖的插件
|
|
183
180
|
this.request = core.getPlugin('request');
|
|
184
|
-
|
|
181
|
+
appPlugin = core.getPlugin('app');
|
|
185
182
|
this.window = core.getPlugin('window');
|
|
186
183
|
if (this.request) {
|
|
187
184
|
_context.next = 8;
|
|
@@ -189,13 +186,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
189
186
|
}
|
|
190
187
|
throw new Error('支付模块需要 request 插件支持');
|
|
191
188
|
case 8:
|
|
192
|
-
if (
|
|
189
|
+
if (appPlugin) {
|
|
193
190
|
_context.next = 10;
|
|
194
191
|
break;
|
|
195
192
|
}
|
|
196
193
|
throw new Error('支付模块需要 app 插件支持');
|
|
197
194
|
case 10:
|
|
198
|
-
this.app =
|
|
195
|
+
this.app = appPlugin.getApp();
|
|
199
196
|
this.dbManager = this.app.dbManager;
|
|
200
197
|
this.logger = this.app.logger;
|
|
201
198
|
|
|
@@ -231,15 +228,6 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
231
228
|
value: function updateOtherParams(params) {
|
|
232
229
|
this.otherParams = params || {};
|
|
233
230
|
}
|
|
234
|
-
}, {
|
|
235
|
-
key: "getPaymentNumberAppData",
|
|
236
|
-
value: function getPaymentNumberAppData(key) {
|
|
237
|
-
var _this$appPlugin, _this$appPlugin$getDa, _this$app, _this$app$getStore, _this$app$getStore$ca, _this$app$getStore$ca2;
|
|
238
|
-
var getData = (_this$appPlugin = this.appPlugin) === null || _this$appPlugin === void 0 || (_this$appPlugin$getDa = _this$appPlugin.getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
|
|
239
|
-
if (typeof getData === 'function') return getData(key);
|
|
240
|
-
var coreData = (_this$app = this.app) === null || _this$app === void 0 || (_this$app = _this$app.models) === null || _this$app === void 0 || (_this$app$getStore = _this$app.getStore) === null || _this$app$getStore === void 0 || (_this$app$getStore$ca = (_this$app$getStore$ca2 = _this$app$getStore.call(_this$app)).getDataByModel) === null || _this$app$getStore$ca === void 0 ? void 0 : _this$app$getStore$ca.call(_this$app$getStore$ca2, 'core', 'core');
|
|
241
|
-
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
242
|
-
}
|
|
243
231
|
|
|
244
232
|
/**
|
|
245
233
|
* 记录信息日志
|
|
@@ -896,8 +884,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
896
884
|
key: "addPaymentItemAsync",
|
|
897
885
|
value: (function () {
|
|
898
886
|
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderUuid, paymentItem) {
|
|
899
|
-
var
|
|
900
|
-
var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, currentTime, hasPaymentNumber, paymentNumberDevicePrefix, paymentNumber, newPaymentItem;
|
|
887
|
+
var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, currentTime, newPaymentItem;
|
|
901
888
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
902
889
|
while (1) switch (_context12.prev = _context12.next) {
|
|
903
890
|
case 0:
|
|
@@ -953,29 +940,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
953
940
|
});
|
|
954
941
|
throw new Error(warningMessage);
|
|
955
942
|
case 17:
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
_context12.next = 24;
|
|
961
|
-
break;
|
|
943
|
+
if ((_paymentItem$metadata = paymentItem.metadata) !== null && _paymentItem$metadata !== void 0 && _paymentItem$metadata.unique_payment_number) {
|
|
944
|
+
paymentUuid = paymentItem.metadata.unique_payment_number;
|
|
945
|
+
} else {
|
|
946
|
+
paymentUuid = getUniqueId('payment_');
|
|
962
947
|
}
|
|
963
|
-
|
|
964
|
-
_context12.next = 27;
|
|
965
|
-
break;
|
|
966
|
-
case 24:
|
|
967
|
-
_context12.next = 26;
|
|
968
|
-
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
969
|
-
return _this5.getPaymentNumberAppData(key);
|
|
970
|
-
});
|
|
971
|
-
case 26:
|
|
972
|
-
_context12.t0 = _context12.sent;
|
|
973
|
-
case 27:
|
|
974
|
-
paymentNumberDevicePrefix = _context12.t0;
|
|
975
|
-
paymentNumber = ensureOrderPaymentNumber(paymentItem, paymentNumberDevicePrefix, createUuidV4).payment_number;
|
|
948
|
+
currentTime = formatDateTime(new Date());
|
|
976
949
|
newPaymentItem = {
|
|
977
950
|
uuid: paymentUuid,
|
|
978
|
-
payment_number: paymentNumber,
|
|
979
951
|
custom_payment_id: normalizeCustomPaymentId(paymentItem),
|
|
980
952
|
name: paymentItem.name,
|
|
981
953
|
code: paymentItem.code,
|
|
@@ -994,7 +966,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
994
966
|
// 创建时间
|
|
995
967
|
updated_at: currentTime,
|
|
996
968
|
// 更新时间
|
|
997
|
-
metadata: _objectSpread({}, paymentItem.metadata)
|
|
969
|
+
metadata: _objectSpread(_objectSpread({}, paymentItem.metadata), {}, {
|
|
970
|
+
// 保留传入的所有 metadata 字段
|
|
971
|
+
unique_payment_number: paymentUuid // 设置唯一支付号为支付项的 uuid
|
|
972
|
+
})
|
|
998
973
|
};
|
|
999
974
|
order.payment.push(newPaymentItem);
|
|
1000
975
|
this.recalculateOrderAmount(order);
|
|
@@ -1002,9 +977,9 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1002
977
|
orderUuid: orderUuid,
|
|
1003
978
|
order: order
|
|
1004
979
|
});
|
|
1005
|
-
_context12.next =
|
|
980
|
+
_context12.next = 25;
|
|
1006
981
|
return this.dbManager.update('order', order, true);
|
|
1007
|
-
case
|
|
982
|
+
case 25:
|
|
1008
983
|
this.logInfo('更新订单支付项完成', {
|
|
1009
984
|
orderUuid: orderUuid
|
|
1010
985
|
});
|
|
@@ -1025,22 +1000,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1025
1000
|
actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
|
|
1026
1001
|
changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
|
|
1027
1002
|
});
|
|
1028
|
-
_context12.next =
|
|
1003
|
+
_context12.next = 35;
|
|
1029
1004
|
break;
|
|
1030
|
-
case
|
|
1031
|
-
_context12.prev =
|
|
1032
|
-
_context12.
|
|
1033
|
-
console.error('[PaymentModule] 添加支付项失败', _context12.
|
|
1034
|
-
this.logError('addPaymentItemAsync failed', _context12.
|
|
1005
|
+
case 30:
|
|
1006
|
+
_context12.prev = 30;
|
|
1007
|
+
_context12.t0 = _context12["catch"](1);
|
|
1008
|
+
console.error('[PaymentModule] 添加支付项失败', _context12.t0);
|
|
1009
|
+
this.logError('addPaymentItemAsync failed', _context12.t0, {
|
|
1035
1010
|
orderUuid: orderUuid,
|
|
1036
1011
|
paymentItem: paymentItem
|
|
1037
1012
|
});
|
|
1038
|
-
throw _context12.
|
|
1039
|
-
case
|
|
1013
|
+
throw _context12.t0;
|
|
1014
|
+
case 35:
|
|
1040
1015
|
case "end":
|
|
1041
1016
|
return _context12.stop();
|
|
1042
1017
|
}
|
|
1043
|
-
}, _callee12, this, [[1,
|
|
1018
|
+
}, _callee12, this, [[1, 30]]);
|
|
1044
1019
|
}));
|
|
1045
1020
|
function addPaymentItemAsync(_x13, _x14) {
|
|
1046
1021
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
@@ -1160,17 +1135,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1160
1135
|
key: "updateVoucherPaymentItemsAsync",
|
|
1161
1136
|
value: (function () {
|
|
1162
1137
|
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderUuid, voucherPaymentItems) {
|
|
1163
|
-
var
|
|
1138
|
+
var _this5 = this;
|
|
1164
1139
|
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1165
1140
|
while (1) switch (_context15.prev = _context15.next) {
|
|
1166
1141
|
case 0:
|
|
1167
1142
|
return _context15.abrupt("return", this.runVoucherUpdateLocked(orderUuid, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
1168
|
-
var
|
|
1143
|
+
var _this5$normalizeVouch, normalizedVoucherItems, originalCount, normalizedCount, order, existingVoucherItems, _iterator2, _step2, voucherItem, orderAfterDelete, existingActiveVoucherKeys, _iterator3, _step3, _voucherItem, orderPaymentType, key, updatedOrder;
|
|
1169
1144
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1170
1145
|
while (1) switch (_context14.prev = _context14.next) {
|
|
1171
1146
|
case 0:
|
|
1172
|
-
|
|
1173
|
-
|
|
1147
|
+
_this5$normalizeVouch = _this5.normalizeVoucherPaymentItems(voucherPaymentItems), normalizedVoucherItems = _this5$normalizeVouch.items, originalCount = _this5$normalizeVouch.originalCount, normalizedCount = _this5$normalizeVouch.normalizedCount;
|
|
1148
|
+
_this5.logInfo('Starting updateVoucherPaymentItemsAsync', {
|
|
1174
1149
|
orderUuid: orderUuid,
|
|
1175
1150
|
originalVoucherCount: originalCount,
|
|
1176
1151
|
normalizedVoucherCount: normalizedCount,
|
|
@@ -1192,7 +1167,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1192
1167
|
}
|
|
1193
1168
|
_context14.prev = 3;
|
|
1194
1169
|
_context14.next = 6;
|
|
1195
|
-
return
|
|
1170
|
+
return _this5.getPaymentOrderByUuidAsync(orderUuid);
|
|
1196
1171
|
case 6:
|
|
1197
1172
|
order = _context14.sent;
|
|
1198
1173
|
if (order) {
|
|
@@ -1232,7 +1207,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1232
1207
|
voucherItem = _step2.value;
|
|
1233
1208
|
console.log("[PaymentModule] \u5220\u9664\u73B0\u6709\u4EE3\u91D1\u5238\u652F\u4ED8\u9879: ".concat(voucherItem.uuid));
|
|
1234
1209
|
_context14.next = 19;
|
|
1235
|
-
return
|
|
1210
|
+
return _this5.deletePaymentAsync(orderUuid, voucherItem.uuid);
|
|
1236
1211
|
case 19:
|
|
1237
1212
|
_context14.next = 14;
|
|
1238
1213
|
break;
|
|
@@ -1249,7 +1224,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1249
1224
|
return _context14.finish(26);
|
|
1250
1225
|
case 29:
|
|
1251
1226
|
_context14.next = 31;
|
|
1252
|
-
return
|
|
1227
|
+
return _this5.getPaymentOrderByUuidAsync(orderUuid);
|
|
1253
1228
|
case 31:
|
|
1254
1229
|
orderAfterDelete = _context14.sent;
|
|
1255
1230
|
if (orderAfterDelete) {
|
|
@@ -1296,7 +1271,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1296
1271
|
order_payment_type: orderPaymentType
|
|
1297
1272
|
}));
|
|
1298
1273
|
_context14.next = 49;
|
|
1299
|
-
return
|
|
1274
|
+
return _this5.addPaymentItemAsync(orderUuid, _voucherItem);
|
|
1300
1275
|
case 49:
|
|
1301
1276
|
existingActiveVoucherKeys.add(key);
|
|
1302
1277
|
case 50:
|
|
@@ -1315,17 +1290,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1315
1290
|
return _context14.finish(57);
|
|
1316
1291
|
case 60:
|
|
1317
1292
|
_context14.next = 62;
|
|
1318
|
-
return
|
|
1293
|
+
return _this5.getPaymentOrderByUuidAsync(orderUuid);
|
|
1319
1294
|
case 62:
|
|
1320
1295
|
updatedOrder = _context14.sent;
|
|
1321
1296
|
_context14.next = 65;
|
|
1322
|
-
return
|
|
1297
|
+
return _this5.core.effects.emit("".concat(_this5.name, ":onPaymentAdded"), {
|
|
1323
1298
|
orderUuid: orderUuid,
|
|
1324
1299
|
order: updatedOrder,
|
|
1325
1300
|
payment: null // 批量操作不提供单个支付项
|
|
1326
1301
|
});
|
|
1327
1302
|
case 65:
|
|
1328
|
-
|
|
1303
|
+
_this5.logInfo('updateVoucherPaymentItemsAsync completed successfully', {
|
|
1329
1304
|
orderUuid: orderUuid,
|
|
1330
1305
|
removedVoucherCount: existingVoucherItems.length,
|
|
1331
1306
|
addedVoucherCount: normalizedVoucherItems.length,
|
|
@@ -1337,7 +1312,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1337
1312
|
_context14.prev = 68;
|
|
1338
1313
|
_context14.t2 = _context14["catch"](3);
|
|
1339
1314
|
console.error('[PaymentModule] 批量更新代金券支付项失败:', _context14.t2);
|
|
1340
|
-
|
|
1315
|
+
_this5.logError('updateVoucherPaymentItemsAsync failed', _context14.t2, {
|
|
1341
1316
|
orderUuid: orderUuid,
|
|
1342
1317
|
voucherPaymentItems: voucherPaymentItems
|
|
1343
1318
|
});
|
|
@@ -1386,7 +1361,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1386
1361
|
return payment.uuid === paymentUuid;
|
|
1387
1362
|
});
|
|
1388
1363
|
if (!paymentItem) {
|
|
1389
|
-
_context16.next =
|
|
1364
|
+
_context16.next = 18;
|
|
1390
1365
|
break;
|
|
1391
1366
|
}
|
|
1392
1367
|
// 如果更新参数中包含 amount,先格式化
|
|
@@ -1394,43 +1369,40 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1394
1369
|
if ('amount' in formattedParams && formattedParams.amount !== undefined) {
|
|
1395
1370
|
formattedParams.amount = formatAmount(formattedParams.amount);
|
|
1396
1371
|
}
|
|
1397
|
-
if (formattedParams.metadata && _typeof(formattedParams.metadata) === 'object') {
|
|
1398
|
-
formattedParams.metadata = _objectSpread(_objectSpread({}, paymentItem.metadata || {}), formattedParams.metadata);
|
|
1399
|
-
}
|
|
1400
1372
|
Object.assign(paymentItem, formattedParams);
|
|
1401
1373
|
|
|
1402
1374
|
// 重新计算待付金额
|
|
1403
1375
|
this.recalculateOrderAmount(order);
|
|
1404
1376
|
|
|
1405
1377
|
// 更新到 IndexDB
|
|
1406
|
-
_context16.next =
|
|
1378
|
+
_context16.next = 14;
|
|
1407
1379
|
return this.dbManager.update('order', order);
|
|
1408
|
-
case
|
|
1409
|
-
_context16.next =
|
|
1380
|
+
case 14:
|
|
1381
|
+
_context16.next = 16;
|
|
1410
1382
|
return this.core.effects.emit("".concat(this.name, ":onPaymentUpdated"), {
|
|
1411
1383
|
order: order,
|
|
1412
1384
|
paymentItem: paymentItem
|
|
1413
1385
|
});
|
|
1414
|
-
case
|
|
1415
|
-
_context16.next =
|
|
1386
|
+
case 16:
|
|
1387
|
+
_context16.next = 18;
|
|
1416
1388
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1417
1389
|
action: 'payment_update',
|
|
1418
1390
|
order: order,
|
|
1419
1391
|
paymentItem: paymentItem
|
|
1420
1392
|
});
|
|
1421
|
-
case
|
|
1422
|
-
_context16.next =
|
|
1393
|
+
case 18:
|
|
1394
|
+
_context16.next = 24;
|
|
1423
1395
|
break;
|
|
1424
|
-
case
|
|
1425
|
-
_context16.prev =
|
|
1396
|
+
case 20:
|
|
1397
|
+
_context16.prev = 20;
|
|
1426
1398
|
_context16.t0 = _context16["catch"](0);
|
|
1427
1399
|
console.error('[PaymentModule] 更新支付项失败', _context16.t0);
|
|
1428
1400
|
throw _context16.t0;
|
|
1429
|
-
case
|
|
1401
|
+
case 24:
|
|
1430
1402
|
case "end":
|
|
1431
1403
|
return _context16.stop();
|
|
1432
1404
|
}
|
|
1433
|
-
}, _callee16, this, [[0,
|
|
1405
|
+
}, _callee16, this, [[0, 20]]);
|
|
1434
1406
|
}));
|
|
1435
1407
|
function updatePaymentAsync(_x19, _x20, _x21) {
|
|
1436
1408
|
return _updatePaymentAsync.apply(this, arguments);
|
|
@@ -1546,7 +1518,6 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1546
1518
|
payments: order.payment.map(function (payment) {
|
|
1547
1519
|
return {
|
|
1548
1520
|
uuid: payment.uuid,
|
|
1549
|
-
payment_number: payment.payment_number,
|
|
1550
1521
|
amount: payment.amount,
|
|
1551
1522
|
code: payment.code,
|
|
1552
1523
|
custom_payment_id: payment.custom_payment_id,
|