@pisell/pisellos 1.0.66 → 1.0.68
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/Cart/index.d.ts +1 -0
- package/dist/modules/Cart/index.js +1 -0
- package/dist/modules/Date/index.js +4 -0
- package/dist/modules/Order/index.js +11 -10
- package/dist/modules/Payment/cashRecommendationAlgorithm.js +1 -1
- package/dist/modules/Payment/index.d.ts +1 -0
- package/dist/modules/Payment/index.js +120 -64
- package/dist/modules/Payment/types.d.ts +21 -0
- package/dist/modules/Payment/walletpass.js +18 -13
- package/dist/modules/Rules/index.js +1 -1
- package/dist/modules/Schedule/index.d.ts +1 -1
- package/dist/modules/Schedule/index.js +9 -0
- package/dist/solution/Checkout/index.d.ts +18 -145
- package/dist/solution/Checkout/index.js +1405 -2308
- package/dist/solution/Checkout/types.d.ts +19 -215
- package/dist/solution/Checkout/types.js +2 -46
- package/dist/solution/Checkout/utils/index.d.ts +9 -5
- package/dist/solution/Checkout/utils/index.js +18 -56
- package/dist/solution/ShopDiscount/index.d.ts +6 -1
- package/dist/solution/ShopDiscount/index.js +1 -0
- package/lib/modules/Cart/index.d.ts +1 -0
- package/lib/modules/Cart/index.js +4 -1
- package/lib/modules/Date/index.js +3 -0
- package/lib/modules/Order/index.js +7 -4
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
- package/lib/modules/Payment/index.d.ts +1 -0
- package/lib/modules/Payment/index.js +56 -12
- package/lib/modules/Payment/types.d.ts +21 -0
- package/lib/modules/Payment/walletpass.js +16 -10
- package/lib/modules/Rules/index.js +1 -1
- package/lib/modules/Schedule/index.d.ts +1 -1
- package/lib/modules/Schedule/index.js +9 -0
- package/lib/solution/Checkout/index.d.ts +18 -145
- package/lib/solution/Checkout/index.js +584 -1117
- package/lib/solution/Checkout/types.d.ts +19 -215
- package/lib/solution/Checkout/types.js +3 -27
- package/lib/solution/Checkout/utils/index.d.ts +9 -5
- package/lib/solution/Checkout/utils/index.js +12 -53
- package/lib/solution/ShopDiscount/index.d.ts +6 -1
- package/lib/solution/ShopDiscount/index.js +1 -0
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { BaseModule } from '../BaseModule';
|
|
|
3
3
|
import { CartItem, CartModuleAPI, ECartItemCheckType, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
|
|
4
4
|
import { Account } from '../Account';
|
|
5
5
|
export * from './types';
|
|
6
|
+
export { getProductDeposit } from './utils';
|
|
6
7
|
/**
|
|
7
8
|
* 购物车模块实现
|
|
8
9
|
*/
|
|
@@ -29,6 +29,7 @@ import { createCartItemOrigin, deleteHolderFromCartItem, deleteRelationFormsFrom
|
|
|
29
29
|
import { cloneDeep } from 'lodash-es';
|
|
30
30
|
import { isNormalProduct } from "../Product/utils";
|
|
31
31
|
export * from "./types";
|
|
32
|
+
export { getProductDeposit } from "./utils";
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* 购物车模块实现
|
|
@@ -267,6 +267,10 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
267
267
|
if (!resource.times || !Array.isArray(resource.times) || !resource.start_time) {
|
|
268
268
|
return resource;
|
|
269
269
|
}
|
|
270
|
+
// 如果resource.advanced 为 null 或者 resource.advanced.unit 为 0,则不进行修正
|
|
271
|
+
if (!resource.advanced || resource.advanced.unit === 0) {
|
|
272
|
+
return resource;
|
|
273
|
+
}
|
|
270
274
|
var resourceStartTime = dayjs(resource.start_time);
|
|
271
275
|
|
|
272
276
|
// 过滤和修正时间段
|
|
@@ -292,18 +292,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
292
292
|
bookings: [],
|
|
293
293
|
relation_products: [],
|
|
294
294
|
relation_forms: [],
|
|
295
|
-
payments: []
|
|
295
|
+
payments: [],
|
|
296
|
+
is_full_overwrite_flag: 1
|
|
296
297
|
}, params);
|
|
297
298
|
if ((_orderData$payments = orderData.payments) !== null && _orderData$payments !== void 0 && _orderData$payments.length) {
|
|
298
299
|
orderData.small_ticket_data_flag = 1;
|
|
299
300
|
}
|
|
300
301
|
|
|
301
|
-
// 如果进来的order_id 是真实的,则不需要再传递 bookings 和 relation_products
|
|
302
|
-
if (params.order_id) {
|
|
303
|
-
orderData.bookings = [];
|
|
304
|
-
orderData.relation_products = [];
|
|
305
|
-
}
|
|
306
|
-
|
|
307
302
|
// 兜底策略,如果是第一次下单,没有 order_id,且没有 schedule_date,则设置为当前时间
|
|
308
303
|
if (!params.order_id && !orderData.schedule_date) {
|
|
309
304
|
orderData.schedule_date = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
@@ -350,10 +345,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
350
345
|
});
|
|
351
346
|
|
|
352
347
|
// 调用后端接口
|
|
353
|
-
_context3.next =
|
|
348
|
+
_context3.next = 10;
|
|
354
349
|
return this.request.post('/order/checkout', orderData);
|
|
355
|
-
case
|
|
350
|
+
case 10:
|
|
356
351
|
response = _context3.sent;
|
|
352
|
+
this.logInfo('Order API called successfully', {
|
|
353
|
+
response: response
|
|
354
|
+
});
|
|
357
355
|
console.log('[Order] 订单创建成功,后端响应:', {
|
|
358
356
|
success: !!response,
|
|
359
357
|
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)
|
|
@@ -363,8 +361,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
363
361
|
_context3.prev = 16;
|
|
364
362
|
_context3.t0 = _context3["catch"](2);
|
|
365
363
|
console.error('[Order] createOrderByCheckout 创建订单失败:', _context3.t0);
|
|
364
|
+
this.logInfo('Order API called failed', {
|
|
365
|
+
error: _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0)
|
|
366
|
+
});
|
|
366
367
|
throw _context3.t0;
|
|
367
|
-
case
|
|
368
|
+
case 21:
|
|
368
369
|
case "end":
|
|
369
370
|
return _context3.stop();
|
|
370
371
|
}
|
|
@@ -19,7 +19,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
19
19
|
*/
|
|
20
20
|
export var CURRENCY_DENOMINATIONS = {
|
|
21
21
|
// 美元
|
|
22
|
-
'USD': [100, 50, 20, 10, 5,
|
|
22
|
+
'USD': [100, 50, 20, 10, 5, 1, 0.5, 0.25, 0.1, 0.05, 0.01],
|
|
23
23
|
// 人民币
|
|
24
24
|
'CNY': [100, 50, 20, 10, 5, 1, 0.5, 0.1, 0.05, 0.01],
|
|
25
25
|
'RMB': [100, 50, 20, 10, 5, 1, 0.5, 0.1, 0.05, 0.01],
|
|
@@ -85,6 +85,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
85
85
|
// IndexDBManager 实例
|
|
86
86
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
87
87
|
// LoggerManager 实例
|
|
88
|
+
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
88
89
|
// 支付方式实例
|
|
89
90
|
_defineProperty(_assertThisInitialized(_this), "cash", void 0);
|
|
90
91
|
_defineProperty(_assertThisInitialized(_this), "eftpos", void 0);
|
|
@@ -104,34 +105,35 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
104
105
|
case 0:
|
|
105
106
|
this.core = core;
|
|
106
107
|
this.store = options.store;
|
|
108
|
+
this.otherParams = options.otherParams || {};
|
|
107
109
|
|
|
108
110
|
// 获取依赖的插件
|
|
109
111
|
this.request = core.getPlugin('request');
|
|
110
112
|
appPlugin = core.getPlugin('app');
|
|
111
113
|
if (this.request) {
|
|
112
|
-
_context.next =
|
|
114
|
+
_context.next = 7;
|
|
113
115
|
break;
|
|
114
116
|
}
|
|
115
117
|
throw new Error('支付模块需要 request 插件支持');
|
|
116
|
-
case
|
|
118
|
+
case 7:
|
|
117
119
|
if (appPlugin) {
|
|
118
|
-
_context.next =
|
|
120
|
+
_context.next = 9;
|
|
119
121
|
break;
|
|
120
122
|
}
|
|
121
123
|
throw new Error('支付模块需要 app 插件支持');
|
|
122
|
-
case
|
|
124
|
+
case 9:
|
|
123
125
|
this.app = appPlugin.getApp();
|
|
124
126
|
this.dbManager = this.app.dbManager;
|
|
125
127
|
this.logger = this.app.logger;
|
|
126
128
|
|
|
127
129
|
// 确保支付模块所需的对象存储已创建
|
|
128
|
-
_context.next =
|
|
130
|
+
_context.next = 14;
|
|
129
131
|
return this.ensurePaymentTables();
|
|
130
|
-
case
|
|
132
|
+
case 14:
|
|
131
133
|
this.registerNetworkHandlers();
|
|
132
134
|
console.log('[PaymentModule] 初始化完成');
|
|
133
135
|
this.logInfo('PaymentModule initialized successfully');
|
|
134
|
-
case
|
|
136
|
+
case 17:
|
|
135
137
|
case "end":
|
|
136
138
|
return _context.stop();
|
|
137
139
|
}
|
|
@@ -148,6 +150,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
148
150
|
}, {
|
|
149
151
|
key: "logInfo",
|
|
150
152
|
value: function logInfo(title, metadata) {
|
|
153
|
+
var _this$otherParams;
|
|
154
|
+
if ((_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.fatherModule) {
|
|
155
|
+
var _this$otherParams2;
|
|
156
|
+
var fatherModule = this.core.getModule((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.fatherModule);
|
|
157
|
+
if (fatherModule) {
|
|
158
|
+
fatherModule.logInfo("".concat(title), metadata);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
151
162
|
if (this.logger) {
|
|
152
163
|
this.logger.addLog({
|
|
153
164
|
type: 'info',
|
|
@@ -646,7 +657,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
646
657
|
key: "createPaymentOrderAsync",
|
|
647
658
|
value: (function () {
|
|
648
659
|
var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
|
|
649
|
-
var
|
|
660
|
+
var existingOrder, newOrder;
|
|
650
661
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
651
662
|
while (1) switch (_context7.prev = _context7.next) {
|
|
652
663
|
case 0:
|
|
@@ -656,19 +667,23 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
656
667
|
});
|
|
657
668
|
_context7.prev = 1;
|
|
658
669
|
_context7.next = 4;
|
|
659
|
-
return this.dbManager.
|
|
670
|
+
return this.dbManager.get('order', params.order_id);
|
|
660
671
|
case 4:
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
672
|
+
existingOrder = _context7.sent;
|
|
673
|
+
this.logInfo('createPaymentOrderAsync existingOrder', {
|
|
674
|
+
existingOrder: existingOrder
|
|
664
675
|
});
|
|
676
|
+
// const existingOrder = existingOrders.find(
|
|
677
|
+
// (order: PaymentOrder) => String(order.id) === String(params.order_id),
|
|
678
|
+
// );
|
|
665
679
|
if (!existingOrder) {
|
|
666
|
-
_context7.next =
|
|
680
|
+
_context7.next = 20;
|
|
667
681
|
break;
|
|
668
682
|
}
|
|
669
683
|
// 如果存在相同 order_id 的订单,更新该订单信息
|
|
670
|
-
|
|
671
|
-
|
|
684
|
+
this.logInfo("createPaymentOrderAsync found duplicate order ID: ".concat(params.order_id, ", updating existing payment order"));
|
|
685
|
+
|
|
686
|
+
// const originalOrder = { ...existingOrder };
|
|
672
687
|
existingOrder.order_info = params.order_info;
|
|
673
688
|
existingOrder.total_amount = params.total_amount;
|
|
674
689
|
existingOrder.is_deposit = params.is_deposit || 0;
|
|
@@ -678,14 +693,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
678
693
|
this.recalculateOrderAmount(existingOrder);
|
|
679
694
|
|
|
680
695
|
// 更新到数据库
|
|
681
|
-
_context7.next =
|
|
696
|
+
_context7.next = 15;
|
|
682
697
|
return this.dbManager.update('order', existingOrder);
|
|
683
|
-
case
|
|
684
|
-
_context7.next =
|
|
698
|
+
case 15:
|
|
699
|
+
_context7.next = 17;
|
|
685
700
|
return this.core.effects.emit(PaymentHooks.OnOrderUpdated, existingOrder);
|
|
686
|
-
case
|
|
701
|
+
case 17:
|
|
687
702
|
return _context7.abrupt("return", existingOrder);
|
|
688
|
-
case
|
|
703
|
+
case 20:
|
|
689
704
|
// 创建新的支付订单
|
|
690
705
|
newOrder = {
|
|
691
706
|
uuid: getUniqueId('pay_order_'),
|
|
@@ -701,33 +716,31 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
701
716
|
is_deposit: params.is_deposit || 0,
|
|
702
717
|
deposit_amount: params.deposit_amount || '0.00'
|
|
703
718
|
};
|
|
704
|
-
_context7.next =
|
|
719
|
+
_context7.next = 23;
|
|
705
720
|
return this.dbManager.add('order', newOrder);
|
|
706
|
-
case
|
|
707
|
-
|
|
708
|
-
return this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
|
|
709
|
-
case 26:
|
|
721
|
+
case 23:
|
|
722
|
+
this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
|
|
710
723
|
this.logInfo('createPaymentOrderAsync completed - new payment order created', {
|
|
711
724
|
orderUuid: newOrder.uuid,
|
|
712
725
|
orderId: newOrder.id
|
|
713
726
|
});
|
|
714
727
|
return _context7.abrupt("return", newOrder);
|
|
715
|
-
case
|
|
716
|
-
_context7.next =
|
|
728
|
+
case 26:
|
|
729
|
+
_context7.next = 33;
|
|
717
730
|
break;
|
|
718
|
-
case
|
|
719
|
-
_context7.prev =
|
|
731
|
+
case 28:
|
|
732
|
+
_context7.prev = 28;
|
|
720
733
|
_context7.t0 = _context7["catch"](1);
|
|
721
734
|
console.error('[PaymentModule] 创建支付订单失败', _context7.t0);
|
|
722
735
|
this.logError('createPaymentOrderAsync failed', _context7.t0, {
|
|
723
736
|
orderId: params.order_id
|
|
724
737
|
});
|
|
725
738
|
throw _context7.t0;
|
|
726
|
-
case
|
|
739
|
+
case 33:
|
|
727
740
|
case "end":
|
|
728
741
|
return _context7.stop();
|
|
729
742
|
}
|
|
730
|
-
}, _callee7, this, [[1,
|
|
743
|
+
}, _callee7, this, [[1, 28]]);
|
|
731
744
|
}));
|
|
732
745
|
function createPaymentOrderAsync(_x6) {
|
|
733
746
|
return _createPaymentOrderAsync.apply(this, arguments);
|
|
@@ -799,35 +812,36 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
799
812
|
case 3:
|
|
800
813
|
order = _context9.sent;
|
|
801
814
|
if (!order) {
|
|
802
|
-
_context9.next =
|
|
815
|
+
_context9.next = 13;
|
|
803
816
|
break;
|
|
804
817
|
}
|
|
805
818
|
updatedOrder = _objectSpread(_objectSpread({}, order), params);
|
|
806
|
-
|
|
819
|
+
this.recalculateOrderAmount(updatedOrder);
|
|
820
|
+
_context9.next = 9;
|
|
807
821
|
return this.dbManager.update('order', updatedOrder);
|
|
808
|
-
case
|
|
809
|
-
_context9.next =
|
|
822
|
+
case 9:
|
|
823
|
+
_context9.next = 11;
|
|
810
824
|
return this.core.effects.emit(PaymentHooks.OnOrderUpdated, updatedOrder);
|
|
811
|
-
case
|
|
812
|
-
_context9.next =
|
|
825
|
+
case 11:
|
|
826
|
+
_context9.next = 13;
|
|
813
827
|
return this.core.effects.emit(PaymentHooks.OnOrderChanged, {
|
|
814
828
|
action: 'update',
|
|
815
829
|
order: updatedOrder,
|
|
816
830
|
originalOrder: order
|
|
817
831
|
});
|
|
818
|
-
case
|
|
819
|
-
_context9.next =
|
|
832
|
+
case 13:
|
|
833
|
+
_context9.next = 19;
|
|
820
834
|
break;
|
|
821
|
-
case
|
|
822
|
-
_context9.prev =
|
|
835
|
+
case 15:
|
|
836
|
+
_context9.prev = 15;
|
|
823
837
|
_context9.t0 = _context9["catch"](0);
|
|
824
838
|
console.error('[PaymentModule] 更新订单失败', _context9.t0);
|
|
825
839
|
throw _context9.t0;
|
|
826
|
-
case
|
|
840
|
+
case 19:
|
|
827
841
|
case "end":
|
|
828
842
|
return _context9.stop();
|
|
829
843
|
}
|
|
830
|
-
}, _callee9, this, [[0,
|
|
844
|
+
}, _callee9, this, [[0, 15]]);
|
|
831
845
|
}));
|
|
832
846
|
function updateOrderAsync(_x8, _x9) {
|
|
833
847
|
return _updateOrderAsync.apply(this, arguments);
|
|
@@ -1030,7 +1044,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1030
1044
|
key: "addPaymentItemAsync",
|
|
1031
1045
|
value: (function () {
|
|
1032
1046
|
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid, paymentItem) {
|
|
1033
|
-
var _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, paymentUuid, newPaymentItem;
|
|
1047
|
+
var _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, newPaymentItem;
|
|
1034
1048
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1035
1049
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1036
1050
|
case 0:
|
|
@@ -1051,6 +1065,34 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1051
1065
|
}
|
|
1052
1066
|
throw new Error("Order not found: ".concat(orderUuid));
|
|
1053
1067
|
case 7:
|
|
1068
|
+
// 🔒 支付锁检查:如果订单待付金额已经为0,不允许继续添加支付项
|
|
1069
|
+
expectAmount = new Decimal(order.expect_amount);
|
|
1070
|
+
paidDepositAmount = order.payment.reduce(function (sum, payment) {
|
|
1071
|
+
if (payment.order_payment_type === 'deposit' && payment.status !== 'voided') {
|
|
1072
|
+
return sum.plus(new Decimal(payment.amount));
|
|
1073
|
+
}
|
|
1074
|
+
return sum;
|
|
1075
|
+
}, new Decimal(0));
|
|
1076
|
+
expectedDepositAmount = new Decimal(order.deposit_amount || '0').sub(paidDepositAmount); // 有一种特殊情况,订单金额为 0,但是定金金额>0,且此时是定金状态的,允许添加支付项
|
|
1077
|
+
if (!(expectAmount.lte(0) && expectedDepositAmount.eq(0))) {
|
|
1078
|
+
_context13.next = 15;
|
|
1079
|
+
break;
|
|
1080
|
+
}
|
|
1081
|
+
warningMessage = "\u8BA2\u5355 ".concat(orderUuid, " \u5F85\u4ED8\u91D1\u989D\u5DF2\u4E3A0\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u65B0\u7684\u652F\u4ED8\u9879");
|
|
1082
|
+
console.warn('[PaymentModule] Payment lock triggered:', {
|
|
1083
|
+
orderUuid: orderUuid,
|
|
1084
|
+
expectAmount: order.expect_amount,
|
|
1085
|
+
attemptedPaymentAmount: paymentItem.amount,
|
|
1086
|
+
attemptedPaymentCode: paymentItem.code,
|
|
1087
|
+
reason: 'Order already fully paid'
|
|
1088
|
+
});
|
|
1089
|
+
this.logError('addPaymentItemAsync blocked by payment lock', new Error(warningMessage), {
|
|
1090
|
+
orderUuid: orderUuid,
|
|
1091
|
+
expectAmount: order.expect_amount,
|
|
1092
|
+
paymentItem: paymentItem
|
|
1093
|
+
});
|
|
1094
|
+
throw new Error(warningMessage);
|
|
1095
|
+
case 15:
|
|
1054
1096
|
paymentUuid = getUniqueId('payment_');
|
|
1055
1097
|
newPaymentItem = {
|
|
1056
1098
|
uuid: paymentUuid,
|
|
@@ -1073,15 +1115,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1073
1115
|
};
|
|
1074
1116
|
order.payment.push(newPaymentItem);
|
|
1075
1117
|
this.recalculateOrderAmount(order);
|
|
1076
|
-
_context13.next =
|
|
1118
|
+
_context13.next = 21;
|
|
1077
1119
|
return this.dbManager.update('order', order);
|
|
1078
|
-
case
|
|
1079
|
-
_context13.next =
|
|
1120
|
+
case 21:
|
|
1121
|
+
_context13.next = 23;
|
|
1080
1122
|
return this.core.effects.emit(PaymentHooks.OnPaymentAdded, {
|
|
1081
1123
|
orderUuid: orderUuid,
|
|
1082
1124
|
payment: newPaymentItem
|
|
1083
1125
|
});
|
|
1084
|
-
case
|
|
1126
|
+
case 23:
|
|
1085
1127
|
this.logInfo('addPaymentItemAsync completed successfully', {
|
|
1086
1128
|
orderUuid: orderUuid,
|
|
1087
1129
|
paymentUuid: newPaymentItem.uuid,
|
|
@@ -1095,10 +1137,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1095
1137
|
actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
|
|
1096
1138
|
changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
|
|
1097
1139
|
});
|
|
1098
|
-
_context13.next =
|
|
1140
|
+
_context13.next = 31;
|
|
1099
1141
|
break;
|
|
1100
|
-
case
|
|
1101
|
-
_context13.prev =
|
|
1142
|
+
case 26:
|
|
1143
|
+
_context13.prev = 26;
|
|
1102
1144
|
_context13.t0 = _context13["catch"](1);
|
|
1103
1145
|
console.error('[PaymentModule] 添加支付项失败', _context13.t0);
|
|
1104
1146
|
this.logError('addPaymentItemAsync failed', _context13.t0, {
|
|
@@ -1106,11 +1148,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1106
1148
|
paymentItem: paymentItem
|
|
1107
1149
|
});
|
|
1108
1150
|
throw _context13.t0;
|
|
1109
|
-
case
|
|
1151
|
+
case 31:
|
|
1110
1152
|
case "end":
|
|
1111
1153
|
return _context13.stop();
|
|
1112
1154
|
}
|
|
1113
|
-
}, _callee13, this, [[1,
|
|
1155
|
+
}, _callee13, this, [[1, 26]]);
|
|
1114
1156
|
}));
|
|
1115
1157
|
function addPaymentItemAsync(_x14, _x15) {
|
|
1116
1158
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
@@ -1257,9 +1299,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1257
1299
|
}
|
|
1258
1300
|
throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
|
|
1259
1301
|
case 7:
|
|
1260
|
-
// 1. 查找所有现有的代金券类支付项(带 voucher_id 且状态不是 voided
|
|
1302
|
+
// 1. 查找所有现有的代金券类支付项(带 voucher_id 且状态不是 voided)并且还没有同步给后端
|
|
1303
|
+
// 如果同步给了后端的voucher 不允许删除
|
|
1261
1304
|
existingVoucherItems = order.payment.filter(function (payment) {
|
|
1262
|
-
return payment.voucher_id && payment.status !== 'voided';
|
|
1305
|
+
return payment.voucher_id && payment.status !== 'voided' && !payment.isSynced;
|
|
1263
1306
|
});
|
|
1264
1307
|
console.log('[PaymentModule] 发现现有代金券支付项:', {
|
|
1265
1308
|
orderUuid: orderUuid,
|
|
@@ -1269,7 +1312,8 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1269
1312
|
uuid: item.uuid,
|
|
1270
1313
|
code: item.code,
|
|
1271
1314
|
amount: item.amount,
|
|
1272
|
-
voucher_id: item.voucher_id
|
|
1315
|
+
voucher_id: item.voucher_id,
|
|
1316
|
+
isSynced: item.isSynced
|
|
1273
1317
|
};
|
|
1274
1318
|
})
|
|
1275
1319
|
});
|
|
@@ -1771,7 +1815,8 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1771
1815
|
return sum;
|
|
1772
1816
|
}
|
|
1773
1817
|
}, new Decimal(0));
|
|
1774
|
-
|
|
1818
|
+
// 如果是定金模式,则使用deposit_amount 去减已付款金额
|
|
1819
|
+
var remainingAmount = order.is_deposit === 1 ? new Decimal(order.deposit_amount).minus(paidAmount) : totalAmount.minus(paidAmount);
|
|
1775
1820
|
order.expect_amount = Decimal.max(0, remainingAmount).toFixed(2);
|
|
1776
1821
|
console.log("[PaymentModule] \u91CD\u65B0\u8BA1\u7B97\u8BA2\u5355\u91D1\u989D:", {
|
|
1777
1822
|
orderUuid: order.uuid,
|
|
@@ -2001,7 +2046,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2001
2046
|
key: "roundAmountAsync",
|
|
2002
2047
|
value: function () {
|
|
2003
2048
|
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(originalAmount, interval, rule) {
|
|
2004
|
-
var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount,
|
|
2049
|
+
var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, originalAmountStr, roundedAmountStr, roundingDifference, roundingDifferenceStr;
|
|
2005
2050
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2006
2051
|
while (1) switch (_context26.prev = _context26.next) {
|
|
2007
2052
|
case 0:
|
|
@@ -2049,8 +2094,19 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2049
2094
|
case 22:
|
|
2050
2095
|
// 计算最终金额:roundedValue * interval
|
|
2051
2096
|
finalAmount = roundedValue.mul(roundingInterval);
|
|
2052
|
-
|
|
2053
|
-
|
|
2097
|
+
originalAmountStr = amount.toFixed(2); // 如果最终金额是 0 元,则不采用舍入金额,返回原始金额
|
|
2098
|
+
if (!finalAmount.eq(0)) {
|
|
2099
|
+
_context26.next = 27;
|
|
2100
|
+
break;
|
|
2101
|
+
}
|
|
2102
|
+
console.log("[PaymentModule] \u6700\u7EC8\u91D1\u989D\u4E3A0\uFF0C\u8FD4\u56DE\u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr));
|
|
2103
|
+
return _context26.abrupt("return", {
|
|
2104
|
+
originalAmount: originalAmountStr,
|
|
2105
|
+
roundedAmount: originalAmountStr,
|
|
2106
|
+
roundingDifference: '0.00'
|
|
2107
|
+
});
|
|
2108
|
+
case 27:
|
|
2109
|
+
roundedAmountStr = finalAmount.toFixed(2); // 计算舍入差额
|
|
2054
2110
|
roundingDifference = finalAmount.sub(amount);
|
|
2055
2111
|
roundingDifferenceStr = roundingDifference.toFixed(2);
|
|
2056
2112
|
console.log("[PaymentModule] \u820D\u5165\u7ED3\u679C - \u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr, ", \u820D\u5165\u540E\u91D1\u989D: ").concat(roundedAmountStr, ", \u820D\u5165\u5DEE\u989D: ").concat(roundingDifferenceStr));
|
|
@@ -2059,16 +2115,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2059
2115
|
roundedAmount: roundedAmountStr,
|
|
2060
2116
|
roundingDifference: roundingDifferenceStr
|
|
2061
2117
|
});
|
|
2062
|
-
case
|
|
2063
|
-
_context26.prev =
|
|
2118
|
+
case 34:
|
|
2119
|
+
_context26.prev = 34;
|
|
2064
2120
|
_context26.t1 = _context26["catch"](0);
|
|
2065
2121
|
console.error('[PaymentModule] 金额舍入失败:', _context26.t1);
|
|
2066
2122
|
throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context26.t1 instanceof Error ? _context26.t1.message : String(_context26.t1)));
|
|
2067
|
-
case
|
|
2123
|
+
case 38:
|
|
2068
2124
|
case "end":
|
|
2069
2125
|
return _context26.stop();
|
|
2070
2126
|
}
|
|
2071
|
-
}, _callee26, this, [[0,
|
|
2127
|
+
}, _callee26, this, [[0, 34]]);
|
|
2072
2128
|
}));
|
|
2073
2129
|
function roundAmountAsync(_x28, _x29, _x30) {
|
|
2074
2130
|
return _roundAmountAsync.apply(this, arguments);
|
|
@@ -129,6 +129,15 @@ export interface PaymentItem {
|
|
|
129
129
|
origin_amount?: string;
|
|
130
130
|
/** 订单支付类型 */
|
|
131
131
|
order_payment_type?: 'normal' | 'deposit';
|
|
132
|
+
/** 本支付项是否已成功同步到后端 */
|
|
133
|
+
isSynced?: boolean;
|
|
134
|
+
/** 最近一次同步失败信息(存在则代表同步失败过) */
|
|
135
|
+
syncError?: {
|
|
136
|
+
error: string;
|
|
137
|
+
errorCode?: string;
|
|
138
|
+
statusCode?: number;
|
|
139
|
+
timestamp: number;
|
|
140
|
+
};
|
|
132
141
|
}
|
|
133
142
|
/**
|
|
134
143
|
* 订单信息
|
|
@@ -614,6 +623,8 @@ export interface WalletDeductionRecommendParams {
|
|
|
614
623
|
amount: number;
|
|
615
624
|
tag: string;
|
|
616
625
|
}[];
|
|
626
|
+
/** 订单ID */
|
|
627
|
+
payment_order_id?: string;
|
|
617
628
|
}
|
|
618
629
|
/**
|
|
619
630
|
* 钱包初始化业务数据接口
|
|
@@ -626,6 +637,10 @@ export interface WalletInitBusinessData {
|
|
|
626
637
|
amountInfo: {
|
|
627
638
|
totalAmount: string;
|
|
628
639
|
subTotal: string;
|
|
640
|
+
/** 是否是定金订单 */
|
|
641
|
+
isDeposit?: number;
|
|
642
|
+
/** 定金金额 */
|
|
643
|
+
depositAmount?: string;
|
|
629
644
|
};
|
|
630
645
|
/** 商品列表 */
|
|
631
646
|
products: {
|
|
@@ -635,6 +650,8 @@ export interface WalletInitBusinessData {
|
|
|
635
650
|
selling_price: number;
|
|
636
651
|
}[];
|
|
637
652
|
order_wait_pay_amount?: number;
|
|
653
|
+
/** 订单ID */
|
|
654
|
+
payment_order_id?: string;
|
|
638
655
|
}
|
|
639
656
|
/**
|
|
640
657
|
* 查询用户识别码列表请求参数
|
|
@@ -652,6 +669,8 @@ export interface UserIdentificationCodeParams extends WalletDeductionRecommendPa
|
|
|
652
669
|
amount: number;
|
|
653
670
|
tag: string;
|
|
654
671
|
}[];
|
|
672
|
+
/** 订单ID */
|
|
673
|
+
payment_order_id?: string;
|
|
655
674
|
}
|
|
656
675
|
/**
|
|
657
676
|
* 钱包推荐扣款响应数据
|
|
@@ -703,6 +722,8 @@ export interface UserIdentificationCodeItem {
|
|
|
703
722
|
export interface SearchIdentificationCodeParams extends WalletDeductionRecommendParams {
|
|
704
723
|
/** 识别码 */
|
|
705
724
|
code: string;
|
|
725
|
+
/** 订单ID */
|
|
726
|
+
payment_order_id?: string;
|
|
706
727
|
}
|
|
707
728
|
/**
|
|
708
729
|
* 搜索识别码响应数据
|
|
@@ -59,7 +59,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
59
59
|
var customer_id = businessData.customer_id,
|
|
60
60
|
amountInfo = businessData.amountInfo,
|
|
61
61
|
products = businessData.products,
|
|
62
|
-
order_wait_pay_amount = businessData.order_wait_pay_amount
|
|
62
|
+
order_wait_pay_amount = businessData.order_wait_pay_amount,
|
|
63
|
+
payment_order_id = businessData.payment_order_id;
|
|
63
64
|
|
|
64
65
|
// 转换金额为数字类型
|
|
65
66
|
var totalAmount = Number(amountInfo.totalAmount);
|
|
@@ -72,10 +73,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
72
73
|
// 订单小计金额
|
|
73
74
|
order_product_amount: subTotal,
|
|
74
75
|
// 订单待支付金额
|
|
75
|
-
order_wait_pay_amount: order_wait_pay_amount || totalAmount,
|
|
76
|
+
order_wait_pay_amount: order_wait_pay_amount || (amountInfo !== null && amountInfo !== void 0 && amountInfo.isDeposit ? Number(amountInfo === null || amountInfo === void 0 ? void 0 : amountInfo.depositAmount) : totalAmount),
|
|
76
77
|
// order_behavior_count_customer_id: 1,
|
|
77
78
|
products: products,
|
|
78
|
-
prepare_payments: []
|
|
79
|
+
prepare_payments: [],
|
|
80
|
+
payment_order_id: payment_order_id
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
// 存储生成的参数到模块中
|
|
@@ -252,7 +254,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
252
254
|
key: "getWalletPassRecommendListAsync",
|
|
253
255
|
value: function () {
|
|
254
256
|
var _getWalletPassRecommendListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
255
|
-
var response;
|
|
257
|
+
var _this$walletParams, response;
|
|
256
258
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
257
259
|
while (1) switch (_context3.prev = _context3.next) {
|
|
258
260
|
case 0:
|
|
@@ -260,7 +262,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
260
262
|
this.paymentModule.logInfo('[WalletPass] 开始获取钱包推荐列表', {
|
|
261
263
|
customer_id: params.customer_id,
|
|
262
264
|
order_expect_amount: params.order_expect_amount,
|
|
263
|
-
sale_channel: params.sale_channel
|
|
265
|
+
sale_channel: params.sale_channel,
|
|
266
|
+
payment_order_id: (_this$walletParams = this.walletParams) === null || _this$walletParams === void 0 ? void 0 : _this$walletParams.payment_order_id
|
|
264
267
|
});
|
|
265
268
|
_context3.next = 4;
|
|
266
269
|
return this.paymentModule.request.post('/machinecode/prepare/deduction/recommend', params // 将 params 作为请求体数据
|
|
@@ -315,7 +318,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
315
318
|
key: "getUserIdentificationCodeListAsync",
|
|
316
319
|
value: function () {
|
|
317
320
|
var _getUserIdentificationCodeListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
318
|
-
var _newParams$prepare_pa, newParams, response, sortedData;
|
|
321
|
+
var _newParams$prepare_pa, _this$walletParams2, newParams, response, sortedData;
|
|
319
322
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
320
323
|
while (1) switch (_context4.prev = _context4.next) {
|
|
321
324
|
case 0:
|
|
@@ -325,7 +328,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
325
328
|
customer_id: newParams.customer_id,
|
|
326
329
|
available: newParams.available,
|
|
327
330
|
prepare_payments_count: ((_newParams$prepare_pa = newParams.prepare_payments) === null || _newParams$prepare_pa === void 0 ? void 0 : _newParams$prepare_pa.length) || 0,
|
|
328
|
-
filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass
|
|
331
|
+
filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass,
|
|
332
|
+
payment_order_id: (_this$walletParams2 = this.walletParams) === null || _this$walletParams2 === void 0 ? void 0 : _this$walletParams2.payment_order_id
|
|
329
333
|
});
|
|
330
334
|
_context4.next = 5;
|
|
331
335
|
return this.paymentModule.request.post('/machinecode/prepare/deduction', newParams);
|
|
@@ -406,9 +410,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
406
410
|
});
|
|
407
411
|
|
|
408
412
|
// 检查识别码是否为9位且前3位为"000"
|
|
409
|
-
|
|
410
|
-
//
|
|
411
|
-
isWalletCode = code.startsWith('WL');
|
|
413
|
+
isWalletCode = code.length === 9 && code.startsWith('000'); // 测试环境先使用 WL
|
|
414
|
+
// const isWalletCode = code.startsWith('WL');
|
|
412
415
|
if (!isWalletCode) {
|
|
413
416
|
_context5.next = 14;
|
|
414
417
|
break;
|
|
@@ -443,7 +446,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
443
446
|
baseWalletParams = this.walletParams; // 构建完整的搜索参数,包含钱包扣款推荐的所有参数
|
|
444
447
|
searchParams = {
|
|
445
448
|
// 基础钱包参数
|
|
446
|
-
sale_channel: params.sale_channel || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.sale_channel),
|
|
449
|
+
sale_channel: params.sale_channel || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.sale_channel) || "pos",
|
|
447
450
|
customer_id: params.customer_id || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.customer_id),
|
|
448
451
|
order_expect_amount: params.order_expect_amount || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_expect_amount),
|
|
449
452
|
order_product_amount: params.order_product_amount || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_product_amount),
|
|
@@ -453,13 +456,15 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
453
456
|
prepare_payments: params.prepare_payments || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.prepare_payments),
|
|
454
457
|
multiple: 1,
|
|
455
458
|
// 搜索特有参数
|
|
456
|
-
code: params.code
|
|
459
|
+
code: params.code,
|
|
460
|
+
payment_order_id: baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.payment_order_id
|
|
457
461
|
};
|
|
458
462
|
this.paymentModule.logInfo('[WalletPass] 搜索普通识别码', {
|
|
459
463
|
code: searchParams.code,
|
|
460
464
|
customer_id: searchParams.customer_id,
|
|
461
465
|
order_expect_amount: searchParams.order_expect_amount,
|
|
462
|
-
multiple: searchParams.multiple
|
|
466
|
+
multiple: searchParams.multiple,
|
|
467
|
+
payment_order_id: baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.payment_order_id
|
|
463
468
|
});
|
|
464
469
|
_context5.next = 19;
|
|
465
470
|
return this.paymentModule.request.post('/machinecode/prepare/deduction/search', searchParams);
|