@pisell/pisellos 2.2.193 → 2.2.194
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/Order/index.d.ts +2 -1
- package/dist/modules/Order/index.js +45 -13
- package/dist/modules/Order/utils/manualProductDiscount.js +1 -1
- package/dist/modules/SalesSummary/index.d.ts +0 -25
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +2 -25
- package/dist/modules/SalesSummary/utils.js +528 -159
- package/dist/server/index.js +2 -2
- package/dist/server/modules/products/index.js +4 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.d.ts +2 -1
- package/lib/modules/Order/index.js +30 -2
- package/lib/modules/Order/utils/manualProductDiscount.js +1 -1
- package/lib/modules/SalesSummary/index.d.ts +0 -25
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +2 -25
- package/lib/modules/SalesSummary/utils.js +419 -89
- package/lib/server/index.js +2 -2
- package/lib/server/modules/products/index.js +0 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -1647,14 +1647,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1647
1647
|
_context20.next = 3;
|
|
1648
1648
|
break;
|
|
1649
1649
|
}
|
|
1650
|
-
this.
|
|
1650
|
+
this.logInfo('setupProductsQuotationPriceBridge: Products 模块未注册');
|
|
1651
1651
|
return _context20.abrupt("return");
|
|
1652
1652
|
case 3:
|
|
1653
1653
|
if (this.schedule) {
|
|
1654
1654
|
_context20.next = 6;
|
|
1655
1655
|
break;
|
|
1656
1656
|
}
|
|
1657
|
-
this.
|
|
1657
|
+
this.logInfo('setupProductsQuotationPriceBridge: Schedule 模块未注册');
|
|
1658
1658
|
return _context20.abrupt("return");
|
|
1659
1659
|
case 6:
|
|
1660
1660
|
_context20.prev = 6;
|
|
@@ -2048,10 +2048,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2048
2048
|
this.productDataSource.run({
|
|
2049
2049
|
pubsub: {
|
|
2050
2050
|
callback: function callback(res) {
|
|
2051
|
-
console.log('sse_products_callback', res)
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
});
|
|
2051
|
+
// console.log('sse_products_callback', res)
|
|
2052
|
+
// this.logInfo('sse_products_callback: 收到同步消息', {
|
|
2053
|
+
// data: res?.data,
|
|
2054
|
+
// });
|
|
2055
2055
|
if (!(res !== null && res !== void 0 && res.data)) return;
|
|
2056
2056
|
var data = res.data;
|
|
2057
2057
|
var channelKey = data.module || 'product';
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -279,7 +279,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
279
279
|
* 获取当前的客户搜索条件
|
|
280
280
|
* @returns 当前搜索条件
|
|
281
281
|
*/
|
|
282
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
282
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
283
283
|
/**
|
|
284
284
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
285
285
|
* @returns 客户状态
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
-
var promotion_exports = {};
|
|
31
|
-
__export(promotion_exports, {
|
|
32
|
-
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
-
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
-
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
-
default: () => import_adapter2.default
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
-
var import_evaluator = require("./evaluator");
|
|
40
|
-
var import_adapter = require("./adapter");
|
|
41
|
-
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
-
var import_examples = require("./examples");
|
|
43
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
-
PromotionAdapter,
|
|
47
|
-
PromotionEvaluator,
|
|
48
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
-
});
|
|
@@ -141,6 +141,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
141
141
|
private calculatePaymentTotal;
|
|
142
142
|
private normalizePaymentSource;
|
|
143
143
|
private updateTempOrderPaymentStatus;
|
|
144
|
+
private shouldKeepPaymentStatusAfterAmountRecalc;
|
|
144
145
|
private resolveWalletPassUseValue;
|
|
145
146
|
private capVoucherPaymentsByRemainingAmount;
|
|
146
147
|
private calculatePaidPaymentSummary;
|
|
@@ -264,7 +265,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
264
265
|
private logSubmitBackendRejected;
|
|
265
266
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
266
267
|
createOrder(params: CommitOrderParams['query']): {
|
|
267
|
-
type: "
|
|
268
|
+
type: "appointment_booking" | "virtual";
|
|
268
269
|
platform: string;
|
|
269
270
|
sales_channel: string;
|
|
270
271
|
order_sales_channel: string;
|
|
@@ -45,6 +45,21 @@ var import_Rules = require("../Rules");
|
|
|
45
45
|
var import_types2 = require("../Rules/types");
|
|
46
46
|
var import_decimal = __toESM(require("decimal.js"));
|
|
47
47
|
var import_lodash_es = require("lodash-es");
|
|
48
|
+
function normalizeDiscountListSignature(discountList) {
|
|
49
|
+
return (discountList || []).map((item) => ({
|
|
50
|
+
type: (item == null ? void 0 : item.type) ?? "",
|
|
51
|
+
discount_id: (item == null ? void 0 : item.discount_id) ?? null,
|
|
52
|
+
order_discount_id: (item == null ? void 0 : item.order_discount_id) ?? null,
|
|
53
|
+
amount: new import_decimal.default(Number(item == null ? void 0 : item.amount) || 0).toFixed(2)
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
function isSameDiscountList(left, right) {
|
|
57
|
+
if (!Array.isArray(left) || !Array.isArray(right))
|
|
58
|
+
return false;
|
|
59
|
+
return JSON.stringify(normalizeDiscountListSignature(left)) === JSON.stringify(
|
|
60
|
+
normalizeDiscountListSignature(right)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
48
63
|
var OrderModule = class extends import_BaseModule.BaseModule {
|
|
49
64
|
constructor(name, version) {
|
|
50
65
|
super(name || "order", version);
|
|
@@ -107,6 +122,11 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
107
122
|
var _a, _b, _c;
|
|
108
123
|
if ((_a = product.metadata) == null ? void 0 : _a.is_manual_discount)
|
|
109
124
|
return product;
|
|
125
|
+
const discountItems = Array.isArray(product.discount_list) ? product.discount_list : [];
|
|
126
|
+
const hasOnlyPersistedDiscountSnapshots = product.order_detail_id !== void 0 && product.order_detail_id !== null && discountItems.length > 0 && discountItems.every((discount) => (discount == null ? void 0 : discount.order_discount_id) !== void 0 && (discount == null ? void 0 : discount.order_discount_id) !== null);
|
|
127
|
+
if (hasOnlyPersistedDiscountSnapshots) {
|
|
128
|
+
return product;
|
|
129
|
+
}
|
|
110
130
|
const totalPerUnitDiscount = (0, import_utils.resolveEffectivePerUnitDiscount)(product);
|
|
111
131
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
|
|
112
132
|
const sourcePrice = ((_b = product.metadata) == null ? void 0 : _b.source_product_price) ?? (((_c = product.metadata) == null ? void 0 : _c.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");
|
|
@@ -618,6 +638,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
618
638
|
return normalized;
|
|
619
639
|
}
|
|
620
640
|
updateTempOrderPaymentStatus(tempOrder) {
|
|
641
|
+
if (this.shouldKeepPaymentStatusAfterAmountRecalc(tempOrder.payment_status)) {
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
621
644
|
const paymentTotal = this.calculatePaymentTotal(tempOrder.payments || []);
|
|
622
645
|
const targetAmount = this.getPaymentTargetAmount();
|
|
623
646
|
if (targetAmount.lte(0)) {
|
|
@@ -630,6 +653,10 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
630
653
|
}
|
|
631
654
|
tempOrder.payment_status = paymentTotal.gte(targetAmount) ? "paid" : "partially_paid";
|
|
632
655
|
}
|
|
656
|
+
shouldKeepPaymentStatusAfterAmountRecalc(paymentStatus) {
|
|
657
|
+
const normalizedStatus = String(paymentStatus || "").trim().toLowerCase();
|
|
658
|
+
return normalizedStatus === "refunded" || normalizedStatus === "partially_refunded";
|
|
659
|
+
}
|
|
633
660
|
resolveWalletPassUseValue(payment, amount) {
|
|
634
661
|
const usageUnit = payment.wallet_pass_usage_unit && typeof payment.wallet_pass_usage_unit === "object" ? payment.wallet_pass_usage_unit : null;
|
|
635
662
|
if (!usageUnit)
|
|
@@ -1603,7 +1630,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1603
1630
|
const callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, "selling_price") || Object.prototype.hasOwnProperty.call(updates || {}, "original_price");
|
|
1604
1631
|
const callerUpdatesMainMeta = ((_c = updates == null ? void 0 : updates.metadata) == null ? void 0 : _c.main_product_selling_price) !== void 0 || ((_d = updates == null ? void 0 : updates.metadata) == null ? void 0 : _d.main_product_original_price) !== void 0 || ((_e = updates == null ? void 0 : updates.metadata) == null ? void 0 : _e.source_product_price) !== void 0;
|
|
1605
1632
|
const isPersistedOrderLine = targetProduct.order_detail_id !== void 0 && targetProduct.order_detail_id !== null;
|
|
1606
|
-
const
|
|
1633
|
+
const callerChangesDiscountList = Array.isArray(updates == null ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
|
|
1634
|
+
const callerUpdatesManualPrice = ((_f = updates == null ? void 0 : updates.metadata) == null ? void 0 : _f.price_override) !== void 0 || ((_g = updates == null ? void 0 : updates.metadata) == null ? void 0 : _g.is_manual_discount) !== void 0 || ((_h = updates == null ? void 0 : updates.metadata) == null ? void 0 : _h.product_discount_reason) !== void 0 || callerChangesDiscountList;
|
|
1607
1635
|
if (isPersistedOrderLine && !callerUpdatesManualPrice) {
|
|
1608
1636
|
nextProduct.selling_price = targetProduct.selling_price;
|
|
1609
1637
|
nextProduct.original_price = targetProduct.original_price;
|
|
@@ -1613,7 +1641,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1613
1641
|
source_product_price: (_i = targetProduct.metadata) == null ? void 0 : _i.source_product_price,
|
|
1614
1642
|
main_product_selling_price: (_j = targetProduct.metadata) == null ? void 0 : _j.main_product_selling_price,
|
|
1615
1643
|
main_product_original_price: (_k = targetProduct.metadata) == null ? void 0 : _k.main_product_original_price,
|
|
1616
|
-
price_schema_version: (_l = targetProduct.metadata) == null ? void 0 : _l.price_schema_version
|
|
1644
|
+
price_schema_version: ((_l = targetProduct.metadata) == null ? void 0 : _l.price_schema_version) ?? 2
|
|
1617
1645
|
};
|
|
1618
1646
|
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
1619
1647
|
const existedMeta = nextProduct.metadata || {};
|
|
@@ -167,7 +167,7 @@ function buildManualProductDiscountItem(params) {
|
|
|
167
167
|
const diff = origin.minus(selling);
|
|
168
168
|
const quantity = resolveSafeProductNum(params.quantity);
|
|
169
169
|
return {
|
|
170
|
-
amount: diff.
|
|
170
|
+
amount: diff.toDecimalPlaces(2).toNumber(),
|
|
171
171
|
type: "product",
|
|
172
172
|
discount: {
|
|
173
173
|
message: params.message ?? "",
|
|
@@ -43,30 +43,5 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
43
43
|
rounding_amount: string;
|
|
44
44
|
pay_service_charge_amount: string;
|
|
45
45
|
is_price_include_tax?: number | undefined;
|
|
46
|
-
} | {
|
|
47
|
-
tax_title: string;
|
|
48
|
-
tax_rate: number | undefined;
|
|
49
|
-
product_quantity: number;
|
|
50
|
-
product_original_amount: string;
|
|
51
|
-
product_amount: string;
|
|
52
|
-
product_expect_amount: string;
|
|
53
|
-
product_tax_fee: string;
|
|
54
|
-
shipping_fee: string;
|
|
55
|
-
shipping_tax_fee: string;
|
|
56
|
-
tax_fee: string;
|
|
57
|
-
surcharge_fee: string;
|
|
58
|
-
surcharges: any;
|
|
59
|
-
discount_amount: string;
|
|
60
|
-
deposit_amount: string;
|
|
61
|
-
deposit: import("./types").DepositInfo | undefined;
|
|
62
|
-
expect_amount: string;
|
|
63
|
-
total_amount: string;
|
|
64
|
-
total_refund_amount: string;
|
|
65
|
-
customer_paid_amount: string;
|
|
66
|
-
order_paid_amount: string;
|
|
67
|
-
amount_gap: string;
|
|
68
|
-
rounding_amount: string;
|
|
69
|
-
pay_service_charge_amount: string;
|
|
70
|
-
is_price_include_tax: number;
|
|
71
46
|
}>;
|
|
72
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SalesSummaryData, SalesSummaryProduct } from './types';
|
|
2
2
|
export declare function createEmptySalesSummary(): SalesSummaryData;
|
|
3
3
|
export declare function calculateSalesSummary(params: {
|
|
4
4
|
products: SalesSummaryProduct[];
|
|
@@ -8,27 +8,4 @@ export declare function calculateSalesSummary(params: {
|
|
|
8
8
|
scheduleById?: Record<string, any>;
|
|
9
9
|
isInScheduleByDate?: any;
|
|
10
10
|
shopDiscount?: string | number;
|
|
11
|
-
}): SalesSummaryData
|
|
12
|
-
product_quantity: number;
|
|
13
|
-
product_original_amount: string;
|
|
14
|
-
product_amount: string;
|
|
15
|
-
product_expect_amount: string;
|
|
16
|
-
product_tax_fee: string;
|
|
17
|
-
shipping_fee: string;
|
|
18
|
-
shipping_tax_fee: string;
|
|
19
|
-
tax_fee: string;
|
|
20
|
-
surcharge_fee: string;
|
|
21
|
-
surcharges: any;
|
|
22
|
-
discount_amount: string;
|
|
23
|
-
deposit_amount: string;
|
|
24
|
-
deposit: DepositInfo | undefined;
|
|
25
|
-
expect_amount: string;
|
|
26
|
-
total_amount: string;
|
|
27
|
-
total_refund_amount: string;
|
|
28
|
-
customer_paid_amount: string;
|
|
29
|
-
order_paid_amount: string;
|
|
30
|
-
amount_gap: string;
|
|
31
|
-
rounding_amount: string;
|
|
32
|
-
pay_service_charge_amount: string;
|
|
33
|
-
is_price_include_tax: number;
|
|
34
|
-
};
|
|
11
|
+
}): SalesSummaryData;
|