@pisell/pisellos 0.0.451 → 0.0.453

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.
@@ -25,6 +25,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
25
25
  request_timezone: string;
26
26
  }): Promise<Discount[]>;
27
27
  batchSearch(code: string, customerId?: number): Promise<Discount[]>;
28
+ batchSearchByProductIds(productIds: number[]): Promise<any>;
28
29
  filterEnabledDiscountList(discountList: Discount[]): Discount[];
29
30
  private checkUsageCreditsLimit;
30
31
  uniqueByProductId(discountList: Discount[]): Discount[];
@@ -208,6 +208,35 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
208
208
  }
209
209
  return batchSearch;
210
210
  }()
211
+ }, {
212
+ key: "batchSearchByProductIds",
213
+ value: function () {
214
+ var _batchSearchByProductIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(productIds) {
215
+ var result;
216
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
217
+ while (1) switch (_context6.prev = _context6.next) {
218
+ case 0:
219
+ _context6.next = 2;
220
+ return this.request.get("/machinecode/batch-search", {
221
+ ids: productIds,
222
+ translate_flag: 1,
223
+ tags: ['good_pass', 'product_discount_card'],
224
+ relation_product: 1
225
+ });
226
+ case 2:
227
+ result = _context6.sent;
228
+ return _context6.abrupt("return", (result === null || result === void 0 ? void 0 : result.data) || []);
229
+ case 4:
230
+ case "end":
231
+ return _context6.stop();
232
+ }
233
+ }, _callee6, this);
234
+ }));
235
+ function batchSearchByProductIds(_x8) {
236
+ return _batchSearchByProductIds.apply(this, arguments);
237
+ }
238
+ return batchSearchByProductIds;
239
+ }()
211
240
  }, {
212
241
  key: "filterEnabledDiscountList",
213
242
  value: function filterEnabledDiscountList(discountList) {
@@ -309,21 +338,21 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
309
338
  }, {
310
339
  key: "destroy",
311
340
  value: function () {
312
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
313
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
314
- while (1) switch (_context6.prev = _context6.next) {
341
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
342
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
343
+ while (1) switch (_context7.prev = _context7.next) {
315
344
  case 0:
316
345
  this.store.discountList = [];
317
346
  this.core.effects.offByModuleDestroy(this.name);
318
- _context6.next = 4;
347
+ _context7.next = 4;
319
348
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
320
349
  case 4:
321
350
  console.log('[Discount] 已销毁');
322
351
  case 5:
323
352
  case "end":
324
- return _context6.stop();
353
+ return _context7.stop();
325
354
  }
326
- }, _callee6, this);
355
+ }, _callee7, this);
327
356
  }));
328
357
  function destroy() {
329
358
  return _destroy.apply(this, arguments);
@@ -333,18 +362,18 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
333
362
  }, {
334
363
  key: "clear",
335
364
  value: function () {
336
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
337
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
338
- while (1) switch (_context7.prev = _context7.next) {
365
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
366
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
367
+ while (1) switch (_context8.prev = _context8.next) {
339
368
  case 0:
340
369
  this.store.discountList = [];
341
370
  this.store.originalDiscountList = [];
342
371
  console.log('[Discount] clear');
343
372
  case 3:
344
373
  case "end":
345
- return _context7.stop();
374
+ return _context8.stop();
346
375
  }
347
- }, _callee7, this);
376
+ }, _callee8, this);
348
377
  }));
349
378
  function clear() {
350
379
  return _clear.apply(this, arguments);
@@ -137,6 +137,7 @@ export interface Discount {
137
137
  num?: number;
138
138
  start_date?: string;
139
139
  start_time?: string;
140
+ discount_rule_uncheck_flag?: boolean;
140
141
  }
141
142
  export interface DiscountState {
142
143
  discountList: Discount[];
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -295,13 +295,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
295
295
  orderTotalAmount = _ref2.orderTotalAmount,
296
296
  holders = _ref2.holders,
297
297
  isFormSubject = _ref2.isFormSubject;
298
- // 识别出来是不是在编辑的界面里又新增了商品
299
- // 这种情况下,如果有可用的优惠券,也会自动勾选上
300
- var isEditModeAddNewProduct = productList.find(function (n) {
301
- return n.booking_id;
302
- }) && productList.find(function (n) {
303
- return !n.booking_id;
304
- });
305
298
  var editModeDiscount = [];
306
299
  var addModeDiscount = [];
307
300
  discountList.forEach(function (discount) {
@@ -352,7 +345,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
352
345
  _id: product._id,
353
346
  parentId: product._id,
354
347
  quantity: product.quantity,
355
- num: product.num
348
+ num: product.num,
349
+ booking_id: product.booking_id
356
350
  });
357
351
 
358
352
  // 2. 展开 bundle 子商品
@@ -376,7 +370,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
376
370
  origin_total: new Decimal(bundleItem.price || 0).mul(bundleItem.num || 1).toNumber(),
377
371
  original_price: bundleItem.original_price,
378
372
  // 继承主商品属性
379
- booking_id: product.booking_id,
373
+ booking_id: bundleItem.booking_id,
380
374
  discount_list: bundleItem.discount_list || []
381
375
  });
