@pisell/pisellos 2.3.96 → 2.3.97
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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/server/utils/small-ticket.d.ts +9 -1
- package/dist/server/utils/small-ticket.js +120 -46
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/server/utils/small-ticket.d.ts +9 -1
- package/lib/server/utils/small-ticket.js +111 -39
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// 导出评估器
|
|
2
|
-
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
-
|
|
4
|
-
// 导出适配器
|
|
5
|
-
export { PromotionAdapter } from "./adapter";
|
|
6
|
-
export { default } from "./adapter";
|
|
7
|
-
|
|
8
|
-
// 导出策略配置示例常量
|
|
9
|
-
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -35,6 +35,8 @@ export interface SmallTicketProduct {
|
|
|
35
35
|
original_price: string;
|
|
36
36
|
total_original_price: string;
|
|
37
37
|
extension_list: any[];
|
|
38
|
+
product_uid?: string | number;
|
|
39
|
+
booking_uid?: string | number;
|
|
38
40
|
options?: Array<{
|
|
39
41
|
name: string;
|
|
40
42
|
num?: number;
|
|
@@ -44,6 +46,11 @@ export interface SmallTicketProduct {
|
|
|
44
46
|
variant?: string;
|
|
45
47
|
combinations?: any[];
|
|
46
48
|
}
|
|
49
|
+
export interface SmallTicketBookingSnapshot extends Record<string, any> {
|
|
50
|
+
product_uid?: string | number;
|
|
51
|
+
booking_uid?: string | number;
|
|
52
|
+
}
|
|
53
|
+
export type SmallTicketAppointment = SmallTicketItem[] | SmallTicketBookingSnapshot[];
|
|
47
54
|
export interface SmallTicketLocaleData {
|
|
48
55
|
base_data: Record<string, any>;
|
|
49
56
|
products: SmallTicketProduct[];
|
|
@@ -52,7 +59,7 @@ export interface SmallTicketLocaleData {
|
|
|
52
59
|
countFee: Record<string, any>;
|
|
53
60
|
};
|
|
54
61
|
customer: SmallTicketItem[];
|
|
55
|
-
appointment:
|
|
62
|
+
appointment: SmallTicketAppointment;
|
|
56
63
|
delivery?: SmallTicketItem[];
|
|
57
64
|
resources: Array<{
|
|
58
65
|
id: string | number;
|
|
@@ -61,6 +68,7 @@ export interface SmallTicketLocaleData {
|
|
|
61
68
|
form_title: string;
|
|
62
69
|
}>;
|
|
63
70
|
payment_data: SmallTicketItem[][];
|
|
71
|
+
wallets: SmallTicketItem[][];
|
|
64
72
|
tickets: any[];
|
|
65
73
|
source_shop: any[];
|
|
66
74
|
refund_data: any[];
|
|
@@ -150,6 +150,11 @@ function buildLocaleData(params) {
|
|
|
150
150
|
locale: locale,
|
|
151
151
|
currencySymbol: currencySymbol
|
|
152
152
|
}),
|
|
153
|
+
wallets: buildWallets({
|
|
154
|
+
order: order,
|
|
155
|
+
locale: locale,
|
|
156
|
+
currencySymbol: currencySymbol
|
|
157
|
+
}),
|
|
153
158
|
tickets: Array.isArray(order.tickets) ? order.tickets : [],
|
|
154
159
|
source_shop: [],
|
|
155
160
|
refund_data: [],
|
|
@@ -162,7 +167,7 @@ function buildBaseData(params) {
|
|
|
162
167
|
shopInfo = params.shopInfo,
|
|
163
168
|
locale = params.locale;
|
|
164
169
|
var orderNumber = stringify(order.buzzer || order.shop_full_order_number);
|
|
165
|
-
return {
|
|
170
|
+
return _objectSpread({
|
|
166
171
|
shop_name: stringify(shopInfo.name || order.shop_name),
|
|
167
172
|
note: stringify(order.note),
|
|
168
173
|
shop_order_number: stringify(order.shop_order_number),
|
|
@@ -175,12 +180,14 @@ function buildBaseData(params) {
|
|
|
175
180
|
buzzer: stringify(order.buzzer || order.pickup_number || ((_order$metadata = order.metadata) === null || _order$metadata === void 0 ? void 0 : _order$metadata.buzzer)),
|
|
176
181
|
order_no: orderNumber,
|
|
177
182
|
order_time: formatDateTime(order.created_at || order.sales_time || new Date(), locale)
|
|
178
|
-
}
|
|
183
|
+
}, isPresentId(order.updated_at) ? {
|
|
184
|
+
updated_at: formatDateTime(order.updated_at, locale)
|
|
185
|
+
} : {});
|
|
179
186
|
}
|
|
180
187
|
function buildProducts(order, locale, productMap) {
|
|
181
188
|
var products = Array.isArray(order.products) ? order.products : [];
|
|
182
189
|
return products.map(function (product) {
|
|
183
|
-
var _ref, _ref2, _product$product_quan, _ref3, _ref4, _ref5, _product$original_pri, _ref6, _ref7, _product$selling_pric, _product$product_id;
|
|
190
|
+
var _ref, _ref2, _product$product_quan, _ref3, _ref4, _ref5, _product$original_pri, _ref6, _ref7, _product$selling_pric, _product$product_id, _product$metadata, _product$metadata2;
|
|
184
191
|
var quantity = toNumber((_ref = (_ref2 = (_product$product_quan = product.product_quantity) !== null && _product$product_quan !== void 0 ? _product$product_quan : product.quantity) !== null && _ref2 !== void 0 ? _ref2 : product.num) !== null && _ref !== void 0 ? _ref : 1, 1);
|
|
185
192
|
var originalPrice = (_ref3 = (_ref4 = (_ref5 = (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product.selling_price) !== null && _ref5 !== void 0 ? _ref5 : product.payment_price) !== null && _ref4 !== void 0 ? _ref4 : product.price) !== null && _ref3 !== void 0 ? _ref3 : 0;
|
|
186
193
|
var sellingPrice = (_ref6 = (_ref7 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.payment_price) !== null && _ref7 !== void 0 ? _ref7 : product.price) !== null && _ref6 !== void 0 ? _ref6 : originalPrice;
|
|
@@ -209,6 +216,8 @@ function buildProducts(order, locale, productMap) {
|
|
|
209
216
|
parentProduct: parentProduct,
|
|
210
217
|
locale: locale
|
|
211
218
|
});
|
|
219
|
+
var productUid = firstPresentValue((_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number, product.unique_identification_number);
|
|
220
|
+
var bookingUid = firstPresentValue(product.booking_uid, (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.booking_uid);
|
|
212
221
|
var extensionList = buildProductExtensionList({
|
|
213
222
|
product: product,
|
|
214
223
|
locale: locale,
|
|
@@ -216,14 +225,18 @@ function buildProducts(order, locale, productMap) {
|
|
|
216
225
|
quantity: quantity,
|
|
217
226
|
originalPrice: originalPrice
|
|
218
227
|
});
|
|
219
|
-
return _objectSpread(_objectSpread(_objectSpread({
|
|
228
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
220
229
|
product_title: productTitle,
|
|
221
230
|
product_quantity: quantity,
|
|
222
231
|
selling_price: formatMoney(sellingPrice, currencySymbol),
|
|
223
232
|
original_price: formatMoney(originalPrice, currencySymbol),
|
|
224
233
|
total_original_price: formatMoney(new Decimal(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
|
|
225
234
|
extension_list: extensionList
|
|
226
|
-
},
|
|
235
|
+
}, isPresentId(productUid) ? {
|
|
236
|
+
product_uid: productUid
|
|
237
|
+
} : {}), isPresentId(bookingUid) ? {
|
|
238
|
+
booking_uid: bookingUid
|
|
239
|
+
} : {}), options.length ? {
|
|
227
240
|
options: options
|
|
228
241
|
} : {}), resolvedVariant ? {
|
|
229
242
|
variant: resolvedVariant
|
|
@@ -604,6 +617,14 @@ function isNonZeroId(value) {
|
|
|
604
617
|
function isPresentId(value) {
|
|
605
618
|
return value !== undefined && value !== null && value !== '';
|
|
606
619
|
}
|
|
620
|
+
function firstPresentValue() {
|
|
621
|
+
for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
622
|
+
values[_key] = arguments[_key];
|
|
623
|
+
}
|
|
624
|
+
return values.find(function (value) {
|
|
625
|
+
return isPresentId(value);
|
|
626
|
+
});
|
|
627
|
+
}
|
|
607
628
|
function isSameId(left, right) {
|
|
608
629
|
if (!isPresentId(left) || !isPresentId(right)) return false;
|
|
609
630
|
return String(left) === String(right);
|
|
@@ -628,7 +649,7 @@ function formatBundlePrice(bundle, currencySymbol) {
|
|
|
628
649
|
return formatMoney(amount, currencySymbol);
|
|
629
650
|
}
|
|
630
651
|
function buildFees(params) {
|
|
631
|
-
var _ref36, _order$shop_discount,
|
|
652
|
+
var _ref36, _order$shop_discount, _firstPresentValue;
|
|
632
653
|
var order = params.order,
|
|
633
654
|
shopInfo = params.shopInfo,
|
|
634
655
|
locale = params.locale,
|
|
@@ -675,12 +696,13 @@ function buildFees(params) {
|
|
|
675
696
|
});
|
|
676
697
|
}
|
|
677
698
|
var productExpectAmount = summary.product_expect_amount || summary.product_amount || order.product_expect_amount;
|
|
678
|
-
var productOriginalAmount = (
|
|
699
|
+
var productOriginalAmount = (_firstPresentValue = firstPresentValue(summary.product_original_amount, order.product_original_amount)) !== null && _firstPresentValue !== void 0 ? _firstPresentValue : calculateProductOriginalAmount(order);
|
|
679
700
|
var totalSavingsAmount = new Decimal(toMoneyNumber(productOriginalAmount)).minus(toMoneyNumber(productExpectAmount)).plus(toMoneyNumber(discountAmount));
|
|
680
701
|
return {
|
|
681
702
|
fees: fees,
|
|
682
703
|
countFee: _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
683
704
|
total_amount: formatMoney(summary.total_amount || order.total_amount, currencySymbol),
|
|
705
|
+
original_item_amount: formatMoney(productOriginalAmount, currencySymbol),
|
|
684
706
|
product_expect_amount: formatMoney(productExpectAmount, currencySymbol),
|
|
685
707
|
expect_amount: formatMoney(summary.expect_amount || order.expect_amount || summary.total_amount || order.total_amount, currencySymbol),
|
|
686
708
|
product_quantity: toNumber(summary.product_quantity || products.reduce(function (sum, product) {
|
|
@@ -701,6 +723,14 @@ function buildFees(params) {
|
|
|
701
723
|
} : {})
|
|
702
724
|
};
|
|
703
725
|
}
|
|
726
|
+
function calculateProductOriginalAmount(order) {
|
|
727
|
+
return normalizeArray(order.products).reduce(function (total, product) {
|
|
728
|
+
var _ref37, _ref38, _product$product_quan2, _ref39, _ref40, _ref41, _product$original_pri2;
|
|
729
|
+
var quantity = toNumber((_ref37 = (_ref38 = (_product$product_quan2 = product.product_quantity) !== null && _product$product_quan2 !== void 0 ? _product$product_quan2 : product.quantity) !== null && _ref38 !== void 0 ? _ref38 : product.num) !== null && _ref37 !== void 0 ? _ref37 : 1, 1);
|
|
730
|
+
var originalPrice = (_ref39 = (_ref40 = (_ref41 = (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : product.selling_price) !== null && _ref41 !== void 0 ? _ref41 : product.payment_price) !== null && _ref40 !== void 0 ? _ref40 : product.price) !== null && _ref39 !== void 0 ? _ref39 : 0;
|
|
731
|
+
return total.plus(new Decimal(toMoneyNumber(originalPrice)).mul(quantity));
|
|
732
|
+
}, new Decimal(0));
|
|
733
|
+
}
|
|
704
734
|
function buildCustomer(order, locale) {
|
|
705
735
|
var _order$customer, _order$customer2, _order$customer3, _order$customer4;
|
|
706
736
|
return [{
|
|
@@ -741,6 +771,22 @@ function buildDelivery(order, locale) {
|
|
|
741
771
|
}
|
|
742
772
|
function buildAppointment(order, locale) {
|
|
743
773
|
var _order$metadata3, _order$metadata4, _order$form_data;
|
|
774
|
+
var bookings = normalizeArray(order.bookings);
|
|
775
|
+
if (bookings.length) {
|
|
776
|
+
return bookings.map(function (booking) {
|
|
777
|
+
var _booking$metadata, _booking$metadata2;
|
|
778
|
+
var snapshot = _objectSpread({}, booking);
|
|
779
|
+
delete snapshot.product_uid;
|
|
780
|
+
delete snapshot.booking_uid;
|
|
781
|
+
var productUid = firstPresentValue(booking.product_uid, (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.product_uid);
|
|
782
|
+
var bookingUid = firstPresentValue((_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.unique_identification_number, booking.booking_uid);
|
|
783
|
+
return _objectSpread(_objectSpread(_objectSpread({}, snapshot), isPresentId(productUid) ? {
|
|
784
|
+
product_uid: productUid
|
|
785
|
+
} : {}), isPresentId(bookingUid) ? {
|
|
786
|
+
booking_uid: bookingUid
|
|
787
|
+
} : {});
|
|
788
|
+
});
|
|
789
|
+
}
|
|
744
790
|
var tableName = order.table_name || ((_order$metadata3 = order.metadata) === null || _order$metadata3 === void 0 ? void 0 : _order$metadata3.table_name) || ((_order$metadata4 = order.metadata) === null || _order$metadata4 === void 0 || (_order$metadata4 = _order$metadata4.table) === null || _order$metadata4 === void 0 ? void 0 : _order$metadata4.name) || ((_order$form_data = order.form_data) === null || _order$form_data === void 0 ? void 0 : _order$form_data.table_name);
|
|
745
791
|
if (!tableName) return [];
|
|
746
792
|
return [{
|
|
@@ -763,41 +809,66 @@ function buildPaymentData(params) {
|
|
|
763
809
|
return payments.filter(function (payment) {
|
|
764
810
|
return isPrintablePayment(payment);
|
|
765
811
|
}).map(function (payment) {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
812
|
+
return buildPaymentItems({
|
|
813
|
+
payment: payment,
|
|
814
|
+
locale: params.locale,
|
|
815
|
+
currencySymbol: params.currencySymbol,
|
|
816
|
+
includeFundRecordBalance: false
|
|
817
|
+
});
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
function buildWallets(params) {
|
|
821
|
+
return normalizeArray(params.order.payments).filter(function (payment) {
|
|
822
|
+
return isPrintablePayment(payment) && !!getFundRecord(payment);
|
|
823
|
+
}).map(function (payment) {
|
|
824
|
+
return buildPaymentItems({
|
|
825
|
+
payment: payment,
|
|
826
|
+
locale: params.locale,
|
|
827
|
+
currencySymbol: params.currencySymbol,
|
|
828
|
+
includeFundRecordBalance: true
|
|
829
|
+
});
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
function buildPaymentItems(params) {
|
|
833
|
+
var payment = params.payment,
|
|
834
|
+
locale = params.locale,
|
|
835
|
+
currencySymbol = params.currencySymbol,
|
|
836
|
+
includeFundRecordBalance = params.includeFundRecordBalance;
|
|
837
|
+
var serviceFee = getPaymentServiceFee(payment);
|
|
838
|
+
var items = [{
|
|
839
|
+
item: paymentMethodName(payment, locale),
|
|
840
|
+
value: formatMoney(resolveReceiptPaymentAmount(payment, serviceFee), currencySymbol)
|
|
841
|
+
}];
|
|
842
|
+
if (serviceFee.gt(0)) {
|
|
843
|
+
items.push({
|
|
844
|
+
item: label(locale, 'surchargeIncluded'),
|
|
845
|
+
value: formatMoney(serviceFee, currencySymbol)
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
var fundRecord = getFundRecord(payment);
|
|
849
|
+
if (fundRecord) {
|
|
850
|
+
items.push.apply(items, _toConsumableArray(buildFundRecordPaymentItems({
|
|
851
|
+
payment: payment,
|
|
852
|
+
fundRecord: fundRecord,
|
|
853
|
+
locale: locale,
|
|
854
|
+
currencySymbol: currencySymbol,
|
|
855
|
+
includeBalance: includeFundRecordBalance
|
|
856
|
+
})));
|
|
857
|
+
} else {
|
|
858
|
+
var _ref42, _payment$remaining_am, _payment$metadata;
|
|
859
|
+
var remainingAmount = (_ref42 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref42 !== void 0 ? _ref42 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
|
|
860
|
+
if (remainingAmount !== undefined && remainingAmount !== null) {
|
|
772
861
|
items.push({
|
|
773
|
-
item: label(
|
|
774
|
-
value: formatMoney(
|
|
862
|
+
item: label(locale, 'remainingAmount'),
|
|
863
|
+
value: formatMoney(remainingAmount, currencySymbol)
|
|
775
864
|
});
|
|
776
865
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
fundRecord: fundRecord,
|
|
782
|
-
locale: params.locale,
|
|
783
|
-
currencySymbol: params.currencySymbol
|
|
784
|
-
})));
|
|
785
|
-
} else {
|
|
786
|
-
var _ref38, _payment$remaining_am, _payment$metadata;
|
|
787
|
-
var remainingAmount = (_ref38 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref38 !== void 0 ? _ref38 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
|
|
788
|
-
if (remainingAmount !== undefined && remainingAmount !== null) {
|
|
789
|
-
items.push({
|
|
790
|
-
item: label(params.locale, 'remainingAmount'),
|
|
791
|
-
value: formatMoney(remainingAmount, params.currencySymbol)
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
items.push({
|
|
796
|
-
item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || new Date(), params.locale),
|
|
797
|
-
value: ''
|
|
798
|
-
});
|
|
799
|
-
return items;
|
|
866
|
+
}
|
|
867
|
+
items.push({
|
|
868
|
+
item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || new Date(), locale),
|
|
869
|
+
value: ''
|
|
800
870
|
});
|
|
871
|
+
return items;
|
|
801
872
|
}
|
|
802
873
|
function getPaymentServiceFee(payment) {
|
|
803
874
|
return new Decimal(toMoneyNumber(payment.service_fee));
|
|
@@ -815,7 +886,8 @@ function buildFundRecordPaymentItems(params) {
|
|
|
815
886
|
var payment = params.payment,
|
|
816
887
|
fundRecord = params.fundRecord,
|
|
817
888
|
locale = params.locale,
|
|
818
|
-
currencySymbol = params.currencySymbol
|
|
889
|
+
currencySymbol = params.currencySymbol,
|
|
890
|
+
includeBalance = params.includeBalance;
|
|
819
891
|
var items = [];
|
|
820
892
|
var usingBeforeValue = fundRecord.using_before_value;
|
|
821
893
|
var usingAfterValue = fundRecord.using_after_value;
|
|
@@ -825,13 +897,15 @@ function buildFundRecordPaymentItems(params) {
|
|
|
825
897
|
item: label(locale, 'redeemPoints'),
|
|
826
898
|
value: trimDecimal(usedPoints)
|
|
827
899
|
});
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
900
|
+
if (includeBalance) {
|
|
901
|
+
items.push({
|
|
902
|
+
item: label(locale, 'remainingPoints'),
|
|
903
|
+
value: trimDecimal(new Decimal(toMoneyNumber(usingAfterValue)))
|
|
904
|
+
});
|
|
905
|
+
}
|
|
832
906
|
return items;
|
|
833
907
|
}
|
|
834
|
-
if (usingAfterValue !== undefined && usingAfterValue !== null) {
|
|
908
|
+
if (includeBalance && usingAfterValue !== undefined && usingAfterValue !== null) {
|
|
835
909
|
items.push({
|
|
836
910
|
item: label(locale, 'remainingAmount'),
|
|
837
911
|
value: formatMoney(usingAfterValue, currencySymbol)
|
|
@@ -904,12 +978,12 @@ function label(locale, key) {
|
|
|
904
978
|
return ((_LABELS$locale = LABELS[locale]) === null || _LABELS$locale === void 0 ? void 0 : _LABELS$locale[key]) || LABELS.en[key] || key;
|
|
905
979
|
}
|
|
906
980
|
function getLocalizedValue(value, locale) {
|
|
907
|
-
var
|
|
981
|
+
var _ref43, _ref44, _ref45, _ref46, _ref47, _ref48, _value$locale2;
|
|
908
982
|
if (value === undefined || value === null) return '';
|
|
909
983
|
if (_typeof(value) !== 'object') return stringify(value);
|
|
910
984
|
var dashedLocale = locale.replace('_', '-');
|
|
911
985
|
var underscoredLocale = locale.replace('-', '_');
|
|
912
|
-
return stringify((
|
|
986
|
+
return stringify((_ref43 = (_ref44 = (_ref45 = (_ref46 = (_ref47 = (_ref48 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref48 !== void 0 ? _ref48 : value[underscoredLocale]) !== null && _ref47 !== void 0 ? _ref47 : value.original) !== null && _ref46 !== void 0 ? _ref46 : value.auto) !== null && _ref45 !== void 0 ? _ref45 : value.default) !== null && _ref44 !== void 0 ? _ref44 : value.en) !== null && _ref43 !== void 0 ? _ref43 : '');
|
|
913
987
|
}
|
|
914
988
|
function serviceTypeToLabelKey(serviceType) {
|
|
915
989
|
var normalized = serviceType.toLowerCase();
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 |
|
|
329
|
+
weekNum: 0 | 5 | 3 | 1 | 2 | 4 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -345,7 +345,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
345
345
|
count: number;
|
|
346
346
|
left: number;
|
|
347
347
|
summaryCount: number;
|
|
348
|
-
status: "
|
|
348
|
+
status: "sold_out" | "lots_of_space" | "filling_up_fast";
|
|
349
349
|
}[];
|
|
350
350
|
/**
|
|
351
351
|
* 找到多个资源的公共可用时间段
|
|
@@ -1 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _adapter.PromotionAdapter;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _evaluator.PromotionEvaluator;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "default", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _adapter.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var _evaluator = require("./evaluator");
|
|
43
|
+
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
+
var _examples = require("./examples");
|
|
45
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -35,6 +35,8 @@ export interface SmallTicketProduct {
|
|
|
35
35
|
original_price: string;
|
|
36
36
|
total_original_price: string;
|
|
37
37
|
extension_list: any[];
|
|
38
|
+
product_uid?: string | number;
|
|
39
|
+
booking_uid?: string | number;
|
|
38
40
|
options?: Array<{
|
|
39
41
|
name: string;
|
|
40
42
|
num?: number;
|
|
@@ -44,6 +46,11 @@ export interface SmallTicketProduct {
|
|
|
44
46
|
variant?: string;
|
|
45
47
|
combinations?: any[];
|
|
46
48
|
}
|
|
49
|
+
export interface SmallTicketBookingSnapshot extends Record<string, any> {
|
|
50
|
+
product_uid?: string | number;
|
|
51
|
+
booking_uid?: string | number;
|
|
52
|
+
}
|
|
53
|
+
export type SmallTicketAppointment = SmallTicketItem[] | SmallTicketBookingSnapshot[];
|
|
47
54
|
export interface SmallTicketLocaleData {
|
|
48
55
|
base_data: Record<string, any>;
|
|
49
56
|
products: SmallTicketProduct[];
|
|
@@ -52,7 +59,7 @@ export interface SmallTicketLocaleData {
|
|
|
52
59
|
countFee: Record<string, any>;
|
|
53
60
|
};
|
|
54
61
|
customer: SmallTicketItem[];
|
|
55
|
-
appointment:
|
|
62
|
+
appointment: SmallTicketAppointment;
|
|
56
63
|
delivery?: SmallTicketItem[];
|
|
57
64
|
resources: Array<{
|
|
58
65
|
id: string | number;
|
|
@@ -61,6 +68,7 @@ export interface SmallTicketLocaleData {
|
|
|
61
68
|
form_title: string;
|
|
62
69
|
}>;
|
|
63
70
|
payment_data: SmallTicketItem[][];
|
|
71
|
+
wallets: SmallTicketItem[][];
|
|
64
72
|
tickets: any[];
|
|
65
73
|
source_shop: any[];
|
|
66
74
|
refund_data: any[];
|
|
@@ -144,6 +144,11 @@ function buildLocaleData(params) {
|
|
|
144
144
|
locale,
|
|
145
145
|
currencySymbol
|
|
146
146
|
}),
|
|
147
|
+
wallets: buildWallets({
|
|
148
|
+
order,
|
|
149
|
+
locale,
|
|
150
|
+
currencySymbol
|
|
151
|
+
}),
|
|
147
152
|
tickets: Array.isArray(order.tickets) ? order.tickets : [],
|
|
148
153
|
source_shop: [],
|
|
149
154
|
refund_data: [],
|
|
@@ -169,7 +174,10 @@ function buildBaseData(params) {
|
|
|
169
174
|
is_repeat: 0,
|
|
170
175
|
buzzer: stringify(order.buzzer || order.pickup_number || order.metadata?.buzzer),
|
|
171
176
|
order_no: orderNumber,
|
|
172
|
-
order_time: formatDateTime(order.created_at || order.sales_time || new Date(), locale)
|
|
177
|
+
order_time: formatDateTime(order.created_at || order.sales_time || new Date(), locale),
|
|
178
|
+
...(isPresentId(order.updated_at) ? {
|
|
179
|
+
updated_at: formatDateTime(order.updated_at, locale)
|
|
180
|
+
} : {})
|
|
173
181
|
};
|
|
174
182
|
}
|
|
175
183
|
function buildProducts(order, locale, productMap) {
|
|
@@ -203,6 +211,8 @@ function buildProducts(order, locale, productMap) {
|
|
|
203
211
|
parentProduct,
|
|
204
212
|
locale
|
|
205
213
|
});
|
|
214
|
+
const productUid = firstPresentValue(product.metadata?.unique_identification_number, product.unique_identification_number);
|
|
215
|
+
const bookingUid = firstPresentValue(product.booking_uid, product.metadata?.booking_uid);
|
|
206
216
|
const extensionList = buildProductExtensionList({
|
|
207
217
|
product,
|
|
208
218
|
locale,
|
|
@@ -217,6 +227,12 @@ function buildProducts(order, locale, productMap) {
|
|
|
217
227
|
original_price: formatMoney(originalPrice, currencySymbol),
|
|
218
228
|
total_original_price: formatMoney(new _decimal.default(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
|
|
219
229
|
extension_list: extensionList,
|
|
230
|
+
...(isPresentId(productUid) ? {
|
|
231
|
+
product_uid: productUid
|
|
232
|
+
} : {}),
|
|
233
|
+
...(isPresentId(bookingUid) ? {
|
|
234
|
+
booking_uid: bookingUid
|
|
235
|
+
} : {}),
|
|
220
236
|
...(options.length ? {
|
|
221
237
|
options
|
|
222
238
|
} : {}),
|
|
@@ -582,6 +598,9 @@ function isNonZeroId(value) {
|
|
|
582
598
|
function isPresentId(value) {
|
|
583
599
|
return value !== undefined && value !== null && value !== '';
|
|
584
600
|
}
|
|
601
|
+
function firstPresentValue(...values) {
|
|
602
|
+
return values.find(value => isPresentId(value));
|
|
603
|
+
}
|
|
585
604
|
function isSameId(left, right) {
|
|
586
605
|
if (!isPresentId(left) || !isPresentId(right)) return false;
|
|
587
606
|
return String(left) === String(right);
|
|
@@ -650,12 +669,13 @@ function buildFees(params) {
|
|
|
650
669
|
});
|
|
651
670
|
}
|
|
652
671
|
const productExpectAmount = summary.product_expect_amount || summary.product_amount || order.product_expect_amount;
|
|
653
|
-
const productOriginalAmount = summary.product_original_amount
|
|
672
|
+
const productOriginalAmount = firstPresentValue(summary.product_original_amount, order.product_original_amount) ?? calculateProductOriginalAmount(order);
|
|
654
673
|
const totalSavingsAmount = new _decimal.default(toMoneyNumber(productOriginalAmount)).minus(toMoneyNumber(productExpectAmount)).plus(toMoneyNumber(discountAmount));
|
|
655
674
|
return {
|
|
656
675
|
fees,
|
|
657
676
|
countFee: {
|
|
658
677
|
total_amount: formatMoney(summary.total_amount || order.total_amount, currencySymbol),
|
|
678
|
+
original_item_amount: formatMoney(productOriginalAmount, currencySymbol),
|
|
659
679
|
product_expect_amount: formatMoney(productExpectAmount, currencySymbol),
|
|
660
680
|
expect_amount: formatMoney(summary.expect_amount || order.expect_amount || summary.total_amount || order.total_amount, currencySymbol),
|
|
661
681
|
product_quantity: toNumber(summary.product_quantity || products.reduce((sum, product) => sum + product.product_quantity, 0), 0),
|
|
@@ -678,6 +698,13 @@ function buildFees(params) {
|
|
|
678
698
|
}
|
|
679
699
|
};
|
|
680
700
|
}
|
|
701
|
+
function calculateProductOriginalAmount(order) {
|
|
702
|
+
return normalizeArray(order.products).reduce((total, product) => {
|
|
703
|
+
const quantity = toNumber(product.product_quantity ?? product.quantity ?? product.num ?? 1, 1);
|
|
704
|
+
const originalPrice = product.original_price ?? product.selling_price ?? product.payment_price ?? product.price ?? 0;
|
|
705
|
+
return total.plus(new _decimal.default(toMoneyNumber(originalPrice)).mul(quantity));
|
|
706
|
+
}, new _decimal.default(0));
|
|
707
|
+
}
|
|
681
708
|
function buildCustomer(order, locale) {
|
|
682
709
|
return [{
|
|
683
710
|
item: label(locale, 'contactName'),
|
|
@@ -715,6 +742,27 @@ function buildDelivery(order, locale) {
|
|
|
715
742
|
return items;
|
|
716
743
|
}
|
|
717
744
|
function buildAppointment(order, locale) {
|
|
745
|
+
const bookings = normalizeArray(order.bookings);
|
|
746
|
+
if (bookings.length) {
|
|
747
|
+
return bookings.map(booking => {
|
|
748
|
+
const snapshot = {
|
|
749
|
+
...booking
|
|
750
|
+
};
|
|
751
|
+
delete snapshot.product_uid;
|
|
752
|
+
delete snapshot.booking_uid;
|
|
753
|
+
const productUid = firstPresentValue(booking.product_uid, booking.metadata?.product_uid);
|
|
754
|
+
const bookingUid = firstPresentValue(booking.metadata?.unique_identification_number, booking.booking_uid);
|
|
755
|
+
return {
|
|
756
|
+
...snapshot,
|
|
757
|
+
...(isPresentId(productUid) ? {
|
|
758
|
+
product_uid: productUid
|
|
759
|
+
} : {}),
|
|
760
|
+
...(isPresentId(bookingUid) ? {
|
|
761
|
+
booking_uid: bookingUid
|
|
762
|
+
} : {})
|
|
763
|
+
};
|
|
764
|
+
});
|
|
765
|
+
}
|
|
718
766
|
const tableName = order.table_name || order.metadata?.table_name || order.metadata?.table?.name || order.form_data?.table_name;
|
|
719
767
|
if (!tableName) return [];
|
|
720
768
|
return [{
|
|
@@ -732,41 +780,62 @@ function buildResources(order, locale) {
|
|
|
732
780
|
}
|
|
733
781
|
function buildPaymentData(params) {
|
|
734
782
|
const payments = normalizeArray(params.order.payments);
|
|
735
|
-
return payments.filter(payment => isPrintablePayment(payment)).map(payment => {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
783
|
+
return payments.filter(payment => isPrintablePayment(payment)).map(payment => buildPaymentItems({
|
|
784
|
+
payment,
|
|
785
|
+
locale: params.locale,
|
|
786
|
+
currencySymbol: params.currencySymbol,
|
|
787
|
+
includeFundRecordBalance: false
|
|
788
|
+
}));
|
|
789
|
+
}
|
|
790
|
+
function buildWallets(params) {
|
|
791
|
+
return normalizeArray(params.order.payments).filter(payment => isPrintablePayment(payment) && !!getFundRecord(payment)).map(payment => buildPaymentItems({
|
|
792
|
+
payment,
|
|
793
|
+
locale: params.locale,
|
|
794
|
+
currencySymbol: params.currencySymbol,
|
|
795
|
+
includeFundRecordBalance: true
|
|
796
|
+
}));
|
|
797
|
+
}
|
|
798
|
+
function buildPaymentItems(params) {
|
|
799
|
+
const {
|
|
800
|
+
payment,
|
|
801
|
+
locale,
|
|
802
|
+
currencySymbol,
|
|
803
|
+
includeFundRecordBalance
|
|
804
|
+
} = params;
|
|
805
|
+
const serviceFee = getPaymentServiceFee(payment);
|
|
806
|
+
const items = [{
|
|
807
|
+
item: paymentMethodName(payment, locale),
|
|
808
|
+
value: formatMoney(resolveReceiptPaymentAmount(payment, serviceFee), currencySymbol)
|
|
809
|
+
}];
|
|
810
|
+
if (serviceFee.gt(0)) {
|
|
811
|
+
items.push({
|
|
812
|
+
item: label(locale, 'surchargeIncluded'),
|
|
813
|
+
value: formatMoney(serviceFee, currencySymbol)
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
const fundRecord = getFundRecord(payment);
|
|
817
|
+
if (fundRecord) {
|
|
818
|
+
items.push(...buildFundRecordPaymentItems({
|
|
819
|
+
payment,
|
|
820
|
+
fundRecord,
|
|
821
|
+
locale,
|
|
822
|
+
currencySymbol,
|
|
823
|
+
includeBalance: includeFundRecordBalance
|
|
824
|
+
}));
|
|
825
|
+
} else {
|
|
826
|
+
const remainingAmount = payment.remaining_amount ?? payment.balance ?? payment.metadata?.remaining_amount;
|
|
827
|
+
if (remainingAmount !== undefined && remainingAmount !== null) {
|
|
742
828
|
items.push({
|
|
743
|
-
item: label(
|
|
744
|
-
value: formatMoney(
|
|
829
|
+
item: label(locale, 'remainingAmount'),
|
|
830
|
+
value: formatMoney(remainingAmount, currencySymbol)
|
|
745
831
|
});
|
|
746
832
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
fundRecord,
|
|
752
|
-
locale: params.locale,
|
|
753
|
-
currencySymbol: params.currencySymbol
|
|
754
|
-
}));
|
|
755
|
-
} else {
|
|
756
|
-
const remainingAmount = payment.remaining_amount ?? payment.balance ?? payment.metadata?.remaining_amount;
|
|
757
|
-
if (remainingAmount !== undefined && remainingAmount !== null) {
|
|
758
|
-
items.push({
|
|
759
|
-
item: label(params.locale, 'remainingAmount'),
|
|
760
|
-
value: formatMoney(remainingAmount, params.currencySymbol)
|
|
761
|
-
});
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
items.push({
|
|
765
|
-
item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || new Date(), params.locale),
|
|
766
|
-
value: ''
|
|
767
|
-
});
|
|
768
|
-
return items;
|
|
833
|
+
}
|
|
834
|
+
items.push({
|
|
835
|
+
item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || new Date(), locale),
|
|
836
|
+
value: ''
|
|
769
837
|
});
|
|
838
|
+
return items;
|
|
770
839
|
}
|
|
771
840
|
function getPaymentServiceFee(payment) {
|
|
772
841
|
return new _decimal.default(toMoneyNumber(payment.service_fee));
|
|
@@ -784,7 +853,8 @@ function buildFundRecordPaymentItems(params) {
|
|
|
784
853
|
payment,
|
|
785
854
|
fundRecord,
|
|
786
855
|
locale,
|
|
787
|
-
currencySymbol
|
|
856
|
+
currencySymbol,
|
|
857
|
+
includeBalance
|
|
788
858
|
} = params;
|
|
789
859
|
const items = [];
|
|
790
860
|
const usingBeforeValue = fundRecord.using_before_value;
|
|
@@ -795,13 +865,15 @@ function buildFundRecordPaymentItems(params) {
|
|
|
795
865
|
item: label(locale, 'redeemPoints'),
|
|
796
866
|
value: trimDecimal(usedPoints)
|
|
797
867
|
});
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
868
|
+
if (includeBalance) {
|
|
869
|
+
items.push({
|
|
870
|
+
item: label(locale, 'remainingPoints'),
|
|
871
|
+
value: trimDecimal(new _decimal.default(toMoneyNumber(usingAfterValue)))
|
|
872
|
+
});
|
|
873
|
+
}
|
|
802
874
|
return items;
|
|
803
875
|
}
|
|
804
|
-
if (usingAfterValue !== undefined && usingAfterValue !== null) {
|
|
876
|
+
if (includeBalance && usingAfterValue !== undefined && usingAfterValue !== null) {
|
|
805
877
|
items.push({
|
|
806
878
|
item: label(locale, 'remainingAmount'),
|
|
807
879
|
value: formatMoney(usingAfterValue, currencySymbol)
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 |
|
|
329
|
+
weekNum: 0 | 5 | 3 | 1 | 2 | 4 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -345,7 +345,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
345
345
|
count: number;
|
|
346
346
|
left: number;
|
|
347
347
|
summaryCount: number;
|
|
348
|
-
status: "
|
|
348
|
+
status: "sold_out" | "lots_of_space" | "filling_up_fast";
|
|
349
349
|
}[];
|
|
350
350
|
/**
|
|
351
351
|
* 找到多个资源的公共可用时间段
|