@pisell/pisellos 2.2.9 → 2.2.10
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/Cart/utils/cartProduct.js +41 -26
- package/dist/modules/Customer/index.js +1 -1
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +69 -36
- package/dist/modules/Discount/types.d.ts +16 -0
- package/dist/modules/Order/index.js +4 -1
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +9 -0
- package/dist/modules/Payment/index.js +2 -2
- 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 +8 -9
- package/dist/modules/Rules/index.d.ts +7 -0
- package/dist/modules/Rules/index.js +1065 -196
- package/dist/modules/Rules/types.d.ts +4 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +30 -8
- package/dist/solution/BookingByStep/utils/products.d.ts +6 -0
- package/dist/solution/BookingByStep/utils/products.js +10 -0
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.js +61 -17
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +80 -19
- package/dist/solution/ShopDiscount/types.d.ts +4 -1
- package/dist/solution/ShopDiscount/utils.d.ts +55 -0
- package/dist/solution/ShopDiscount/utils.js +432 -3
- package/lib/modules/Cart/utils/cartProduct.js +35 -22
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +19 -4
- package/lib/modules/Discount/types.d.ts +16 -0
- package/lib/modules/Order/index.js +2 -0
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +11 -0
- package/lib/modules/Payment/index.js +1 -1
- package/lib/modules/Payment/types.d.ts +1 -0
- package/lib/modules/Payment/walletpass.js +10 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +0 -7
- package/lib/modules/Rules/index.d.ts +7 -0
- package/lib/modules/Rules/index.js +824 -182
- package/lib/modules/Rules/types.d.ts +4 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +19 -2
- package/lib/solution/BookingByStep/utils/products.d.ts +6 -0
- package/lib/solution/BookingByStep/utils/products.js +8 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.js +66 -17
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +55 -9
- package/lib/solution/ShopDiscount/types.d.ts +4 -1
- package/lib/solution/ShopDiscount/utils.d.ts +55 -0
- package/lib/solution/ShopDiscount/utils.js +266 -3
- package/package.json +2 -2
|
@@ -44,6 +44,7 @@ type ProductDetail = {
|
|
|
44
44
|
quantity: number;
|
|
45
45
|
vouchersApplicable?: boolean;
|
|
46
46
|
holder_id?: number;
|
|
47
|
+
startDate?: any;
|
|
47
48
|
};
|
|
48
49
|
export interface RulesParamsHooks {
|
|
49
50
|
getProduct: (product: Record<string, any>) => ProductDetail;
|
|
@@ -54,8 +55,10 @@ export interface RulesParamsHooks {
|
|
|
54
55
|
origin_total?: number;
|
|
55
56
|
price?: string | number;
|
|
56
57
|
variant?: any[];
|
|
57
|
-
original_price?: number;
|
|
58
|
+
original_price?: number | string;
|
|
58
59
|
quantity?: number;
|
|
60
|
+
bundle?: any[];
|
|
61
|
+
main_product_selling_price?: string | number;
|
|
59
62
|
}) => Record<string, any>;
|
|
60
63
|
}
|
|
61
64
|
export {};
|
|
@@ -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<"normal" | "duration" | "session">;
|
|
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();
|
|
@@ -2292,6 +2313,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2292
2313
|
}
|
|
2293
2314
|
});
|
|
2294
2315
|
});
|
|
2316
|
+
this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateBookingDate"), {});
|
|
2295
2317
|
}
|
|
2296
2318
|
}, {
|
|
2297
2319
|
key: "getScheduleDataByIds",
|
|
@@ -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
|
};
|
|
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
123
123
|
* 获取当前的客户搜索条件
|
|
124
124
|
* @returns 当前搜索条件
|
|
125
125
|
*/
|
|
126
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
126
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
127
127
|
/**
|
|
128
128
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
129
129
|
* @returns 客户状态
|
|
@@ -396,23 +396,66 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
396
396
|
return pre + (item.amount || 0);
|
|
397
397
|
}, 0);
|
|
398
398
|
};
|
|
399
|
-
var
|
|
400
|
-
return {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
399
|
+
var formatProduct = function formatProduct(items) {
|
|
400
|
+
return items.map(function (item) {
|
|
401
|
+
var _item$is_charge_tax;
|
|
402
|
+
return {
|
|
403
|
+
product_id: item.product_id,
|
|
404
|
+
product_variant_id: item.product_variant_id,
|
|
405
|
+
quantity: item.num,
|
|
406
|
+
// 商品是否含税:1;0
|
|
407
|
+
is_charge_tax: (_item$is_charge_tax = item.is_charge_tax) !== null && _item$is_charge_tax !== void 0 ? _item$is_charge_tax : 0,
|
|
408
|
+
// 若商品不含税,计算得到的税费,单位(元)
|
|
409
|
+
tax_fee: item.tax_fee,
|
|
410
|
+
// 整个商品折扣后的总金额
|
|
411
|
+
selling_price: item.calculated_selling_price,
|
|
412
|
+
// 使用者id
|
|
413
|
+
holder_id: item.holder_id,
|
|
414
|
+
// 整个商品折扣前的总金额
|
|
415
|
+
original_price: item.calculated_original_price,
|
|
416
|
+
// 主商品折扣前金额,不包含套餐子商品
|
|
417
|
+
main_product_original_price: item.price,
|
|
418
|
+
// 主商品折扣后金额,不包含套餐子商品
|
|
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
|
+
},
|
|
428
|
+
product_bundle: item.product_bundle.map(function (bundle) {
|
|
429
|
+
return {
|
|
430
|
+
bundle_id: bundle.bundle_id,
|
|
431
|
+
bundle_product_id: bundle.bundle_product_id,
|
|
432
|
+
bundle_variant_id: bundle.bundle_variant_id,
|
|
433
|
+
price_type: bundle.price_type,
|
|
434
|
+
price_type_ext: bundle.price_type_ext,
|
|
435
|
+
// 套餐子商品总价,不包含折扣金额
|
|
436
|
+
bundle_sum_price: bundle.bundle_sum_price,
|
|
437
|
+
// 套餐子商品折扣后金额
|
|
438
|
+
bundle_selling_price: bundle.bundle_selling_price,
|
|
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
|
+
}
|
|
448
|
+
};
|
|
449
|
+
})
|
|
450
|
+
};
|
|
451
|
+
}) || [];
|
|
452
|
+
};
|
|
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) {
|
|
454
|
+
return _objectSpread(_objectSpread({}, item.product), {}, {
|
|
405
455
|
holder_id: _this3.getHolderIdFromBooking(item)
|
|
406
|
-
};
|
|
407
|
-
})) || [];
|
|
408
|
-
var relationProducts = ((_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
|
|
409
|
-
return {
|
|
410
|
-
product_id: item.product_id,
|
|
411
|
-
product_variant_id: item.product_variant_id,
|
|
412
|
-
quantity: item.num,
|
|
413
|
-
selling_price: item.source_product_price
|
|
414
|
-
};
|
|
415
|
-
})) || [];
|
|
456
|
+
});
|
|
457
|
+
})) || []);
|
|
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) || []);
|
|
416
459
|
return [].concat(_toConsumableArray(productList), _toConsumableArray(relationProducts));
|
|
417
460
|
}
|
|
418
461
|
}, {
|
|
@@ -447,7 +490,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
447
490
|
depositAmount: (_this$store$currentOr5 = this.store.currentOrder) === null || _this$store$currentOr5 === void 0 ? void 0 : _this$store$currentOr5.deposit_amount,
|
|
448
491
|
isDeposit: (_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.is_deposit
|
|
449
492
|
},
|
|
450
|
-
products: this.getProductListByOrder()
|
|
493
|
+
products: this.getProductListByOrder(),
|
|
494
|
+
is_price_include_tax: this.otherParams.is_price_include_tax
|
|
451
495
|
}, params); // 判断订单是否已经同步,如果是则追加payment_order_id参数
|
|
452
496
|
if (this.store.isOrderSynced) {
|
|
453
497
|
walletBusinessData.payment_order_id = (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.order_id;
|
|
@@ -18,6 +18,8 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
18
18
|
private initializePlugins;
|
|
19
19
|
private registerDependentModules;
|
|
20
20
|
private registerEventListeners;
|
|
21
|
+
getCurrentBookingTime(): string | null;
|
|
22
|
+
private filterDiscountListByBookingTime;
|
|
21
23
|
setCustomer(customer: Customer): Promise<void>;
|
|
22
24
|
setHolders(holders: {
|
|
23
25
|
form_record_id: number;
|
|
@@ -27,6 +27,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
27
27
|
import { BaseModule } from "../../modules/BaseModule";
|
|
28
28
|
import { DiscountModule } from "../../modules/Discount";
|
|
29
29
|
import { RulesModule } from "../../modules/Rules";
|
|
30
|
+
import { filterDiscountListByBookingTime as _filterDiscountListByBookingTime, isAllNormalProduct } from "./utils";
|
|
30
31
|
import Decimal from 'decimal.js';
|
|
31
32
|
import { isBoolean } from 'lodash-es';
|
|
32
33
|
export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
@@ -51,6 +52,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
51
52
|
discount: null,
|
|
52
53
|
rules: null,
|
|
53
54
|
originalDiscountList: [],
|
|
55
|
+
currentBookingTime: "",
|
|
56
|
+
filteredDiscountList: [],
|
|
54
57
|
holders: []
|
|
55
58
|
};
|
|
56
59
|
return _this;
|
|
@@ -208,6 +211,55 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
208
211
|
|
|
209
212
|
// =========== 公共 API ===========
|
|
210
213
|
|
|
214
|
+
// 设置预约时间
|
|
215
|
+
// public async setBookingTime(bookingTime: string | null): Promise<void> {
|
|
216
|
+
// if (this.store.currentBookingTime !== bookingTime) {
|
|
217
|
+
// this.store.currentBookingTime = bookingTime;
|
|
218
|
+
//
|
|
219
|
+
// // 更新过滤后的优惠券列表
|
|
220
|
+
// await this.updateFilteredDiscountList();
|
|
221
|
+
// }
|
|
222
|
+
// }
|
|
223
|
+
|
|
224
|
+
// 获取当前预约时间
|
|
225
|
+
}, {
|
|
226
|
+
key: "getCurrentBookingTime",
|
|
227
|
+
value: function getCurrentBookingTime() {
|
|
228
|
+
return this.store.currentBookingTime;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// 根据预约时间过滤优惠券列表
|
|
232
|
+
}, {
|
|
233
|
+
key: "filterDiscountListByBookingTime",
|
|
234
|
+
value: function filterDiscountListByBookingTime(discountList, bookingTime) {
|
|
235
|
+
// 如果全部是普通商品,不需要过滤,直接返回当前数据
|
|
236
|
+
if (isAllNormalProduct(this.store.productList || [])) {
|
|
237
|
+
return discountList;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// 否则使用 bookingTime 进行过滤
|
|
241
|
+
return _filterDiscountListByBookingTime(discountList, bookingTime);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// 更新过滤后的优惠券列表
|
|
245
|
+
// private async updateFilteredDiscountList(): Promise<void> {
|
|
246
|
+
// const originalList = this.store.originalDiscountList;
|
|
247
|
+
// const filteredList = this.filterDiscountListByBookingTime(originalList, this.store.currentBookingTime);
|
|
248
|
+
//
|
|
249
|
+
// this.store.filteredDiscountList = filteredList;
|
|
250
|
+
//
|
|
251
|
+
// // 更新 DiscountModule 中的优惠券列表
|
|
252
|
+
// this.setDiscountList(filteredList);
|
|
253
|
+
//
|
|
254
|
+
// if (this.store.productList?.length) {
|
|
255
|
+
// const result = this.calcDiscount(this.store.productList);
|
|
256
|
+
// await this.core.effects.emit(
|
|
257
|
+
// ShopDiscountHooks.onLoadPrepareCalcResult,
|
|
258
|
+
// result,
|
|
259
|
+
// );
|
|
260
|
+
// }
|
|
261
|
+
// }
|
|
262
|
+
|
|
211
263
|
// 设置客户
|
|
212
264
|
}, {
|
|
213
265
|
key: "setCustomer",
|
|
@@ -507,7 +559,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
507
559
|
if (index !== -1) {
|
|
508
560
|
editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
|
|
509
561
|
amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
510
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.num) || 1).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
562
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
511
563
|
});
|
|
512
564
|
} else {
|
|
513
565
|
var _discount$discount2, _discount$discount3, _discount$discount4;
|
|
@@ -518,7 +570,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
518
570
|
name: discount.name || discount.discount.title.auto,
|
|
519
571
|
isEditMode: true,
|
|
520
572
|
limited_relation_product_data: {},
|
|
521
|
-
savedAmount: discount.amount * ((product === null || product === void 0 ? void 0 : product.num) || 1),
|
|
573
|
+
savedAmount: discount.amount * ((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1),
|
|
522
574
|
isAvailable: true,
|
|
523
575
|
id: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) || discount.id,
|
|
524
576
|
format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
|
|
@@ -539,17 +591,20 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
539
591
|
var targetProduct = productList.find(function (n) {
|
|
540
592
|
return n.id === id;
|
|
541
593
|
});
|
|
594
|
+
if (!targetProduct) return false;
|
|
542
595
|
var product = (_this3$hooks2 = _this3.hooks) === null || _this3$hooks2 === void 0 ? void 0 : _this3$hooks2.getProduct(targetProduct);
|
|
543
596
|
// 如果 product.total 是小于等于0有可能是她已经用过商品券或者折扣卡导致的,或者本身就是负数价格,所以此时还需要判断 origin_total 是否小于等于0
|
|
544
597
|
// 如果 product.vouchersApplicable是布尔值,并且是 false,也当做免费商品处理,此商品不可用优惠券或折扣卡
|
|
545
598
|
return Number(product === null || product === void 0 ? void 0 : product.total) <= 0 && (Number(product === null || product === void 0 ? void 0 : product.origin_total) <= 0 || !(product !== null && product !== void 0 && product.origin_total)) || isBoolean(product === null || product === void 0 ? void 0 : product.vouchersApplicable) && !(product !== null && product !== void 0 && product.vouchersApplicable);
|
|
546
599
|
};
|
|
547
|
-
var allUsedProductIds = newDiscountList.
|
|
600
|
+
var allUsedProductIds = newDiscountList.filter(function (item) {
|
|
601
|
+
return !(item !== null && item !== void 0 && item.isEditMode);
|
|
602
|
+
}).map(function (n) {
|
|
548
603
|
var _n$appliedProductDeta;
|
|
549
|
-
return n.isSelected ? (_n$appliedProductDeta = n.appliedProductDetails) === null || _n$appliedProductDeta === void 0 ? void 0 : _n$appliedProductDeta.map(function (n) {
|
|
604
|
+
return n.isSelected ? ((_n$appliedProductDeta = n.appliedProductDetails) === null || _n$appliedProductDeta === void 0 ? void 0 : _n$appliedProductDeta.map(function (n) {
|
|
550
605
|
var _n$discount;
|
|
551
606
|
return (_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.product_id;
|
|
552
|
-
}) : [];
|
|
607
|
+
})) || n.product_id : [];
|
|
553
608
|
}).flat();
|
|
554
609
|
newDiscountList.forEach(function (item) {
|
|
555
610
|
var _item$applicableProdu;
|
|
@@ -662,7 +717,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
662
717
|
key: "loadPrepareConfig",
|
|
663
718
|
value: function () {
|
|
664
719
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
665
|
-
var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, _result3;
|
|
720
|
+
var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
666
721
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
667
722
|
while (1) switch (_context9.prev = _context9.next) {
|
|
668
723
|
case 0:
|
|
@@ -689,31 +744,37 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
689
744
|
newGoodPassList = goodPassList === null || goodPassList === void 0 ? void 0 : goodPassList.filter(function (n) {
|
|
690
745
|
return !scanDiscountIds.includes(n.id);
|
|
691
746
|
});
|
|
692
|
-
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || []));
|
|
747
|
+
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
|
|
693
748
|
this.store.originalDiscountList = newDiscountList;
|
|
694
|
-
|
|
749
|
+
_context9.next = 12;
|
|
750
|
+
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.setOriginalDiscountList(newDiscountList);
|
|
751
|
+
case 12:
|
|
752
|
+
// 根据当前预约时间过滤优惠券列表
|
|
753
|
+
filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
754
|
+
this.store.filteredDiscountList = filteredDiscountList;
|
|
755
|
+
this.setDiscountList(filteredDiscountList || []);
|
|
695
756
|
if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
|
|
696
|
-
_context9.next =
|
|
757
|
+
_context9.next = 19;
|
|
697
758
|
break;
|
|
698
759
|
}
|
|
699
760
|
_result3 = this.calcDiscount(this.store.productList);
|
|
700
|
-
_context9.next =
|
|
761
|
+
_context9.next = 19;
|
|
701
762
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
702
|
-
case 15:
|
|
703
|
-
_context9.next = 17;
|
|
704
|
-
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
|
|
705
|
-
case 17:
|
|
706
|
-
_context9.next = 22;
|
|
707
|
-
break;
|
|
708
763
|
case 19:
|
|
709
|
-
_context9.
|
|
764
|
+
_context9.next = 21;
|
|
765
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
|
|
766
|
+
case 21:
|
|
767
|
+
_context9.next = 26;
|
|
768
|
+
break;
|
|
769
|
+
case 23:
|
|
770
|
+
_context9.prev = 23;
|
|
710
771
|
_context9.t0 = _context9["catch"](0);
|
|
711
772
|
console.error('[ShopDiscount] 加载准备配置出错:', _context9.t0);
|
|
712
|
-
case
|
|
773
|
+
case 26:
|
|
713
774
|
case "end":
|
|
714
775
|
return _context9.stop();
|
|
715
776
|
}
|
|
716
|
-
}, _callee9, this, [[0,
|
|
777
|
+
}, _callee9, this, [[0, 23]]);
|
|
717
778
|
}));
|
|
718
779
|
function loadPrepareConfig(_x9) {
|
|
719
780
|
return _loadPrepareConfig.apply(this, arguments);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { DiscountModule
|
|
1
|
+
import { DiscountModule } from '../../modules/Discount';
|
|
2
2
|
import { RulesModule } from '../../modules/Rules';
|
|
3
|
+
import { Discount } from "../../modules/Discount/types";
|
|
3
4
|
export declare enum ShopDiscountHooks {
|
|
4
5
|
onInited = "shopDiscount:onInited",
|
|
5
6
|
onDestroy = "shopDiscount:onDestroy",
|
|
@@ -28,6 +29,8 @@ export interface ShopDiscountState {
|
|
|
28
29
|
form_id?: number;
|
|
29
30
|
main_field?: string;
|
|
30
31
|
}[];
|
|
32
|
+
currentBookingTime: string | null;
|
|
33
|
+
filteredDiscountList: Discount[];
|
|
31
34
|
}
|
|
32
35
|
export interface SetDiscountSelectedParams {
|
|
33
36
|
discountId: number;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Discount } from "../../modules/Discount/types";
|
|
2
2
|
export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
|
|
3
|
+
export declare const isNormalProductByDurationSchedule: (item: any) => boolean;
|
|
4
|
+
export declare const isAllNormalProduct: (items: any[]) => boolean;
|
|
3
5
|
/**
|
|
4
6
|
* 获取折扣金额 基于折扣卡类型计算
|
|
5
7
|
* 商品券:直接返回商品价格
|
|
@@ -10,3 +12,56 @@ export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
|
|
|
10
12
|
* @returns
|
|
11
13
|
*/
|
|
12
14
|
export declare const getDiscountAmount: (discount: Discount, total: number, price: number) => number;
|
|
15
|
+
export declare const getDiscountListAmountTotal: (discount: Discount[]) => any;
|
|
16
|
+
/**
|
|
17
|
+
* 获取折扣金额 计算每个折扣的金额
|
|
18
|
+
* @param discount
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export declare const getDiscountListAmount: (discount: Discount[]) => any;
|
|
22
|
+
export interface ScheduleItem {
|
|
23
|
+
id: number;
|
|
24
|
+
name: string | {
|
|
25
|
+
[key: string]: string;
|
|
26
|
+
};
|
|
27
|
+
type: 'standard' | 'time-slots' | 'designation';
|
|
28
|
+
start_time: string | null;
|
|
29
|
+
end_time: string | null;
|
|
30
|
+
repeat_type: 'none' | 'daily' | 'weekly';
|
|
31
|
+
repeat_rule: {
|
|
32
|
+
end: {
|
|
33
|
+
type: 'never' | 'date' | 'occurrence';
|
|
34
|
+
end_date: string | null;
|
|
35
|
+
occurrence: number | null;
|
|
36
|
+
};
|
|
37
|
+
frequency: number;
|
|
38
|
+
excluded_date: Array<{
|
|
39
|
+
start: string;
|
|
40
|
+
end: string;
|
|
41
|
+
}>;
|
|
42
|
+
included_date: Array<{
|
|
43
|
+
start: string;
|
|
44
|
+
end: string;
|
|
45
|
+
}>;
|
|
46
|
+
frequency_date: number[];
|
|
47
|
+
} | null;
|
|
48
|
+
designation: Array<{
|
|
49
|
+
start_date: string;
|
|
50
|
+
start_time: string;
|
|
51
|
+
end_date: string;
|
|
52
|
+
end_time: string;
|
|
53
|
+
}> | null;
|
|
54
|
+
is_all: number;
|
|
55
|
+
time_slot: Array<{
|
|
56
|
+
start_time: string;
|
|
57
|
+
end_time: string;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
export declare const getDateIsInSchedule: (dateTime: string, scheduleList: ScheduleItem[]) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* 根据预约时间过滤优惠券列表
|
|
63
|
+
* @param discountList 优惠券列表
|
|
64
|
+
* @param bookingTime 预约时间 (格式: YYYY-MM-DD HH:mm:ss)
|
|
65
|
+
* @returns 过滤后的优惠券列表
|
|
66
|
+
*/
|
|
67
|
+
export declare const filterDiscountListByBookingTime: (discountList: Discount[], bookingTime: string | null) => Discount[];
|