@pisell/pisellos 0.0.41 → 0.0.43
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.d.ts +1 -1
- package/dist/modules/Cart/utils.js +3 -2
- package/dist/modules/Summary/index.d.ts +7 -0
- package/dist/modules/Summary/index.js +29 -3
- package/dist/modules/Summary/utils.d.ts +1 -0
- package/dist/modules/Summary/utils.js +14 -9
- package/dist/solution/BookingByStep/index.d.ts +4 -0
- package/dist/solution/BookingByStep/index.js +88 -65
- package/lib/modules/Cart/utils.d.ts +1 -1
- package/lib/modules/Cart/utils.js +2 -2
- package/lib/modules/Summary/index.d.ts +7 -0
- package/lib/modules/Summary/index.js +15 -1
- package/lib/modules/Summary/utils.d.ts +1 -0
- package/lib/modules/Summary/utils.js +10 -8
- package/lib/solution/BookingByStep/index.d.ts +4 -0
- package/lib/solution/BookingByStep/index.js +6 -0
- package/package.json +1 -1
|
@@ -113,7 +113,7 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
// 如果商品有定金规则,则计算定金
|
|
116
|
-
if (product
|
|
116
|
+
if ((product === null || product === void 0 || (_product$custom_depos = product.custom_deposit_data) === null || _product$custom_depos === void 0 ? void 0 : _product$custom_depos.has_deposit) == 1) {
|
|
117
117
|
cartItem.deposit = getProductDeposit({
|
|
118
118
|
cartItem: cartItem,
|
|
119
119
|
product: product,
|
|
@@ -532,6 +532,7 @@ export var getProductDeposit = function getProductDeposit(params) {
|
|
|
532
532
|
deposit_fixed = _ref.deposit_fixed,
|
|
533
533
|
deposit_percentage = _ref.deposit_percentage,
|
|
534
534
|
deposit_policy_data = _ref.deposit_policy_data;
|
|
535
|
+
// 协议数据
|
|
535
536
|
protocols.push.apply(protocols, _toConsumableArray(deposit_policy_data || []));
|
|
536
537
|
// 判断主商品是否有定金规则
|
|
537
538
|
if (typeof deposit_fixed === "string" && typeof deposit_percentage === "string") {
|
|
@@ -563,7 +564,7 @@ export var getProductDeposit = function getProductDeposit(params) {
|
|
|
563
564
|
}
|
|
564
565
|
}
|
|
565
566
|
return {
|
|
566
|
-
total: total.
|
|
567
|
+
total: total.toNumber(),
|
|
567
568
|
protocols: protocols
|
|
568
569
|
};
|
|
569
570
|
}
|
|
@@ -7,11 +7,18 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
|
|
|
7
7
|
protected defaultVersion: string;
|
|
8
8
|
private shopStore;
|
|
9
9
|
private store;
|
|
10
|
+
private request;
|
|
10
11
|
private cacheId;
|
|
11
12
|
private openCache;
|
|
12
13
|
private fatherModule;
|
|
13
14
|
constructor(name?: string, version?: string);
|
|
14
15
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
15
16
|
getSummary(cartItems: CartItem[]): Promise<ISummaryState["summary"]>;
|
|
17
|
+
/**
|
|
18
|
+
* 获取协议
|
|
19
|
+
* @param protocolId 协议ID
|
|
20
|
+
* @returns 协议
|
|
21
|
+
*/
|
|
22
|
+
getProtocol(protocolId: string): Promise<any>;
|
|
16
23
|
storeChange(): void;
|
|
17
24
|
}
|
|
@@ -28,6 +28,7 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
28
28
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
|
|
29
29
|
_defineProperty(_assertThisInitialized(_this), "shopStore", void 0);
|
|
30
30
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
31
32
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
32
33
|
_defineProperty(_assertThisInitialized(_this), "openCache", false);
|
|
33
34
|
_defineProperty(_assertThisInitialized(_this), "fatherModule", void 0);
|
|
@@ -44,6 +45,7 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
44
45
|
this.core = core;
|
|
45
46
|
this.store = options.store;
|
|
46
47
|
this.shopStore = this.core.getPlugin("shopStore");
|
|
48
|
+
this.request = this.core.getPlugin("request");
|
|
47
49
|
if (options.initialState) {
|
|
48
50
|
this.store.summary = options.initialState.summary;
|
|
49
51
|
}
|
|
@@ -55,11 +57,11 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
55
57
|
this.fatherModule = options.otherParams.fatherModule;
|
|
56
58
|
}
|
|
57
59
|
if (this.shopStore) {
|
|
58
|
-
_context.next =
|
|
60
|
+
_context.next = 9;
|
|
59
61
|
break;
|
|
60
62
|
}
|
|
61
63
|
throw new Error("SummaryModule 需要 shopStore 插件支持");
|
|
62
|
-
case
|
|
64
|
+
case 9:
|
|
63
65
|
case "end":
|
|
64
66
|
return _context.stop();
|
|
65
67
|
}
|
|
@@ -94,6 +96,30 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
94
96
|
}
|
|
95
97
|
return getSummary;
|
|
96
98
|
}()
|
|
99
|
+
/**
|
|
100
|
+
* 获取协议
|
|
101
|
+
* @param protocolId 协议ID
|
|
102
|
+
* @returns 协议
|
|
103
|
+
*/
|
|
104
|
+
}, {
|
|
105
|
+
key: "getProtocol",
|
|
106
|
+
value: (function () {
|
|
107
|
+
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(protocolId) {
|
|
108
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
109
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
110
|
+
case 0:
|
|
111
|
+
return _context3.abrupt("return", this.request.get("/shop-policy/".concat(protocolId)));
|
|
112
|
+
case 1:
|
|
113
|
+
case "end":
|
|
114
|
+
return _context3.stop();
|
|
115
|
+
}
|
|
116
|
+
}, _callee3, this);
|
|
117
|
+
}));
|
|
118
|
+
function getProtocol(_x4) {
|
|
119
|
+
return _getProtocol.apply(this, arguments);
|
|
120
|
+
}
|
|
121
|
+
return getProtocol;
|
|
122
|
+
}())
|
|
97
123
|
}, {
|
|
98
124
|
key: "storeChange",
|
|
99
125
|
value: function storeChange() {
|
|
@@ -102,7 +128,7 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
102
128
|
cacheId: this.cacheId,
|
|
103
129
|
fatherModule: this.fatherModule,
|
|
104
130
|
store: this.store,
|
|
105
|
-
cacheKey: [
|
|
131
|
+
cacheKey: ["summary"]
|
|
106
132
|
});
|
|
107
133
|
}
|
|
108
134
|
}
|
|
@@ -68,13 +68,14 @@ export var calculateDeposit = function calculateDeposit(items) {
|
|
|
68
68
|
return undefined;
|
|
69
69
|
}
|
|
70
70
|
var protocols = [];
|
|
71
|
+
var hasDeposit = false;
|
|
71
72
|
var total = items.reduce(function (sum, item) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var cartItemTotalPrice = new Decimal((item === null || item === void 0 || (_item$
|
|
73
|
+
if (item !== null && item !== void 0 && item.deposit) {
|
|
74
|
+
var _item$deposit, _item$deposit2;
|
|
75
|
+
hasDeposit = true;
|
|
76
|
+
var cartItemTotalPrice = new Decimal((item === null || item === void 0 || (_item$deposit = item.deposit) === null || _item$deposit === void 0 ? void 0 : _item$deposit.total) || 0);
|
|
76
77
|
// 将协议数据去重合并
|
|
77
|
-
item === null || item === void 0 || (_item$
|
|
78
|
+
item === null || item === void 0 || (_item$deposit2 = item.deposit) === null || _item$deposit2 === void 0 || (_item$deposit2 = _item$deposit2.protocols) === null || _item$deposit2 === void 0 || _item$deposit2.forEach(function (protocol) {
|
|
78
79
|
if (protocols.findIndex(function (p) {
|
|
79
80
|
return p.id === protocol.id;
|
|
80
81
|
}) === -1) {
|
|
@@ -85,8 +86,12 @@ export var calculateDeposit = function calculateDeposit(items) {
|
|
|
85
86
|
}
|
|
86
87
|
return sum;
|
|
87
88
|
}, new Decimal(0));
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
if (hasDeposit) {
|
|
90
|
+
return {
|
|
91
|
+
total: total.toFixed(2),
|
|
92
|
+
protocols: protocols,
|
|
93
|
+
hasDeposit: hasDeposit
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return undefined;
|
|
92
97
|
};
|
|
@@ -70,6 +70,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
70
70
|
policies?: import("../../modules/Summary/types").IProtocol[] | undefined;
|
|
71
71
|
} | undefined;
|
|
72
72
|
}>;
|
|
73
|
+
/**
|
|
74
|
+
* 获取协议
|
|
75
|
+
*/
|
|
76
|
+
getProtocol(protocolId: string): Promise<any>;
|
|
73
77
|
getProducts(): Promise<ProductData[]>;
|
|
74
78
|
setLoginAccount(accountId: string, accountInfo: Account): Promise<void>;
|
|
75
79
|
generateCartData(): Promise<void>;
|
|
@@ -527,22 +527,45 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
527
527
|
return _getSummary.apply(this, arguments);
|
|
528
528
|
}
|
|
529
529
|
return getSummary;
|
|
530
|
-
}()
|
|
530
|
+
}()
|
|
531
|
+
/**
|
|
532
|
+
* 获取协议
|
|
533
|
+
*/
|
|
531
534
|
)
|
|
532
535
|
}, {
|
|
533
|
-
key: "
|
|
534
|
-
value: function () {
|
|
535
|
-
var
|
|
536
|
+
key: "getProtocol",
|
|
537
|
+
value: (function () {
|
|
538
|
+
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(protocolId) {
|
|
536
539
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
537
540
|
while (1) switch (_context12.prev = _context12.next) {
|
|
538
541
|
case 0:
|
|
539
|
-
return _context12.abrupt("return", this.store.
|
|
542
|
+
return _context12.abrupt("return", this.store.summary.getProtocol(protocolId));
|
|
540
543
|
case 1:
|
|
541
544
|
case "end":
|
|
542
545
|
return _context12.stop();
|
|
543
546
|
}
|
|
544
547
|
}, _callee12, this);
|
|
545
548
|
}));
|
|
549
|
+
function getProtocol(_x8) {
|
|
550
|
+
return _getProtocol.apply(this, arguments);
|
|
551
|
+
}
|
|
552
|
+
return getProtocol;
|
|
553
|
+
}() // 获取可选择的商品、服务列表
|
|
554
|
+
)
|
|
555
|
+
}, {
|
|
556
|
+
key: "getProducts",
|
|
557
|
+
value: function () {
|
|
558
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
559
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
560
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
561
|
+
case 0:
|
|
562
|
+
return _context13.abrupt("return", this.store.products.getProducts());
|
|
563
|
+
case 1:
|
|
564
|
+
case "end":
|
|
565
|
+
return _context13.stop();
|
|
566
|
+
}
|
|
567
|
+
}, _callee13, this);
|
|
568
|
+
}));
|
|
546
569
|
function getProducts() {
|
|
547
570
|
return _getProducts.apply(this, arguments);
|
|
548
571
|
}
|
|
@@ -551,15 +574,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
551
574
|
}, {
|
|
552
575
|
key: "setLoginAccount",
|
|
553
576
|
value: function () {
|
|
554
|
-
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
577
|
+
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(accountId, accountInfo) {
|
|
555
578
|
var _this4 = this;
|
|
556
579
|
var account, stateAccountId, cartItems;
|
|
557
|
-
return _regeneratorRuntime().wrap(function
|
|
558
|
-
while (1) switch (
|
|
580
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
581
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
559
582
|
case 0:
|
|
560
583
|
account = this.store.accountList.getAccount(accountId);
|
|
561
584
|
if (!account) {
|
|
562
|
-
|
|
585
|
+
_context14.next = 9;
|
|
563
586
|
break;
|
|
564
587
|
}
|
|
565
588
|
stateAccountId = account.getId();
|
|
@@ -575,17 +598,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
575
598
|
}
|
|
576
599
|
});
|
|
577
600
|
this.store.accountList.updateAccountListById(stateAccountId, accountInfo);
|
|
578
|
-
|
|
601
|
+
_context14.next = 10;
|
|
579
602
|
break;
|
|
580
603
|
case 9:
|
|
581
604
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
|
|
582
605
|
case 10:
|
|
583
606
|
case "end":
|
|
584
|
-
return
|
|
607
|
+
return _context14.stop();
|
|
585
608
|
}
|
|
586
|
-
},
|
|
609
|
+
}, _callee14, this);
|
|
587
610
|
}));
|
|
588
|
-
function setLoginAccount(
|
|
611
|
+
function setLoginAccount(_x9, _x10) {
|
|
589
612
|
return _setLoginAccount.apply(this, arguments);
|
|
590
613
|
}
|
|
591
614
|
return setLoginAccount;
|
|
@@ -593,14 +616,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
593
616
|
}, {
|
|
594
617
|
key: "generateCartData",
|
|
595
618
|
value: function () {
|
|
596
|
-
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
597
|
-
return _regeneratorRuntime().wrap(function
|
|
598
|
-
while (1) switch (
|
|
619
|
+
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
620
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
621
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
599
622
|
case 0:
|
|
600
623
|
case "end":
|
|
601
|
-
return
|
|
624
|
+
return _context15.stop();
|
|
602
625
|
}
|
|
603
|
-
},
|
|
626
|
+
}, _callee15);
|
|
604
627
|
}));
|
|
605
628
|
function generateCartData() {
|
|
606
629
|
return _generateCartData.apply(this, arguments);
|
|
@@ -610,23 +633,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
610
633
|
}, {
|
|
611
634
|
key: "getFreeProduct",
|
|
612
635
|
value: function () {
|
|
613
|
-
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
636
|
+
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(id) {
|
|
614
637
|
var res;
|
|
615
|
-
return _regeneratorRuntime().wrap(function
|
|
616
|
-
while (1) switch (
|
|
638
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
639
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
617
640
|
case 0:
|
|
618
|
-
|
|
641
|
+
_context16.next = 2;
|
|
619
642
|
return this.request.post("/pay/order/free-pay/".concat(id));
|
|
620
643
|
case 2:
|
|
621
|
-
res =
|
|
622
|
-
return
|
|
644
|
+
res = _context16.sent;
|
|
645
|
+
return _context16.abrupt("return", res);
|
|
623
646
|
case 4:
|
|
624
647
|
case "end":
|
|
625
|
-
return
|
|
648
|
+
return _context16.stop();
|
|
626
649
|
}
|
|
627
|
-
},
|
|
650
|
+
}, _callee16, this);
|
|
628
651
|
}));
|
|
629
|
-
function getFreeProduct(
|
|
652
|
+
function getFreeProduct(_x11) {
|
|
630
653
|
return _getFreeProduct.apply(this, arguments);
|
|
631
654
|
}
|
|
632
655
|
return getFreeProduct;
|
|
@@ -634,10 +657,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
634
657
|
}, {
|
|
635
658
|
key: "submitOrder",
|
|
636
659
|
value: function () {
|
|
637
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
660
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
638
661
|
var cartItems, newCartItems;
|
|
639
|
-
return _regeneratorRuntime().wrap(function
|
|
640
|
-
while (1) switch (
|
|
662
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
663
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
641
664
|
case 0:
|
|
642
665
|
cartItems = this.store.cart.getItems();
|
|
643
666
|
newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
|
|
@@ -650,16 +673,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
650
673
|
return _objectSpread({}, newResourcesItem);
|
|
651
674
|
});
|
|
652
675
|
});
|
|
653
|
-
return
|
|
676
|
+
return _context17.abrupt("return", this.store.order.commitOrder({
|
|
654
677
|
query: {
|
|
655
678
|
cartItems: newCartItems
|
|
656
679
|
}
|
|
657
680
|
}));
|
|
658
681
|
case 4:
|
|
659
682
|
case "end":
|
|
660
|
-
return
|
|
683
|
+
return _context17.stop();
|
|
661
684
|
}
|
|
662
|
-
},
|
|
685
|
+
}, _callee17, this);
|
|
663
686
|
}));
|
|
664
687
|
function submitOrder() {
|
|
665
688
|
return _submitOrder.apply(this, arguments);
|
|
@@ -669,14 +692,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
669
692
|
}, {
|
|
670
693
|
key: "pay",
|
|
671
694
|
value: function () {
|
|
672
|
-
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
673
|
-
return _regeneratorRuntime().wrap(function
|
|
674
|
-
while (1) switch (
|
|
695
|
+
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
696
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
697
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
675
698
|
case 0:
|
|
676
699
|
case "end":
|
|
677
|
-
return
|
|
700
|
+
return _context18.stop();
|
|
678
701
|
}
|
|
679
|
-
},
|
|
702
|
+
}, _callee18);
|
|
680
703
|
}));
|
|
681
704
|
function pay() {
|
|
682
705
|
return _pay.apply(this, arguments);
|
|
@@ -686,14 +709,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
686
709
|
}, {
|
|
687
710
|
key: "getPayInfo",
|
|
688
711
|
value: function () {
|
|
689
|
-
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
690
|
-
return _regeneratorRuntime().wrap(function
|
|
691
|
-
while (1) switch (
|
|
712
|
+
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
713
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
714
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
692
715
|
case 0:
|
|
693
716
|
case "end":
|
|
694
|
-
return
|
|
717
|
+
return _context19.stop();
|
|
695
718
|
}
|
|
696
|
-
},
|
|
719
|
+
}, _callee19);
|
|
697
720
|
}));
|
|
698
721
|
function getPayInfo() {
|
|
699
722
|
return _getPayInfo.apply(this, arguments);
|
|
@@ -703,15 +726,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
703
726
|
}, {
|
|
704
727
|
key: "setOtherParams",
|
|
705
728
|
value: function () {
|
|
706
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
729
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
707
730
|
var _ref5,
|
|
708
731
|
_ref5$cover,
|
|
709
732
|
cover,
|
|
710
|
-
|
|
711
|
-
return _regeneratorRuntime().wrap(function
|
|
712
|
-
while (1) switch (
|
|
733
|
+
_args20 = arguments;
|
|
734
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
735
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
713
736
|
case 0:
|
|
714
|
-
_ref5 =
|
|
737
|
+
_ref5 = _args20.length > 1 && _args20[1] !== undefined ? _args20[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
|
|
715
738
|
if (cover) {
|
|
716
739
|
this.otherParams = params;
|
|
717
740
|
} else {
|
|
@@ -719,11 +742,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
719
742
|
}
|
|
720
743
|
case 2:
|
|
721
744
|
case "end":
|
|
722
|
-
return
|
|
745
|
+
return _context20.stop();
|
|
723
746
|
}
|
|
724
|
-
},
|
|
747
|
+
}, _callee20, this);
|
|
725
748
|
}));
|
|
726
|
-
function setOtherParams(
|
|
749
|
+
function setOtherParams(_x12) {
|
|
727
750
|
return _setOtherParams.apply(this, arguments);
|
|
728
751
|
}
|
|
729
752
|
return setOtherParams;
|
|
@@ -731,16 +754,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
731
754
|
}, {
|
|
732
755
|
key: "getOtherParams",
|
|
733
756
|
value: function () {
|
|
734
|
-
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
735
|
-
return _regeneratorRuntime().wrap(function
|
|
736
|
-
while (1) switch (
|
|
757
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
758
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
759
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
737
760
|
case 0:
|
|
738
|
-
return
|
|
761
|
+
return _context21.abrupt("return", this.otherParams);
|
|
739
762
|
case 1:
|
|
740
763
|
case "end":
|
|
741
|
-
return
|
|
764
|
+
return _context21.stop();
|
|
742
765
|
}
|
|
743
|
-
},
|
|
766
|
+
}, _callee21, this);
|
|
744
767
|
}));
|
|
745
768
|
function getOtherParams() {
|
|
746
769
|
return _getOtherParams.apply(this, arguments);
|
|
@@ -1327,25 +1350,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1327
1350
|
}, {
|
|
1328
1351
|
key: "openProductDetail",
|
|
1329
1352
|
value: function () {
|
|
1330
|
-
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1353
|
+
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(productId) {
|
|
1331
1354
|
var targetProduct;
|
|
1332
|
-
return _regeneratorRuntime().wrap(function
|
|
1333
|
-
while (1) switch (
|
|
1355
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1356
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1334
1357
|
case 0:
|
|
1335
|
-
|
|
1358
|
+
_context22.next = 2;
|
|
1336
1359
|
return this.store.products.getProduct(productId);
|
|
1337
1360
|
case 2:
|
|
1338
|
-
targetProduct =
|
|
1361
|
+
targetProduct = _context22.sent;
|
|
1339
1362
|
if (targetProduct) {
|
|
1340
1363
|
this.store.currentProduct = targetProduct;
|
|
1341
1364
|
}
|
|
1342
1365
|
case 4:
|
|
1343
1366
|
case "end":
|
|
1344
|
-
return
|
|
1367
|
+
return _context22.stop();
|
|
1345
1368
|
}
|
|
1346
|
-
},
|
|
1369
|
+
}, _callee22, this);
|
|
1347
1370
|
}));
|
|
1348
|
-
function openProductDetail(
|
|
1371
|
+
function openProductDetail(_x13) {
|
|
1349
1372
|
return _openProductDetail.apply(this, arguments);
|
|
1350
1373
|
}
|
|
1351
1374
|
return openProductDetail;
|
|
@@ -125,7 +125,7 @@ var formatProductToCartItem = (params) => {
|
|
|
125
125
|
if (options == null ? void 0 : options.length) {
|
|
126
126
|
cartItem.options = formatOptions(options);
|
|
127
127
|
}
|
|
128
|
-
if ((_a = product == null ? void 0 : product.custom_deposit_data) == null ? void 0 : _a.has_deposit) {
|
|
128
|
+
if (((_a = product == null ? void 0 : product.custom_deposit_data) == null ? void 0 : _a.has_deposit) == 1) {
|
|
129
129
|
cartItem.deposit = getProductDeposit({ cartItem, product, bundle, options, num });
|
|
130
130
|
}
|
|
131
131
|
const oringin = formatProductToCartItemOrigin(params);
|
|
@@ -439,7 +439,7 @@ var getProductDeposit = (params) => {
|
|
|
439
439
|
}, new import_decimal.default(0));
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
return { total: total.
|
|
442
|
+
return { total: total.toNumber(), protocols };
|
|
443
443
|
}
|
|
444
444
|
return null;
|
|
445
445
|
};
|
|
@@ -7,11 +7,18 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
|
|
|
7
7
|
protected defaultVersion: string;
|
|
8
8
|
private shopStore;
|
|
9
9
|
private store;
|
|
10
|
+
private request;
|
|
10
11
|
private cacheId;
|
|
11
12
|
private openCache;
|
|
12
13
|
private fatherModule;
|
|
13
14
|
constructor(name?: string, version?: string);
|
|
14
15
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
15
16
|
getSummary(cartItems: CartItem[]): Promise<ISummaryState["summary"]>;
|
|
17
|
+
/**
|
|
18
|
+
* 获取协议
|
|
19
|
+
* @param protocolId 协议ID
|
|
20
|
+
* @returns 协议
|
|
21
|
+
*/
|
|
22
|
+
getProtocol(protocolId: string): Promise<any>;
|
|
16
23
|
storeChange(): void;
|
|
17
24
|
}
|
|
@@ -36,6 +36,7 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
36
36
|
this.core = core;
|
|
37
37
|
this.store = options.store;
|
|
38
38
|
this.shopStore = this.core.getPlugin("shopStore");
|
|
39
|
+
this.request = this.core.getPlugin("request");
|
|
39
40
|
if (options.initialState) {
|
|
40
41
|
this.store.summary = options.initialState.summary;
|
|
41
42
|
}
|
|
@@ -57,9 +58,22 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
57
58
|
this.store.summary = summary;
|
|
58
59
|
return this.store.summary;
|
|
59
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* 获取协议
|
|
63
|
+
* @param protocolId 协议ID
|
|
64
|
+
* @returns 协议
|
|
65
|
+
*/
|
|
66
|
+
async getProtocol(protocolId) {
|
|
67
|
+
return this.request.get(`/shop-policy/${protocolId}`);
|
|
68
|
+
}
|
|
60
69
|
storeChange() {
|
|
61
70
|
if (this.openCache) {
|
|
62
|
-
this.checkSaveCache({
|
|
71
|
+
this.checkSaveCache({
|
|
72
|
+
cacheId: this.cacheId,
|
|
73
|
+
fatherModule: this.fatherModule,
|
|
74
|
+
store: this.store,
|
|
75
|
+
cacheKey: ["summary"]
|
|
76
|
+
});
|
|
63
77
|
}
|
|
64
78
|
}
|
|
65
79
|
};
|
|
@@ -78,11 +78,13 @@ var calculateDeposit = (items) => {
|
|
|
78
78
|
return void 0;
|
|
79
79
|
}
|
|
80
80
|
const protocols = [];
|
|
81
|
+
let hasDeposit = false;
|
|
81
82
|
const total = items.reduce((sum, item) => {
|
|
82
|
-
var _a, _b, _c
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
var _a, _b, _c;
|
|
84
|
+
if (item == null ? void 0 : item.deposit) {
|
|
85
|
+
hasDeposit = true;
|
|
86
|
+
const cartItemTotalPrice = new import_decimal.default(((_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.total) || 0);
|
|
87
|
+
(_c = (_b = item == null ? void 0 : item.deposit) == null ? void 0 : _b.protocols) == null ? void 0 : _c.forEach((protocol) => {
|
|
86
88
|
if (protocols.findIndex((p) => p.id === protocol.id) === -1) {
|
|
87
89
|
protocols.push(protocol);
|
|
88
90
|
}
|
|
@@ -91,10 +93,10 @@ var calculateDeposit = (items) => {
|
|
|
91
93
|
}
|
|
92
94
|
return sum;
|
|
93
95
|
}, new import_decimal.default(0));
|
|
94
|
-
|
|
95
|
-
total: total.toFixed(2),
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
if (hasDeposit) {
|
|
97
|
+
return { total: total.toFixed(2), protocols, hasDeposit };
|
|
98
|
+
}
|
|
99
|
+
return void 0;
|
|
98
100
|
};
|
|
99
101
|
// Annotate the CommonJS export names for ESM import in node:
|
|
100
102
|
0 && (module.exports = {
|
|
@@ -70,6 +70,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
70
70
|
policies?: import("../../modules/Summary/types").IProtocol[] | undefined;
|
|
71
71
|
} | undefined;
|
|
72
72
|
}>;
|
|
73
|
+
/**
|
|
74
|
+
* 获取协议
|
|
75
|
+
*/
|
|
76
|
+
getProtocol(protocolId: string): Promise<any>;
|
|
73
77
|
getProducts(): Promise<ProductData[]>;
|
|
74
78
|
setLoginAccount(accountId: string, accountInfo: Account): Promise<void>;
|
|
75
79
|
generateCartData(): Promise<void>;
|
|
@@ -252,6 +252,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
252
252
|
const summary = await this.store.summary.getSummary(cartItems);
|
|
253
253
|
return summary;
|
|
254
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* 获取协议
|
|
257
|
+
*/
|
|
258
|
+
async getProtocol(protocolId) {
|
|
259
|
+
return this.store.summary.getProtocol(protocolId);
|
|
260
|
+
}
|
|
255
261
|
// 获取可选择的商品、服务列表
|
|
256
262
|
async getProducts() {
|
|
257
263
|
return this.store.products.getProducts();
|