@pisell/pisellos 1.0.145 → 1.0.147
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 +9 -0
- package/dist/modules/Cart/utils/changePrice.js +16 -9
- package/dist/modules/Discount/index.d.ts +2 -1
- package/dist/solution/ShopDiscount/index.d.ts +2 -1
- package/dist/solution/ShopDiscount/index.js +28 -19
- package/dist/solution/ShopDiscount/types.d.ts +1 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Cart/utils/changePrice.js +13 -9
- package/lib/modules/Discount/index.d.ts +2 -1
- package/lib/solution/ShopDiscount/index.d.ts +2 -1
- package/lib/solution/ShopDiscount/index.js +9 -3
- package/lib/solution/ShopDiscount/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
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";
|
|
@@ -23,8 +23,8 @@ function _updateAllCartItemPrice() {
|
|
|
23
23
|
_iterator = _createForOfIteratorHelper(cartItems);
|
|
24
24
|
_context2.prev = 1;
|
|
25
25
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
26
|
-
var _item$_productOrigin, _bundle;
|
|
27
|
-
var item, targetProduct, cartProduct, productInfo, bundle, _productInfo$variant;
|
|
26
|
+
var _item$_productOrigin$, _item$_productOrigin, _item$_origin, _targetProduct$varian, _ref, _targetVariant$price, _ref2, _targetVariant$base_p, _item$_productOrigin2, _bundle;
|
|
27
|
+
var item, targetProduct, cartProduct, productInfo, variantId, targetVariant, bundle, _productInfo$variant;
|
|
28
28
|
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
29
29
|
while (1) switch (_context.prev = _context.next) {
|
|
30
30
|
case 0:
|
|
@@ -40,10 +40,17 @@ function _updateAllCartItemPrice() {
|
|
|
40
40
|
if (!productInfo) {
|
|
41
41
|
productInfo = item._productOrigin;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
|
|
44
|
+
// 查找选择的规格id
|
|
45
|
+
variantId = (_item$_productOrigin$ = item === null || item === void 0 || (_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 ? void 0 : _item$_productOrigin.product_variant_id) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : item === null || item === void 0 || (_item$_origin = item._origin) === null || _item$_origin === void 0 || (_item$_origin = _item$_origin.product) === null || _item$_origin === void 0 ? void 0 : _item$_origin.product_variant_id;
|
|
46
|
+
targetVariant = targetProduct === null || targetProduct === void 0 || (_targetProduct$varian = targetProduct.variant) === null || _targetProduct$varian === void 0 ? void 0 : _targetProduct$varian.find(function (variant) {
|
|
47
|
+
return Number(variant.id) === Number(variantId);
|
|
48
|
+
});
|
|
49
|
+
bundle = item._bundleOrigin; // productInfo.price = targetProduct?.price;
|
|
50
|
+
// productInfo.base_price = targetProduct?.base_price;
|
|
51
|
+
productInfo.price = (_ref = (_targetVariant$price = targetVariant === null || targetVariant === void 0 ? void 0 : targetVariant.price) !== null && _targetVariant$price !== void 0 ? _targetVariant$price : targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.price) !== null && _ref !== void 0 ? _ref : productInfo.price;
|
|
52
|
+
productInfo.base_price = (_ref2 = (_targetVariant$base_p = targetVariant === null || targetVariant === void 0 ? void 0 : targetVariant.base_price) !== null && _targetVariant$base_p !== void 0 ? _targetVariant$base_p : targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.base_price) !== null && _ref2 !== void 0 ? _ref2 : productInfo.base_price;
|
|
53
|
+
productInfo.product_variant_id = (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.product_variant_id;
|
|
47
54
|
bundle = (_bundle = bundle) === null || _bundle === void 0 ? void 0 : _bundle.map(function (n) {
|
|
48
55
|
var _targetProduct$bundle;
|
|
49
56
|
// 更新 bundle 的价格
|
|
@@ -75,8 +82,8 @@ function _updateAllCartItemPrice() {
|
|
|
75
82
|
// 如果有返回variant,则把对应variant的数据也补充进去
|
|
76
83
|
if (targetProduct !== null && targetProduct !== void 0 && targetProduct.variant) {
|
|
77
84
|
productInfo.variant = (_productInfo$variant = productInfo.variant) === null || _productInfo$variant === void 0 ? void 0 : _productInfo$variant.map(function (n) {
|
|
78
|
-
var _targetProduct$
|
|
79
|
-
var targetVariant = (_targetProduct$
|
|
85
|
+
var _targetProduct$varian2;
|
|
86
|
+
var targetVariant = (_targetProduct$varian2 = targetProduct.variant) === null || _targetProduct$varian2 === void 0 ? void 0 : _targetProduct$varian2.find(function (m) {
|
|
80
87
|
return m.id === n.id;
|
|
81
88
|
});
|
|
82
89
|
if (targetVariant) {
|
|
@@ -99,7 +106,7 @@ function _updateAllCartItemPrice() {
|
|
|
99
106
|
bundle: bundle,
|
|
100
107
|
options: item._optionsOrigin
|
|
101
108
|
});
|
|
102
|
-
case
|
|
109
|
+
case 17:
|
|
103
110
|
case "end":
|
|
104
111
|
return _context.stop();
|
|
105
112
|
}
|
|
@@ -17,12 +17,13 @@ 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;
|
|
26
27
|
}): Promise<Discount[]>;
|
|
27
28
|
batchSearch(code: string, customerId?: number): Promise<DiscountWithReason>;
|
|
28
29
|
batchSearchByProductIds(productIds: number[]): Promise<any>;
|
|
@@ -26,6 +26,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
26
26
|
setHolders(holders: {
|
|
27
27
|
form_record_id: number;
|
|
28
28
|
}[]): void;
|
|
29
|
+
setOrderId(id?: number): void;
|
|
29
30
|
setBookingSubject(bookingSubject: {
|
|
30
31
|
type?: 'form' | 'customer';
|
|
31
32
|
[key: string]: any;
|
|
@@ -58,7 +59,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
58
59
|
private bestDiscount;
|
|
59
60
|
loadPrepareConfig(params: {
|
|
60
61
|
customerId: number;
|
|
61
|
-
action?: 'create' | '
|
|
62
|
+
action?: 'create' | 'edit';
|
|
62
63
|
with_good_pass?: 0 | 1;
|
|
63
64
|
with_discount_card?: 0 | 1;
|
|
64
65
|
}): Promise<void>;
|
|
@@ -57,7 +57,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
57
57
|
currentBookingTime: "",
|
|
58
58
|
filteredDiscountList: [],
|
|
59
59
|
orderTotalAmount: 0,
|
|
60
|
-
bookingSubject: undefined
|
|
60
|
+
bookingSubject: undefined,
|
|
61
|
+
orderId: undefined
|
|
61
62
|
};
|
|
62
63
|
return _this;
|
|
63
64
|
}
|
|
@@ -302,6 +303,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
302
303
|
value: function setHolders(holders) {
|
|
303
304
|
this.store.holders = holders;
|
|
304
305
|
}
|
|
306
|
+
}, {
|
|
307
|
+
key: "setOrderId",
|
|
308
|
+
value: function setOrderId(id) {
|
|
309
|
+
this.store.orderId = id;
|
|
310
|
+
}
|
|
305
311
|
}, {
|
|
306
312
|
key: "setBookingSubject",
|
|
307
313
|
value: function setBookingSubject(bookingSubject) {
|
|
@@ -790,24 +796,27 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
790
796
|
key: "loadPrepareConfig",
|
|
791
797
|
value: function () {
|
|
792
798
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
793
|
-
var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
799
|
+
var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2, orderId, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
794
800
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
795
801
|
while (1) switch (_context10.prev = _context10.next) {
|
|
796
802
|
case 0:
|
|
797
803
|
_context10.prev = 0;
|
|
804
|
+
orderId = this.store.orderId;
|
|
798
805
|
customerId = params.customerId || ((_this$getCustomer2 = this.getCustomer()) === null || _this$getCustomer2 === void 0 ? void 0 : _this$getCustomer2.id); // if (customerId === 1 || !customerId) {
|
|
799
806
|
// return
|
|
800
807
|
// }
|
|
801
|
-
_context10.next =
|
|
802
|
-
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.loadPrepareConfig({
|
|
808
|
+
_context10.next = 5;
|
|
809
|
+
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.loadPrepareConfig(_objectSpread({
|
|
803
810
|
customer_id: customerId,
|
|
804
|
-
action: 'create',
|
|
811
|
+
action: orderId ? 'edit' : 'create',
|
|
805
812
|
with_good_pass: 1,
|
|
806
813
|
with_discount_card: 1,
|
|
807
814
|
with_wallet_pass_holder: 1,
|
|
808
815
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
809
|
-
}
|
|
810
|
-
|
|
816
|
+
}, orderId ? {
|
|
817
|
+
order_id: orderId
|
|
818
|
+
} : {}));
|
|
819
|
+
case 5:
|
|
811
820
|
goodPassList = _context10.sent;
|
|
812
821
|
scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
|
|
813
822
|
return item.isScan;
|
|
@@ -820,35 +829,35 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
820
829
|
});
|
|
821
830
|
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
|
|
822
831
|
this.store.originalDiscountList = newDiscountList;
|
|
823
|
-
_context10.next =
|
|
832
|
+
_context10.next = 13;
|
|
824
833
|
return (_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList(newDiscountList);
|
|
825
|
-
case
|
|
834
|
+
case 13:
|
|
826
835
|
// 根据当前预约时间过滤优惠券列表
|
|
827
836
|
filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
828
837
|
this.store.filteredDiscountList = filteredDiscountList;
|
|
829
838
|
this.setDiscountList(filteredDiscountList || []);
|
|
830
839
|
if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
|
|
831
|
-
_context10.next =
|
|
840
|
+
_context10.next = 20;
|
|
832
841
|
break;
|
|
833
842
|
}
|
|
834
843
|
_result3 = this.calcDiscount(this.store.productList);
|
|
835
|
-
_context10.next =
|
|
844
|
+
_context10.next = 20;
|
|
836
845
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
837
|
-
case
|
|
838
|
-
_context10.next =
|
|
846
|
+
case 20:
|
|
847
|
+
_context10.next = 22;
|
|
839
848
|
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
|
|
840
|
-
case
|
|
841
|
-
_context10.next =
|
|
849
|
+
case 22:
|
|
850
|
+
_context10.next = 27;
|
|
842
851
|
break;
|
|
843
|
-
case
|
|
844
|
-
_context10.prev =
|
|
852
|
+
case 24:
|
|
853
|
+
_context10.prev = 24;
|
|
845
854
|
_context10.t0 = _context10["catch"](0);
|
|
846
855
|
console.error('[ShopDiscount] 加载准备配置出错:', _context10.t0);
|
|
847
|
-
case
|
|
856
|
+
case 27:
|
|
848
857
|
case "end":
|
|
849
858
|
return _context10.stop();
|
|
850
859
|
}
|
|
851
|
-
}, _callee10, this, [[0,
|
|
860
|
+
}, _callee10, this, [[0, 24]]);
|
|
852
861
|
}));
|
|
853
862
|
function loadPrepareConfig(_x10) {
|
|
854
863
|
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
|
-
});
|
|
@@ -34,7 +34,7 @@ __export(changePrice_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(changePrice_exports);
|
|
35
35
|
var import_decimal = __toESM(require("decimal.js"));
|
|
36
36
|
async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCart, updateItemInitInfo) {
|
|
37
|
-
var _a, _b;
|
|
37
|
+
var _a, _b, _c, _d, _e, _f;
|
|
38
38
|
for (const item of cartItems) {
|
|
39
39
|
const targetProduct = priceData.find((n) => n.id === item.id);
|
|
40
40
|
const cartProduct = await getProduct(
|
|
@@ -44,10 +44,14 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
|
|
|
44
44
|
if (!productInfo) {
|
|
45
45
|
productInfo = item._productOrigin;
|
|
46
46
|
}
|
|
47
|
+
const variantId = ((_a = item == null ? void 0 : item._productOrigin) == null ? void 0 : _a.product_variant_id) ?? ((_c = (_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.product_variant_id);
|
|
48
|
+
const targetVariant = (_d = targetProduct == null ? void 0 : targetProduct.variant) == null ? void 0 : _d.find(
|
|
49
|
+
(variant) => Number(variant.id) === Number(variantId)
|
|
50
|
+
);
|
|
47
51
|
let bundle = item._bundleOrigin;
|
|
48
|
-
productInfo.price = targetProduct == null ? void 0 : targetProduct.price;
|
|
49
|
-
productInfo.base_price = targetProduct == null ? void 0 : targetProduct.base_price;
|
|
50
|
-
productInfo.product_variant_id = (
|
|
52
|
+
productInfo.price = (targetVariant == null ? void 0 : targetVariant.price) ?? (targetProduct == null ? void 0 : targetProduct.price) ?? productInfo.price;
|
|
53
|
+
productInfo.base_price = (targetVariant == null ? void 0 : targetVariant.base_price) ?? (targetProduct == null ? void 0 : targetProduct.base_price) ?? productInfo.base_price;
|
|
54
|
+
productInfo.product_variant_id = (_e = item._productOrigin) == null ? void 0 : _e.product_variant_id;
|
|
51
55
|
bundle = bundle == null ? void 0 : bundle.map((n) => {
|
|
52
56
|
var _a2;
|
|
53
57
|
const targetBundle = (_a2 = targetProduct == null ? void 0 : targetProduct.bundle_group) == null ? void 0 : _a2.find(
|
|
@@ -76,14 +80,14 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
|
|
|
76
80
|
return n;
|
|
77
81
|
});
|
|
78
82
|
if (targetProduct == null ? void 0 : targetProduct.variant) {
|
|
79
|
-
productInfo.variant = (
|
|
83
|
+
productInfo.variant = (_f = productInfo.variant) == null ? void 0 : _f.map((n) => {
|
|
80
84
|
var _a2;
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
85
|
+
const targetVariant2 = (_a2 = targetProduct.variant) == null ? void 0 : _a2.find((m) => m.id === n.id);
|
|
86
|
+
if (targetVariant2) {
|
|
83
87
|
return {
|
|
84
88
|
...n,
|
|
85
|
-
price:
|
|
86
|
-
base_price:
|
|
89
|
+
price: targetVariant2.price,
|
|
90
|
+
base_price: targetVariant2.base_price
|
|
87
91
|
};
|
|
88
92
|
}
|
|
89
93
|
return n;
|
|
@@ -17,12 +17,13 @@ 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;
|
|
26
27
|
}): Promise<Discount[]>;
|
|
27
28
|
batchSearch(code: string, customerId?: number): Promise<DiscountWithReason>;
|
|
28
29
|
batchSearchByProductIds(productIds: number[]): Promise<any>;
|
|
@@ -26,6 +26,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
26
26
|
setHolders(holders: {
|
|
27
27
|
form_record_id: number;
|
|
28
28
|
}[]): void;
|
|
29
|
+
setOrderId(id?: number): void;
|
|
29
30
|
setBookingSubject(bookingSubject: {
|
|
30
31
|
type?: 'form' | 'customer';
|
|
31
32
|
[key: string]: any;
|
|
@@ -58,7 +59,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
58
59
|
private bestDiscount;
|
|
59
60
|
loadPrepareConfig(params: {
|
|
60
61
|
customerId: number;
|
|
61
|
-
action?: 'create' | '
|
|
62
|
+
action?: 'create' | 'edit';
|
|
62
63
|
with_good_pass?: 0 | 1;
|
|
63
64
|
with_discount_card?: 0 | 1;
|
|
64
65
|
}): Promise<void>;
|
|
@@ -57,7 +57,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
57
57
|
currentBookingTime: "",
|
|
58
58
|
filteredDiscountList: [],
|
|
59
59
|
orderTotalAmount: 0,
|
|
60
|
-
bookingSubject: void 0
|
|
60
|
+
bookingSubject: void 0,
|
|
61
|
+
orderId: void 0
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
// =========== 生命周期方法 ===========
|
|
@@ -202,6 +203,9 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
202
203
|
setHolders(holders) {
|
|
203
204
|
this.store.holders = holders;
|
|
204
205
|
}
|
|
206
|
+
setOrderId(id) {
|
|
207
|
+
this.store.orderId = id;
|
|
208
|
+
}
|
|
205
209
|
setBookingSubject(bookingSubject) {
|
|
206
210
|
this.store.bookingSubject = bookingSubject;
|
|
207
211
|
}
|
|
@@ -519,14 +523,16 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
519
523
|
async loadPrepareConfig(params) {
|
|
520
524
|
var _a, _b, _c, _d, _e;
|
|
521
525
|
try {
|
|
526
|
+
const orderId = this.store.orderId;
|
|
522
527
|
const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
|
|
523
528
|
const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
|
|
524
529
|
customer_id: customerId,
|
|
525
|
-
action: "create",
|
|
530
|
+
action: orderId ? "edit" : "create",
|
|
526
531
|
with_good_pass: 1,
|
|
527
532
|
with_discount_card: 1,
|
|
528
533
|
with_wallet_pass_holder: 1,
|
|
529
|
-
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
534
|
+
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
535
|
+
...orderId ? { order_id: orderId } : {}
|
|
530
536
|
}));
|
|
531
537
|
const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
|
|
532
538
|
(item) => item.isScan
|