@pisell/pisellos 3.0.4 → 3.0.6

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.
Files changed (189) hide show
  1. package/dist/modules/Account/index.d.ts +2 -6
  2. package/dist/modules/Account/index.js +21 -103
  3. package/dist/modules/Account/types.d.ts +12 -1
  4. package/dist/modules/AccountList/index.d.ts +20 -1
  5. package/dist/modules/AccountList/index.js +243 -75
  6. package/dist/modules/AccountList/types.d.ts +33 -1
  7. package/dist/modules/AccountList/types.js +8 -0
  8. package/dist/modules/AccountList/utils.d.ts +9 -0
  9. package/dist/modules/AccountList/utils.js +25 -0
  10. package/dist/modules/BaseModule.d.ts +2 -2
  11. package/dist/modules/BaseModule.js +1 -1
  12. package/dist/modules/Cart/index.d.ts +8 -5
  13. package/dist/modules/Cart/index.js +101 -25
  14. package/dist/modules/Cart/types.d.ts +82 -5
  15. package/dist/modules/Cart/types.js +22 -0
  16. package/dist/modules/Cart/utils.d.ts +106 -13
  17. package/dist/modules/Cart/utils.js +289 -76
  18. package/dist/modules/Date/index.d.ts +6 -6
  19. package/dist/modules/Date/index.js +41 -58
  20. package/dist/modules/Date/types.d.ts +22 -6
  21. package/dist/modules/Date/utils.d.ts +4 -3
  22. package/dist/modules/Date/utils.js +81 -30
  23. package/dist/modules/Discount/index.d.ts +4 -4
  24. package/dist/modules/Discount/index.js +11 -11
  25. package/dist/modules/Order/index.d.ts +11 -5
  26. package/dist/modules/Order/index.js +47 -18
  27. package/dist/modules/Order/types.d.ts +10 -3
  28. package/dist/modules/Order/utils.d.ts +10 -0
  29. package/dist/modules/Order/utils.js +15 -0
  30. package/dist/modules/Product/index.d.ts +14 -1
  31. package/dist/modules/Product/index.js +35 -0
  32. package/dist/modules/Product/types.d.ts +27 -3
  33. package/dist/modules/ProductList/index.js +11 -5
  34. package/dist/modules/Resource/types.d.ts +1 -0
  35. package/dist/modules/Resource/utils.js +1 -1
  36. package/dist/modules/Rules/index.d.ts +3 -3
  37. package/dist/modules/Rules/index.js +121 -53
  38. package/dist/modules/Rules/types.d.ts +5 -1
  39. package/dist/modules/Schedule/index.d.ts +18 -0
  40. package/dist/modules/Schedule/index.js +111 -0
  41. package/dist/modules/Schedule/type.d.ts +157 -0
  42. package/dist/modules/Schedule/type.js +1 -0
  43. package/dist/modules/Schedule/types.d.ts +182 -0
  44. package/dist/modules/Schedule/types.js +1 -0
  45. package/dist/modules/Schedule/utils.d.ts +67 -0
  46. package/dist/modules/Schedule/utils.js +729 -0
  47. package/dist/modules/Step/index.d.ts +14 -3
  48. package/dist/modules/Step/index.js +54 -2
  49. package/dist/modules/Summary/index.d.ts +12 -5
  50. package/dist/modules/Summary/index.js +33 -7
  51. package/dist/modules/Summary/types.d.ts +23 -2
  52. package/dist/modules/Summary/utils.d.ts +14 -4
  53. package/dist/modules/Summary/utils.js +46 -4
  54. package/dist/modules/index.d.ts +10 -0
  55. package/dist/modules/index.js +11 -1
  56. package/dist/plugins/index.d.ts +3 -3
  57. package/dist/plugins/request.d.ts +3 -3
  58. package/dist/plugins/request.js +30 -30
  59. package/dist/plugins/shopStore.d.ts +1 -1
  60. package/dist/solution/BookingByStep/index.d.ts +97 -24
  61. package/dist/solution/BookingByStep/index.js +1024 -322
  62. package/dist/solution/BookingByStep/types.d.ts +3 -10
  63. package/dist/solution/BookingByStep/types.js +11 -15
  64. package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
  65. package/dist/solution/BookingByStep/utils/products.js +3 -0
  66. package/dist/solution/BookingByStep/utils/resources.d.ts +60 -6
  67. package/dist/solution/BookingByStep/utils/resources.js +293 -52
  68. package/dist/solution/ShopDiscount/index.d.ts +4 -4
  69. package/dist/solution/ShopDiscount/index.js +16 -16
  70. package/dist/solution/ShopDiscount/types.d.ts +2 -2
  71. package/dist/solution/ShopDiscount/utils.js +1 -1
  72. package/lib/core/index.js +7 -2
  73. package/lib/modules/Account/index.d.ts +2 -6
  74. package/lib/modules/Account/index.js +15 -30
  75. package/lib/modules/Account/types.d.ts +12 -1
  76. package/lib/modules/AccountList/index.d.ts +20 -1
  77. package/lib/modules/AccountList/index.js +122 -13
  78. package/lib/modules/AccountList/types.d.ts +33 -1
  79. package/lib/modules/AccountList/utils.d.ts +9 -0
  80. package/lib/modules/AccountList/utils.js +39 -0
  81. package/lib/modules/BaseModule.d.ts +2 -2
  82. package/lib/modules/BaseModule.js +14 -3
  83. package/lib/modules/Cart/index.d.ts +8 -5
  84. package/lib/modules/Cart/index.js +81 -8
  85. package/lib/modules/Cart/types.d.ts +82 -5
  86. package/lib/modules/Cart/types.js +20 -2
  87. package/lib/modules/Cart/utils.d.ts +106 -13
  88. package/lib/modules/Cart/utils.js +188 -45
  89. package/lib/modules/Date/index.d.ts +6 -6
  90. package/lib/modules/Date/index.js +13 -28
  91. package/lib/modules/Date/types.d.ts +22 -6
  92. package/lib/modules/Date/utils.d.ts +4 -3
  93. package/lib/modules/Date/utils.js +47 -13
  94. package/lib/modules/Discount/index.d.ts +4 -4
  95. package/lib/modules/Discount/index.js +9 -2
  96. package/lib/modules/Guests/index.js +4 -1
  97. package/lib/modules/Order/index.d.ts +11 -5
  98. package/lib/modules/Order/index.js +24 -3
  99. package/lib/modules/Order/types.d.ts +10 -3
  100. package/lib/modules/Order/utils.d.ts +10 -0
  101. package/lib/modules/Order/utils.js +45 -0
  102. package/lib/modules/Payment/index.js +1 -6
  103. package/lib/modules/Product/index.d.ts +14 -1
  104. package/lib/modules/Product/index.js +19 -0
  105. package/lib/modules/Product/types.d.ts +27 -3
  106. package/lib/modules/ProductList/index.js +21 -7
  107. package/lib/modules/Resource/index.js +4 -1
  108. package/lib/modules/Resource/types.d.ts +1 -0
  109. package/lib/modules/Resource/utils.js +7 -4
  110. package/lib/modules/Rules/index.d.ts +3 -3
  111. package/lib/modules/Rules/index.js +118 -43
  112. package/lib/modules/Rules/types.d.ts +5 -1
  113. package/lib/modules/Schedule/index.d.ts +18 -0
  114. package/lib/modules/Schedule/index.js +81 -0
  115. package/lib/modules/Schedule/type.d.ts +157 -0
  116. package/lib/modules/Schedule/type.js +17 -0
  117. package/lib/modules/Schedule/types.d.ts +182 -0
  118. package/lib/modules/Schedule/types.js +17 -0
  119. package/lib/modules/Schedule/utils.d.ts +67 -0
  120. package/lib/modules/Schedule/utils.js +600 -0
  121. package/lib/modules/Step/index.d.ts +14 -3
  122. package/lib/modules/Step/index.js +38 -1
  123. package/lib/modules/Summary/index.d.ts +12 -5
  124. package/lib/modules/Summary/index.js +15 -1
  125. package/lib/modules/Summary/types.d.ts +23 -2
  126. package/lib/modules/Summary/utils.d.ts +14 -4
  127. package/lib/modules/Summary/utils.js +30 -1
  128. package/lib/modules/index.d.ts +10 -0
  129. package/lib/modules/index.js +21 -1
  130. package/lib/plugins/index.d.ts +3 -3
  131. package/lib/plugins/request.d.ts +3 -3
  132. package/lib/plugins/request.js +48 -11
  133. package/lib/plugins/shopStore.d.ts +1 -1
  134. package/lib/solution/BookingByStep/index.d.ts +97 -24
  135. package/lib/solution/BookingByStep/index.js +693 -145
  136. package/lib/solution/BookingByStep/types.d.ts +3 -10
  137. package/lib/solution/BookingByStep/types.js +37 -14
  138. package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
  139. package/lib/solution/BookingByStep/utils/products.js +3 -0
  140. package/lib/solution/BookingByStep/utils/resources.d.ts +60 -6
  141. package/lib/solution/BookingByStep/utils/resources.js +286 -54
  142. package/lib/solution/BuyTickets/index.js +34 -20
  143. package/lib/solution/ShopDiscount/index.d.ts +4 -4
  144. package/lib/solution/ShopDiscount/index.js +10 -2
  145. package/lib/solution/ShopDiscount/types.d.ts +2 -2
  146. package/package.json +4 -2
  147. package/dist/core/index.d.ts.map +0 -1
  148. package/dist/effects/index.d.ts.map +0 -1
  149. package/dist/index.d.ts.map +0 -1
  150. package/dist/modules/Account/index.d.ts.map +0 -1
  151. package/dist/modules/Account/types.d.ts.map +0 -1
  152. package/dist/modules/AccountList/types.d.ts.map +0 -1
  153. package/dist/modules/Cart/index.d.ts.map +0 -1
  154. package/dist/modules/Cart/types.d.ts.map +0 -1
  155. package/dist/modules/Date/types.d.ts.map +0 -1
  156. package/dist/modules/Date/utils.d.ts.map +0 -1
  157. package/dist/modules/Guests/index.d.ts.map +0 -1
  158. package/dist/modules/Guests/types.d.ts.map +0 -1
  159. package/dist/modules/Order/index.d.ts.map +0 -1
  160. package/dist/modules/Order/types.d.ts.map +0 -1
  161. package/dist/modules/Payment/index.d.ts.map +0 -1
  162. package/dist/modules/Payment/types.d.ts.map +0 -1
  163. package/dist/modules/Product/index.d.ts.map +0 -1
  164. package/dist/modules/Product/types.d.ts.map +0 -1
  165. package/dist/modules/ProductList/types.d.ts.map +0 -1
  166. package/dist/modules/Resource/index.d.ts.map +0 -1
  167. package/dist/modules/Resource/types.d.ts.map +0 -1
  168. package/dist/modules/Resource/utils.d.ts.map +0 -1
  169. package/dist/modules/Rules/types.d.ts.map +0 -1
  170. package/dist/modules/Step/index.d.ts.map +0 -1
  171. package/dist/modules/Step/tyeps.d.ts.map +0 -1
  172. package/dist/modules/Summary/index.d.ts.map +0 -1
  173. package/dist/modules/Summary/types.d.ts.map +0 -1
  174. package/dist/modules/Summary/utils.d.ts.map +0 -1
  175. package/dist/modules/index.d.ts.map +0 -1
  176. package/dist/plugins/index.d.ts.map +0 -1
  177. package/dist/plugins/request.d.ts.map +0 -1
  178. package/dist/plugins/shopStore.d.ts.map +0 -1
  179. package/dist/plugins/window.d.ts.map +0 -1
  180. package/dist/solution/BookingByStep/types.d.ts.map +0 -1
  181. package/dist/solution/BookingByStep/utils/products.d.ts.map +0 -1
  182. package/dist/solution/BuyTickets/index.d.ts.map +0 -1
  183. package/dist/solution/BuyTickets/types.d.ts.map +0 -1
  184. package/dist/solution/PlaceOrder/index.d.ts.map +0 -1
  185. package/dist/solution/ShopDiscount/types.d.ts.map +0 -1
  186. package/dist/solution/ShopDiscount/utils.d.ts.map +0 -1
  187. package/dist/solution/index.d.ts.map +0 -1
  188. package/dist/store/createStore.d.ts.map +0 -1
  189. package/dist/types/index.d.ts.map +0 -1
