@pisell/pisellos 2.2.164 → 2.2.166
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.
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +45 -15
- package/dist/modules/Order/index.d.ts +10 -3
- package/dist/modules/Order/index.js +275 -142
- package/dist/modules/Order/types.d.ts +9 -2
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +13 -0
- package/dist/modules/Order/utils.js +69 -15
- package/dist/server/index.js +1 -0
- package/dist/solution/BaseSales/index.d.ts +9 -1
- package/dist/solution/BaseSales/index.js +378 -241
- package/dist/solution/BaseSales/types.d.ts +3 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +33 -14
- package/dist/solution/BaseSales/utils.js +36 -7
- package/dist/solution/BookingTicket/index.d.ts +3 -0
- package/dist/solution/BookingTicket/index.js +170 -86
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +4 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.js +37 -19
- package/dist/solution/ScanOrder/utils.js +36 -7
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +35 -9
- package/lib/modules/Order/index.d.ts +10 -3
- package/lib/modules/Order/index.js +107 -4
- package/lib/modules/Order/types.d.ts +9 -2
- package/lib/modules/Order/utils.d.ts +13 -0
- package/lib/modules/Order/utils.js +57 -9
- package/lib/server/index.js +1 -0
- package/lib/solution/BaseSales/index.d.ts +9 -1
- package/lib/solution/BaseSales/index.js +71 -3
- package/lib/solution/BaseSales/types.d.ts +3 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +31 -10
- package/lib/solution/BaseSales/utils.js +37 -5
- package/lib/solution/BookingTicket/index.d.ts +3 -0
- package/lib/solution/BookingTicket/index.js +57 -6
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +4 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.js +28 -12
- package/lib/solution/ScanOrder/utils.js +37 -5
- package/package.json +1 -1
|
@@ -1,15 +1,18 @@
|
|
|
1
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); }
|
|
2
|
-
|
|
3
|
-
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; }
|
|
4
|
-
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; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
2
|
+
var _excluded = ["bundle_selling_price"];
|
|
7
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
5
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
6
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
7
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
13
16
|
/**
|
|
14
17
|
* 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
|
|
15
18
|
*
|
|
@@ -53,8 +56,26 @@ function resolveSourceProductPrice(product, sourceProduct) {
|
|
|
53
56
|
}
|
|
54
57
|
return Number((_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : 0);
|
|
55
58
|
}
|
|
59
|
+
|
|
60
|
+
/** 订单行 bundle → booking other.bundle(保留 original_price 供 setProductPrice 按比例分摊) */
|
|
61
|
+
function mapOrderBundleToOtherBundle(bundle) {
|
|
62
|
+
return bundle.map(function (item) {
|
|
63
|
+
var _ref, _ref2, _item$original_price, _ref3, _item$bundle_selling_, _item$original_total, _ref4, _item$num, _ref5, _item$quantity;
|
|
64
|
+
var catalogOriginal = (_ref = (_ref2 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.product_price) !== null && _ref2 !== void 0 ? _ref2 : item.price) !== null && _ref !== void 0 ? _ref : item.bundle_selling_price;
|
|
65
|
+
var selling = (_ref3 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref3 !== void 0 ? _ref3 : catalogOriginal;
|
|
66
|
+
var _omitBundleSelling = item.bundle_selling_price,
|
|
67
|
+
rest = _objectWithoutProperties(item, _excluded);
|
|
68
|
+
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
69
|
+
price: selling,
|
|
70
|
+
original_price: catalogOriginal,
|
|
71
|
+
original_total: (_item$original_total = item.original_total) !== null && _item$original_total !== void 0 ? _item$original_total : catalogOriginal,
|
|
72
|
+
num: (_ref4 = (_item$num = item.num) !== null && _item$num !== void 0 ? _item$num : item.quantity) !== null && _ref4 !== void 0 ? _ref4 : 1,
|
|
73
|
+
quantity: (_ref5 = (_item$quantity = item.quantity) !== null && _item$quantity !== void 0 ? _item$quantity : item.num) !== null && _ref5 !== void 0 ? _ref5 : 1
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
56
77
|
export function buildNormalProductCacheItemFromOrderLine(input) {
|
|
57
|
-
var _product$product_id, _product$selling_pric2, _product$original_pri, _product$metadata, _product$product_vari, _product$num, _product$product_vari2, _product$num2, _title, _product$note, _price3, _product$order_detail;
|
|
78
|
+
var _product$product_id, _product$selling_pric2, _product$original_pri, _product$metadata, _product$metadata2, _product$product_vari, _originExtend$other, _product$num, _product$product_vari2, _product$num2, _title, _product$note, _originExtend$price, _originExtend$total, _originExtend$origin_, _price3, _product$order_detail;
|
|
58
79
|
var product = input.product,
|
|
59
80
|
sourceProduct = input.sourceProduct;
|
|
60
81
|
var resolvedId = (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id;
|
|
@@ -63,33 +84,42 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
|
|
|
63
84
|
var original = Number((_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : selling);
|
|
64
85
|
var uid = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number;
|
|
65
86
|
var option = Array.isArray(product.product_option_item) ? _toConsumableArray(product.product_option_item) : [];
|
|
66
|
-
var bundle = Array.isArray(product.product_bundle) ?
|
|
87
|
+
var bundle = mapOrderBundleToOtherBundle(Array.isArray(product.product_bundle) ? product.product_bundle : []);
|
|
88
|
+
var originExtend = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 || (_product$metadata2 = _product$metadata2.origin) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2._extend;
|
|
67
89
|
var other = {
|
|
68
90
|
product_id: resolvedId,
|
|
69
91
|
product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
|
|
70
92
|
option: option,
|
|
71
|
-
bundle: bundle,
|
|
93
|
+
bundle: originExtend !== null && originExtend !== void 0 && (_originExtend$other = originExtend.other) !== null && _originExtend$other !== void 0 && _originExtend$other.bundle ? JSON.parse(JSON.stringify(originExtend.other.bundle)) : bundle,
|
|
72
94
|
quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1
|
|
73
95
|
};
|
|
74
96
|
var skuValue = {
|
|
75
97
|
product_id: resolvedId,
|
|
76
98
|
product_variant_id: (_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : 0,
|
|
77
|
-
option: option,
|
|
78
|
-
bundle: bundle
|
|
99
|
+
option: other.option,
|
|
100
|
+
bundle: other.bundle
|
|
79
101
|
};
|
|
80
|
-
var extend = {
|
|
102
|
+
var extend = _objectSpread(_objectSpread({
|
|
81
103
|
quantity: (_product$num2 = product.num) !== null && _product$num2 !== void 0 ? _product$num2 : 1,
|
|
82
104
|
product_name: (_title = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title !== void 0 ? _title : '',
|
|
83
105
|
note: (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : '',
|
|
84
106
|
// v2:_extend.price 为主商品 source 价;行 composite 用 total / origin_total 展示
|
|
85
|
-
price: sourcePrice,
|
|
86
|
-
total: selling,
|
|
87
|
-
origin_total: original,
|
|
107
|
+
price: (_originExtend$price = originExtend === null || originExtend === void 0 ? void 0 : originExtend.price) !== null && _originExtend$price !== void 0 ? _originExtend$price : sourcePrice,
|
|
108
|
+
total: (_originExtend$total = originExtend === null || originExtend === void 0 ? void 0 : originExtend.total) !== null && _originExtend$total !== void 0 ? _originExtend$total : selling,
|
|
109
|
+
origin_total: (_originExtend$origin_ = originExtend === null || originExtend === void 0 ? void 0 : originExtend.origin_total) !== null && _originExtend$origin_ !== void 0 ? _originExtend$origin_ : original,
|
|
88
110
|
other: other,
|
|
89
111
|
skuValue: JSON.parse(JSON.stringify(skuValue)),
|
|
90
112
|
_skuValue: JSON.parse(JSON.stringify(skuValue)),
|
|
91
113
|
isNormalProduct: true
|
|
92
|
-
}
|
|
114
|
+
}, (originExtend === null || originExtend === void 0 ? void 0 : originExtend.priceOverride) !== undefined ? {
|
|
115
|
+
priceOverride: originExtend.priceOverride
|
|
116
|
+
} : {}), (originExtend === null || originExtend === void 0 ? void 0 : originExtend.bundle_edit) !== undefined ? {
|
|
117
|
+
bundle_edit: originExtend.bundle_edit
|
|
118
|
+
} : {});
|
|
119
|
+
if (originExtend !== null && originExtend !== void 0 && originExtend.skuValue || originExtend !== null && originExtend !== void 0 && originExtend._skuValue) {
|
|
120
|
+
extend.skuValue = JSON.parse(JSON.stringify(originExtend.skuValue || originExtend._skuValue));
|
|
121
|
+
extend._skuValue = JSON.parse(JSON.stringify(extend.skuValue));
|
|
122
|
+
}
|
|
93
123
|
return _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
|
|
94
124
|
id: resolvedId,
|
|
95
125
|
product_id: resolvedId,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, CheckoutOrderParams, CancelOrderParams, ChangeBookingStatusParams } from './types';
|
|
3
|
+
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CheckoutOrderParams, CancelOrderParams, ChangeBookingStatusParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
6
|
import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions } from './types';
|
|
@@ -72,6 +72,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
72
72
|
getLocalOrderByOrderNumber(orderNumber: string): Promise<Record<string, any> | null>;
|
|
73
73
|
getLocalOrderByExternalSaleNumber(externalSaleNumber: string): Promise<Record<string, any> | null>;
|
|
74
74
|
saveDraft(): Promise<void>;
|
|
75
|
+
private saveDraftInBackground;
|
|
75
76
|
private hydrateTempOrderFromLocalRecord;
|
|
76
77
|
private extractOrderIdFromSubmitResult;
|
|
77
78
|
private calculatePaymentTotal;
|
|
@@ -103,7 +104,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
103
104
|
updateTempOrderNote(note: string): string;
|
|
104
105
|
updateTempOrderNote(note: string, sync: true): Promise<string>;
|
|
105
106
|
updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
|
|
106
|
-
|
|
107
|
+
syncTempOrderNoteToRemote(orderId: number | string, note: string): Promise<string>;
|
|
107
108
|
getTempOrderNote(): string;
|
|
108
109
|
updateTempOrderShopDiscount(amount: string | number): string;
|
|
109
110
|
updateTempOrderBuzzer(buzzer: string): string;
|
|
@@ -157,8 +158,14 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
157
158
|
addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput): Promise<OrderProduct[]>;
|
|
158
159
|
private hasGoodPassDiscount;
|
|
159
160
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<OrderProduct[]>;
|
|
161
|
+
updateOrderProductQuantity(params: UpdateOrderProductQuantityParams): Promise<OrderProduct[]>;
|
|
160
162
|
updateOrderBooking(params: UpdateOrderBookingParams): any[];
|
|
161
163
|
removeProductFromOrder(identity: OrderProductIdentity): Promise<OrderProduct[]>;
|
|
164
|
+
/**
|
|
165
|
+
* 仅清空购物车行(products / bookings / discount_list),不重置整单。
|
|
166
|
+
* 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
|
|
167
|
+
*/
|
|
168
|
+
clearOrderCartLines(): Promise<OrderTempOrder>;
|
|
162
169
|
/**
|
|
163
170
|
* 提交当前 Sales tempOrder。
|
|
164
171
|
*
|
|
@@ -235,4 +242,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
235
242
|
getLastOrderInfo(): Record<string, any> | undefined;
|
|
236
243
|
getOrderInfo(order_id: number): Promise<any>;
|
|
237
244
|
}
|
|
238
|
-
export type { UpdateOrderBookingParams, UpdateOrderProductParams } from './types';
|
|
245
|
+
export type { UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|