@pisell/pisellos 0.0.495 → 0.0.496

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.
@@ -112,14 +112,14 @@ export interface SubmitScanOrderParams {
112
112
  products: SubmitScanOrderProduct[];
113
113
  bookings: SubmitScanOrderBooking[];
114
114
  payments: any[];
115
- surcharges: any[];
115
+ surcharges?: any[];
116
116
  discount_list: any[];
117
117
  relation_forms: any[];
118
118
  form_record_ids?: SubmitScanOrderFormRecord[];
119
119
  contacts: any[];
120
120
  contacts_info: any[];
121
121
  holder: Record<string, any> | null;
122
- summary: SubmitScanOrderSummary;
122
+ summary?: SubmitScanOrderSummary;
123
123
  metadata: Record<string, any>;
124
124
  };
125
125
  }
@@ -1,5 +1,5 @@
1
1
  var _excluded = ["_origin", "identity_key"],
2
- _excluded2 = ["created_at"];
2
+ _excluded2 = ["created_at", "summary", "surcharges"];
3
3
  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; }
4
4
  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; }
5
5
  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; }
@@ -233,8 +233,10 @@ export function buildSubmitPayload(params) {
233
233
  form_record_ids: [relationId]
234
234
  }] : undefined;
235
235
  var _createdAt = tempOrder.created_at,
