@pisell/pisellos 0.0.127 → 0.0.129
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/Date/index.d.ts +1 -0
- package/dist/modules/Date/index.js +10 -0
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +15 -7
- package/dist/modules/Rules/index.js +48 -19
- package/dist/solution/BookingByStep/index.js +168 -111
- package/dist/solution/BookingByStep/utils/resources.d.ts +6 -2
- package/dist/solution/BookingByStep/utils/resources.js +14 -4
- package/dist/solution/ShopDiscount/index.js +9 -9
- package/lib/modules/Date/index.d.ts +1 -0
- package/lib/modules/Date/index.js +6 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +18 -6
- package/lib/modules/Rules/index.js +48 -17
- package/lib/solution/BookingByStep/index.js +88 -42
- package/lib/solution/BookingByStep/utils/resources.d.ts +6 -2
- package/lib/solution/BookingByStep/utils/resources.js +12 -4
- package/lib/solution/ShopDiscount/index.js +7 -5
- package/package.json +1 -1
|
@@ -79,7 +79,7 @@ export declare const formatResources: ({ booking, resources, }: {
|
|
|
79
79
|
* @return {*}
|
|
80
80
|
* @Author: zhiwei.Wang
|
|
81
81
|
*/
|
|
82
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, }: {
|
|
82
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
|
|
83
83
|
resource: ResourceItem;
|
|
84
84
|
duration: number;
|
|
85
85
|
split: number;
|
|
@@ -96,6 +96,8 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
|
|
|
96
96
|
unit: number;
|
|
97
97
|
} | undefined;
|
|
98
98
|
} | undefined;
|
|
99
|
+
hasFlexibleDuration?: boolean | undefined;
|
|
100
|
+
operating_day_boundary?: string | undefined;
|
|
99
101
|
}) => TimeSliceItem[];
|
|
100
102
|
/**
|
|
101
103
|
* @title: 获取时间切片列表的交集
|
|
@@ -133,7 +135,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
|
|
|
133
135
|
* @return {*}
|
|
134
136
|
* @Author: zhiwei.Wang
|
|
135
137
|
*/
|
|
136
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, }: {
|
|
138
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
|
|
137
139
|
resourceIds: number[];
|
|
138
140
|
resourcesMap: any;
|
|
139
141
|
duration: number;
|
|
@@ -151,6 +153,8 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
|
|
|
151
153
|
unit: number;
|
|
152
154
|
} | undefined;
|
|
153
155
|
} | undefined;
|
|
156
|
+
hasFlexibleDuration?: boolean | undefined;
|
|
157
|
+
operating_day_boundary?: string | undefined;
|
|
154
158
|
}) => any[];
|
|
155
159
|
/**
|
|
156
160
|
* @title: 获取其他人的已选资源
|
|
@@ -415,7 +415,9 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
415
415
|
capacity = _ref5.capacity,
|
|
416
416
|
_ref5$resourcesUseabl = _ref5.resourcesUseableMap,
|
|
417
417
|
resourcesUseableMap = _ref5$resourcesUseabl === void 0 ? {} : _ref5$resourcesUseabl,
|
|
418
|
-
cut_off_time = _ref5.cut_off_time
|
|
418
|
+
cut_off_time = _ref5.cut_off_time,
|
|
419
|
+
hasFlexibleDuration = _ref5.hasFlexibleDuration,
|
|
420
|
+
operating_day_boundary = _ref5.operating_day_boundary;
|
|
419
421
|
var times = resource.times;
|
|
420
422
|
|
|
421
423
|
// 存储所有时间切片
|
|
@@ -424,7 +426,7 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
424
426
|
// 处理每个时间范围
|
|
425
427
|
times.forEach(function (time) {
|
|
426
428
|
// 创建今天的日期字符串,用于构建完整的日期时间
|
|
427
|
-
|
|
429
|
+
// const today = dayjs(currentDate).format('YYYY-MM-DD');
|
|
428
430
|
|
|
429
431
|
// 解析开始和结束时间
|
|
430
432
|
var startTime = dayjs("".concat(time.start_at));
|
|
@@ -460,6 +462,10 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
460
462
|
resourcesUseableMap[resource.id] = _status.usable;
|
|
461
463
|
}
|
|
462
464
|
if (_status.usable) {
|
|
465
|
+
// 如果有hasFlexibleDuration,且timeSlice.start_at 大于等于operating_day_boundary,则不添加时间切片
|
|
466
|
+
if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= operating_day_boundary) {
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
463
469
|
// 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
|
|
464
470
|
timeSlices.push(_objectSpread(_objectSpread({}, timeSlice), {}, {
|
|
465
471
|
// 这里需要补充这个时间段内是否可预约
|
|
@@ -565,7 +571,9 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
|
|
|
565
571
|
split = _ref6.split,
|
|
566
572
|
capacity = _ref6.capacity,
|
|
567
573
|
resourcesUseableMap = _ref6.resourcesUseableMap,
|
|
568
|
-
cut_off_time = _ref6.cut_off_time
|
|
574
|
+
cut_off_time = _ref6.cut_off_time,
|
|
575
|
+
hasFlexibleDuration = _ref6.hasFlexibleDuration,
|
|
576
|
+
operating_day_boundary = _ref6.operating_day_boundary;
|
|
569
577
|
// 获取资源列表
|
|
570
578
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
571
579
|
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
@@ -588,7 +596,9 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
|
|
|
588
596
|
currentDate: currentDate,
|
|
589
597
|
capacity: capacity,
|
|
590
598
|
resourcesUseableMap: resourcesUseableMap,
|
|
591
|
-
cut_off_time: cut_off_time
|
|
599
|
+
cut_off_time: cut_off_time,
|
|
600
|
+
hasFlexibleDuration: hasFlexibleDuration,
|
|
601
|
+
operating_day_boundary: operating_day_boundary
|
|
592
602
|
}));
|
|
593
603
|
}, []);
|
|
594
604
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
var _excluded = ["wallet_pass_list"];
|
|
2
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
|
-
function
|
|
4
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
2
|
+
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
|
|
5
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
5
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -196,7 +194,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
196
194
|
_this2.loadPrepareConfig({
|
|
197
195
|
customerId: customer.id,
|
|
198
196
|
action: 'create',
|
|
199
|
-
with_good_pass: 1
|
|
197
|
+
with_good_pass: 1,
|
|
198
|
+
with_discount_card: 1
|
|
200
199
|
});
|
|
201
200
|
});
|
|
202
201
|
}
|
|
@@ -473,14 +472,14 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
473
472
|
key: "getCustomerWallet",
|
|
474
473
|
value: function () {
|
|
475
474
|
var _getCustomerWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id) {
|
|
476
|
-
var result,
|
|
475
|
+
var result, customer;
|
|
477
476
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
478
477
|
while (1) switch (_context7.prev = _context7.next) {
|
|
479
478
|
case 0:
|
|
480
479
|
_context7.prev = 0;
|
|
481
480
|
_context7.next = 3;
|
|
482
|
-
return this.request.get("/customer/info/
|
|
483
|
-
|
|
481
|
+
return this.request.get("/customer/info/".concat(id), {
|
|
482
|
+
with_trashed: 1
|
|
484
483
|
});
|
|
485
484
|
case 3:
|
|
486
485
|
result = _context7.sent;
|
|
@@ -488,7 +487,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
488
487
|
_context7.next = 9;
|
|
489
488
|
break;
|
|
490
489
|
}
|
|
491
|
-
|
|
490
|
+
customer = Object.assign({}, (_objectDestructuringEmpty(result.data), result.data));
|
|
492
491
|
this.setCustomer(customer);
|
|
493
492
|
_context7.next = 9;
|
|
494
493
|
return this.core.effects.emit(ShopDiscountHooks.onScanCustomerChange, customer);
|
|
@@ -526,7 +525,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
526
525
|
return (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.loadPrepareConfig({
|
|
527
526
|
customer_id: customerId,
|
|
528
527
|
action: 'create',
|
|
529
|
-
with_good_pass: 1
|
|
528
|
+
with_good_pass: 1,
|
|
529
|
+
with_discount_card: 1
|
|
530
530
|
});
|
|
531
531
|
case 4:
|
|
532
532
|
goodPassList = _context8.sent;
|
|
@@ -20,4 +20,5 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
20
20
|
getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
21
21
|
clearDateRange(): void;
|
|
22
22
|
storeChange(): void;
|
|
23
|
+
getResourcesListByDate(date: string): any[] | undefined;
|
|
23
24
|
}
|
|
@@ -125,6 +125,12 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
+
getResourcesListByDate(date) {
|
|
129
|
+
var _a;
|
|
130
|
+
const dateList = this.store.dateList;
|
|
131
|
+
const resourcesList = (_a = dateList.find((item) => item.date === date)) == null ? void 0 : _a.resource;
|
|
132
|
+
return resourcesList;
|
|
133
|
+
}
|
|
128
134
|
};
|
|
129
135
|
// Annotate the CommonJS export names for ESM import in node:
|
|
130
136
|
0 && (module.exports = {
|
|
@@ -17,6 +17,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
17
17
|
loadPrepareConfig(params: {
|
|
18
18
|
action?: 'create';
|
|
19
19
|
with_good_pass: 0 | 1;
|
|
20
|
+
with_discount_card: 0 | 1;
|
|
20
21
|
customer_id: number;
|
|
21
22
|
}): Promise<Discount[]>;
|
|
22
23
|
batchSearch(code: string): Promise<Discount[]>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
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
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/modules/Discount/index.ts
|
|
@@ -25,6 +35,7 @@ module.exports = __toCommonJS(Discount_exports);
|
|
|
25
35
|
var import_utils = require("../../solution/ShopDiscount/utils");
|
|
26
36
|
var import_BaseModule = require("../BaseModule");
|
|
27
37
|
var import_types = require("./types");
|
|
38
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
28
39
|
var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
29
40
|
constructor(name, version) {
|
|
30
41
|
super(name, version);
|
|
@@ -68,21 +79,22 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
68
79
|
return this.store.discountList;
|
|
69
80
|
}
|
|
70
81
|
async loadPrepareConfig(params) {
|
|
71
|
-
var _a;
|
|
82
|
+
var _a, _b;
|
|
72
83
|
const prepareConfig = await this.request.post(
|
|
73
84
|
`/order/prepare/config`,
|
|
74
85
|
params
|
|
75
86
|
);
|
|
76
87
|
const goodPassList = this.filterEnabledDiscountList(
|
|
77
|
-
((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || []
|
|
88
|
+
[...((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || [], ...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []]
|
|
78
89
|
) || [];
|
|
90
|
+
this.setDiscountList(goodPassList);
|
|
79
91
|
return goodPassList;
|
|
80
92
|
}
|
|
81
93
|
async batchSearch(code) {
|
|
82
94
|
const result = await this.request.get(`/machinecode/batch-search`, {
|
|
83
95
|
code,
|
|
84
96
|
translate_flag: 1,
|
|
85
|
-
|
|
97
|
+
tags: ["good_pass", "product_discount_card"],
|
|
86
98
|
available: 1,
|
|
87
99
|
relation_product: 1
|
|
88
100
|
});
|
|
@@ -91,7 +103,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
91
103
|
}
|
|
92
104
|
filterEnabledDiscountList(discountList) {
|
|
93
105
|
return discountList.filter(
|
|
94
|
-
(discount) => discount.limit_status === "enable" &&
|
|
106
|
+
(discount) => discount.limit_status === "enable" && new import_decimal.default((discount == null ? void 0 : discount.par_value) || 0).minus(new import_decimal.default((discount == null ? void 0 : discount.used_par_value) || 0)).greaterThan(0)
|
|
95
107
|
);
|
|
96
108
|
}
|
|
97
109
|
// 根据productIds去重
|
|
@@ -110,8 +122,8 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
110
122
|
}
|
|
111
123
|
if (discount.appliedProductDetails) {
|
|
112
124
|
return discount.appliedProductDetails.reduce((total, product) => {
|
|
113
|
-
const price =
|
|
114
|
-
return total
|
|
125
|
+
const price = new import_decimal.default((product == null ? void 0 : product.amount) || 0);
|
|
126
|
+
return new import_decimal.default(total).plus(price).toNumber();
|
|
115
127
|
}, 0);
|
|
116
128
|
}
|
|
117
129
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
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
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/modules/Rules/index.ts
|
|
@@ -26,6 +36,7 @@ var import_BaseModule = require("../BaseModule");
|
|
|
26
36
|
var import_types = require("./types");
|
|
27
37
|
var import_utils = require("../../solution/ShopDiscount/utils");
|
|
28
38
|
var import_utils2 = require("../Cart/utils");
|
|
39
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
29
40
|
var RulesModule = class extends import_BaseModule.BaseModule {
|
|
30
41
|
constructor(name, version) {
|
|
31
42
|
super(name, version);
|
|
@@ -107,19 +118,36 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
107
118
|
return !discount.isManualSelect;
|
|
108
119
|
});
|
|
109
120
|
const sortedDiscountList = [...filteredDiscountList].sort((a, b) => {
|
|
110
|
-
if (a.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return
|
|
121
|
+
if (a.tag === "good_pass" && b.tag !== "good_pass")
|
|
122
|
+
return -1;
|
|
123
|
+
if (b.tag === "good_pass" && a.tag !== "good_pass")
|
|
124
|
+
return 1;
|
|
125
|
+
if (a.tag === "good_pass" && b.tag === "good_pass") {
|
|
126
|
+
return compareByExpireTime(a, b);
|
|
127
|
+
} else if (a.tag === "product_discount_card" && b.tag === "product_discount_card") {
|
|
128
|
+
if (a.par_value !== b.par_value) {
|
|
129
|
+
const valueA = new import_decimal.default(a.par_value || 0);
|
|
130
|
+
const valueB = new import_decimal.default(b.par_value || 0);
|
|
131
|
+
return valueA.minus(valueB).toNumber();
|
|
132
|
+
}
|
|
133
|
+
return compareByExpireTime(a, b);
|
|
134
|
+
}
|
|
135
|
+
return compareByExpireTime(a, b);
|
|
136
|
+
function compareByExpireTime(itemA, itemB) {
|
|
137
|
+
if (itemA.expire_time && itemB.expire_time) {
|
|
138
|
+
const timeA = new Date(itemA.expire_time).getTime();
|
|
139
|
+
const timeB = new Date(itemB.expire_time).getTime();
|
|
140
|
+
return timeA - timeB;
|
|
141
|
+
}
|
|
142
|
+
return itemA.expire_time ? -1 : itemB.expire_time ? 1 : 0;
|
|
114
143
|
}
|
|
115
|
-
return a.expire_time ? -1 : b.expire_time ? 1 : 0;
|
|
116
144
|
});
|
|
117
145
|
const sortedProductList = [...productList].sort((a, b) => {
|
|
118
146
|
const aProduct = this.hooks.getProduct(a);
|
|
119
147
|
const bProduct = this.hooks.getProduct(b);
|
|
120
|
-
const priceA =
|
|
121
|
-
const priceB =
|
|
122
|
-
return priceB
|
|
148
|
+
const priceA = new import_decimal.default(aProduct.price || "0");
|
|
149
|
+
const priceB = new import_decimal.default(bProduct.price || "0");
|
|
150
|
+
return priceB.minus(priceA).toNumber();
|
|
123
151
|
});
|
|
124
152
|
const usedDiscounts = /* @__PURE__ */ new Map();
|
|
125
153
|
const discountApplicability = /* @__PURE__ */ new Map();
|
|
@@ -146,7 +174,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
146
174
|
discount: {
|
|
147
175
|
resource_id: discount.id,
|
|
148
176
|
title: discount.format_title,
|
|
149
|
-
original_amount: product.origin_total
|
|
177
|
+
original_amount: product.origin_total,
|
|
178
|
+
pre_value: discount.par_value
|
|
150
179
|
}
|
|
151
180
|
});
|
|
152
181
|
discountApplicableProducts.set(discount.id, applicableProducts);
|
|
@@ -220,14 +249,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
220
249
|
}
|
|
221
250
|
usedDiscounts.set(selectedDiscount.id, true);
|
|
222
251
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount.id) || [];
|
|
252
|
+
const targetProductPrice = selectedDiscount.tag === "good_pass" ? "0" : new import_decimal.default(selectedDiscount.par_value || 0).div(100).mul(new import_decimal.default(product.price || 0)).toFixed(2);
|
|
223
253
|
const discountDetail = {
|
|
224
|
-
amount: product.price,
|
|
225
|
-
type: selectedDiscount.tag,
|
|
254
|
+
amount: selectedDiscount.tag === "product_discount_card" ? new import_decimal.default(product.price || 0).minus(new import_decimal.default(targetProductPrice)).toNumber() : product.price,
|
|
255
|
+
type: selectedDiscount.tag === "product_discount_card" ? "discount_card" : selectedDiscount.tag,
|
|
226
256
|
discount: {
|
|
227
257
|
resource_id: selectedDiscount.id,
|
|
228
258
|
title: selectedDiscount.format_title,
|
|
229
|
-
original_amount: product.
|
|
230
|
-
product_id: selectedDiscount.product_id
|
|
259
|
+
original_amount: product.price,
|
|
260
|
+
product_id: selectedDiscount.product_id,
|
|
261
|
+
percent: selectedDiscount.par_value
|
|
231
262
|
}
|
|
232
263
|
};
|
|
233
264
|
appliedProducts.push(discountDetail);
|
|
@@ -237,7 +268,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
237
268
|
product._id,
|
|
238
269
|
this.hooks.setProduct(originProduct, {
|
|
239
270
|
discount_list: [discountDetail],
|
|
240
|
-
price:
|
|
271
|
+
price: new import_decimal.default(targetProductPrice).toNumber(),
|
|
241
272
|
origin_total: (0, import_utils2.getProductOriginTotalPrice)({
|
|
242
273
|
product: {
|
|
243
274
|
original_price: product.original_price
|
|
@@ -247,7 +278,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
247
278
|
}),
|
|
248
279
|
total: (0, import_utils2.getProductTotalPrice)({
|
|
249
280
|
product: {
|
|
250
|
-
price:
|
|
281
|
+
price: targetProductPrice
|
|
251
282
|
},
|
|
252
283
|
bundle: product.bundle,
|
|
253
284
|
options: product.options
|
|
@@ -259,8 +290,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
259
290
|
product._id,
|
|
260
291
|
this.hooks.setProduct(originProduct, {
|
|
261
292
|
discount_list: [discountDetail],
|
|
262
|
-
price:
|
|
263
|
-
total: (product.origin_total || product.total)
|
|
293
|
+
price: new import_decimal.default(targetProductPrice).toNumber(),
|
|
294
|
+
total: new import_decimal.default(product.origin_total || product.total || 0).minus(new import_decimal.default(product.price || 0)).toNumber(),
|
|
264
295
|
origin_total: product.origin_total || product.total
|
|
265
296
|
})
|
|
266
297
|
);
|