@pisell/pisellos 0.0.227 → 0.0.229
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/BaseModule.js +10 -8
- package/dist/modules/Discount/index.d.ts +2 -1
- package/dist/modules/Discount/index.js +67 -4
- package/dist/modules/Discount/types.d.ts +25 -0
- package/dist/modules/ProductList/index.js +3 -4
- package/dist/solution/BookingByStep/index.js +5 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ShopDiscount/index.d.ts +1 -1
- package/dist/solution/ShopDiscount/index.js +6 -6
- package/lib/modules/BaseModule.js +3 -1
- package/lib/modules/Discount/index.d.ts +2 -1
- package/lib/modules/Discount/index.js +45 -3
- package/lib/modules/Discount/types.d.ts +25 -0
- package/lib/modules/ProductList/index.js +0 -1
- package/lib/solution/BookingByStep/index.js +5 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ShopDiscount/index.d.ts +1 -1
- package/lib/solution/ShopDiscount/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
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); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2
4
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
5
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
6
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -39,7 +41,7 @@ export var BaseModule = /*#__PURE__*/function () {
|
|
|
39
41
|
var currentCacheData = window.sessionStorage.getItem(fatherModule);
|
|
40
42
|
var currentCacheDataObj = JSON.parse(currentCacheData || '{}');
|
|
41
43
|
if (!currentCacheData || !currentCacheDataObj[cacheId]) {
|
|
42
|
-
currentCacheDataObj = _defineProperty({}, cacheId, _defineProperty({}, this.name, {}));
|
|
44
|
+
currentCacheDataObj = _objectSpread(_defineProperty({}, cacheId, _defineProperty({}, this.name, {})), currentCacheDataObj);
|
|
43
45
|
}
|
|
44
46
|
if (!currentCacheDataObj[cacheId][this.name]) {
|
|
45
47
|
currentCacheDataObj[cacheId][this.name] = {};
|
|
@@ -50,17 +52,17 @@ export var BaseModule = /*#__PURE__*/function () {
|
|
|
50
52
|
window.sessionStorage.setItem(fatherModule, JSON.stringify(currentCacheDataObj));
|
|
51
53
|
} else {
|
|
52
54
|
var _currentCacheData = window.sessionStorage.getItem(cacheId);
|
|
53
|
-
var
|
|
54
|
-
if (!
|
|
55
|
-
|
|
55
|
+
var _currentCacheDataObj = JSON.parse(_currentCacheData || '{}');
|
|
56
|
+
if (!_currentCacheDataObj) {
|
|
57
|
+
_currentCacheDataObj = {};
|
|
56
58
|
}
|
|
57
|
-
if (!
|
|
58
|
-
|
|
59
|
+
if (!_currentCacheDataObj[this.name]) {
|
|
60
|
+
_currentCacheDataObj[this.name] = {};
|
|
59
61
|
}
|
|
60
62
|
cacheKey.forEach(function (key) {
|
|
61
|
-
|
|
63
|
+
_currentCacheDataObj[_this.name][key] = store[key];
|
|
62
64
|
});
|
|
63
|
-
window.sessionStorage.setItem(cacheId, JSON.stringify(
|
|
65
|
+
window.sessionStorage.setItem(cacheId, JSON.stringify(_currentCacheDataObj));
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
}
|
|
@@ -20,8 +20,9 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
20
20
|
with_discount_card: 0 | 1;
|
|
21
21
|
customer_id: number;
|
|
22
22
|
}): Promise<Discount[]>;
|
|
23
|
-
batchSearch(code: string): Promise<Discount[]>;
|
|
23
|
+
batchSearch(code: string, customerId?: number): Promise<Discount[]>;
|
|
24
24
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
25
|
+
private checkUsageCreditsLimit;
|
|
25
26
|
uniqueByProductId(discountList: Discount[]): Discount[];
|
|
26
27
|
filterDiscountListByProductIds(discountList: Discount[], productIds: number[]): Discount[];
|
|
27
28
|
calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
|
|
@@ -145,7 +145,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
145
145
|
}, {
|
|
146
146
|
key: "batchSearch",
|
|
147
147
|
value: function () {
|
|
148
|
-
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(code) {
|
|
148
|
+
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(code, customerId) {
|
|
149
149
|
var result, resultDiscountList;
|
|
150
150
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
151
151
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -156,7 +156,10 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
156
156
|
translate_flag: 1,
|
|
157
157
|
tags: ['good_pass', 'product_discount_card'],
|
|
158
158
|
available: 1,
|
|
159
|
-
relation_product: 1
|
|
159
|
+
relation_product: 1,
|
|
160
|
+
with: ['extensionData'],
|
|
161
|
+
order_behavior_count: 1,
|
|
162
|
+
order_behavior_count_customer_id: customerId || 1
|
|
160
163
|
});
|
|
161
164
|
case 2:
|
|
162
165
|
result = _context4.sent;
|
|
@@ -168,7 +171,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
168
171
|
}
|
|
169
172
|
}, _callee4, this);
|
|
170
173
|
}));
|
|
171
|
-
function batchSearch(_x5) {
|
|
174
|
+
function batchSearch(_x5, _x6) {
|
|
172
175
|
return _batchSearch.apply(this, arguments);
|
|
173
176
|
}
|
|
174
177
|
return batchSearch;
|
|
@@ -176,11 +179,71 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
176
179
|
}, {
|
|
177
180
|
key: "filterEnabledDiscountList",
|
|
178
181
|
value: function filterEnabledDiscountList(discountList) {
|
|
182
|
+
var _this2 = this;
|
|
179
183
|
return discountList.filter(function (discount) {
|
|
180
|
-
return discount.limit_status === 'enable' && new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0);
|
|
184
|
+
return discount.limit_status === 'enable' && new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0) && _this2.checkUsageCreditsLimit(discount);
|
|
181
185
|
});
|
|
182
186
|
}
|
|
183
187
|
|
|
188
|
+
// 检查使用次数限制
|
|
189
|
+
}, {
|
|
190
|
+
key: "checkUsageCreditsLimit",
|
|
191
|
+
value: function checkUsageCreditsLimit(discount) {
|
|
192
|
+
// 如果没有 extension_data,则不需要限制
|
|
193
|
+
if (!discount.extension_data || discount.extension_data.length === 0) {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// 查找 field_key 为 usage_credits 的数据
|
|
198
|
+
var usageCreditsData = discount.extension_data.find(function (data) {
|
|
199
|
+
return data.field_key === 'usage_credits';
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// 如果没有找到 usage_credits 数据,则不需要限制
|
|
203
|
+
if (!usageCreditsData) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
var value = usageCreditsData.value;
|
|
207
|
+
|
|
208
|
+
// 检查总次数限制
|
|
209
|
+
if (value.total_credits && value.total_credits > 0) {
|
|
210
|
+
if ((discount.total_order_behavior_count || 0) >= value.total_credits) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// 检查单用户限制
|
|
216
|
+
if (value.per_user_limit && value.per_user_limit > 0) {
|
|
217
|
+
if ((discount.customer_order_behavior_count || 0) >= value.per_user_limit) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// 检查单日限制
|
|
223
|
+
if (value.max_per_day && value.max_per_day > 0) {
|
|
224
|
+
if ((discount.today_order_behavior_count || 0) >= value.max_per_day) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// 检查单周限制
|
|
230
|
+
if (value.max_per_week && value.max_per_week > 0) {
|
|
231
|
+
if ((discount.week_order_behavior_count || 0) >= value.max_per_week) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// 检查单月限制
|
|
237
|
+
if (value.max_per_month && value.max_per_month > 0) {
|
|
238
|
+
if ((discount.month_order_behavior_count || 0) >= value.max_per_month) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// 所有检查都通过
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
|
|
184
247
|
// 根据productIds去重
|
|
185
248
|
}, {
|
|
186
249
|
key: "uniqueByProductId",
|
|
@@ -36,6 +36,25 @@ interface ApplicableProductDetails {
|
|
|
36
36
|
title?: string;
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
+
interface UsageCreditsValue {
|
|
40
|
+
total_credits: number;
|
|
41
|
+
per_user_limit: number;
|
|
42
|
+
max_per_day: number;
|
|
43
|
+
max_per_week: number;
|
|
44
|
+
max_per_month: number;
|
|
45
|
+
}
|
|
46
|
+
interface ExtensionData {
|
|
47
|
+
id: number;
|
|
48
|
+
shop_id: number;
|
|
49
|
+
product_id: number;
|
|
50
|
+
field_id: number;
|
|
51
|
+
field_key: string;
|
|
52
|
+
type: string;
|
|
53
|
+
value: UsageCreditsValue | Record<string, any> | string | number | boolean | any[];
|
|
54
|
+
created_at: string | null;
|
|
55
|
+
updated_at: string | null;
|
|
56
|
+
deleted_at: string | null;
|
|
57
|
+
}
|
|
39
58
|
export interface Discount {
|
|
40
59
|
id: number;
|
|
41
60
|
product_name: string;
|
|
@@ -70,6 +89,12 @@ export interface Discount {
|
|
|
70
89
|
appliedProductDetails: ApplicableProductDetails[];
|
|
71
90
|
isDisabledForProductUsed?: boolean;
|
|
72
91
|
amount?: number;
|
|
92
|
+
extension_data?: ExtensionData[];
|
|
93
|
+
total_order_behavior_count?: number;
|
|
94
|
+
today_order_behavior_count?: number;
|
|
95
|
+
week_order_behavior_count?: number;
|
|
96
|
+
month_order_behavior_count?: number;
|
|
97
|
+
customer_order_behavior_count?: number;
|
|
73
98
|
}
|
|
74
99
|
export interface DiscountState {
|
|
75
100
|
discountList: Discount[];
|
|
@@ -111,9 +111,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
111
111
|
} catch (error) {
|
|
112
112
|
console.error(error);
|
|
113
113
|
}
|
|
114
|
-
debugger;
|
|
115
114
|
// 如果没传schedule_date,则从
|
|
116
|
-
_context3.next =
|
|
115
|
+
_context3.next = 6;
|
|
117
116
|
return this.request.post("/product/query", {
|
|
118
117
|
open_quotation: 1,
|
|
119
118
|
open_bundle: 0,
|
|
@@ -137,14 +136,14 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
137
136
|
}, {
|
|
138
137
|
useCache: true
|
|
139
138
|
});
|
|
140
|
-
case
|
|
139
|
+
case 6:
|
|
141
140
|
productsData = _context3.sent;
|
|
142
141
|
sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
|
|
143
142
|
return Number(b.sort) - Number(a.sort);
|
|
144
143
|
});
|
|
145
144
|
this.addProduct(sortedList);
|
|
146
145
|
return _context3.abrupt("return", sortedList);
|
|
147
|
-
case
|
|
146
|
+
case 10:
|
|
148
147
|
case "end":
|
|
149
148
|
return _context3.stop();
|
|
150
149
|
}
|
|
@@ -1281,7 +1281,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1281
1281
|
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
1282
1282
|
if (!allOriginResources.length) {
|
|
1283
1283
|
var dateList = this.store.date.getDateList();
|
|
1284
|
-
dateList.forEach(function (n) {
|
|
1284
|
+
dateList === null || dateList === void 0 || dateList.forEach(function (n) {
|
|
1285
1285
|
if (n.resource) allOriginResources.push.apply(allOriginResources, _toConsumableArray(n.resource));
|
|
1286
1286
|
});
|
|
1287
1287
|
}
|
|
@@ -1417,13 +1417,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1417
1417
|
}, {
|
|
1418
1418
|
key: "destroy",
|
|
1419
1419
|
value: function destroy() {
|
|
1420
|
-
var _this$store$cart, _this$store$step, _this$store$products, _this$store$guests, _this$store$date, _this$store$accountLi;
|
|
1420
|
+
var _this$store$cart, _this$store$step, _this$store$products, _this$store$guests, _this$store$date, _this$store$accountLi, _this$store$schedule, _this$store$summary, _this$store$order;
|
|
1421
1421
|
(_this$store$cart = this.store.cart) === null || _this$store$cart === void 0 || _this$store$cart.destroy();
|
|
1422
1422
|
(_this$store$step = this.store.step) === null || _this$store$step === void 0 || _this$store$step.destroy();
|
|
1423
1423
|
(_this$store$products = this.store.products) === null || _this$store$products === void 0 || _this$store$products.destroy();
|
|
1424
1424
|
(_this$store$guests = this.store.guests) === null || _this$store$guests === void 0 || _this$store$guests.destroy();
|
|
1425
1425
|
(_this$store$date = this.store.date) === null || _this$store$date === void 0 || _this$store$date.destroy();
|
|
1426
1426
|
(_this$store$accountLi = this.store.accountList) === null || _this$store$accountLi === void 0 || _this$store$accountLi.destroy();
|
|
1427
|
+
(_this$store$schedule = this.store.schedule) === null || _this$store$schedule === void 0 || _this$store$schedule.destroy();
|
|
1428
|
+
(_this$store$summary = this.store.summary) === null || _this$store$summary === void 0 || _this$store$summary.destroy();
|
|
1429
|
+
(_this$store$order = this.store.order) === null || _this$store$order === void 0 || _this$store$order.destroy();
|
|
1427
1430
|
this.core.effects.offByModuleDestroy(this.name);
|
|
1428
1431
|
this.core.unregisterModule(this);
|
|
1429
1432
|
}
|
|
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
111
111
|
* 获取当前的客户搜索条件
|
|
112
112
|
* @returns 当前搜索条件
|
|
113
113
|
*/
|
|
114
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
114
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
115
115
|
/**
|
|
116
116
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
117
117
|
* @returns 客户状态
|
|
@@ -34,7 +34,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
34
34
|
discountList: Discount[];
|
|
35
35
|
};
|
|
36
36
|
setProductList(productList: Record<string, any>[]): void;
|
|
37
|
-
scanCode(code: string): Promise<{
|
|
37
|
+
scanCode(code: string, customerId?: number): Promise<{
|
|
38
38
|
isAvailable: boolean;
|
|
39
39
|
productList: Record<string, any>[];
|
|
40
40
|
discountList: Discount[];
|
|
@@ -305,14 +305,14 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
305
305
|
}, {
|
|
306
306
|
key: "scanCode",
|
|
307
307
|
value: function () {
|
|
308
|
-
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code) {
|
|
308
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
|
|
309
309
|
var _this$store$discount3, resultDiscountList, rulesModule, withScanList, _ref3, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
|
|
310
310
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
311
311
|
while (1) switch (_context5.prev = _context5.next) {
|
|
312
312
|
case 0:
|
|
313
313
|
_context5.prev = 0;
|
|
314
314
|
_context5.next = 3;
|
|
315
|
-
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.batchSearch(code);
|
|
315
|
+
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.batchSearch(code, customerId);
|
|
316
316
|
case 3:
|
|
317
317
|
_context5.t0 = _context5.sent;
|
|
318
318
|
if (_context5.t0) {
|
|
@@ -394,7 +394,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
394
394
|
}
|
|
395
395
|
}, _callee5, this, [[0, 23]]);
|
|
396
396
|
}));
|
|
397
|
-
function scanCode(_x4) {
|
|
397
|
+
function scanCode(_x4, _x5) {
|
|
398
398
|
return _scanCode.apply(this, arguments);
|
|
399
399
|
}
|
|
400
400
|
return scanCode;
|
|
@@ -439,7 +439,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
439
439
|
}
|
|
440
440
|
}, _callee6, this);
|
|
441
441
|
}));
|
|
442
|
-
function emitDiscountListChange(
|
|
442
|
+
function emitDiscountListChange(_x6) {
|
|
443
443
|
return _emitDiscountListChange.apply(this, arguments);
|
|
444
444
|
}
|
|
445
445
|
return emitDiscountListChange;
|
|
@@ -576,7 +576,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
576
576
|
}
|
|
577
577
|
}, _callee7, this, [[0, 11]]);
|
|
578
578
|
}));
|
|
579
|
-
function getCustomerWallet(
|
|
579
|
+
function getCustomerWallet(_x7) {
|
|
580
580
|
return _getCustomerWallet.apply(this, arguments);
|
|
581
581
|
}
|
|
582
582
|
return getCustomerWallet;
|
|
@@ -636,7 +636,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
636
636
|
}
|
|
637
637
|
}, _callee8, this, [[0, 18]]);
|
|
638
638
|
}));
|
|
639
|
-
function loadPrepareConfig(
|
|
639
|
+
function loadPrepareConfig(_x8) {
|
|
640
640
|
return _loadPrepareConfig.apply(this, arguments);
|
|
641
641
|
}
|
|
642
642
|
return loadPrepareConfig;
|
|
@@ -20,8 +20,9 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
20
20
|
with_discount_card: 0 | 1;
|
|
21
21
|
customer_id: number;
|
|
22
22
|
}): Promise<Discount[]>;
|
|
23
|
-
batchSearch(code: string): Promise<Discount[]>;
|
|
23
|
+
batchSearch(code: string, customerId?: number): Promise<Discount[]>;
|
|
24
24
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
25
|
+
private checkUsageCreditsLimit;
|
|
25
26
|
uniqueByProductId(discountList: Discount[]): Discount[];
|
|
26
27
|
filterDiscountListByProductIds(discountList: Discount[], productIds: number[]): Discount[];
|
|
27
28
|
calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
|
|
@@ -89,22 +89,64 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
89
89
|
) || [];
|
|
90
90
|
return goodPassList;
|
|
91
91
|
}
|
|
92
|
-
async batchSearch(code) {
|
|
92
|
+
async batchSearch(code, customerId) {
|
|
93
93
|
const result = await this.request.get(`/machinecode/batch-search`, {
|
|
94
94
|
code,
|
|
95
95
|
translate_flag: 1,
|
|
96
96
|
tags: ["good_pass", "product_discount_card"],
|
|
97
97
|
available: 1,
|
|
98
|
-
relation_product: 1
|
|
98
|
+
relation_product: 1,
|
|
99
|
+
with: ["extensionData"],
|
|
100
|
+
order_behavior_count: 1,
|
|
101
|
+
order_behavior_count_customer_id: customerId || 1
|
|
99
102
|
});
|
|
100
103
|
const resultDiscountList = this.filterEnabledDiscountList((result == null ? void 0 : result.data) || []) || [];
|
|
101
104
|
return resultDiscountList;
|
|
102
105
|
}
|
|
103
106
|
filterEnabledDiscountList(discountList) {
|
|
104
107
|
return discountList.filter(
|
|
105
|
-
(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)
|
|
108
|
+
(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) && this.checkUsageCreditsLimit(discount)
|
|
106
109
|
);
|
|
107
110
|
}
|
|
111
|
+
// 检查使用次数限制
|
|
112
|
+
checkUsageCreditsLimit(discount) {
|
|
113
|
+
if (!discount.extension_data || discount.extension_data.length === 0) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
const usageCreditsData = discount.extension_data.find(
|
|
117
|
+
(data) => data.field_key === "usage_credits"
|
|
118
|
+
);
|
|
119
|
+
if (!usageCreditsData) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
const value = usageCreditsData.value;
|
|
123
|
+
if (value.total_credits && value.total_credits > 0) {
|
|
124
|
+
if ((discount.total_order_behavior_count || 0) >= value.total_credits) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (value.per_user_limit && value.per_user_limit > 0) {
|
|
129
|
+
if ((discount.customer_order_behavior_count || 0) >= value.per_user_limit) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (value.max_per_day && value.max_per_day > 0) {
|
|
134
|
+
if ((discount.today_order_behavior_count || 0) >= value.max_per_day) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (value.max_per_week && value.max_per_week > 0) {
|
|
139
|
+
if ((discount.week_order_behavior_count || 0) >= value.max_per_week) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (value.max_per_month && value.max_per_month > 0) {
|
|
144
|
+
if ((discount.month_order_behavior_count || 0) >= value.max_per_month) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
108
150
|
// 根据productIds去重
|
|
109
151
|
uniqueByProductId(discountList) {
|
|
110
152
|
return (0, import_utils.uniqueById)(discountList, "product_id");
|
|
@@ -36,6 +36,25 @@ interface ApplicableProductDetails {
|
|
|
36
36
|
title?: string;
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
+
interface UsageCreditsValue {
|
|
40
|
+
total_credits: number;
|
|
41
|
+
per_user_limit: number;
|
|
42
|
+
max_per_day: number;
|
|
43
|
+
max_per_week: number;
|
|
44
|
+
max_per_month: number;
|
|
45
|
+
}
|
|
46
|
+
interface ExtensionData {
|
|
47
|
+
id: number;
|
|
48
|
+
shop_id: number;
|
|
49
|
+
product_id: number;
|
|
50
|
+
field_id: number;
|
|
51
|
+
field_key: string;
|
|
52
|
+
type: string;
|
|
53
|
+
value: UsageCreditsValue | Record<string, any> | string | number | boolean | any[];
|
|
54
|
+
created_at: string | null;
|
|
55
|
+
updated_at: string | null;
|
|
56
|
+
deleted_at: string | null;
|
|
57
|
+
}
|
|
39
58
|
export interface Discount {
|
|
40
59
|
id: number;
|
|
41
60
|
product_name: string;
|
|
@@ -70,6 +89,12 @@ export interface Discount {
|
|
|
70
89
|
appliedProductDetails: ApplicableProductDetails[];
|
|
71
90
|
isDisabledForProductUsed?: boolean;
|
|
72
91
|
amount?: number;
|
|
92
|
+
extension_data?: ExtensionData[];
|
|
93
|
+
total_order_behavior_count?: number;
|
|
94
|
+
today_order_behavior_count?: number;
|
|
95
|
+
week_order_behavior_count?: number;
|
|
96
|
+
month_order_behavior_count?: number;
|
|
97
|
+
customer_order_behavior_count?: number;
|
|
73
98
|
}
|
|
74
99
|
export interface DiscountState {
|
|
75
100
|
discountList: Discount[];
|
|
@@ -693,7 +693,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
693
693
|
}
|
|
694
694
|
if (!allOriginResources.length) {
|
|
695
695
|
const dateList = this.store.date.getDateList();
|
|
696
|
-
dateList.forEach((n) => {
|
|
696
|
+
dateList == null ? void 0 : dateList.forEach((n) => {
|
|
697
697
|
if (n.resource)
|
|
698
698
|
allOriginResources.push(...n.resource);
|
|
699
699
|
});
|
|
@@ -808,13 +808,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
808
808
|
return errorCartItemIds;
|
|
809
809
|
}
|
|
810
810
|
destroy() {
|
|
811
|
-
var _a, _b, _c, _d, _e, _f;
|
|
811
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
812
812
|
(_a = this.store.cart) == null ? void 0 : _a.destroy();
|
|
813
813
|
(_b = this.store.step) == null ? void 0 : _b.destroy();
|
|
814
814
|
(_c = this.store.products) == null ? void 0 : _c.destroy();
|
|
815
815
|
(_d = this.store.guests) == null ? void 0 : _d.destroy();
|
|
816
816
|
(_e = this.store.date) == null ? void 0 : _e.destroy();
|
|
817
817
|
(_f = this.store.accountList) == null ? void 0 : _f.destroy();
|
|
818
|
+
(_g = this.store.schedule) == null ? void 0 : _g.destroy();
|
|
819
|
+
(_h = this.store.summary) == null ? void 0 : _h.destroy();
|
|
820
|
+
(_i = this.store.order) == null ? void 0 : _i.destroy();
|
|
818
821
|
this.core.effects.offByModuleDestroy(this.name);
|
|
819
822
|
this.core.unregisterModule(this);
|
|
820
823
|
}
|
|
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
111
111
|
* 获取当前的客户搜索条件
|
|
112
112
|
* @returns 当前搜索条件
|
|
113
113
|
*/
|
|
114
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
114
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
115
115
|
/**
|
|
116
116
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
117
117
|
* @returns 客户状态
|
|
@@ -34,7 +34,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
34
34
|
discountList: Discount[];
|
|
35
35
|
};
|
|
36
36
|
setProductList(productList: Record<string, any>[]): void;
|
|
37
|
-
scanCode(code: string): Promise<{
|
|
37
|
+
scanCode(code: string, customerId?: number): Promise<{
|
|
38
38
|
isAvailable: boolean;
|
|
39
39
|
productList: Record<string, any>[];
|
|
40
40
|
discountList: Discount[];
|
|
@@ -199,10 +199,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
199
199
|
this.store.productList = productList;
|
|
200
200
|
}
|
|
201
201
|
// 扫码输入code
|
|
202
|
-
async scanCode(code) {
|
|
202
|
+
async scanCode(code, customerId) {
|
|
203
203
|
var _a, _b;
|
|
204
204
|
try {
|
|
205
|
-
const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code)) || [];
|
|
205
|
+
const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, customerId)) || [];
|
|
206
206
|
const rulesModule = this.store.rules;
|
|
207
207
|
if (!rulesModule) {
|
|
208
208
|
return {
|