@pisell/pisellos 2.2.13 → 2.2.14

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.
@@ -216,70 +216,23 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
216
216
  return pre + (item.amount || 0);
217
217
  }, 0);
218
218
  };
219
- const formatProduct = (items) => {
220
- return items.map(
221
- (item) => ({
222
- product_id: item.product_id,
223
- product_variant_id: item.product_variant_id,
224
- quantity: item.num,
225
- // 商品是否含税:1;0
226
- is_charge_tax: item.is_charge_tax ?? 0,
227
- // 若商品不含税,计算得到的税费,单位(元)
228
- tax_fee: item.tax_fee,
229
- // 整个商品折扣后的总金额
230
- selling_price: item.calculated_selling_price,
231
- // 使用者id
232
- holder_id: item.holder_id,
233
- // 整个商品折扣前的总金额
234
- original_price: item.calculated_original_price,
235
- // 主商品折扣前金额,不包含套餐子商品
236
- main_product_original_price: item.price,
237
- // 主商品折扣后金额,不包含套餐子商品
238
- main_product_selling_price: item.main_product_selling_price,
239
- metadata: {
240
- // 主商品+非原价(加减价)子商品税费
241
- "main_product_attached_bundle_tax_fee": item.metadata.main_product_attached_bundle_tax_fee,
242
- // 主商品+非原价(加减价)子商品附加费
243
- "main_product_attached_bundle_surcharge_fee": item.metadata.main_product_attached_bundle_surcharge_fee,
244
- // 可选,附加费均摊舍入金额
245
- "surcharge_rounding_remainder": item.metadata.surcharge_rounding_remainder
246
- },
247
- product_bundle: item.product_bundle.map((bundle) => {
248
- return {
249
- bundle_id: bundle.bundle_id,
250
- bundle_product_id: bundle.bundle_product_id,
251
- bundle_variant_id: bundle.bundle_variant_id,
252
- price_type: bundle.price_type,
253
- price_type_ext: bundle.price_type_ext,
254
- // 套餐子商品总价,不包含折扣金额
255
- bundle_sum_price: bundle.bundle_sum_price,
256
- // 套餐子商品折扣后金额
257
- bundle_selling_price: bundle.bundle_selling_price,
258
- num: bundle.num,
259
- is_charge_tax: bundle.is_charge_tax,
260
- tax_fee: bundle.tax_fee,
261
- metadata: {
262
- // 子商品单数量附加费
263
- "surcharge_fee": bundle.metadata.surcharge_fee,
264
- // 可选,附加费均摊舍入金额
265
- "surcharge_rounding_remainder": bundle.metadata.surcharge_rounding_remainder
266
- }
267
- };
268
- })
269
- })
270
- ) || [];
271
- };
272
- const productList = formatProduct(
273
- ((_c = (_b = (_a = this.store.currentOrder.order_info) == null ? void 0 : _a.original_order_data) == null ? void 0 : _b.bookings) == null ? void 0 : _c.map(
274
- (item) => {
275
- return {
276
- ...item.product,
277
- holder_id: this.getHolderIdFromBooking(item)
278
- };
279
- }
280
- )) || []
281
- );
282
- const relationProducts = formatProduct(((_e = (_d = this.store.currentOrder.order_info) == null ? void 0 : _d.original_order_data) == null ? void 0 : _e.relation_products) || []);
219
+ const productList = ((_b = (_a = this.store.currentOrder.order_info) == null ? void 0 : _a.original_order_data.bookings) == null ? void 0 : _b.map(
220
+ (item) => ({
221
+ product_id: item.product.product_id,
222
+ product_variant_id: item.product.product_variant_id,
223
+ quantity: item.product.num,
224
+ selling_price: item.product.calculated_selling_price,
225
+ holder_id: this.getHolderIdFromBooking(item)
226
+ })
227
+ )) || [];
228
+ const relationProducts = ((_e = (_d = (_c = this.store.currentOrder.order_info) == null ? void 0 : _c.original_order_data) == null ? void 0 : _d.relation_products) == null ? void 0 : _e.map(
229
+ (item) => ({
230
+ product_id: item.product_id,
231
+ product_variant_id: item.product_variant_id,
232
+ quantity: item.num,
233
+ selling_price: item.source_product_price
234
+ })
235
+ )) || [];
283
236
  return [...productList, ...relationProducts];