@@ -16,6 +16,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
16
16
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
17
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
18
  import { BaseModule } from "../BaseModule";
19
+ import { generateDuration } from "./utils";
19
20
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
20
21
  _inherits(OrderModule, _BaseModule);
21
22
  var _super = _createSuper(OrderModule);
@@ -23,8 +24,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
23
24
  var _this;
24
25
  _classCallCheck(this, OrderModule);
25
26
  _this = _super.call(this, name, version);
26
- _defineProperty(_assertThisInitialized(_this), "defaultName", "order");
27
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
27
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'order');
28
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
28
29
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
29
30
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
30
31
  return _this;
@@ -38,7 +39,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
38
39
  case 0:
39
40
  this.core = core;
40
41
  this.store = options.store;
41
- this.request = this.core.getPlugin("request");
42
+ this.request = this.core.getPlugin('request');
42
43
  case 3:
43
44
  case "end":
44
45
  return _context.stop();
@@ -54,46 +55,74 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
54
55
  key: "createOrder",
55
56
  value: function createOrder(params) {
56
57
  var order = {
57
- type: "appointment_booking",
58
- platform: "H5",
59
- sales_channel: "my_pisel",
60
- order_sales_channel: "online_store",
58
+ type: 'appointment_booking',
59
+ platform: 'H5',
60
+ sales_channel: 'my_pisel',
61
+ order_sales_channel: 'online_store',
61
62
  bookings: [],
62
- shop_note: "",
63
- schedule_date: ""
63
+ shop_note: '',
64
+ schedule_date: '',
65
+ is_deposit: 0
64
66
  };
67
+ var is_deposit = 0; // 是否存在定金,0 不存在,1 存在
65
68
  if (params.cartItems.length > 0) {
66
69
  params.cartItems.forEach(function (item) {
70
+ if (!item._origin.duration) {
71
+ var _generateDuration = generateDuration(item),
72
+ duration = _generateDuration.duration,
73
+ durationType = _generateDuration.durationType;
74
+ item._origin.duration = duration;
75
+ item._origin.sub_type = durationType;
76
+ }
67
77
  order.bookings.push(item._origin);
78
+ if (item !== null && item !== void 0 && item.deposit) {
79
+ is_deposit = 1;
80
+ }
68
81
  });
69
82
  var firstCartItem = params.cartItems[0];
70
- order.schedule_date = firstCartItem.start_date + " " + firstCartItem.start_time + ":00";
83
+ order.schedule_date = firstCartItem.start_date + ' ' + firstCartItem.start_time + ':00';
84
+ order.is_deposit = is_deposit;
71
85
  }
72
86
  return order;
73
87
  }
