@pisell/pisellos 2.1.149 → 2.1.150
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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Discount/index.d.ts +6 -2
- package/dist/modules/Discount/index.js +14 -8
- package/dist/modules/Order/index.js +3 -1
- package/dist/solution/ShopDiscount/index.d.ts +2 -1
- package/dist/solution/ShopDiscount/index.js +32 -20
- package/dist/solution/ShopDiscount/types.d.ts +1 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Discount/index.d.ts +6 -2
- package/lib/modules/Discount/index.js +3 -1
- package/lib/modules/Order/index.js +1 -1
- package/lib/solution/ShopDiscount/index.d.ts +2 -1
- package/lib/solution/ShopDiscount/index.js +10 -4
- package/lib/solution/ShopDiscount/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// 导出评估器
|
|
2
|
-
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
-
|
|
4
|
-
// 导出适配器
|
|
5
|
-
export { PromotionAdapter } from "./adapter";
|
|
6
|
-
export { default } from "./adapter";
|
|
7
|
-
|
|
8
|
-
// 导出策略配置示例常量
|
|
9
|
-
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -17,14 +17,18 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
17
17
|
setOriginalDiscountList(originalDiscountList: Discount[]): Promise<void>;
|
|
18
18
|
getOriginalDiscountList(): Discount[];
|
|
19
19
|
loadPrepareConfig(params: {
|
|
20
|
-
action?: 'create';
|
|
20
|
+
action?: 'create' | 'edit';
|
|
21
21
|
with_good_pass: 0 | 1;
|
|
22
22
|
with_discount_card: 0 | 1;
|
|
23
23
|
customer_id: number;
|
|
24
24
|
with_wallet_pass_holder: 0 | 1;
|
|
25
25
|
request_timezone: string;
|
|
26
|
+
order_id?: number;
|
|
27
|
+
}): Promise<Discount[]>;
|
|
28
|
+
batchSearch(code: string, options?: {
|
|
29
|
+
customerId?: number;
|
|
30
|
+
orderId?: number;
|
|
26
31
|
}): Promise<Discount[]>;
|
|
27
|
-
batchSearch(code: string, customerId?: number): Promise<Discount[]>;
|
|
28
32
|
batchSearchByProductIds(productIds: number[]): Promise<any>;
|
|
29
33
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
30
34
|
private checkUsageCreditsLimit;
|
|
@@ -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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
5
|
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."); }
|
|
4
6
|
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); }
|
|
@@ -176,13 +178,14 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
176
178
|
}, {
|
|
177
179
|
key: "batchSearch",
|
|
178
180
|
value: function () {
|
|
179
|
-
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code,
|
|
180
|
-
var result, resultDiscountList;
|
|
181
|
+
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, options) {
|
|
182
|
+
var _ref, customerId, orderId, result, resultDiscountList;
|
|
181
183
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
182
184
|
while (1) switch (_context5.prev = _context5.next) {
|
|
183
185
|
case 0:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
_ref = options || {}, customerId = _ref.customerId, orderId = _ref.orderId;
|
|
187
|
+
_context5.next = 3;
|
|
188
|
+
return this.request.get("/machinecode/batch-search", _objectSpread(_objectSpread({
|
|
186
189
|
code: code,
|
|
187
190
|
translate_flag: 1,
|
|
188
191
|
tags: ['good_pass', 'product_discount_card'],
|
|
@@ -190,14 +193,17 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
190
193
|
relation_product: 1,
|
|
191
194
|
with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
|
|
192
195
|
order_behavior_count: 1,
|
|
193
|
-
order_behavior_count_customer_id: customerId || 1
|
|
196
|
+
order_behavior_count_customer_id: customerId || 1
|
|
197
|
+
}, orderId ? {
|
|
198
|
+
order_behavior_count_order_id: orderId
|
|
199
|
+
} : {}), {}, {
|
|
194
200
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
195
|
-
});
|
|
196
|
-
case
|
|
201
|
+
}));
|
|
202
|
+
case 3:
|
|
197
203
|
result = _context5.sent;
|
|
198
204
|
resultDiscountList = this.filterEnabledDiscountList((result === null || result === void 0 ? void 0 : result.data) || []) || [];
|
|
199
205
|
return _context5.abrupt("return", resultDiscountList);
|
|
200
|
-
case
|
|
206
|
+
case 6:
|
|
201
207
|
case "end":
|
|
202
208
|
return _context5.stop();
|
|
203
209
|
}
|
|
@@ -233,7 +233,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
233
233
|
while (1) switch (_context3.prev = _context3.next) {
|
|
234
234
|
case 0:
|
|
235
235
|
_context3.next = 2;
|
|
236
|
-
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code,
|
|
236
|
+
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, {
|
|
237
|
+
customerId: customerId
|
|
238
|
+
});
|
|
237
239
|
case 2:
|
|
238
240
|
_context3.t0 = _context3.sent;
|
|
239
241
|
if (_context3.t0) {
|
|
@@ -29,6 +29,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
29
29
|
type?: 'form' | 'customer';
|
|
30
30
|
[key: string]: any;
|
|
31
31
|
}): void;
|
|
32
|
+
setOrderId(id?: number): void;
|
|
32
33
|
calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
|
|
33
34
|
productList: Record<string, any>[];
|
|
34
35
|
discountList: Discount[];
|
|
@@ -56,7 +57,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
56
57
|
private bestDiscount;
|
|
57
58
|
loadPrepareConfig(params: {
|
|
58
59
|
customerId: number;
|
|
59
|
-
action?: 'create' | '
|
|
60
|
+
action?: 'create' | 'edit';
|
|
60
61
|
with_good_pass?: 0 | 1;
|
|
61
62
|
with_discount_card?: 0 | 1;
|
|
62
63
|
}): Promise<void>;
|
|
@@ -56,7 +56,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
56
56
|
originalDiscountList: [],
|
|
57
57
|
currentBookingTime: "",
|
|
58
58
|
filteredDiscountList: [],
|
|
59
|
-
bookingSubject: undefined
|
|
59
|
+
bookingSubject: undefined,
|
|
60
|
+
orderId: undefined
|
|
60
61
|
};
|
|
61
62
|
return _this;
|
|
62
63
|
}
|
|
@@ -299,6 +300,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
299
300
|
value: function setBookingSubject(bookingSubject) {
|
|
300
301
|
this.store.bookingSubject = bookingSubject;
|
|
301
302
|
}
|
|
303
|
+
}, {
|
|
304
|
+
key: "setOrderId",
|
|
305
|
+
value: function setOrderId(id) {
|
|
306
|
+
this.store.orderId = id;
|
|
307
|
+
}
|
|
302
308
|
|
|
303
309
|
// 计算优惠券
|
|
304
310
|
}, {
|
|
@@ -434,7 +440,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
434
440
|
case 0:
|
|
435
441
|
_context6.prev = 0;
|
|
436
442
|
_context6.next = 3;
|
|
437
|
-
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code,
|
|
443
|
+
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, {
|
|
444
|
+
customerId: customerId,
|
|
445
|
+
orderId: this.store.orderId
|
|
446
|
+
});
|
|
438
447
|
case 3:
|
|
439
448
|
_context6.t0 = _context6.sent;
|
|
440
449
|
if (_context6.t0) {
|
|
@@ -769,24 +778,27 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
769
778
|
key: "loadPrepareConfig",
|
|
770
779
|
value: function () {
|
|
771
780
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
772
|
-
var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
781
|
+
var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2, orderId, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
773
782
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
774
783
|
while (1) switch (_context10.prev = _context10.next) {
|
|
775
784
|
case 0:
|
|
776
785
|
_context10.prev = 0;
|
|
786
|
+
orderId = this.store.orderId;
|
|
777
787
|
customerId = params.customerId || ((_this$getCustomer2 = this.getCustomer()) === null || _this$getCustomer2 === void 0 ? void 0 : _this$getCustomer2.id); // if (customerId === 1 || !customerId) {
|
|
778
788
|
// return
|
|
779
789
|
// }
|
|
780
|
-
_context10.next =
|
|
781
|
-
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.loadPrepareConfig({
|
|
790
|
+
_context10.next = 5;
|
|
791
|
+
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.loadPrepareConfig(_objectSpread({
|
|
782
792
|
customer_id: customerId,
|
|
783
|
-
action: 'create',
|
|
793
|
+
action: orderId ? 'edit' : 'create',
|
|
784
794
|
with_good_pass: 1,
|
|
785
795
|
with_discount_card: 1,
|
|
786
796
|
with_wallet_pass_holder: 1,
|
|
787
797
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
788
|
-
}
|
|
789
|
-
|
|
798
|
+
}, orderId ? {
|
|
799
|
+
order_id: orderId
|
|
800
|
+
} : {}));
|
|
801
|
+
case 5:
|
|
790
802
|
goodPassList = _context10.sent;
|
|
791
803
|
scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
|
|
792
804
|
return item.isScan;
|
|
@@ -799,35 +811,35 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
799
811
|
});
|
|
800
812
|
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
|
|
801
813
|
this.store.originalDiscountList = newDiscountList;
|
|
802
|
-
_context10.next =
|
|
814
|
+
_context10.next = 13;
|
|
803
815
|
return (_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList(newDiscountList);
|
|
804
|
-
case
|
|
816
|
+
case 13:
|
|
805
817
|
// 根据当前预约时间过滤优惠券列表
|
|
806
818
|
filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
807
819
|
this.store.filteredDiscountList = filteredDiscountList;
|
|
808
820
|
this.setDiscountList(filteredDiscountList || []);
|
|
809
821
|
if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
|
|
810
|
-
_context10.next =
|
|
822
|
+
_context10.next = 20;
|
|
811
823
|
break;
|
|
812
824
|
}
|
|
813
825
|
_result3 = this.calcDiscount(this.store.productList);
|
|
814
|
-
_context10.next =
|
|
826
|
+
_context10.next = 20;
|
|
815
827
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
816
|
-
case
|
|
817
|
-
_context10.next =
|
|
828
|
+
case 20:
|
|
829
|
+
_context10.next = 22;
|
|
818
830
|
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
|
|
819
|
-
case
|
|
820
|
-
_context10.next =
|
|
831
|
+
case 22:
|
|
832
|
+
_context10.next = 27;
|
|
821
833
|
break;
|
|
822
|
-
case
|
|
823
|
-
_context10.prev =
|
|
834
|
+
case 24:
|
|
835
|
+
_context10.prev = 24;
|
|
824
836
|
_context10.t0 = _context10["catch"](0);
|
|
825
837
|
console.error('[ShopDiscount] 加载准备配置出错:', _context10.t0);
|
|
826
|
-
case
|
|
838
|
+
case 27:
|
|
827
839
|
case "end":
|
|
828
840
|
return _context10.stop();
|
|
829
841
|
}
|
|
830
|
-
}, _callee10, this, [[0,
|
|
842
|
+
}, _callee10, this, [[0, 24]]);
|
|
831
843
|
}));
|
|
832
844
|
function loadPrepareConfig(_x10) {
|
|
833
845
|
return _loadPrepareConfig.apply(this, arguments);
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
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
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
-
var promotion_exports = {};
|
|
31
|
-
__export(promotion_exports, {
|
|
32
|
-
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
-
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
-
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
-
default: () => import_adapter2.default
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
-
var import_evaluator = require("./evaluator");
|
|
40
|
-
var import_adapter = require("./adapter");
|
|
41
|
-
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
-
var import_examples = require("./examples");
|
|
43
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
-
PromotionAdapter,
|
|
47
|
-
PromotionEvaluator,
|
|
48
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
-
});
|
|
@@ -17,14 +17,18 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
17
17
|
setOriginalDiscountList(originalDiscountList: Discount[]): Promise<void>;
|
|
18
18
|
getOriginalDiscountList(): Discount[];
|
|
19
19
|
loadPrepareConfig(params: {
|
|
20
|
-
action?: 'create';
|
|
20
|
+
action?: 'create' | 'edit';
|
|
21
21
|
with_good_pass: 0 | 1;
|
|
22
22
|
with_discount_card: 0 | 1;
|
|
23
23
|
customer_id: number;
|
|
24
24
|
with_wallet_pass_holder: 0 | 1;
|
|
25
25
|
request_timezone: string;
|
|
26
|
+
order_id?: number;
|
|
27
|
+
}): Promise<Discount[]>;
|
|
28
|
+
batchSearch(code: string, options?: {
|
|
29
|
+
customerId?: number;
|
|
30
|
+
orderId?: number;
|
|
26
31
|
}): Promise<Discount[]>;
|
|
27
|
-
batchSearch(code: string, customerId?: number): Promise<Discount[]>;
|
|
28
32
|
batchSearchByProductIds(productIds: number[]): Promise<any>;
|
|
29
33
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
30
34
|
private checkUsageCreditsLimit;
|
|
@@ -102,7 +102,8 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
102
102
|
) || [];
|
|
103
103
|
return goodPassList;
|
|
104
104
|
}
|
|
105
|
-
async batchSearch(code,
|
|
105
|
+
async batchSearch(code, options) {
|
|
106
|
+
const { customerId, orderId } = options || {};
|
|
106
107
|
const result = await this.request.get(`/machinecode/batch-search`, {
|
|
107
108
|
code,
|
|
108
109
|
translate_flag: 1,
|
|
@@ -112,6 +113,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
112
113
|
with: ["extensionData", "customScheduleSnapshot", "holder.detail"],
|
|
113
114
|
order_behavior_count: 1,
|
|
114
115
|
order_behavior_count_customer_id: customerId || 1,
|
|
116
|
+
...orderId ? { order_behavior_count_order_id: orderId } : {},
|
|
115
117
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
116
118
|
});
|
|
117
119
|
const resultDiscountList = this.filterEnabledDiscountList((result == null ? void 0 : result.data) || []) || [];
|
|
@@ -184,7 +184,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
184
184
|
}
|
|
185
185
|
async scanCode(code, customerId) {
|
|
186
186
|
var _a, _b, _c, _d;
|
|
187
|
-
const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, customerId)) || [];
|
|
187
|
+
const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId })) || [];
|
|
188
188
|
const rulesModule = this.store.rules;
|
|
189
189
|
if (!rulesModule) {
|
|
190
190
|
return {
|
|
@@ -29,6 +29,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
29
29
|
type?: 'form' | 'customer';
|
|
30
30
|
[key: string]: any;
|
|
31
31
|
}): void;
|
|
32
|
+
setOrderId(id?: number): void;
|
|
32
33
|
calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
|
|
33
34
|
productList: Record<string, any>[];
|
|
34
35
|
discountList: Discount[];
|
|
@@ -56,7 +57,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
56
57
|
private bestDiscount;
|
|
57
58
|
loadPrepareConfig(params: {
|
|
58
59
|
customerId: number;
|
|
59
|
-
action?: 'create' | '
|
|
60
|
+
action?: 'create' | 'edit';
|
|
60
61
|
with_good_pass?: 0 | 1;
|
|
61
62
|
with_discount_card?: 0 | 1;
|
|
62
63
|
}): Promise<void>;
|
|
@@ -56,7 +56,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
56
56
|
originalDiscountList: [],
|
|
57
57
|
currentBookingTime: "",
|
|
58
58
|
filteredDiscountList: [],
|
|
59
|
-
bookingSubject: void 0
|
|
59
|
+
bookingSubject: void 0,
|
|
60
|
+
orderId: void 0
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
// =========== 生命周期方法 ===========
|
|
@@ -201,6 +202,9 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
201
202
|
setBookingSubject(bookingSubject) {
|
|
202
203
|
this.store.bookingSubject = bookingSubject;
|
|
203
204
|
}
|
|
205
|
+
setOrderId(id) {
|
|
206
|
+
this.store.orderId = id;
|
|
207
|
+
}
|
|
204
208
|
// 计算优惠券
|
|
205
209
|
calcDiscount(productList, options) {
|
|
206
210
|
var _a;
|
|
@@ -277,7 +281,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
277
281
|
async scanCode(code, customerId) {
|
|
278
282
|
var _a, _b, _c;
|
|
279
283
|
try {
|
|
280
|
-
const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, customerId)) || [];
|
|
284
|
+
const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId, orderId: this.store.orderId })) || [];
|
|
281
285
|
const rulesModule = this.store.rules;
|
|
282
286
|
if (!rulesModule) {
|
|
283
287
|
return {
|
|
@@ -503,14 +507,16 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
503
507
|
async loadPrepareConfig(params) {
|
|
504
508
|
var _a, _b, _c, _d, _e;
|
|
505
509
|
try {
|
|
510
|
+
const orderId = this.store.orderId;
|
|
506
511
|
const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
|
|
507
512
|
const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
|
|
508
513
|
customer_id: customerId,
|
|
509
|
-
action: "create",
|
|
514
|
+
action: orderId ? "edit" : "create",
|
|
510
515
|
with_good_pass: 1,
|
|
511
516
|
with_discount_card: 1,
|
|
512
517
|
with_wallet_pass_holder: 1,
|
|
513
|
-
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
518
|
+
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
519
|
+
...orderId ? { order_id: orderId } : {}
|
|
514
520
|
}));
|
|
515
521
|
const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
|
|
516
522
|
(item) => item.isScan
|