@pisell/pisellos 2.3.164 → 2.3.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/model/strategy/adapter/promotion/evaluator.js +89 -104
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +28 -4
- package/dist/modules/Holder/utils.d.ts +2 -0
- package/dist/modules/Holder/utils.js +32 -2
- package/dist/modules/OpenData/contactInfo.d.ts +20 -0
- package/dist/modules/OpenData/contactInfo.js +70 -0
- package/dist/modules/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +1 -0
- package/dist/modules/OpenData/types.d.ts +9 -0
- package/dist/modules/Order/holderRelations.d.ts +14 -0
- package/dist/modules/Order/holderRelations.js +154 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +89 -44
- package/dist/modules/Order/types.d.ts +19 -1
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
- package/dist/modules/Order/utils/discountProductLineIdentity.js +142 -7
- package/dist/modules/Order/utils/orderCollectionIdentity.js +24 -10
- package/dist/modules/Order/utils.d.ts +1 -1
- package/dist/modules/Order/utils.js +35 -9
- package/dist/modules/Rules/index.js +62 -61
- package/dist/server/index.js +18 -12
- package/dist/server/modules/order/index.d.ts +4 -0
- package/dist/server/modules/order/index.js +255 -190
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/products/index.js +3 -2
- package/dist/shared/receipt/small-ticket.js +17 -6
- package/dist/shared/sales/loadSalesOrderSnapshot.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +4 -0
- package/dist/solution/BaseSales/index.js +1116 -935
- package/dist/solution/BaseSales/types.d.ts +2 -1
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +7 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -4
- package/dist/solution/BookingTicket/index.d.ts +15 -1
- package/dist/solution/BookingTicket/index.js +784 -501
- package/dist/solution/UnifiedBookingSales/index.js +1 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +9 -14
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +17 -1
- package/lib/modules/Holder/utils.d.ts +2 -0
- package/lib/modules/Holder/utils.js +27 -1
- package/lib/modules/OpenData/contactInfo.d.ts +20 -0
- package/lib/modules/OpenData/contactInfo.js +56 -0
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +12 -0
- package/lib/modules/OpenData/types.d.ts +9 -0
- package/lib/modules/Order/holderRelations.d.ts +14 -0
- package/lib/modules/Order/holderRelations.js +98 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +44 -12
- package/lib/modules/Order/types.d.ts +19 -1
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
- package/lib/modules/Order/utils/discountProductLineIdentity.js +51 -2
- package/lib/modules/Order/utils/orderCollectionIdentity.js +5 -0
- package/lib/modules/Order/utils.d.ts +1 -1
- package/lib/modules/Order/utils.js +27 -6
- package/lib/modules/Rules/index.js +2 -1
- package/lib/server/index.js +6 -0
- package/lib/server/modules/order/index.d.ts +4 -0
- package/lib/server/modules/order/index.js +46 -4
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/server/modules/products/index.js +2 -1
- package/lib/shared/receipt/small-ticket.js +15 -7
- package/lib/shared/sales/loadSalesOrderSnapshot.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +4 -0
- package/lib/solution/BaseSales/index.js +68 -2
- package/lib/solution/BaseSales/types.d.ts +2 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -8
- package/lib/solution/BookingTicket/index.d.ts +15 -1
- package/lib/solution/BookingTicket/index.js +132 -3
- package/lib/solution/UnifiedBookingSales/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
2
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
5
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
6
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
7
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
8
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
9
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
10
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
+
function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
|
|
12
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
13
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
14
|
+
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; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
|
+
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); }
|
|
17
|
+
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); }
|
|
18
|
+
export var CONTACT_INFO_FIELDS = ['first_name', 'last_name', 'phone', 'email'];
|
|
19
|
+
export function resolveContactInfoConfig(data) {
|
|
20
|
+
var enabled = (data === null || data === void 0 ? void 0 : data['sale.enable_contact_info']) === true;
|
|
21
|
+
var fields = CONTACT_INFO_FIELDS.reduce(function (result, field) {
|
|
22
|
+
var visible = (data === null || data === void 0 ? void 0 : data["sale.".concat(field, ".visible")]) !== false;
|
|
23
|
+
result[field] = {
|
|
24
|
+
visible: visible,
|
|
25
|
+
required: enabled && visible && (data === null || data === void 0 ? void 0 : data["sale.".concat(field, ".required")]) === true
|
|
26
|
+
};
|
|
27
|
+
return result;
|
|
28
|
+
}, {});
|
|
29
|
+
return {
|
|
30
|
+
enabled: enabled && CONTACT_INFO_FIELDS.some(function (field) {
|
|
31
|
+
return fields[field].visible;
|
|
32
|
+
}),
|
|
33
|
+
fields: fields
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function getMissingContactInfoFields(config, value) {
|
|
37
|
+
if (!config.enabled) return [];
|
|
38
|
+
var contact = isContactRecord(value) ? value : {};
|
|
39
|
+
return CONTACT_INFO_FIELDS.filter(function (field) {
|
|
40
|
+
if (!config.fields[field].visible || !config.fields[field].required) return false;
|
|
41
|
+
var fieldValue = field === 'phone' ? isContactRecord(contact.phone) ? contact.phone.phone : undefined : contact[field];
|
|
42
|
+
return typeof fieldValue !== 'string' || !fieldValue.trim();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export function isContactRecord(value) {
|
|
46
|
+
return !!value && _typeof(value) === 'object' && !Array.isArray(value);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Customer relations wrap the contact in value; sales orders store the object itself. */
|
|
50
|
+
export function extractCustomerContactInfo(customer) {
|
|
51
|
+
if (!isContactRecord(customer)) return null;
|
|
52
|
+
var contact = customer.contacts_info;
|
|
53
|
+
if (!isContactRecord(contact)) return null;
|
|
54
|
+
var value = Object.prototype.hasOwnProperty.call(contact, 'value') ? contact.value : contact;
|
|
55
|
+
return isContactRecord(value) ? value : null;
|
|
56
|
+
}
|
|
57
|
+
export var ContactInfoRequiredError = /*#__PURE__*/function (_Error) {
|
|
58
|
+
_inherits(ContactInfoRequiredError, _Error);
|
|
59
|
+
var _super = _createSuper(ContactInfoRequiredError);
|
|
60
|
+
function ContactInfoRequiredError(fields) {
|
|
61
|
+
var _this;
|
|
62
|
+
_classCallCheck(this, ContactInfoRequiredError);
|
|
63
|
+
_this = _super.call(this, "Contact information is required: ".concat(fields.join(', ')));
|
|
64
|
+
_defineProperty(_assertThisInitialized(_this), "code", 'CONTACT_INFO_REQUIRED');
|
|
65
|
+
_this.fields = fields;
|
|
66
|
+
_this.name = 'ContactInfoRequiredError';
|
|
67
|
+
return _this;
|
|
68
|
+
}
|
|
69
|
+
return _createClass(ContactInfoRequiredError);
|
|
70
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
@@ -3,6 +3,7 @@ import { BaseModule } from '../BaseModule';
|
|
|
3
3
|
import type { ScheduleModule } from '../Schedule';
|
|
4
4
|
import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult, InvoiceLayoutConfig, InvoiceTemplateSettings } from './types';
|
|
5
5
|
export * from './types';
|
|
6
|
+
export * from './contactInfo';
|
|
6
7
|
export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales, } from './utils';
|
|
7
8
|
export declare class OpenDataModule extends BaseModule implements Module {
|
|
8
9
|
protected defaultName: string;
|
|
@@ -18,6 +18,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
18
18
|
import { BaseModule } from "../BaseModule";
|
|
19
19
|
import { computeAvailability, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "./utils";
|
|
20
20
|
export * from "./types";
|
|
21
|
+
export * from "./contactInfo";
|
|
21
22
|
export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales } from "./utils";
|
|
22
23
|
function isRecord(value) {
|
|
23
24
|
return !!value && _typeof(value) === 'object' && !Array.isArray(value);
|
|
@@ -69,6 +69,15 @@ export interface OpenDataConfig {
|
|
|
69
69
|
'reservation.time_slice'?: number | string;
|
|
70
70
|
'sale.allow_item_notes'?: boolean;
|
|
71
71
|
'sale.allow_order_notes'?: boolean;
|
|
72
|
+
'sale.enable_contact_info'?: boolean;
|
|
73
|
+
'sale.first_name.visible'?: boolean;
|
|
74
|
+
'sale.first_name.required'?: boolean;
|
|
75
|
+
'sale.last_name.visible'?: boolean;
|
|
76
|
+
'sale.last_name.required'?: boolean;
|
|
77
|
+
'sale.phone.visible'?: boolean;
|
|
78
|
+
'sale.phone.required'?: boolean;
|
|
79
|
+
'sale.email.visible'?: boolean;
|
|
80
|
+
'sale.email.required'?: boolean;
|
|
72
81
|
/** False submits an order without starting or confirming payment. */
|
|
73
82
|
'sale.require_payment_on_submit'?: boolean | null;
|
|
74
83
|
'sale.enable_item_rules'?: boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { OrderHolderRelation, OrderTempOrder } from './types';
|
|
2
|
+
/** 在原订单上补齐关系身份,让缓存、提交和重试共用同一个 UUID。 */
|
|
3
|
+
export declare function ensureHolderRelationUuids(order: {
|
|
4
|
+
holder_relations?: OrderHolderRelation[];
|
|
5
|
+
}): void;
|
|
6
|
+
export declare function hasProductBooking(product: Record<string, any>): boolean;
|
|
7
|
+
export declare function getProductHolderRelations(order: {
|
|
8
|
+
holder_relations?: OrderHolderRelation[];
|
|
9
|
+
}, product: Record<string, any>): OrderHolderRelation[];
|
|
10
|
+
export declare function replaceProductHolderRelations(order: OrderTempOrder, product: Record<string, any>, patch: OrderHolderRelation[] | undefined): void;
|
|
11
|
+
/** 只删除明确被用户删除的行,不从稀疏远端快照推断删除。 */
|
|
12
|
+
export declare function removeProductHolderRelations(order: OrderTempOrder, products: Array<Record<string, any>>): void;
|
|
13
|
+
/** 仅兼容尚无新字段的旧测试草稿;显式 [] 永远不恢复旧 product 数据。 */
|
|
14
|
+
export declare function restoreLegacyHolderRelations(order: Record<string, any>): OrderHolderRelation[] | undefined;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
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); }
|
|
6
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
|
+
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."); }
|
|
8
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
+
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); }
|
|
11
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
import { createUuidV4 } from "./utils/orderCollectionIdentity";
|
|
15
|
+
function getHolderRelationUuid(relation) {
|
|
16
|
+
return typeof (relation === null || relation === void 0 ? void 0 : relation.uuid) === 'string' && relation.uuid.trim() ? relation.uuid : undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** 在原订单上补齐关系身份,让缓存、提交和重试共用同一个 UUID。 */
|
|
20
|
+
export function ensureHolderRelationUuids(order) {
|
|
21
|
+
if (!Array.isArray(order.holder_relations)) return;
|
|
22
|
+
var _iterator = _createForOfIteratorHelper(order.holder_relations),
|
|
23
|
+
_step;
|
|
24
|
+
try {
|
|
25
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
26
|
+
var relation = _step.value;
|
|
27
|
+
if (relation && _typeof(relation) === 'object' && !getHolderRelationUuid(relation)) {
|
|
28
|
+
relation.uuid = createUuidV4();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
_iterator.e(err);
|
|
33
|
+
} finally {
|
|
34
|
+
_iterator.f();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function hasProductBooking(product) {
|
|
38
|
+
var _product$metadata, _product$metadata2;
|
|
39
|
+
var bookingIds = [product.booking_id, (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.booking_id, product.schedule_event_id];
|
|
40
|
+
return Boolean(product.booking_uid || ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.booking_uid)) || bookingIds.some(function (id) {
|
|
41
|
+
return id !== undefined && id !== null && String(id) !== '' && String(id) !== '0';
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function getProductHolderRelations(order, product) {
|
|
45
|
+
var _product$metadata$uni, _product$metadata3;
|
|
46
|
+
var uid = (_product$metadata$uni = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number;
|
|
47
|
+
if (uid === undefined || uid === null || uid === '') return [];
|
|
48
|
+
return (order.holder_relations || []).filter(function (relation) {
|
|
49
|
+
return relation.relation_model === 'order_detail' && String(relation.relation_uuid) === String(uid);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export function replaceProductHolderRelations(order, product, patch) {
|
|
53
|
+
var _product$metadata$uni2, _product$metadata4;
|
|
54
|
+
if (patch === undefined || hasProductBooking(product)) return;
|
|
55
|
+
var uid = (_product$metadata$uni2 = (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.unique_identification_number) !== null && _product$metadata$uni2 !== void 0 ? _product$metadata$uni2 : product.unique_identification_number;
|
|
56
|
+
if (uid === undefined || uid === null || uid === '') return;
|
|
57
|
+
var existing = getProductHolderRelations(order, product);
|
|
58
|
+
var next = new Map();
|
|
59
|
+
var _iterator2 = _createForOfIteratorHelper(patch),
|
|
60
|
+
_step2;
|
|
61
|
+
try {
|
|
62
|
+
var _loop = function _loop() {
|
|
63
|
+
var relation = _step2.value;
|
|
64
|
+
var key = "".concat(relation.holder_type, ":").concat(relation.holder_id);
|
|
65
|
+
var previous = existing.find(function (item) {
|
|
66
|
+
return item.holder_type === relation.holder_type && String(item.holder_id) === String(relation.holder_id);
|
|
67
|
+
});
|
|
68
|
+
next.set(key, _objectSpread(_objectSpread(_objectSpread({}, previous), relation), {}, {
|
|
69
|
+
uuid: getHolderRelationUuid(previous) || getHolderRelationUuid(relation) || createUuidV4(),
|
|
70
|
+
relation_model: 'order_detail',
|
|
71
|
+
relation_uuid: String(uid)
|
|
72
|
+
}, previous !== null && previous !== void 0 && previous.metadata || relation.metadata ? {
|
|
73
|
+
metadata: _objectSpread(_objectSpread({}, previous === null || previous === void 0 ? void 0 : previous.metadata), relation.metadata)
|
|
74
|
+
} : {}));
|
|
75
|
+
};
|
|
76
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
77
|
+
_loop();
|
|
78
|
+
}
|
|
79
|
+
} catch (err) {
|
|
80
|
+
_iterator2.e(err);
|
|
81
|
+
} finally {
|
|
82
|
+
_iterator2.f();
|
|
83
|
+
}
|
|
84
|
+
order.holder_relations = [].concat(_toConsumableArray((order.holder_relations || []).filter(function (relation) {
|
|
85
|
+
return relation.relation_model !== 'order_detail' || String(relation.relation_uuid) !== String(uid);
|
|
86
|
+
})), _toConsumableArray(next.values()));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** 只删除明确被用户删除的行,不从稀疏远端快照推断删除。 */
|
|
90
|
+
export function removeProductHolderRelations(order, products) {
|
|
91
|
+
if (!Array.isArray(order.holder_relations)) return;
|
|
92
|
+
var removedUids = new Set(products.map(function (product) {
|
|
93
|
+
var _ref, _product$metadata$uni3, _product$metadata5;
|
|
94
|
+
return String((_ref = (_product$metadata$uni3 = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) !== null && _product$metadata$uni3 !== void 0 ? _product$metadata$uni3 : product.unique_identification_number) !== null && _ref !== void 0 ? _ref : '');
|
|
95
|
+
}));
|
|
96
|
+
order.holder_relations = order.holder_relations.filter(function (relation) {
|
|
97
|
+
return relation.relation_model !== 'order_detail' || !removedUids.has(String(relation.relation_uuid));
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** 仅兼容尚无新字段的旧测试草稿;显式 [] 永远不恢复旧 product 数据。 */
|
|
102
|
+
export function restoreLegacyHolderRelations(order) {
|
|
103
|
+
if (Object.prototype.hasOwnProperty.call(order, 'holder_relations')) {
|
|
104
|
+
return Array.isArray(order.holder_relations) ? order.holder_relations : undefined;
|
|
105
|
+
}
|
|
106
|
+
var relations = [];
|
|
107
|
+
var bookingProductUids = new Set((order.bookings || []).map(function (booking) {
|
|
108
|
+
var _ref2, _booking$product_uid, _booking$metadata;
|
|
109
|
+
return String((_ref2 = (_booking$product_uid = booking.product_uid) !== null && _booking$product_uid !== void 0 ? _booking$product_uid : (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.product_uid) !== null && _ref2 !== void 0 ? _ref2 : '');
|
|
110
|
+
}));
|
|
111
|
+
var _iterator3 = _createForOfIteratorHelper(order.products || []),
|
|
112
|
+
_step3;
|
|
113
|
+
try {
|
|
114
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
115
|
+
var _product$metadata$uni4, _product$metadata6, _product$metadata7, _product$metadata$hol, _product$metadata8;
|
|
116
|
+
var product = _step3.value;
|
|
117
|
+
if (hasProductBooking(product)) continue;
|
|
118
|
+
var uid = (_product$metadata$uni4 = (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.unique_identification_number) !== null && _product$metadata$uni4 !== void 0 ? _product$metadata$uni4 : product.unique_identification_number;
|
|
119
|
+
if (uid === undefined || uid === null || uid === '' || bookingProductUids.has(String(uid))) continue;
|
|
120
|
+
var holder = ((_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.holder) || {};
|
|
121
|
+
var rawIds = (_product$metadata$hol = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.holder_id) !== null && _product$metadata$hol !== void 0 ? _product$metadata$hol : holder.form_record;
|
|
122
|
+
var ids = (Array.isArray(rawIds) ? rawIds : [rawIds]).filter(function (id) {
|
|
123
|
+
return id !== undefined && id !== null && id !== '' && Number.isInteger(Number(id)) && Number(id) >= 0;
|
|
124
|
+
});
|
|
125
|
+
var _iterator4 = _createForOfIteratorHelper(ids),
|
|
126
|
+
_step4;
|
|
127
|
+
try {
|
|
128
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
129
|
+
var id = _step4.value;
|
|
130
|
+
var metadata = _objectSpread(_objectSpread({}, holder), {}, {
|
|
131
|
+
form_record: [Number(id)]
|
|
132
|
+
});
|
|
133
|
+
if (ids.length !== 1) delete metadata.name;
|
|
134
|
+
relations.push({
|
|
135
|
+
relation_model: 'order_detail',
|
|
136
|
+
relation_uuid: String(uid),
|
|
137
|
+
holder_type: 'form',
|
|
138
|
+
holder_id: Number(id),
|
|
139
|
+
metadata: metadata
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
} catch (err) {
|
|
143
|
+
_iterator4.e(err);
|
|
144
|
+
} finally {
|
|
145
|
+
_iterator4.f();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
} catch (err) {
|
|
149
|
+
_iterator3.e(err);
|
|
150
|
+
} finally {
|
|
151
|
+
_iterator3.f();
|
|
152
|
+
}
|
|
153
|
+
return relations.length ? relations : undefined;
|
|
154
|
+
}
|
|
@@ -673,6 +673,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
673
673
|
getOrderInfo(order_id: number): Promise<any>;
|
|
674
674
|
getVouchers(): any[];
|
|
675
675
|
}
|
|
676
|
-
export type { AddProductToOrderOptions, OrderMetaList, PointCardSnapshotItem, VirtualCurrencySnapshotItem, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|
|
676
|
+
export type { OrderHolderRelation, AddProductToOrderOptions, OrderMetaList, PointCardSnapshotItem, VirtualCurrencySnapshotItem, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|
|
677
677
|
export { isFulfillmentTimingBooking } from './pickupTiming';
|
|
678
678
|
export type { PickupTimingBooking, PickupTimingBookingInput, PickupTimingBookingMetadata, PickupTimingSelectionMode, PickupTimingSource, } from './pickupTiming';
|