74
88
  }, {
75
- key: "commitOrder",
89
+ key: "checkBeforeSubmitOrder",
90
+ value: function checkBeforeSubmitOrder(params) {
91
+ var cartItems = params.cartItems,
92
+ type = params.type;
93
+ if (type === 'holder') {
94
+ // 判断cartItems中是否有不存在holder_id的商品,如果有则返回false
95
+ var hasNoHolderId = cartItems.some(function (item) {
96
+ return !item.holder_id;
97
+ });
98
+ if (hasNoHolderId) {
99
+ return false;
100
+ }
101
+ }
102
+ return true;
103
+ }
104
+ }, {
105
+ key: "submitOrder",
76
106
  value: function () {
77
- var _commitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(order) {
107
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(order) {
78
108
  var url, query, fetchUrl, params;
79
109
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
80
110
  while (1) switch (_context2.prev = _context2.next) {
81
111
  case 0:
82
112
  url = order.url, query = order.query;
83
- fetchUrl = url || "/order/appointment";
113
+ fetchUrl = url || '/order/appointment';
84
114
  params = this.createOrder(query);
85
- console.log(params);
86
115
  return _context2.abrupt("return", this.request.post(fetchUrl, params));
87
- case 5:
116
+ case 4:
88
117
  case "end":
89
118
  return _context2.stop();
90
119
  }
91
120
  }, _callee2, this);
92
121
  }));
