@pisell/pisellos 2.3.173 → 2.3.175

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.
@@ -180,7 +180,8 @@ export declare class PromotionEvaluator {
180
180
  */
181
181
  private processItemReward;
182
182
  private normalizePositiveInteger;
183
- private getAvailablePromotionQuantity;
183
+ /** 仅放开 X件Y元处理过的触发数量,奖励目标仍按全部已处理数量互斥。 */
184
+ private getItemRewardTriggerQuantity;
184
185
  private buildItemRewardTargetUnits;
185
186
  private resolveItemRewardFinalPrice;
186
187
  private resolveItemRewardLimit;
@@ -375,6 +375,8 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
375
375
  // 3. 追踪已处理的商品(避免重复处理)
376
376
  // key: `${product_id}_${product_variant_id}`
377
377
  var processedQuantityMap = new Map();
378
+ // X件Y元处理过的数量仍可作为商品奖励的触发条件。
379
+ var xItemsProcessedQuantityMap = new Map();
378
380
 
379
381
  // 4. 处理每个促销组,收集结果
380
382
  var pricedProducts = [];
@@ -392,7 +394,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
392
394
  var matchedBundleIndexMap = group.productMatchedBundleIndexMap || new Map();
393
395
  if (actionType === PROMOTION_ACTION_TYPES.X_ITEMS_FOR_Y_PRICE) {
394
396
  // X件Y元处理
395
- var result = this.processXItemsForYPrice(group, processedQuantityMap, matchedBundleIndexMap);
397
+ var result = this.processXItemsForYPrice(group, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap);
396
398
  pricedProducts.push.apply(pricedProducts, _toConsumableArray(result.products));
397
399
  totalOriginalAmount = totalOriginalAmount.plus(result.originalAmount);
398
400
  totalFinalAmount = totalFinalAmount.plus(result.finalAmount);
@@ -409,7 +411,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
409
411
  }
410
412
  } else if (actionType === PROMOTION_ACTION_TYPES.ITEM_REWARD) {
411
413
  // 商品奖励处理:条件商品触发,目标商品行享优惠,不自动新增商品
412
- var _result2 = this.processItemReward(group, processedQuantityMap, products, matchedBundleIndexMap);
414
+ var _result2 = this.processItemReward(group, processedQuantityMap, products, xItemsProcessedQuantityMap, matchedBundleIndexMap);
413
415
  pricedProducts.push.apply(pricedProducts, _toConsumableArray(_result2.products));
414
416
  totalOriginalAmount = totalOriginalAmount.plus(_result2.originalAmount);
415
417
  totalFinalAmount = totalFinalAmount.plus(_result2.finalAmount);
@@ -689,7 +691,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
689
691
  */
690
692
  }, {
691
693
  key: "processXItemsForYPrice",
692
- value: function processXItemsForYPrice(group, processedQuantityMap, matchedBundleIndexMap) {
694
+ value: function processXItemsForYPrice(group, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
693
695
  var strategyId = group.strategyId,
694
696
  strategyMetadata = group.strategyMetadata,
695
697
  actionDetail = group.actionDetail,
@@ -911,6 +913,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
911
913
 
912
914
  // 更新已处理数量
913
915
  processedQuantityMap.set(_key, _processedQty + _availableQty);
916
+ xItemsProcessedQuantityMap.set(_key, (xItemsProcessedQuantityMap.get(_key) || 0) + _availableQty);
914
917
  }
915
918
 
916
919
  // 8. 尾差调整:只补实际组价的舍入差额,不将高于原价的组价补到某一件。
@@ -1117,7 +1120,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1117
1120
  */
1118
1121
  }, {
1119
1122
  key: "processItemReward",
1120
- value: function processItemReward(group, processedQuantityMap, allProducts, matchedBundleIndexMap) {
1123
+ value: function processItemReward(group, processedQuantityMap, allProducts, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
1121
1124
  var _this4 = this;
1122
1125
  var strategyId = group.strategyId,
1123
1126
  strategyMetadata = group.strategyMetadata,
@@ -1126,7 +1129,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1126
1129
  var detail = actionDetail;
1127
1130
  var triggerQuantity = this.normalizePositiveInteger(detail.triggerQuantity, 1);
1128
1131
  var rewardQuantity = this.normalizePositiveInteger(detail.rewardQuantity, 1);
1129
- var conditionQuantity = this.getAvailablePromotionQuantity(triggerProducts, processedQuantityMap, matchedBundleIndexMap);
1132
+ var conditionQuantity = this.getItemRewardTriggerQuantity(triggerProducts, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap);
1130
1133
  if (conditionQuantity < triggerQuantity) {
1131
1134
  return {
1132
1135
  products: [],
@@ -1242,9 +1245,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1242
1245
  var n = Math.floor(Number(value));
1243
1246
  return Number.isFinite(n) && n > 0 ? n : fallback;
1244
1247
  }
1248
+
1249
+ /** 仅放开 X件Y元处理过的触发数量,奖励目标仍按全部已处理数量互斥。 */
1245
1250
  }, {
1246
- key: "getAvailablePromotionQuantity",
1247
- value: function getAvailablePromotionQuantity(products, processedQuantityMap, matchedBundleIndexMap) {
1251
+ key: "getItemRewardTriggerQuantity",
1252
+ value: function getItemRewardTriggerQuantity(products, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
1248
1253
  var total = 0;
1249
1254
  var _iterator19 = _createForOfIteratorHelper(products),
1250
1255
  _step19;
@@ -1253,7 +1258,8 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1253
1258
  var product = _step19.value;
1254
1259
  var key = this.getProductKey(product);
1255
1260
  var processedQty = processedQuantityMap.get(key) || 0;
1256
- var availableQty = product.quantity - processedQty;
1261
+ var xItemsProcessedQty = xItemsProcessedQuantityMap.get(key) || 0;
1262
+ var availableQty = product.quantity - processedQty + xItemsProcessedQty;
1257
1263
  if (availableQty <= 0) continue;
1258
1264
  var matchedBundleIndex = matchedBundleIndexMap === null || matchedBundleIndexMap === void 0 ? void 0 : matchedBundleIndexMap.get(product.id);
1259
1265
  if (matchedBundleIndex !== undefined && product.bundle) {
@@ -4873,7 +4873,9 @@ var Server = /*#__PURE__*/function () {
4873
4873
  case 3:
4874
4874
  _context52.prev = 3;
4875
4875
  _context52.next = 6;
4876
- return this.app.request.post('/shop/order/v2/list', data, {
4876
+ return this.app.request.post('/shop/order/v2/list', _objectSpread(_objectSpread({}, data), {}, {
4877
+ with: _toConsumableArray(new Set([].concat(_toConsumableArray(Array.isArray(data.with) ? data.with : []), ['buzzer'])))
4878
+ }), {
4877
4879
  isShopApi: true
4878
4880
  });
4879
4881
  case 6:
@@ -519,6 +519,8 @@ export interface OrderFilters {
519
519
  max_total_amount?: number;
520
520
  tag_ids?: (string | number)[];
521
521
  shipping_type?: string[];
522
+ /** 交付方式,精确匹配 metadata.shop_service_data.service_type;多选之间为 OR */
523
+ service_type?: string[];
522
524
  delivery_zone_name?: string;
523
525
  location_id?: string | number;
524
526
  shipping_order_number?: string;
@@ -1,3 +1,4 @@
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); }
1
2
  import dayjs from 'dayjs';
2
3
  /** 从订单 payments 提取支付方式 code,与 UI 筛选选项及 filterBookings 一致 */
3
4
  function getOrderPaymentCodes(order) {
@@ -248,6 +249,25 @@ export function filterOrders(orders, filters) {
248
249
  }
249
250
  }
250
251
 
252
+ // service_type - 交付方式(同组多选 OR,与其他条件 AND)
253
+ if (Array.isArray(safeFilters.service_type) && safeFilters.service_type.length > 0) {
254
+ var _order$metadata;
255
+ var shopServiceData = (_order$metadata = order.metadata) === null || _order$metadata === void 0 ? void 0 : _order$metadata.shop_service_data;
256
+ var serviceType = shopServiceData && _typeof(shopServiceData) === 'object' ? shopServiceData.service_type : undefined;
257
+ if (typeof serviceType !== 'string' || !safeFilters.service_type.includes(serviceType)) {
258
+ rejected.push({
259
+ order_id: order.order_id,
260
+ order_number: order.order_number,
261
+ reason: {
262
+ field: 'service_type',
263
+ actual: serviceType,
264
+ expected: safeFilters.service_type
265
+ }
266
+ });
267
+ return false;
268
+ }
269
+ }
270
+
251
271
  // delivery_zone_name - 配送区域(模糊匹配)
252
272
  if (safeFilters.delivery_zone_name !== undefined && safeFilters.delivery_zone_name !== null && safeFilters.delivery_zone_name !== '') {
253
273
  if (!order.delivery_zone_name || !order.delivery_zone_name.toLowerCase().includes(safeFilters.delivery_zone_name.toLowerCase())) {
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
328
328
  date: string;
329
329
  status: string;
330
330
  week: string;
331
- weekNum: 0 | 1 | 2 | 6 | 3 | 4 | 5;
331
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
332
332
  }[]>;
333
333
  submitTimeSlot(timeSlots: TimeSliceItem): void;
334
334
  private getScheduleDataByIds;
@@ -366,7 +366,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
366
366
  * 获取当前的客户搜索条件
367
367
  * @returns 当前搜索条件
368
368
  */
369
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
369
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
370
370
  /**
371
371
  * 获取客户列表状态(包含滚动加载相关状态)
372
372
  * @returns 客户状态
@@ -180,7 +180,8 @@ export declare class PromotionEvaluator {
180
180
  */
181
181
  private processItemReward;
182
182
  private normalizePositiveInteger;
183
- private getAvailablePromotionQuantity;
183
+ /** 仅放开 X件Y元处理过的触发数量,奖励目标仍按全部已处理数量互斥。 */
184
+ private getItemRewardTriggerQuantity;
184
185
  private buildItemRewardTargetUnits;
185
186
  private resolveItemRewardFinalPrice;
186
187
  private resolveItemRewardLimit;
@@ -313,6 +313,8 @@ class PromotionEvaluator {
313
313
  // 3. 追踪已处理的商品(避免重复处理)
314
314
  // key: `${product_id}_${product_variant_id}`
315
315
  const processedQuantityMap = new Map();
316
+ // X件Y元处理过的数量仍可作为商品奖励的触发条件。
317
+ const xItemsProcessedQuantityMap = new Map();
316
318
 
317
319
  // 4. 处理每个促销组,收集结果
318
320
  const pricedProducts = [];
@@ -328,7 +330,7 @@ class PromotionEvaluator {
328
330
  const matchedBundleIndexMap = group.productMatchedBundleIndexMap || new Map();
329
331
  if (actionType === _type.PROMOTION_ACTION_TYPES.X_ITEMS_FOR_Y_PRICE) {
330
332
  // X件Y元处理
331
- const result = this.processXItemsForYPrice(group, processedQuantityMap, matchedBundleIndexMap);
333
+ const result = this.processXItemsForYPrice(group, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap);
332
334
  pricedProducts.push(...result.products);
333
335
  totalOriginalAmount = totalOriginalAmount.plus(result.originalAmount);
334
336
  totalFinalAmount = totalFinalAmount.plus(result.finalAmount);
@@ -345,7 +347,7 @@ class PromotionEvaluator {
345
347
  }
346
348
  } else if (actionType === _type.PROMOTION_ACTION_TYPES.ITEM_REWARD) {
347
349
  // 商品奖励处理:条件商品触发,目标商品行享优惠,不自动新增商品
348
- const result = this.processItemReward(group, processedQuantityMap, products, matchedBundleIndexMap);
350
+ const result = this.processItemReward(group, processedQuantityMap, products, xItemsProcessedQuantityMap, matchedBundleIndexMap);
349
351
  pricedProducts.push(...result.products);
350
352
  totalOriginalAmount = totalOriginalAmount.plus(result.originalAmount);
351
353
  totalFinalAmount = totalFinalAmount.plus(result.finalAmount);
@@ -566,7 +568,7 @@ class PromotionEvaluator {
566
568
  *
567
569
  * 注意:每个商品按 id 独立处理,不会合并不同 id 的商品
568
570
  */
569
- processXItemsForYPrice(group, processedQuantityMap, matchedBundleIndexMap) {
571
+ processXItemsForYPrice(group, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
570
572
  const {
571
573
  strategyId,
572
574
  strategyMetadata,
@@ -759,6 +761,7 @@ class PromotionEvaluator {
759
761
 
760
762
  // 更新已处理数量
761
763
  processedQuantityMap.set(key, processedQty + availableQty);
764
+ xItemsProcessedQuantityMap.set(key, (xItemsProcessedQuantityMap.get(key) || 0) + availableQty);
762
765
  }
763
766
 
764
767
  // 8. 尾差调整:只补实际组价的舍入差额,不将高于原价的组价补到某一件。
@@ -922,7 +925,7 @@ class PromotionEvaluator {
922
925
  * 4. 按消费者最优(可节省金额从高到低)选择目标单位
923
926
  * 5. 对目标商品拆分并写入 finalPrice,触发商品本身不改价
924
927
  */
925
- processItemReward(group, processedQuantityMap, allProducts, matchedBundleIndexMap) {
928
+ processItemReward(group, processedQuantityMap, allProducts, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
926
929
  const {
927
930
  strategyId,
928
931
  strategyMetadata,
@@ -932,7 +935,7 @@ class PromotionEvaluator {
932
935
  const detail = actionDetail;
933
936
  const triggerQuantity = this.normalizePositiveInteger(detail.triggerQuantity, 1);
934
937
  const rewardQuantity = this.normalizePositiveInteger(detail.rewardQuantity, 1);
935
- const conditionQuantity = this.getAvailablePromotionQuantity(triggerProducts, processedQuantityMap, matchedBundleIndexMap);
938
+ const conditionQuantity = this.getItemRewardTriggerQuantity(triggerProducts, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap);
936
939
  if (conditionQuantity < triggerQuantity) {
937
940
  return {
938
941
  products: [],
@@ -1028,12 +1031,15 @@ class PromotionEvaluator {
1028
1031
  const n = Math.floor(Number(value));
1029
1032
  return Number.isFinite(n) && n > 0 ? n : fallback;
1030
1033
  }
1031
- getAvailablePromotionQuantity(products, processedQuantityMap, matchedBundleIndexMap) {
1034
+
1035
+ /** 仅放开 X件Y元处理过的触发数量,奖励目标仍按全部已处理数量互斥。 */
1036
+ getItemRewardTriggerQuantity(products, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
1032
1037
  let total = 0;
1033
1038
  for (const product of products) {
1034
1039
  const key = this.getProductKey(product);
1035
1040
  const processedQty = processedQuantityMap.get(key) || 0;
1036
- const availableQty = product.quantity - processedQty;
1041
+ const xItemsProcessedQty = xItemsProcessedQuantityMap.get(key) || 0;
1042
+ const availableQty = product.quantity - processedQty + xItemsProcessedQty;
1037
1043
  if (availableQty <= 0) continue;
1038
1044
  const matchedBundleIndex = matchedBundleIndexMap?.get(product.id);
1039
1045
  if (matchedBundleIndex !== undefined && product.bundle) {
@@ -2475,7 +2475,10 @@ class Server {
2475
2475
  };
2476
2476
  }
2477
2477
  try {
2478
- const response = await this.app.request.post('/shop/order/v2/list', data, {
2478
+ const response = await this.app.request.post('/shop/order/v2/list', {
2479
+ ...data,
2480
+ with: [...new Set([...(Array.isArray(data.with) ? data.with : []), 'buzzer'])]
2481
+ }, {
2479
2482
  isShopApi: true
2480
2483
  });
2481
2484
  const payload = response?.data ?? response;
@@ -519,6 +519,8 @@ export interface OrderFilters {
519
519
  max_total_amount?: number;
520
520
  tag_ids?: (string | number)[];
521
521
  shipping_type?: string[];
522
+ /** 交付方式,精确匹配 metadata.shop_service_data.service_type;多选之间为 OR */
523
+ service_type?: string[];
522
524
  delivery_zone_name?: string;
523
525
  location_id?: string | number;
524
526
  shipping_order_number?: string;
@@ -247,6 +247,24 @@ function filterOrders(orders, filters) {
247
247
  }
248
248
  }
249
249
 
250
+ // service_type - 交付方式(同组多选 OR,与其他条件 AND)
251
+ if (Array.isArray(safeFilters.service_type) && safeFilters.service_type.length > 0) {
252
+ const shopServiceData = order.metadata?.shop_service_data;
253
+ const serviceType = shopServiceData && typeof shopServiceData === 'object' ? shopServiceData.service_type : undefined;
254
+ if (typeof serviceType !== 'string' || !safeFilters.service_type.includes(serviceType)) {
255
+ rejected.push({
256
+ order_id: order.order_id,
257
+ order_number: order.order_number,
258
+ reason: {
259
+ field: 'service_type',
260
+ actual: serviceType,
261
+ expected: safeFilters.service_type
262
+ }
263
+ });
264
+ return false;
265
+ }
266
+ }
267
+
250
268
  // delivery_zone_name - 配送区域(模糊匹配)
251
269
  if (safeFilters.delivery_zone_name !== undefined && safeFilters.delivery_zone_name !== null && safeFilters.delivery_zone_name !== '') {
252
270
  if (!order.delivery_zone_name || !order.delivery_zone_name.toLowerCase().includes(safeFilters.delivery_zone_name.toLowerCase())) {
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
328
328
  date: string;
329
329
  status: string;
330
330
  week: string;
331
- weekNum: 0 | 1 | 2 | 6 | 3 | 4 | 5;
331
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
332
332
  }[]>;
333
333
  submitTimeSlot(timeSlots: TimeSliceItem): void;
334
334
  private getScheduleDataByIds;
@@ -366,7 +366,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
366
366
  * 获取当前的客户搜索条件
367
367
  * @returns 当前搜索条件
368
368
  */
369
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
369
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
370
370
  /**
371
371
  * 获取客户列表状态(包含滚动加载相关状态)
372
372
  * @returns 客户状态
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.173",
4
+ "version": "2.3.175",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",