@pisell/private-materials 3.4.3 → 3.4.4

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 (183) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +13 -13
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +4 -4
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +7 -7
  11. package/es/components/Sales/Cart/index.js +5 -1
  12. package/es/components/Sales/Cart/utils.d.ts +40 -0
  13. package/es/components/Sales/Cart/utils.js +187 -0
  14. package/es/components/Sales/Checkout/index.d.ts +4 -0
  15. package/es/components/Sales/Checkout/index.js +52 -8
  16. package/es/components/Sales/Checkout/serve.d.ts +13 -0
  17. package/es/components/Sales/Checkout/serve.js +16 -2
  18. package/es/components/Sales/Checkout/utils.d.ts +1 -0
  19. package/es/components/Sales/Checkout/utils.js +9 -2
  20. package/es/components/Sales/Customer/index.d.ts +25 -0
  21. package/es/components/Sales/Event/Detail.d.ts +1 -0
  22. package/es/components/Sales/Event/Detail.js +45 -11
  23. package/es/components/Sales/Event/serve.d.ts +10 -0
  24. package/es/components/Sales/Event/serve.js +25 -0
  25. package/es/components/Sales/Summary/index.d.ts +10 -0
  26. package/es/components/Sales/Summary/index.js +17 -2
  27. package/es/components/Sales/Summary/serve.d.ts +1 -0
  28. package/es/components/Sales/Summary/serve.js +6 -0
  29. package/es/components/Sales/Summary/utils.d.ts +16 -1
  30. package/es/components/Sales/Summary/utils.js +43 -1
  31. package/es/components/appointmentBooking/components/Content/index.js +15 -1
  32. package/es/components/appointmentBooking/components/Deposit/index.d.ts +6 -0
  33. package/es/components/appointmentBooking/components/Deposit/index.js +27 -7
  34. package/es/components/appointmentBooking/components/Form/index.d.ts +4 -0
  35. package/es/components/appointmentBooking/components/Form/utils.d.ts +8 -0
  36. package/es/components/appointmentBooking/deposit/components/PolicyModal/index.js +25 -20
  37. package/es/components/appointmentBooking/deposit/index.js +4 -2
  38. package/es/components/booking/components/TabProduct/tabs/index.js +1 -5
  39. package/es/components/booking/components/browserSelect/index.js +1 -1
  40. package/es/components/booking/components/footer/index.js +32 -24
  41. package/es/components/booking/forms/model.js +5 -5
  42. package/es/components/booking/info/service/Lists.d.ts +2 -0
  43. package/es/components/booking/info/service/addService/utils.d.ts +1 -1
  44. package/es/components/booking/info/service/like/index.js +1 -1
  45. package/es/components/booking/info/utils.js +1 -1
  46. package/es/components/booking/info2/service/addService/utils.d.ts +1 -1
  47. package/es/components/booking/info2/service/index.d.ts +4 -0
  48. package/es/components/booking/info2/utils.d.ts +4 -0
  49. package/es/components/booking/info2/utilsByBooking.js +9 -3
  50. package/es/components/booking/materiels/startTime/index.js +1 -1
  51. package/es/components/booking/notes/NoteBlock/NoteItem/index.js +1 -1
  52. package/es/components/booking/notes/NoteBlock/index.js +11 -11
  53. package/es/components/booking/notes/model.js +5 -5
  54. package/es/components/booking/payments/model.js +5 -5
  55. package/es/components/booking/utils.d.ts +2 -2
  56. package/es/components/eftposPay/amount.d.ts +1 -1
  57. package/es/components/eftposPay/device.d.ts +1 -1
  58. package/es/components/eftposPay/hooks.d.ts +2 -2
  59. package/es/components/eftposPay/store/index.d.ts +5 -5
  60. package/es/components/eventBooking/components/Provider/Cart/ContinueButton/index.js +29 -17
  61. package/es/components/eventBooking/components/Provider/Cart/Deposit/index.d.ts +2 -0
  62. package/es/components/eventBooking/components/Provider/Cart/Deposit/index.js +17 -0
  63. package/es/components/eventBooking/components/Provider/Cart/Item/Total.js +10 -6
  64. package/es/components/eventBooking/components/Provider/Cart/Item/index.js +4 -2
  65. package/es/components/eventBooking/components/bookingDetailModal/index.js +6 -3
  66. package/es/components/eventBooking/locales.d.ts +24 -0
  67. package/es/components/eventBooking/locales.js +27 -3
  68. package/es/components/listComponent/index.js +5 -5
  69. package/es/components/pay/toC/PaymentMethods/GlobePayAliPayH5/index.js +18 -3
  70. package/es/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.d.ts +1 -1
  71. package/es/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.js +7 -2
  72. package/es/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.less +8 -0
  73. package/es/components/pay/toC/PaymentMethods/SuperPayAliPayH5/index.js +18 -3
  74. package/es/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +113 -0
  75. package/es/components/pay/toC/locales.d.ts +3 -0
  76. package/es/components/pay/toC/locales.js +3 -0
  77. package/es/components/pay/toC/utils.d.ts +57 -0
  78. package/es/components/productExtension/card/index.js +3 -3
  79. package/es/components/productExtension/fields/Actor/CutOffTime/index.js +1 -1
  80. package/es/components/productExtension/fields/Forms/index.js +12 -12
  81. package/es/components/productExtension/fields/SelectProducts/ProductItemPreview/index.js +1 -1
  82. package/es/components/productExtension/fields/SelectProducts/server.js +2 -2
  83. package/es/components/productExtension/fields/SelectResourcesTable/server.js +2 -2
  84. package/es/components/productExtension/server.js +2 -2
  85. package/es/components/ruleSetting/ruleBorder/index.js +1 -1
  86. package/es/components/schedules/calendar/index.js +4 -4
  87. package/es/components/schedules/calendar/serve.js +2 -2
  88. package/es/components/schedules/components/CurrentDay/index.js +5 -5
  89. package/es/components/schedules/components/CurrentDay/serve.js +2 -2
  90. package/es/components/schedules/components/DropdownSort/index.js +1 -1
  91. package/es/components/schedules/components/ResourceList/index.js +1 -1
  92. package/es/components/schedules/components/Search/index.js +5 -5
  93. package/es/components/schedules/model.js +5 -5
  94. package/es/components/schedules/openHours/index.js +1 -1
  95. package/es/components/schedules/openHours/serve.js +2 -2
  96. package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/MaxParticipantsModule/index.js +1 -1
  97. package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/ResourcesModule/index.js +5 -5
  98. package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/SchedulesModule/index.js +4 -4
  99. package/es/components/schedules/products/ProductDetailDrawer/index.js +3 -3
  100. package/es/components/schedules/products/serve.js +2 -2
  101. package/es/components/schedules/products/utils.js +5 -5
  102. package/es/components/schedules/resources/detail/detailContent.js +2 -2
  103. package/es/components/schedules/resources/detail/index.js +10 -10
  104. package/es/components/schedules/resources/list/index.js +2 -2
  105. package/es/components/schedules/resources/relationProduct/index.js +1 -1
  106. package/es/components/schedules/resources/serve.js +2 -2
  107. package/es/components/schedules/schedules/ScheduleDetailDrawer/index.js +9 -9
  108. package/es/components/schedules/utils.d.ts +1 -1
  109. package/es/components/schedules/utils.js +4 -4
  110. package/es/components/selectModal/index.js +2 -2
  111. package/es/components/shoppingCart/components/Cart/Product.d.ts +3 -0
  112. package/es/components/ticketBooking/components/menuBar/index.js +38 -2
  113. package/es/components/ticketBooking/components/menuBar/index.less +8 -0
  114. package/es/components/ticketBooking/locales.d.ts +174 -0
  115. package/es/components/ticketBooking/locales.js +6 -3
  116. package/es/hooks/useComponents.js +1 -1
  117. package/es/utils/index.d.ts +1 -1
  118. package/lib/components/Sales/Cart/index.js +1 -0
  119. package/lib/components/Sales/Cart/utils.d.ts +40 -0
  120. package/lib/components/Sales/Cart/utils.js +129 -0
  121. package/lib/components/Sales/Checkout/index.d.ts +4 -0
  122. package/lib/components/Sales/Checkout/index.js +39 -7
  123. package/lib/components/Sales/Checkout/serve.d.ts +13 -0
  124. package/lib/components/Sales/Checkout/serve.js +7 -2
  125. package/lib/components/Sales/Checkout/utils.d.ts +1 -0
  126. package/lib/components/Sales/Checkout/utils.js +5 -2
  127. package/lib/components/Sales/Customer/index.d.ts +25 -0
  128. package/lib/components/Sales/Event/Detail.d.ts +1 -0
  129. package/lib/components/Sales/Event/Detail.js +37 -12
  130. package/lib/components/Sales/Event/serve.d.ts +10 -0
  131. package/lib/components/Sales/Event/serve.js +7 -0
  132. package/lib/components/Sales/Summary/index.d.ts +10 -0
  133. package/lib/components/Sales/Summary/index.js +7 -1
  134. package/lib/components/Sales/Summary/serve.d.ts +1 -0
  135. package/lib/components/Sales/Summary/serve.js +32 -0
  136. package/lib/components/Sales/Summary/utils.d.ts +16 -1
  137. package/lib/components/Sales/Summary/utils.js +30 -1
  138. package/lib/components/appointmentBooking/components/Content/index.js +6 -1
  139. package/lib/components/appointmentBooking/components/Deposit/index.d.ts +6 -0
  140. package/lib/components/appointmentBooking/components/Deposit/index.js +36 -4
  141. package/lib/components/appointmentBooking/components/Form/index.d.ts +4 -0
  142. package/lib/components/appointmentBooking/components/Form/utils.d.ts +8 -0
  143. package/lib/components/appointmentBooking/deposit/components/PolicyModal/index.js +8 -4
  144. package/lib/components/appointmentBooking/deposit/index.js +4 -2
  145. package/lib/components/booking/components/footer/index.js +24 -11
  146. package/lib/components/booking/info/service/Lists.d.ts +2 -0
  147. package/lib/components/booking/info/service/addService/utils.d.ts +1 -1
  148. package/lib/components/booking/info/utils.js +3 -1
  149. package/lib/components/booking/info2/service/addService/utils.d.ts +1 -1
  150. package/lib/components/booking/info2/service/index.d.ts +4 -0
  151. package/lib/components/booking/info2/utils.d.ts +4 -0
  152. package/lib/components/booking/info2/utilsByBooking.js +4 -1
  153. package/lib/components/booking/utils.d.ts +2 -2
  154. package/lib/components/eftposPay/amount.d.ts +1 -1
  155. package/lib/components/eftposPay/device.d.ts +1 -1
  156. package/lib/components/eftposPay/hooks.d.ts +2 -2
  157. package/lib/components/eftposPay/store/index.d.ts +5 -5
  158. package/lib/components/eventBooking/components/Provider/Cart/ContinueButton/index.js +16 -4
  159. package/lib/components/eventBooking/components/Provider/Cart/Deposit/index.d.ts +2 -0
  160. package/lib/components/eventBooking/components/Provider/Cart/Deposit/index.js +55 -0
  161. package/lib/components/eventBooking/components/Provider/Cart/Item/Total.js +8 -5
  162. package/lib/components/eventBooking/components/Provider/Cart/Item/index.js +4 -2
  163. package/lib/components/eventBooking/components/bookingDetailModal/index.js +4 -3
  164. package/lib/components/eventBooking/locales.d.ts +24 -0
  165. package/lib/components/eventBooking/locales.js +27 -3
  166. package/lib/components/pay/toC/PaymentMethods/GlobePayAliPayH5/index.js +13 -1
  167. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.d.ts +1 -1
  168. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.js +2 -2
  169. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.less +8 -0
  170. package/lib/components/pay/toC/PaymentMethods/SuperPayAliPayH5/index.js +13 -1
  171. package/lib/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +113 -0
  172. package/lib/components/pay/toC/locales.d.ts +3 -0
  173. package/lib/components/pay/toC/locales.js +3 -0
  174. package/lib/components/pay/toC/utils.d.ts +57 -0
  175. package/lib/components/schedules/utils.d.ts +1 -1
  176. package/lib/components/schedules/utils.js +1 -1
  177. package/lib/components/shoppingCart/components/Cart/Product.d.ts +3 -0
  178. package/lib/components/ticketBooking/components/menuBar/index.js +42 -2
  179. package/lib/components/ticketBooking/components/menuBar/index.less +8 -0
  180. package/lib/components/ticketBooking/locales.d.ts +174 -0
  181. package/lib/components/ticketBooking/locales.js +6 -3
  182. package/lib/utils/index.d.ts +1 -1
  183. package/package.json +4 -4
