@pisell/pisellos 0.0.495 → 0.0.497
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/Order/types.d.ts +2 -2
- package/dist/modules/Order/utils.js +5 -4
- package/dist/modules/SalesSummary/utils.js +19 -12
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/ScanOrder/types.d.ts +1 -1
- package/dist/solution/VenueBooking/index.js +78 -25
- package/dist/solution/VenueBooking/utils/slotMerge.js +4 -5
- package/lib/modules/Order/types.d.ts +2 -2
- package/lib/modules/Order/utils.js +2 -3
- package/lib/modules/SalesSummary/utils.js +20 -13
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/ScanOrder/types.d.ts +1 -1
- package/lib/solution/VenueBooking/index.js +29 -3
- package/lib/solution/VenueBooking/utils/slotMerge.js +4 -5
- package/package.json +1 -1
|
@@ -112,14 +112,14 @@ export interface SubmitScanOrderParams {
|
|
|
112
112
|
products: SubmitScanOrderProduct[];
|
|
113
113
|
bookings: SubmitScanOrderBooking[];
|
|
114
114
|
payments: any[];
|
|
115
|
-
surcharges
|
|
115
|
+
surcharges?: any[];
|
|
116
116
|
discount_list: any[];
|
|
117
117
|
relation_forms: any[];
|
|
118
118
|
form_record_ids?: SubmitScanOrderFormRecord[];
|
|
119
119
|
contacts: any[];
|
|
120
120
|
contacts_info: any[];
|
|
121
121
|
holder: Record<string, any> | null;
|
|
122
|
-
summary
|
|
122
|
+
summary?: SubmitScanOrderSummary;
|
|
123
123
|
metadata: Record<string, any>;
|
|
124
124
|
};
|
|
125
125
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var _excluded = ["_origin", "identity_key"],
|
|
2
|
-
_excluded2 = ["created_at"];
|
|
2
|
+
_excluded2 = ["created_at", "summary", "surcharges"];
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -233,8 +233,10 @@ export function buildSubmitPayload(params) {
|
|
|
233
233
|
form_record_ids: [relationId]
|
|
234
234
|
}] : undefined;
|
|
235
235
|
var _createdAt = tempOrder.created_at,
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
_summary = tempOrder.summary,
|
|
237
|
+
_surcharges = tempOrder.surcharges,
|
|
238
|
+
tempOrderRest = _objectWithoutProperties(tempOrder, _excluded2);
|
|
239
|
+
return _objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
238
240
|
platform: normalizeSubmitPlatform(tempOrder.platform),
|
|
239
241
|
request_unique_idempotency_token: cacheId,
|
|
240
242
|
type: tempOrder.type || 'table-order',
|
|
@@ -254,7 +256,6 @@ export function buildSubmitPayload(params) {
|
|
|
254
256
|
schedule_date: scheduleDate,
|
|
255
257
|
bookings: bookings,
|
|
256
258
|
payments: tempOrder.payments || [],
|
|
257
|
-
surcharges: tempOrder.surcharges || [],
|
|
258
259
|
// discount_list: tempOrder.discount_list || [],
|
|
259
260
|
relation_forms: tempOrder.relation_forms || [],
|
|
260
261
|
form_record_ids: formRecordIds,
|
|
@@ -304,8 +304,10 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
|
304
304
|
|
|
305
305
|
// --- 主商品折后税费 ---
|
|
306
306
|
var mainTotal = getMainProductPaymentTotal(product);
|
|
307
|
+
var surchargeFee = toDecimal(product.surcharge_fee);
|
|
308
|
+
var mainTaxableBase = mainTotal.lte(0) ? surchargeFee : mainTotal.plus(surchargeFee);
|
|
307
309
|
var mainTaxPrecise = calculateSingleItemTax({
|
|
308
|
-
price:
|
|
310
|
+
price: mainTaxableBase,
|
|
309
311
|
taxRate: rate,
|
|
310
312
|
isPriceIncludeTax: isPriceIncludeTax,
|
|
311
313
|
isChargeTax: (_product$is_charge_ta2 = product.is_charge_tax) !== null && _product$is_charge_ta2 !== void 0 ? _product$is_charge_ta2 : 0
|
|
@@ -320,8 +322,9 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
|
320
322
|
|
|
321
323
|
// --- 主商品原价税费 ---
|
|
322
324
|
var originalTotal = getUnitOriginalTotal(product);
|
|
325
|
+
var originalTaxableBase = originalTotal.lte(0) ? surchargeFee : originalTotal.plus(surchargeFee);
|
|
323
326
|
var originalTaxPrecise = calculateSingleItemTax({
|
|
324
|
-
price:
|
|
327
|
+
price: originalTaxableBase,
|
|
325
328
|
taxRate: rate,
|
|
326
329
|
isPriceIncludeTax: isPriceIncludeTax,
|
|
327
330
|
isChargeTax: (_product$is_charge_ta3 = product.is_charge_tax) !== null && _product$is_charge_ta3 !== void 0 ? _product$is_charge_ta3 : 0
|
|
@@ -451,16 +454,6 @@ export function calculateSalesSummary(params) {
|
|
|
451
454
|
var productAmount = products.reduce(function (sum, item) {
|
|
452
455
|
return sum.plus(getUnitPaymentTotal(item).times(getSafeNum(item.num)));
|
|
453
456
|
}, new Decimal(0));
|
|
454
|
-
var hasTaxRate = taxRate !== undefined && taxRate !== null && taxRate > 0;
|
|
455
|
-
var productTaxFee;
|
|
456
|
-
if (hasTaxRate) {
|
|
457
|
-
var taxResult = calculateProductsTax(products, taxRate, isPriceIncludeTax);
|
|
458
|
-
productTaxFee = taxResult.tax;
|
|
459
|
-
} else {
|
|
460
|
-
productTaxFee = products.reduce(function (sum, item) {
|
|
461
|
-
return sum.plus(toDecimal(item.tax_fee).times(getSafeNum(item.num)));
|
|
462
|
-
}, new Decimal(0));
|
|
463
|
-
}
|
|
464
457
|
var surchargeServiceItems = buildSurchargeServiceItems(products);
|
|
465
458
|
var surcharge = getSurcharge({
|
|
466
459
|
service: surchargeServiceItems,
|
|
@@ -479,6 +472,20 @@ export function calculateSalesSummary(params) {
|
|
|
479
472
|
}, surcharge, {
|
|
480
473
|
isEdit: false
|
|
481
474
|
}) || 0);
|
|
475
|
+
for (var i = 0; i < products.length; i++) {
|
|
476
|
+
var _surchargeServiceItem;
|
|
477
|
+
products[i].surcharge_fee = ((_surchargeServiceItem = surchargeServiceItems[i]) === null || _surchargeServiceItem === void 0 ? void 0 : _surchargeServiceItem.surcharge_fee) || 0;
|
|
478
|
+
}
|
|
479
|
+
var hasTaxRate = taxRate !== undefined && taxRate !== null && taxRate > 0;
|
|
480
|
+
var productTaxFee;
|
|
481
|
+
if (hasTaxRate) {
|
|
482
|
+
var taxResult = calculateProductsTax(products, taxRate, isPriceIncludeTax);
|
|
483
|
+
productTaxFee = taxResult.tax;
|
|
484
|
+
} else {
|
|
485
|
+
productTaxFee = products.reduce(function (sum, item) {
|
|
486
|
+
return sum.plus(toDecimal(item.tax_fee).times(getSafeNum(item.num)));
|
|
487
|
+
}, new Decimal(0));
|
|
488
|
+
}
|
|
482
489
|
var expectAmount = productAmount.plus(surchargeAmount);
|
|
483
490
|
var totalAmount = isPriceIncludeTax === 1 ? expectAmount : expectAmount.plus(productTaxFee);
|
|
484
491
|
var deposit = calculateProductsDeposit(products);
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 1 | 2 | 3 |
|
|
314
|
+
weekNum: 0 | 1 | 4 | 2 | 3 | 6 | 5;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -330,7 +330,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
330
330
|
count: number;
|
|
331
331
|
left: number;
|
|
332
332
|
summaryCount: number;
|
|
333
|
-
status: "
|
|
333
|
+
status: "sold_out" | "lots_of_space" | "filling_up_fast";
|
|
334
334
|
}[];
|
|
335
335
|
/**
|
|
336
336
|
* 找到多个资源的公共可用时间段
|
|
@@ -122,7 +122,7 @@ export interface ScanOrderTempOrder {
|
|
|
122
122
|
summary: ScanOrderSummary;
|
|
123
123
|
metadata: Record<string, any>;
|
|
124
124
|
}
|
|
125
|
-
export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platform' | 'products' | 'created_at'> {
|
|
125
|
+
export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platform' | 'products' | 'created_at' | 'summary' | 'surcharges'> {
|
|
126
126
|
platform: 'H5' | 'PC';
|
|
127
127
|
request_unique_idempotency_token?: string;
|
|
128
128
|
form_record_ids?: Array<{
|
|
@@ -47,6 +47,7 @@ import { mergeConsecutiveSlots, expandMergedSlotToIndividual, buildVenueIdentity
|
|
|
47
47
|
import { createUuidV4 } from "../../modules/Order/utils";
|
|
48
48
|
import { OrderModule } from "../../modules/Order";
|
|
49
49
|
import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
|
|
50
|
+
import Decimal from 'decimal.js';
|
|
50
51
|
export * from "./types";
|
|
51
52
|
var OPEN_DATA_SECTION_CODES = ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow', 'checkout'];
|
|
52
53
|
function cloneCustomDepositData(customDepositData) {
|
|
@@ -1672,7 +1673,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1672
1673
|
key: "setDiscountSelected",
|
|
1673
1674
|
value: (function () {
|
|
1674
1675
|
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1675
|
-
var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator7, _step7, d, afterApplyTarget, finalSummary, finalProduct, finalTarget;
|
|
1676
|
+
var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator7, _step7, d, selectedResourceIds, _iterator8, _step8, _product$discount_lis, product, before, totalDiscountAmount, newPaymentPrice, paymentStr, afterApplyTarget, finalSummary, finalProduct, finalTarget;
|
|
1676
1677
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1677
1678
|
while (1) switch (_context20.prev = _context20.next) {
|
|
1678
1679
|
case 0:
|
|
@@ -1748,21 +1749,73 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1748
1749
|
}
|
|
1749
1750
|
}
|
|
1750
1751
|
}
|
|
1752
|
+
selectedResourceIds = new Set(nextDiscountList.filter(function (d) {
|
|
1753
|
+
return d.isSelected;
|
|
1754
|
+
}).map(function (d) {
|
|
1755
|
+
return d.id;
|
|
1756
|
+
}));
|
|
1757
|
+
_iterator8 = _createForOfIteratorHelper(tempOrder.products);
|
|
1758
|
+
_context20.prev = 19;
|
|
1759
|
+
_iterator8.s();
|
|
1760
|
+
case 21:
|
|
1761
|
+
if ((_step8 = _iterator8.n()).done) {
|
|
1762
|
+
_context20.next = 30;
|
|
1763
|
+
break;
|
|
1764
|
+
}
|
|
1765
|
+
product = _step8.value;
|
|
1766
|
+
if ((_product$discount_lis = product.discount_list) !== null && _product$discount_lis !== void 0 && _product$discount_lis.length) {
|
|
1767
|
+
_context20.next = 25;
|
|
1768
|
+
break;
|
|
1769
|
+
}
|
|
1770
|
+
return _context20.abrupt("continue", 28);
|
|
1771
|
+
case 25:
|
|
1772
|
+
before = product.discount_list.length;
|
|
1773
|
+
product.discount_list = product.discount_list.filter(function (pd) {
|
|
1774
|
+
var _pd$discount$resource, _pd$discount;
|
|
1775
|
+
var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
|
|
1776
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1777
|
+
});
|
|
1778
|
+
if (product.discount_list.length < before) {
|
|
1779
|
+
totalDiscountAmount = product.discount_list.reduce(function (sum, pd) {
|
|
1780
|
+
return sum + (pd.amount || 0);
|
|
1781
|
+
}, 0);
|
|
1782
|
+
newPaymentPrice = new Decimal(product.selling_price || 0).minus(totalDiscountAmount).toNumber();
|
|
1783
|
+
paymentStr = toPriceString(newPaymentPrice);
|
|
1784
|
+
product.payment_price = paymentStr;
|
|
1785
|
+
if (product.metadata) {
|
|
1786
|
+
product.metadata.main_product_selling_price = paymentStr;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
case 28:
|
|
1790
|
+
_context20.next = 21;
|
|
1791
|
+
break;
|
|
1792
|
+
case 30:
|
|
1793
|
+
_context20.next = 35;
|
|
1794
|
+
break;
|
|
1795
|
+
case 32:
|
|
1796
|
+
_context20.prev = 32;
|
|
1797
|
+
_context20.t0 = _context20["catch"](19);
|
|
1798
|
+
_iterator8.e(_context20.t0);
|
|
1799
|
+
case 35:
|
|
1800
|
+
_context20.prev = 35;
|
|
1801
|
+
_iterator8.f();
|
|
1802
|
+
return _context20.finish(35);
|
|
1803
|
+
case 38:
|
|
1751
1804
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1752
|
-
_context20.next =
|
|
1805
|
+
_context20.next = 41;
|
|
1753
1806
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1754
|
-
case
|
|
1807
|
+
case 41:
|
|
1755
1808
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
1756
1809
|
return d.isSelected;
|
|
1757
1810
|
});
|
|
1758
1811
|
afterApplyTarget = this.store.order.getDiscountList().find(function (d) {
|
|
1759
1812
|
return d.id === params.discountId;
|
|
1760
1813
|
}) || null;
|
|
1761
|
-
_context20.next =
|
|
1814
|
+
_context20.next = 45;
|
|
1762
1815
|
return this.store.order.recalculateSummary({
|
|
1763
1816
|
createIfMissing: true
|
|
1764
1817
|
});
|
|
1765
|
-
case
|
|
1818
|
+
case 45:
|
|
1766
1819
|
this.store.order.persistTempOrder();
|
|
1767
1820
|
finalSummary = ((_this$store$order$get = this.store.order.getTempOrder()) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.summary) || null;
|
|
1768
1821
|
finalProduct = ((_this$store$order$get2 = this.store.order.getTempOrder()) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.products) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2[0]) || null;
|
|
@@ -1771,16 +1824,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1771
1824
|
return d.id === params.discountId;
|
|
1772
1825
|
}) || null;
|
|
1773
1826
|
return _context20.abrupt("return", this.store.order.getDiscountList());
|
|
1774
|
-
case
|
|
1775
|
-
_context20.prev =
|
|
1776
|
-
_context20.
|
|
1777
|
-
this.logMethodError('setDiscountSelected', _context20.
|
|
1778
|
-
throw _context20.
|
|
1779
|
-
case
|
|
1827
|
+
case 53:
|
|
1828
|
+
_context20.prev = 53;
|
|
1829
|
+
_context20.t1 = _context20["catch"](1);
|
|
1830
|
+
this.logMethodError('setDiscountSelected', _context20.t1);
|
|
1831
|
+
throw _context20.t1;
|
|
1832
|
+
case 57:
|
|
1780
1833
|
case "end":
|
|
1781
1834
|
return _context20.stop();
|
|
1782
1835
|
}
|
|
1783
|
-
}, _callee20, this, [[1, 32]]);
|
|
1836
|
+
}, _callee20, this, [[1, 53], [19, 32, 35, 38]]);
|
|
1784
1837
|
}));
|
|
1785
1838
|
function setDiscountSelected(_x14) {
|
|
1786
1839
|
return _setDiscountSelected.apply(this, arguments);
|
|
@@ -2254,17 +2307,17 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2254
2307
|
if (visited.has(value)) return;
|
|
2255
2308
|
visited.add(value);
|
|
2256
2309
|
if (Array.isArray(value)) {
|
|
2257
|
-
var
|
|
2258
|
-
|
|
2310
|
+
var _iterator9 = _createForOfIteratorHelper(value),
|
|
2311
|
+
_step9;
|
|
2259
2312
|
try {
|
|
2260
|
-
for (
|
|
2261
|
-
var item =
|
|
2313
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
2314
|
+
var item = _step9.value;
|
|
2262
2315
|
collectFromValue(item);
|
|
2263
2316
|
}
|
|
2264
2317
|
} catch (err) {
|
|
2265
|
-
|
|
2318
|
+
_iterator9.e(err);
|
|
2266
2319
|
} finally {
|
|
2267
|
-
|
|
2320
|
+
_iterator9.f();
|
|
2268
2321
|
}
|
|
2269
2322
|
return;
|
|
2270
2323
|
}
|
|
@@ -2419,7 +2472,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2419
2472
|
key: "applyPrefillByItemRule",
|
|
2420
2473
|
value: function () {
|
|
2421
2474
|
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
2422
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges,
|
|
2475
|
+
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator10, _step10, _prefillItem$product_, _targetProduct$_origi, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, _ref5, _sourceItem$original_, _ref6, _sourceItem$payment_p, sellingPrice, originalPrice, paymentPrice, targetProduct, existedQuantity, delta, nextProduct;
|
|
2423
2476
|
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2424
2477
|
while (1) switch (_context35.prev = _context35.next) {
|
|
2425
2478
|
case 0:
|
|
@@ -2464,15 +2517,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2464
2517
|
productSourceMap = _context35.sent;
|
|
2465
2518
|
tempOrder = this.ensureTempOrder();
|
|
2466
2519
|
hasChanges = false;
|
|
2467
|
-
|
|
2520
|
+
_iterator10 = _createForOfIteratorHelper(prefillItems);
|
|
2468
2521
|
_context35.prev = 20;
|
|
2469
|
-
|
|
2522
|
+
_iterator10.s();
|
|
2470
2523
|
case 22:
|
|
2471
|
-
if ((
|
|
2524
|
+
if ((_step10 = _iterator10.n()).done) {
|
|
2472
2525
|
_context35.next = 47;
|
|
2473
2526
|
break;
|
|
2474
2527
|
}
|
|
2475
|
-
prefillItem =
|
|
2528
|
+
prefillItem = _step10.value;
|
|
2476
2529
|
productId = Number(prefillItem.product_id);
|
|
2477
2530
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
2478
2531
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
@@ -2544,10 +2597,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2544
2597
|
case 49:
|
|
2545
2598
|
_context35.prev = 49;
|
|
2546
2599
|
_context35.t0 = _context35["catch"](20);
|
|
2547
|
-
|
|
2600
|
+
_iterator10.e(_context35.t0);
|
|
2548
2601
|
case 52:
|
|
2549
2602
|
_context35.prev = 52;
|
|
2550
|
-
|
|
2603
|
+
_iterator10.f();
|
|
2551
2604
|
return _context35.finish(52);
|
|
2552
2605
|
case 55:
|
|
2553
2606
|
if (!hasChanges) {
|
|
@@ -66,8 +66,8 @@ export function buildPriceBreakdown(params) {
|
|
|
66
66
|
productId: productId,
|
|
67
67
|
datetime: slot.startTime
|
|
68
68
|
}) : 0;
|
|
69
|
-
var startHm = dayjs(slot.startTime, 'YYYY-MM-DD HH:mm').format('HH:mm');
|
|
70
|
-
var endHm = dayjs(slot.endTime, 'YYYY-MM-DD HH:mm').format('HH:mm');
|
|
69
|
+
var startHm = dayjs(slot.startTime, 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD HH:mm');
|
|
70
|
+
var endHm = dayjs(slot.endTime, 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD HH:mm');
|
|
71
71
|
var last = entries[entries.length - 1];
|
|
72
72
|
if (last && last.unit_price === unitPrice && last.quotation_shelf_id === shelfId && last.end_time === startHm) {
|
|
73
73
|
last.end_time = endHm;
|
|
@@ -150,7 +150,6 @@ export function expandMergedSlotToIndividual(product, slotDurationMinutes) {
|
|
|
150
150
|
var endTime = meta.end_time;
|
|
151
151
|
if (!startTime || !endTime) return [];
|
|
152
152
|
var breakdown = meta.price_breakdown;
|
|
153
|
-
var datePrefix = dayjs(startTime, 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD');
|
|
154
153
|
var result = [];
|
|
155
154
|
var cursor = dayjs(startTime, 'YYYY-MM-DD HH:mm');
|
|
156
155
|
var end = dayjs(endTime, 'YYYY-MM-DD HH:mm');
|
|
@@ -161,8 +160,8 @@ export function expandMergedSlotToIndividual(product, slotDurationMinutes) {
|
|
|
161
160
|
try {
|
|
162
161
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
163
162
|
var entry = _step2.value;
|
|
164
|
-
var entryCursor = dayjs(
|
|
165
|
-
var entryEnd = dayjs(
|
|
163
|
+
var entryCursor = dayjs(entry.start_time, 'YYYY-MM-DD HH:mm');
|
|
164
|
+
var entryEnd = dayjs(entry.end_time, 'YYYY-MM-DD HH:mm');
|
|
166
165
|
while (entryCursor.isBefore(entryEnd)) {
|
|
167
166
|
priceMap.set(entryCursor.format('HH:mm'), entry.unit_price);
|
|
168
167
|
entryCursor = entryCursor.add(slotDurationMinutes, 'minute');
|
|
@@ -112,14 +112,14 @@ export interface SubmitScanOrderParams {
|
|
|
112
112
|
products: SubmitScanOrderProduct[];
|
|
113
113
|
bookings: SubmitScanOrderBooking[];
|
|
114
114
|
payments: any[];
|
|
115
|
-
surcharges
|
|
115
|
+
surcharges?: any[];
|
|
116
116
|
discount_list: any[];
|
|
117
117
|
relation_forms: any[];
|
|
118
118
|
form_record_ids?: SubmitScanOrderFormRecord[];
|
|
119
119
|
contacts: any[];
|
|
120
120
|
contacts_info: any[];
|
|
121
121
|
holder: Record<string, any> | null;
|
|
122
|
-
summary
|
|
122
|
+
summary?: SubmitScanOrderSummary;
|
|
123
123
|
metadata: Record<string, any>;
|
|
124
124
|
};
|
|
125
125
|
}
|
|
@@ -235,9 +235,9 @@ function buildSubmitPayload(params) {
|
|
|
235
235
|
form_id: tableFormId,
|
|
236
236
|
form_record_ids: [relationId]
|
|
237
237
|
}] : void 0;
|
|
238
|
-
const { created_at: _createdAt, ...
|
|
238
|
+
const { created_at: _createdAt, summary: _summary, surcharges: _surcharges, ...tempOrderRest } = tempOrder;
|
|
239
239
|
return {
|
|
240
|
-
...
|
|
240
|
+
...tempOrderRest,
|
|
241
241
|
platform: normalizeSubmitPlatform(tempOrder.platform),
|
|
242
242
|
request_unique_idempotency_token: cacheId,
|
|
243
243
|
type: tempOrder.type || "table-order",
|
|
@@ -257,7 +257,6 @@ function buildSubmitPayload(params) {
|
|
|
257
257
|
schedule_date: scheduleDate,
|
|
258
258
|
bookings,
|
|
259
259
|
payments: tempOrder.payments || [],
|
|
260
|
-
surcharges: tempOrder.surcharges || [],
|
|
261
260
|
// discount_list: tempOrder.discount_list || [],
|
|
262
261
|
relation_forms: tempOrder.relation_forms || [],
|
|
263
262
|
form_record_ids: formRecordIds,
|
|
@@ -259,8 +259,10 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
|
259
259
|
for (const product of products) {
|
|
260
260
|
const quantity = new import_decimal.default(getSafeNum(product.num));
|
|
261
261
|
const mainTotal = getMainProductPaymentTotal(product);
|
|
262
|
+
const surchargeFee = toDecimal(product.surcharge_fee);
|
|
263
|
+
const mainTaxableBase = mainTotal.lte(0) ? surchargeFee : mainTotal.plus(surchargeFee);
|
|
262
264
|
const mainTaxPrecise = calculateSingleItemTax({
|
|
263
|
-
price:
|
|
265
|
+
price: mainTaxableBase,
|
|
264
266
|
taxRate: rate,
|
|
265
267
|
isPriceIncludeTax,
|
|
266
268
|
isChargeTax: product.is_charge_tax ?? 0
|
|
@@ -270,8 +272,9 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
|
270
272
|
lastTaxableItem = { type: "main", item: product };
|
|
271
273
|
}
|
|
272
274
|
const originalTotal = getUnitOriginalTotal(product);
|
|
275
|
+
const originalTaxableBase = originalTotal.lte(0) ? surchargeFee : originalTotal.plus(surchargeFee);
|
|
273
276
|
const originalTaxPrecise = calculateSingleItemTax({
|
|
274
|
-
price:
|
|
277
|
+
price: originalTaxableBase,
|
|
275
278
|
taxRate: rate,
|
|
276
279
|
isPriceIncludeTax,
|
|
277
280
|
isChargeTax: product.is_charge_tax ?? 0
|
|
@@ -358,6 +361,7 @@ function createEmptySalesSummary() {
|
|
|
358
361
|
};
|
|
359
362
|
}
|
|
360
363
|
function calculateSalesSummary(params) {
|
|
364
|
+
var _a;
|
|
361
365
|
const {
|
|
362
366
|
products,
|
|
363
367
|
isPriceIncludeTax,
|
|
@@ -380,17 +384,6 @@ function calculateSalesSummary(params) {
|
|
|
380
384
|
(sum, item) => sum.plus(getUnitPaymentTotal(item).times(getSafeNum(item.num))),
|
|
381
385
|
new import_decimal.default(0)
|
|
382
386
|
);
|
|
383
|
-
const hasTaxRate = taxRate !== void 0 && taxRate !== null && taxRate > 0;
|
|
384
|
-
let productTaxFee;
|
|
385
|
-
if (hasTaxRate) {
|
|
386
|
-
const taxResult = calculateProductsTax(products, taxRate, isPriceIncludeTax);
|
|
387
|
-
productTaxFee = taxResult.tax;
|
|
388
|
-
} else {
|
|
389
|
-
productTaxFee = products.reduce(
|
|
390
|
-
(sum, item) => sum.plus(toDecimal(item.tax_fee).times(getSafeNum(item.num))),
|
|
391
|
-
new import_decimal.default(0)
|
|
392
|
-
);
|
|
393
|
-
}
|
|
394
387
|
const surchargeServiceItems = buildSurchargeServiceItems(products);
|
|
395
388
|
const surcharge = (0, import_utils.getSurcharge)(
|
|
396
389
|
{
|
|
@@ -413,6 +406,20 @@ function calculateSalesSummary(params) {
|
|
|
413
406
|
{ isEdit: false }
|
|
414
407
|
) || 0
|
|
415
408
|
);
|
|
409
|
+
for (let i = 0; i < products.length; i++) {
|
|
410
|
+
products[i].surcharge_fee = ((_a = surchargeServiceItems[i]) == null ? void 0 : _a.surcharge_fee) || 0;
|
|
411
|
+
}
|
|
412
|
+
const hasTaxRate = taxRate !== void 0 && taxRate !== null && taxRate > 0;
|
|
413
|
+
let productTaxFee;
|
|
414
|
+
if (hasTaxRate) {
|
|
415
|
+
const taxResult = calculateProductsTax(products, taxRate, isPriceIncludeTax);
|
|
416
|
+
productTaxFee = taxResult.tax;
|
|
417
|
+
} else {
|
|
418
|
+
productTaxFee = products.reduce(
|
|
419
|
+
(sum, item) => sum.plus(toDecimal(item.tax_fee).times(getSafeNum(item.num))),
|
|
420
|
+
new import_decimal.default(0)
|
|
421
|
+
);
|
|
422
|
+
}
|
|
416
423
|
const expectAmount = productAmount.plus(surchargeAmount);
|
|
417
424
|
const totalAmount = isPriceIncludeTax === 1 ? expectAmount : expectAmount.plus(productTaxFee);
|
|
418
425
|
const deposit = calculateProductsDeposit(products);
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 1 | 2 | 3 |
|
|
314
|
+
weekNum: 0 | 1 | 4 | 2 | 3 | 6 | 5;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -330,7 +330,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
330
330
|
count: number;
|
|
331
331
|
left: number;
|
|
332
332
|
summaryCount: number;
|
|
333
|
-
status: "
|
|
333
|
+
status: "sold_out" | "lots_of_space" | "filling_up_fast";
|
|
334
334
|
}[];
|
|
335
335
|
/**
|
|
336
336
|
* 找到多个资源的公共可用时间段
|
|
@@ -122,7 +122,7 @@ export interface ScanOrderTempOrder {
|
|
|
122
122
|
summary: ScanOrderSummary;
|
|
123
123
|
metadata: Record<string, any>;
|
|
124
124
|
}
|
|
125
|
-
export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platform' | 'products' | 'created_at'> {
|
|
125
|
+
export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platform' | 'products' | 'created_at' | 'summary' | 'surcharges'> {
|
|
126
126
|
platform: 'H5' | 'PC';
|
|
127
127
|
request_unique_idempotency_token?: string;
|
|
128
128
|
form_record_ids?: Array<{
|
|
@@ -52,6 +52,7 @@ var import_slotMerge = require("./utils/slotMerge");
|
|
|
52
52
|
var import_utils2 = require("../../modules/Order/utils");
|
|
53
53
|
var import_Order = require("../../modules/Order");
|
|
54
54
|
var import_types4 = require("../RegisterAndLogin/types");
|
|
55
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
55
56
|
__reExport(VenueBooking_exports, require("./types"), module.exports);
|
|
56
57
|
var OPEN_DATA_SECTION_CODES = [
|
|
57
58
|
"basic",
|
|
@@ -1015,7 +1016,7 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1015
1016
|
}
|
|
1016
1017
|
/** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
|
|
1017
1018
|
async setDiscountSelected(params) {
|
|
1018
|
-
var _a, _b, _c, _d, _e;
|
|
1019
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1019
1020
|
this.logMethodStart("setDiscountSelected", params);
|
|
1020
1021
|
try {
|
|
1021
1022
|
if (!this.store.order)
|
|
@@ -1067,14 +1068,39 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1067
1068
|
}
|
|
1068
1069
|
}
|
|
1069
1070
|
}
|
|
1071
|
+
const selectedResourceIds = new Set(
|
|
1072
|
+
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
1073
|
+
);
|
|
1074
|
+
for (const product of tempOrder.products) {
|
|
1075
|
+
if (!((_c = product.discount_list) == null ? void 0 : _c.length))
|
|
1076
|
+
continue;
|
|
1077
|
+
const before = product.discount_list.length;
|
|
1078
|
+
product.discount_list = product.discount_list.filter((pd) => {
|
|
1079
|
+
var _a2;
|
|
1080
|
+
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
1081
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1082
|
+
});
|
|
1083
|
+
if (product.discount_list.length < before) {
|
|
1084
|
+
const totalDiscountAmount = product.discount_list.reduce(
|
|
1085
|
+
(sum, pd) => sum + (pd.amount || 0),
|
|
1086
|
+
0
|
|
1087
|
+
);
|
|
1088
|
+
const newPaymentPrice = new import_decimal.default(product.selling_price || 0).minus(totalDiscountAmount).toNumber();
|
|
1089
|
+
const paymentStr = (0, import_utils.toPriceString)(newPaymentPrice);
|
|
1090
|
+
product.payment_price = paymentStr;
|
|
1091
|
+
if (product.metadata) {
|
|
1092
|
+
product.metadata.main_product_selling_price = paymentStr;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1070
1096
|
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1071
1097
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
1072
1098
|
tempOrder.discount_list = (nextDiscountList || []).filter((d) => d.isSelected);
|
|
1073
1099
|
const afterApplyTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1074
1100
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1075
1101
|
this.store.order.persistTempOrder();
|
|
1076
|
-
const finalSummary = ((
|
|
1077
|
-
const finalProduct = ((
|
|
1102
|
+
const finalSummary = ((_d = this.store.order.getTempOrder()) == null ? void 0 : _d.summary) || null;
|
|
1103
|
+
const finalProduct = ((_f = (_e = this.store.order.getTempOrder()) == null ? void 0 : _e.products) == null ? void 0 : _f[0]) || null;
|
|
1078
1104
|
this.logMethodSuccess("setDiscountSelected", params);
|
|
1079
1105
|
const finalTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1080
1106
|
return this.store.order.getDiscountList();
|
|
@@ -88,8 +88,8 @@ function buildPriceBreakdown(params) {
|
|
|
88
88
|
for (const slot of group.slots) {
|
|
89
89
|
const unitPrice = Number(slot.price || "0");
|
|
90
90
|
const shelfId = quotation ? quotation.getQuotationShelfId({ productId, datetime: slot.startTime }) : 0;
|
|
91
|
-
const startHm = (0, import_dayjs.default)(slot.startTime, "YYYY-MM-DD HH:mm").format("HH:mm");
|
|
92
|
-
const endHm = (0, import_dayjs.default)(slot.endTime, "YYYY-MM-DD HH:mm").format("HH:mm");
|
|
91
|
+
const startHm = (0, import_dayjs.default)(slot.startTime, "YYYY-MM-DD HH:mm").format("YYYY-MM-DD HH:mm");
|
|
92
|
+
const endHm = (0, import_dayjs.default)(slot.endTime, "YYYY-MM-DD HH:mm").format("YYYY-MM-DD HH:mm");
|
|
93
93
|
const last = entries[entries.length - 1];
|
|
94
94
|
if (last && last.unit_price === unitPrice && last.quotation_shelf_id === shelfId && last.end_time === startHm) {
|
|
95
95
|
last.end_time = endHm;
|
|
@@ -157,15 +157,14 @@ function expandMergedSlotToIndividual(product, slotDurationMinutes) {
|
|
|
157
157
|
if (!startTime || !endTime)
|
|
158
158
|
return [];
|
|
159
159
|
const breakdown = meta.price_breakdown;
|
|
160
|
-
const datePrefix = (0, import_dayjs.default)(startTime, "YYYY-MM-DD HH:mm").format("YYYY-MM-DD");
|
|
161
160
|
const result = [];
|
|
162
161
|
let cursor = (0, import_dayjs.default)(startTime, "YYYY-MM-DD HH:mm");
|
|
163
162
|
const end = (0, import_dayjs.default)(endTime, "YYYY-MM-DD HH:mm");
|
|
164
163
|
if (breakdown == null ? void 0 : breakdown.length) {
|
|
165
164
|
const priceMap = /* @__PURE__ */ new Map();
|
|
166
165
|
for (const entry of breakdown) {
|
|
167
|
-
let entryCursor = (0, import_dayjs.default)(
|
|
168
|
-
const entryEnd = (0, import_dayjs.default)(
|
|
166
|
+
let entryCursor = (0, import_dayjs.default)(entry.start_time, "YYYY-MM-DD HH:mm");
|
|
167
|
+
const entryEnd = (0, import_dayjs.default)(entry.end_time, "YYYY-MM-DD HH:mm");
|
|
169
168
|
while (entryCursor.isBefore(entryEnd)) {
|
|
170
169
|
priceMap.set(entryCursor.format("HH:mm"), entry.unit_price);
|
|
171
170
|
entryCursor = entryCursor.add(slotDurationMinutes, "minute");
|