236
- tempOrderWithoutCreatedAt = _objectWithoutProperties(tempOrder, _excluded2);
237
- return _objectSpread(_objectSpread({}, tempOrderWithoutCreatedAt), {}, {
236
+ _summary = tempOrder.summary,
237
+ _surcharges = tempOrder.surcharges,
238
+ tempOrderRest = _objectWithoutProperties(tempOrder, _excluded2);
239
+ return _objectSpread(_objectSpread({}, tempOrderRest), {}, {
238
240
  platform: normalizeSubmitPlatform(tempOrder.platform),
239
241
  request_unique_idempotency_token: cacheId,
240
242
  type: tempOrder.type || 'table-order',
@@ -254,7 +256,6 @@ export function buildSubmitPayload(params) {
254
256
  schedule_date: scheduleDate,
255
257
  bookings: bookings,
256
258
  payments: tempOrder.payments || [],
257
- surcharges: tempOrder.surcharges || [],
258
259
  // discount_list: tempOrder.discount_list || [],
259
260
  relation_forms: tempOrder.relation_forms || [],
260
261
  form_record_ids: formRecordIds,
@@ -304,8 +304,10 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
304
304
 
305
305
  // --- 主商品折后税费 ---
306
306
  var mainTotal = getMainProductPaymentTotal(product);
307
+ var surchargeFee = toDecimal(product.surcharge_fee);
308
+ var mainTaxableBase = mainTotal.lte(0) ? surchargeFee : mainTotal.plus(surchargeFee);
307
309
  var mainTaxPrecise = calculateSingleItemTax({
308
- price: mainTotal,
310
+ price: mainTaxableBase,
309
311
  taxRate: rate,
310
312
  isPriceIncludeTax: isPriceIncludeTax,
311
313
  isChargeTax: (_product$is_charge_ta2 = product.is_charge_tax) !== null && _product$is_charge_ta2 !== void 0 ? _product$is_charge_ta2 : 0
@@ -320,8 +322,9 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
320
322
 
321
323
  // --- 主商品原价税费 ---
322
324
  var originalTotal = getUnitOriginalTotal(product);
325
+ var originalTaxableBase = originalTotal.lte(0) ? surchargeFee : originalTotal.plus(surchargeFee);
323
326
  var originalTaxPrecise = calculateSingleItemTax({
324
- price: originalTotal,
327
+ price: originalTaxableBase,
325
328
  taxRate: rate,
326
329
  isPriceIncludeTax: isPriceIncludeTax,
327
330
  isChargeTax: (_product$is_charge_ta3 = product.is_charge_tax) !== null && _product$is_charge_ta3 !== void 0 ? _product$is_charge_ta3 : 0
@@ -451,16 +454,6 @@ export function calculateSalesSummary(params) {
451
454
  var productAmount = products.reduce(function (sum, item) {
452
455
  return sum.plus(getUnitPaymentTotal(item).times(getSafeNum(item.num)));
453
456
  }, new Decimal(0));
454
- var hasTaxRate = taxRate !== undefined && taxRate !== null && taxRate > 0;
455
- var productTaxFee;
456
- if (hasTaxRate) {
457
- var taxResult = calculateProductsTax(products, taxRate, isPriceIncludeTax);
458
- productTaxFee = taxResult.tax;
459
- } else {
460
- productTaxFee = products.reduce(function (sum, item) {
461
- return sum.plus(toDecimal(item.tax_fee).times(getSafeNum(item.num)));
462
- }, new Decimal(0));
463
- }
464
457
  var surchargeServiceItems = buildSurchargeServiceItems(products);
465
458
  var surcharge = getSurcharge({
466
459
  service: surchargeServiceItems,
@@ -479,6 +472,20 @@ export function calculateSalesSummary(params) {
479
472
  }, surcharge, {
480
473
  isEdit: false
481
474
  }) || 0);
475
+ for (var i = 0; i < products.length; i++) {
476
+ var _surchargeServiceItem;
477
+ products[i].surcharge_fee = ((_surchargeServiceItem = surchargeServiceItems[i]) === null || _surchargeServiceItem === void 0 ? void 0 : _surchargeServiceItem.surcharge_fee) || 0;
478
+ }
479
+ var hasTaxRate = taxRate !== undefined && taxRate !== null && taxRate > 0;
480
+ var productTaxFee;
481
+ if (hasTaxRate) {
482
+ var taxResult = calculateProductsTax(products, taxRate, isPriceIncludeTax);
483
+ productTaxFee = taxResult.tax;
484
+ } else {
485
+ productTaxFee = products.reduce(function (sum, item) {
486
+ return sum.plus(toDecimal(item.tax_fee).times(getSafeNum(item.num)));
487
+ }, new Decimal(0));
488
+ }
482
489
  var expectAmount = productAmount.plus(surchargeAmount);
483
490
  var totalAmount = isPriceIncludeTax === 1 ? expectAmount : expectAmount.plus(productTaxFee);
484
491
  var deposit = calculateProductsDeposit(products);
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 1 | 4 | 2 | 3 | 6 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -330,7 +330,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
330
330
  count: number;
331
331
  left: number;
332
332
  summaryCount: number;
333
- status: "lots_of_space" | "filling_up_fast" | "sold_out";
333
+ status: "sold_out" | "lots_of_space" | "filling_up_fast";
334
334
  }[];
335
335
  /**
336
336
  * 找到多个资源的公共可用时间段
@@ -122,7 +122,7 @@ export interface ScanOrderTempOrder {
122
122
  summary: ScanOrderSummary;
123
123
  metadata: Record<string, any>;
124
124
  }
125
- export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platform' | 'products' | 'created_at'> {
125
+ export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platform' | 'products' | 'created_at' | 'summary' | 'surcharges'> {
126
126
  platform: 'H5' | 'PC';
127
127
  request_unique_idempotency_token?: string;
128
128
  form_record_ids?: Array<{
@@ -66,8 +66,8 @@ export function buildPriceBreakdown(params) {
66
66
  productId: productId,
67
67
  datetime: slot.startTime
68
68
  }) : 0;
69
- var startHm = dayjs(slot.startTime, 'YYYY-MM-DD HH:mm').format('HH:mm');
70
- var endHm = dayjs(slot.endTime, 'YYYY-MM-DD HH:mm').format('HH:mm');
69
+ var startHm = dayjs(slot.startTime, 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD HH:mm');
70
+ var endHm = dayjs(slot.endTime, 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD HH:mm');
71
71
  var last = entries[entries.length - 1];
72
72
  if (last && last.unit_price === unitPrice && last.quotation_shelf_id === shelfId && last.end_time === startHm) {
73
73
  last.end_time = endHm;
@@ -150,7 +150,6 @@ export function expandMergedSlotToIndividual(product, slotDurationMinutes) {
150
150
  var endTime = meta.end_time;
151
151
  if (!startTime || !endTime) return [];
152
152
  var breakdown = meta.price_breakdown;
153
- var datePrefix = dayjs(startTime, 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD');
154
153
  var result = [];
155
154
  var cursor = dayjs(startTime, 'YYYY-MM-DD HH:mm');
156
155
  var end = dayjs(endTime, 'YYYY-MM-DD HH:mm');
@@ -161,8 +160,8 @@ export function expandMergedSlotToIndividual(product, slotDurationMinutes) {
161
160
  try {
162
161
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
163
162
  var entry = _step2.value;
164
- var entryCursor = dayjs("".concat(datePrefix, " ").concat(entry.start_time), 'YYYY-MM-DD HH:mm');
165
- var entryEnd = dayjs("".concat(datePrefix, " ").concat(entry.end_time), 'YYYY-MM-DD HH:mm');
163
+ var entryCursor = dayjs(entry.start_time, 'YYYY-MM-DD HH:mm');
164
+ var entryEnd = dayjs(entry.end_time, 'YYYY-MM-DD HH:mm');
166
165
  while (entryCursor.isBefore(entryEnd)) {
167
166
  priceMap.set(entryCursor.format('HH:mm'), entry.unit_price);
168
167
  entryCursor = entryCursor.add(slotDurationMinutes, 'minute');
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
34
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
+ default: () => import_adapter2.default
37
+ });
38
+ module.exports = __toCommonJS(promotion_exports);
39
+ var import_evaluator = require("./evaluator");
40
+ var import_adapter = require("./adapter");
41
+ var import_adapter2 = __toESM(require("./adapter"));
42
+ var import_examples = require("./examples");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ BUY_X_GET_Y_FREE_STRATEGY,
46
+ PromotionAdapter,
47
+ PromotionEvaluator,
48
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
49
+ });
@@ -112,14 +112,14 @@ export interface SubmitScanOrderParams {
112
112
  products: SubmitScanOrderProduct[];
113
113
  bookings: SubmitScanOrderBooking[];
114
114
  payments: any[];
115
- surcharges: any[];
115
+ surcharges?: any[];
116
116
  discount_list: any[];
117
117
  relation_forms: any[];
118
118
  form_record_ids?: SubmitScanOrderFormRecord[];
119
119
  contacts: any[];
120
120
  contacts_info: any[];
121
121
  holder: Record<string, any> | null;
122
- summary: SubmitScanOrderSummary;
122
+ summary?: SubmitScanOrderSummary;
123
123
  metadata: Record<string, any>;
124
124
  };
125
125
  }
@@ -235,9 +235,9 @@ function buildSubmitPayload(params) {
235
235
  form_id: tableFormId,
236
236
  form_record_ids: [relationId]
237
237
  }] : void 0;
238
- const { created_at: _createdAt, ...tempOrderWithoutCreatedAt } = tempOrder;
238
+ const { created_at: _createdAt, summary: _summary, surcharges: _surcharges, ...tempOrderRest } = tempOrder;
239
239
  return {
240
- ...tempOrderWithoutCreatedAt,
240
+ ...tempOrderRest,
241
241
  platform: normalizeSubmitPlatform(tempOrder.platform),
242
242
  request_unique_idempotency_token: cacheId,
243
243
  type: tempOrder.type || "table-order",
@@ -257,7 +257,6 @@ function buildSubmitPayload(params) {
257
257
  schedule_date: scheduleDate,
258
258
  bookings,
259
259
  payments: tempOrder.payments || [],
260
- surcharges: tempOrder.surcharges || [],
261
260
  // discount_list: tempOrder.discount_list || [],
262
261
  relation_forms: tempOrder.relation_forms || [],
263
262
  form_record_ids: formRecordIds,
@@ -259,8 +259,10 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
259
259
  for (const product of products) {
260
260
  const quantity = new import_decimal.default(getSafeNum(product.num));
261
261
  const mainTotal = getMainProductPaymentTotal(product);
262
+ const surchargeFee = toDecimal(product.surcharge_fee);
263
+ const mainTaxableBase = mainTotal.lte(0) ? surchargeFee : mainTotal.plus(surchargeFee);
262
264
  const mainTaxPrecise = calculateSingleItemTax({
263
- price: mainTotal,
265
+ price: mainTaxableBase,
264
266
  taxRate: rate,
265
267
  isPriceIncludeTax,
266
268
  isChargeTax: product.is_charge_tax ?? 0
@@ -270,8 +272,9 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
270
272
  lastTaxableItem = { type: "main", item: product };
271
273
  }
272
274
  const originalTotal = getUnitOriginalTotal(product);
275
+ const originalTaxableBase = originalTotal.lte(0) ? surchargeFee : originalTotal.plus(surchargeFee);
273
276
  const originalTaxPrecise = calculateSingleItemTax({
274
- price: originalTotal,
277
+ price: originalTaxableBase,
275
278
  taxRate: rate,
276
279
  isPriceIncludeTax,
277
280
  isChargeTax: product.is_charge_tax ?? 0
@@ -358,6 +361,7 @@ function createEmptySalesSummary() {
358
361
  };
359
362
  }
360
363
  function calculateSalesSummary(params) {
364
+ var _a;
361
365
  const {
362
366
  products,
363
367
  isPriceIncludeTax,
@@ -380,17 +384,6 @@ function calculateSalesSummary(params) {
380
384
  (sum, item) => sum.plus(getUnitPaymentTotal(item).times(getSafeNum(item.num))),
381
385
  new import_decimal.default(0)
382
386
  );
383
- const hasTaxRate = taxRate !== void 0 && taxRate !== null && taxRate > 0;
384
- let productTaxFee;
385
- if (hasTaxRate) {
386
- const taxResult = calculateProductsTax(products, taxRate, isPriceIncludeTax);
387
- productTaxFee = taxResult.tax;
388
- } else {
389
- productTaxFee = products.reduce(
390
- (sum, item) => sum.plus(toDecimal(item.tax_fee).times(getSafeNum(item.num))),
391
- new import_decimal.default(0)
392
- );
393
- }
394
387
  const surchargeServiceItems = buildSurchargeServiceItems(products);
395
388
  const surcharge = (0, import_utils.getSurcharge)(
396
389
  {
@@ -413,6 +406,20 @@ function calculateSalesSummary(params) {
413
406
  { isEdit: false }
414
407
  ) || 0
415
408
  );
409
+ for (let i = 0; i < products.length; i++) {
410
+ products[i].surcharge_fee = ((_a = surchargeServiceItems[i]) == null ? void 0 : _a.surcharge_fee) || 0;
411
+ }
412
+ const hasTaxRate = taxRate !== void 0 && taxRate !== null && taxRate > 0;
413
+ let productTaxFee;
414
+ if (hasTaxRate) {
415
+ const taxResult = calculateProductsTax(products, taxRate, isPriceIncludeTax);
416
+ productTaxFee = taxResult.tax;
417
+ } else {
418
+ productTaxFee = products.reduce(
419
+ (sum, item) => sum.plus(toDecimal(item.tax_fee).times(getSafeNum(item.num))),
420
+ new import_decimal.default(0)
421
+ );
422
+ }
416
423
  const expectAmount = productAmount.plus(surchargeAmount);
417
424
  const totalAmount = isPriceIncludeTax === 1 ? expectAmount : expectAmount.plus(productTaxFee);
418
425
  const deposit = calculateProductsDeposit(products);
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 1 | 4 | 2 | 3 | 6 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -330,7 +330,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
330
330
  count: number;
331
331
  left: number;
332
332
  summaryCount: number;
333
- status: "lots_of_space" | "filling_up_fast" | "sold_out";
333
+ status: "sold_out" | "lots_of_space" | "filling_up_fast";
334
334
  }[];
335
335
  /**
336
336
  * 找到多个资源的公共可用时间段
@@ -122,7 +122,7 @@ export interface ScanOrderTempOrder {
122
122
  summary: ScanOrderSummary;
123
123
  metadata: Record<string, any>;
124
124
  }
125
- export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platform' | 'products' | 'created_at'> {
125
+ export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platform' | 'products' | 'created_at' | 'summary' | 'surcharges'> {
126
126
  platform: 'H5' | 'PC';
127
127
  request_unique_idempotency_token?: string;
128
128
  form_record_ids?: Array<{
@@ -88,8 +88,8 @@ function buildPriceBreakdown(params) {
88
88
  for (const slot of group.slots) {
89
89
  const unitPrice = Number(slot.price || "0");
90
90
  const shelfId = quotation ? quotation.getQuotationShelfId({ productId, datetime: slot.startTime }) : 0;
91
- const startHm = (0, import_dayjs.default)(slot.startTime, "YYYY-MM-DD HH:mm").format("HH:mm");
92
- const endHm = (0, import_dayjs.default)(slot.endTime, "YYYY-MM-DD HH:mm").format("HH:mm");
91
+ const startHm = (0, import_dayjs.default)(slot.startTime, "YYYY-MM-DD HH:mm").format("YYYY-MM-DD HH:mm");
92
+ const endHm = (0, import_dayjs.default)(slot.endTime, "YYYY-MM-DD HH:mm").format("YYYY-MM-DD HH:mm");
93
93
  const last = entries[entries.length - 1];
94
94
  if (last && last.unit_price === unitPrice && last.quotation_shelf_id === shelfId && last.end_time === startHm) {
95
95
  last.end_time = endHm;
@@ -157,15 +157,14 @@ function expandMergedSlotToIndividual(product, slotDurationMinutes) {
157
157
  if (!startTime || !endTime)
158
158
  return [];
159
159
  const breakdown = meta.price_breakdown;
160
- const datePrefix = (0, import_dayjs.default)(startTime, "YYYY-MM-DD HH:mm").format("YYYY-MM-DD");
161
160
  const result = [];
162
161
  let cursor = (0, import_dayjs.default)(startTime, "YYYY-MM-DD HH:mm");
163
162
  const end = (0, import_dayjs.default)(endTime, "YYYY-MM-DD HH:mm");
164
163
  if (breakdown == null ? void 0 : breakdown.length) {
165
164
  const priceMap = /* @__PURE__ */ new Map();
166
165
  for (const entry of breakdown) {
167
- let entryCursor = (0, import_dayjs.default)(`${datePrefix} ${entry.start_time}`, "YYYY-MM-DD HH:mm");
168
- const entryEnd = (0, import_dayjs.default)(`${datePrefix} ${entry.end_time}`, "YYYY-MM-DD HH:mm");
166
+ let entryCursor = (0, import_dayjs.default)(entry.start_time, "YYYY-MM-DD HH:mm");
167
+ const entryEnd = (0, import_dayjs.default)(entry.end_time, "YYYY-MM-DD HH:mm");
169
168
  while (entryCursor.isBefore(entryEnd)) {
170
169
  priceMap.set(entryCursor.format("HH:mm"), entry.unit_price);
171
170
  entryCursor = entryCursor.add(slotDurationMinutes, "minute");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.495",
4
+ "version": "0.0.496",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",