93
- function commitOrder(_x3) {
94
- return _commitOrder.apply(this, arguments);
122
+ function submitOrder(_x3) {
123
+ return _submitOrder.apply(this, arguments);
95
124
  }
96
- return commitOrder;
125
+ return submitOrder;
97
126
  }()
98
127
  }]);
99
128
  return OrderModule;
@@ -1,4 +1,4 @@
1
- import { CartItem } from "../Cart/types";
1
+ import { CartItem } from '../Cart/types';
2
2
  export declare enum OrderHooks {
3
3
  OnOrderCreate = "order:onOrderCreate",
4
4
  OnOrderUpdate = "order:onOrderUpdate",
@@ -25,10 +25,17 @@ export interface OrderModuleAPI {
25
25
  * @param params 订单信息
26
26
  * @returns 订单信息
27
27
  */
28
- createOrder: (params: CommitOrderParams["query"]) => any;
28
+ createOrder: (params: CommitOrderParams['query']) => any;
29
+ /**
30
+ * 检查购物车提交订单前是否符合条件
31
+ */
32
+ checkBeforeSubmitOrder: (params: {
33
+ cartItems: CartItem[];
34
+ type: 'holder' | 'account';
35
+ }) => boolean;
29
36
  /**
30
37
  * 提交订单
31
38
  * @param params 订单信息
32
39
  */
33
- commitOrder: (params: CommitOrderParams) => Promise<void>;
40
+ submitOrder: (params: CommitOrderParams) => Promise<void>;
34
41
  }
@@ -0,0 +1,10 @@
1
+ import { CartItem } from "../Cart";
2
+ /**
3
+ * 通过 session 类商品的开始时间结束时间生成商品的时长
4
+ * @param {CartItem} cartItem
5
+ * @return {*}
6
+ */
7
+ export declare const generateDuration: (cartItem: CartItem) => {
8
+ duration: number;
9
+ durationType: string;
10
+ };
@@ -0,0 +1,15 @@
1
+ import dayjs from "dayjs";
2
+ /**
3
+ * 通过 session 类商品的开始时间结束时间生成商品的时长
4
+ * @param {CartItem} cartItem
5
+ * @return {*}
6
+ */
7
+ export var generateDuration = function generateDuration(cartItem) {
8
+ var startDate = dayjs("".concat(cartItem.start_date, " ").concat(cartItem.start_time));
9
+ var endDate = dayjs("".concat(cartItem.end_date, " ").concat(cartItem.end_time));
10
+ var duration = endDate.diff(startDate, 'minutes');
11
+ return {
12
+ duration: duration,
13
+ durationType: 'minutes'
14
+ };
15
+ };
@@ -2,16 +2,26 @@ import { Module, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
3
  import { ProductData, ProductMedia, ProductTag, ProductCategory, ProductBundleGroup } from './types';
4
4
  export * from './types';
5
+ /**
6
+ * 商品详情模块
7
+ * 除了跟商品列表模块组合外,还会提供单独的商品详情页的一些方法
8
+ *
9
+ * @export
10
+ * @class Product
11
+ * @extends {BaseModule}
12
+ * @implements {Module}
13
+ */
5
14
  export declare class Product extends BaseModule implements Module {
6
15
  protected defaultName: string;
7
16
  protected defaultVersion: string;
8
17
  private store;
18
+ protected otherParams: any;
9
19
  constructor(name?: string, version?: string);
10
20
  initialize(core: PisellCore, options: any): Promise<void>;
11
21
  /**
12
22
  * 获取商品数据
13
23
  */
14
- getData(): ProductData | null;
24
+ getData(): ProductData;
15
25
  /**
16
26
  * 获取商品ID
17
27
  */
@@ -36,4 +46,7 @@ export declare class Product extends BaseModule implements Module {
36
46
  * 获取商品分类
37
47
  */
38
48
  getCategories(): ProductCategory[];
49
+ setOtherParams(key: string, value: any): void;
50
+ getOtherParams(): any;
51
+ getProductType(): "duration" | "session" | "normal";
39
52
  }
@@ -17,6 +17,16 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
17
17
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
18
  import { BaseModule } from "../BaseModule";
19
19
  export * from "./types";
20
+
21
+ /**
22
+ * 商品详情模块
23
+ * 除了跟商品列表模块组合外,还会提供单独的商品详情页的一些方法
24
+ *
25
+ * @export
26
+ * @class Product
27
+ * @extends {BaseModule}
28
+ * @implements {Module}
29
+ */
20
30
  export var Product = /*#__PURE__*/function (_BaseModule) {
21
31
  _inherits(Product, _BaseModule);
22
32
  var _super = _createSuper(Product);
@@ -27,6 +37,9 @@ export var Product = /*#__PURE__*/function (_BaseModule) {
27
37
  _defineProperty(_assertThisInitialized(_this), "defaultName", 'product');
28
38
  _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
29
39
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
40
+ _defineProperty(_assertThisInitialized(_this), "otherParams", {
41
+ scheduler: []
42
+ });
30
43
  return _this;
31
44
  }
32
45
  _createClass(Product, [{
@@ -113,6 +126,28 @@ export var Product = /*#__PURE__*/function (_BaseModule) {
113
126
  value: function getCategories() {
114
127
  return this.store.categories;
115
128
  }
129
+ }, {
130
+ key: "setOtherParams",
131
+ value: function setOtherParams(key, value) {
132
+ this.otherParams[key] = value;
133
+ }
134
+ }, {
135
+ key: "getOtherParams",
136
+ value: function getOtherParams() {
137
+ return this.otherParams;
138
+ }
139
+ }, {
140
+ key: "getProductType",
141
+ value: function getProductType() {
142
+ var _this$store$schedule;
143
+ if (this.store.duration) {
144
+ return 'duration';
145
+ }
146
+ if ((_this$store$schedule = this.store['schedule.ids']) !== null && _this$store$schedule !== void 0 && _this$store$schedule.length) {
147
+ return 'session';
148
+ }
149
+ return 'normal';
150
+ }
116
151
  }]);
117
152
  return Product;
118
153
  }(BaseModule);
@@ -17,7 +17,7 @@ export interface ProductData {
17
17
  /** 商品slug */
18
18
  slug: string;
19
19
  /** draft:草稿;published:已发布;pending:待发布;archived:已归档 */
20
- status: "draft" | "published" | "pending" | "archived";
20
+ status: 'draft' | 'published' | 'pending' | 'archived';
21
21
  /** 库存数量 */
22
22
  stock_quantity: number;
23
23
  /** 销售数量 */
@@ -152,6 +152,30 @@ export interface ProductData {
152
152
  options?: any[];
153
153
  /** 商品原信息 */
154
154
  origin?: any;
155
+ /** 容量 */
156
+ capacity?: any;
157
+ /** 商品套餐 */
158
+ product_bundle?: any;
159
+ /** 日程ids */
160
+ 'schedule.ids'?: number[];
161
+ /** 商品日程信息,前端临时用,随时需要回收的 */
162
+ _schedule?: any;
163
+ /** 商品定金信息 */
164
+ custom_deposit_data?: {
165
+ /** 商品是否包含定金 1:是 0:否 */
166
+ has_deposit: 0 | 1;
167
+ /** 定金固定金额 */
168
+ deposit_fixed?: string;
169
+ /** 定金百分比 */
170
+ deposit_percentage?: string;
171
+ /** 定金协议数据 */
172
+ deposit_policy_data?: Array<{
173
+ /** 定金协议id */
174
+ id: number;
175
+ /** 定金协议标题 */
176
+ title: string;
177
+ }>;
178
+ };
155
179
  }
156
180
  /**
157
181
  * 商品媒体信息接口
@@ -414,7 +438,7 @@ export interface ProductResourceItem {
414
438
  /** 资源标题 */
415
439
  title: string;
416
440
  /** 资源编码 */
417
- code: "resource";
441
+ code: 'resource';
418
442
  /** 默认资源 */
419
443
  default_resource?: number[];
420
444
  /** 可选资源 */
@@ -423,7 +447,7 @@ export interface ProductResourceItem {
423
447
  resource_type_id: number;
424
448
  /** 选择类型 */
425
449
  select_type?: {
426
- type: "single";
450
+ type: 'single';
427
451
  min: 1;
428
452
  max: 1;
429
453
  };
@@ -42,16 +42,22 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
42
42
  key: "initialize",
43
43
  value: function () {
44
44
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
45
+ var _options$initialState;
45
46
  return _regeneratorRuntime().wrap(function _callee$(_context) {
46
47
  while (1) switch (_context.prev = _context.next) {
47
48
  case 0:
48
49
  this.core = core;
49
50
  this.store = options.store;
50
- this.store.productMap = new Map();
51
- this.store.list = [];
52
- this.store.selectProducts = [];
53
- this.storeChange();
54
- case 6:
51
+ if (Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
52
+ this.store.list = options.initialState.list;
53
+ this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
54
+ this.storeChange();
55
+ } else {
56
+ this.store.list = [];
57
+ this.store.productMap = new Map();
58
+ this.store.selectProducts = [];
59
+ }
60
+ case 3:
55
61
  case "end":
56
62
  return _context.stop();
57
63
  }
@@ -26,6 +26,7 @@ export interface Resource {
26
26
  startTime?: string;
27
27
  endTime?: string;
28
28
  resourceType?: string;
29
+ children?: Resource[];
29
30
  }
30
31
  /**
31
32
  * 资源列表状态
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @title: 获取资源map
3
- * @description:
3
+ * @description:
4
4
  * @param {any} resourceList
5
5
  * @return {*}
6
6
  * @Author: zhiwei.Wang
@@ -1,6 +1,6 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { Rules, RulesModuleAPI, DiscountResult } from "./types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { Rules, RulesModuleAPI, DiscountResult } from './types';
4
4
  import { Discount } from "../Discount/types";
5
5
  export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
6
6
  protected defaultName: string;
@@ -26,6 +26,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
26
26
  import { BaseModule } from "../BaseModule";
27
27
  import { RulesHooks } from "./types";
28
28
  import { uniqueById } from "../../solution/ShopDiscount/utils";
29
+ import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
29
30
  export var RulesModule = /*#__PURE__*/function (_BaseModule) {
30
31
  _inherits(RulesModule, _BaseModule);
31
32
  var _super = _createSuper(RulesModule);
@@ -33,8 +34,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
33
34
  var _this;
34
35
  _classCallCheck(this, RulesModule);
35
36
  _this = _super.call(this, name, version);
36
- _defineProperty(_assertThisInitialized(_this), "defaultName", "rules");
37
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
37
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'rules');
38
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
38
39
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
39
40
  _defineProperty(_assertThisInitialized(_this), "hooks", void 0);
40
41
  _this.hooks = {};
@@ -175,8 +176,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
175
176
  var sortedProductList = _toConsumableArray(productList).sort(function (a, b) {
176
177
  var aProduct = _this3.hooks.getProduct(a);
177
178
  var bProduct = _this3.hooks.getProduct(b);
178
- var priceA = parseFloat(aProduct.price || "0");
179
- var priceB = parseFloat(bProduct.price || "0");
179
+ var priceA = parseFloat(aProduct.price || '0');
180
+ var priceB = parseFloat(bProduct.price || '0');
180
181
  return priceB - priceA;
181
182
  });
182
183
 
@@ -209,7 +210,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
209
210
  var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
210
211
 
211
212
  // 是符合折扣的商品
212
- var isLimitedProduct = limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id);
213
+ var isLimitedProduct = limitedData.type === 'product_all' || limitedData.product_ids && limitedData.product_ids.includes(product.id);
213
214
 
214
215
  // 编辑的商品 使用了优惠券不可用
215
216
  var isAvailableProduct = !(product !== null && product !== void 0 && product.booking_id && product !== null && product !== void 0 && (_product$discount_lis = product.discount_list) !== null && _product$discount_lis !== void 0 && _product$discount_lis.length && product !== null && product !== void 0 && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.every(function (discount) {
@@ -256,7 +257,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
256
257
  var limitedData = discount.limited_relation_product_data;
257
258
 
258
259
  // 判断优惠券是否适用于该商品
259
- if (limitedData.type === "product_all") {
260
+ if (limitedData.type === 'product_all') {
260
261
  return true;
261
262
  } else if (limitedData.product_ids && limitedData.product_ids.includes(product.id)) {
262
263
  return true;
@@ -268,7 +269,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
268
269
  var selectedDiscount = applicableDiscounts[0];
269
270
 
270
271
  // 如果是手动折扣,则不适用优惠券
271
- var isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : product.total != product.origin_total && !((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length);
272
+ var isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && !((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length);
272
273
 
273
274
  // 勾选时覆盖手动折扣
274
275
  if (options !== null && options !== void 0 && options.discountId && (options === null || options === void 0 ? void 0 : options.discountId) === (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.id)) {
@@ -277,55 +278,122 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
277
278
 
278
279
  // 如果没有适用的优惠券,或者手动折扣,则不适用优惠券
279
280
  if (applicableDiscounts.length === 0 || isManualDiscount) {
280
- processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
281
- total: product.origin_total || product.total,
282
- price: product.price
283
- }), {}, {
284
- discount_list: []
285
- })));
286
- return;
287
- }
288
- if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined') {
289
- return;
290
- }
281
+ if (product.isClient) {
282
+ processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
283
+ origin_total: getProductOriginTotalPrice({
284
+ product: {
285
+ original_price: product.original_price
286
+ },
287
+ bundle: product.bundle,
288
+ options: product.options
289
+ }),
290
+ total: getProductTotalPrice({
291
+ product: {
292
+ price: product.price
293
+ },
294
+ bundle: product.bundle,
295
+ options: product.options
296
+ }),
297
+ price: product.price
298
+ }), {}, {
299
+ discount_list: []
300
+ })));
301
+ } else {
302
+ processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
303
+ total: product.origin_total || product.total,
304
+ price: product.price
305
+ }), {}, {
306
+ discount_list: []
307
+ })));
308
+ return;
309
+ }
310
+ if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined') {
311
+ return;
312
+ }
291
313
 
