@pisell/pisellos 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +7 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/OpenData/index.d.ts +2 -0
- package/dist/modules/OpenData/index.js +8 -0
- package/dist/modules/Order/index.d.ts +28 -8
- package/dist/modules/Order/index.js +818 -503
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/payment-utils.js +225 -0
- package/dist/modules/Order/types.d.ts +35 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
- package/dist/modules/Order/utils.js +10 -6
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +79 -50
- package/dist/modules/Payment/types.d.ts +107 -28
- package/dist/modules/Payment/types.js +20 -3
- package/dist/modules/Payment/walletpass.d.ts +38 -1
- package/dist/modules/Payment/walletpass.js +917 -114
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/Rules/index.d.ts +3 -0
- package/dist/modules/Rules/index.js +130 -99
- package/dist/server/index.d.ts +16 -0
- package/dist/server/index.js +2084 -1188
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +70 -4
- package/dist/server/modules/order/index.js +1816 -728
- package/dist/server/modules/order/types.d.ts +25 -3
- package/dist/server/modules/order/types.js +7 -1
- package/dist/solution/BaseSales/index.d.ts +111 -13
- package/dist/solution/BaseSales/index.js +1799 -446
- package/dist/solution/BaseSales/types.d.ts +55 -1
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +7 -3
- package/dist/solution/BookingTicket/index.js +138 -52
- package/dist/solution/BookingTicket/types.d.ts +1 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +10 -2
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.js +23 -3
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +34 -24
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/OpenData/index.d.ts +2 -0
- package/lib/modules/OpenData/index.js +5 -0
- package/lib/modules/Order/index.d.ts +28 -8
- package/lib/modules/Order/index.js +233 -68
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/payment-utils.js +224 -0
- package/lib/modules/Order/types.d.ts +35 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
- package/lib/modules/Order/utils.js +11 -4
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +34 -13
- package/lib/modules/Payment/types.d.ts +107 -28
- package/lib/modules/Payment/types.js +4 -3
- package/lib/modules/Payment/walletpass.d.ts +38 -1
- package/lib/modules/Payment/walletpass.js +730 -21
- package/lib/modules/ProductList/index.js +9 -1
- package/lib/modules/Rules/index.d.ts +3 -0
- package/lib/modules/Rules/index.js +39 -10
- package/lib/server/index.d.ts +16 -0
- package/lib/server/index.js +677 -28
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +70 -4
- package/lib/server/modules/order/index.js +818 -69
- package/lib/server/modules/order/types.d.ts +25 -3
- package/lib/server/modules/order/types.js +1 -0
- package/lib/solution/BaseSales/index.d.ts +111 -13
- package/lib/solution/BaseSales/index.js +882 -46
- package/lib/solution/BaseSales/types.d.ts +55 -1
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +7 -3
- package/lib/solution/BookingTicket/index.js +63 -9
- package/lib/solution/BookingTicket/types.d.ts +1 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +5 -3
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/UnifiedBookingSales/index.js +10 -2
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +13 -6
- package/lib/types/index.d.ts +1 -0
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/solution/BookingTicket/utils/weighingProductSku.ts
|
|
20
|
+
var weighingProductSku_exports = {};
|
|
21
|
+
__export(weighingProductSku_exports, {
|
|
22
|
+
buildProductSkuFromCacheItem: () => buildProductSkuFromCacheItem
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(weighingProductSku_exports);
|
|
25
|
+
var WEIGHT_UNIT_MAP = {
|
|
26
|
+
KILOGRAMS: "kg",
|
|
27
|
+
GRAMS: "g",
|
|
28
|
+
POUNDS: "lb",
|
|
29
|
+
OUNCES: "oz"
|
|
30
|
+
};
|
|
31
|
+
function isRecord(value) {
|
|
32
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
33
|
+
}
|
|
34
|
+
function buildProductSkuFromCacheItem(cacheItem) {
|
|
35
|
+
var _a, _b, _c, _d;
|
|
36
|
+
const currentSku = isRecord(cacheItem == null ? void 0 : cacheItem.product_sku) ? cacheItem.product_sku : void 0;
|
|
37
|
+
const weighing = isRecord((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.weighing) ? (_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.weighing : void 0;
|
|
38
|
+
const hasRuntimeWeighingSku = Number((currentSku == null ? void 0 : currentSku.open_sold_weight) || 0) === 1 && ((currentSku == null ? void 0 : currentSku.weight) !== void 0 || (currentSku == null ? void 0 : currentSku.net_weight) !== void 0 || (currentSku == null ? void 0 : currentSku.weight_source) !== void 0);
|
|
39
|
+
const isWeighingSku = Number((currentSku == null ? void 0 : currentSku.open_sold_weight) || 0) === 1;
|
|
40
|
+
if (!isWeighingSku && !weighing)
|
|
41
|
+
return void 0;
|
|
42
|
+
if (hasRuntimeWeighingSku)
|
|
43
|
+
return { ...currentSku };
|
|
44
|
+
if (!weighing)
|
|
45
|
+
return currentSku ? { ...currentSku } : void 0;
|
|
46
|
+
return {
|
|
47
|
+
...currentSku || {},
|
|
48
|
+
open_sold_weight: 1,
|
|
49
|
+
unit_data_snapshot: weighing.scalePriceProduct,
|
|
50
|
+
unit: WEIGHT_UNIT_MAP[String(weighing.unit)] || weighing.unit,
|
|
51
|
+
unit_weight: weighing.unit_weight ?? "1.000",
|
|
52
|
+
unit_price: weighing.unit_price,
|
|
53
|
+
weight_source: weighing.mode,
|
|
54
|
+
tare_name: ((_c = weighing.tare) == null ? void 0 : _c.label) ?? "",
|
|
55
|
+
tare_weight: ((_d = weighing.tare) == null ? void 0 : _d.value) ?? 0,
|
|
56
|
+
weight: weighing.weight ?? 0,
|
|
57
|
+
net_weight: weighing.net_weight ?? 0
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
buildProductSkuFromCacheItem
|
|
63
|
+
});
|
|
@@ -83,6 +83,7 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
83
83
|
private getBookingAppointmentStatus;
|
|
84
84
|
private isBookingIncludedInStats;
|
|
85
85
|
private getBookingOrderPaymentStatus;
|
|
86
|
+
private isUnpaidBooking;
|
|
86
87
|
private countBookingOrders;
|
|
87
88
|
private countCompletedBookings;
|
|
88
89
|
private groupBookingsByResource;
|
|
@@ -39,6 +39,7 @@ var import_dayjs = __toESM(require("dayjs"));
|
|
|
39
39
|
var import_BaseModule = require("../../modules/BaseModule");
|
|
40
40
|
var import_types = require("./types");
|
|
41
41
|
__reExport(Sales_exports, require("./types"), module.exports);
|
|
42
|
+
var UNPAID_PAYMENT_STATUSES = /* @__PURE__ */ new Set(["unpaid", "partially_paid", "payment_processing"]);
|
|
42
43
|
var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
43
44
|
// LoggerManager 实例
|
|
44
45
|
constructor(name, version) {
|
|
@@ -258,6 +259,9 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
258
259
|
var _a;
|
|
259
260
|
return String(((_a = booking.order) == null ? void 0 : _a.payment_status) ?? "");
|
|
260
261
|
}
|
|
262
|
+
isUnpaidBooking(booking) {
|
|
263
|
+
return UNPAID_PAYMENT_STATUSES.has(this.getBookingOrderPaymentStatus(booking));
|
|
264
|
+
}
|
|
261
265
|
countBookingOrders(bookings) {
|
|
262
266
|
const orderIds = /* @__PURE__ */ new Set();
|
|
263
267
|
bookings.forEach((booking) => {
|
|
@@ -631,9 +635,7 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
631
635
|
const completedBookingList = matchedBookingList.filter(
|
|
632
636
|
(booking) => this.getBookingAppointmentStatus(booking) === "completed"
|
|
633
637
|
);
|
|
634
|
-
const unpaidBookingList = matchedBookingList.filter(
|
|
635
|
-
(booking) => this.getBookingOrderPaymentStatus(booking) === "unpaid" || this.getBookingOrderPaymentStatus(booking) === "payment_processing"
|
|
636
|
-
);
|
|
638
|
+
const unpaidBookingList = matchedBookingList.filter((booking) => this.isUnpaidBooking(booking));
|
|
637
639
|
const bookings = this.pickBookingsForCurrentPoint(
|
|
638
640
|
current,
|
|
639
641
|
this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList)
|
|
@@ -47,6 +47,10 @@ var import_utils2 = require("../../modules/Order/utils");
|
|
|
47
47
|
var import_dayjs = __toESM(require("dayjs"));
|
|
48
48
|
var import_itemRule = require("../../model/strategy/adapter/itemRule");
|
|
49
49
|
__reExport(ScanOrder_exports, require("./types"), module.exports);
|
|
50
|
+
function isItemRewardProductDiscount(discount) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
53
|
+
}
|
|
50
54
|
var _ScanOrderImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
51
55
|
constructor(name, version) {
|
|
52
56
|
super(name, version);
|
|
@@ -699,6 +703,10 @@ var _ScanOrderImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
699
703
|
for (const product of tempOrder.products) {
|
|
700
704
|
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
701
705
|
continue;
|
|
706
|
+
if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
|
|
707
|
+
product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
702
710
|
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
703
711
|
var _a2;
|
|
704
712
|
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
@@ -517,8 +517,16 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
|
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
519
|
async getOpenData() {
|
|
520
|
-
var _a;
|
|
521
|
-
|
|
520
|
+
var _a, _b, _c;
|
|
521
|
+
const businessCode = String(((_a = this.otherParams) == null ? void 0 : _a.businessCode) || "").trim();
|
|
522
|
+
const channel = String(((_b = this.otherParams) == null ? void 0 : _b.channel) || "").trim();
|
|
523
|
+
if (!businessCode || !channel)
|
|
524
|
+
return null;
|
|
525
|
+
const target = `${businessCode}+${channel}`;
|
|
526
|
+
const cachedData = ((_c = this.store.openData) == null ? void 0 : _c.getOpenData()) || null;
|
|
527
|
+
if (cachedData && this.openDataTarget === target)
|
|
528
|
+
return cachedData;
|
|
529
|
+
return this.loadOpenData({ businessCode, channel });
|
|
522
530
|
}
|
|
523
531
|
/**
|
|
524
532
|
* Loads the product catalog used by both UI and Planner. Schedule data is requested with each
|
|
@@ -167,6 +167,7 @@ export declare class VenueBookingImpl extends BaseSalesImpl implements Module {
|
|
|
167
167
|
private recalculateOrderPricesFromQuotation;
|
|
168
168
|
scanCode(code: string, customerId?: number): Promise<{
|
|
169
169
|
isAvailable: boolean;
|
|
170
|
+
isAccepted?: boolean | undefined;
|
|
170
171
|
discountList: import("../../modules/Discount").Discount[];
|
|
171
172
|
type: "server" | "clientCalc";
|
|
172
173
|
unavailableReason?: import("../../modules/Rules/types").UnavailableReason | undefined;
|
|
@@ -67,6 +67,10 @@ var OPEN_DATA_SECTION_CODES = [
|
|
|
67
67
|
"workflow",
|
|
68
68
|
"checkout"
|
|
69
69
|
];
|
|
70
|
+
function isItemRewardProductDiscount(discount) {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
73
|
+
}
|
|
70
74
|
function cloneCustomDepositData(customDepositData) {
|
|
71
75
|
if (!customDepositData || typeof customDepositData !== "object")
|
|
72
76
|
return void 0;
|
|
@@ -1432,7 +1436,7 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1432
1436
|
}
|
|
1433
1437
|
/** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
|
|
1434
1438
|
async setDiscountSelected(params) {
|
|
1435
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1439
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1436
1440
|
this.logMethodStart("setDiscountSelected", params);
|
|
1437
1441
|
try {
|
|
1438
1442
|
if (!this.store.order)
|
|
@@ -1488,9 +1492,12 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1488
1492
|
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
1489
1493
|
);
|
|
1490
1494
|
for (const product of tempOrder.products) {
|
|
1491
|
-
|
|
1492
|
-
|
|
1495
|
+
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
1496
|
+
continue;
|
|
1497
|
+
if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
|
|
1498
|
+
product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
|
|
1493
1499
|
continue;
|
|
1500
|
+
}
|
|
1494
1501
|
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
1495
1502
|
var _a2;
|
|
1496
1503
|
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
@@ -1501,7 +1508,7 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1501
1508
|
0
|
|
1502
1509
|
);
|
|
1503
1510
|
const optionSum = (0, import_utils3.sumOptionUnitPrice)((0, import_utils3.getProductSkuOptions)(product));
|
|
1504
|
-
const sourcePrice = ((
|
|
1511
|
+
const sourcePrice = ((_d = product.metadata) == null ? void 0 : _d.source_product_price) ?? (((_e = product.metadata) == null ? void 0 : _e.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
|
|
1505
1512
|
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1506
1513
|
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1507
1514
|
if (product.metadata) {
|
|
@@ -1519,8 +1526,8 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1519
1526
|
const afterApplyTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1520
1527
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1521
1528
|
this.store.order.persistTempOrder();
|
|
1522
|
-
const finalSummary = ((
|
|
1523
|
-
const finalProduct = ((
|
|
1529
|
+
const finalSummary = ((_f = this.store.order.getTempOrder()) == null ? void 0 : _f.summary) || null;
|
|
1530
|
+
const finalProduct = ((_h = (_g = this.store.order.getTempOrder()) == null ? void 0 : _g.products) == null ? void 0 : _h[0]) || null;
|
|
1524
1531
|
this.logMethodSuccess("setDiscountSelected", params);
|
|
1525
1532
|
const finalTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1526
1533
|
return this.store.order.getDiscountList();
|
package/lib/types/index.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export interface PisellCore {
|
|
|
48
48
|
getModule: <T extends Module>(name: string) => T | null;
|
|
49
49
|
getModuleExports: <T = any>(name: string) => T | null;
|
|
50
50
|
hasModule: (name: string) => boolean;
|
|
51
|
+
getModuleNames: () => string[];
|
|
51
52
|
effects: {
|
|
52
53
|
on: (event: string, callback: (payload: any) => void) => () => void;
|
|
53
54
|
once: (event: string, callback: (payload: any) => void) => () => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PaymentNumberAppDataGetter = (key: string) => unknown;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the synchronous fallback without caching runtime device data.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData: PaymentNumberAppDataGetter): string;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the latest device segment when a new payment number is generated.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolvePaymentNumberDevicePrefix(getAppData: PaymentNumberAppDataGetter): Promise<string>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/payment-number.ts
|
|
20
|
+
var payment_number_exports = {};
|
|
21
|
+
__export(payment_number_exports, {
|
|
22
|
+
resolvePaymentNumberDevicePrefix: () => resolvePaymentNumberDevicePrefix,
|
|
23
|
+
resolvePaymentNumberDevicePrefixFromDeviceId: () => resolvePaymentNumberDevicePrefixFromDeviceId
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(payment_number_exports);
|
|
26
|
+
function normalizeNonEmptyString(value) {
|
|
27
|
+
if (value === void 0 || value === null)
|
|
28
|
+
return null;
|
|
29
|
+
if (typeof value !== "string" && typeof value !== "number")
|
|
30
|
+
return null;
|
|
31
|
+
if (typeof value === "number" && !Number.isFinite(value))
|
|
32
|
+
return null;
|
|
33
|
+
const normalized = String(value).trim();
|
|
34
|
+
return normalized || null;
|
|
35
|
+
}
|
|
36
|
+
function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData) {
|
|
37
|
+
try {
|
|
38
|
+
const deviceId = normalizeNonEmptyString(getAppData("device_id"));
|
|
39
|
+
if (deviceId && deviceId !== "0")
|
|
40
|
+
return deviceId.slice(-2);
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
return "LOCAL";
|
|
44
|
+
}
|
|
45
|
+
async function resolvePaymentNumberDevicePrefix(getAppData) {
|
|
46
|
+
try {
|
|
47
|
+
const getAsyncIotDeviceInfo = getAppData("async_iot_device_info");
|
|
48
|
+
if (typeof getAsyncIotDeviceInfo === "function") {
|
|
49
|
+
const info = await getAsyncIotDeviceInfo();
|
|
50
|
+
const shortNumber = normalizeNonEmptyString(
|
|
51
|
+
info == null ? void 0 : info.short_number
|
|
52
|
+
);
|
|
53
|
+
if (shortNumber && shortNumber !== "0")
|
|
54
|
+
return shortNumber;
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
return resolvePaymentNumberDevicePrefixFromDeviceId(getAppData);
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
resolvePaymentNumberDevicePrefix,
|
|
63
|
+
resolvePaymentNumberDevicePrefixFromDeviceId
|
|
64
|
+
});
|