@pisell/pisellos 2.2.222 → 2.2.224
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/index.js +0 -9
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +3 -0
- package/dist/modules/Customer/index.d.ts +7 -0
- package/dist/modules/Customer/index.js +16 -0
- package/dist/modules/OpenData/index.d.ts +7 -0
- package/dist/modules/OpenData/index.js +16 -1
- package/dist/modules/Order/index.d.ts +43 -0
- package/dist/modules/Order/index.js +296 -112
- package/dist/modules/Order/types.d.ts +16 -0
- package/dist/modules/Order/utils.js +7 -4
- package/dist/modules/Payment/index.d.ts +7 -0
- package/dist/modules/Payment/index.js +12 -0
- package/dist/modules/ProductList/index.d.ts +7 -0
- package/dist/modules/ProductList/index.js +11 -0
- package/dist/modules/SalesSummary/index.d.ts +7 -0
- package/dist/modules/SalesSummary/index.js +61 -26
- package/dist/modules/Schedule/index.d.ts +7 -0
- package/dist/modules/Schedule/index.js +16 -0
- package/dist/modules/Summary/index.js +2 -1
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/server/modules/order/utils/filterBookings.js +25 -2
- package/dist/server/utils/small-ticket.js +160 -30
- package/dist/solution/BaseSales/index.d.ts +17 -0
- package/dist/solution/BaseSales/index.js +524 -439
- package/dist/solution/BaseSales/utils/cartPromotion.js +24 -7
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +0 -8
- package/dist/solution/BookingTicket/index.js +41 -75
- package/dist/types/index.d.ts +10 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +3 -0
- package/lib/modules/Customer/index.d.ts +7 -0
- package/lib/modules/Customer/index.js +12 -0
- package/lib/modules/OpenData/index.d.ts +7 -0
- package/lib/modules/OpenData/index.js +13 -1
- package/lib/modules/Order/index.d.ts +43 -0
- package/lib/modules/Order/index.js +145 -3
- package/lib/modules/Order/types.d.ts +16 -0
- package/lib/modules/Order/utils.js +6 -2
- package/lib/modules/Payment/index.d.ts +7 -0
- package/lib/modules/Payment/index.js +9 -0
- package/lib/modules/ProductList/index.d.ts +7 -0
- package/lib/modules/ProductList/index.js +9 -0
- package/lib/modules/SalesSummary/index.d.ts +7 -0
- package/lib/modules/SalesSummary/index.js +15 -1
- package/lib/modules/Schedule/index.d.ts +7 -0
- package/lib/modules/Schedule/index.js +12 -0
- package/lib/modules/Summary/index.js +2 -1
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/server/modules/order/utils/filterBookings.js +17 -2
- package/lib/server/utils/small-ticket.js +141 -32
- package/lib/solution/BaseSales/index.d.ts +17 -0
- package/lib/solution/BaseSales/index.js +48 -10
- package/lib/solution/BaseSales/utils/cartPromotion.js +28 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +0 -8
- package/lib/solution/BookingTicket/index.js +0 -12
- package/lib/types/index.d.ts +10 -0
- package/package.json +1 -1
|
@@ -79,6 +79,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
79
79
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
80
80
|
_defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
|
|
81
81
|
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
82
|
+
_defineProperty(_assertThisInitialized(_this), "moduleHooksOverride", void 0);
|
|
82
83
|
_defineProperty(_assertThisInitialized(_this), "orderHooks", void 0);
|
|
83
84
|
_defineProperty(_assertThisInitialized(_this), "otherParams", void 0);
|
|
84
85
|
// ─── 促销/赠品 ────────────────────────────────────
|
|
@@ -258,11 +259,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
258
259
|
this.cacheId = otherParams.cacheId;
|
|
259
260
|
this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
|
|
260
261
|
this.rulesHooksOverride = (_otherParams$rules = otherParams.rules) === null || _otherParams$rules === void 0 ? void 0 : _otherParams$rules.hooks;
|
|
261
|
-
this.
|
|
262
|
+
this.moduleHooksOverride = options.hooks;
|
|
263
|
+
this.orderHooks = this.moduleHooksOverride || ((_otherParams$order = otherParams.order) === null || _otherParams$order === void 0 ? void 0 : _otherParams$order.hooks) || ((_otherParams$hooks = otherParams.hooks) === null || _otherParams$hooks === void 0 ? void 0 : _otherParams$hooks.order);
|
|
262
264
|
this.otherParams = otherParams;
|
|
263
265
|
this.registerDiscountModules(options);
|
|
264
266
|
this.logInfo('OrderModule initialized successfully');
|
|
265
|
-
case
|
|
267
|
+
case 20:
|
|
266
268
|
case "end":
|
|
267
269
|
return _context.stop();
|
|
268
270
|
}
|
|
@@ -273,6 +275,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
273
275
|
}
|
|
274
276
|
return initialize;
|
|
275
277
|
}()
|
|
278
|
+
/**
|
|
279
|
+
* 更新父级解决方案透传的运行态参数,并同步 Order 内部依赖的派生字段。
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* orderModule.updateOtherParams({ cacheId: 'cache-2', channel: 'pos' });
|
|
283
|
+
*/
|
|
284
|
+
}, {
|
|
285
|
+
key: "updateOtherParams",
|
|
286
|
+
value: function updateOtherParams(params) {
|
|
287
|
+
var _otherParams$rules2, _otherParams$order2, _otherParams$hooks2;
|
|
288
|
+
var otherParams = params || {};
|
|
289
|
+
this.cacheId = otherParams.cacheId;
|
|
290
|
+
this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
|
|
291
|
+
this.rulesHooksOverride = (_otherParams$rules2 = otherParams.rules) === null || _otherParams$rules2 === void 0 ? void 0 : _otherParams$rules2.hooks;
|
|
292
|
+
this.orderHooks = this.moduleHooksOverride || ((_otherParams$order2 = otherParams.order) === null || _otherParams$order2 === void 0 ? void 0 : _otherParams$order2.hooks) || ((_otherParams$hooks2 = otherParams.hooks) === null || _otherParams$hooks2 === void 0 ? void 0 : _otherParams$hooks2.order);
|
|
293
|
+
this.otherParams = otherParams;
|
|
294
|
+
}
|
|
295
|
+
|
|
276
296
|
/**
|
|
277
297
|
* 记录信息日志
|
|
278
298
|
*/
|
|
@@ -2052,6 +2072,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2052
2072
|
var bookingUid = String(bookingMetadata.unique_identification_number || createUuidV4());
|
|
2053
2073
|
productMetadata.unique_identification_number = productUid;
|
|
2054
2074
|
bookingMetadata.unique_identification_number = bookingUid;
|
|
2075
|
+
this.syncBookingMetadataHolder(params.booking, bookingMetadata);
|
|
2055
2076
|
return {
|
|
2056
2077
|
productUid: productUid,
|
|
2057
2078
|
bookingUid: bookingUid,
|
|
@@ -2070,11 +2091,155 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2070
2091
|
})
|
|
2071
2092
|
};
|
|
2072
2093
|
}
|
|
2094
|
+
|
|
2095
|
+
/**
|
|
2096
|
+
* booking.holder 是提交真源;metadata.holder 作为详情/回显冗余字段同步保存。
|
|
2097
|
+
*
|
|
2098
|
+
* @example
|
|
2099
|
+
* this.syncBookingMetadataHolder(booking, metadata);
|
|
2100
|
+
*/
|
|
2101
|
+
}, {
|
|
2102
|
+
key: "syncBookingMetadataHolder",
|
|
2103
|
+
value: function syncBookingMetadataHolder(booking, metadata) {
|
|
2104
|
+
if ((booking === null || booking === void 0 ? void 0 : booking.holder) !== undefined) {
|
|
2105
|
+
metadata.holder = booking.holder;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
/**
|
|
2110
|
+
* 从单条 booking 的 holder / metadata 中收集 holder form_record。
|
|
2111
|
+
*
|
|
2112
|
+
* @example
|
|
2113
|
+
* const ids = this.collectBookingHolderRecords(booking);
|
|
2114
|
+
*/
|
|
2115
|
+
}, {
|
|
2116
|
+
key: "collectBookingHolderRecords",
|
|
2117
|
+
value: function collectBookingHolderRecords(booking) {
|
|
2118
|
+
var _holder$form_record, _booking$metadata;
|
|
2119
|
+
var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
2120
|
+
var source = (_holder$form_record = holder === null || holder === void 0 ? void 0 : holder.form_record) !== null && _holder$form_record !== void 0 ? _holder$form_record : booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.holder_id;
|
|
2121
|
+
var records = Array.isArray(source) ? source : [source];
|
|
2122
|
+
return records.filter(function (record) {
|
|
2123
|
+
return record !== undefined && record !== null && record !== '';
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
/**
|
|
2128
|
+
* 按 form_record 顺序读取 booking holder 的主字段名称。
|
|
2129
|
+
*
|
|
2130
|
+
* @example
|
|
2131
|
+
* const names = this.collectBookingHolderNames(booking);
|
|
2132
|
+
*/
|
|
2133
|
+
}, {
|
|
2134
|
+
key: "collectBookingHolderNames",
|
|
2135
|
+
value: function collectBookingHolderNames(booking) {
|
|
2136
|
+
var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
2137
|
+
var rawName = holder === null || holder === void 0 ? void 0 : holder.name;
|
|
2138
|
+
if (Array.isArray(rawName)) {
|
|
2139
|
+
return rawName.map(function (name) {
|
|
2140
|
+
return String(name || '').trim();
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
if (typeof rawName === 'string') {
|
|
2144
|
+
return rawName.split(',').map(function (name) {
|
|
2145
|
+
return name.trim();
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
return [];
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
/**
|
|
2152
|
+
* 按老 ticketBooking `formatHolder` 语义汇总订单顶层 holder。
|
|
2153
|
+
*
|
|
2154
|
+
* @example
|
|
2155
|
+
* const holder = this.buildTempOrderHolderFromBookings(tempOrder);
|
|
2156
|
+
*/
|
|
2157
|
+
}, {
|
|
2158
|
+
key: "buildTempOrderHolderFromBookings",
|
|
2159
|
+
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
2160
|
+
var _baseHolder$customer_, _baseHolder, _ref44, _baseHolder$form_id, _baseHolder2, _tempOrder$holder5, _baseHolder3, _this$otherParams;
|
|
2161
|
+
var holderRecords = [];
|
|
2162
|
+
var holderNames = [];
|
|
2163
|
+
var baseHolder = null;
|
|
2164
|
+
var seen = new Set();
|
|
2165
|
+
var _iterator18 = _createForOfIteratorHelper(tempOrder.bookings || []),
|
|
2166
|
+
_step18;
|
|
2167
|
+
try {
|
|
2168
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
2169
|
+
var booking = _step18.value;
|
|
2170
|
+
var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
2171
|
+
if (!baseHolder && holder) {
|
|
2172
|
+
baseHolder = holder;
|
|
2173
|
+
}
|
|
2174
|
+
var records = this.collectBookingHolderRecords(booking);
|
|
2175
|
+
var names = this.collectBookingHolderNames(booking);
|
|
2176
|
+
var _iterator19 = _createForOfIteratorHelper(records.entries()),
|
|
2177
|
+
_step19;
|
|
2178
|
+
try {
|
|
2179
|
+
for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
|
|
2180
|
+
var _step19$value = _slicedToArray(_step19.value, 2),
|
|
2181
|
+
index = _step19$value[0],
|
|
2182
|
+
record = _step19$value[1];
|
|
2183
|
+
var key = String(record);
|
|
2184
|
+
if (seen.has(key)) continue;
|
|
2185
|
+
seen.add(key);
|
|
2186
|
+
holderRecords.push(record);
|
|
2187
|
+
if (names[index]) {
|
|
2188
|
+
holderNames.push(names[index]);
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
} catch (err) {
|
|
2192
|
+
_iterator19.e(err);
|
|
2193
|
+
} finally {
|
|
2194
|
+
_iterator19.f();
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
} catch (err) {
|
|
2198
|
+
_iterator18.e(err);
|
|
2199
|
+
} finally {
|
|
2200
|
+
_iterator18.f();
|
|
2201
|
+
}
|
|
2202
|
+
if (!holderRecords.length) {
|
|
2203
|
+
return null;
|
|
2204
|
+
}
|
|
2205
|
+
var nextHolder = {
|
|
2206
|
+
customer_id: (_baseHolder$customer_ = (_baseHolder = baseHolder) === null || _baseHolder === void 0 ? void 0 : _baseHolder.customer_id) !== null && _baseHolder$customer_ !== void 0 ? _baseHolder$customer_ : tempOrder.customer_id,
|
|
2207
|
+
form_id: (_ref44 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder5 = tempOrder.holder) === null || _tempOrder$holder5 === void 0 ? void 0 : _tempOrder$holder5.form_id) !== null && _ref44 !== void 0 ? _ref44 : 0,
|
|
2208
|
+
form_record: holderRecords
|
|
2209
|
+
};
|
|
2210
|
+
if (holderNames.length) {
|
|
2211
|
+
nextHolder.name = holderNames.join(',');
|
|
2212
|
+
}
|
|
2213
|
+
if ((_baseHolder3 = baseHolder) !== null && _baseHolder3 !== void 0 && _baseHolder3.is_source_shop || (_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.isFranchisee) {
|
|
2214
|
+
nextHolder.is_source_shop = 1;
|
|
2215
|
+
}
|
|
2216
|
+
return nextHolder;
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
/**
|
|
2220
|
+
* 将 booking 级 holder 汇总到 tempOrder 顶层 holder。
|
|
2221
|
+
*
|
|
2222
|
+
* @example
|
|
2223
|
+
* this.syncTempOrderHolderFromBookings(tempOrder);
|
|
2224
|
+
*/
|
|
2225
|
+
}, {
|
|
2226
|
+
key: "syncTempOrderHolderFromBookings",
|
|
2227
|
+
value: function syncTempOrderHolderFromBookings(tempOrder) {
|
|
2228
|
+
var bookings = tempOrder.bookings || [];
|
|
2229
|
+
var hasHolderSource = bookings.some(function (booking) {
|
|
2230
|
+
var _booking$metadata2;
|
|
2231
|
+
return (booking === null || booking === void 0 ? void 0 : booking.holder) !== undefined || (booking === null || booking === void 0 || (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.holder_id) !== undefined;
|
|
2232
|
+
});
|
|
2233
|
+
var nextHolder = this.buildTempOrderHolderFromBookings(tempOrder);
|
|
2234
|
+
if (nextHolder || hasHolderSource || bookings.length === 0) {
|
|
2235
|
+
tempOrder.holder = nextHolder;
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2073
2238
|
}, {
|
|
2074
2239
|
key: "getBookingUniqueIdentificationNumber",
|
|
2075
2240
|
value: function getBookingUniqueIdentificationNumber(booking) {
|
|
2076
|
-
var _booking$
|
|
2077
|
-
var uid = booking === null || booking === void 0 || (_booking$
|
|
2241
|
+
var _booking$metadata3;
|
|
2242
|
+
var uid = booking === null || booking === void 0 || (_booking$metadata3 = booking.metadata) === null || _booking$metadata3 === void 0 ? void 0 : _booking$metadata3.unique_identification_number;
|
|
2078
2243
|
if (uid === undefined || uid === null || uid === '') return null;
|
|
2079
2244
|
return String(uid);
|
|
2080
2245
|
}
|
|
@@ -2114,7 +2279,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2114
2279
|
key: "recalculateSummary",
|
|
2115
2280
|
value: function () {
|
|
2116
2281
|
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(options) {
|
|
2117
|
-
var
|
|
2282
|
+
var _ref45, _salesSummaryResult$e;
|
|
2118
2283
|
var tempOrder, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
2119
2284
|
return _regeneratorRuntime().wrap(function _callee10$(_context12) {
|
|
2120
2285
|
while (1) switch (_context12.prev = _context12.next) {
|
|
@@ -2184,7 +2349,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2184
2349
|
roundingAmount = paidPaymentSummary.roundingAmount;
|
|
2185
2350
|
payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
|
|
2186
2351
|
hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
|
|
2187
|
-
expectAmount = hasSalesSummaryAmount ? new Decimal((
|
|
2352
|
+
expectAmount = hasSalesSummaryAmount ? new Decimal((_ref45 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref45 !== void 0 ? _ref45 : 0) : null;
|
|
2188
2353
|
amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
|
|
2189
2354
|
rounding_amount: roundingAmount.toFixed(2)
|
|
2190
2355
|
}, expectAmount ? {
|
|
@@ -2340,17 +2505,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2340
2505
|
}, {
|
|
2341
2506
|
key: "buildTempOrderCustomer",
|
|
2342
2507
|
value: function buildTempOrderCustomer(params) {
|
|
2343
|
-
var
|
|
2508
|
+
var _ref46, _ref47, _ref48, _source$name, _ref49, _ref50, _ref51, _source$customer_name, _source$id, _source$customer_id, _ref52, _source$country_calli, _source$phone, _source$email;
|
|
2344
2509
|
if (!params.customerId) return null;
|
|
2345
2510
|
var source = params.source ? cloneDeep(params.source) : {};
|
|
2346
|
-
var name = (
|
|
2347
|
-
var customerName = (
|
|
2511
|
+
var name = (_ref46 = (_ref47 = (_ref48 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref48 !== void 0 ? _ref48 : source.customerName) !== null && _ref47 !== void 0 ? _ref47 : source.customer_name) !== null && _ref46 !== void 0 ? _ref46 : params.customerName;
|
|
2512
|
+
var customerName = (_ref49 = (_ref50 = (_ref51 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref51 !== void 0 ? _ref51 : source.display_name) !== null && _ref50 !== void 0 ? _ref50 : source.name) !== null && _ref49 !== void 0 ? _ref49 : params.customerName;
|
|
2348
2513
|
return _objectSpread(_objectSpread({}, source), {}, {
|
|
2349
2514
|
id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
|
|
2350
2515
|
customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
|
|
2351
2516
|
name: String(name || ''),
|
|
2352
2517
|
customer_name: String(customerName || ''),
|
|
2353
|
-
country_calling_code: String((
|
|
2518
|
+
country_calling_code: String((_ref52 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref52 !== void 0 ? _ref52 : params.countryCallingCode),
|
|
2354
2519
|
phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
|
|
2355
2520
|
email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
|
|
2356
2521
|
});
|
|
@@ -2415,14 +2580,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2415
2580
|
}, {
|
|
2416
2581
|
key: "updateTempOrderCustomer",
|
|
2417
2582
|
value: function updateTempOrderCustomer(customer) {
|
|
2418
|
-
var _tempOrder$customer_i2,
|
|
2583
|
+
var _tempOrder$customer_i2, _ref53, _ref54, _customer$customer_id, _ref55, _ref56, _ref57, _customer$customer_na, _ref58, _customer$country_cal, _tempOrder$customer_i3;
|
|
2419
2584
|
var tempOrder = this.ensureTempOrder();
|
|
2420
2585
|
var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
|
|
2421
|
-
var customerId = (
|
|
2422
|
-
var customerName = (
|
|
2586
|
+
var customerId = (_ref53 = (_ref54 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref54 !== void 0 ? _ref54 : customer.id) !== null && _ref53 !== void 0 ? _ref53 : null;
|
|
2587
|
+
var customerName = (_ref55 = (_ref56 = (_ref57 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref57 !== void 0 ? _ref57 : customer.display_name) !== null && _ref56 !== void 0 ? _ref56 : customer.name) !== null && _ref55 !== void 0 ? _ref55 : '';
|
|
2423
2588
|
tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
|
|
2424
2589
|
tempOrder.customer_name = String(customerName || '');
|
|
2425
|
-
tempOrder.country_calling_code = String((
|
|
2590
|
+
tempOrder.country_calling_code = String((_ref58 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref58 !== void 0 ? _ref58 : '');
|
|
2426
2591
|
tempOrder.phone = String(customer.phone || '');
|
|
2427
2592
|
tempOrder.email = String(customer.email || '');
|
|
2428
2593
|
tempOrder.customer = this.buildTempOrderCustomer({
|
|
@@ -2760,21 +2925,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2760
2925
|
return _regeneratorRuntime().wrap(function _callee14$(_context16) {
|
|
2761
2926
|
while (1) switch (_context16.prev = _context16.next) {
|
|
2762
2927
|
case 0:
|
|
2763
|
-
|
|
2928
|
+
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
2929
|
+
_context16.next = 3;
|
|
2764
2930
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
2765
|
-
case
|
|
2766
|
-
_context16.next =
|
|
2931
|
+
case 3:
|
|
2932
|
+
_context16.next = 5;
|
|
2767
2933
|
return this.applyPromotion();
|
|
2768
|
-
case
|
|
2934
|
+
case 5:
|
|
2769
2935
|
this.applyDiscount();
|
|
2770
2936
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
2771
|
-
_context16.next =
|
|
2937
|
+
_context16.next = 9;
|
|
2772
2938
|
return this.recalculateSummary({
|
|
2773
2939
|
createIfMissing: true
|
|
2774
2940
|
});
|
|
2775
|
-
case 8:
|
|
2776
|
-
this.persistTempOrder();
|
|
2777
2941
|
case 9:
|
|
2942
|
+
this.persistTempOrder();
|
|
2943
|
+
case 10:
|
|
2778
2944
|
case "end":
|
|
2779
2945
|
return _context16.stop();
|
|
2780
2946
|
}
|
|
@@ -2797,7 +2963,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2797
2963
|
value: (function () {
|
|
2798
2964
|
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, product, booking) {
|
|
2799
2965
|
var _this16 = this;
|
|
2800
|
-
var linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
2966
|
+
var linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, hasIncomingProductNote, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
2801
2967
|
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
2802
2968
|
while (1) switch (_context17.prev = _context17.next) {
|
|
2803
2969
|
case 0:
|
|
@@ -2810,7 +2976,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2810
2976
|
normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
|
|
2811
2977
|
normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
|
|
2812
2978
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
2813
|
-
|
|
2979
|
+
hasIncomingProductNote = typeof normalizedIncoming.note === 'string' && normalizedIncoming.note.trim().length > 0;
|
|
2980
|
+
shouldForceNewLine = !!booking || hasIncomingProductNote;
|
|
2814
2981
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
2815
2982
|
if (_this16.hasGoodPassDiscount(item)) return false;
|
|
2816
2983
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
@@ -2822,10 +2989,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2822
2989
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
2823
2990
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
2824
2991
|
if (!matchedProduct) {
|
|
2825
|
-
_context17.next =
|
|
2992
|
+
_context17.next = 17;
|
|
2826
2993
|
break;
|
|
2827
2994
|
}
|
|
2828
|
-
_context17.next =
|
|
2995
|
+
_context17.next = 14;
|
|
2829
2996
|
return this.shouldMergeProductToOrder({
|
|
2830
2997
|
incomingProduct: productToAdd,
|
|
2831
2998
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -2836,13 +3003,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2836
3003
|
tempOrder: tempOrder,
|
|
2837
3004
|
booking: booking
|
|
2838
3005
|
});
|
|
2839
|
-
case
|
|
3006
|
+
case 14:
|
|
2840
3007
|
_context17.t0 = _context17.sent;
|
|
2841
|
-
_context17.next =
|
|
3008
|
+
_context17.next = 18;
|
|
2842
3009
|
break;
|
|
2843
|
-
case 16:
|
|
2844
|
-
_context17.t0 = false;
|
|
2845
3010
|
case 17:
|
|
3011
|
+
_context17.t0 = false;
|
|
3012
|
+
case 18:
|
|
2846
3013
|
shouldMerge = _context17.t0;
|
|
2847
3014
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
2848
3015
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
@@ -2894,7 +3061,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2894
3061
|
if (linked) {
|
|
2895
3062
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
2896
3063
|
}
|
|
2897
|
-
case
|
|
3064
|
+
case 21:
|
|
2898
3065
|
case "end":
|
|
2899
3066
|
return _context17.stop();
|
|
2900
3067
|
}
|
|
@@ -2917,7 +3084,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2917
3084
|
key: "addProductToOrder",
|
|
2918
3085
|
value: (function () {
|
|
2919
3086
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(product, booking) {
|
|
2920
|
-
var tempOrder,
|
|
3087
|
+
var tempOrder, _ref59, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
2921
3088
|
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
2922
3089
|
while (1) switch (_context18.prev = _context18.next) {
|
|
2923
3090
|
case 0:
|
|
@@ -2927,7 +3094,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2927
3094
|
break;
|
|
2928
3095
|
}
|
|
2929
3096
|
productRecord = product;
|
|
2930
|
-
splitCount = getSafeProductNum((
|
|
3097
|
+
splitCount = getSafeProductNum((_ref59 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref59 !== void 0 ? _ref59 : 1);
|
|
2931
3098
|
if (!(splitCount > 1)) {
|
|
2932
3099
|
_context18.next = 18;
|
|
2933
3100
|
break;
|
|
@@ -2993,9 +3160,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2993
3160
|
}, {
|
|
2994
3161
|
key: "getBundleRuntimeIdentity",
|
|
2995
3162
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
2996
|
-
var
|
|
3163
|
+
var _ref60, _bundle$bundle_id2, _ref61, _bundle$bundle_group_2, _ref62, _ref63, _bundle$bundle_produc3, _ref64, _bundle$bundle_varian3;
|
|
2997
3164
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
2998
|
-
return [(
|
|
3165
|
+
return [(_ref60 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref60 !== void 0 ? _ref60 : '', (_ref61 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref61 !== void 0 ? _ref61 : '', (_ref62 = (_ref63 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref63 !== void 0 ? _ref63 : bundle.product_id) !== null && _ref62 !== void 0 ? _ref62 : '', (_ref64 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref64 !== void 0 ? _ref64 : 0].join('|');
|
|
2999
3166
|
}
|
|
3000
3167
|
}, {
|
|
3001
3168
|
key: "preservePersistedBundlePriceFields",
|
|
@@ -3027,7 +3194,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3027
3194
|
value: function () {
|
|
3028
3195
|
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
3029
3196
|
var _targetProduct$metada2, _product_sku, _metadata, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _nextProduct$metadata, _targetProduct$metada8, _tempOrder$products$p;
|
|
3030
|
-
var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_sku, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, isPersistedOrderLine, callerChangesDiscountList, callerUpdatesManualPrice, _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$metada9, productUid, linked;
|
|
3197
|
+
var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_sku, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, isPersistedOrderLine, callerChangesDiscountList, callerUpdatesManualPrice, callerAllowsBookingReprice, _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$metada9, productUid, linked;
|
|
3031
3198
|
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3032
3199
|
while (1) switch (_context19.prev = _context19.next) {
|
|
3033
3200
|
case 0:
|
|
@@ -3090,7 +3257,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3090
3257
|
isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
3091
3258
|
callerChangesDiscountList = Array.isArray(updates === null || updates === void 0 ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
|
|
3092
3259
|
callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata4 = updates.metadata) === null || _metadata4 === void 0 ? void 0 : _metadata4.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata5 = updates.metadata) === null || _metadata5 === void 0 ? void 0 : _metadata5.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata6 = updates.metadata) === null || _metadata6 === void 0 ? void 0 : _metadata6.product_discount_reason) !== undefined || callerChangesDiscountList;
|
|
3093
|
-
|
|
3260
|
+
callerAllowsBookingReprice = function () {
|
|
3261
|
+
if (params.allow_booking_reprice !== true || !booking || !callerUpdatesTopPrice || !callerUpdatesMainMeta) {
|
|
3262
|
+
return false;
|
|
3263
|
+
}
|
|
3264
|
+
var hasChangedPrice = function hasChangedPrice(nextValue, currentValue) {
|
|
3265
|
+
if (nextValue === undefined || nextValue === null || nextValue === '') {
|
|
3266
|
+
return false;
|
|
3267
|
+
}
|
|
3268
|
+
return !new Decimal(Number(nextValue) || 0).equals(new Decimal(Number(currentValue) || 0));
|
|
3269
|
+
};
|
|
3270
|
+
return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
|
|
3271
|
+
}();
|
|
3272
|
+
if (isPersistedOrderLine && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
3094
3273
|
nextProduct.selling_price = targetProduct.selling_price;
|
|
3095
3274
|
nextProduct.original_price = targetProduct.original_price;
|
|
3096
3275
|
nextProduct.payment_price = targetProduct.payment_price;
|
|
@@ -3142,20 +3321,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3142
3321
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
3143
3322
|
}
|
|
3144
3323
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
3324
|
+
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3145
3325
|
this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
|
|
3146
|
-
_context19.next =
|
|
3326
|
+
_context19.next = 32;
|
|
3147
3327
|
return this.applyPromotion();
|
|
3148
|
-
case
|
|
3328
|
+
case 32:
|
|
3149
3329
|
this.applyDiscount();
|
|
3150
3330
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3151
|
-
_context19.next =
|
|
3331
|
+
_context19.next = 36;
|
|
3152
3332
|
return this.recalculateSummary({
|
|
3153
3333
|
createIfMissing: true
|
|
3154
3334
|
});
|
|
3155
|
-
case
|
|
3335
|
+
case 36:
|
|
3156
3336
|
this.persistTempOrder();
|
|
3157
3337
|
return _context19.abrupt("return", tempOrder.products);
|
|
3158
|
-
case
|
|
3338
|
+
case 38:
|
|
3159
3339
|
case "end":
|
|
3160
3340
|
return _context19.stop();
|
|
3161
3341
|
}
|
|
@@ -3256,9 +3436,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3256
3436
|
unique_identification_number: bookingUid
|
|
3257
3437
|
})
|
|
3258
3438
|
});
|
|
3439
|
+
this.syncBookingMetadataHolder(nextBooking, nextBooking.metadata);
|
|
3259
3440
|
nextBooking.is_all = normalizeBookingIsAll(nextBooking);
|
|
3260
3441
|
nextBooking.sub_type = normalizeBookingSubType(nextBooking);
|
|
3261
3442
|
tempOrder.bookings[bookingIndex] = nextBooking;
|
|
3443
|
+
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3262
3444
|
this.persistTempOrder();
|
|
3263
3445
|
return tempOrder.bookings;
|
|
3264
3446
|
}
|
|
@@ -3277,18 +3459,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3277
3459
|
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3278
3460
|
while (1) switch (_context21.prev = _context21.next) {
|
|
3279
3461
|
case 0:
|
|
3280
|
-
|
|
3462
|
+
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3463
|
+
_context21.next = 3;
|
|
3281
3464
|
return this.applyPromotion();
|
|
3282
|
-
case
|
|
3465
|
+
case 3:
|
|
3283
3466
|
this.applyDiscount();
|
|
3284
3467
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3285
|
-
_context21.next =
|
|
3468
|
+
_context21.next = 7;
|
|
3286
3469
|
return this.recalculateSummary({
|
|
3287
3470
|
createIfMissing: true
|
|
3288
3471
|
});
|
|
3289
|
-
case 6:
|
|
3290
|
-
this.persistTempOrder();
|
|
3291
3472
|
case 7:
|
|
3473
|
+
this.persistTempOrder();
|
|
3474
|
+
case 8:
|
|
3292
3475
|
case "end":
|
|
3293
3476
|
return _context21.stop();
|
|
3294
3477
|
}
|
|
@@ -3382,24 +3565,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3382
3565
|
tempOrder = this.ensureTempOrder();
|
|
3383
3566
|
tempOrder.products = [];
|
|
3384
3567
|
tempOrder.bookings = [];
|
|
3568
|
+
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3385
3569
|
if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
|
|
3386
3570
|
tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
|
|
3387
3571
|
productsByUid: {}
|
|
3388
3572
|
});
|
|
3389
3573
|
}
|
|
3390
|
-
_context24.next =
|
|
3574
|
+
_context24.next = 7;
|
|
3391
3575
|
return this.applyPromotion();
|
|
3392
|
-
case
|
|
3576
|
+
case 7:
|
|
3393
3577
|
this.applyDiscount();
|
|
3394
3578
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3395
|
-
_context24.next =
|
|
3579
|
+
_context24.next = 11;
|
|
3396
3580
|
return this.recalculateSummary({
|
|
3397
3581
|
createIfMissing: true
|
|
3398
3582
|
});
|
|
3399
|
-
case
|
|
3583
|
+
case 11:
|
|
3400
3584
|
this.persistTempOrder();
|
|
3401
3585
|
return _context24.abrupt("return", tempOrder);
|
|
3402
|
-
case
|
|
3586
|
+
case 13:
|
|
3403
3587
|
case "end":
|
|
3404
3588
|
return _context24.stop();
|
|
3405
3589
|
}
|
|
@@ -3414,23 +3598,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3414
3598
|
}, {
|
|
3415
3599
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
3416
3600
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
3417
|
-
var _params$cacheId, _this$
|
|
3601
|
+
var _params$cacheId, _this$otherParams2, _ref65, _params$businessCode, _this$otherParams3, _this$otherParams4;
|
|
3418
3602
|
var tempOrder = this.ensureTempOrder();
|
|
3419
3603
|
this.persistTempOrder();
|
|
3420
3604
|
var payload = buildSubmitPayload({
|
|
3421
3605
|
tempOrder: tempOrder,
|
|
3422
3606
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
3423
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
3424
|
-
businessCode: (
|
|
3607
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform),
|
|
3608
|
+
businessCode: (_ref65 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.businessCode) !== null && _ref65 !== void 0 ? _ref65 : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.business_code,
|
|
3425
3609
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
3426
3610
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
3427
3611
|
summary: this.store.summary || createEmptySummary(),
|
|
3428
3612
|
enhance: function enhance(nextPayload) {
|
|
3429
|
-
var
|
|
3613
|
+
var _ref66, _tempOrder$order_numb, _ref67, _tempOrder$shop_order, _ref68, _tempOrder$shop_full_;
|
|
3430
3614
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
3431
|
-
order_number: (
|
|
3432
|
-
shop_order_number: (
|
|
3433
|
-
shop_full_order_number: (
|
|
3615
|
+
order_number: (_ref66 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref66 !== void 0 ? _ref66 : null,
|
|
3616
|
+
shop_order_number: (_ref67 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref67 !== void 0 ? _ref67 : null,
|
|
3617
|
+
shop_full_order_number: (_ref68 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref68 !== void 0 ? _ref68 : null,
|
|
3434
3618
|
small_ticket_data_flag: 1
|
|
3435
3619
|
});
|
|
3436
3620
|
}
|
|
@@ -3487,7 +3671,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3487
3671
|
key: "submitTempOrder",
|
|
3488
3672
|
value: (function () {
|
|
3489
3673
|
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
3490
|
-
var _params$cacheId2, _this$
|
|
3674
|
+
var _params$cacheId2, _this$otherParams5, _ref69, _params$businessCode2, _this$otherParams6, _this$otherParams7;
|
|
3491
3675
|
var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
3492
3676
|
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
3493
3677
|
while (1) switch (_context26.prev = _context26.next) {
|
|
@@ -3532,8 +3716,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3532
3716
|
payload = buildSubmitPayload({
|
|
3533
3717
|
tempOrder: tempOrder,
|
|
3534
3718
|
cacheId: effectiveCacheId,
|
|
3535
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
3536
|
-
businessCode: (
|
|
3719
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
3720
|
+
businessCode: (_ref69 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref69 !== void 0 ? _ref69 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
|
|
3537
3721
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
3538
3722
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
3539
3723
|
summary: latestSummary,
|
|
@@ -4346,19 +4530,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4346
4530
|
};
|
|
4347
4531
|
var tempOrderExtend = nextTempOrder._extend;
|
|
4348
4532
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
4349
|
-
var
|
|
4350
|
-
|
|
4533
|
+
var _iterator20 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
4534
|
+
_step20;
|
|
4351
4535
|
try {
|
|
4352
|
-
for (
|
|
4353
|
-
var _product$metadata7,
|
|
4354
|
-
var
|
|
4355
|
-
index =
|
|
4356
|
-
product =
|
|
4536
|
+
for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
|
|
4537
|
+
var _product$metadata7, _ref70, _ref71, _existed$origin, _rawProduct$metadata;
|
|
4538
|
+
var _step20$value = _slicedToArray(_step20.value, 2),
|
|
4539
|
+
index = _step20$value[0],
|
|
4540
|
+
product = _step20$value[1];
|
|
4357
4541
|
var uid = (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number;
|
|
4358
4542
|
if (!uid) continue;
|
|
4359
4543
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
4360
4544
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
4361
|
-
var origin = (
|
|
4545
|
+
var origin = (_ref70 = (_ref71 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref71 !== void 0 ? _ref71 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref70 !== void 0 ? _ref70 : rawProduct;
|
|
4362
4546
|
var originSnapshot = cloneDeep(origin);
|
|
4363
4547
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
4364
4548
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -4374,9 +4558,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4374
4558
|
});
|
|
4375
4559
|
}
|
|
4376
4560
|
} catch (err) {
|
|
4377
|
-
|
|
4561
|
+
_iterator20.e(err);
|
|
4378
4562
|
} finally {
|
|
4379
|
-
|
|
4563
|
+
_iterator20.f();
|
|
4380
4564
|
}
|
|
4381
4565
|
tempOrderExtend.productsByUid = productsByUid;
|
|
4382
4566
|
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
@@ -4407,18 +4591,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4407
4591
|
var segments = [];
|
|
4408
4592
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
4409
4593
|
if (Array.isArray(sku.variant)) {
|
|
4410
|
-
var
|
|
4411
|
-
|
|
4594
|
+
var _iterator21 = _createForOfIteratorHelper(sku.variant),
|
|
4595
|
+
_step21;
|
|
4412
4596
|
try {
|
|
4413
|
-
for (
|
|
4414
|
-
var variant =
|
|
4597
|
+
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
4598
|
+
var variant = _step21.value;
|
|
4415
4599
|
var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
|
|
4416
4600
|
if (segment) segments.push(segment);
|
|
4417
4601
|
}
|
|
4418
4602
|
} catch (err) {
|
|
4419
|
-
|
|
4603
|
+
_iterator21.e(err);
|
|
4420
4604
|
} finally {
|
|
4421
|
-
|
|
4605
|
+
_iterator21.f();
|
|
4422
4606
|
}
|
|
4423
4607
|
}
|
|
4424
4608
|
return segments.join(', ');
|
|
@@ -4426,10 +4610,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4426
4610
|
}, {
|
|
4427
4611
|
key: "normalizeHydratedProductOptionItem",
|
|
4428
4612
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
4429
|
-
var
|
|
4430
|
-
var rawNum = (
|
|
4613
|
+
var _ref72, _optionItem$num, _ref73, _optionItem$add_price;
|
|
4614
|
+
var rawNum = (_ref72 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref72 !== void 0 ? _ref72 : 1;
|
|
4431
4615
|
var parsedNum = Number(rawNum);
|
|
4432
|
-
var rawPrice = (
|
|
4616
|
+
var rawPrice = (_ref73 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref73 !== void 0 ? _ref73 : 0;
|
|
4433
4617
|
var parsedPrice = Number(rawPrice);
|
|
4434
4618
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
4435
4619
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -4520,67 +4704,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4520
4704
|
var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
|
|
4521
4705
|
savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
4522
4706
|
};
|
|
4523
|
-
var
|
|
4524
|
-
|
|
4707
|
+
var _iterator22 = _createForOfIteratorHelper(productList),
|
|
4708
|
+
_step22;
|
|
4525
4709
|
try {
|
|
4526
|
-
for (
|
|
4527
|
-
var product =
|
|
4710
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
4711
|
+
var product = _step22.value;
|
|
4528
4712
|
var qty = product.num || 1;
|
|
4529
|
-
var
|
|
4530
|
-
|
|
4713
|
+
var _iterator24 = _createForOfIteratorHelper(product.discount_list || []),
|
|
4714
|
+
_step24;
|
|
4531
4715
|
try {
|
|
4532
|
-
for (
|
|
4533
|
-
var pd =
|
|
4716
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
4717
|
+
var pd = _step24.value;
|
|
4534
4718
|
addDiscountAmount(pd, qty);
|
|
4535
4719
|
}
|
|
4536
4720
|
} catch (err) {
|
|
4537
|
-
|
|
4721
|
+
_iterator24.e(err);
|
|
4538
4722
|
} finally {
|
|
4539
|
-
|
|
4723
|
+
_iterator24.f();
|
|
4540
4724
|
}
|
|
4541
|
-
var
|
|
4542
|
-
|
|
4725
|
+
var _iterator25 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
4726
|
+
_step25;
|
|
4543
4727
|
try {
|
|
4544
|
-
for (
|
|
4545
|
-
var
|
|
4546
|
-
var bundle =
|
|
4547
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
4548
|
-
var
|
|
4549
|
-
|
|
4728
|
+
for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
|
|
4729
|
+
var _ref74, _bundle$num3;
|
|
4730
|
+
var bundle = _step25.value;
|
|
4731
|
+
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref74 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref74 !== void 0 ? _ref74 : 1) || 1).toNumber();
|
|
4732
|
+
var _iterator26 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
4733
|
+
_step26;
|
|
4550
4734
|
try {
|
|
4551
|
-
for (
|
|
4552
|
-
var _pd =
|
|
4735
|
+
for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
|
|
4736
|
+
var _pd = _step26.value;
|
|
4553
4737
|
addDiscountAmount(_pd, bundleQty);
|
|
4554
4738
|
}
|
|
4555
4739
|
} catch (err) {
|
|
4556
|
-
|
|
4740
|
+
_iterator26.e(err);
|
|
4557
4741
|
} finally {
|
|
4558
|
-
|
|
4742
|
+
_iterator26.f();
|
|
4559
4743
|
}
|
|
4560
4744
|
}
|
|
4561
4745
|
} catch (err) {
|
|
4562
|
-
|
|
4746
|
+
_iterator25.e(err);
|
|
4563
4747
|
} finally {
|
|
4564
|
-
|
|
4748
|
+
_iterator25.f();
|
|
4565
4749
|
}
|
|
4566
4750
|
}
|
|
4567
4751
|
} catch (err) {
|
|
4568
|
-
|
|
4752
|
+
_iterator22.e(err);
|
|
4569
4753
|
} finally {
|
|
4570
|
-
|
|
4754
|
+
_iterator22.f();
|
|
4571
4755
|
}
|
|
4572
|
-
var
|
|
4573
|
-
|
|
4756
|
+
var _iterator23 = _createForOfIteratorHelper(discountList),
|
|
4757
|
+
_step23;
|
|
4574
4758
|
try {
|
|
4575
|
-
for (
|
|
4576
|
-
var d =
|
|
4759
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
4760
|
+
var d = _step23.value;
|
|
4577
4761
|
var key = d.id;
|
|
4578
4762
|
d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
|
|
4579
4763
|
}
|
|
4580
4764
|
} catch (err) {
|
|
4581
|
-
|
|
4765
|
+
_iterator23.e(err);
|
|
4582
4766
|
} finally {
|
|
4583
|
-
|
|
4767
|
+
_iterator23.f();
|
|
4584
4768
|
}
|
|
4585
4769
|
}
|
|
4586
4770
|
}]);
|