@pisell/pisellos 3.0.71 → 3.0.73
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/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/Rules/index.d.ts +8 -0
- package/dist/modules/Rules/index.js +1033 -183
- package/dist/modules/Rules/types.d.ts +4 -1
- package/dist/solution/BookingByStep/index.js +1 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +82 -19
- package/dist/solution/ShopDiscount/types.d.ts +4 -0
- 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/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/Rules/index.d.ts +8 -0
- package/lib/modules/Rules/index.js +813 -172
- package/lib/modules/Rules/types.d.ts +4 -1
- package/lib/solution/BookingByStep/index.js +4 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +58 -10
- package/lib/solution/ShopDiscount/types.d.ts +4 -0
- package/lib/solution/ShopDiscount/utils.d.ts +55 -0
- package/lib/solution/ShopDiscount/utils.js +266 -3
- package/package.json +1 -1
|
@@ -174,6 +174,24 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
|
|
|
174
174
|
discounts = params.discounts;
|
|
175
175
|
// const num = params.num || 1;
|
|
176
176
|
var price = Number(product.price);
|
|
177
|
+
|
|
178
|
+
// 如果商品有折扣,则计算折扣
|
|
179
|
+
if (discounts !== null && discounts !== void 0 && discounts.length) {
|
|
180
|
+
discounts.forEach(function (currentValue) {
|
|
181
|
+
var _currentValue$discoun;
|
|
182
|
+
// 不是商品券则代表折扣卡,计算打折后的价格
|
|
183
|
+
// 一个商品折扣卡只能存在于一张
|
|
184
|
+
// if (currentValue.type !== 'good_pass') {
|
|
185
|
+
price = getDiscountAmount({
|
|
186
|
+
tag: currentValue.type,
|
|
187
|
+
par_value: currentValue.discount.percent,
|
|
188
|
+
metadata: {
|
|
189
|
+
discount_card_type: currentValue === null || currentValue === void 0 || (_currentValue$discoun = currentValue.discount) === null || _currentValue$discoun === void 0 ? void 0 : _currentValue$discoun.discount_card_type
|
|
190
|
+
}
|
|
191
|
+
}, price, price);
|
|
192
|
+
// }
|
|
193
|
+
});
|
|
194
|
+
}
|
|
177
195
|
if (bundle !== null && bundle !== void 0 && bundle.length) {
|
|
178
196
|
price = bundle.reduce(function (accumulator, currentValue) {
|
|
179
197
|
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
@@ -186,25 +204,7 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
|
|
|
186
204
|
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
187
205
|
}, price);
|
|
188
206
|
}
|
|
189
|
-
|
|
190
|
-
// 如果商品有折扣,则计算折扣
|
|
191
|
-
if (discounts !== null && discounts !== void 0 && discounts.length) {
|
|
192
|
-
discounts.forEach(function (currentValue) {
|
|
193
|
-
// 不是商品券则代表折扣卡,计算打折后的价格
|
|
194
|
-
// 一个商品折扣卡只能存在于一张
|
|
195
|
-
if (currentValue.type !== 'good_pass') {
|
|
196
|
-
var _currentValue$discoun;
|
|
197
|
-
price = getDiscountAmount({
|
|
198
|
-
tag: currentValue.type,
|
|
199
|
-
par_value: currentValue.discount.percent,
|
|
200
|
-
metadata: {
|
|
201
|
-
discount_card_type: currentValue === null || currentValue === void 0 || (_currentValue$discoun = currentValue.discount) === null || _currentValue$discoun === void 0 ? void 0 : _currentValue$discoun.discount_card_type
|
|
202
|
-
}
|
|
203
|
-
}, price, price);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
return price;
|
|
207
|
+
return Math.max(0, price);
|
|
208
208
|
};
|
|
209
209
|
|
|
210
210
|
/**
|
|
@@ -284,24 +284,39 @@ export var formatBundle = function formatBundle(bundle) {
|
|
|
284
284
|
price: item === null || item === void 0 ? void 0 : item.price,
|
|
285
285
|
total: item === null || item === void 0 ? void 0 : item.price,
|
|
286
286
|
price_type: item === null || item === void 0 ? void 0 : item.price_type,
|
|
287
|
+
original_price: item === null || item === void 0 ? void 0 : item.original_price,
|
|
288
|
+
original_total: item === null || item === void 0 ? void 0 : item.original_total,
|
|
289
|
+
price_type_ext: item === null || item === void 0 ? void 0 : item.price_type_ext,
|
|
287
290
|
bundle_sum_price: item === null || item === void 0 ? void 0 : item.bundle_sum_price,
|
|
288
291
|
bundle_sum_type: item === null || item === void 0 ? void 0 : item.bundle_sum_type,
|
|
289
|
-
options: formatOptions(item === null || item === void 0 ? void 0 : item.option)
|
|
292
|
+
options: formatOptions(item === null || item === void 0 ? void 0 : item.option),
|
|
293
|
+
_bundle_product_id: item._bundle_product_id,
|
|
294
|
+
discount_list: item.discount_list,
|
|
295
|
+
originBundleItem: item.originBundleItem || item
|
|
290
296
|
};
|
|
291
297
|
});
|
|
292
298
|
};
|
|
293
299
|
export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
|
|
294
300
|
if (!(bundle !== null && bundle !== void 0 && bundle.length)) return [];
|
|
295
301
|
return bundle.map(function (d) {
|
|
302
|
+
var getBundleValueByKey = function getBundleValueByKey(key) {
|
|
303
|
+
var _d$originBundleItem;
|
|
304
|
+
return (d === null || d === void 0 ? void 0 : d[key]) || (d === null || d === void 0 || (_d$originBundleItem = d.originBundleItem) === null || _d$originBundleItem === void 0 ? void 0 : _d$originBundleItem[key]);
|
|
305
|
+
};
|
|
296
306
|
return {
|
|
297
|
-
bundle_group_id:
|
|
307
|
+
bundle_group_id: getBundleValueByKey('group_id'),
|
|
298
308
|
bundle_id: d.id,
|
|
299
|
-
bundle_product_id: (
|
|
300
|
-
bundle_variant_id:
|
|
309
|
+
bundle_product_id: getBundleValueByKey('_bundle_product_id') || getBundleValueByKey('product_id'),
|
|
310
|
+
bundle_variant_id: getBundleValueByKey('bundle_variant_id'),
|
|
301
311
|
num: d.num,
|
|
302
|
-
extension_id:
|
|
303
|
-
extension_type:
|
|
304
|
-
option: formatOptionsToOrigin(
|
|
312
|
+
extension_id: getBundleValueByKey('extension_id'),
|
|
313
|
+
extension_type: getBundleValueByKey('extension_type'),
|
|
314
|
+
option: formatOptionsToOrigin(getBundleValueByKey('option')),
|
|
315
|
+
discount_list: d.discount_list,
|
|
316
|
+
"bundle_selling_price": d === null || d === void 0 ? void 0 : d.price,
|
|
317
|
+
metadata: {
|
|
318
|
+
custom_product_bundle_map_id: d._id
|
|
319
|
+
}
|
|
305
320
|
};
|
|
306
321
|
});
|
|
307
322
|
};
|
|
@@ -14,6 +14,8 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
14
14
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
15
15
|
setDiscountList(discountList: Discount[]): Promise<void>;
|
|
16
16
|
getDiscountList(): Discount[];
|
|
17
|
+
setOriginalDiscountList(originalDiscountList: Discount[]): Promise<void>;
|
|
18
|
+
getOriginalDiscountList(): Discount[];
|
|
17
19
|
loadPrepareConfig(params: {
|
|
18
20
|
action?: 'create';
|
|
19
21
|
with_good_pass: 0 | 1;
|
|
@@ -46,7 +46,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
46
46
|
key: "initialize",
|
|
47
47
|
value: function () {
|
|
48
48
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
49
|
-
var _options$initialState, _options$otherParams, _options$otherParams2;
|
|
49
|
+
var _options$initialState, _options$initialState2, _options$otherParams, _options$otherParams2;
|
|
50
50
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
51
51
|
while (1) switch (_context.prev = _context.next) {
|
|
52
52
|
case 0:
|
|
@@ -57,6 +57,11 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
57
57
|
} else {
|
|
58
58
|
this.store.discountList = [];
|
|
59
59
|
}
|
|
60
|
+
if (Array.isArray(options === null || options === void 0 || (_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.originalDiscountList)) {
|
|
61
|
+
this.store.originalDiscountList = options === null || options === void 0 ? void 0 : options.initialState.originalDiscountList;
|
|
62
|
+
} else {
|
|
63
|
+
this.store.originalDiscountList = [];
|
|
64
|
+
}
|
|
60
65
|
if (options !== null && options !== void 0 && (_options$otherParams = options.otherParams) !== null && _options$otherParams !== void 0 && _options$otherParams.cacheId) {
|
|
61
66
|
this.openCache = options.otherParams.openCache;
|
|
62
67
|
this.cacheId = options.otherParams.cacheId;
|
|
@@ -69,17 +74,17 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
69
74
|
this.request = core.getPlugin('request');
|
|
70
75
|
this.window = core.getPlugin('window');
|
|
71
76
|
if (this.request) {
|
|
72
|
-
_context.next =
|
|
77
|
+
_context.next = 10;
|
|
73
78
|
break;
|
|
74
79
|
}
|
|
75
80
|
throw new Error('discount模块需要 request 插件支持');
|
|
76
|
-
case
|
|
81
|
+
case 10:
|
|
77
82
|
if (this.window) {
|
|
78
|
-
_context.next =
|
|
83
|
+
_context.next = 12;
|
|
79
84
|
break;
|
|
80
85
|
}
|
|
81
86
|
throw new Error('discount模块需要 window 插件支持');
|
|
82
|
-
case
|
|
87
|
+
case 12:
|
|
83
88
|
case "end":
|
|
84
89
|
return _context.stop();
|
|
85
90
|
}
|
|
@@ -116,28 +121,54 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
116
121
|
value: function getDiscountList() {
|
|
117
122
|
return this.store.discountList;
|
|
118
123
|
}
|
|
124
|
+
|
|
125
|
+
// 设置原始优惠券列表
|
|
126
|
+
}, {
|
|
127
|
+
key: "setOriginalDiscountList",
|
|
128
|
+
value: function () {
|
|
129
|
+
var _setOriginalDiscountList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(originalDiscountList) {
|
|
130
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
131
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
132
|
+
case 0:
|
|
133
|
+
this.store.originalDiscountList = originalDiscountList;
|
|
134
|
+
case 1:
|
|
135
|
+
case "end":
|
|
136
|
+
return _context3.stop();
|
|
137
|
+
}
|
|
138
|
+
}, _callee3, this);
|
|
139
|
+
}));
|
|
140
|
+
function setOriginalDiscountList(_x4) {
|
|
141
|
+
return _setOriginalDiscountList.apply(this, arguments);
|
|
142
|
+
}
|
|
143
|
+
return setOriginalDiscountList;
|
|
144
|
+
}() // 获取原始优惠券列表
|
|
145
|
+
}, {
|
|
146
|
+
key: "getOriginalDiscountList",
|
|
147
|
+
value: function getOriginalDiscountList() {
|
|
148
|
+
return this.store.originalDiscountList || [];
|
|
149
|
+
}
|
|
119
150
|
}, {
|
|
120
151
|
key: "loadPrepareConfig",
|
|
121
152
|
value: function () {
|
|
122
|
-
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
153
|
+
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
123
154
|
var _prepareConfig$data, _prepareConfig$data2;
|
|
124
155
|
var prepareConfig, goodPassList;
|
|
125
|
-
return _regeneratorRuntime().wrap(function
|
|
126
|
-
while (1) switch (
|
|
156
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
157
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
127
158
|
case 0:
|
|
128
|
-
|
|
159
|
+
_context4.next = 2;
|
|
129
160
|
return this.request.post("/order/prepare/config", params);
|
|
130
161
|
case 2:
|
|
131
|
-
prepareConfig =
|
|
162
|
+
prepareConfig = _context4.sent;
|
|
132
163
|
goodPassList = this.filterEnabledDiscountList([].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.discount_card_list) || []))) || []; // this.setDiscountList(goodPassList);
|
|
133
|
-
return
|
|
164
|
+
return _context4.abrupt("return", goodPassList);
|
|
134
165
|
case 5:
|
|
135
166
|
case "end":
|
|
136
|
-
return
|
|
167
|
+
return _context4.stop();
|
|
137
168
|
}
|
|
138
|
-
},
|
|
169
|
+
}, _callee4, this);
|
|
139
170
|
}));
|
|
140
|
-
function loadPrepareConfig(
|
|
171
|
+
function loadPrepareConfig(_x5) {
|
|
141
172
|
return _loadPrepareConfig.apply(this, arguments);
|
|
142
173
|
}
|
|
143
174
|
return loadPrepareConfig;
|
|
@@ -145,12 +176,12 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
145
176
|
}, {
|
|
146
177
|
key: "batchSearch",
|
|
147
178
|
value: function () {
|
|
148
|
-
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
179
|
+
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
|
|
149
180
|
var result, resultDiscountList;
|
|
150
|
-
return _regeneratorRuntime().wrap(function
|
|
151
|
-
while (1) switch (
|
|
181
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
182
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
152
183
|
case 0:
|
|
153
|
-
|
|
184
|
+
_context5.next = 2;
|
|
154
185
|
return this.request.get("/machinecode/batch-search", {
|
|
155
186
|
code: code,
|
|
156
187
|
translate_flag: 1,
|
|
@@ -162,16 +193,16 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
162
193
|
order_behavior_count_customer_id: customerId || 1
|
|
163
194
|
});
|
|
164
195
|
case 2:
|
|
165
|
-
result =
|
|
196
|
+
result = _context5.sent;
|
|
166
197
|
resultDiscountList = this.filterEnabledDiscountList((result === null || result === void 0 ? void 0 : result.data) || []) || [];
|
|
167
|
-
return
|
|
198
|
+
return _context5.abrupt("return", resultDiscountList);
|
|
168
199
|
case 5:
|
|
169
200
|
case "end":
|
|
170
|
-
return
|
|
201
|
+
return _context5.stop();
|
|
171
202
|
}
|
|
172
|
-
},
|
|
203
|
+
}, _callee5, this);
|
|
173
204
|
}));
|
|
174
|
-
function batchSearch(
|
|
205
|
+
function batchSearch(_x6, _x7) {
|
|
175
206
|
return _batchSearch.apply(this, arguments);
|
|
176
207
|
}
|
|
177
208
|
return batchSearch;
|
|
@@ -268,7 +299,8 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
268
299
|
}
|
|
269
300
|
if (discount.appliedProductDetails) {
|
|
270
301
|
return discount.appliedProductDetails.reduce(function (total, product) {
|
|
271
|
-
var
|
|
302
|
+
var _product$discount;
|
|
303
|
+
var price = new Decimal((product === null || product === void 0 || (_product$discount = product.discount) === null || _product$discount === void 0 ? void 0 : _product$discount.fixed_amount) || 0).mul((product === null || product === void 0 ? void 0 : product._num) || 1);
|
|
272
304
|
return new Decimal(total).plus(price).toNumber();
|
|
273
305
|
}, 0);
|
|
274
306
|
}
|
|
@@ -276,21 +308,21 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
276
308
|
}, {
|
|
277
309
|
key: "destroy",
|
|
278
310
|
value: function () {
|
|
279
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
280
|
-
return _regeneratorRuntime().wrap(function
|
|
281
|
-
while (1) switch (
|
|
311
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
312
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
313
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
282
314
|
case 0:
|
|
283
315
|
this.store.discountList = [];
|
|
284
316
|
this.core.effects.offByModuleDestroy(this.name);
|
|
285
|
-
|
|
317
|
+
_context6.next = 4;
|
|
286
318
|
return this.core.effects.emit(DiscountHooks.OnDestroy, {});
|
|
287
319
|
case 4:
|
|
288
320
|
console.log('[Discount] 已销毁');
|
|
289
321
|
case 5:
|
|
290
322
|
case "end":
|
|
291
|
-
return
|
|
323
|
+
return _context6.stop();
|
|
292
324
|
}
|
|
293
|
-
},
|
|
325
|
+
}, _callee6, this);
|
|
294
326
|
}));
|
|
295
327
|
function destroy() {
|
|
296
328
|
return _destroy.apply(this, arguments);
|
|
@@ -300,17 +332,18 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
300
332
|
}, {
|
|
301
333
|
key: "clear",
|
|
302
334
|
value: function () {
|
|
303
|
-
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
304
|
-
return _regeneratorRuntime().wrap(function
|
|
305
|
-
while (1) switch (
|
|
335
|
+
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
336
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
337
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
306
338
|
case 0:
|
|
307
339
|
this.store.discountList = [];
|
|
340
|
+
this.store.originalDiscountList = [];
|
|
308
341
|
console.log('[Discount] clear');
|
|
309
|
-
case
|
|
342
|
+
case 3:
|
|
310
343
|
case "end":
|
|
311
|
-
return
|
|
344
|
+
return _context7.stop();
|
|
312
345
|
}
|
|
313
|
-
},
|
|
346
|
+
}, _callee7, this);
|
|
314
347
|
}));
|
|
315
348
|
function clear() {
|
|
316
349
|
return _clear.apply(this, arguments);
|
|
@@ -15,11 +15,16 @@ interface Formattitle {
|
|
|
15
15
|
'zh-CN'?: any;
|
|
16
16
|
'zh-HK'?: any;
|
|
17
17
|
}
|
|
18
|
+
interface PackageSubItemUsageRules {
|
|
19
|
+
type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
|
|
20
|
+
rules: ("original_price" | "markup_price")[];
|
|
21
|
+
}
|
|
18
22
|
interface Limitedrelationproductdata {
|
|
19
23
|
id: number;
|
|
20
24
|
type: 'product_all' | 'products' | 'product_collection';
|
|
21
25
|
product_ids: number[];
|
|
22
26
|
product_collection_id: number[];
|
|
27
|
+
package_sub_item_usage_rules?: PackageSubItemUsageRules;
|
|
23
28
|
}
|
|
24
29
|
interface ApplicableProductDetails {
|
|
25
30
|
amount: string;
|
|
@@ -29,12 +34,14 @@ interface ApplicableProductDetails {
|
|
|
29
34
|
original_amount: string;
|
|
30
35
|
num: number;
|
|
31
36
|
discount?: {
|
|
37
|
+
fixed_amount?: number;
|
|
32
38
|
product_id?: number;
|
|
33
39
|
original_amount?: string;
|
|
34
40
|
percent?: string;
|
|
35
41
|
resource_id?: number;
|
|
36
42
|
title?: string;
|
|
37
43
|
};
|
|
44
|
+
_num: number;
|
|
38
45
|
}
|
|
39
46
|
interface UsageCreditsValue {
|
|
40
47
|
total_credits: number;
|
|
@@ -72,6 +79,8 @@ export interface Discount {
|
|
|
72
79
|
format_title: Formattitle;
|
|
73
80
|
metadata?: {
|
|
74
81
|
discount_card_type?: 'fixed_amount' | 'percent';
|
|
82
|
+
custom_product_bundle_map_id?: string;
|
|
83
|
+
validity_type?: "custom_schedule_validity" | "fixed_validity";
|
|
75
84
|
};
|
|
76
85
|
product: Product;
|
|
77
86
|
type: "product" | 'good_pass';
|
|
@@ -98,9 +107,16 @@ export interface Discount {
|
|
|
98
107
|
week_order_behavior_count?: number;
|
|
99
108
|
month_order_behavior_count?: number;
|
|
100
109
|
customer_order_behavior_count?: number;
|
|
110
|
+
custom_schedule_snapshot?: {
|
|
111
|
+
data: any[];
|
|
112
|
+
};
|
|
113
|
+
num?: number;
|
|
114
|
+
start_date?: string;
|
|
115
|
+
start_time?: string;
|
|
101
116
|
}
|
|
102
117
|
export interface DiscountState {
|
|
103
118
|
discountList: Discount[];
|
|
119
|
+
originalDiscountList?: Discount[];
|
|
104
120
|
}
|
|
105
121
|
export interface DiscountModuleAPI {
|
|
106
122
|
setDiscountList: (discountList: Discount[]) => Promise<void>;
|
|
@@ -24,7 +24,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
24
24
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
25
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
26
|
import { BaseModule } from "../BaseModule";
|
|
27
|
-
import { generateDuration, mergeRelationForms } from "./utils";
|
|
27
|
+
import { generateDuration, getAllDiscountList, mergeRelationForms } from "./utils";
|
|
28
28
|
import { isNormalProduct } from "../Product/utils";
|
|
29
29
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
30
30
|
_inherits(OrderModule, _BaseModule);
|
|
@@ -86,6 +86,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
86
86
|
item._origin.duration = duration;
|
|
87
87
|
item._origin.sub_type = durationType;
|
|
88
88
|
}
|
|
89
|
+
var discountList = getAllDiscountList(item);
|
|
90
|
+
item._origin.product.discount_list = discountList;
|
|
91
|
+
|
|
89
92
|
// 购物车是否为普通商品
|
|
90
93
|
if (isNormalProduct(item._origin)) {
|
|
91
94
|
var _order$relation_forms;
|
|
@@ -51,4 +51,13 @@ export var mergeRelationForms = function mergeRelationForms(relationForms) {
|
|
|
51
51
|
}, {})).filter(function (item) {
|
|
52
52
|
return item.form_record_ids.length > 0;
|
|
53
53
|
}); // 过滤掉没有有效记录的表单
|
|
54
|
+
};
|
|
55
|
+
export var getAllDiscountList = function getAllDiscountList(cartItem) {
|
|
56
|
+
var _cartItem$_origin, _cartItem$_origin2;
|
|
57
|
+
var discountList = (cartItem === null || cartItem === void 0 || (_cartItem$_origin = cartItem._origin) === null || _cartItem$_origin === void 0 || (_cartItem$_origin = _cartItem$_origin.product) === null || _cartItem$_origin === void 0 ? void 0 : _cartItem$_origin.discount_list) || [];
|
|
58
|
+
((cartItem === null || cartItem === void 0 || (_cartItem$_origin2 = cartItem._origin) === null || _cartItem$_origin2 === void 0 || (_cartItem$_origin2 = _cartItem$_origin2.product) === null || _cartItem$_origin2 === void 0 ? void 0 : _cartItem$_origin2.product_bundle) || []).forEach(function (item) {
|
|
59
|
+
discountList = [].concat(_toConsumableArray(discountList), _toConsumableArray(item.discount_list || []));
|
|
60
|
+
item.discount_list = undefined;
|
|
61
|
+
});
|
|
62
|
+
return discountList;
|
|
54
63
|
};
|
|
@@ -26,8 +26,16 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
26
26
|
}, options?: {
|
|
27
27
|
isSelected?: boolean;
|
|
28
28
|
discountId?: number;
|
|
29
|
+
selectedList?: any[];
|
|
29
30
|
scan?: boolean;
|
|
30
31
|
}): DiscountResult;
|
|
32
|
+
/**
|
|
33
|
+
* 检查优惠是否符合 PackageSubItemUsageRules 配置
|
|
34
|
+
* @param discount 优惠券
|
|
35
|
+
* @param flatItem 扁平化后的商品项(可能是主商品或bundle子商品)
|
|
36
|
+
* @returns 是否可用
|
|
37
|
+
*/
|
|
38
|
+
private checkPackageSubItemUsageRules;
|
|
31
39
|
destroy(): Promise<void>;
|
|
32
40
|
clear(): Promise<void>;
|
|
33
41
|
}
|