@pisell/pisellos 1.0.89 → 1.0.91
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/types.d.ts +1 -1
- package/dist/modules/Payment/index.js +37 -21
- package/dist/modules/Payment/types.d.ts +1 -0
- package/dist/modules/Payment/walletpass.js +3 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +9 -10
- package/dist/modules/Rules/index.js +10 -7
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +29 -8
- package/dist/solution/BookingByStep/utils/capacity.js +2 -1
- package/dist/solution/BookingByStep/utils/products.d.ts +6 -0
- package/dist/solution/BookingByStep/utils/products.js +10 -0
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +54 -17
- package/dist/solution/index.d.ts +1 -1
- package/dist/solution/index.js +2 -2
- package/lib/modules/Discount/types.d.ts +1 -1
- package/lib/modules/Payment/index.js +28 -9
- package/lib/modules/Payment/types.d.ts +1 -0
- package/lib/modules/Payment/walletpass.js +9 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +1 -8
- package/lib/modules/Rules/index.js +7 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +15 -2
- package/lib/solution/BookingByStep/utils/capacity.js +2 -1
- package/lib/solution/BookingByStep/utils/products.d.ts +6 -0
- package/lib/solution/BookingByStep/utils/products.js +8 -2
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +42 -3
- package/lib/solution/index.d.ts +1 -1
- package/lib/solution/index.js +3 -3
- package/package.json +1 -1
|
@@ -107,10 +107,10 @@ export interface Discount {
|
|
|
107
107
|
week_order_behavior_count?: number;
|
|
108
108
|
month_order_behavior_count?: number;
|
|
109
109
|
customer_order_behavior_count?: number;
|
|
110
|
-
num?: number;
|
|
111
110
|
custom_schedule_snapshot?: {
|
|
112
111
|
data: any[];
|
|
113
112
|
};
|
|
113
|
+
num?: number;
|
|
114
114
|
}
|
|
115
115
|
export interface DiscountState {
|
|
116
116
|
discountList: Discount[];
|
|
@@ -634,7 +634,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
634
634
|
case 0:
|
|
635
635
|
_context6.prev = 0;
|
|
636
636
|
_context6.next = 3;
|
|
637
|
-
return this.dbManager.get('order', orderUuid);
|
|
637
|
+
return this.dbManager.get('order', orderUuid, true);
|
|
638
638
|
case 3:
|
|
639
639
|
return _context6.abrupt("return", _context6.sent);
|
|
640
640
|
case 6:
|
|
@@ -723,7 +723,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
723
723
|
}; // 🚀 性能监控:记录数据库添加操作耗时
|
|
724
724
|
dbAddStartTime = Date.now();
|
|
725
725
|
_context7.next = 6;
|
|
726
|
-
return this.dbManager.add('order', newOrder);
|
|
726
|
+
return this.dbManager.add('order', newOrder, true);
|
|
727
727
|
case 6:
|
|
728
728
|
dbAddDuration = Date.now() - dbAddStartTime;
|
|
729
729
|
this.logInfo('Database add operation completed', {
|
|
@@ -1054,7 +1054,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1054
1054
|
key: "addPaymentItemAsync",
|
|
1055
1055
|
value: (function () {
|
|
1056
1056
|
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;
|
|
1057
|
+
var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, newPaymentItem;
|
|
1058
1058
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1059
1059
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1060
1060
|
case 0:
|
|
@@ -1065,16 +1065,23 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1065
1065
|
orderPaymentType: paymentItem.order_payment_type
|
|
1066
1066
|
});
|
|
1067
1067
|
_context13.prev = 1;
|
|
1068
|
-
|
|
1068
|
+
this.logInfo('准备获取订单', {
|
|
1069
|
+
orderUuid: orderUuid
|
|
1070
|
+
});
|
|
1071
|
+
_context13.next = 5;
|
|
1069
1072
|
return this.getPaymentOrderByUuidAsync(orderUuid);
|
|
1070
|
-
case
|
|
1073
|
+
case 5:
|
|
1071
1074
|
order = _context13.sent;
|
|
1075
|
+
this.logInfo('获取订单信息成功', {
|
|
1076
|
+
orderUuid: orderUuid,
|
|
1077
|
+
order: order
|
|
1078
|
+
});
|
|
1072
1079
|
if (order) {
|
|
1073
|
-
_context13.next =
|
|
1080
|
+
_context13.next = 9;
|
|
1074
1081
|
break;
|
|
1075
1082
|
}
|
|
1076
1083
|
throw new Error("Order not found: ".concat(orderUuid));
|
|
1077
|
-
case
|
|
1084
|
+
case 9:
|
|
1078
1085
|
// 🔒 支付锁检查:如果订单待付金额已经为0,不允许继续添加支付项
|
|
1079
1086
|
expectAmount = new Decimal(order.expect_amount);
|
|
1080
1087
|
paidDepositAmount = order.payment.reduce(function (sum, payment) {
|
|
@@ -1085,7 +1092,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1085
1092
|
}, new Decimal(0));
|
|
1086
1093
|
expectedDepositAmount = new Decimal(order.deposit_amount || '0').sub(paidDepositAmount); // 有一种特殊情况,订单金额为 0,但是定金金额>0,且此时是定金状态的,允许添加支付项
|
|
1087
1094
|
if (!(expectAmount.lte(0) && expectedDepositAmount.eq(0))) {
|
|
1088
|
-
_context13.next =
|
|
1095
|
+
_context13.next = 17;
|
|
1089
1096
|
break;
|
|
1090
1097
|
}
|
|
1091
1098
|
warningMessage = "\u8BA2\u5355 ".concat(orderUuid, " \u5F85\u4ED8\u91D1\u989D\u5DF2\u4E3A0\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u65B0\u7684\u652F\u4ED8\u9879");
|
|
@@ -1102,8 +1109,12 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1102
1109
|
paymentItem: paymentItem
|
|
1103
1110
|
});
|
|
1104
1111
|
throw new Error(warningMessage);
|
|
1105
|
-
case
|
|
1106
|
-
|
|
1112
|
+
case 17:
|
|
1113
|
+
if ((_paymentItem$metadata = paymentItem.metadata) !== null && _paymentItem$metadata !== void 0 && _paymentItem$metadata.unique_payment_number) {
|
|
1114
|
+
paymentUuid = paymentItem.metadata.unique_payment_number;
|
|
1115
|
+
} else {
|
|
1116
|
+
paymentUuid = getUniqueId('payment_');
|
|
1117
|
+
}
|
|
1107
1118
|
newPaymentItem = {
|
|
1108
1119
|
uuid: paymentUuid,
|
|
1109
1120
|
id: paymentItem.id || 0,
|
|
@@ -1125,15 +1136,20 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1125
1136
|
};
|
|
1126
1137
|
order.payment.push(newPaymentItem);
|
|
1127
1138
|
this.recalculateOrderAmount(order);
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1139
|
+
this.logInfo('开始更新订单支付项', {
|
|
1140
|
+
orderUuid: orderUuid,
|
|
1141
|
+
order: order
|
|
1142
|
+
});
|
|
1143
|
+
_context13.next = 24;
|
|
1144
|
+
return this.dbManager.update('order', order, true);
|
|
1145
|
+
case 24:
|
|
1146
|
+
this.logInfo('更新订单支付项完成', {
|
|
1147
|
+
orderUuid: orderUuid
|
|
1148
|
+
});
|
|
1149
|
+
this.core.effects.emit("".concat(this.name, ":onPaymentAdded"), {
|
|
1133
1150
|
orderUuid: orderUuid,
|
|
1134
1151
|
payment: newPaymentItem
|
|
1135
1152
|
});
|
|
1136
|
-
case 23:
|
|
1137
1153
|
this.logInfo('addPaymentItemAsync completed successfully', {
|
|
1138
1154
|
orderUuid: orderUuid,
|
|
1139
1155
|
paymentUuid: newPaymentItem.uuid,
|
|
@@ -1147,10 +1163,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1147
1163
|
actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
|
|
1148
1164
|
changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
|
|
1149
1165
|
});
|
|
1150
|
-
_context13.next =
|
|
1166
|
+
_context13.next = 34;
|
|
1151
1167
|
break;
|
|
1152
|
-
case
|
|
1153
|
-
_context13.prev =
|
|
1168
|
+
case 29:
|
|
1169
|
+
_context13.prev = 29;
|
|
1154
1170
|
_context13.t0 = _context13["catch"](1);
|
|
1155
1171
|
console.error('[PaymentModule] 添加支付项失败', _context13.t0);
|
|
1156
1172
|
this.logError('addPaymentItemAsync failed', _context13.t0, {
|
|
@@ -1158,11 +1174,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1158
1174
|
paymentItem: paymentItem
|
|
1159
1175
|
});
|
|
1160
1176
|
throw _context13.t0;
|
|
1161
|
-
case
|
|
1177
|
+
case 34:
|
|
1162
1178
|
case "end":
|
|
1163
1179
|
return _context13.stop();
|
|
1164
1180
|
}
|
|
1165
|
-
}, _callee13, this, [[1,
|
|
1181
|
+
}, _callee13, this, [[1, 29]]);
|
|
1166
1182
|
}));
|
|
1167
1183
|
function addPaymentItemAsync(_x14, _x15) {
|
|
1168
1184
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
@@ -63,12 +63,14 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
63
63
|
amountInfo = businessData.amountInfo,
|
|
64
64
|
products = businessData.products,
|
|
65
65
|
order_wait_pay_amount = businessData.order_wait_pay_amount,
|
|
66
|
-
payment_order_id = businessData.payment_order_id
|
|
66
|
+
payment_order_id = businessData.payment_order_id,
|
|
67
|
+
is_price_include_tax = businessData.is_price_include_tax;
|
|
67
68
|
|
|
68
69
|
// 转换金额为数字类型
|
|
69
70
|
var totalAmount = Number(amountInfo.totalAmount);
|
|
70
71
|
var subTotal = Number(amountInfo.subTotal);
|
|
71
72
|
var walletParams = {
|
|
73
|
+
is_price_include_tax: is_price_include_tax,
|
|
72
74
|
sale_channel: 'pos',
|
|
73
75
|
customer_id: customer_id || 0,
|
|
74
76
|
// 提供默认值,确保类型为 number
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -129,9 +129,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
129
129
|
with_count: with_count,
|
|
130
130
|
// client_schedule_ids: schedule_ids,
|
|
131
131
|
schedule_date: schedule_date,
|
|
132
|
+
application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel,
|
|
132
133
|
with_schedule: with_schedule,
|
|
133
134
|
schedule_datetime: schedule_datetime,
|
|
134
|
-
application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel,
|
|
135
135
|
is_eject: 1
|
|
136
136
|
}, {
|
|
137
137
|
useCache: true
|
|
@@ -140,17 +140,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
140
140
|
productsData = _context3.sent;
|
|
141
141
|
sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
|
|
142
142
|
return Number(b.sort) - Number(a.sort);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
143
|
+
}); // if (sortedList.length) {
|
|
144
|
+
// sortedList.forEach((n: any) => {
|
|
145
|
+
// if (n.is_eject !== 1 && n['schedule.ids'] && n['schedule.ids'].length) {
|
|
146
|
+
// n.is_eject = 1
|
|
147
|
+
// }
|
|
148
|
+
// })
|
|
149
|
+
// }
|
|
151
150
|
this.addProduct(sortedList);
|
|
152
151
|
return _context3.abrupt("return", sortedList);
|
|
153
|
-
case
|
|
152
|
+
case 10:
|
|
154
153
|
case "end":
|
|
155
154
|
return _context3.stop();
|
|
156
155
|
}
|
|
@@ -24,7 +24,6 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
24
24
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
25
|
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); }
|
|
26
26
|
import { BaseModule } from "../BaseModule";
|
|
27
|
-
import { RulesHooks } from "./types";
|
|
28
27
|
import { uniqueById, getDiscountAmount, getDiscountListAmountTotal, getDiscountListAmount, filterDiscountListByBookingTime } from "../../solution/ShopDiscount/utils";
|
|
29
28
|
import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
|
|
30
29
|
import Decimal from 'decimal.js';
|
|
@@ -74,7 +73,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
74
73
|
case 0:
|
|
75
74
|
this.store.rulesList = rulesList;
|
|
76
75
|
_context2.next = 3;
|
|
77
|
-
return this.core.effects.emit(
|
|
76
|
+
return this.core.effects.emit("".concat(this.name, ":onRulesListChange"), rulesList);
|
|
78
77
|
case 3:
|
|
79
78
|
case "end":
|
|
80
79
|
return _context2.stop();
|
|
@@ -423,7 +422,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
423
422
|
var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
|
|
424
423
|
|
|
425
424
|
// 判断优惠券是否适用于该商品
|
|
426
|
-
if (isAvailableProduct && isLimitedProduct &&
|
|
425
|
+
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable) {
|
|
427
426
|
var _discountApplicabilit, _discount$metadata;
|
|
428
427
|
// 记录此优惠券适用的商品
|
|
429
428
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -506,12 +505,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
506
505
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
507
506
|
var _product$discount_lis3, _product$discount_lis4;
|
|
508
507
|
// 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
|
|
509
|
-
//
|
|
508
|
+
// 商品券时主商品价格为0不可用
|
|
510
509
|
if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.find(function (n) {
|
|
511
510
|
var _n$discount;
|
|
512
511
|
return ((_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.resource_id) === discount.id;
|
|
513
512
|
})) && (discount.tag || discount.type) === 'good_pass') return false;
|
|
514
|
-
|
|
513
|
+
|
|
514
|
+
// 折扣卡商品价格为0时不可用
|
|
515
515
|
if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.find(function (n) {
|
|
516
516
|
var _n$discount2;
|
|
517
517
|
return ((_n$discount2 = n.discount) === null || _n$discount2 === void 0 ? void 0 : _n$discount2.resource_id) === discount.id;
|
|
@@ -660,7 +660,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
660
660
|
discount_list: []
|
|
661
661
|
}))]);
|
|
662
662
|
} else {
|
|
663
|
-
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
663
|
+
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
664
|
+
price: product.price,
|
|
665
|
+
main_product_selling_price: product.price
|
|
666
|
+
} : {
|
|
664
667
|
_id: product._id.split('___')[0] + '___' + index,
|
|
665
668
|
total: product.origin_total || product.total,
|
|
666
669
|
price: product.price,
|
|
@@ -673,7 +676,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
673
676
|
// bundle子商品:保存到扁平化Map
|
|
674
677
|
processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
675
678
|
discount_list: [],
|
|
676
|
-
price: flatItem.bundleItem.original_price,
|
|
679
|
+
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
677
680
|
processed: true
|
|
678
681
|
})]);
|
|
679
682
|
}
|
|
@@ -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
|
*
|
|
@@ -31,7 +31,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
31
31
|
import { BaseModule } from "../../modules/BaseModule";
|
|
32
32
|
import { createModule } from "./types";
|
|
33
33
|
import { formatProductToCartItem, createCartItemOrigin, getUniqueId, handleVariantProduct, formatDateToCartItem, formatAccountToCartItem } from "../../modules/Cart/utils";
|
|
34
|
-
import { getAvailableProductResources } from "./utils/products";
|
|
34
|
+
import { getAvailableProductResources, isSessionProduct } from "./utils/products";
|
|
35
35
|
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
|
|
36
36
|
import dayjs from 'dayjs';
|
|
37
37
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
@@ -238,19 +238,29 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
238
238
|
key: "loadProducts",
|
|
239
239
|
value: (function () {
|
|
240
240
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
241
|
-
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date;
|
|
241
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date, res;
|
|
242
242
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
243
243
|
while (1) switch (_context2.prev = _context2.next) {
|
|
244
244
|
case 0:
|
|
245
245
|
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, schedule_date = _ref.schedule_date;
|
|
246
|
-
|
|
246
|
+
_context2.next = 3;
|
|
247
|
+
return this.store.products.loadProducts({
|
|
247
248
|
category_ids: category_ids,
|
|
248
249
|
product_ids: product_ids,
|
|
249
250
|
collection: collection,
|
|
250
251
|
schedule_date: schedule_date,
|
|
251
252
|
cacheId: this.cacheId
|
|
252
|
-
})
|
|
253
|
-
case
|
|
253
|
+
});
|
|
254
|
+
case 3:
|
|
255
|
+
res = _context2.sent;
|
|
256
|
+
// 预拉取当天的资源数据
|
|
257
|
+
this.getAvailableDate({
|
|
258
|
+
startDate: schedule_date || dayjs().format('YYYY-MM-DD'),
|
|
259
|
+
endDate: schedule_date || dayjs().format('YYYY-MM-DD'),
|
|
260
|
+
products: _toConsumableArray(res)
|
|
261
|
+
});
|
|
262
|
+
return _context2.abrupt("return", res);
|
|
263
|
+
case 6:
|
|
254
264
|
case "end":
|
|
255
265
|
return _context2.stop();
|
|
256
266
|
}
|
|
@@ -282,7 +292,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
282
292
|
value: (function () {
|
|
283
293
|
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
284
294
|
var _schedule$product_ids;
|
|
285
|
-
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, newProductIds, schedule, otherProductsIds, allProductIds;
|
|
295
|
+
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, newProductIds, schedule, otherProductsIds, allProductIds, res;
|
|
286
296
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
287
297
|
while (1) switch (_context3.prev = _context3.next) {
|
|
288
298
|
case 0:
|
|
@@ -329,8 +339,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
329
339
|
schedule_date: date
|
|
330
340
|
});
|
|
331
341
|
case 10:
|
|
332
|
-
|
|
333
|
-
|
|
342
|
+
res = _context3.sent;
|
|
343
|
+
return _context3.abrupt("return", res);
|
|
344
|
+
case 12:
|
|
334
345
|
case "end":
|
|
335
346
|
return _context3.stop();
|
|
336
347
|
}
|
|
@@ -1150,6 +1161,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1150
1161
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1151
1162
|
product_variant_id: product_variant_id
|
|
1152
1163
|
});
|
|
1164
|
+
debugger;
|
|
1165
|
+
// 保护,如果进来的是 session 商品,则必须要有 date 和时间片,否则不允许添加
|
|
1166
|
+
if (isSessionProduct(productData)) {
|
|
1167
|
+
if (!date || !date.startTime || !date.endTime) {
|
|
1168
|
+
return {
|
|
1169
|
+
success: false,
|
|
1170
|
+
errorCode: 'date_or_time_required'
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1153
1174
|
|
|
1154
1175
|
// 库存检测
|
|
1155
1176
|
var currentCartItems = this.store.cart.getItems();
|
|
@@ -24,8 +24,9 @@ export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref) {
|
|
|
24
24
|
if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'package') {
|
|
25
25
|
return (product_bundle || []).map(function (d) {
|
|
26
26
|
var id = d.bundle_product_id;
|
|
27
|
+
var variantId = d.bundle_variant_id;
|
|
27
28
|
var item = ((capacity === null || capacity === void 0 ? void 0 : capacity.package) || []).find(function (item) {
|
|
28
|
-
return item.product_id === id;
|
|
29
|
+
return item.product_id === id || item.product_id === variantId;
|
|
29
30
|
});
|
|
30
31
|
return {
|
|
31
32
|
id: id,
|
|
@@ -9,3 +9,9 @@ export declare const getAvailableProductResources: (products: ProductData[]) =>
|
|
|
9
9
|
rules: any[];
|
|
10
10
|
resourcesMap: Record<number, ProductResourceItem>;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* 判断商品是否是 session 商品
|
|
14
|
+
* @param product 商品数据
|
|
15
|
+
* @returns 是否是 session 商品
|
|
16
|
+
*/
|
|
17
|
+
export declare const isSessionProduct: (product: ProductData) => boolean;
|
|
@@ -47,4 +47,14 @@ export var getAvailableProductResources = function getAvailableProductResources(
|
|
|
47
47
|
rules: rules,
|
|
48
48
|
resourcesMap: resourcesMap
|
|
49
49
|
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 判断商品是否是 session 商品
|
|
54
|
+
* @param product 商品数据
|
|
55
|
+
* @returns 是否是 session 商品
|
|
56
|
+
*/
|
|
57
|
+
export var isSessionProduct = function isSessionProduct(product) {
|
|
58
|
+
var _product$scheduleIds, _product$scheduleIds2;
|
|
59
|
+
return ((_product$scheduleIds = product === null || product === void 0 || (_product$scheduleIds2 = product['schedule.ids']) === null || _product$scheduleIds2 === void 0 ? void 0 : _product$scheduleIds2.length) !== null && _product$scheduleIds !== void 0 ? _product$scheduleIds : 0) > 0;
|
|
50
60
|
};
|
|
@@ -48,6 +48,7 @@ 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;
|
|
@@ -371,10 +371,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
371
371
|
}
|
|
372
372
|
return initializeCheckoutAsync;
|
|
373
373
|
}())
|
|
374
|
+
}, {
|
|
375
|
+
key: "getHolderIdFromBooking",
|
|
376
|
+
value: function getHolderIdFromBooking(obj) {
|
|
377
|
+
var _obj$holder;
|
|
378
|
+
if (!obj) return undefined;
|
|
379
|
+
var ret = obj.holder_id || ((_obj$holder = obj.holder) === null || _obj$holder === void 0 ? void 0 : _obj$holder.form_record);
|
|
380
|
+
if (Array.isArray(ret)) {
|
|
381
|
+
return ret.length > 0 ? Number(ret[0]) : undefined;
|
|
382
|
+
}
|
|
383
|
+
return Number(ret) || undefined;
|
|
384
|
+
}
|
|
374
385
|
}, {
|
|
375
386
|
key: "getProductListByOrder",
|
|
376
387
|
value: function getProductListByOrder() {
|
|
377
|
-
var _this$store$currentOr,
|
|
388
|
+
var _this$store$currentOr,
|
|
389
|
+
_this3 = this,
|
|
390
|
+
_this$store$currentOr2;
|
|
378
391
|
if (!this.store.currentOrder) {
|
|
379
392
|
return [];
|
|
380
393
|
}
|
|
@@ -396,12 +409,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
396
409
|
tax_fee: item.tax_fee,
|
|
397
410
|
// 整个商品折扣后的总金额
|
|
398
411
|
selling_price: item.calculated_selling_price,
|
|
412
|
+
// 使用者id
|
|
413
|
+
holder_id: item.holder_id,
|
|
399
414
|
// 整个商品折扣前的总金额
|
|
400
415
|
original_price: item.calculated_original_price,
|
|
401
416
|
// 主商品折扣前金额,不包含套餐子商品
|
|
402
417
|
main_product_original_price: item.price,
|
|
403
418
|
// 主商品折扣后金额,不包含套餐子商品
|
|
404
419
|
main_product_selling_price: item.main_product_selling_price,
|
|
420
|
+
metadata: {
|
|
421
|
+
// 主商品+非原价(加减价)子商品税费
|
|
422
|
+
"main_product_attached_bundle_tax_fee": item.metadata.main_product_attached_bundle_tax_fee,
|
|
423
|
+
// 主商品+非原价(加减价)子商品附加费
|
|
424
|
+
"main_product_attached_bundle_surcharge_fee": item.metadata.main_product_attached_bundle_surcharge_fee,
|
|
425
|
+
// 可选,附加费均摊舍入金额
|
|
426
|
+
"surcharge_rounding_remainder": item.metadata.surcharge_rounding_remainder
|
|
427
|
+
},
|
|
405
428
|
product_bundle: item.product_bundle.map(function (bundle) {
|
|
406
429
|
return {
|
|
407
430
|
bundle_id: bundle.bundle_id,
|
|
@@ -413,14 +436,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
413
436
|
bundle_sum_price: bundle.bundle_sum_price,
|
|
414
437
|
// 套餐子商品折扣后金额
|
|
415
438
|
bundle_selling_price: bundle.bundle_selling_price,
|
|
416
|
-
num: bundle.num
|
|
439
|
+
num: bundle.num,
|
|
440
|
+
is_charge_tax: bundle.is_charge_tax,
|
|
441
|
+
tax_fee: bundle.tax_fee,
|
|
442
|
+
metadata: {
|
|
443
|
+
// 子商品单数量附加费
|
|
444
|
+
"surcharge_fee": bundle.metadata.surcharge_fee,
|
|
445
|
+
// 可选,附加费均摊舍入金额
|
|
446
|
+
"surcharge_rounding_remainder": bundle.metadata.surcharge_rounding_remainder
|
|
447
|
+
}
|
|
417
448
|
};
|
|
418
449
|
})
|
|
419
450
|
};
|
|
420
451
|
}) || [];
|
|
421
452
|
};
|
|
422
453
|
var productList = formatProduct(((_this$store$currentOr = this.store.currentOrder.order_info) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.original_order_data) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.bookings) === null || _this$store$currentOr === void 0 ? void 0 : _this$store$currentOr.map(function (item) {
|
|
423
|
-
return item.product
|
|
454
|
+
return _objectSpread(_objectSpread({}, item.product), {}, {
|
|
455
|
+
holder_id: _this3.getHolderIdFromBooking(item)
|
|
456
|
+
});
|
|
424
457
|
})) || []);
|
|
425
458
|
var relationProducts = formatProduct(((_this$store$currentOr2 = this.store.currentOrder.order_info) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.original_order_data) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.relation_products) || []);
|
|
426
459
|
return [].concat(_toConsumableArray(productList), _toConsumableArray(relationProducts));
|
|
@@ -456,7 +489,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
456
489
|
depositAmount: (_this$store$currentOr4 = this.store.currentOrder) === null || _this$store$currentOr4 === void 0 ? void 0 : _this$store$currentOr4.deposit_amount,
|
|
457
490
|
isDeposit: (_this$store$currentOr5 = this.store.currentOrder) === null || _this$store$currentOr5 === void 0 ? void 0 : _this$store$currentOr5.is_deposit
|
|
458
491
|
},
|
|
459
|
-
products: this.getProductListByOrder()
|
|
492
|
+
products: this.getProductListByOrder(),
|
|
493
|
+
is_price_include_tax: this.otherParams.is_price_include_tax
|
|
460
494
|
}, params); // 判断订单是否已经同步,如果是则追加payment_order_id参数
|
|
461
495
|
if (this.store.isOrderSynced) {
|
|
462
496
|
walletBusinessData.payment_order_id = (_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.order_id;
|
|
@@ -1566,7 +1600,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1566
1600
|
key: "updateVoucherPaymentItemsAsync",
|
|
1567
1601
|
value: (function () {
|
|
1568
1602
|
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(voucherPaymentItems) {
|
|
1569
|
-
var
|
|
1603
|
+
var _this4 = this;
|
|
1570
1604
|
var paymentItems, allPaymentItemsSynced, remainingAmount, remainingValue, isOrderSynced, orderPaymentType, voucherPaymentItemsWithType, currentOrderId, isCurrentOrderReal, updatedOrder;
|
|
1571
1605
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1572
1606
|
while (1) switch (_context18.prev = _context18.next) {
|
|
@@ -1618,8 +1652,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1618
1652
|
|
|
1619
1653
|
// 从 otherParams 获取 metadata 字段
|
|
1620
1654
|
var metadata = _objectSpread(_objectSpread({}, item.metadata), {}, {
|
|
1621
|
-
rounding_rule:
|
|
1622
|
-
shop_wallet_pass_id:
|
|
1655
|
+
rounding_rule: _this4.otherParams.order_rounding_setting,
|
|
1656
|
+
shop_wallet_pass_id: _this4.otherParams.shop_wallet_pass_id
|
|
1623
1657
|
});
|
|
1624
1658
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
1625
1659
|
order_payment_type: orderPaymentType,
|
|
@@ -3164,7 +3198,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3164
3198
|
key: "updateStateAmountToRemaining",
|
|
3165
3199
|
value: (function () {
|
|
3166
3200
|
var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
3167
|
-
var
|
|
3201
|
+
var _this5 = this;
|
|
3168
3202
|
var checkOrder,
|
|
3169
3203
|
_yield$this$fetchOrde3,
|
|
3170
3204
|
paymentItems,
|
|
@@ -3215,8 +3249,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3215
3249
|
depositPaidAmount = paymentItems.filter(function (item) {
|
|
3216
3250
|
return item.order_payment_type === 'deposit' && item.status !== 'voided';
|
|
3217
3251
|
}).reduce(function (sum, item) {
|
|
3218
|
-
// 如果是 wallet
|
|
3219
|
-
|
|
3252
|
+
// 如果是 wallet,并且还没同步到后端,且此时还没有其他类型的支付项(现金,eftpos,标记支付),不计入已付金额
|
|
3253
|
+
// 如果有其他支付项了,代表此时处于马上要同步的状态,所以计入
|
|
3254
|
+
if (item.voucher_id && !item.isSynced && paymentItems.filter(function (item) {
|
|
3255
|
+
return !item.voucher_id;
|
|
3256
|
+
}).length === 0) {
|
|
3220
3257
|
return sum;
|
|
3221
3258
|
}
|
|
3222
3259
|
var amount = new Decimal(item.amount || '0');
|
|
@@ -3257,7 +3294,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3257
3294
|
hasStateChanged = true;
|
|
3258
3295
|
setTimeout(function () {
|
|
3259
3296
|
// 发出 stateAmount 变更事件
|
|
3260
|
-
|
|
3297
|
+
_this5.core.effects.emit("".concat(_this5.name, ":onStateAmountChanged"), {
|
|
3261
3298
|
oldAmount: currentStateAmount,
|
|
3262
3299
|
newAmount: remainingAmount,
|
|
3263
3300
|
timestamp: Date.now(),
|
|
@@ -3278,7 +3315,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3278
3315
|
|
|
3279
3316
|
// 发出 balanceDueAmount 变更事件
|
|
3280
3317
|
setTimeout(function () {
|
|
3281
|
-
|
|
3318
|
+
_this5.core.effects.emit("".concat(_this5.name, ":onBalanceDueAmountChanged"), {
|
|
3282
3319
|
oldAmount: currentBalanceDueAmount,
|
|
3283
3320
|
newAmount: remainingAmount,
|
|
3284
3321
|
timestamp: Date.now(),
|
|
@@ -3576,7 +3613,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3576
3613
|
key: "syncOrderToBackendWithReturn",
|
|
3577
3614
|
value: (function () {
|
|
3578
3615
|
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
3579
|
-
var
|
|
3616
|
+
var _this6 = this,
|
|
3580
3617
|
_this$store$currentOr23,
|
|
3581
3618
|
_this$store$currentOr24,
|
|
3582
3619
|
_this$store$currentCu2,
|
|
@@ -3657,8 +3694,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3657
3694
|
var _item$metadata, _item$metadata2;
|
|
3658
3695
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
3659
3696
|
metadata: _objectSpread(_objectSpread({}, item.metadata), {}, {
|
|
3660
|
-
rounding_rule: ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.rounding_rule) ||
|
|
3661
|
-
shop_wallet_pass_id: ((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.shop_wallet_pass_id) ||
|
|
3697
|
+
rounding_rule: ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.rounding_rule) || _this6.otherParams.order_rounding_setting,
|
|
3698
|
+
shop_wallet_pass_id: ((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.shop_wallet_pass_id) || _this6.otherParams.shop_wallet_pass_id
|
|
3662
3699
|
})
|
|
3663
3700
|
});
|
|
3664
3701
|
}); // 确定最终的定金金额:优先使用手动设置的值,否则从支付项中计算
|
|
@@ -4365,7 +4402,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4365
4402
|
}, {
|
|
4366
4403
|
key: "resetStoreState",
|
|
4367
4404
|
value: function resetStoreState() {
|
|
4368
|
-
var
|
|
4405
|
+
var _this7 = this;
|
|
4369
4406
|
try {
|
|
4370
4407
|
var prevOrderInfo = this.store.currentOrder ? {
|
|
4371
4408
|
uuid: this.store.currentOrder.uuid,
|
|
@@ -4400,7 +4437,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4400
4437
|
// 使用 setTimeout 确保事件处理不会阻塞状态重置
|
|
4401
4438
|
if (prevOrderInfo) {
|
|
4402
4439
|
setTimeout(function () {
|
|
4403
|
-
|
|
4440
|
+
_this7.core.effects.emit("".concat(_this7.name, ":onOrderCleared"), {
|
|
4404
4441
|
previousOrder: prevOrderInfo,
|
|
4405
4442
|
timestamp: Date.now()
|
|
4406
4443
|
});
|
package/dist/solution/index.d.ts
CHANGED
package/dist/solution/index.js
CHANGED
|
@@ -107,10 +107,10 @@ export interface Discount {
|
|
|
107
107
|
week_order_behavior_count?: number;
|
|
108
108
|
month_order_behavior_count?: number;
|
|
109
109
|
customer_order_behavior_count?: number;
|
|
110
|
-
num?: number;
|
|
111
110
|
custom_schedule_snapshot?: {
|
|
112
111
|
data: any[];
|
|
113
112
|
};
|
|
113
|
+
num?: number;
|
|
114
114
|
}
|
|
115
115
|
export interface DiscountState {
|
|
116
116
|
discountList: Discount[];
|
|
@@ -308,7 +308,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
308
308
|
*/
|
|
309
309
|
async getPaymentOrderByUuidAsync(orderUuid) {
|
|
310
310
|
try {
|
|
311
|
-
return await this.dbManager.get("order", orderUuid);
|
|
311
|
+
return await this.dbManager.get("order", orderUuid, true);
|
|
312
312
|
} catch (error) {
|
|
313
313
|
console.error("[PaymentModule] 获取支付订单失败", error);
|
|
314
314
|
return null;
|
|
@@ -338,7 +338,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
338
338
|
deposit_amount: params.deposit_amount || "0.00"
|
|
339
339
|
};
|
|
340
340
|
const dbAddStartTime = Date.now();
|
|
341
|
-
await this.dbManager.add("order", newOrder);
|
|
341
|
+
await this.dbManager.add("order", newOrder, true);
|
|
342
342
|
const dbAddDuration = Date.now() - dbAddStartTime;
|
|
343
343
|
this.logInfo("Database add operation completed", {
|
|
344
344
|
operation: "dbManager.add",
|
|
@@ -502,7 +502,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
502
502
|
* 为某个订单添加支付项(新方法)
|
|
503
503
|
*/
|
|
504
504
|
async addPaymentItemAsync(orderUuid, paymentItem) {
|
|
505
|
-
var _a, _b, _c;
|
|
505
|
+
var _a, _b, _c, _d;
|
|
506
506
|
this.logInfo("Starting addPaymentItemAsync", {
|
|
507
507
|
orderUuid,
|
|
508
508
|
paymentAmount: paymentItem.amount,
|
|
@@ -510,7 +510,14 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
510
510
|
orderPaymentType: paymentItem.order_payment_type
|
|
511
511
|
});
|
|
512
512
|
try {
|
|
513
|
+
this.logInfo("准备获取订单", {
|
|
514
|
+
orderUuid
|
|
515
|
+
});
|
|
513
516
|
const order = await this.getPaymentOrderByUuidAsync(orderUuid);
|
|
517
|
+
this.logInfo("获取订单信息成功", {
|
|
518
|
+
orderUuid,
|
|
519
|
+
order
|
|
520
|
+
});
|
|
514
521
|
if (!order) {
|
|
515
522
|
throw new Error(`Order not found: ${orderUuid}`);
|
|
516
523
|
}
|
|
@@ -538,7 +545,12 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
538
545
|
});
|
|
539
546
|
throw new Error(warningMessage);
|
|
540
547
|
}
|
|
541
|
-
|
|
548
|
+
let paymentUuid;
|
|
549
|
+
if ((_a = paymentItem.metadata) == null ? void 0 : _a.unique_payment_number) {
|
|
550
|
+
paymentUuid = paymentItem.metadata.unique_payment_number;
|
|
551
|
+
} else {
|
|
552
|
+
paymentUuid = (0, import_utils.getUniqueId)("payment_");
|
|
553
|
+
}
|
|
542
554
|
const newPaymentItem = {
|
|
543
555
|
uuid: paymentUuid,
|
|
544
556
|
id: paymentItem.id || 0,
|
|
@@ -562,23 +574,30 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
562
574
|
};
|
|
563
575
|
order.payment.push(newPaymentItem);
|
|
564
576
|
this.recalculateOrderAmount(order);
|
|
565
|
-
|
|
566
|
-
|
|
577
|
+
this.logInfo("开始更新订单支付项", {
|
|
578
|
+
orderUuid,
|
|
579
|
+
order
|
|
580
|
+
});
|
|
581
|
+
await this.dbManager.update("order", order, true);
|
|
582
|
+
this.logInfo("更新订单支付项完成", {
|
|
583
|
+
orderUuid
|
|
584
|
+
});
|
|
585
|
+
this.core.effects.emit(`${this.name}:onPaymentAdded`, {
|
|
567
586
|
orderUuid,
|
|
568
587
|
payment: newPaymentItem
|
|
569
588
|
});
|
|
570
589
|
this.logInfo("addPaymentItemAsync completed successfully", {
|
|
571
590
|
orderUuid,
|
|
572
591
|
paymentUuid: newPaymentItem.uuid,
|
|
573
|
-
uniquePaymentNumber: (
|
|
592
|
+
uniquePaymentNumber: (_b = newPaymentItem.metadata) == null ? void 0 : _b.unique_payment_number,
|
|
574
593
|
newExpectAmount: order.expect_amount,
|
|
575
594
|
paymentAmount: newPaymentItem.amount,
|
|
576
595
|
paymentCode: newPaymentItem.code,
|
|
577
596
|
orderPaymentType: newPaymentItem.order_payment_type,
|
|
578
597
|
metadataFields: Object.keys(newPaymentItem.metadata || {}),
|
|
579
598
|
// 现金支付找零信息
|
|
580
|
-
actualPaidAmount: (
|
|
581
|
-
changeGivenAmount: (
|
|
599
|
+
actualPaidAmount: (_c = newPaymentItem.metadata) == null ? void 0 : _c.actual_paid_amount,
|
|
600
|
+
changeGivenAmount: (_d = newPaymentItem.metadata) == null ? void 0 : _d.change_given_amount
|
|
582
601
|
});
|
|
583
602
|
} catch (error) {
|
|
584
603
|
console.error("[PaymentModule] 添加支付项失败", error);
|
|
@@ -51,10 +51,18 @@ var WalletPassPaymentImpl = class {
|
|
|
51
51
|
*/
|
|
52
52
|
generateWalletParams(businessData) {
|
|
53
53
|
var _a;
|
|
54
|
-
const {
|
|
54
|
+
const {
|
|
55
|
+
customer_id,
|
|
56
|
+
amountInfo,
|
|
57
|
+
products,
|
|
58
|
+
order_wait_pay_amount,
|
|
59
|
+
payment_order_id,
|
|
60
|
+
is_price_include_tax
|
|
61
|
+
} = businessData;
|
|
55
62
|
const totalAmount = Number(amountInfo.totalAmount);
|
|
56
63
|
const subTotal = Number(amountInfo.subTotal);
|
|
57
64
|
const walletParams = {
|
|
65
|
+
is_price_include_tax,
|
|
58
66
|
sale_channel: "pos",
|
|
59
67
|
customer_id: customer_id || 0,
|
|
60
68
|
// 提供默认值,确保类型为 number
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -95,21 +95,14 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
95
95
|
with_count,
|
|
96
96
|
// client_schedule_ids: schedule_ids,
|
|
97
97
|
schedule_date,
|
|
98
|
+
application_code: (_b = this.otherParams) == null ? void 0 : _b.channel,
|
|
98
99
|
with_schedule,
|
|
99
100
|
schedule_datetime,
|
|
100
|
-
application_code: (_b = this.otherParams) == null ? void 0 : _b.channel,
|
|
101
101
|
is_eject: 1
|
|
102
102
|
},
|
|
103
103
|
{ useCache: true }
|
|
104
104
|
);
|
|
105
105
|
const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
|
|
106
|
-
if (sortedList.length) {
|
|
107
|
-
sortedList.forEach((n) => {
|
|
108
|
-
if (n.is_eject !== 1 && n["schedule.ids"] && n["schedule.ids"].length) {
|
|
109
|
-
n.is_eject = 1;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
106
|
this.addProduct(sortedList);
|
|
114
107
|
return sortedList;
|
|
115
108
|
}
|
|
@@ -33,7 +33,6 @@ __export(Rules_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(Rules_exports);
|
|
35
35
|
var import_BaseModule = require("../BaseModule");
|
|
36
|
-
var import_types = require("./types");
|
|
37
36
|
var import_utils = require("../../solution/ShopDiscount/utils");
|
|
38
37
|
var import_utils2 = require("../Cart/utils");
|
|
39
38
|
var import_decimal = __toESM(require("decimal.js"));
|
|
@@ -53,7 +52,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
53
52
|
}
|
|
54
53
|
async setRulesList(rulesList) {
|
|
55
54
|
this.store.rulesList = rulesList;
|
|
56
|
-
await this.core.effects.emit(
|
|
55
|
+
await this.core.effects.emit(`${this.name}:onRulesListChange`, rulesList);
|
|
57
56
|
}
|
|
58
57
|
getRulesList() {
|
|
59
58
|
return this.store.rulesList;
|
|
@@ -277,7 +276,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
277
276
|
const isLimitedProduct = limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id);
|
|
278
277
|
const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount2.tag || discount2.type)))) : !((flatItem == null ? void 0 : flatItem.booking_id) && ((_d = (_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.metadata) == null ? void 0 : _d.custom_product_bundle_map_id));
|
|
279
278
|
const isBundleAvailable = this.checkPackageSubItemUsageRules(discount, flatItem);
|
|
280
|
-
if (isAvailableProduct && isLimitedProduct &&
|
|
279
|
+
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable) {
|
|
281
280
|
(_e = discountApplicability.get(discount.id)) == null ? void 0 : _e.push(product.id);
|
|
282
281
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
283
282
|
const discountType = discount.tag || discount.type;
|
|
@@ -468,7 +467,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
468
467
|
processedProductsMap.set(
|
|
469
468
|
product._id,
|
|
470
469
|
[this.hooks.setProduct(originProduct, {
|
|
471
|
-
...isManualDiscount ? {
|
|
470
|
+
...isManualDiscount ? {
|
|
471
|
+
price: product.price,
|
|
472
|
+
main_product_selling_price: product.price
|
|
473
|
+
} : {
|
|
472
474
|
_id: product._id.split("___")[0] + "___" + index,
|
|
473
475
|
total: product.origin_total || product.total,
|
|
474
476
|
price: product.price,
|
|
@@ -482,7 +484,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
482
484
|
processedFlatItemsMap.set(flatItem._id, [{
|
|
483
485
|
...flatItem,
|
|
484
486
|
discount_list: [],
|
|
485
|
-
price: flatItem.bundleItem.original_price,
|
|
487
|
+
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
486
488
|
processed: true
|
|
487
489
|
}]);
|
|
488
490
|
}
|
|
@@ -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
|
*
|
|
@@ -185,13 +185,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
185
185
|
collection = [],
|
|
186
186
|
schedule_date
|
|
187
187
|
}) {
|
|
188
|
-
|
|
188
|
+
const res = await this.store.products.loadProducts({
|
|
189
189
|
category_ids,
|
|
190
190
|
product_ids,
|
|
191
191
|
collection,
|
|
192
192
|
schedule_date,
|
|
193
193
|
cacheId: this.cacheId
|
|
194
194
|
});
|
|
195
|
+
this.getAvailableDate({
|
|
196
|
+
startDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
197
|
+
endDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
198
|
+
products: [...res]
|
|
199
|
+
});
|
|
200
|
+
return res;
|
|
195
201
|
}
|
|
196
202
|
/**
|
|
197
203
|
* 通过 schedule 来读取商品,适用于 session 类商品
|
|
@@ -228,11 +234,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
228
234
|
const allProductIds = [...newProductIds, ...otherProductsIds].filter(
|
|
229
235
|
(n, index, self) => self.indexOf(n) === index
|
|
230
236
|
);
|
|
231
|
-
|
|
237
|
+
const res = await this.loadProducts({
|
|
232
238
|
product_ids: allProductIds,
|
|
233
239
|
category_ids,
|
|
234
240
|
schedule_date: date
|
|
235
241
|
});
|
|
242
|
+
return res;
|
|
236
243
|
}
|
|
237
244
|
/**
|
|
238
245
|
* 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
@@ -599,6 +606,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
599
606
|
quantity = 1
|
|
600
607
|
} = product || {};
|
|
601
608
|
const productData = { ...origin, product_variant_id };
|
|
609
|
+
debugger;
|
|
610
|
+
if ((0, import_products.isSessionProduct)(productData)) {
|
|
611
|
+
if (!date || !date.startTime || !date.endTime) {
|
|
612
|
+
return { success: false, errorCode: "date_or_time_required" };
|
|
613
|
+
}
|
|
614
|
+
}
|
|
602
615
|
const currentCartItems = this.store.cart.getItems();
|
|
603
616
|
const stockCheckResult = (0, import_stock.checkProductStock)({
|
|
604
617
|
productData,
|
|
@@ -47,8 +47,9 @@ var formatDefaultCapacitys = ({
|
|
|
47
47
|
if ((capacity == null ? void 0 : capacity.type) === "package") {
|
|
48
48
|
return (product_bundle || []).map((d) => {
|
|
49
49
|
const id = d.bundle_product_id;
|
|
50
|
+
const variantId = d.bundle_variant_id;
|
|
50
51
|
const item = ((capacity == null ? void 0 : capacity.package) || []).find(
|
|
51
|
-
(item2) => item2.product_id === id
|
|
52
|
+
(item2) => item2.product_id === id || item2.product_id === variantId
|
|
52
53
|
);
|
|
53
54
|
return {
|
|
54
55
|
id,
|
|
@@ -9,3 +9,9 @@ export declare const getAvailableProductResources: (products: ProductData[]) =>
|
|
|
9
9
|
rules: any[];
|
|
10
10
|
resourcesMap: Record<number, ProductResourceItem>;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* 判断商品是否是 session 商品
|
|
14
|
+
* @param product 商品数据
|
|
15
|
+
* @returns 是否是 session 商品
|
|
16
|
+
*/
|
|
17
|
+
export declare const isSessionProduct: (product: ProductData) => boolean;
|
|
@@ -19,7 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/solution/BookingByStep/utils/products.ts
|
|
20
20
|
var products_exports = {};
|
|
21
21
|
__export(products_exports, {
|
|
22
|
-
getAvailableProductResources: () => getAvailableProductResources
|
|
22
|
+
getAvailableProductResources: () => getAvailableProductResources,
|
|
23
|
+
isSessionProduct: () => isSessionProduct
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(products_exports);
|
|
25
26
|
var getAvailableProductResources = (products) => {
|
|
@@ -57,7 +58,12 @@ var getAvailableProductResources = (products) => {
|
|
|
57
58
|
});
|
|
58
59
|
return { resourceIds: [...new Set(resourceIds)], rules, resourcesMap };
|
|
59
60
|
};
|
|
61
|
+
var isSessionProduct = (product) => {
|
|
62
|
+
var _a;
|
|
63
|
+
return (((_a = product == null ? void 0 : product["schedule.ids"]) == null ? void 0 : _a.length) ?? 0) > 0;
|
|
64
|
+
};
|
|
60
65
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
66
|
0 && (module.exports = {
|
|
62
|
-
getAvailableProductResources
|
|
67
|
+
getAvailableProductResources,
|
|
68
|
+
isSessionProduct
|
|
63
69
|
});
|
|
@@ -48,6 +48,7 @@ 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;
|
|
@@ -196,6 +196,16 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
196
196
|
throw error;
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
+
getHolderIdFromBooking(obj) {
|
|
200
|
+
var _a;
|
|
201
|
+
if (!obj)
|
|
202
|
+
return void 0;
|
|
203
|
+
let ret = obj.holder_id || ((_a = obj.holder) == null ? void 0 : _a.form_record);
|
|
204
|
+
if (Array.isArray(ret)) {
|
|
205
|
+
return ret.length > 0 ? Number(ret[0]) : void 0;
|
|
206
|
+
}
|
|
207
|
+
return Number(ret) || void 0;
|
|
208
|
+
}
|
|
199
209
|
getProductListByOrder() {
|
|
200
210
|
var _a, _b, _c, _d, _e;
|
|
201
211
|
if (!this.store.currentOrder) {
|
|
@@ -218,12 +228,22 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
218
228
|
tax_fee: item.tax_fee,
|
|
219
229
|
// 整个商品折扣后的总金额
|
|
220
230
|
selling_price: item.calculated_selling_price,
|
|
231
|
+
// 使用者id
|
|
232
|
+
holder_id: item.holder_id,
|
|
221
233
|
// 整个商品折扣前的总金额
|
|
222
234
|
original_price: item.calculated_original_price,
|
|
223
235
|
// 主商品折扣前金额,不包含套餐子商品
|
|
224
236
|
main_product_original_price: item.price,
|
|
225
237
|
// 主商品折扣后金额,不包含套餐子商品
|
|
226
238
|
main_product_selling_price: item.main_product_selling_price,
|
|
239
|
+
metadata: {
|
|
240
|
+
// 主商品+非原价(加减价)子商品税费
|
|
241
|
+
"main_product_attached_bundle_tax_fee": item.metadata.main_product_attached_bundle_tax_fee,
|
|
242
|
+
// 主商品+非原价(加减价)子商品附加费
|
|
243
|
+
"main_product_attached_bundle_surcharge_fee": item.metadata.main_product_attached_bundle_surcharge_fee,
|
|
244
|
+
// 可选,附加费均摊舍入金额
|
|
245
|
+
"surcharge_rounding_remainder": item.metadata.surcharge_rounding_remainder
|
|
246
|
+
},
|
|
227
247
|
product_bundle: item.product_bundle.map((bundle) => {
|
|
228
248
|
return {
|
|
229
249
|
bundle_id: bundle.bundle_id,
|
|
@@ -235,13 +255,30 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
235
255
|
bundle_sum_price: bundle.bundle_sum_price,
|
|
236
256
|
// 套餐子商品折扣后金额
|
|
237
257
|
bundle_selling_price: bundle.bundle_selling_price,
|
|
238
|
-
num: bundle.num
|
|
258
|
+
num: bundle.num,
|
|
259
|
+
is_charge_tax: bundle.is_charge_tax,
|
|
260
|
+
tax_fee: bundle.tax_fee,
|
|
261
|
+
metadata: {
|
|
262
|
+
// 子商品单数量附加费
|
|
263
|
+
"surcharge_fee": bundle.metadata.surcharge_fee,
|
|
264
|
+
// 可选,附加费均摊舍入金额
|
|
265
|
+
"surcharge_rounding_remainder": bundle.metadata.surcharge_rounding_remainder
|
|
266
|
+
}
|
|
239
267
|
};
|
|
240
268
|
})
|
|
241
269
|
})
|
|
242
270
|
) || [];
|
|
243
271
|
};
|
|
244
|
-
const productList = formatProduct(
|
|
272
|
+
const productList = formatProduct(
|
|
273
|
+
((_c = (_b = (_a = this.store.currentOrder.order_info) == null ? void 0 : _a.original_order_data) == null ? void 0 : _b.bookings) == null ? void 0 : _c.map(
|
|
274
|
+
(item) => {
|
|
275
|
+
return {
|
|
276
|
+
...item.product,
|
|
277
|
+
holder_id: this.getHolderIdFromBooking(item)
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
)) || []
|
|
281
|
+
);
|
|
245
282
|
const relationProducts = formatProduct(((_e = (_d = this.store.currentOrder.order_info) == null ? void 0 : _d.original_order_data) == null ? void 0 : _e.relation_products) || []);
|
|
246
283
|
return [...productList, ...relationProducts];
|
|
247
284
|
}
|
|
@@ -266,6 +303,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
266
303
|
isDeposit: (_e = this.store.currentOrder) == null ? void 0 : _e.is_deposit
|
|
267
304
|
},
|
|
268
305
|
products: this.getProductListByOrder(),
|
|
306
|
+
is_price_include_tax: this.otherParams.is_price_include_tax,
|
|
307
|
+
// core 有
|
|
269
308
|
...params
|
|
270
309
|
};
|
|
271
310
|
if (this.store.isOrderSynced) {
|
|
@@ -1988,7 +2027,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1988
2027
|
const depositPaidAmount = paymentItems.filter(
|
|
1989
2028
|
(item) => item.order_payment_type === "deposit" && item.status !== "voided"
|
|
1990
2029
|
).reduce((sum, item) => {
|
|
1991
|
-
if (item.voucher_id && !item.isSynced) {
|
|
2030
|
+
if (item.voucher_id && !item.isSynced && paymentItems.filter((item2) => !item2.voucher_id).length === 0) {
|
|
1992
2031
|
return sum;
|
|
1993
2032
|
}
|
|
1994
2033
|
const amount = new import_decimal.default(item.amount || "0");
|
package/lib/solution/index.d.ts
CHANGED
package/lib/solution/index.js
CHANGED
|
@@ -20,14 +20,14 @@ __reExport(solution_exports, require("./BuyTickets"), module.exports);
|
|
|
20
20
|
__reExport(solution_exports, require("./BookingByStep"), module.exports);
|
|
21
21
|
__reExport(solution_exports, require("./BookingTicket"), module.exports);
|
|
22
22
|
__reExport(solution_exports, require("./ShopDiscount"), module.exports);
|
|
23
|
-
__reExport(solution_exports, require("./Checkout"), module.exports);
|
|
24
23
|
__reExport(solution_exports, require("./RegisterAndLogin"), module.exports);
|
|
24
|
+
__reExport(solution_exports, require("./Checkout"), module.exports);
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
...require("./BuyTickets"),
|
|
28
28
|
...require("./BookingByStep"),
|
|
29
29
|
...require("./BookingTicket"),
|
|
30
30
|
...require("./ShopDiscount"),
|
|
31
|
-
...require("./
|
|
32
|
-
...require("./
|
|
31
|
+
...require("./RegisterAndLogin"),
|
|
32
|
+
...require("./Checkout")
|
|
33
33
|
});
|