@@ -22,7 +22,7 @@ import { checkBeforeAddToCartApi } from "./serve";
22
22
  import { useCustomer } from "../Customer";
23
23
  import { useRequest } from 'ahooks';
24
24
  import { formatValues } from "../Checkout/utils";
25
- import { handleCartItemOrigin, handleProductInfo } from "./utils";
25
+ import { handleCartItemOrigin, handleProductDeposit, handleProductInfo } from "./utils";
26
26
  var defaultState = {
27
27
  cartItems: [],
28
28
  currentCartItem: null
@@ -329,6 +329,10 @@ export var CartProvider = function CartProvider(_ref) {
329
329
  }),
330
330
  _productDetail: eventDetail.productDetail
331
331
  };
332
+
333
+ // 处理定金
334
+ newCartItem.deposit = handleProductDeposit(newCartItem, eventDetail, num);
335
+ // 处理提交给接口的数据
332
336
  var originData = handleCartItemOrigin(newCartItem, eventDetail);
333
337
  newCartItem._originData = originData;
334
338
  if (_holderItem !== null && _holderItem !== void 0 && _holderItem._originData) {
@@ -1,3 +1,4 @@
1
+ import Decimal from 'decimal.js';
1
2
  import { ICalculatePriceParams } from './types';
2
3
  export declare const handleProductInfo: (eventDetail: any, num: number) => {
3
4
  totalPrice: number;
@@ -21,3 +22,42 @@ export declare const getOriginTotalPrice: (params: ICalculatePriceParams) => num
21
22
  export declare const handleCartItemOrigin: (cartItem: any, eventDetail: any) => any;
22
23
  export declare const formatBundleToOrigin: (bundle: any) => any;
23
24
  export declare const formatOptionsToOrigin: (options: any) => any;
25
+ export declare const handleProductDeposit: (cartItem: any, eventDetail: any, num: number) => {
26
+ total: number;
27
+ protocols: any;
28
+ } | null;
29
+ /**
30
+ * 获取商品定金
31
+ * @description 定金基于商品售价来算,最终乘商品数量
32
+ * 1、如果套餐主商品有定金规则,则定金为:(套餐商品总售价 * 定金百分比 + 定金固定金额)* 商品数量
33
+ * 2、如果套餐主商品没有定金规则,子商品有定金规则,则定金为:(套餐子商品售价 * 套餐子商品定金百分比 + 套餐子商品定金固定金额)* 商品数量,最终将所有子商品定金相加
34
+ * 3、普通商品/单规格商品/组合规则商品,定金规则:(商品总售价 * 定金百分比 + 定金固定金额)* 商品数量
35
+ * @param params 参数
36
+ * @returns 商品定金
37
+ */
38
+ export declare const getProductDeposit: (params: {
39
+ cartItem: any;
40
+ product: any;
41
+ bundle?: any;
42
+ options?: any;
43
+ num?: number;
44
+ }) => {
45
+ total: number;
46
+ protocols: any;
47
+ } | null;
48
+ /**
49
+ * 计算商品定金
50
+ * @param params 参数
51
+ * @returns 商品定金
52
+ */
53
+ export declare const calculateProductDeposit: (params: {
54
+ depositData: {
55
+ deposit_fixed?: string;
56
+ deposit_percentage?: string;
57
+ };
58
+ total: string | number;
59
+ num: number;
60
+ }) => {
61
+ result: boolean;
62
+ depositTotal: Decimal;
63
+ };
@@ -1,3 +1,10 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ 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."); }
3
+ 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); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
+ import Decimal from 'decimal.js';
1
8
  export var handleProductInfo = function handleProductInfo(eventDetail, num) {
2
9
  var productDetail = eventDetail.productDetail,
3
10
  bookingOptionItem = eventDetail.bookingOptionItem;
@@ -158,4 +165,184 @@ export var formatOptionsToOrigin = function formatOptionsToOrigin(options) {
158
165
  option_group_id: d.option_group_id
159
166
  };
160
167
  });