292
- // 标记优惠券为已使用
293
- usedDiscounts.set(selectedDiscount.id, true);
294
-
295
- // 记录实际应用了优惠券的商品信息
296
- var appliedProducts = appliedDiscountProducts.get(selectedDiscount.id) || [];
297
- var discountDetail = {
298
- amount: product.price,
299
- type: selectedDiscount.tag,
300
- discount: {
301
- resource_id: selectedDiscount.id,
302
- title: selectedDiscount.format_title,
303
- original_amount: product.origin_total,
304
- product_id: selectedDiscount.product_id
314
+ // 标记优惠券为已使用
315
+ usedDiscounts.set(selectedDiscount.id, true);
316
+
317
+ // 记录实际应用了优惠券的商品信息
318
+ var appliedProducts = appliedDiscountProducts.get(selectedDiscount.id) || [];
319
+ var discountDetail = {
320
+ amount: product.price,
321
+ type: selectedDiscount.tag,
322
+ discount: {
323
+ resource_id: selectedDiscount.id,
324
+ title: selectedDiscount.format_title,
325
+ original_amount: product.origin_total,
326
+ product_id: selectedDiscount.product_id
327
+ }
328
+ };
329
+ appliedProducts.push(discountDetail);
330
+ appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
331
+
332
+ // 记录应用了优惠券的商品
333
+ // 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
334
+ if (product.isClient) {
335
+ processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, {
336
+ discount_list: [discountDetail],
337
+ price: 0,
338
+ origin_total: getProductOriginTotalPrice({
339
+ product: {
340
+ original_price: product.original_price
341
+ },
342
+ bundle: product.bundle,
343
+ options: product.options
344
+ }),
345
+ total: getProductTotalPrice({
346
+ product: {
347
+ price: '0'
348
+ },
349
+ bundle: product.bundle,
350
+ options: product.options
351
+ })
352
+ }));
353
+ } else {
354
+ processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, {
355
+ discount_list: [discountDetail],
356
+ price: 0,
357
+ total: (product.origin_total || product.total) - product.price,
358
+ origin_total: product.origin_total || product.total
359
+ }));
305
360
  }
