@pisell/pisellos 2.3.88 → 2.3.89

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.
@@ -191,6 +191,8 @@ export interface OrderLocalizedText {
191
191
  export interface OrderProduct extends OrderProductIdentity {
192
192
  order_detail_id: number | null;
193
193
  num: number;
194
+ /** Product 或当前 Variant 的生产编码 */
195
+ production_code?: string;
194
196
  bundle_edit?: number;
195
197
  product_sku: OrderProductSku;
196
198
  gift_card?: number;
@@ -868,6 +868,7 @@ function formatSubmitBundleItems(bundle) {
868
868
  return {
869
869
  is_charge_tax: (_rawBundle$is_charge_ = rawBundle.is_charge_tax) !== null && _rawBundle$is_charge_ !== void 0 ? _rawBundle$is_charge_ : 0,
870
870
  bundle_variant_id: (_rawBundle$bundle_var = rawBundle.bundle_variant_id) !== null && _rawBundle$bundle_var !== void 0 ? _rawBundle$bundle_var : 0,
871
+ production_code: rawBundle.production_code,
871
872
  num: num,
872
873
  quantity: toBundleNumber((_rawBundle$quantity = rawBundle.quantity) !== null && _rawBundle$quantity !== void 0 ? _rawBundle$quantity : rawBundle.num, num),
873
874
  extension_id: (_rawBundle$extension_ = rawBundle.extension_id) !== null && _rawBundle$extension_ !== void 0 ? _rawBundle$extension_ : 0,
@@ -77,6 +77,8 @@ export interface ProductData {
77
77
  is_gst: number;
78
78
  /** 商品编码 */
79
79
  code: string;
80
+ /** ERP/生产侧商品编码;有规格时以选中 Variant 的值为准 */
81
+ production_code?: string;
80
82
  /** 商品条码 */
81
83
  barcode: string;
82
84
  /** 是否支持配送 */
@@ -2223,7 +2223,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2223
2223
  }, {
2224
2224
  key: "checkPackageSubItemUsageRules",
2225
2225
  value: function checkPackageSubItemUsageRules(discount, flatItem) {
2226
- var _flatItem$product;
2226
+ var _flatItem$product, _flatItem$originProdu, _flatItem$parentProdu10;
2227
2227
  var limitedData = discount.limited_relation_product_data;
2228
2228
  var usageRules = limitedData === null || limitedData === void 0 ? void 0 : limitedData.package_sub_item_usage_rules;
2229
2229
  var rules = ['original_price'].concat(_toConsumableArray((usageRules === null || usageRules === void 0 ? void 0 : usageRules.rules) || []));
@@ -2236,7 +2236,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2236
2236
  // 套餐适用范围配置
2237
2237
  var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
2238
2238
  var _ref18 = packageScope || {},
2239
- scopeType = _ref18.type,
2239
+ _ref18$type = _ref18.type,
2240
+ scopeType = _ref18$type === void 0 ? 'product_all' : _ref18$type,
2240
2241
  _ref18$exclude_bundle = _ref18.exclude_bundle_product_ids,
2241
2242
  exclude_bundle_product_ids = _ref18$exclude_bundle === void 0 ? [] : _ref18$exclude_bundle,
2242
2243
  _ref18$include_bundle = _ref18.include_bundle_product_ids,
@@ -2246,6 +2247,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2246
2247
  var isMainProduct = flatItem.type === 'main'; // 单独购买
2247
2248
  var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
2248
2249
  var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
2250
+ // 主商品id
2251
+ var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu = flatItem.originProduct) === null || _flatItem$originProdu === void 0 || (_flatItem$originProdu = _flatItem$originProdu._productOrigin) === null || _flatItem$originProdu === void 0 ? void 0 : _flatItem$originProdu.id) || (flatItem === null || flatItem === void 0 || (_flatItem$parentProdu10 = flatItem.parentProduct) === null || _flatItem$parentProdu10 === void 0 ? void 0 : _flatItem$parentProdu10.id) || 0;
2249
2252
 
2250
2253
  // 主商品直接可用
2251
2254
  if (isMainProduct) {
@@ -2258,12 +2261,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2258
2261
  return true; // 单独购买时可用
2259
2262
  }
2260
2263
  if (isBundleItem) {
2261
- var _flatItem$bundleItem10, _flatItem$bundleItem11, _flatItem$originProdu, _flatItem$parentProdu10;
2264
+ var _flatItem$bundleItem10, _flatItem$bundleItem11;
2262
2265
  // 套餐中购买时,判断是否为原价
2263
2266
  var priceType = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type;
2264
2267
  var priceTypeExt = (_flatItem$bundleItem11 = flatItem.bundleItem) === null || _flatItem$bundleItem11 === void 0 ? void 0 : _flatItem$bundleItem11.price_type_ext;
2265
2268
  // 主商品id
2266
- var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu = flatItem.originProduct) === null || _flatItem$originProdu === void 0 || (_flatItem$originProdu = _flatItem$originProdu._productOrigin) === null || _flatItem$originProdu === void 0 ? void 0 : _flatItem$originProdu.id) || (flatItem === null || flatItem === void 0 || (_flatItem$parentProdu10 = flatItem.parentProduct) === null || _flatItem$parentProdu10 === void 0 ? void 0 : _flatItem$parentProdu10.id) || 0;
2269
+ // const mainProductId = flatItem?.originProduct?._productOrigin?.id || flatItem?.parentProduct?.id || 0;
2267
2270
  // original_price 对应:
2268
2271
  // 1. price_type: "markup" && price_type_ext: "product_price"
2269
2272
  // markup_price 对应:
@@ -2288,13 +2291,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2288
2291
  if (!filter) {
2289
2292
  isScopeValid = true;
2290
2293
  } else {
2291
- isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
2294
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
2292
2295
  }
2293
2296
  }
2294
2297
 
2295
2298
  // 包含套餐判断, products值兼容旧数据
2296
2299
  if (scopeType === 'specific_packages' || scopeType === 'products') {
2297
- isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
2300
+ isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
2298
2301
  }
2299
2302
 
2300
2303
  // 价格和套餐适用范围都符合,则可用
@@ -2357,13 +2360,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2357
2360
  if (!filter) {
2358
2361
  _isScopeValid = true;
2359
2362
  } else {
2360
- _isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
2363
+ _isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
2361
2364
  }
2362
2365
  }
2363
2366
 
2364
2367
  // 包含套餐判断, products值兼容旧数据
2365
2368
  if (scopeType === 'specific_packages' || scopeType === 'products') {
2366
- _isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
2369
+ _isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
2367
2370
  }
2368
2371
 
2369
2372
  // 价格和套餐适用范围都符合,则可用
@@ -112,6 +112,8 @@ export interface BaseSalesUpdateOrderProductQuantityParams extends BaseSalesOrde
112
112
  export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
113
113
  order_detail_id: number | null;
114
114
  num: number;
115
+ /** Product 或当前 Variant 的生产编码 */
116
+ production_code?: string;
115
117
  product_sku: BaseSalesProductSku;
116
118
  /**
117
119
  * 券后 **行 composite 单价** = `metadata.main_product_selling_price`
@@ -3,6 +3,7 @@ import type { ProductData } from '../../../modules/Product/types';
3
3
  export interface BaseProductDetailOptionItem {
4
4
  option_group_item_id?: number | string;
5
5
  option_group_id?: number | string;
6
+ production_code?: string;
6
7
  num?: number | string;
7
8
  quantity?: number | string;
8
9
  price?: number | string;
@@ -10,6 +11,7 @@ export interface BaseProductDetailOptionItem {
10
11
  [key: string]: any;
11
12
  }
12
13
  export interface BaseProductDetailBundleItem {
14
+ production_code?: string;
13
15
  option?: BaseProductDetailOptionItem[];
14
16
  [key: string]: any;
15
17
  }
@@ -18,6 +20,7 @@ export interface BaseProductDetailPayload {
18
20
  product_id?: number | string | null;
19
21
  variant_id?: number | string | null;
20
22
  product_variant_id?: number | string | null;
23
+ production_code?: string;
21
24
  quantity?: number | string;
22
25
  num?: number | string;
23
26
  option?: BaseProductDetailOptionItem[];
@@ -30,6 +30,10 @@ function toPriceString(value) {
30
30
  if (!Number.isFinite(parsedValue)) return fallback;
31
31
  return parsedValue.toFixed(2);
32
32
  }
33
+ function normalizeProductionCode(value) {
34
+ if (value === undefined || value === null) return '';
35
+ return String(value).trim();
36
+ }
33
37
  function isBlankValue(value) {
34
38
  return value === undefined || value === null || typeof value === 'string' && value.trim() === '';
35
39
  }
@@ -104,7 +108,7 @@ function findVariantById(origin, variantId) {
104
108
  * 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
105
109
  */
106
110
  export function transformBaseProductToOrderProduct(params) {
107
- var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref15, _findVariantById, _ref16, _ref17, _ref18, _ref19, _ref20, _matchedVariant$price, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend, _ref24, _ref25, _payload$product_sku$, _payload$product_sku, _payload$bundle, _payload$quantity, _payload$_extend2, _extend, _extend2, _ref26, _ref27, _origin$base_price, _ref28, _ref29, _payload$line_total2, _payload$_extend3, _payload$_extend4, _extend3, _payload$_extend5, _payload$_extend6, _ref30, _ref31, _payload$tax_fee, _ref32, _ref33, _payload$is_charge_ta;
111
+ var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref15, _findVariantById, _origin$production_co, _ref16, _ref17, _ref18, _ref19, _ref20, _matchedVariant$price, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend, _ref24, _ref25, _payload$product_sku$, _payload$product_sku, _payload$bundle, _payload$quantity, _payload$_extend2, _extend, _extend2, _ref26, _ref27, _origin$base_price, _ref28, _ref29, _payload$line_total2, _payload$_extend3, _payload$_extend4, _extend3, _payload$_extend5, _payload$_extend6, _ref30, _ref31, _payload$tax_fee, _ref32, _ref33, _payload$is_charge_ta;
108
112
  var payload = params.payload,
109
113
  _params$fallbackProdu = params.fallbackProductId,
110
114
  fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
@@ -116,6 +120,7 @@ export function transformBaseProductToOrderProduct(params) {
116
120
  var callbackOrigin = payload.origin || ((_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.sourceProduct) || ((_payload$_origin2 = payload._origin) === null || _payload$_origin2 === void 0 ? void 0 : _payload$_origin2.sourceItem) || payload._origin || {};
117
121
  var origin = _objectSpread(_objectSpread({}, sourceProduct || {}), callbackOrigin || {});
118
122
  var matchedVariant = (_ref15 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref15 !== void 0 ? _ref15 : findVariantById(origin, productVariantId);
123
+ var productionCode = normalizeProductionCode(Object.prototype.hasOwnProperty.call(payload, 'production_code') ? payload.production_code : productVariantId > 0 ? matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.production_code : (_origin$production_co = origin === null || origin === void 0 ? void 0 : origin.production_code) !== null && _origin$production_co !== void 0 ? _origin$production_co : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.production_code);
119
124
  var hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
120
125
  // 手动改价后 payload.price 是分摊后的主商品售价,不能再作为券前 source。
121
126
  // 此时优先从商品/variant 快照读取目录价;售价仍由 line_total - bundle 推导。
@@ -198,6 +203,7 @@ export function transformBaseProductToOrderProduct(params) {
198
203
  return _objectSpread(_objectSpread({
199
204
  product_id: productId,
200
205
  product_variant_id: productVariantId,
206
+ production_code: productionCode,
201
207
  unique_identification_number: uniqueIdentificationNumber ? String(uniqueIdentificationNumber) : undefined,
202
208
  num: resolvedQuantity,
203
209
  product_sku: _objectSpread(_objectSpread({}, payload.product_sku && _typeof(payload.product_sku) === 'object' ? payload.product_sku : {}), {}, {
@@ -256,11 +256,14 @@ export function normalizeOrderProduct(product) {
256
256
  sellingPrice: composedSellingPrice,
257
257
  quantity: getSafeProductNum(product.num)
258
258
  });
259
- return {
259
+ return _objectSpread(_objectSpread({
260
260
  order_detail_id: product.order_detail_id || null,
261
261
  product_id: product.product_id,
262
262
  num: getSafeProductNum(product.num),
263
- product_variant_id: product.product_variant_id,
263
+ product_variant_id: product.product_variant_id
264
+ }, product.production_code !== undefined && product.production_code !== null ? {
265
+ production_code: String(product.production_code).trim()
266
+ } : {}), {}, {
264
267
  product_sku: productSku,
265
268
  selling_price: composedSellingPrice,
266
269
  original_price: finalOriginalPrice,
@@ -270,5 +273,5 @@ export function normalizeOrderProduct(product) {
270
273
  product_bundle: normalizedBundle,
271
274
  metadata: metadata,
272
275
  note: product.note != null ? String(product.note) : ''
273
- };
276
+ });
274
277
  }
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 5 | 3 | 4 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -345,7 +345,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
345
345
  count: number;
346
346
  left: number;
347
347
  summaryCount: number;
348
- status: "sold_out" | "lots_of_space" | "filling_up_fast";
348
+ status: "lots_of_space" | "filling_up_fast" | "sold_out";
349
349
  }[];
350
350
  /**
351
351
  * 找到多个资源的公共可用时间段
@@ -319,7 +319,7 @@ export function transformDetailToProductAndBooking(cacheItem, ctx) {
319
319
  * 把 cacheItem._extend.other 中的字段 + 顶层运行态拼成 `BaseProductDetailPayload`。
320
320
  */
321
321
  function buildBasePayloadFromCacheItem(cacheItem, ctx) {
322
- var _cacheItem$_extend, _cacheItem$_extend$qu, _cacheItem$_extend2, _cacheItem$product_id, _cacheItem$id, _ref5, _other$product_varian, _extend$skuValue, _extend$_skuValue, _extend$price, _extend$price2;
322
+ var _cacheItem$_extend, _cacheItem$_extend$qu, _cacheItem$_extend2, _cacheItem$product_id, _cacheItem$id, _ref5, _other$product_varian, _other$production_cod, _extend$skuValue, _extend$_skuValue, _extend$price, _extend$price2;
323
323
  var other = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.other) || {};
324
324
  var quantity = (ctx === null || ctx === void 0 ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : (_cacheItem$_extend$qu = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.quantity) !== null && _cacheItem$_extend$qu !== void 0 ? _cacheItem$_extend$qu : 1;
325
325
  var resolvedPid = (_cacheItem$product_id = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_id) !== null && _cacheItem$product_id !== void 0 ? _cacheItem$product_id : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.id;
@@ -329,6 +329,8 @@ function buildBasePayloadFromCacheItem(cacheItem, ctx) {
329
329
  id: (_cacheItem$id = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.id) !== null && _cacheItem$id !== void 0 ? _cacheItem$id : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_id,
330
330
  product_id: resolvedPid,
331
331
  variant_id: (_ref5 = (_other$product_varian = other === null || other === void 0 ? void 0 : other.product_variant_id) !== null && _other$product_varian !== void 0 ? _other$product_varian : other === null || other === void 0 ? void 0 : other.variant_id) !== null && _ref5 !== void 0 ? _ref5 : 0,
332
+ // SKUOptionsSelection 已按 Product / Variant 解析好主商品编码;显式空串也需保留。
333
+ production_code: (_other$production_cod = other === null || other === void 0 ? void 0 : other.production_code) !== null && _other$production_cod !== void 0 ? _other$production_cod : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.production_code,
332
334
  quantity: quantity,
333
335
  // 规格弹窗本次选择是 option 权威源,避免目录/旧订单里的空 option 覆盖它。
334
336
  product_sku: productSku ? _objectSpread(_objectSpread({}, productSku), {}, {
@@ -44,6 +44,8 @@ export interface ScanOrderProductSku {
44
44
  export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
45
45
  order_detail_id: number | null;
46
46
  num: number;
47
+ /** Product 或当前 Variant 的生产编码 */
48
+ production_code?: string;
47
49
  product_sku: ScanOrderProductSku;
48
50
  /**
49
51
  * 券后 **行 composite 单价** = `metadata.main_product_selling_price`
@@ -660,11 +660,14 @@ export function normalizeOrderProduct(product) {
660
660
  sellingPrice: composedSellingPrice,
661
661
  quantity: getSafeProductNum(product.num)
662
662
  });
663
- return {
663
+ return _objectSpread(_objectSpread({
664
664
  order_detail_id: product.order_detail_id || null,
665
665
  product_id: product.product_id,
666
666
  num: getSafeProductNum(product.num),
667
- product_variant_id: product.product_variant_id,
667
+ product_variant_id: product.product_variant_id
668
+ }, product.production_code !== undefined && product.production_code !== null ? {
669
+ production_code: String(product.production_code).trim()
670
+ } : {}), {}, {
668
671
  product_sku: productSku,
669
672
  selling_price: composedSellingPrice,
670
673
  original_price: manualOriginalPrice,
@@ -674,7 +677,7 @@ export function normalizeOrderProduct(product) {
674
677
  product_bundle: normalizedBundle,
675
678
  metadata: metadata,
676
679
  note: product.note != null ? String(product.note) : ''
677
- };
680
+ });
678
681
  }
679
682
 
680
683
  /**
@@ -1 +1,46 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _examples.ITEM_REWARD_STRATEGY;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "PromotionAdapter", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _adapter.PromotionAdapter;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "PromotionEvaluator", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _evaluator.PromotionEvaluator;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "default", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _adapter.default;
40
+ }
41
+ });
42
+ var _evaluator = require("./evaluator");
43
+ var _adapter = _interopRequireWildcard(require("./adapter"));
44
+ var _examples = require("./examples");
45
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -191,6 +191,8 @@ export interface OrderLocalizedText {
191
191
  export interface OrderProduct extends OrderProductIdentity {
192
192
  order_detail_id: number | null;
193
193
  num: number;
194
+ /** Product 或当前 Variant 的生产编码 */
195
+ production_code?: string;
194
196
  bundle_edit?: number;
195
197
  product_sku: OrderProductSku;
196
198
  gift_card?: number;
@@ -909,6 +909,7 @@ function formatSubmitBundleItems(bundle) {
909
909
  return {
910
910
  is_charge_tax: rawBundle.is_charge_tax ?? 0,
911
911
  bundle_variant_id: rawBundle.bundle_variant_id ?? 0,
912
+ production_code: rawBundle.production_code,
912
913
  num,
913
914
  quantity: toBundleNumber(rawBundle.quantity ?? rawBundle.num, num),
914
915
  extension_id: rawBundle.extension_id ?? 0,
@@ -77,6 +77,8 @@ export interface ProductData {
77
77
  is_gst: number;
78
78
  /** 商品编码 */
79
79
  code: string;
80
+ /** ERP/生产侧商品编码;有规格时以选中 Variant 的值为准 */
81
+ production_code?: string;
80
82
  /** 商品条码 */
81
83
  barcode: string;
82
84
  /** 是否支持配送 */
@@ -1961,7 +1961,7 @@ class RulesModule extends _BaseModule.BaseModule {
1961
1961
  // 套餐适用范围配置
1962
1962
  const packageScope = usageRules?.package_scope;
1963
1963
  const {
1964
- type: scopeType,
1964
+ type: scopeType = 'product_all',
1965
1965
  exclude_bundle_product_ids = [],
1966
1966
  include_bundle_product_ids = [],
1967
1967
  filter = 0
@@ -1969,6 +1969,8 @@ class RulesModule extends _BaseModule.BaseModule {
1969
1969
  const isMainProduct = flatItem.type === 'main'; // 单独购买
1970
1970
  const isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
1971
1971
  const bundleMainProductId = flatItem.product?.product_id;
1972
+ // 主商品id
1973
+ const mainProductId = flatItem?.originProduct?._productOrigin?.id || flatItem?.parentProduct?.id || 0;
1972
1974
 
1973
1975
  // 主商品直接可用
1974
1976
  if (isMainProduct) {
@@ -1985,7 +1987,7 @@ class RulesModule extends _BaseModule.BaseModule {
1985
1987
  const priceType = flatItem.bundleItem?.price_type;
1986
1988
  const priceTypeExt = flatItem.bundleItem?.price_type_ext;
1987
1989
  // 主商品id
1988
- const mainProductId = flatItem?.originProduct?._productOrigin?.id || flatItem?.parentProduct?.id || 0;
1990
+ // const mainProductId = flatItem?.originProduct?._productOrigin?.id || flatItem?.parentProduct?.id || 0;
1989
1991
  // original_price 对应:
1990
1992
  // 1. price_type: "markup" && price_type_ext: "product_price"
1991
1993
  // markup_price 对应:
@@ -2010,13 +2012,13 @@ class RulesModule extends _BaseModule.BaseModule {
2010
2012
  if (!filter) {
2011
2013
  isScopeValid = true;
2012
2014
  } else {
2013
- isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
2015
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
2014
2016
  }
2015
2017
  }
2016
2018
 
2017
2019
  // 包含套餐判断, products值兼容旧数据
2018
2020
  if (scopeType === 'specific_packages' || scopeType === 'products') {
2019
- isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
2021
+ isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
2020
2022
  }
2021
2023
 
2022
2024
  // 价格和套餐适用范围都符合,则可用
@@ -2078,13 +2080,13 @@ class RulesModule extends _BaseModule.BaseModule {
2078
2080
  if (!filter) {
2079
2081
  isScopeValid = true;
2080
2082
  } else {
2081
- isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
2083
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
2082
2084
  }
2083
2085
  }
2084
2086
 
2085
2087
  // 包含套餐判断, products值兼容旧数据
2086
2088
  if (scopeType === 'specific_packages' || scopeType === 'products') {
2087
- isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
2089
+ isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
2088
2090
  }
2089
2091
 
2090
2092
  // 价格和套餐适用范围都符合,则可用
@@ -112,6 +112,8 @@ export interface BaseSalesUpdateOrderProductQuantityParams extends BaseSalesOrde
112
112
  export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
113
113
  order_detail_id: number | null;
114
114
  num: number;
115
+ /** Product 或当前 Variant 的生产编码 */
116
+ production_code?: string;
115
117
  product_sku: BaseSalesProductSku;
116
118
  /**
117
119
  * 券后 **行 composite 单价** = `metadata.main_product_selling_price`
@@ -3,6 +3,7 @@ import type { ProductData } from '../../../modules/Product/types';
3
3
  export interface BaseProductDetailOptionItem {
4
4
  option_group_item_id?: number | string;
5
5
  option_group_id?: number | string;
6
+ production_code?: string;
6
7
  num?: number | string;
7
8
  quantity?: number | string;
8
9
  price?: number | string;
@@ -10,6 +11,7 @@ export interface BaseProductDetailOptionItem {
10
11
  [key: string]: any;
11
12
  }
12
13
  export interface BaseProductDetailBundleItem {
14
+ production_code?: string;
13
15
  option?: BaseProductDetailOptionItem[];
14
16
  [key: string]: any;
15
17
  }
@@ -18,6 +20,7 @@ export interface BaseProductDetailPayload {
18
20
  product_id?: number | string | null;
19
21
  variant_id?: number | string | null;
20
22
  product_variant_id?: number | string | null;
23
+ production_code?: string;
21
24
  quantity?: number | string;
22
25
  num?: number | string;
23
26
  option?: BaseProductDetailOptionItem[];
@@ -27,6 +27,10 @@ function toPriceString(value, fallback = '0.00') {
27
27
  if (!Number.isFinite(parsedValue)) return fallback;
28
28
  return parsedValue.toFixed(2);
29
29
  }
30
+ function normalizeProductionCode(value) {
31
+ if (value === undefined || value === null) return '';
32
+ return String(value).trim();
33
+ }
30
34
  function isBlankValue(value) {
31
35
  return value === undefined || value === null || typeof value === 'string' && value.trim() === '';
32
36
  }
@@ -108,6 +112,7 @@ function transformBaseProductToOrderProduct(params) {
108
112
  ...(callbackOrigin || {})
109
113
  };
110
114
  const matchedVariant = findVariantById(callbackOrigin, productVariantId) ?? findVariantById(sourceProduct, productVariantId) ?? findVariantById(origin, productVariantId);
115
+ const productionCode = normalizeProductionCode(Object.prototype.hasOwnProperty.call(payload, 'production_code') ? payload.production_code : productVariantId > 0 ? matchedVariant?.production_code : origin?.production_code ?? sourceProduct?.production_code);
111
116
  const hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
112
117
  // 手动改价后 payload.price 是分摊后的主商品售价,不能再作为券前 source。
113
118
  // 此时优先从商品/variant 快照读取目录价;售价仍由 line_total - bundle 推导。
@@ -193,6 +198,7 @@ function transformBaseProductToOrderProduct(params) {
193
198
  return {
194
199
  product_id: productId,
195
200
  product_variant_id: productVariantId,
201
+ production_code: productionCode,
196
202
  unique_identification_number: uniqueIdentificationNumber ? String(uniqueIdentificationNumber) : undefined,
197
203
  num: resolvedQuantity,
198
204
  product_sku: {
@@ -257,6 +257,9 @@ function normalizeOrderProduct(product) {
257
257
  product_id: product.product_id,
258
258
  num: getSafeProductNum(product.num),
259
259
  product_variant_id: product.product_variant_id,
260
+ ...(product.production_code !== undefined && product.production_code !== null ? {
261
+ production_code: String(product.production_code).trim()
262
+ } : {}),
260
263
  product_sku: productSku,
261
264
  selling_price: composedSellingPrice,
262
265
  original_price: finalOriginalPrice,
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 5 | 3 | 4 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -345,7 +345,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
345
345
  count: number;
346
346
  left: number;
347
347
  summaryCount: number;
348
- status: "sold_out" | "lots_of_space" | "filling_up_fast";
348
+ status: "lots_of_space" | "filling_up_fast" | "sold_out";
349
349
  }[];
350
350
  /**
351
351
  * 找到多个资源的公共可用时间段
@@ -336,6 +336,8 @@ function buildBasePayloadFromCacheItem(cacheItem, ctx) {
336
336
  id: cacheItem?.id ?? cacheItem?.product_id,
337
337
  product_id: resolvedPid,
338
338
  variant_id: other?.product_variant_id ?? other?.variant_id ?? 0,
339
+ // SKUOptionsSelection 已按 Product / Variant 解析好主商品编码;显式空串也需保留。
340
+ production_code: other?.production_code ?? cacheItem?.production_code,
339
341
  quantity,
340
342
  // 规格弹窗本次选择是 option 权威源,避免目录/旧订单里的空 option 覆盖它。
341
343
  product_sku: productSku ? {
@@ -44,6 +44,8 @@ export interface ScanOrderProductSku {
44
44
  export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
45
45
  order_detail_id: number | null;
46
46
  num: number;
47
+ /** Product 或当前 Variant 的生产编码 */
48
+ production_code?: string;
47
49
  product_sku: ScanOrderProductSku;
48
50
  /**
49
51
  * 券后 **行 composite 单价** = `metadata.main_product_selling_price`
@@ -633,6 +633,9 @@ function normalizeOrderProduct(product) {
633
633
  product_id: product.product_id,
634
634
  num: getSafeProductNum(product.num),
635
635
  product_variant_id: product.product_variant_id,
636
+ ...(product.production_code !== undefined && product.production_code !== null ? {
637
+ production_code: String(product.production_code).trim()
638
+ } : {}),
636
639
  product_sku: productSku,
637
640
  selling_price: composedSellingPrice,
638
641
  original_price: manualOriginalPrice,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.88",
4
+ "version": "2.3.89",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",