168
+ };
169
+ export var handleProductDeposit = function handleProductDeposit(cartItem, eventDetail, num) {
170
+ var _origin$custom_deposi;
171
+ var productDetail = eventDetail.productDetail,
172
+ bookingOptionItem = eventDetail.bookingOptionItem;
173
+
174
+ // 如果是普通商品
175
+ var normalProduct = bookingOptionItem === null || bookingOptionItem === void 0 ? void 0 : bookingOptionItem._originData;
176
+ if (!productDetail && normalProduct) {
177
+ var custom_deposit_data = normalProduct.custom_deposit_data;
178
+ if ((custom_deposit_data === null || custom_deposit_data === void 0 ? void 0 : custom_deposit_data.has_deposit) == 1) {
179
+ return getProductDeposit({
180
+ cartItem: cartItem,
181
+ product: normalProduct,
182
+ num: num
183
+ });
184
+ } else {
185
+ return null;
186
+ }
187
+ }
188
+ if (!productDetail) {
189
+ return null;
190
+ }
191
+ var _ref = productDetail || {},
192
+ origin = _ref.origin,
193
+ bundle = _ref.bundle,
194
+ options = _ref.options,
195
+ product_variant_id = _ref.product_variant_id;
196
+ var deposit = null;
197
+ var product = origin;
198
+ if (product_variant_id) {
199
+ product.product_variant_id = product_variant_id;
200
+ }
201
+ if ((origin === null || origin === void 0 || (_origin$custom_deposi = origin.custom_deposit_data) === null || _origin$custom_deposi === void 0 ? void 0 : _origin$custom_deposi.has_deposit) == 1) {
202
+ deposit = getProductDeposit({
203
+ cartItem: cartItem,
204
+ product: product,
205
+ bundle: bundle,
206
+ options: options,
207
+ num: num
208
+ });
209
+ }
210
+ return deposit;
211
+ };
212
+
213
+ /**
214
+ * 获取商品定金
215
+ * @description 定金基于商品售价来算,最终乘商品数量
216
+ * 1、如果套餐主商品有定金规则,则定金为:(套餐商品总售价 * 定金百分比 + 定金固定金额)* 商品数量
217
+ * 2、如果套餐主商品没有定金规则,子商品有定金规则,则定金为:(套餐子商品售价 * 套餐子商品定金百分比 + 套餐子商品定金固定金额)* 商品数量,最终将所有子商品定金相加
218
+ * 3、普通商品/单规格商品/组合规则商品,定金规则:(商品总售价 * 定金百分比 + 定金固定金额)* 商品数量
219
+ * @param params 参数
220
+ * @returns 商品定金
221
+ */
222
+ export var getProductDeposit = function getProductDeposit(params) {
223
+ var _product$custom_depos;
224
+ var cartItem = params.cartItem,
225
+ product = params.product,
226
+ bundle = params.bundle,
227
+ options = params.options;
228
+ var num = (params === null || params === void 0 ? void 0 : params.num) || 1;
229
+
230
+ // 判定商品是否有定金规则
231
+ 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) {
232
+ var total = new Decimal(0);
233
+ var _ref2 = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
234
+ deposit_fixed = _ref2.deposit_fixed,
235
+ deposit_percentage = _ref2.deposit_percentage,
236
+ deposit_policy_data = _ref2.deposit_policy_data,
237
+ self_deposit_policy_ids = _ref2.self_deposit_policy_ids;
238
+ // 所有协议数据
239
+ var allProtocols = deposit_policy_data || [];
240
+ // 是否存在定金,主商品has_deposit为1,但是自身没有定金设置,需要判定子商品是否存在定金,如果不存在最终判定也是不存在定金
241
+ var productHasDeposit = false;
242
+ // 关联的定金协议id
243
+ var protocolIds = [];
244
+
245
+ // 判断主商品是否有定金规则
246
+ if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
247
+ var _calculateProductDepo = calculateProductDeposit({
248
+ depositData: product === null || product === void 0 ? void 0 : product.custom_deposit_data,
249
+ total: (cartItem === null || cartItem === void 0 ? void 0 : cartItem.total) || 0,
250
+ num: num
251
+ }),
252
+ depositTotal = _calculateProductDepo.depositTotal,
253
+ result = _calculateProductDepo.result;
254
+ if (result) {
255
+ total = depositTotal;
256
+ protocolIds.push.apply(protocolIds, _toConsumableArray(self_deposit_policy_ids || []));
257
+ productHasDeposit = true;
258
+ }
259
+ } else {
260
+ // 组合规格商品
261
+ if (product !== null && product !== void 0 && product.product_variant_id) {
262
+ var _product$variant;
263
+ var variantProduct = product === null || product === void 0 || (_product$variant = product.variant) === null || _product$variant === void 0 ? void 0 : _product$variant.find(function (item) {
264
+ return (item === null || item === void 0 ? void 0 : item.id) === (product === null || product === void 0 ? void 0 : product.product_variant_id);
265
+ });
266
+ if (variantProduct) {
267
+ var depositData = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.custom_deposit_data;
268
+ var _calculateProductDepo2 = calculateProductDeposit({
269
+ depositData: depositData,
270
+ total: (cartItem === null || cartItem === void 0 ? void 0 : cartItem.total) || 0,
271
+ num: num
272
+ }),
273
+ _depositTotal = _calculateProductDepo2.depositTotal,
274
+ _result = _calculateProductDepo2.result;
275
+ if (_result) {
276
+ total = _depositTotal;
277
+ protocolIds.push.apply(protocolIds, _toConsumableArray((depositData === null || depositData === void 0 ? void 0 : depositData.self_deposit_policy_ids) || []));
278
+ productHasDeposit = true;
279
+ }
280
+ }
281
+ }
282
+ if (bundle !== null && bundle !== void 0 && bundle.length) {
283
+ total = bundle.reduce(function (accumulator, currBundleProduct) {
284
+ var depositData = currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.custom_deposit_data;
285
+ var _calculateProductDepo3 = calculateProductDeposit({
286
+ depositData: depositData,
287
+ total: currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.price,
288
+ num: (currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.num) || 1
289
+ }),
290
+ depositTotal = _calculateProductDepo3.depositTotal,
291
+ result = _calculateProductDepo3.result;
292
+ if (result) {
293
+ protocolIds.push.apply(protocolIds, _toConsumableArray((depositData === null || depositData === void 0 ? void 0 : depositData.self_deposit_policy_ids) || []));
294
+ productHasDeposit = true;
295
+ return accumulator.plus(depositTotal);
296
+ }
297
+ return accumulator;
298
+ }, new Decimal(0));
299
+ }
300
+ }
301
+ if (productHasDeposit) {
302
+ var ids = new Set(protocolIds);
303
+ var protocols = allProtocols.filter(function (item) {
304
+ return ids.has(item.id);
305
+ });
306
+ return {
307
+ total: total.toNumber(),
308
+ protocols: protocols
309
+ };
310
+ }
311
+ return null;
312
+ }
313
+ return null;
314
+ };
315
+
316
+ /**
317
+ * 计算商品定金
318
+ * @param params 参数
319
+ * @returns 商品定金
320
+ */
321
+ export var calculateProductDeposit = function calculateProductDeposit(params) {
322
+ var depositData = params.depositData,
323
+ total = params.total,
324
+ num = params.num;
325
+ if (!depositData) {
326
+ return {
327
+ result: false,
328
+ depositTotal: new Decimal(0)
329
+ };
330
+ }
331
+ var _ref3 = depositData || {},
332
+ deposit_fixed = _ref3.deposit_fixed,
333
+ deposit_percentage = _ref3.deposit_percentage;
334
+ if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
335
+ var depositFixed = new Decimal(deposit_fixed || 0);
336
+ var depositPercent = new Decimal(deposit_percentage || 0);
337
+ var productTotalPrice = new Decimal(total || 0);
338
+ var deposit = depositFixed.plus(depositPercent.times(productTotalPrice));
339
+ return {
340
+ depositTotal: deposit.times(num),
341
+ result: true
342
+ };
343
+ }
344
+ return {
345
+ result: false,
346
+ depositTotal: new Decimal(0)
347
+ };
161
348
  };