284
237
  }
285
238
  async initWalletData(params) {
@@ -304,8 +257,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
304
257
  isDeposit: (_h = this.store.currentOrder) == null ? void 0 : _h.is_deposit
305
258
  },
306
259
  products: this.getProductListByOrder(),
307
- is_price_include_tax: this.otherParams.is_price_include_tax,
308
- // core 有
309
260
  ...params
310
261
  };
311
262
  if (this.store.isOrderSynced) {
@@ -1030,7 +981,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1030
981
  if (Number(remainingAmount) > 0) {
1031
982
  this.logInfo("订单金额还有待付的,同步 EFTPOS 支付");
1032
983
  const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
1033
- const isCashPayment2 = paymentItem.code === "CASHMANUAL";
984
+ const isCash = (0, import_utils.isCashPayment)(paymentItem);
1034
985
  const isCustomePayment = paymentItem.type === "custom";
1035
986
  this.logInfo("EFTPOS 支付检查:", {
1036
987
  paymentCode: paymentItem.code,
@@ -1038,7 +989,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1038
989
  isEftposPayment,
1039
990
  currentOrderSynced: this.store.isOrderSynced
1040
991
  });
1041
- if (isEftposPayment || isCashPayment2 || isCustomePayment) {
992
+ if (isEftposPayment || isCash || isCustomePayment) {
1042
993
  this.logInfo("检测到 EFTPOS 支付,立即同步订单到后端...");
1043
994
  try {
1044
995
  const syncResult = await this.syncOrderToBackendWithReturn(true);
@@ -1767,7 +1718,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1767
1718
  * @returns 处理后的支付项(包含找零信息)
1768
1719
  */
1769
1720
  async processCashPaymentItem(paymentItem) {
1770
- const cashPayment = (0, import_utils.isCashPayment)(paymentItem.code, paymentItem.type);
1721
+ const cashPayment = (0, import_utils.isCashPayment)(paymentItem);
1771
1722
  if (!cashPayment) {
1772
1723
  return paymentItem;
1773
1724
  }
@@ -1,5 +1,6 @@
1
1
  import { CheckoutInitParams, CheckoutError, CheckoutErrorType, LocalOrderData, CartSummaryItem, ExtractedAmountInfo } from '../types';
2
2
  import { CartItem } from '../../../modules/Cart/types';
3
+ import { PaymentItemInput } from '../../../modules/Payment/types';
3
4
  /**
4
5
  * 验证结账数据
5
6
  */
@@ -118,4 +119,4 @@ export declare function shouldSyncOrderForPayment(paymentCode: string, paymentTy
118
119
  * @param paymentType 支付方式类型
119
120
  * @returns 是否为现金支付
120
121
  */
121
- export declare function isCashPayment(paymentCode?: string, paymentType?: string): boolean;
122
+ export declare function isCashPayment(paymentItem: PaymentItemInput): boolean;
@@ -326,13 +326,15 @@ function shouldSyncOrderForPayment(paymentCode, paymentType) {
326
326
  }
327
327
  return true;
328
328
  }
329
- function isCashPayment(paymentCode, paymentType) {
330
- const codeUpper = (paymentCode == null ? void 0 : paymentCode.toUpperCase()) || "";
331
- const typeUpper = (paymentType == null ? void 0 : paymentType.toUpperCase()) || "";
329
+ function isCashPayment(paymentItem) {
330
+ var _a, _b, _c;
331
+ const codeUpper = ((_a = paymentItem.code) == null ? void 0 : _a.toUpperCase()) || "";
332
+ const typeUpper = ((_b = paymentItem.type) == null ? void 0 : _b.toUpperCase()) || "";
333
+ const isNameCash = (_c = paymentItem.name) == null ? void 0 : _c.toLowerCase().includes("cash");
332
334
  const cashIdentifiers = ["CASH", "CASHMANUAL", "MANUAL"];
333
335
  return cashIdentifiers.some(
334
336
  (identifier) => codeUpper.includes(identifier) || typeUpper.includes(identifier)
335
- );
337
+ ) || isNameCash;
336
338
  }
337
339
  // Annotate the CommonJS export names for ESM import in node:
338
340
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.13",
4
+ "version": "2.2.14",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -69,4 +69,4 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  }
72
- }
72
+ }