@pisell/pisellos 0.0.224 → 0.0.226
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/ProductList/index.d.ts +1 -0
- package/dist/modules/ProductList/index.js +10 -5
- package/dist/modules/Rules/index.js +20 -9
- package/lib/modules/ProductList/index.d.ts +1 -0
- package/lib/modules/ProductList/index.js +6 -2
- package/lib/modules/Rules/index.js +16 -9
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
8
8
|
protected defaultVersion: string;
|
|
9
9
|
private store;
|
|
10
10
|
private request;
|
|
11
|
+
private otherParams;
|
|
11
12
|
constructor(name?: string, version?: string);
|
|
12
13
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
13
14
|
storeChange(path?: string, value?: any): Promise<void>;
|
|
@@ -31,6 +31,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
31
31
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
32
32
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
33
33
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
34
35
|
return _this;
|
|
35
36
|
}
|
|
36
37
|
_createClass(ProductList, [{
|
|
@@ -43,6 +44,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
43
44
|
case 0:
|
|
44
45
|
this.core = core;
|
|
45
46
|
this.store = options.store;
|
|
47
|
+
this.otherParams = options.otherParams || {};
|
|
46
48
|
if (Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
|
|
47
49
|
this.store.list = options.initialState.list;
|
|
48
50
|
this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
|
|
@@ -53,7 +55,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
53
55
|
this.store.selectProducts = [];
|
|
54
56
|
}
|
|
55
57
|
this.request = core.getPlugin('request');
|
|
56
|
-
case
|
|
58
|
+
case 5:
|
|
57
59
|
case "end":
|
|
58
60
|
return _context.stop();
|
|
59
61
|
}
|
|
@@ -100,6 +102,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
100
102
|
key: "loadProducts",
|
|
101
103
|
value: function () {
|
|
102
104
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
|
|
105
|
+
var _this$otherParams;
|
|
103
106
|
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$menu_list_ids, menu_list_ids, paramsCustomerId, _ref$with_count, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, userPlugin, customer_id, _userPlugin$get, productsData;
|
|
104
107
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
105
108
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -124,8 +127,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
124
127
|
} catch (error) {
|
|
125
128
|
console.error(error);
|
|
126
129
|
}
|
|
130
|
+
debugger;
|
|
127
131
|
// 如果没传schedule_date,则从
|
|
128
|
-
_context3.next =
|
|
132
|
+
_context3.next = 7;
|
|
129
133
|
return this.request.post("/product/query", {
|
|
130
134
|
open_quotation: 1,
|
|
131
135
|
open_bundle: 0,
|
|
@@ -144,15 +148,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
144
148
|
// client_schedule_ids: schedule_ids,
|
|
145
149
|
schedule_date: schedule_date,
|
|
146
150
|
with_schedule: with_schedule,
|
|
147
|
-
schedule_datetime: schedule_datetime
|
|
151
|
+
schedule_datetime: schedule_datetime,
|
|
152
|
+
application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel
|
|
148
153
|
}, {
|
|
149
154
|
useCache: true
|
|
150
155
|
});
|
|
151
|
-
case
|
|
156
|
+
case 7:
|
|
152
157
|
productsData = _context3.sent;
|
|
153
158
|
this.addProduct(productsData.data.list);
|
|
154
159
|
return _context3.abrupt("return", productsData.data.list);
|
|
155
|
-
case
|
|
160
|
+
case 10:
|
|
156
161
|
case "end":
|
|
157
162
|
return _context3.stop();
|
|
158
163
|
}
|
|
@@ -297,19 +297,25 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
297
297
|
|
|
298
298
|
// 记录可抵扣的商品详情
|
|
299
299
|
var applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
300
|
-
|
|
300
|
+
var discountType = discount.tag || discount.type;
|
|
301
|
+
var productData = {
|
|
301
302
|
amount: product.price,
|
|
302
|
-
type:
|
|
303
|
-
tag:
|
|
303
|
+
type: discountType,
|
|
304
|
+
tag: discountType,
|
|
304
305
|
discount: {
|
|
305
306
|
resource_id: discount.id,
|
|
306
307
|
title: discount.format_title,
|
|
307
308
|
original_amount: product.origin_total,
|
|
308
309
|
pre_value: discount.par_value,
|
|
309
310
|
product_id: originProduct.id
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// 如果 discount.tag 或者 discount.type 是 good_pass,则不需要添加 num 属性
|
|
315
|
+
if (discountType !== 'good_pass') {
|
|
316
|
+
productData.num = product.num || 1;
|
|
317
|
+
}
|
|
318
|
+
applicableProducts.push(productData);
|
|
313
319
|
discountApplicableProducts.set(discount.id, applicableProducts);
|
|
314
320
|
}
|
|
315
321
|
});
|
|
@@ -451,18 +457,23 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
451
457
|
|
|
452
458
|
// 计算使用折扣卡/商品券以后,单个商品的总 total
|
|
453
459
|
var targetProductTotal = _selectedDiscount.tag === 'good_pass' ? new Decimal(productOriginTotal).minus(new Decimal(product.price || 0)).toNumber() : new Decimal(100).minus(_selectedDiscount.par_value || 0).div(100).mul(new Decimal(productOriginTotal)).toNumber();
|
|
460
|
+
var discountType = _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag;
|
|
454
461
|
var discountDetail = {
|
|
455
462
|
amount: new Decimal(productOriginTotal).minus(new Decimal(targetProductTotal)).toNumber(),
|
|
456
|
-
type:
|
|
463
|
+
type: discountType,
|
|
457
464
|
discount: {
|
|
458
465
|
resource_id: _selectedDiscount.id,
|
|
459
466
|
title: _selectedDiscount.format_title,
|
|
460
467
|
original_amount: productOriginTotal,
|
|
461
468
|
product_id: originProduct.id,
|
|
462
469
|
percent: _selectedDiscount.par_value
|
|
463
|
-
}
|
|
464
|
-
num: product.num || 1
|
|
470
|
+
}
|
|
465
471
|
};
|
|
472
|
+
|
|
473
|
+
// 如果 discount.tag 或者 discount.type 是 good_pass,则不需要添加 num 属性
|
|
474
|
+
if ((_selectedDiscount.tag || _selectedDiscount.type) !== 'good_pass') {
|
|
475
|
+
discountDetail.num = product.num || 1;
|
|
476
|
+
}
|
|
466
477
|
appliedProducts.push(discountDetail);
|
|
467
478
|
appliedDiscountProducts.set(_selectedDiscount.id, appliedProducts);
|
|
468
479
|
|
|
@@ -8,6 +8,7 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
8
8
|
protected defaultVersion: string;
|
|
9
9
|
private store;
|
|
10
10
|
private request;
|
|
11
|
+
private otherParams;
|
|
11
12
|
constructor(name?: string, version?: string);
|
|
12
13
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
13
14
|
storeChange(path?: string, value?: any): Promise<void>;
|
|
@@ -33,11 +33,13 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
33
33
|
super(name, version);
|
|
34
34
|
this.defaultName = "productList";
|
|
35
35
|
this.defaultVersion = "1.0.0";
|
|
36
|
+
this.otherParams = {};
|
|
36
37
|
}
|
|
37
38
|
async initialize(core, options) {
|
|
38
39
|
var _a;
|
|
39
40
|
this.core = core;
|
|
40
41
|
this.store = options.store;
|
|
42
|
+
this.otherParams = options.otherParams || {};
|
|
41
43
|
if (Array.isArray((_a = options.initialState) == null ? void 0 : _a.list)) {
|
|
42
44
|
this.store.list = options.initialState.list;
|
|
43
45
|
this.core.effects.emit(`${this.name}:changed`, this.store.list);
|
|
@@ -76,7 +78,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
76
78
|
cacheId,
|
|
77
79
|
with_schedule
|
|
78
80
|
}) {
|
|
79
|
-
var _a;
|
|
81
|
+
var _a, _b;
|
|
80
82
|
let userPlugin = this.core.getPlugin("user");
|
|
81
83
|
let customer_id = void 0;
|
|
82
84
|
try {
|
|
@@ -84,6 +86,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
84
86
|
} catch (error) {
|
|
85
87
|
console.error(error);
|
|
86
88
|
}
|
|
89
|
+
debugger;
|
|
87
90
|
const productsData = await this.request.post(
|
|
88
91
|
`/product/query`,
|
|
89
92
|
{
|
|
@@ -111,7 +114,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
111
114
|
// client_schedule_ids: schedule_ids,
|
|
112
115
|
schedule_date,
|
|
113
116
|
with_schedule,
|
|
114
|
-
schedule_datetime
|
|
117
|
+
schedule_datetime,
|
|
118
|
+
application_code: (_b = this.otherParams) == null ? void 0 : _b.channel
|
|
115
119
|
},
|
|
116
120
|
{ useCache: true }
|
|
117
121
|
);
|
|
@@ -189,19 +189,23 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
189
189
|
if (isAvailableProduct && isLimitedProduct) {
|
|
190
190
|
(_c = discountApplicability.get(discount.id)) == null ? void 0 : _c.push(product.id);
|
|
191
191
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
192
|
-
|
|
192
|
+
const discountType = discount.tag || discount.type;
|
|
193
|
+
const productData = {
|
|
193
194
|
amount: product.price,
|
|
194
|
-
type:
|
|
195
|
-
tag:
|
|
195
|
+
type: discountType,
|
|
196
|
+
tag: discountType,
|
|
196
197
|
discount: {
|
|
197
198
|
resource_id: discount.id,
|
|
198
199
|
title: discount.format_title,
|
|
199
200
|
original_amount: product.origin_total,
|
|
200
201
|
pre_value: discount.par_value,
|
|
201
202
|
product_id: originProduct.id
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
if (discountType !== "good_pass") {
|
|
206
|
+
productData.num = product.num || 1;
|
|
207
|
+
}
|
|
208
|
+
applicableProducts.push(productData);
|
|
205
209
|
discountApplicableProducts.set(discount.id, applicableProducts);
|
|
206
210
|
}
|
|
207
211
|
});
|
|
@@ -310,18 +314,21 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
310
314
|
productOriginTotal = product.total;
|
|
311
315
|
}
|
|
312
316
|
const targetProductTotal = selectedDiscount2.tag === "good_pass" ? new import_decimal.default(productOriginTotal).minus(new import_decimal.default(product.price || 0)).toNumber() : new import_decimal.default(100).minus(selectedDiscount2.par_value || 0).div(100).mul(new import_decimal.default(productOriginTotal)).toNumber();
|
|
317
|
+
const discountType = selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag;
|
|
313
318
|
const discountDetail = {
|
|
314
319
|
amount: new import_decimal.default(productOriginTotal).minus(new import_decimal.default(targetProductTotal)).toNumber(),
|
|
315
|
-
type:
|
|
320
|
+
type: discountType,
|
|
316
321
|
discount: {
|
|
317
322
|
resource_id: selectedDiscount2.id,
|
|
318
323
|
title: selectedDiscount2.format_title,
|
|
319
324
|
original_amount: productOriginTotal,
|
|
320
325
|
product_id: originProduct.id,
|
|
321
326
|
percent: selectedDiscount2.par_value
|
|
322
|
-
}
|
|
323
|
-
num: product.num || 1
|
|
327
|
+
}
|
|
324
328
|
};
|
|
329
|
+
if ((selectedDiscount2.tag || selectedDiscount2.type) !== "good_pass") {
|
|
330
|
+
discountDetail.num = product.num || 1;
|
|
331
|
+
}
|
|
325
332
|
appliedProducts.push(discountDetail);
|
|
326
333
|
appliedDiscountProducts.set(selectedDiscount2.id, appliedProducts);
|
|
327
334
|
if (product.isClient) {
|