306
- };
307
- appliedProducts.push(discountDetail);
308
- appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
309
-
310
- // 记录应用了优惠券的商品
311
- // 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
312
- processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, {
313
- discount_list: [discountDetail],
314
- price: 0,
315
- total: (product.origin_total || product.total) - product.price,
316
- origin_total: product.origin_total || product.total
317
- }));
361
+ }
318
362
  });
319
363
 
320
364
  // 按原始顺序构建处理后的商品列表
321
365
  var processedProductList = productList.map(function (originProduct) {
322
366
  var product = _this3.hooks.getProduct(originProduct);
323
- return processedProductsMap.get(product._id) || _this3.hooks.setProduct(originProduct, {
324
- discount_list: [],
325
- total: product.total,
326
- origin_total: product.origin_total,
327
- price: product.price
328
- });
367
+ var getDefaultProduct = function getDefaultProduct() {
368
+ if (product.isClient) {
369
+ _this3.hooks.setProduct(originProduct, {
370
+ discount_list: [],
371
+ price: product.price,
372
+ origin_total: getProductOriginTotalPrice({
373
+ product: {
374
+ original_price: product.original_price
375
+ },
376
+ bundle: product.bundle,
377
+ options: product.options
378
+ }),
379
+ total: getProductTotalPrice({
380
+ product: {
381
+ price: product.price
382
+ },
383
+ bundle: product.bundle,
384
+ options: product.options
385
+ })
386
+ });
387
+ } else {
388
+ _this3.hooks.setProduct(originProduct, {
389
+ discount_list: [],
390
+ total: product.total,
391
+ origin_total: product.origin_total,
392
+ price: product.price
393
+ });
394
+ }
395
+ };
396
+ return processedProductsMap.get(product._id) || getDefaultProduct();
329
397
  });