382
376
  });
@@ -514,6 +508,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
514
508
  // 🔥 扁平化商品列表(包含主商品和bundle子商品)
515
509
  var flattenedList = flattenProductsWithBundle(productList);
516
510
 
511
+ // 识别出来是不是在编辑的界面里又新增了商品
512
+ // 这种情况下,如果有可用的优惠券,也会自动勾选上
513
+ var isEditModeAddNewProduct = flattenedList.find(function (n) {
514
+ return n.booking_id;
515
+ }) && flattenedList.find(function (n) {
516
+ return !n.booking_id;
517
+ });
518
+
517
519
  // 对扁平化后的列表按价格降序排序(用于应用优惠券时优先选择高价商品)
518
520
  var sortedFlattenedList = flattenedList.sort(function (a, b) {
519
521
  var _ref3, _a$original_price, _ref4, _b$original_price;
@@ -896,7 +898,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
896
898
  discount_product_id: discount.product_id
897
899
  },
898
900
  metadata: {
899
- num: num
901
+ num: num,
902
+ discount_rule_uncheck_flag: discount === null || discount === void 0 ? void 0 : discount.discount_rule_uncheck_flag
900
903
  }
901
904
  };
902
905
  applicableProducts.push(productData);
@@ -1259,10 +1262,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1259
1262
  // 前端使用的num数量,为了计算优惠金额
1260
1263
  _num: isGoodPass ? 1 : product.num,
1261
1264
  config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
1262
- metadata: _objectSpread({
1265
+ metadata: _objectSpread(_objectSpread({
1263
1266
  num: 1
1264
1267
  }, productDiscountDifference !== undefined && {
1265
1268
  product_discount_difference: productDiscountDifference
1269
+ }), {}, {
1270
+ discount_rule_uncheck_flag: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.discount_rule_uncheck_flag
1266
1271
  })
1267
1272
  };
1268
1273
  appliedProducts.push(discountDetail);
@@ -1348,6 +1353,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1348
1353
  metadata: {
1349
1354
  // 🔥 使用拆分后的唯一 _id
1350
1355
  custom_product_bundle_map_id: uniqueId,
1356
+ discount_rule_uncheck_flag: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.discount_rule_uncheck_flag,
1351
1357
  num: 1
1352
1358
  },
1353
1359
  _num: 1,
@@ -1432,6 +1438,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1432
1438
  metadata: _objectSpread({
1433
1439
  // 🔥 使用唯一的 _id
1434
1440
  custom_product_bundle_map_id: _uniqueId,
1441
+ discount_rule_uncheck_flag: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.discount_rule_uncheck_flag,
1435
1442
  num: product.num || 1
1436
1443
  }, _productDiscountDifference !== undefined && {
1437
1444
  product_discount_difference: _productDiscountDifference
@@ -0,0 +1,32 @@
1
+ import dayjs from "dayjs";
2
+ import { ScheduleItem } from "./types";
3
+ export declare const getDateIsInSchedule: (dateTime: string, scheduleList: ScheduleItem[]) => boolean;
4
+ export type ScheduleTimeSlot = {
5
+ /** 开始时间 HH:mm */
6
+ start_time: string;
7
+ /** 结束时间 HH:mm */
8
+ end_time: string;
9
+ /** 开始日期时间 YYYY-MM-DD HH:mm:ss */
10
+ start_at: dayjs.Dayjs;
11
+ /** 结束日期时间 YYYY-MM-DD HH:mm:ss */
12
+ end_at: dayjs.Dayjs;
13
+ };
14
+ /**
15
+ * 获取当前日期日程时间点
16
+ * @param date 日期 YYYY-MM-DD
17
+ * @param scheduleList 日程列表
18
+ * @returns 当前日期日程时间点 结构,数组 [{
19
+ *
20
+ * // HH:mm
21
+ * end_time: string,
22
+ * // HH:mm
23
+ * start_time: string,
24
+ * // 日期时间
25
+ * // YYYY-MM-DD HH:mm:ss
26
+ * end_at: Dayjs,
27
+ * // YYYY-MM-DD HH:mm:ss
28
+ * start_at: Dayjs,
29
+ *
30
+ * }]
31
+ */
32
+ export declare const getScheduleStartEndTimePoints: (date: string, scheduleList: ScheduleItem[]) => ScheduleTimeSlot[];