@pisell/pisellos 2.2.7 → 2.2.9
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/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +1 -1
- package/dist/modules/Payment/cash.js +1 -1
- package/dist/modules/Payment/eftpos.js +1 -1
- package/dist/modules/Payment/index.js +102 -32
- package/dist/modules/Payment/types.d.ts +21 -2
- package/dist/modules/Payment/walletpass.js +5 -2
- package/dist/modules/Rules/index.d.ts +9 -2
- package/dist/modules/Rules/index.js +39 -6
- package/dist/modules/Rules/types.d.ts +4 -0
- package/dist/server/modules/menu/index.js +1 -1
- package/dist/server/modules/products/index.js +1 -1
- package/dist/server/modules/schedule/index.js +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/Checkout/index.d.ts +2 -0
- package/dist/solution/Checkout/index.js +217 -72
- package/dist/solution/Checkout/types.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.d.ts +3 -0
- package/dist/solution/ShopDiscount/index.js +16 -5
- package/dist/solution/ShopDiscount/types.d.ts +5 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +1 -1
- package/lib/modules/Payment/cash.js +1 -1
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.js +71 -11
- package/lib/modules/Payment/types.d.ts +21 -2
- package/lib/modules/Payment/walletpass.js +6 -4
- package/lib/modules/Rules/index.d.ts +9 -2
- package/lib/modules/Rules/index.js +40 -9
- package/lib/modules/Rules/types.d.ts +4 -0
- package/lib/server/modules/menu/index.js +1 -1
- package/lib/server/modules/products/index.js +1 -1
- package/lib/server/modules/schedule/index.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/Checkout/index.d.ts +2 -0
- package/lib/solution/Checkout/index.js +121 -10
- package/lib/solution/Checkout/types.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.d.ts +3 -0
- package/lib/solution/ShopDiscount/index.js +12 -4
- package/lib/solution/ShopDiscount/types.d.ts +5 -0
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
19
19
|
with_good_pass: 0 | 1;
|
|
20
20
|
with_discount_card: 0 | 1;
|
|
21
21
|
customer_id: number;
|
|
22
|
+
with_wallet_pass_holder: 0 | 1;
|
|
22
23
|
}): Promise<Discount[]>;
|
|
23
24
|
batchSearch(code: string, customerId?: number): Promise<Discount[]>;
|
|
24
25
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
@@ -157,7 +157,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
157
157
|
tags: ['good_pass', 'product_discount_card'],
|
|
158
158
|
available: 1,
|
|
159
159
|
relation_product: 1,
|
|
160
|
-
with: ['extensionData'],
|
|
160
|
+
with: ['extensionData', 'holder.detail'],
|
|
161
161
|
order_behavior_count: 1,
|
|
162
162
|
order_behavior_count_customer_id: customerId || 1
|
|
163
163
|
});
|
|
@@ -38,7 +38,7 @@ export var EftposPaymentImpl = /*#__PURE__*/function () {
|
|
|
38
38
|
paymentItem = {
|
|
39
39
|
amount: amount.toString(),
|
|
40
40
|
code: eftposMethod.code,
|
|
41
|
-
|
|
41
|
+
custom_payment_id: eftposMethod.id,
|
|
42
42
|
name: eftposMethod.name,
|
|
43
43
|
type: eftposMethod.type,
|
|
44
44
|
voucher_id: ''
|
|
@@ -21,7 +21,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
21
21
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
22
22
|
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); }
|
|
23
23
|
import { BaseModule } from "../BaseModule";
|
|
24
|
-
import { PaymentStatus, PaymentMethodType, RoundingRule } from "./types";
|
|
24
|
+
import { PaymentStatus, PaymentHooks, PaymentMethodType, RoundingRule } from "./types";
|
|
25
25
|
import { getUniqueId } from "../Cart/utils";
|
|
26
26
|
import { CashPaymentImpl } from "./cash";
|
|
27
27
|
import { EftposPaymentImpl } from "./eftpos";
|
|
@@ -43,6 +43,21 @@ function formatAmount(amount) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* 格式化日期时间为字符串
|
|
48
|
+
* 格式: YYYY-MM-DD HH:mm:ss
|
|
49
|
+
* 示例: 2025-12-10 16:14:50
|
|
50
|
+
*/
|
|
51
|
+
function formatDateTime(date) {
|
|
52
|
+
var year = date.getFullYear();
|
|
53
|
+
var month = String(date.getMonth() + 1).padStart(2, '0');
|
|
54
|
+
var day = String(date.getDate()).padStart(2, '0');
|
|
55
|
+
var hours = String(date.getHours()).padStart(2, '0');
|
|
56
|
+
var minutes = String(date.getMinutes()).padStart(2, '0');
|
|
57
|
+
var seconds = String(date.getSeconds()).padStart(2, '0');
|
|
58
|
+
return "".concat(year, "-").concat(month, "-").concat(day, " ").concat(hours, ":").concat(minutes, ":").concat(seconds);
|
|
59
|
+
}
|
|
60
|
+
|
|
46
61
|
/**
|
|
47
62
|
* 生成请求唯一ID
|
|
48
63
|
* 格式: 年月日时分秒毫秒+4位随机数
|
|
@@ -634,7 +649,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
634
649
|
case 0:
|
|
635
650
|
_context6.prev = 0;
|
|
636
651
|
_context6.next = 3;
|
|
637
|
-
return this.dbManager.get('order', orderUuid);
|
|
652
|
+
return this.dbManager.get('order', orderUuid, true);
|
|
638
653
|
case 3:
|
|
639
654
|
return _context6.abrupt("return", _context6.sent);
|
|
640
655
|
case 6:
|
|
@@ -662,7 +677,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
662
677
|
value: (function () {
|
|
663
678
|
var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
|
|
664
679
|
var _this3 = this;
|
|
665
|
-
var newOrder, dbAddStartTime, dbAddDuration;
|
|
680
|
+
var newOrder, currentTime, dbAddStartTime, dbAddDuration;
|
|
666
681
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
667
682
|
while (1) switch (_context7.prev = _context7.next) {
|
|
668
683
|
case 0:
|
|
@@ -720,11 +735,45 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
720
735
|
tax_fee: '0.00',
|
|
721
736
|
is_deposit: params.is_deposit || 0,
|
|
722
737
|
deposit_amount: params.deposit_amount || '0.00'
|
|
723
|
-
}; //
|
|
738
|
+
}; // 🔧 新增: 处理云端已存在的支付项
|
|
739
|
+
if (params.existPayment && params.existPayment.length > 0) {
|
|
740
|
+
currentTime = formatDateTime(new Date());
|
|
741
|
+
newOrder.payment = params.existPayment.map(function (payment) {
|
|
742
|
+
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
743
|
+
isSynced: true,
|
|
744
|
+
// 标记为已同步
|
|
745
|
+
status: payment.status || 'active',
|
|
746
|
+
// 如果云端支付项已有时间戳,则保留;否则使用当前时间
|
|
747
|
+
created_at: payment.created_at || currentTime,
|
|
748
|
+
updated_at: payment.updated_at || currentTime
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
// 重新计算待付金额
|
|
753
|
+
this.recalculateOrderAmount(newOrder);
|
|
754
|
+
this.logInfo('创建订单时包含云端支付项', {
|
|
755
|
+
orderId: params.order_id,
|
|
756
|
+
existPaymentCount: params.existPayment.length,
|
|
757
|
+
totalAmount: newOrder.total_amount,
|
|
758
|
+
expectAmount: newOrder.expect_amount,
|
|
759
|
+
paymentDetails: params.existPayment.map(function (p) {
|
|
760
|
+
return {
|
|
761
|
+
uuid: p.uuid,
|
|
762
|
+
code: p.code,
|
|
763
|
+
amount: p.amount,
|
|
764
|
+
status: p.status,
|
|
765
|
+
created_at: p.created_at,
|
|
766
|
+
updated_at: p.updated_at
|
|
767
|
+
};
|
|
768
|
+
})
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
// 🚀 性能监控:记录数据库添加操作耗时
|
|
724
773
|
dbAddStartTime = Date.now();
|
|
725
|
-
_context7.next =
|
|
726
|
-
return this.dbManager.add('order', newOrder);
|
|
727
|
-
case
|
|
774
|
+
_context7.next = 7;
|
|
775
|
+
return this.dbManager.add('order', newOrder, true);
|
|
776
|
+
case 7:
|
|
728
777
|
dbAddDuration = Date.now() - dbAddStartTime;
|
|
729
778
|
this.logInfo('Database add operation completed', {
|
|
730
779
|
operation: 'dbManager.add',
|
|
@@ -738,19 +787,19 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
738
787
|
_this3.core.effects.emit("".concat(_this3.name, ":onOrderAdded"), newOrder);
|
|
739
788
|
}, 0);
|
|
740
789
|
return _context7.abrupt("return", newOrder);
|
|
741
|
-
case
|
|
742
|
-
_context7.prev =
|
|
790
|
+
case 13:
|
|
791
|
+
_context7.prev = 13;
|
|
743
792
|
_context7.t0 = _context7["catch"](1);
|
|
744
793
|
console.error('[PaymentModule] 创建支付订单失败', _context7.t0);
|
|
745
794
|
this.logError('createPaymentOrderAsync failed', _context7.t0, {
|
|
746
795
|
orderId: params.order_id
|
|
747
796
|
});
|
|
748
797
|
throw _context7.t0;
|
|
749
|
-
case
|
|
798
|
+
case 18:
|
|
750
799
|
case "end":
|
|
751
800
|
return _context7.stop();
|
|
752
801
|
}
|
|
753
|
-
}, _callee7, this, [[1,
|
|
802
|
+
}, _callee7, this, [[1, 13]]);
|
|
754
803
|
}));
|
|
755
804
|
function createPaymentOrderAsync(_x6) {
|
|
756
805
|
return _createPaymentOrderAsync.apply(this, arguments);
|
|
@@ -1054,7 +1103,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1054
1103
|
key: "addPaymentItemAsync",
|
|
1055
1104
|
value: (function () {
|
|
1056
1105
|
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid, paymentItem) {
|
|
1057
|
-
var _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, newPaymentItem;
|
|
1106
|
+
var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, currentTime, newPaymentItem;
|
|
1058
1107
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1059
1108
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1060
1109
|
case 0:
|
|
@@ -1065,16 +1114,23 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1065
1114
|
orderPaymentType: paymentItem.order_payment_type
|
|
1066
1115
|
});
|
|
1067
1116
|
_context13.prev = 1;
|
|
1068
|
-
|
|
1117
|
+
this.logInfo('准备获取订单', {
|
|
1118
|
+
orderUuid: orderUuid
|
|
1119
|
+
});
|
|
1120
|
+
_context13.next = 5;
|
|
1069
1121
|
return this.getPaymentOrderByUuidAsync(orderUuid);
|
|
1070
|
-
case
|
|
1122
|
+
case 5:
|
|
1071
1123
|
order = _context13.sent;
|
|
1124
|
+
this.logInfo('获取订单信息成功', {
|
|
1125
|
+
orderUuid: orderUuid,
|
|
1126
|
+
order: order
|
|
1127
|
+
});
|
|
1072
1128
|
if (order) {
|
|
1073
|
-
_context13.next =
|
|
1129
|
+
_context13.next = 9;
|
|
1074
1130
|
break;
|
|
1075
1131
|
}
|
|
1076
1132
|
throw new Error("Order not found: ".concat(orderUuid));
|
|
1077
|
-
case
|
|
1133
|
+
case 9:
|
|
1078
1134
|
// 🔒 支付锁检查:如果订单待付金额已经为0,不允许继续添加支付项
|
|
1079
1135
|
expectAmount = new Decimal(order.expect_amount);
|
|
1080
1136
|
paidDepositAmount = order.payment.reduce(function (sum, payment) {
|
|
@@ -1085,7 +1141,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1085
1141
|
}, new Decimal(0));
|
|
1086
1142
|
expectedDepositAmount = new Decimal(order.deposit_amount || '0').sub(paidDepositAmount); // 有一种特殊情况,订单金额为 0,但是定金金额>0,且此时是定金状态的,允许添加支付项
|
|
1087
1143
|
if (!(expectAmount.lte(0) && expectedDepositAmount.eq(0))) {
|
|
1088
|
-
_context13.next =
|
|
1144
|
+
_context13.next = 17;
|
|
1089
1145
|
break;
|
|
1090
1146
|
}
|
|
1091
1147
|
warningMessage = "\u8BA2\u5355 ".concat(orderUuid, " \u5F85\u4ED8\u91D1\u989D\u5DF2\u4E3A0\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u65B0\u7684\u652F\u4ED8\u9879");
|
|
@@ -1102,11 +1158,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1102
1158
|
paymentItem: paymentItem
|
|
1103
1159
|
});
|
|
1104
1160
|
throw new Error(warningMessage);
|
|
1105
|
-
case
|
|
1106
|
-
|
|
1161
|
+
case 17:
|
|
1162
|
+
if ((_paymentItem$metadata = paymentItem.metadata) !== null && _paymentItem$metadata !== void 0 && _paymentItem$metadata.unique_payment_number) {
|
|
1163
|
+
paymentUuid = paymentItem.metadata.unique_payment_number;
|
|
1164
|
+
} else {
|
|
1165
|
+
paymentUuid = getUniqueId('payment_');
|
|
1166
|
+
}
|
|
1167
|
+
currentTime = formatDateTime(new Date());
|
|
1107
1168
|
newPaymentItem = {
|
|
1108
1169
|
uuid: paymentUuid,
|
|
1109
|
-
|
|
1170
|
+
custom_payment_id: paymentItem.custom_payment_id || 0,
|
|
1110
1171
|
name: paymentItem.name,
|
|
1111
1172
|
code: paymentItem.code,
|
|
1112
1173
|
type: paymentItem.type,
|
|
@@ -1118,6 +1179,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1118
1179
|
// 新支付项默认为活跃状态
|
|
1119
1180
|
order_payment_type: paymentItem.order_payment_type || 'normal',
|
|
1120
1181
|
// 默认为正常支付
|
|
1182
|
+
created_at: currentTime,
|
|
1183
|
+
// 创建时间
|
|
1184
|
+
updated_at: currentTime,
|
|
1185
|
+
// 更新时间
|
|
1121
1186
|
metadata: _objectSpread(_objectSpread({}, paymentItem.metadata), {}, {
|
|
1122
1187
|
// 保留传入的所有 metadata 字段
|
|
1123
1188
|
unique_payment_number: paymentUuid // 设置唯一支付号为支付项的 uuid
|
|
@@ -1125,15 +1190,20 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1125
1190
|
};
|
|
1126
1191
|
order.payment.push(newPaymentItem);
|
|
1127
1192
|
this.recalculateOrderAmount(order);
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1193
|
+
this.logInfo('开始更新订单支付项', {
|
|
1194
|
+
orderUuid: orderUuid,
|
|
1195
|
+
order: order
|
|
1196
|
+
});
|
|
1197
|
+
_context13.next = 25;
|
|
1198
|
+
return this.dbManager.update('order', order, true);
|
|
1199
|
+
case 25:
|
|
1200
|
+
this.logInfo('更新订单支付项完成', {
|
|
1201
|
+
orderUuid: orderUuid
|
|
1202
|
+
});
|
|
1203
|
+
this.core.effects.emit(PaymentHooks.OnPaymentAdded, {
|
|
1133
1204
|
orderUuid: orderUuid,
|
|
1134
1205
|
payment: newPaymentItem
|
|
1135
1206
|
});
|
|
1136
|
-
case 23:
|
|
1137
1207
|
this.logInfo('addPaymentItemAsync completed successfully', {
|
|
1138
1208
|
orderUuid: orderUuid,
|
|
1139
1209
|
paymentUuid: newPaymentItem.uuid,
|
|
@@ -1147,10 +1217,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1147
1217
|
actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
|
|
1148
1218
|
changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
|
|
1149
1219
|
});
|
|
1150
|
-
_context13.next =
|
|
1220
|
+
_context13.next = 35;
|
|
1151
1221
|
break;
|
|
1152
|
-
case
|
|
1153
|
-
_context13.prev =
|
|
1222
|
+
case 30:
|
|
1223
|
+
_context13.prev = 30;
|
|
1154
1224
|
_context13.t0 = _context13["catch"](1);
|
|
1155
1225
|
console.error('[PaymentModule] 添加支付项失败', _context13.t0);
|
|
1156
1226
|
this.logError('addPaymentItemAsync failed', _context13.t0, {
|
|
@@ -1158,11 +1228,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1158
1228
|
paymentItem: paymentItem
|
|
1159
1229
|
});
|
|
1160
1230
|
throw _context13.t0;
|
|
1161
|
-
case
|
|
1231
|
+
case 35:
|
|
1162
1232
|
case "end":
|
|
1163
1233
|
return _context13.stop();
|
|
1164
1234
|
}
|
|
1165
|
-
}, _callee13, this, [[1,
|
|
1235
|
+
}, _callee13, this, [[1, 30]]);
|
|
1166
1236
|
}));
|
|
1167
1237
|
function addPaymentItemAsync(_x14, _x15) {
|
|
1168
1238
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
@@ -1624,7 +1694,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1624
1694
|
uuid: payment.uuid,
|
|
1625
1695
|
amount: payment.amount,
|
|
1626
1696
|
code: payment.code,
|
|
1627
|
-
|
|
1697
|
+
custom_payment_id: payment.custom_payment_id,
|
|
1628
1698
|
name: payment.name,
|
|
1629
1699
|
type: payment.type,
|
|
1630
1700
|
voucher_id: payment.voucher_id,
|
|
@@ -96,7 +96,7 @@ export interface PaymentItem {
|
|
|
96
96
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
|
97
97
|
code: string;
|
|
98
98
|
/** 支付类型id,跟支付列表上对应的支付方式保持一致 */
|
|
99
|
-
|
|
99
|
+
custom_payment_id: number;
|
|
100
100
|
/** 支付类型名称,跟支付列表上对应的支付方式保持一致 */
|
|
101
101
|
name: string;
|
|
102
102
|
/** 支付类型type,跟支付列表上对应的支付方式保持一致 */
|
|
@@ -138,6 +138,10 @@ export interface PaymentItem {
|
|
|
138
138
|
statusCode?: number;
|
|
139
139
|
timestamp: number;
|
|
140
140
|
};
|
|
141
|
+
/** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss) */
|
|
142
|
+
created_at?: string;
|
|
143
|
+
/** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss) */
|
|
144
|
+
updated_at?: string;
|
|
141
145
|
}
|
|
142
146
|
/**
|
|
143
147
|
* 订单信息
|
|
@@ -200,6 +204,8 @@ export interface PushOrderParams {
|
|
|
200
204
|
deposit_amount?: string;
|
|
201
205
|
/** 原始订单数据(可选,由 Checkout 模块传入) */
|
|
202
206
|
order_info?: any;
|
|
207
|
+
/** 云端已存在的支付项(可选,用于处理订单在其他设备或云端生成的场景) */
|
|
208
|
+
existPayment?: PaymentItem[];
|
|
203
209
|
}
|
|
204
210
|
/**
|
|
205
211
|
* 更新订单参数
|
|
@@ -219,7 +225,7 @@ export interface PaymentItemInput {
|
|
|
219
225
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
|
220
226
|
code: string;
|
|
221
227
|
/** 支付类型id,跟支付列表上对应的支付方式保持一致 */
|
|
222
|
-
|
|
228
|
+
custom_payment_id: number;
|
|
223
229
|
/** 支付类型名称,跟支付列表上对应的支付方式保持一致 */
|
|
224
230
|
name: string;
|
|
225
231
|
/** 支付类型type,跟支付列表上对应的支付方式保持一致 */
|
|
@@ -248,6 +254,10 @@ export interface PaymentItemInput {
|
|
|
248
254
|
/** 找零金额(现金支付时的找零金额) */
|
|
249
255
|
change_given_amount?: number;
|
|
250
256
|
};
|
|
257
|
+
/** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
|
|
258
|
+
created_at?: string;
|
|
259
|
+
/** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
|
|
260
|
+
updated_at?: string;
|
|
251
261
|
}
|
|
252
262
|
/**
|
|
253
263
|
* 推送支付项参数
|
|
@@ -598,6 +608,8 @@ export interface WalletDeductionRecommendParams {
|
|
|
598
608
|
expect_columns?: string[];
|
|
599
609
|
/** 客户id */
|
|
600
610
|
customer_id?: number;
|
|
611
|
+
/** 客户holder_id */
|
|
612
|
+
holder_id?: number;
|
|
601
613
|
/** 订单总计金额 */
|
|
602
614
|
order_expect_amount: number;
|
|
603
615
|
/** 订单小计金额 */
|
|
@@ -616,6 +628,8 @@ export interface WalletDeductionRecommendParams {
|
|
|
616
628
|
quantity: number;
|
|
617
629
|
/** 商品使用了所有优惠后的最终价格 */
|
|
618
630
|
selling_price: number;
|
|
631
|
+
/** 客户holder_id */
|
|
632
|
+
holder_id?: number;
|
|
619
633
|
}[];
|
|
620
634
|
/** 预备支付 */
|
|
621
635
|
prepare_payments?: {
|
|
@@ -633,6 +647,10 @@ export interface WalletDeductionRecommendParams {
|
|
|
633
647
|
export interface WalletInitBusinessData {
|
|
634
648
|
/** 客户ID(可选) */
|
|
635
649
|
customer_id?: number;
|
|
650
|
+
/** 客户 holder */
|
|
651
|
+
holder?: {
|
|
652
|
+
form_record: number[];
|
|
653
|
+
};
|
|
636
654
|
/** 金额信息 */
|
|
637
655
|
amountInfo: {
|
|
638
656
|
totalAmount: string;
|
|
@@ -648,6 +666,7 @@ export interface WalletInitBusinessData {
|
|
|
648
666
|
product_variant_id: string;
|
|
649
667
|
quantity: number;
|
|
650
668
|
selling_price: number;
|
|
669
|
+
holder_id?: number;
|
|
651
670
|
}[];
|
|
652
671
|
order_wait_pay_amount?: number;
|
|
653
672
|
/** 订单ID */
|
|
@@ -58,8 +58,9 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
58
58
|
}, {
|
|
59
59
|
key: "generateWalletParams",
|
|
60
60
|
value: function generateWalletParams(businessData) {
|
|
61
|
-
var _walletParams$product;
|
|
61
|
+
var _holder$form_record, _walletParams$product;
|
|
62
62
|
var customer_id = businessData.customer_id,
|
|
63
|
+
holder = businessData.holder,
|
|
63
64
|
amountInfo = businessData.amountInfo,
|
|
64
65
|
products = businessData.products,
|
|
65
66
|
order_wait_pay_amount = businessData.order_wait_pay_amount,
|
|
@@ -72,6 +73,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
72
73
|
sale_channel: 'pos',
|
|
73
74
|
customer_id: customer_id || 0,
|
|
74
75
|
// 提供默认值,确保类型为 number
|
|
76
|
+
holder_id: (holder === null || holder === void 0 || (_holder$form_record = holder.form_record) === null || _holder$form_record === void 0 ? void 0 : _holder$form_record[0]) || undefined,
|
|
75
77
|
order_expect_amount: totalAmount,
|
|
76
78
|
// 订单小计金额
|
|
77
79
|
order_product_amount: subTotal,
|
|
@@ -87,6 +89,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
87
89
|
this.walletParams = walletParams;
|
|
88
90
|
this.paymentModule.logInfo('[WalletPass] 钱包默认参数已生成并存储', {
|
|
89
91
|
customer_id: walletParams.customer_id,
|
|
92
|
+
holder_id: walletParams.holder_id,
|
|
90
93
|
order_expect_amount: walletParams.order_expect_amount,
|
|
91
94
|
order_product_amount: walletParams.order_product_amount,
|
|
92
95
|
order_wait_pay_amount: walletParams.order_wait_pay_amount,
|
|
@@ -563,7 +566,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
563
566
|
paymentItem = {
|
|
564
567
|
amount: amount.toString(),
|
|
565
568
|
code: walletMethod.code,
|
|
566
|
-
|
|
569
|
+
custom_payment_id: walletMethod.id,
|
|
567
570
|
name: walletMethod.name,
|
|
568
571
|
type: walletMethod.type,
|
|
569
572
|
voucher_id: voucherId || ''
|
|
@@ -12,18 +12,25 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
12
12
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
13
13
|
setRulesList(rulesList: Rules[]): Promise<void>;
|
|
14
14
|
getRulesList(): Rules[];
|
|
15
|
-
|
|
15
|
+
private checkHolderMatch;
|
|
16
|
+
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, }: {
|
|
16
17
|
oldDiscountList: Discount[];
|
|
17
18
|
newDiscountList: Discount[];
|
|
18
19
|
productList: any[];
|
|
20
|
+
holders: {
|
|
21
|
+
form_record_id: number;
|
|
22
|
+
}[];
|
|
19
23
|
}): {
|
|
20
24
|
isAvailable: boolean;
|
|
21
25
|
discountList: Discount[];
|
|
22
26
|
productList: any[];
|
|
23
27
|
};
|
|
24
|
-
calcDiscount({ discountList, productList, }: {
|
|
28
|
+
calcDiscount({ discountList, productList, holders, }: {
|
|
25
29
|
discountList: Discount[];
|
|
26
30
|
productList: any[];
|
|
31
|
+
holders: {
|
|
32
|
+
form_record_id: number;
|
|
33
|
+
}[];
|
|
27
34
|
}, options?: {
|
|
28
35
|
isSelected?: boolean;
|
|
29
36
|
discountId?: number;
|
|
@@ -28,6 +28,8 @@ import { uniqueById, getDiscountAmount } from "../../solution/ShopDiscount/utils
|
|
|
28
28
|
import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
|
|
29
29
|
import Decimal from 'decimal.js';
|
|
30
30
|
import { isBoolean } from 'lodash-es';
|
|
31
|
+
// 临时变量
|
|
32
|
+
var flatItem;
|
|
31
33
|
export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
32
34
|
_inherits(RulesModule, _BaseModule);
|
|
33
35
|
var _super = _createSuper(RulesModule);
|
|
@@ -90,6 +92,23 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
90
92
|
return this.store.rulesList;
|
|
91
93
|
}
|
|
92
94
|
|
|
95
|
+
// 检查 holder 是否匹配
|
|
96
|
+
}, {
|
|
97
|
+
key: "checkHolderMatch",
|
|
98
|
+
value: function checkHolderMatch(discount, product, holders) {
|
|
99
|
+
var _discount$holder;
|
|
100
|
+
// 非表单类型 holder 视为匹配
|
|
101
|
+
if (((_discount$holder = discount.holder) === null || _discount$holder === void 0 ? void 0 : _discount$holder.holder_type) !== 'form') return true;
|
|
102
|
+
// 主预约holder, 目前(20251124)默认只考虑单个holder的情况
|
|
103
|
+
var orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : undefined;
|
|
104
|
+
var productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
|
|
105
|
+
// 父预约及商品都无holder, 则略过检查
|
|
106
|
+
if (!orderHolderId && !productHolderId) return true;
|
|
107
|
+
|
|
108
|
+
// 最终直接匹配 holder 是否相同
|
|
109
|
+
return (productHolderId || orderHolderId) === discount.holder.holder_id;
|
|
110
|
+
}
|
|
111
|
+
|
|
93
112
|
// 判断discountList 是否可以对当前productList生效
|
|
94
113
|
}, {
|
|
95
114
|
key: "isDiscountListAvailable",
|
|
@@ -97,7 +116,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
97
116
|
var _this2 = this;
|
|
98
117
|
var oldDiscountList = _ref.oldDiscountList,
|
|
99
118
|
newDiscountList = _ref.newDiscountList,
|
|
100
|
-
productList = _ref.productList
|
|
119
|
+
productList = _ref.productList,
|
|
120
|
+
holders = _ref.holders;
|
|
101
121
|
// 首先检查是否有新的优惠券可应用
|
|
102
122
|
if (!newDiscountList || newDiscountList.length === 0) {
|
|
103
123
|
return {
|
|
@@ -127,7 +147,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
127
147
|
var mergedDiscountList = uniqueById(uniqueById([].concat(_toConsumableArray(filteredOldDiscountList), _toConsumableArray(newDiscountList))), 'product_id');
|
|
128
148
|
var result = this.calcDiscount({
|
|
129
149
|
discountList: mergedDiscountList,
|
|
130
|
-
productList: _toConsumableArray(productList)
|
|
150
|
+
productList: _toConsumableArray(productList),
|
|
151
|
+
holders: holders
|
|
131
152
|
}, {
|
|
132
153
|
scan: true
|
|
133
154
|
});
|
|
@@ -164,7 +185,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
164
185
|
value: function calcDiscount(_ref2, options) {
|
|
165
186
|
var _this3 = this;
|
|
166
187
|
var discountList = _ref2.discountList,
|
|
167
|
-
productList = _ref2.productList
|
|
188
|
+
productList = _ref2.productList,
|
|
189
|
+
holders = _ref2.holders;
|
|
168
190
|
// 识别出来是不是在编辑的界面里又新增了商品
|
|
169
191
|
// 这种情况下,如果有可用的优惠券,也会自动勾选上
|
|
170
192
|
var isEditModeAddNewProduct = productList.find(function (n) {
|
|
@@ -302,11 +324,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
302
324
|
sortedProductList.forEach(function (originProduct) {
|
|
303
325
|
var product = _this3.hooks.getProduct(originProduct);
|
|
304
326
|
addModeDiscount.forEach(function (discount) {
|
|
305
|
-
var _product$discount_lis2, _product$discount_lis3;
|
|
327
|
+
var _flatItem$parentProdu, _flatItem$product, _product$discount_lis2, _product$discount_lis3;
|
|
306
328
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
329
|
+
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
330
|
+
var isHolderMatch = _this3.checkHolderMatch(discount, {
|
|
331
|
+
holder_id: ((flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 || (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.holder_id : flatItem === null || flatItem === void 0 || (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.holder_id) || product.holder_id
|
|
332
|
+
}, holders);
|
|
307
333
|
|
|
308
334
|
// 是符合折扣的商品
|
|
309
|
-
var isLimitedProduct = limitedData.type === 'product_all' || limitedData.product_ids && limitedData.product_ids.includes(product.id);
|
|
335
|
+
var isLimitedProduct = (limitedData.type === 'product_all' || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
|
|
310
336
|
|
|
311
337
|
// 编辑的商品 使用了优惠券不可用
|
|
312
338
|
var isAvailableProduct = !(product !== null && product !== void 0 && product.booking_id && product !== null && product !== void 0 && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.length && product !== null && product !== void 0 && (_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.every(function (discount) {
|
|
@@ -361,7 +387,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
361
387
|
|
|
362
388
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
363
389
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
364
|
-
var _product$discount_lis6;
|
|
390
|
+
var _product$discount_lis6, _flatItem$parentProdu2, _flatItem$product2;
|
|
365
391
|
// 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
|
|
366
392
|
// 商品券时主商品价格小于等于0不可用
|
|
367
393
|
if ((Number(product.price) <= 0 || !product.price) && (discount.tag || discount.type) === 'good_pass') return false;
|
|
@@ -375,6 +401,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
375
401
|
if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
|
|
376
402
|
var limitedData = discount.limited_relation_product_data;
|
|
377
403
|
|
|
404
|
+
// 拿到discount配置的holder信息 product信息 product.holder 不可用return false
|
|
405
|
+
var isHolderMatch = _this3.checkHolderMatch(discount, {
|
|
406
|
+
holder_id: ((flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 || (_flatItem$parentProdu2 = flatItem.parentProduct) === null || _flatItem$parentProdu2 === void 0 ? void 0 : _flatItem$parentProdu2.holder_id : flatItem === null || flatItem === void 0 || (_flatItem$product2 = flatItem.product) === null || _flatItem$product2 === void 0 ? void 0 : _flatItem$product2.holder_id) || product.holder_id
|
|
407
|
+
}, holders);
|
|
408
|
+
// 如果 holder 不匹配,则不适用
|
|
409
|
+
if (!isHolderMatch) return false;
|
|
410
|
+
|
|
378
411
|
// 判断优惠券是否适用于该商品
|
|
379
412
|
if (limitedData.type === 'product_all') {
|
|
380
413
|
return true;
|
|
@@ -22,6 +22,9 @@ export interface RulesModuleAPI {
|
|
|
22
22
|
calcDiscount: (params: {
|
|
23
23
|
discountList: any[];
|
|
24
24
|
productList: any[];
|
|
25
|
+
holders: {
|
|
26
|
+
form_record_id: number;
|
|
27
|
+
}[];
|
|
25
28
|
}) => DiscountResult;
|
|
26
29
|
}
|
|
27
30
|
type ProductDetail = {
|
|
@@ -40,6 +43,7 @@ type ProductDetail = {
|
|
|
40
43
|
num?: number;
|
|
41
44
|
quantity: number;
|
|
42
45
|
vouchersApplicable?: boolean;
|
|
46
|
+
holder_id?: number;
|
|
43
47
|
};
|
|
44
48
|
export interface RulesParamsHooks {
|
|
45
49
|
getProduct: (product: Record<string, any>) => ProductDetail;
|
|
@@ -475,7 +475,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
475
475
|
front_end_cache_id: cacheId,
|
|
476
476
|
application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel
|
|
477
477
|
}, {
|
|
478
|
-
|
|
478
|
+
cache: undefined
|
|
479
479
|
});
|
|
480
480
|
case 4:
|
|
481
481
|
productsData = _context6.sent;
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
};
|
|
343
343
|
setOtherData(key: string, value: any): void;
|
|
344
344
|
getOtherData(key: string): any;
|
|
345
|
-
getProductTypeById(id: number): Promise<"
|
|
345
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
346
346
|
/**
|
|
347
347
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
348
348
|
*
|
|
@@ -48,11 +48,13 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
48
48
|
* 初始化结账流程
|
|
49
49
|
*/
|
|
50
50
|
initializeCheckoutAsync(params: CheckoutInitParams): Promise<void>;
|
|
51
|
+
getHolderIdFromBooking(obj: any): number | undefined;
|
|
51
52
|
getProductListByOrder(): {
|
|
52
53
|
product_id: number;
|
|
53
54
|
product_variant_id: string;
|
|
54
55
|
quantity: number;
|
|
55
56
|
selling_price: number;
|
|
57
|
+
holder_id?: number;
|
|
56
58
|
}[];
|
|
57
59
|
initWalletData(params?: {
|
|
58
60
|
order_wait_pay_amount: number;
|