330
398
 
331
399
  // 按原始顺序更新优惠券列表,标记已使用和可用的优惠券
@@ -343,7 +411,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
343
411
  var isAvailable = applicableProducts.length > 0;
344
412
 
345
413
  // 如果此优惠券被明确设置为不选中,保持其状态,但正确设置isAvailable
346
- if (typeof discount.isSelected === "boolean" && discount.isSelected === false && discount.isManualSelect) {
414
+ if (typeof discount.isSelected === 'boolean' && discount.isSelected === false && discount.isManualSelect) {
347
415
  return _objectSpread(_objectSpread({}, discount), {}, {
348
416
  isSelected: false,
349
417
  isAvailable: isAvailable,
@@ -368,7 +436,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
368
436
  appliedProductDetails: appliedProductDetails
369
437
  });
370
438
  }
371
- var isSelected = typeof discount.isSelected === "boolean" ? discount.isSelected : undefined;
439
+ var isSelected = typeof discount.isSelected === 'boolean' ? discount.isSelected : undefined;
372
440
 
373
441
  // 如果是可用的 并且没有手动标记 则设置为选中
374
442
  if (isAvailable && appliedProductDetails.length && !discount.isManualSelect) {
@@ -404,7 +472,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
404
472
  _context3.next = 3;
405
473
  return this.core.effects.emit(RulesHooks.OnDestroy, {});
406
474
  case 3:
407
- console.log("[Rules] 已销毁");
475
+ console.log('[Rules] 已销毁');
408
476
  case 4:
409
477
  case "end":
410
478
  return _context3.stop();
@@ -423,7 +491,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
423
491
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
424
492
  while (1) switch (_context4.prev = _context4.next) {
425
493
  case 0:
426
- console.log("[Rules] clear");
494
+ console.log('[Rules] clear');
427
495
  case 1:
428
496
  case "end":
429
497
  return _context4.stop();
@@ -1,4 +1,4 @@
1
- import { Discount } from "../Discount/types";
1
+ import { Discount } from '../Discount/types';
2
2
  export declare enum RulesHooks {
3
3
  OnRulesListChange = "rules:onRulesListChange",
4
4
  OnDestroy = "rules:onDestroy"
@@ -25,6 +25,7 @@ export interface RulesModuleAPI {
25
25
  }) => DiscountResult;
26
26
  }
27
27
  type ProductDetail = {
28
+ isClient?: boolean;
28
29
  isManualDiscount?: boolean;
29
30
  booking_id: any;
30
31
  id: number;
@@ -33,6 +34,9 @@ type ProductDetail = {
33
34
  discount_list: Discount[];
34
35
  origin_total: number;
35
36
  _id: string;
37
+ options?: any[];
38
+ bundle?: any[];
39
+ original_price?: number | string;
36
40
  };
37
41
  export interface RulesParamsHooks {
38
42
  getProduct: (product: Record<string, any>) => ProductDetail;