@@ -5,6 +5,9 @@ interface PayProps {
5
5
  order_id: string;
6
6
  amount: number;
7
7
  sale_channel?: string;
8
+ is_deposit?: number;
9
+ deposit_amount?: number;
10
+ total_amount?: number;
8
11
  }
9
12
  interface CheckoutContextType {
10
13
  onCheckBeforeBooking: (data: any) => Promise<{
@@ -15,6 +18,7 @@ interface CheckoutContextType {
15
18
  onPay: (payProps: PayProps) => void;
16
19
  createBooking: any;
17
20
  checkBeforeBooking: any;
21
+ freePay: any;
18
22
  }
19
23
  interface CheckoutProviderProps {
20
24
  children: React.ReactNode;
@@ -1,4 +1,9 @@
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; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ 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); }
2
7
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
8
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
9
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -6,8 +11,9 @@ import React, { createContext, useRef } from 'react';
6
11
  import { useSales } from "../../../businessModel/SalesModel";
7
12
  import useEngineContext from "../../../hooks/useEngineContext";
8
13
  import { useRequest } from 'ahooks';
9
- import { checkBeforeBookingApi, createBookingApi } from "./serve";
14
+ import { checkBeforeBookingApi, createBookingApi, freePayApi } from "./serve";
10
15
  import { useCart } from "../Cart";
16
+ import { Toast } from "../../appointmentBooking/utils";
11
17
 
12
18
  // 定义上下文接口
13
19
 
@@ -27,6 +33,7 @@ export var CheckoutProvider = function CheckoutProvider(_ref) {
27
33
  updateDisabledCartItem = _useCart.updateDisabledCartItem;
28
34
  var checkoutCallback = useRef(null);
29
35
  var checkRef = useRef(null);
36
+ var payRef = useRef(null);
30
37
  var checkBeforeBooking = useRequest(checkBeforeBookingApi, {
31
38
  manual: true,
32
39
  onSuccess: function onSuccess(res) {
@@ -61,6 +68,17 @@ export var CheckoutProvider = function CheckoutProvider(_ref) {
61
68
  });
62
69
  }
63
70
  });
71
+ var freePay = useRequest(freePayApi, {
72
+ manual: true,
73
+ onSuccess: function onSuccess(res) {
74
+ if (res !== null && res !== void 0 && res.status) {
75
+ var _payRef$current, _payRef$current2;
76
+ goPaymentFinish((_payRef$current = payRef.current) === null || _payRef$current === void 0 ? void 0 : _payRef$current.order_id, (_payRef$current2 = payRef.current) === null || _payRef$current2 === void 0 ? void 0 : _payRef$current2.total_amount);
77
+ } else {
78
+ Toast(res === null || res === void 0 ? void 0 : res.message);
79
+ }
80
+ }
81
+ });
64
82
 
65
83
  /**
66
84
  * @title: 下单前校验
@@ -106,6 +124,11 @@ export var CheckoutProvider = function CheckoutProvider(_ref) {
106
124
  return _ref2.apply(this, arguments);
107
125
  };
108
126
  }();
127
+ var goPaymentFinish = function goPaymentFinish(order_id, amount) {
128
+ var _utils$history;
129
+ var url = "/payment-finish/success?order_id=".concat(order_id, "&amount=").concat(Number(amount));
130
+ utils === null || utils === void 0 || (_utils$history = utils.history) === null || _utils$history === void 0 || _utils$history.replace(url);
131
+ };
109
132
 
110
133
  /**
111
134
  * @title: 支付
@@ -115,20 +138,41 @@ export var CheckoutProvider = function CheckoutProvider(_ref) {
115
138
  * @Author: zhiwei.Wang
116
139
  */
117
140
  var onPay = function onPay(payProps) {
118
- utils.action({
119
- type: 'pisell1.payment',
120
- data: payProps,
121
- callback: function callback(e) {
122
- checkoutCallback.current && checkoutCallback.current(e);
141
+ payRef.current = payProps;
142
+ var is_deposit = payProps.is_deposit,
143
+ deposit_amount = payProps.deposit_amount,
144
+ total_amount = payProps.total_amount;
145
+
146
+ // 如果有定金,则支付定金金额,否则订单金额
147
+ var _total = is_deposit ? deposit_amount || 0 : total_amount || 0;
148
+ if (_total > 0) {
149
+ utils.action({
150
+ type: 'pisell1.payment',
151
+ data: _objectSpread(_objectSpread({}, payProps), {}, {
152
+ total_amount: _total
153
+ }),
154
+ callback: function callback(e) {
155
+ checkoutCallback.current && checkoutCallback.current(e);
156
+ }
157
+ });
158
+ } else {
159
+ // 定金为0则直接跳转结果页面
160
+ if (is_deposit) {
161
+ goPaymentFinish(payProps.order_id, _total);
162
+ return;
123
163
  }
124
- });
164
+
165
+ // 金额为0则需要调用免费支付接口,接口调用成功后跳转结果页面
166
+ freePay.runAsync(payProps.order_id);
167
+ }
125
168
  };
126
169
  var contextValue = {
127
170
  onCheckBeforeBooking: onCheckBeforeBooking,
128
171
  onCheckout: onCheckout,
129
172
  onPay: onPay,
130
173
  createBooking: createBooking,
131
- checkBeforeBooking: checkBeforeBooking
174
+ checkBeforeBooking: checkBeforeBooking,
175
+ freePay: freePay
132
176
  };
133
177
  return /*#__PURE__*/React.createElement(CheckoutContext.Provider, {
134
178
  value: contextValue
@@ -1,2 +1,15 @@
1
+ /**
2
+ * @title: 下单前置校验接口
3
+ * @param {any} data
4
+ */
1
5
  export declare const checkBeforeBookingApi: (data: any) => Promise<any>;
6
+ /**
7
+ * @title: 创建订单
8
+ * @param {any} data
9
+ */
2
10
  export declare const createBookingApi: (data: any) => Promise<any>;
11
+ /**
12
+ * @title: 免费支付
13
+ * @param {string} orderId
14
+ */
15
+ export declare const freePayApi: (orderId: string) => Promise<any>;
@@ -1,11 +1,25 @@
1
1
  import { request } from "../../../utils";
2
2
 
3
- // 下单前置校验接口
3
+ /**
4
+ * @title: 下单前置校验接口
5
+ * @param {any} data
6
+ */
4
7
  export var checkBeforeBookingApi = function checkBeforeBookingApi(data) {
5
8
  return request.getRequest().post('/h5/eventbookingv2/order/check-config', data);
6
9
  };
7
10
 
8
- // 创建
11
+ /**
12
+ * @title: 创建订单
13
+ * @param {any} data
14
+ */
9
15
  export var createBookingApi = function createBookingApi(data) {
10
16
  return request.getRequest().post('/h5/eventbookingv2/order', data);
17
+ };
18
+
19
+ /**
20
+ * @title: 免费支付
21
+ * @param {string} orderId
22
+ */
23
+ export var freePayApi = function freePayApi(orderId) {
24
+ return request.getRequest().post("/h5/pay/order/free-pay/".concat(orderId), {});
11
25
  };
@@ -29,6 +29,7 @@ export declare const formatValues: (params: {
29
29
  platform: 'h5' | 'pc';
30
30
  excludeDisabled?: boolean;
31
31
  extra?: Record<string, any>;
32
+ otherValue?: Record<string, any>;
32
33
  }) => any;
33
34
  /**
34
35
  * @title: 获取拉开表单弹窗参数
@@ -86,10 +86,11 @@ var formatBookings = function formatBookings(list) {
86
86
  */
87
87
  export var formatValues = function formatValues(params) {
88
88
  var state = params.state,
89
+ otherValue = params.otherValue,
89
90
  platform = params.platform,
90
91
  excludeDisabled = params.excludeDisabled,
91
92
  extra = params.extra;
92
- var values = _objectSpread({
93
+ var values = _objectSpread(_objectSpread({
93
94
  type: 'event_booking_v2',
94
95
  platform: platform === 'pc' ? 'PC' : 'H5',
95
96
  sales_channel: 'my_pisel',
@@ -97,7 +98,7 @@ export var formatValues = function formatValues(params) {
97
98
  bookings: [],
98
99
  shop_note: '',
99
100
  schedule_date: ''
100
- }, extra || {});
101
+ }, extra || {}), otherValue || {});
101
102
  console.log('values', values);
102
103
  var data = [];
103
104
  if (excludeDisabled) {
@@ -109,6 +110,12 @@ export var formatValues = function formatValues(params) {
109
110
  data = state.cartData.cartItems;
110
111
  }
111
112
 
113
+ // 定金
114
+ var is_deposit = data.find(function (v) {
115
+ return v.deposit;
116
+ }) ? 1 : 0;
117
+ values.is_deposit = is_deposit;
118
+
112
119
  // 服务
113
120
  values.bookings = formatBookings(data);
114
121
  return values;
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ interface CustomerData {
3
+ }
4
+ interface CustomerContextType {
5
+ appContext: any;
6
+ appUtils: any;
7
+ isLogin: () => boolean;
8
+ openLoginModal: (params: any) => void;
9
+ getUserInfo: () => any;
10
+ }
11
+ interface CustomerProviderProps {
12
+ children: React.ReactNode;
13
+ }
14
+ export declare const CustomerContext: React.Context<CustomerContextType | undefined>;
15
+ export declare const CustomerProvider: React.FC<CustomerProviderProps>;
16
+ /**
17
+ * 使用步骤管理的Hook
18
+ * @throws {Error} 如果在StepProvider外部使用会抛出错误
19
+ * @returns {StepContextType} 步骤管理上下文
20
+ */
21
+ export declare const useCustomer: () => CustomerContextType;
22
+ declare const _default: {
23
+ defaultState: CustomerData;
24
+ };
25
+ export default _default;
@@ -14,6 +14,7 @@ interface EventDetailContextType {
14
14
  currentBookingOption: any;
15
15
  selectEventDetailProductDetail: (productDetail: any) => void;
16
16
  checkBeforeSelectEventDetail: () => boolean;
17
+ getProductDetailRequest: any;
17
18
  }
18
19
  interface EventDetailProviderProps {
19
20
  children: React.ReactNode;
@@ -15,7 +15,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
15
15
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
17
  import React, { createContext, useRef, useState } from 'react';
18
- import { getEventDetailBookingOptionsApi, getEventDetailIntroductionApi, getEventDetailSelectDateApi, getEventDetailTeacherApi } from "./serve";
18
+ import { getEventDetailBookingOptionsApi, getEventDetailIntroductionApi, getEventDetailSelectDateApi, getEventDetailTeacherApi, getProductDetailApi } from "./serve";
19
19
  import { useRequest } from 'ahooks';
20
20
  import { useEvent } from "./index";
21
21
  import { getIamgeFromMedia } from "../utils";
@@ -219,22 +219,55 @@ export var EventDetailProvider = function EventDetailProvider(_ref) {
219
219
  selectEventDetailBookingOptions(current.value);
220
220
  }
221
221
  });
222
+ var getProductDetailRequest = useRequest(getProductDetailApi, {
223
+ manual: true,
224
+ loadingDelay: 200
225
+ });
226
+
227
+ /**
228
+ * @title: 选择活动关联的商品
229
+ * @param id 活动关联的商品id
230
+ */
222
231
  var selectEventDetailBookingOptions = function selectEventDetailBookingOptions(id) {
223
- var _bookingOptions$filte;
232
+ var _bookingOptions$filte, _option$_originData;
224
233
  var _ref2 = detailRef.current || {},
225
234
  introduction = _ref2.introduction,
226
235
  bookingOptions = _ref2.bookingOptions;
227
236
  var option = bookingOptions === null || bookingOptions === void 0 || (_bookingOptions$filte = bookingOptions.filter(function (v) {
228
237
  return v.value === id;
229
238
  })) === null || _bookingOptions$filte === void 0 ? void 0 : _bookingOptions$filte[0];
230
- _setDetail({
231
- introduction: _objectSpread(_objectSpread({}, introduction), {}, {
232
- price: option.price,
233
- origin_price: option.original_price
234
- }),
235
- selectedProduct: option // 选中的活动关联的商品
236
- });
237
- _setCurrentBookingOption(id);
239
+ var setSelectedData = function setSelectedData(data) {
240
+ _setDetail({
241
+ introduction: _objectSpread(_objectSpread({}, introduction), {}, {
242
+ price: data === null || data === void 0 ? void 0 : data.price,
243
+ origin_price: data === null || data === void 0 ? void 0 : data.original_price
244
+ }),
245
+ selectedProduct: data // 选中的活动关联的商品
246
+ });
247
+ _setCurrentBookingOption(id);
248
+ };
249
+
250
+ // 普通商品需要单独查询商品详情
251
+ if ((option === null || option === void 0 || (_option$_originData = option._originData) === null || _option$_originData === void 0 ? void 0 : _option$_originData.is_eject) === 0) {
252
+ var _introduction$_origin;
253
+ getProductDetailRequest.runAsync(id, {
254
+ open_deposit: 1,
255
+ front_end_cache_id: (introduction === null || introduction === void 0 || (_introduction$_origin = introduction._originData) === null || _introduction$_origin === void 0 ? void 0 : _introduction$_origin.id) + '_' + id
256
+ }).then(function (res) {
257
+ var _res$data2;
258
+ // 定金相关信息
259
+ var custom_deposit_data = res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.custom_deposit_data;
260
+ var newOption = _objectSpread({}, option);
261
+ if (custom_deposit_data && newOption._originData) {
262
+ newOption._originData.custom_deposit_data = custom_deposit_data;
263
+ }
264
+ setSelectedData(newOption);
265
+ }).catch(function () {
266
+ setSelectedData(option);
267
+ });
268
+ } else {
269
+ setSelectedData(option);
270
+ }
238
271
  };
239
272
 
240
273
  /**
@@ -272,7 +305,8 @@ export var EventDetailProvider = function EventDetailProvider(_ref) {
272
305
  getEventDetailSelectDate: getEventDetailSelectDate,
273
306
  currentBookingOption: currentBookingOption,
274
307
  selectEventDetailProductDetail: selectEventDetailProductDetail,
275
- checkBeforeSelectEventDetail: checkBeforeSelectEventDetail
308
+ checkBeforeSelectEventDetail: checkBeforeSelectEventDetail,
309
+ getProductDetailRequest: getProductDetailRequest
276
310
  };
277
311
  return /*#__PURE__*/React.createElement(EventDetailContext.Provider, {
278
312
  value: contextValue
@@ -37,3 +37,13 @@ export declare const getProductPrice: (params: {
37
37
  customer_id: number;
38
38
  schedule_date?: string;
39
39
  }) => Promise<any>;
40
+ /**
41
+ * 获取商品详情
42
+ * @param id 商品id
43
+ * @param params 参数
44
+ * @returns
45
+ */
46
+ export declare const getProductDetailApi: (id: number, params: {
47
+ open_deposit?: string | number;
48
+ front_end_cache_id?: string;
49
+ }) => Promise<any>;
@@ -55,4 +55,29 @@ export var getProductPrice = /*#__PURE__*/function () {
55
55
  return function getProductPrice(_x) {
56
56
  return _ref.apply(this, arguments);
57
57
  };
58
+ }();
59
+
60
+ /**
61
+ * 获取商品详情
62
+ * @param id 商品id
63
+ * @param params 参数
64
+ * @returns
65
+ */
66
+ export var getProductDetailApi = /*#__PURE__*/function () {
67
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(id, params) {
68
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
69
+ while (1) switch (_context2.prev = _context2.next) {
70
+ case 0:
71
+ return _context2.abrupt("return", request.getRequest().get("/h5/product/standard/show/".concat(id), params, {
72
+ useCache: true
73
+ }));
74
+ case 1:
75
+ case "end":
76
+ return _context2.stop();
77
+ }
78
+ }, _callee2);
79
+ }));
80
+ return function getProductDetailApi(_x2, _x3) {
81
+ return _ref2.apply(this, arguments);
82
+ };
58
83
  }();