@pisell/pisellos 0.10.15 → 0.10.17
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/core/index.js +6 -9
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- package/dist/model/strategy/strategy-example.js +5 -19
- package/dist/modules/Cart/index.js +0 -3
- package/dist/modules/Cart/utils/cartProduct.js +0 -1
- package/dist/modules/Date/index.js +1 -5
- package/dist/modules/Discount/index.js +2 -4
- package/dist/modules/OpenData/index.d.ts +5 -2
- package/dist/modules/OpenData/index.js +27 -14
- package/dist/modules/OpenData/types.d.ts +42 -0
- package/dist/modules/OpenData/types.js +7 -1
- package/dist/modules/OpenData/utils.d.ts +15 -1
- package/dist/modules/OpenData/utils.js +85 -0
- package/dist/modules/Order/index.d.ts +4 -2
- package/dist/modules/Order/index.js +131 -123
- package/dist/modules/Order/types.d.ts +8 -1
- package/dist/modules/Order/types.js +1 -0
- package/dist/modules/Order/utils.js +7 -1
- package/dist/modules/Payment/index.js +97 -162
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/modules/ProductList/index.js +96 -74
- package/dist/modules/Rules/index.js +12 -12
- package/dist/modules/SalesSummary/index.js +6 -4
- package/dist/modules/Schedule/index.js +0 -1
- package/dist/modules/Schedule/utils.js +0 -1
- package/dist/modules/Step/index.js +0 -1
- package/dist/plugins/request.js +1 -4
- package/dist/plugins/window.js +2 -6
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +977 -641
- package/dist/server/modules/menu/index.js +32 -41
- package/dist/server/modules/order/index.d.ts +8 -0
- package/dist/server/modules/order/index.js +253 -219
- package/dist/server/modules/products/index.js +24 -42
- package/dist/server/modules/quotation/index.js +29 -38
- package/dist/server/modules/resource/index.js +3 -4
- package/dist/server/modules/schedule/index.js +27 -35
- package/dist/server/utils/product.js +0 -1
- package/dist/server/utils/small-ticket.d.ts +9 -1
- package/dist/server/utils/small-ticket.js +117 -43
- package/dist/solution/BaseSales/index.d.ts +7 -0
- package/dist/solution/BaseSales/index.js +350 -215
- package/dist/solution/BaseSales/types.d.ts +2 -0
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +15 -6
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +7 -1
- package/dist/solution/BaseSales/utils.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/index.js +7 -59
- package/dist/solution/BookingByStep/utils/capacity.js +1 -11
- package/dist/solution/BookingByStep/utils/resources.js +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
- package/dist/solution/BookingTicket/index.d.ts +14 -19
- package/dist/solution/BookingTicket/index.js +553 -433
- package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -1
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
- package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
- package/dist/solution/BuyTickets/index.js +9 -12
- package/dist/solution/Checkout/index.js +177 -252
- package/dist/solution/Checkout/utils/index.js +4 -16
- package/dist/solution/RegisterAndLogin/index.js +30 -76
- package/dist/solution/Sales/index.d.ts +20 -4
- package/dist/solution/Sales/index.js +348 -75
- package/dist/solution/Sales/types.d.ts +10 -0
- package/dist/solution/ScanOrder/index.js +50 -60
- package/dist/solution/ScanOrder/types.d.ts +2 -0
- package/dist/solution/ScanOrder/utils.js +6 -3
- package/dist/solution/ShopDiscount/index.js +2 -7
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +495 -422
- package/dist/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/dist/solution/VenueBooking/index.js +45 -55
- package/dist/utils/task.js +15 -18
- package/dist/utils/watch.js +0 -1
- package/lib/apis/picoding.js +2 -0
- package/lib/core/index.js +131 -131
- package/lib/effects/index.js +46 -57
- package/lib/index.js +82 -49
- package/lib/model/index.js +14 -21
- package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +209 -315
- package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
- package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
- package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
- package/lib/model/strategy/adapter/index.js +100 -64
- package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
- package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
- package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
- package/lib/model/strategy/adapter/itemRule/index.js +83 -57
- package/lib/model/strategy/adapter/itemRule/type.js +97 -36
- package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
- package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
- package/lib/model/strategy/adapter/promotion/examples.js +222 -234
- package/lib/model/strategy/adapter/promotion/index.js +1 -51
- package/lib/model/strategy/adapter/promotion/type.js +243 -36
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
- package/lib/model/strategy/adapter/walletPass/example.js +217 -190
- package/lib/model/strategy/adapter/walletPass/index.js +75 -51
- package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
- package/lib/model/strategy/adapter/walletPass/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
- package/lib/model/strategy/engine.js +270 -168
- package/lib/model/strategy/index.js +49 -34
- package/lib/model/strategy/strategy-example.js +243 -239
- package/lib/model/strategy/type.js +100 -40
- package/lib/modules/Account/index.js +39 -53
- package/lib/modules/Account/types.js +20 -33
- package/lib/modules/AccountList/index.js +116 -154
- package/lib/modules/AccountList/types.js +30 -31
- package/lib/modules/AccountList/utils.js +18 -30
- package/lib/modules/BaseModule.js +23 -42
- package/lib/modules/BookingContext/index.js +158 -136
- package/lib/modules/BookingContext/types.js +46 -32
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
- package/lib/modules/BookingContext/utils/flexible.js +38 -55
- package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
- package/lib/modules/BookingContext/utils/index.js +124 -41
- package/lib/modules/BookingContext/utils/noResource.js +58 -70
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
- package/lib/modules/BookingContext/utils/productExtend.js +202 -155
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
- package/lib/modules/BookingContext/utils/resources.js +209 -167
- package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
- package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
- package/lib/modules/Cart/index.js +170 -124
- package/lib/modules/Cart/types.js +46 -51
- package/lib/modules/Cart/utils/cartAccount.js +40 -39
- package/lib/modules/Cart/utils/cartDate.js +56 -61
- package/lib/modules/Cart/utils/cartDiscount.js +28 -33
- package/lib/modules/Cart/utils/cartNote.js +27 -32
- package/lib/modules/Cart/utils/cartProduct.js +321 -251
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +70 -78
- package/lib/modules/Cart/utils/changePrice.js +22 -50
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.js +235 -172
- package/lib/modules/Customer/types.js +38 -35
- package/lib/modules/Date/index.js +116 -115
- package/lib/modules/Date/types.js +16 -28
- package/lib/modules/Date/utils.js +174 -123
- package/lib/modules/Discount/index.js +133 -143
- package/lib/modules/Discount/types.js +9 -31
- package/lib/modules/Guests/index.js +30 -56
- package/lib/modules/Guests/types.js +23 -33
- package/lib/modules/Holder/index.js +209 -189
- package/lib/modules/Holder/types.js +4 -16
- package/lib/modules/Holder/utils.js +20 -49
- package/lib/modules/OpenData/index.d.ts +5 -2
- package/lib/modules/OpenData/index.js +119 -78
- package/lib/modules/OpenData/types.d.ts +42 -0
- package/lib/modules/OpenData/types.js +12 -16
- package/lib/modules/OpenData/utils.d.ts +15 -1
- package/lib/modules/OpenData/utils.js +129 -78
- package/lib/modules/Order/index.d.ts +4 -2
- package/lib/modules/Order/index.js +1843 -2251
- package/lib/modules/Order/payment-utils.js +77 -120
- package/lib/modules/Order/types.d.ts +8 -1
- package/lib/modules/Order/types.js +88 -35
- package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
- package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
- package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
- package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
- package/lib/modules/Order/utils/virtualSettlement.js +120 -171
- package/lib/modules/Order/utils.js +834 -668
- package/lib/modules/Payment/cash.js +20 -33
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
- package/lib/modules/Payment/eftpos.js +16 -30
- package/lib/modules/Payment/index.js +532 -399
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.js +230 -108
- package/lib/modules/Payment/utils.js +52 -51
- package/lib/modules/Payment/walletpass.js +485 -660
- package/lib/modules/Product/index.js +51 -46
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/modules/Product/types.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.js +141 -161
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.js +66 -100
- package/lib/modules/Quotation/types.js +4 -16
- package/lib/modules/Resource/index.js +27 -59
- package/lib/modules/Resource/types.js +22 -32
- package/lib/modules/Resource/utils.js +30 -38
- package/lib/modules/ResourcePlanner/index.js +25 -23
- package/lib/modules/ResourcePlanner/localClock.js +54 -119
- package/lib/modules/ResourcePlanner/planner.js +591 -772
- package/lib/modules/ResourcePlanner/types.js +10 -29
- package/lib/modules/Rules/index.js +1224 -963
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.js +80 -89
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.js +359 -442
- package/lib/modules/ScanOrderLogger/index.js +59 -79
- package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
- package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
- package/lib/modules/ScanOrderLogger/types.js +4 -16
- package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
- package/lib/modules/Schedule/index.js +100 -114
- package/lib/modules/Schedule/type.js +4 -16
- package/lib/modules/Schedule/types.js +4 -16
- package/lib/modules/Schedule/utils.js +433 -291
- package/lib/modules/Step/index.js +40 -52
- package/lib/modules/Step/tyeps.js +4 -16
- package/lib/modules/Summary/index.js +66 -71
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +773 -418
- package/lib/modules/SurchargeList/index.js +46 -60
- package/lib/modules/SurchargeList/types.js +4 -16
- package/lib/modules/index.js +245 -63
- package/lib/plugins/app.js +4 -16
- package/lib/plugins/index.js +36 -25
- package/lib/plugins/request.js +137 -126
- package/lib/plugins/shopStore.js +4 -16
- package/lib/plugins/user.js +4 -16
- package/lib/plugins/window.js +171 -179
- package/lib/server/index.d.ts +11 -0
- package/lib/server/index.js +3432 -2757
- package/lib/server/modules/floor-plan/index.js +102 -123
- package/lib/server/modules/floor-plan/types.js +15 -30
- package/lib/server/modules/index.js +106 -68
- package/lib/server/modules/menu/index.js +146 -122
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.d.ts +8 -0
- package/lib/server/modules/order/index.js +781 -956
- package/lib/server/modules/order/types.js +122 -33
- package/lib/server/modules/order/utils/filterBookings.js +219 -194
- package/lib/server/modules/order/utils/filterOrders.js +118 -92
- package/lib/server/modules/payment/index.js +59 -83
- package/lib/server/modules/payment/types.js +4 -16
- package/lib/server/modules/products/index.js +575 -459
- package/lib/server/modules/products/types.js +44 -34
- package/lib/server/modules/quotation/index.js +137 -172
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.js +213 -184
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.js +135 -123
- package/lib/server/modules/schedule/types.js +14 -21
- package/lib/server/modules/schedule/utils.js +334 -163
- package/lib/server/types.js +4 -16
- package/lib/server/utils/index.js +25 -23
- package/lib/server/utils/product.js +196 -139
- package/lib/server/utils/schedule.js +34 -41
- package/lib/server/utils/small-ticket.d.ts +9 -1
- package/lib/server/utils/small-ticket.js +565 -470
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BaseSales/index.d.ts +7 -0
- package/lib/solution/BaseSales/index.js +1385 -1503
- package/lib/solution/BaseSales/types.d.ts +2 -0
- package/lib/solution/BaseSales/types.js +42 -38
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +652 -498
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
- package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +138 -180
- package/lib/solution/BaseSales/utils.js +161 -143
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +1527 -1340
- package/lib/solution/BookingByStep/types.js +40 -99
- package/lib/solution/BookingByStep/utils/capacity.js +192 -160
- package/lib/solution/BookingByStep/utils/products.js +42 -52
- package/lib/solution/BookingByStep/utils/resources.js +527 -330
- package/lib/solution/BookingByStep/utils/stock.js +65 -44
- package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
- package/lib/solution/BookingTicket/index.d.ts +14 -19
- package/lib/solution/BookingTicket/index.js +663 -526
- package/lib/solution/BookingTicket/types.js +99 -77
- package/lib/solution/BookingTicket/utils/addProductDecision.js +229 -190
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
- package/lib/solution/BookingTicket/utils/cartView.js +114 -99
- package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
- package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
- package/lib/solution/BuyTickets/index.js +67 -70
- package/lib/solution/BuyTickets/types.js +22 -38
- package/lib/solution/Checkout/index.js +1451 -1158
- package/lib/solution/Checkout/types.js +91 -61
- package/lib/solution/Checkout/utils/index.js +228 -156
- package/lib/solution/PlaceOrder/index.js +55 -0
- package/lib/solution/RegisterAndLogin/config.js +493 -460
- package/lib/solution/RegisterAndLogin/index.js +633 -630
- package/lib/solution/RegisterAndLogin/types.js +189 -76
- package/lib/solution/RegisterAndLogin/utils.js +183 -125
- package/lib/solution/Sales/index.d.ts +20 -4
- package/lib/solution/Sales/index.js +502 -330
- package/lib/solution/Sales/types.d.ts +10 -0
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.js +822 -852
- package/lib/solution/ScanOrder/types.d.ts +2 -0
- package/lib/solution/ScanOrder/types.js +33 -34
- package/lib/solution/ScanOrder/utils.js +412 -374
- package/lib/solution/ShopDiscount/index.js +226 -232
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +300 -172
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +1087 -1222
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
- package/lib/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/lib/solution/UnifiedBookingSales/types.js +10 -32
- package/lib/solution/VenueBooking/index.js +811 -879
- package/lib/solution/VenueBooking/types.js +19 -39
- package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
- package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.js +124 -41
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.js +4 -16
- package/lib/utils/payment-number.js +26 -46
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
|
@@ -47,6 +47,9 @@ import { QuotationModule } from "../../modules/Quotation";
|
|
|
47
47
|
import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
|
|
48
48
|
import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
|
|
49
49
|
var SERVER_ORDER_CHANGED_EVENT = 'order:onOrdersChanged';
|
|
50
|
+
var OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
|
|
51
|
+
var OS_INVOICE_LAYOUT_CONFIG_FIELD = '_os_invoice_layout_config';
|
|
52
|
+
var OS_INVOICE_TEMPLATE_SETTINGS_FIELD = '_os_invoice_template_settings';
|
|
50
53
|
var WALLET_PAYMENT_CODE_BY_TAG = {
|
|
51
54
|
product_voucher: 'PRODUCTVOUCHER',
|
|
52
55
|
gift_card: 'GIFTCARD',
|
|
@@ -371,6 +374,24 @@ function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
|
|
|
371
374
|
}
|
|
372
375
|
return record;
|
|
373
376
|
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* merge hydrate 不会统一给所有商品补 saved 标记,因此先只标记远端已保存商品。
|
|
380
|
+
* 当前 tempOrder 中尚未提交的本地商品会在 merge 后继续保持 current item 语义。
|
|
381
|
+
*/
|
|
382
|
+
function markLoadedSalesDetailProductsAsSaved(sourceRecord) {
|
|
383
|
+
if (!sourceRecord || _typeof(sourceRecord) !== 'object') return sourceRecord;
|
|
384
|
+
if (!Array.isArray(sourceRecord.products)) return sourceRecord;
|
|
385
|
+
return _objectSpread(_objectSpread({}, sourceRecord), {}, {
|
|
386
|
+
products: sourceRecord.products.map(function (product) {
|
|
387
|
+
return _objectSpread(_objectSpread({}, product || {}), {}, {
|
|
388
|
+
metadata: _objectSpread(_objectSpread({}, product !== null && product !== void 0 && product.metadata && _typeof(product.metadata) === 'object' ? product.metadata : {}), {}, {
|
|
389
|
+
is_edit_for_runtime: true
|
|
390
|
+
})
|
|
391
|
+
});
|
|
392
|
+
})
|
|
393
|
+
});
|
|
394
|
+
}
|
|
374
395
|
export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
375
396
|
_inherits(BaseSalesImpl, _BaseModule);
|
|
376
397
|
var _super = _createSuper(BaseSalesImpl);
|
|
@@ -670,7 +691,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
670
691
|
}, {
|
|
671
692
|
key: "hydrateLatestLoadedSalesDetail",
|
|
672
693
|
value: function () {
|
|
673
|
-
var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(record, loadSequence,
|
|
694
|
+
var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(record, loadSequence, options) {
|
|
674
695
|
var _this4 = this;
|
|
675
696
|
var hydratedSales, skippedBeforeHydrate, hydrateTask, queuedTask;
|
|
676
697
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
@@ -680,7 +701,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
680
701
|
skippedBeforeHydrate = false;
|
|
681
702
|
hydrateTask = /*#__PURE__*/function () {
|
|
682
703
|
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
683
|
-
var sales;
|
|
704
|
+
var hydrateOptions, sales;
|
|
684
705
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
685
706
|
while (1) switch (_context4.prev = _context4.next) {
|
|
686
707
|
case 0:
|
|
@@ -697,30 +718,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
697
718
|
}
|
|
698
719
|
throw new Error('order 模块未初始化');
|
|
699
720
|
case 5:
|
|
700
|
-
|
|
701
|
-
return _this4.store.order.hydrateTempOrderFromRecord(record, hydrateSource === 'sessionStorage' ? {
|
|
702
|
-
recalcOnHydrate: true,
|
|
703
|
-
source: 'sessionStorage'
|
|
704
|
-
} : {
|
|
721
|
+
hydrateOptions = {
|
|
705
722
|
recalcOnHydrate: false
|
|
706
|
-
}
|
|
707
|
-
|
|
723
|
+
};
|
|
724
|
+
if ((options === null || options === void 0 ? void 0 : options.hydrateSource) === 'sessionStorage') {
|
|
725
|
+
hydrateOptions = {
|
|
726
|
+
recalcOnHydrate: true,
|
|
727
|
+
source: 'sessionStorage'
|
|
728
|
+
};
|
|
729
|
+
} else if (options !== null && options !== void 0 && options.merge) {
|
|
730
|
+
hydrateOptions = {
|
|
731
|
+
recalcOnHydrate: true,
|
|
732
|
+
source: 'mergedSalesDetail'
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
_context4.next = 9;
|
|
736
|
+
return _this4.store.order.hydrateTempOrderFromRecord(record, hydrateOptions);
|
|
737
|
+
case 9:
|
|
708
738
|
sales = _context4.sent;
|
|
709
739
|
hydratedSales = sales;
|
|
710
740
|
|
|
711
741
|
// hydrate 期间可能又发起了更新请求;后续任务已串行排队,将负责最终状态。
|
|
712
742
|
if (!(loadSequence !== _this4.salesDetailLoadSequence)) {
|
|
713
|
-
_context4.next =
|
|
743
|
+
_context4.next = 13;
|
|
714
744
|
break;
|
|
715
745
|
}
|
|
716
746
|
return _context4.abrupt("return");
|
|
717
|
-
case
|
|
747
|
+
case 13:
|
|
718
748
|
_this4.currentSalesDetail = sales;
|
|
719
|
-
_context4.next =
|
|
749
|
+
_context4.next = 16;
|
|
720
750
|
return _this4.core.effects.emit("".concat(_this4.name, ":onSalesOrderLoaded"), {
|
|
721
751
|
sales: sales
|
|
722
752
|
});
|
|
723
|
-
case
|
|
753
|
+
case 16:
|
|
724
754
|
case "end":
|
|
725
755
|
return _context4.stop();
|
|
726
756
|
}
|
|
@@ -1175,6 +1205,88 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1175
1205
|
return (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.channel;
|
|
1176
1206
|
}
|
|
1177
1207
|
|
|
1208
|
+
/** Subclasses with target-scoped OpenData override this guard before reusing the cache. */
|
|
1209
|
+
}, {
|
|
1210
|
+
key: "isInvoiceOpenDataCacheCurrent",
|
|
1211
|
+
value: function isInvoiceOpenDataCacheCurrent() {
|
|
1212
|
+
return true;
|
|
1213
|
+
}
|
|
1214
|
+
}, {
|
|
1215
|
+
key: "getFulfillmentRefModeConfigs",
|
|
1216
|
+
value: function getFulfillmentRefModeConfigs() {
|
|
1217
|
+
var _this$otherParams9, _this$otherParams10, _this$store, _this$store$getOpenDa;
|
|
1218
|
+
var candidates = [(_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.openData, (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.dineInConfig, (_this$store = this.store) === null || _this$store === void 0 || (_this$store = _this$store.openData) === null || _this$store === void 0 || (_this$store$getOpenDa = _this$store.getOpenData) === null || _this$store$getOpenDa === void 0 ? void 0 : _this$store$getOpenDa.call(_this$store)];
|
|
1219
|
+
return candidates.filter(function (candidate) {
|
|
1220
|
+
return candidate && _typeof(candidate) === 'object' && !Array.isArray(candidate);
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
}, {
|
|
1224
|
+
key: "getFulfillmentRefMode",
|
|
1225
|
+
value: function getFulfillmentRefMode() {
|
|
1226
|
+
var _iterator2 = _createForOfIteratorHelper(this.getFulfillmentRefModeConfigs()),
|
|
1227
|
+
_step2;
|
|
1228
|
+
try {
|
|
1229
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1230
|
+
var config = _step2.value;
|
|
1231
|
+
var mode = config['fulfillment.fulfillment_ref_mode'];
|
|
1232
|
+
if (mode === undefined || mode === null) continue;
|
|
1233
|
+
var normalized = String(mode).trim();
|
|
1234
|
+
if (normalized) return normalized;
|
|
1235
|
+
}
|
|
1236
|
+
} catch (err) {
|
|
1237
|
+
_iterator2.e(err);
|
|
1238
|
+
} finally {
|
|
1239
|
+
_iterator2.f();
|
|
1240
|
+
}
|
|
1241
|
+
return undefined;
|
|
1242
|
+
}
|
|
1243
|
+
}, {
|
|
1244
|
+
key: "getCachedInvoiceLayoutConfig",
|
|
1245
|
+
value: function getCachedInvoiceLayoutConfig() {
|
|
1246
|
+
var _this$store2;
|
|
1247
|
+
var openDataModule = (_this$store2 = this.store) === null || _this$store2 === void 0 ? void 0 : _this$store2.openData;
|
|
1248
|
+
if (typeof (openDataModule === null || openDataModule === void 0 ? void 0 : openDataModule.getInvoiceLayoutConfig) !== 'function') return undefined;
|
|
1249
|
+
if (!this.isInvoiceOpenDataCacheCurrent()) return undefined;
|
|
1250
|
+
try {
|
|
1251
|
+
return openDataModule.getInvoiceLayoutConfig();
|
|
1252
|
+
} catch (error) {
|
|
1253
|
+
this.logWarning('读取 Invoice OpenData 布局失败,提交时不注入布局配置', {
|
|
1254
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1255
|
+
});
|
|
1256
|
+
return undefined;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}, {
|
|
1260
|
+
key: "getCachedInvoiceTemplateSettings",
|
|
1261
|
+
value: function getCachedInvoiceTemplateSettings() {
|
|
1262
|
+
var _this$store3;
|
|
1263
|
+
var openDataModule = (_this$store3 = this.store) === null || _this$store3 === void 0 ? void 0 : _this$store3.openData;
|
|
1264
|
+
if (typeof (openDataModule === null || openDataModule === void 0 ? void 0 : openDataModule.getInvoiceTemplateSettings) !== 'function') return undefined;
|
|
1265
|
+
if (!this.isInvoiceOpenDataCacheCurrent()) return undefined;
|
|
1266
|
+
try {
|
|
1267
|
+
return openDataModule.getInvoiceTemplateSettings();
|
|
1268
|
+
} catch (error) {
|
|
1269
|
+
this.logWarning('读取 Invoice OpenData 模板配置失败,提交时不注入模板配置', {
|
|
1270
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1271
|
+
});
|
|
1272
|
+
return undefined;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
}, {
|
|
1276
|
+
key: "buildSubmitPayloadEnhancerWithOpenDataConfig",
|
|
1277
|
+
value: function buildSubmitPayloadEnhancerWithOpenDataConfig(enhancePayload) {
|
|
1278
|
+
var fulfillmentRefMode = this.getFulfillmentRefMode();
|
|
1279
|
+
var invoiceLayoutConfig = this.getCachedInvoiceLayoutConfig();
|
|
1280
|
+
var invoiceTemplateSettings = this.getCachedInvoiceTemplateSettings();
|
|
1281
|
+
if (!fulfillmentRefMode && !invoiceLayoutConfig && !invoiceTemplateSettings) {
|
|
1282
|
+
return enhancePayload;
|
|
1283
|
+
}
|
|
1284
|
+
return function (payload, ctx) {
|
|
1285
|
+
var enhancedPayload = enhancePayload ? enhancePayload(payload, ctx) : payload;
|
|
1286
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, enhancedPayload), fulfillmentRefMode ? _defineProperty({}, OS_FULFILLMENT_REF_MODE_FIELD, fulfillmentRefMode) : {}), invoiceLayoutConfig ? _defineProperty({}, OS_INVOICE_LAYOUT_CONFIG_FIELD, cloneDeep(invoiceLayoutConfig)) : {}), invoiceTemplateSettings ? _defineProperty({}, OS_INVOICE_TEMPLATE_SETTINGS_FIELD, cloneDeep(invoiceTemplateSettings)) : {});
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1178
1290
|
/**
|
|
1179
1291
|
* 工厂入口:根据子模块名实例化对应模块。
|
|
1180
1292
|
* 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
|
|
@@ -1241,22 +1353,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1241
1353
|
value: (function () {
|
|
1242
1354
|
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(changedParams) {
|
|
1243
1355
|
var _this6 = this;
|
|
1244
|
-
var
|
|
1245
|
-
|
|
1356
|
+
var _ref26,
|
|
1357
|
+
_ref26$cover,
|
|
1246
1358
|
cover,
|
|
1247
1359
|
_args11 = arguments;
|
|
1248
1360
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1249
1361
|
while (1) switch (_context11.prev = _context11.next) {
|
|
1250
1362
|
case 0:
|
|
1251
|
-
|
|
1363
|
+
_ref26 = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {}, _ref26$cover = _ref26.cover, cover = _ref26$cover === void 0 ? false : _ref26$cover;
|
|
1252
1364
|
_context11.next = 3;
|
|
1253
1365
|
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
1254
|
-
var
|
|
1255
|
-
var
|
|
1366
|
+
var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref27) {
|
|
1367
|
+
var _ref29, moduleName, subModule, targetModule, nextSubModuleOtherParams;
|
|
1256
1368
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1257
1369
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1258
1370
|
case 0:
|
|
1259
|
-
|
|
1371
|
+
_ref29 = _slicedToArray(_ref27, 2), moduleName = _ref29[0], subModule = _ref29[1];
|
|
1260
1372
|
if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
|
|
1261
1373
|
_context10.next = 3;
|
|
1262
1374
|
break;
|
|
@@ -1283,7 +1395,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1283
1395
|
}, _callee10);
|
|
1284
1396
|
}));
|
|
1285
1397
|
return function (_x11) {
|
|
1286
|
-
return
|
|
1398
|
+
return _ref28.apply(this, arguments);
|
|
1287
1399
|
};
|
|
1288
1400
|
}()));
|
|
1289
1401
|
case 3:
|
|
@@ -1363,8 +1475,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1363
1475
|
}, {
|
|
1364
1476
|
key: "isMultiCurrencySettlementEnabled",
|
|
1365
1477
|
value: function isMultiCurrencySettlementEnabled() {
|
|
1366
|
-
var _this$
|
|
1367
|
-
return ((_this$
|
|
1478
|
+
var _this$otherParams11;
|
|
1479
|
+
return ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.enableMultiCurrencySettlement) === true;
|
|
1368
1480
|
}
|
|
1369
1481
|
}, {
|
|
1370
1482
|
key: "isActiveVirtualSettlementOrder",
|
|
@@ -1405,10 +1517,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1405
1517
|
}
|
|
1406
1518
|
tempOrder.metadata = tempOrder.metadata || {};
|
|
1407
1519
|
if (shouldManageLegalCurrencySnapshot) {
|
|
1408
|
-
var
|
|
1520
|
+
var _ref30, _ref31, _tempOrder$metadata$l, _ref32, _ref33, _tempOrder$metadata$l2, _tempOrder$metadata$l3;
|
|
1409
1521
|
var legalCurrencySnapshot = {
|
|
1410
|
-
currency_code: String((
|
|
1411
|
-
currency_symbol: String((
|
|
1522
|
+
currency_code: String((_ref30 = (_ref31 = currencyCode !== null && currencyCode !== void 0 ? currencyCode : (_tempOrder$metadata$l = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l === void 0 ? void 0 : _tempOrder$metadata$l.currency_code) !== null && _ref31 !== void 0 ? _ref31 : tempOrder.currency_code) !== null && _ref30 !== void 0 ? _ref30 : ''),
|
|
1523
|
+
currency_symbol: String((_ref32 = (_ref33 = currencySymbol !== null && currencySymbol !== void 0 ? currencySymbol : (_tempOrder$metadata$l2 = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l2 === void 0 ? void 0 : _tempOrder$metadata$l2.currency_symbol) !== null && _ref33 !== void 0 ? _ref33 : tempOrder.currency_symbol) !== null && _ref32 !== void 0 ? _ref32 : ''),
|
|
1412
1524
|
currency_format: String(((_tempOrder$metadata$l3 = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l3 === void 0 ? void 0 : _tempOrder$metadata$l3.currency_format) || (isVirtualSettlement ? 'symbol_first' : tempOrder.currency_format) || 'symbol_first')
|
|
1413
1525
|
};
|
|
1414
1526
|
if (JSON.stringify(tempOrder.metadata.legal_currency_snapshot || {}) !== JSON.stringify(legalCurrencySnapshot)) {
|
|
@@ -1436,11 +1548,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1436
1548
|
key: "initialize",
|
|
1437
1549
|
value: function () {
|
|
1438
1550
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(core) {
|
|
1439
|
-
var _this$
|
|
1551
|
+
var _this$otherParams12,
|
|
1440
1552
|
_this$appPlugin2,
|
|
1441
1553
|
_this$appPlugin2$getA,
|
|
1442
1554
|
_this9 = this,
|
|
1443
|
-
_this$
|
|
1555
|
+
_this$otherParams13;
|
|
1444
1556
|
var options,
|
|
1445
1557
|
app,
|
|
1446
1558
|
targetCacheData,
|
|
@@ -1455,7 +1567,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1455
1567
|
this.paymentNumberDevicePrefix = null;
|
|
1456
1568
|
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
1457
1569
|
this.otherParams = options.otherParams || {};
|
|
1458
|
-
this.cacheId = (_this$
|
|
1570
|
+
this.cacheId = (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.cacheId;
|
|
1459
1571
|
this.reusedSharedSubModuleNames.clear();
|
|
1460
1572
|
this.window = core.getPlugin('window');
|
|
1461
1573
|
this.request = core.getPlugin('request');
|
|
@@ -1497,7 +1609,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1497
1609
|
_context12.next = 19;
|
|
1498
1610
|
return this.store.schedule.loadAllSchedule();
|
|
1499
1611
|
case 19:
|
|
1500
|
-
if (this.store.order && typeof ((_this$
|
|
1612
|
+
if (this.store.order && typeof ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.enableTempOrderPersist) === 'boolean') {
|
|
1501
1613
|
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
1502
1614
|
}
|
|
1503
1615
|
_context12.next = 22;
|
|
@@ -1569,7 +1681,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1569
1681
|
key: "loadSalesDetail",
|
|
1570
1682
|
value: (function () {
|
|
1571
1683
|
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderIdOrParams) {
|
|
1572
|
-
var loadSequence,
|
|
1684
|
+
var loadSequence, _ref34, _ref35, _ref36, _ref37, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, mergeSourceRecord, currentTempOrder, mergedRecord, record;
|
|
1573
1685
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1574
1686
|
while (1) switch (_context14.prev = _context14.next) {
|
|
1575
1687
|
case 0:
|
|
@@ -1587,7 +1699,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1587
1699
|
};
|
|
1588
1700
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
1589
1701
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
1590
|
-
lookup = (
|
|
1702
|
+
lookup = (_ref34 = (_ref35 = (_ref36 = (_ref37 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref37 !== void 0 ? _ref37 : params.orderNumber) !== null && _ref36 !== void 0 ? _ref36 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref35 !== void 0 ? _ref35 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref34 !== void 0 ? _ref34 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
1591
1703
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
1592
1704
|
_context14.next = 11;
|
|
1593
1705
|
break;
|
|
@@ -1621,39 +1733,43 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1621
1733
|
loadedSalesDetail = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data; // payment_pending 只存在于本地;远端详情需过滤,但会话快照必须完整恢复。
|
|
1622
1734
|
shouldFilterPendingPayments = params.hydrateSource !== 'sessionStorage';
|
|
1623
1735
|
remoteRecord = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(loadedSalesDetail) : loadedSalesDetail;
|
|
1736
|
+
mergeSourceRecord = params.merge ? markLoadedSalesDetailProductsAsSaved(remoteRecord) : remoteRecord;
|
|
1624
1737
|
currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
1625
|
-
mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder,
|
|
1738
|
+
mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, mergeSourceRecord, 'preserve-local') : mergeSourceRecord;
|
|
1626
1739
|
record = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(mergedRecord) : mergedRecord;
|
|
1627
|
-
_context14.next =
|
|
1628
|
-
return this.hydrateLatestLoadedSalesDetail(record, loadSequence,
|
|
1629
|
-
|
|
1630
|
-
|
|
1740
|
+
_context14.next = 31;
|
|
1741
|
+
return this.hydrateLatestLoadedSalesDetail(record, loadSequence, {
|
|
1742
|
+
hydrateSource: params.hydrateSource,
|
|
1743
|
+
merge: params.merge
|
|
1744
|
+
});
|
|
1631
1745
|
case 31:
|
|
1632
|
-
_context14.
|
|
1746
|
+
return _context14.abrupt("return", _context14.sent);
|
|
1747
|
+
case 32:
|
|
1748
|
+
_context14.prev = 32;
|
|
1633
1749
|
this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
|
|
1634
1750
|
if (!(this.salesDetailLoadInFlightCount === 0)) {
|
|
1635
|
-
_context14.next =
|
|
1751
|
+
_context14.next = 43;
|
|
1636
1752
|
break;
|
|
1637
1753
|
}
|
|
1638
|
-
_context14.prev =
|
|
1639
|
-
_context14.next =
|
|
1754
|
+
_context14.prev = 35;
|
|
1755
|
+
_context14.next = 38;
|
|
1640
1756
|
return this.drainQueuedServerOrderChanges();
|
|
1641
|
-
case
|
|
1642
|
-
_context14.next =
|
|
1757
|
+
case 38:
|
|
1758
|
+
_context14.next = 43;
|
|
1643
1759
|
break;
|
|
1644
|
-
case
|
|
1645
|
-
_context14.prev =
|
|
1646
|
-
_context14.t1 = _context14["catch"](
|
|
1760
|
+
case 40:
|
|
1761
|
+
_context14.prev = 40;
|
|
1762
|
+
_context14.t1 = _context14["catch"](35);
|
|
1647
1763
|
this.logError('drain queued server order changes failed', {
|
|
1648
1764
|
error: _context14.t1 instanceof Error ? _context14.t1.message : String(_context14.t1)
|
|
1649
1765
|
});
|
|
1650
|
-
case 42:
|
|
1651
|
-
return _context14.finish(31);
|
|
1652
1766
|
case 43:
|
|
1767
|
+
return _context14.finish(32);
|
|
1768
|
+
case 44:
|
|
1653
1769
|
case "end":
|
|
1654
1770
|
return _context14.stop();
|
|
1655
1771
|
}
|
|
1656
|
-
}, _callee14, this, [[4,,
|
|
1772
|
+
}, _callee14, this, [[4,, 32, 44], [35, 40]]);
|
|
1657
1773
|
}));
|
|
1658
1774
|
function loadSalesDetail(_x13) {
|
|
1659
1775
|
return _loadSalesDetail.apply(this, arguments);
|
|
@@ -2201,12 +2317,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2201
2317
|
return !_this12.isPersistedOrderProduct(product);
|
|
2202
2318
|
});
|
|
2203
2319
|
if (hasDraftProduct) return false;
|
|
2204
|
-
|
|
2205
|
-
|
|
2320
|
+
|
|
2321
|
+
// 编辑详情 hydrate 时,商品行上的历史券卡会被还原为 isEditMode=true、
|
|
2322
|
+
// isSelected=true 的只读记录。它们表示“该折扣已在原订单结算”,不是用户在
|
|
2323
|
+
// 当前编辑会话中新做的选择,不能据此放行刚从 prepare/config 拉回来的折扣。
|
|
2324
|
+
// 否则后续 Rules.calcDiscount 会把没有 isManualSelect 标记的可用 runtime 卡
|
|
2325
|
+
// 当作自动候选,再次写入 tempOrder。这里只识别非 isEditMode 的 runtime 状态;
|
|
2326
|
+
// 新建单、编辑态新增商品以及用户本次明确选择/取消折扣的原有流程保持不变。
|
|
2327
|
+
var hasRuntimeDiscountSelection = params.currentDiscountList.some(function (discount) {
|
|
2328
|
+
return !discount.isEditMode && (discount.isSelected || discount.isManualSelect);
|
|
2206
2329
|
});
|
|
2207
|
-
if (
|
|
2330
|
+
if (hasRuntimeDiscountSelection) return false;
|
|
2331
|
+
|
|
2332
|
+
// nextDiscountList 已经合并了历史只读折扣与本次获取的 runtime 折扣,
|
|
2333
|
+
// 因此这里同样必须排除 isEditMode;只有 runtime 条目已有明确选择状态时,
|
|
2334
|
+
// 才允许继续进入折扣重算。
|
|
2208
2335
|
return !params.nextDiscountList.some(function (discount) {
|
|
2209
|
-
return discount.
|
|
2336
|
+
return !discount.isEditMode && (discount.isSelected || discount.isManualSelect);
|
|
2210
2337
|
});
|
|
2211
2338
|
}
|
|
2212
2339
|
}, {
|
|
@@ -2240,7 +2367,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2240
2367
|
value: function () {
|
|
2241
2368
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2242
2369
|
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
2243
|
-
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, _discountModule$setOr2, _discountModule$setDi, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result,
|
|
2370
|
+
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, _discountModule$setOr2, _discountModule$setDi, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
2244
2371
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2245
2372
|
while (1) switch (_context22.prev = _context22.next) {
|
|
2246
2373
|
case 0:
|
|
@@ -2357,11 +2484,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2357
2484
|
});
|
|
2358
2485
|
case 48:
|
|
2359
2486
|
if (!rulesModule) {
|
|
2360
|
-
_context22.next =
|
|
2487
|
+
_context22.next = 84;
|
|
2361
2488
|
break;
|
|
2362
2489
|
}
|
|
2363
2490
|
orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
|
|
2364
|
-
console.log('[BaseSales.applyDiscountConfig.calcDiscount]');
|
|
2365
2491
|
result = rulesModule.calcDiscount({
|
|
2366
2492
|
productList: tempOrder.products,
|
|
2367
2493
|
discountList: nextDiscountList,
|
|
@@ -2377,23 +2503,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2377
2503
|
if (result.productList) {
|
|
2378
2504
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2379
2505
|
}
|
|
2380
|
-
|
|
2381
|
-
_context22.prev =
|
|
2382
|
-
|
|
2383
|
-
case
|
|
2384
|
-
if ((
|
|
2385
|
-
_context22.next =
|
|
2506
|
+
_iterator3 = _createForOfIteratorHelper(tempOrder.products || []);
|
|
2507
|
+
_context22.prev = 53;
|
|
2508
|
+
_iterator3.s();
|
|
2509
|
+
case 55:
|
|
2510
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
2511
|
+
_context22.next = 70;
|
|
2386
2512
|
break;
|
|
2387
2513
|
}
|
|
2388
|
-
product =
|
|
2514
|
+
product = _step3.value;
|
|
2389
2515
|
productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
|
|
2390
2516
|
runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
|
|
2391
2517
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2392
|
-
_context22.next =
|
|
2518
|
+
_context22.next = 61;
|
|
2393
2519
|
break;
|
|
2394
2520
|
}
|
|
2395
|
-
return _context22.abrupt("continue",
|
|
2396
|
-
case
|
|
2521
|
+
return _context22.abrupt("continue", 68);
|
|
2522
|
+
case 61:
|
|
2397
2523
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
2398
2524
|
return sum + Number(pd.amount || 0);
|
|
2399
2525
|
}, 0);
|
|
@@ -2409,60 +2535,60 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2409
2535
|
mainPrice: newMainSellingPrice,
|
|
2410
2536
|
bundle: product.product_bundle
|
|
2411
2537
|
});
|
|
2412
|
-
case
|
|
2413
|
-
_context22.next =
|
|
2538
|
+
case 68:
|
|
2539
|
+
_context22.next = 55;
|
|
2414
2540
|
break;
|
|
2415
|
-
case
|
|
2416
|
-
_context22.next =
|
|
2541
|
+
case 70:
|
|
2542
|
+
_context22.next = 75;
|
|
2417
2543
|
break;
|
|
2418
|
-
case
|
|
2419
|
-
_context22.prev =
|
|
2420
|
-
_context22.t0 = _context22["catch"](
|
|
2421
|
-
|
|
2422
|
-
case
|
|
2423
|
-
_context22.prev =
|
|
2424
|
-
|
|
2425
|
-
return _context22.finish(
|
|
2426
|
-
case
|
|
2544
|
+
case 72:
|
|
2545
|
+
_context22.prev = 72;
|
|
2546
|
+
_context22.t0 = _context22["catch"](53);
|
|
2547
|
+
_iterator3.e(_context22.t0);
|
|
2548
|
+
case 75:
|
|
2549
|
+
_context22.prev = 75;
|
|
2550
|
+
_iterator3.f();
|
|
2551
|
+
return _context22.finish(75);
|
|
2552
|
+
case 78:
|
|
2427
2553
|
if (!result.discountList) {
|
|
2428
|
-
_context22.next =
|
|
2554
|
+
_context22.next = 84;
|
|
2429
2555
|
break;
|
|
2430
2556
|
}
|
|
2431
2557
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2432
2558
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2433
|
-
_context22.next =
|
|
2559
|
+
_context22.next = 83;
|
|
2434
2560
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2435
|
-
case
|
|
2561
|
+
case 83:
|
|
2436
2562
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
2437
2563
|
return discount.isSelected;
|
|
2438
2564
|
});
|
|
2439
|
-
case
|
|
2440
|
-
_context22.next =
|
|
2565
|
+
case 84:
|
|
2566
|
+
_context22.next = 86;
|
|
2441
2567
|
return this.store.order.recalculateSummary({
|
|
2442
2568
|
createIfMissing: true
|
|
2443
2569
|
});
|
|
2444
|
-
case
|
|
2570
|
+
case 86:
|
|
2445
2571
|
summary = _context22.sent;
|
|
2446
2572
|
this.store.order.persistTempOrder();
|
|
2447
|
-
_context22.next =
|
|
2573
|
+
_context22.next = 90;
|
|
2448
2574
|
return this.effectsEmit('onDiscountApplied', {
|
|
2449
2575
|
productList: tempOrder.products || [],
|
|
2450
2576
|
discountList: nextDiscountList,
|
|
2451
2577
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
2452
2578
|
tempOrder: tempOrder
|
|
2453
2579
|
});
|
|
2454
|
-
case
|
|
2580
|
+
case 90:
|
|
2455
2581
|
return _context22.abrupt("return", {
|
|
2456
2582
|
productList: tempOrder.products || [],
|
|
2457
2583
|
discountList: nextDiscountList,
|
|
2458
2584
|
availableWalletIds: this.getAvailableWalletIds(),
|
|
2459
2585
|
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
2460
2586
|
});
|
|
2461
|
-
case
|
|
2587
|
+
case 91:
|
|
2462
2588
|
case "end":
|
|
2463
2589
|
return _context22.stop();
|
|
2464
2590
|
}
|
|
2465
|
-
}, _callee22, this, [[
|
|
2591
|
+
}, _callee22, this, [[53, 72, 75, 78]]);
|
|
2466
2592
|
}));
|
|
2467
2593
|
function loadDiscountConfig(_x16) {
|
|
2468
2594
|
return _loadDiscountConfig.apply(this, arguments);
|
|
@@ -2524,11 +2650,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2524
2650
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2525
2651
|
case 16:
|
|
2526
2652
|
if (!rulesModule) {
|
|
2527
|
-
_context23.next =
|
|
2653
|
+
_context23.next = 27;
|
|
2528
2654
|
break;
|
|
2529
2655
|
}
|
|
2530
2656
|
orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
|
|
2531
|
-
console.log('[BaseSales.bestDiscount.calcDiscount]');
|
|
2532
2657
|
result = rulesModule.calcDiscount({
|
|
2533
2658
|
productList: tempOrder.products,
|
|
2534
2659
|
discountList: nextDiscountList,
|
|
@@ -2542,14 +2667,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2542
2667
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2543
2668
|
}
|
|
2544
2669
|
if (!result.discountList) {
|
|
2545
|
-
_context23.next =
|
|
2670
|
+
_context23.next = 27;
|
|
2546
2671
|
break;
|
|
2547
2672
|
}
|
|
2548
2673
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2549
2674
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2550
|
-
_context23.next =
|
|
2675
|
+
_context23.next = 25;
|
|
2551
2676
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2552
|
-
case
|
|
2677
|
+
case 25:
|
|
2553
2678
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
2554
2679
|
return discount.isSelected;
|
|
2555
2680
|
});
|
|
@@ -2557,24 +2682,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2557
2682
|
productList: tempOrder.products,
|
|
2558
2683
|
discountList: nextDiscountList
|
|
2559
2684
|
};
|
|
2560
|
-
case
|
|
2561
|
-
_context23.next =
|
|
2685
|
+
case 27:
|
|
2686
|
+
_context23.next = 29;
|
|
2562
2687
|
return this.store.order.recalculateSummary({
|
|
2563
2688
|
createIfMissing: true
|
|
2564
2689
|
});
|
|
2565
|
-
case
|
|
2690
|
+
case 29:
|
|
2566
2691
|
this.store.order.persistTempOrder();
|
|
2567
|
-
_context23.next =
|
|
2692
|
+
_context23.next = 32;
|
|
2568
2693
|
return this.effectsEmit('onDiscountApplied', {
|
|
2569
2694
|
productList: tempOrder.products || [],
|
|
2570
2695
|
discountList: nextDiscountList,
|
|
2571
2696
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
2572
2697
|
tempOrder: tempOrder
|
|
2573
2698
|
});
|
|
2574
|
-
case
|
|
2699
|
+
case 32:
|
|
2575
2700
|
cb === null || cb === void 0 || cb(result);
|
|
2576
2701
|
return _context23.abrupt("return", result);
|
|
2577
|
-
case
|
|
2702
|
+
case 34:
|
|
2578
2703
|
case "end":
|
|
2579
2704
|
return _context23.stop();
|
|
2580
2705
|
}
|
|
@@ -2714,7 +2839,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2714
2839
|
key: "setDiscountSelected",
|
|
2715
2840
|
value: function () {
|
|
2716
2841
|
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2717
|
-
var currentOrder, _store3, _store3$setDiscountLi, list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds,
|
|
2842
|
+
var currentOrder, _store3, _store3$setDiscountLi, list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator4, _step4, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator5, _step5, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
2718
2843
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2719
2844
|
while (1) switch (_context26.prev = _context26.next) {
|
|
2720
2845
|
case 0:
|
|
@@ -2761,7 +2886,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2761
2886
|
case 23:
|
|
2762
2887
|
if (rulesModule) {
|
|
2763
2888
|
orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
|
|
2764
|
-
console.log('[BaseSales.setDiscountSelected.calcDiscount]');
|
|
2765
2889
|
result = rulesModule.calcDiscount({
|
|
2766
2890
|
productList: tempOrder.products,
|
|
2767
2891
|
discountList: updated,
|
|
@@ -2788,10 +2912,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2788
2912
|
}).map(function (d) {
|
|
2789
2913
|
return d.id;
|
|
2790
2914
|
}));
|
|
2791
|
-
|
|
2915
|
+
_iterator4 = _createForOfIteratorHelper(nextDiscountList);
|
|
2792
2916
|
try {
|
|
2793
|
-
for (
|
|
2794
|
-
d =
|
|
2917
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
2918
|
+
d = _step4.value;
|
|
2795
2919
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
2796
2920
|
d.isSelected = false;
|
|
2797
2921
|
d.isManualSelect = true;
|
|
@@ -2799,9 +2923,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2799
2923
|
}
|
|
2800
2924
|
}
|
|
2801
2925
|
} catch (err) {
|
|
2802
|
-
|
|
2926
|
+
_iterator4.e(err);
|
|
2803
2927
|
} finally {
|
|
2804
|
-
|
|
2928
|
+
_iterator4.f();
|
|
2805
2929
|
}
|
|
2806
2930
|
}
|
|
2807
2931
|
}
|
|
@@ -2818,15 +2942,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2818
2942
|
return rid != null && selectedResourceIds.has(rid);
|
|
2819
2943
|
});
|
|
2820
2944
|
};
|
|
2821
|
-
|
|
2945
|
+
_iterator5 = _createForOfIteratorHelper(tempOrder.products);
|
|
2822
2946
|
_context26.prev = 27;
|
|
2823
|
-
|
|
2947
|
+
_iterator5.s();
|
|
2824
2948
|
case 29:
|
|
2825
|
-
if ((
|
|
2949
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
2826
2950
|
_context26.next = 46;
|
|
2827
2951
|
break;
|
|
2828
2952
|
}
|
|
2829
|
-
product =
|
|
2953
|
+
product = _step5.value;
|
|
2830
2954
|
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
2831
2955
|
runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
|
|
2832
2956
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
@@ -2838,10 +2962,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2838
2962
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
2839
2963
|
if (Array.isArray(product.product_bundle)) {
|
|
2840
2964
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
2841
|
-
var
|
|
2965
|
+
var _ref38, _bundle$original_pric;
|
|
2842
2966
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
2843
2967
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
2844
|
-
var restoredBundlePrice = (
|
|
2968
|
+
var restoredBundlePrice = (_ref38 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref38 !== void 0 ? _ref38 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
2845
2969
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
2846
2970
|
price: restoredBundlePrice,
|
|
2847
2971
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -2877,10 +3001,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2877
3001
|
case 48:
|
|
2878
3002
|
_context26.prev = 48;
|
|
2879
3003
|
_context26.t0 = _context26["catch"](27);
|
|
2880
|
-
|
|
3004
|
+
_iterator5.e(_context26.t0);
|
|
2881
3005
|
case 51:
|
|
2882
3006
|
_context26.prev = 51;
|
|
2883
|
-
|
|
3007
|
+
_iterator5.f();
|
|
2884
3008
|
return _context26.finish(51);
|
|
2885
3009
|
case 54:
|
|
2886
3010
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
@@ -3174,8 +3298,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3174
3298
|
key: "submitSalesOrder",
|
|
3175
3299
|
value: (function () {
|
|
3176
3300
|
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
3177
|
-
var _params$smallTicketDa, _this$
|
|
3178
|
-
var virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, submitParams;
|
|
3301
|
+
var _params$smallTicketDa, _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
|
|
3302
|
+
var virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, virtualSettlementEnhancePayload, enhancePayload, submitParams;
|
|
3179
3303
|
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
3180
3304
|
while (1) switch (_context30.prev = _context30.next) {
|
|
3181
3305
|
case 0:
|
|
@@ -3192,12 +3316,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3192
3316
|
// this.store.order.persistTempOrder();
|
|
3193
3317
|
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
3194
3318
|
smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
3319
|
+
virtualSettlementEnhancePayload = virtualSettlement ? function (payload, ctx) {
|
|
3320
|
+
var _callerPayload$metada, _currencySettlementCo;
|
|
3321
|
+
var callerPayload = params !== null && params !== void 0 && params.enhancePayload ? params.enhancePayload(payload, ctx) : payload;
|
|
3322
|
+
var currencySettlementConfig = ((_callerPayload$metada = callerPayload.metadata) === null || _callerPayload$metada === void 0 ? void 0 : _callerPayload$metada.currency_settlement_config) || {};
|
|
3323
|
+
return _objectSpread(_objectSpread({}, callerPayload), {}, {
|
|
3324
|
+
metadata: _objectSpread(_objectSpread({}, callerPayload.metadata || {}), {}, {
|
|
3325
|
+
currency_settlement_config: _objectSpread(_objectSpread({}, currencySettlementConfig), {}, {
|
|
3326
|
+
settlement_type: 'virtual_currency',
|
|
3327
|
+
settlement_ids: [virtualSettlement.currencyProductId],
|
|
3328
|
+
currency_display_snapshot: cloneDeep((_currencySettlementCo = currencySettlementConfig.currency_display_snapshot) !== null && _currencySettlementCo !== void 0 ? _currencySettlementCo : buildCurrencyDisplaySnapshot(virtualSettlement.snapshot))
|
|
3329
|
+
})
|
|
3330
|
+
}),
|
|
3331
|
+
currency_code: virtualSettlement.currencyCode,
|
|
3332
|
+
currency_symbol: virtualSettlement.currencySymbol,
|
|
3333
|
+
currency_format: virtualSettlement.currencyFormat
|
|
3334
|
+
});
|
|
3335
|
+
} : params === null || params === void 0 ? void 0 : params.enhancePayload;
|
|
3336
|
+
enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(virtualSettlementEnhancePayload);
|
|
3195
3337
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
3196
3338
|
cacheId: this.cacheId,
|
|
3197
|
-
platform: (_this$
|
|
3198
|
-
businessCode: ((_this$
|
|
3339
|
+
platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
|
|
3340
|
+
businessCode: ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.business_code),
|
|
3199
3341
|
channel: this.getSubmitOrderSalesChannel(),
|
|
3200
|
-
type: (_this$
|
|
3342
|
+
type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type,
|
|
3201
3343
|
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
3202
3344
|
}, virtualSettlement ? {
|
|
3203
3345
|
payments: virtualSettlement.payments
|
|
@@ -3211,29 +3353,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3211
3353
|
confirmPendingVoucherPayments: false
|
|
3212
3354
|
} : (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
3213
3355
|
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
3214
|
-
} : {}),
|
|
3215
|
-
enhancePayload:
|
|
3216
|
-
var _callerPayload$metada, _currencySettlementCo;
|
|
3217
|
-
var callerPayload = params !== null && params !== void 0 && params.enhancePayload ? params.enhancePayload(payload, ctx) : payload;
|
|
3218
|
-
var currencySettlementConfig = ((_callerPayload$metada = callerPayload.metadata) === null || _callerPayload$metada === void 0 ? void 0 : _callerPayload$metada.currency_settlement_config) || {};
|
|
3219
|
-
return _objectSpread(_objectSpread({}, callerPayload), {}, {
|
|
3220
|
-
metadata: _objectSpread(_objectSpread({}, callerPayload.metadata || {}), {}, {
|
|
3221
|
-
currency_settlement_config: _objectSpread(_objectSpread({}, currencySettlementConfig), {}, {
|
|
3222
|
-
settlement_type: 'virtual_currency',
|
|
3223
|
-
settlement_ids: [virtualSettlement.currencyProductId],
|
|
3224
|
-
currency_display_snapshot: cloneDeep((_currencySettlementCo = currencySettlementConfig.currency_display_snapshot) !== null && _currencySettlementCo !== void 0 ? _currencySettlementCo : buildCurrencyDisplaySnapshot(virtualSettlement.snapshot))
|
|
3225
|
-
})
|
|
3226
|
-
}),
|
|
3227
|
-
currency_code: virtualSettlement.currencyCode,
|
|
3228
|
-
currency_symbol: virtualSettlement.currencySymbol,
|
|
3229
|
-
currency_format: virtualSettlement.currencyFormat
|
|
3230
|
-
});
|
|
3231
|
-
}
|
|
3232
|
-
} : (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
3233
|
-
enhancePayload: params.enhancePayload
|
|
3356
|
+
} : {}), enhancePayload !== undefined ? {
|
|
3357
|
+
enhancePayload: enhancePayload
|
|
3234
3358
|
} : {});
|
|
3235
3359
|
return _context30.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
|
|
3236
|
-
case
|
|
3360
|
+
case 11:
|
|
3237
3361
|
case "end":
|
|
3238
3362
|
return _context30.stop();
|
|
3239
3363
|
}
|
|
@@ -3248,7 +3372,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3248
3372
|
key: "saveSalesOrderDraft",
|
|
3249
3373
|
value: function () {
|
|
3250
3374
|
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
3251
|
-
var _params$platform, _this$
|
|
3375
|
+
var _params$platform, _this$otherParams18, _this$otherParams19, _this$otherParams20, _params$channel, _params$type, _this$otherParams21;
|
|
3252
3376
|
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3253
3377
|
while (1) switch (_context31.prev = _context31.next) {
|
|
3254
3378
|
case 0:
|
|
@@ -3260,10 +3384,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3260
3384
|
case 2:
|
|
3261
3385
|
return _context31.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
|
|
3262
3386
|
cacheId: this.cacheId,
|
|
3263
|
-
platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$
|
|
3264
|
-
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$
|
|
3387
|
+
platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
|
|
3388
|
+
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode) || ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.business_code),
|
|
3265
3389
|
channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
|
|
3266
|
-
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$
|
|
3390
|
+
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type
|
|
3267
3391
|
}, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
3268
3392
|
enhancePayload: params.enhancePayload
|
|
3269
3393
|
} : {})));
|
|
@@ -3282,8 +3406,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3282
3406
|
key: "submitTempOrderAsync",
|
|
3283
3407
|
value: function () {
|
|
3284
3408
|
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3285
|
-
var _params$smallTicketDa2, _this$
|
|
3286
|
-
var inferredPaymentStatus, smallTicketDataFlag, submitParams;
|
|
3409
|
+
var _params$smallTicketDa2, _this$otherParams22, _this$otherParams23, _this$otherParams24, _this$otherParams25;
|
|
3410
|
+
var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
|
|
3287
3411
|
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3288
3412
|
while (1) switch (_context32.prev = _context32.next) {
|
|
3289
3413
|
case 0:
|
|
@@ -3295,12 +3419,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3295
3419
|
case 2:
|
|
3296
3420
|
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
3297
3421
|
smallTicketDataFlag = (_params$smallTicketDa2 = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa2 !== void 0 ? _params$smallTicketDa2 : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
3422
|
+
enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params === null || params === void 0 ? void 0 : params.enhancePayload);
|
|
3298
3423
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
3299
3424
|
cacheId: this.cacheId,
|
|
3300
|
-
platform: (_this$
|
|
3301
|
-
businessCode: ((_this$
|
|
3425
|
+
platform: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.platform,
|
|
3426
|
+
businessCode: ((_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.businessCode) || ((_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.business_code),
|
|
3302
3427
|
channel: this.getSubmitOrderSalesChannel(),
|
|
3303
|
-
type: (_this$
|
|
3428
|
+
type: (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.type,
|
|
3304
3429
|
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
3305
3430
|
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
3306
3431
|
payments: params.payments
|
|
@@ -3310,11 +3435,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3310
3435
|
smallTicketDataFlag: smallTicketDataFlag
|
|
3311
3436
|
} : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
3312
3437
|
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
3313
|
-
} : {}),
|
|
3314
|
-
enhancePayload:
|
|
3438
|
+
} : {}), enhancePayload !== undefined ? {
|
|
3439
|
+
enhancePayload: enhancePayload
|
|
3315
3440
|
} : {});
|
|
3316
3441
|
return _context32.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
3317
|
-
case
|
|
3442
|
+
case 7:
|
|
3318
3443
|
case "end":
|
|
3319
3444
|
return _context32.stop();
|
|
3320
3445
|
}
|
|
@@ -3332,8 +3457,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3332
3457
|
}, {
|
|
3333
3458
|
key: "shouldUseCheckoutSyncTask",
|
|
3334
3459
|
value: function shouldUseCheckoutSyncTask() {
|
|
3335
|
-
var _this$
|
|
3336
|
-
var configured = (_this$
|
|
3460
|
+
var _this$otherParams26;
|
|
3461
|
+
var configured = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.checkoutSyncTaskEnabled;
|
|
3337
3462
|
return typeof configured === 'boolean' ? configured : true;
|
|
3338
3463
|
}
|
|
3339
3464
|
|
|
@@ -3347,8 +3472,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3347
3472
|
key: "printLocalOrderReceipt",
|
|
3348
3473
|
value: function () {
|
|
3349
3474
|
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(lookup) {
|
|
3350
|
-
var _this$
|
|
3351
|
-
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order6, _data;
|
|
3475
|
+
var _this$otherParams27, _this$otherParams28, _this$otherParams29, _this$otherParams30;
|
|
3476
|
+
var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$order6, _data;
|
|
3352
3477
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3353
3478
|
while (1) switch (_context33.prev = _context33.next) {
|
|
3354
3479
|
case 0:
|
|
@@ -3365,10 +3490,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3365
3490
|
external_sale_number: lookup
|
|
3366
3491
|
};
|
|
3367
3492
|
context = {
|
|
3368
|
-
platform: (_this$
|
|
3369
|
-
businessCode: ((_this$
|
|
3493
|
+
platform: (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.platform,
|
|
3494
|
+
businessCode: ((_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.businessCode) || ((_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.business_code),
|
|
3370
3495
|
channel: this.getSubmitOrderSalesChannel(),
|
|
3371
|
-
type: (_this$
|
|
3496
|
+
type: (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.type
|
|
3372
3497
|
};
|
|
3373
3498
|
payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
|
|
3374
3499
|
lookup_order_from_db: 1,
|
|
@@ -3384,22 +3509,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3384
3509
|
channel: context.channel,
|
|
3385
3510
|
type: context.type
|
|
3386
3511
|
});
|
|
3387
|
-
|
|
3388
|
-
|
|
3512
|
+
invoiceLayoutConfig = this.getCachedInvoiceLayoutConfig();
|
|
3513
|
+
invoiceTemplateSettings = this.getCachedInvoiceTemplateSettings();
|
|
3514
|
+
printPayload = _objectSpread(_objectSpread(_objectSpread({}, payload), invoiceLayoutConfig ? {
|
|
3515
|
+
invoice: cloneDeep(invoiceLayoutConfig)
|
|
3516
|
+
} : {}), invoiceTemplateSettings ? {
|
|
3517
|
+
template_settings: cloneDeep(invoiceTemplateSettings)
|
|
3518
|
+
} : {});
|
|
3519
|
+
_context33.next = 11;
|
|
3520
|
+
return this.request.post('/local/print-order', printPayload, {
|
|
3389
3521
|
osServer: true,
|
|
3390
3522
|
customToast: function customToast() {}
|
|
3391
3523
|
});
|
|
3392
|
-
case
|
|
3524
|
+
case 11:
|
|
3393
3525
|
response = _context33.sent;
|
|
3394
3526
|
if (hasLookup) {
|
|
3395
|
-
_context33.next =
|
|
3527
|
+
_context33.next = 15;
|
|
3396
3528
|
break;
|
|
3397
3529
|
}
|
|
3398
|
-
_context33.next =
|
|
3530
|
+
_context33.next = 15;
|
|
3399
3531
|
return (_this$store$order$app = (_this$store$order6 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order6, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
|
|
3400
|
-
case
|
|
3532
|
+
case 15:
|
|
3401
3533
|
return _context33.abrupt("return", response);
|
|
3402
|
-
case
|
|
3534
|
+
case 16:
|
|
3403
3535
|
case "end":
|
|
3404
3536
|
return _context33.stop();
|
|
3405
3537
|
}
|
|
@@ -3427,8 +3559,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3427
3559
|
key: "syncPaymentsToOrder",
|
|
3428
3560
|
value: function () {
|
|
3429
3561
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
3430
|
-
var
|
|
3431
|
-
var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
3562
|
+
var _ref39, _params$businessCode, _this$otherParams31, _this$otherParams32, _params$channel2;
|
|
3563
|
+
var businessCode, channel, enhancePayload, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
3432
3564
|
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3433
3565
|
while (1) switch (_context34.prev = _context34.next) {
|
|
3434
3566
|
case 0:
|
|
@@ -3438,36 +3570,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3438
3570
|
}
|
|
3439
3571
|
throw new Error('order 模块未初始化');
|
|
3440
3572
|
case 2:
|
|
3441
|
-
businessCode = (
|
|
3573
|
+
businessCode = (_ref39 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.businessCode) !== null && _ref39 !== void 0 ? _ref39 : (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.business_code;
|
|
3442
3574
|
channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
|
|
3443
|
-
|
|
3575
|
+
enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params.enhancePayload);
|
|
3576
|
+
syncParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params), {}, {
|
|
3444
3577
|
checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask()
|
|
3445
3578
|
}, businessCode !== undefined ? {
|
|
3446
3579
|
businessCode: businessCode
|
|
3447
3580
|
} : {}), channel !== undefined ? {
|
|
3448
3581
|
channel: channel
|
|
3582
|
+
} : {}), enhancePayload !== undefined ? {
|
|
3583
|
+
enhancePayload: enhancePayload
|
|
3449
3584
|
} : {});
|
|
3450
3585
|
syncState = this.store.order.getOrderSyncState();
|
|
3451
3586
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
3452
|
-
_context34.next =
|
|
3587
|
+
_context34.next = 10;
|
|
3453
3588
|
break;
|
|
3454
3589
|
}
|
|
3455
3590
|
this.queueLatestAutoPaymentSync();
|
|
3456
3591
|
return _context34.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
3457
|
-
case
|
|
3592
|
+
case 10:
|
|
3458
3593
|
payments = params.payments || [];
|
|
3459
|
-
_context34.next =
|
|
3594
|
+
_context34.next = 13;
|
|
3460
3595
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
3461
3596
|
payments: payments,
|
|
3462
3597
|
params: syncParams,
|
|
3463
3598
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
3464
3599
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
3465
3600
|
});
|
|
3466
|
-
case
|
|
3467
|
-
_context34.prev =
|
|
3468
|
-
_context34.next =
|
|
3601
|
+
case 13:
|
|
3602
|
+
_context34.prev = 13;
|
|
3603
|
+
_context34.next = 16;
|
|
3469
3604
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
3470
|
-
case
|
|
3605
|
+
case 16:
|
|
3471
3606
|
syncResult = _context34.sent;
|
|
3472
3607
|
latestPayments = this.store.order.getOrderPayments();
|
|
3473
3608
|
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
@@ -3486,22 +3621,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3486
3621
|
depositAmount: syncResult.depositAmount,
|
|
3487
3622
|
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
3488
3623
|
};
|
|
3489
|
-
_context34.next =
|
|
3624
|
+
_context34.next = 23;
|
|
3490
3625
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
3491
|
-
case
|
|
3626
|
+
case 23:
|
|
3492
3627
|
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
3493
|
-
_context34.next =
|
|
3628
|
+
_context34.next = 26;
|
|
3494
3629
|
break;
|
|
3495
3630
|
}
|
|
3496
|
-
_context34.next =
|
|
3631
|
+
_context34.next = 26;
|
|
3497
3632
|
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
3498
|
-
case
|
|
3633
|
+
case 26:
|
|
3499
3634
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3500
3635
|
return _context34.abrupt("return", syncResult);
|
|
3501
|
-
case
|
|
3502
|
-
_context34.prev =
|
|
3503
|
-
_context34.t0 = _context34["catch"](
|
|
3504
|
-
_context34.next =
|
|
3636
|
+
case 30:
|
|
3637
|
+
_context34.prev = 30;
|
|
3638
|
+
_context34.t0 = _context34["catch"](13);
|
|
3639
|
+
_context34.next = 34;
|
|
3505
3640
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
3506
3641
|
ok: false,
|
|
3507
3642
|
error: _context34.t0,
|
|
@@ -3510,14 +3645,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3510
3645
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
3511
3646
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
3512
3647
|
});
|
|
3513
|
-
case
|
|
3648
|
+
case 34:
|
|
3514
3649
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3515
3650
|
throw _context34.t0;
|
|
3516
|
-
case
|
|
3651
|
+
case 36:
|
|
3517
3652
|
case "end":
|
|
3518
3653
|
return _context34.stop();
|
|
3519
3654
|
}
|
|
3520
|
-
}, _callee34, this, [[
|
|
3655
|
+
}, _callee34, this, [[13, 30]]);
|
|
3521
3656
|
}));
|
|
3522
3657
|
function syncPaymentsToOrder(_x28) {
|
|
3523
3658
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
@@ -3697,10 +3832,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3697
3832
|
}, {
|
|
3698
3833
|
key: "addOrderPaymentWithDevicePrefix",
|
|
3699
3834
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3700
|
-
var _this$
|
|
3835
|
+
var _this$otherParams33,
|
|
3701
3836
|
_paymentRecord$paymen,
|
|
3702
3837
|
_paymentRecord$create,
|
|
3703
|
-
|
|
3838
|
+
_ref40,
|
|
3704
3839
|
_paymentRecord$origin,
|
|
3705
3840
|
_this14 = this;
|
|
3706
3841
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
@@ -3713,7 +3848,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3713
3848
|
return this.store.order.getOrderPayments();
|
|
3714
3849
|
}
|
|
3715
3850
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
3716
|
-
var shopWalletPassId = (_this$
|
|
3851
|
+
var shopWalletPassId = (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.shop_wallet_pass_id;
|
|
3717
3852
|
if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
|
|
3718
3853
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
3719
3854
|
}
|
|
@@ -3722,7 +3857,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3722
3857
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
3723
3858
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
3724
3859
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
3725
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
3860
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref40 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref40 !== void 0 ? _ref40 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
3726
3861
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
|
|
3727
3862
|
service_fee: calculatedServiceFee
|
|
3728
3863
|
} : {}), {}, {
|
|
@@ -4003,7 +4138,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4003
4138
|
}, {
|
|
4004
4139
|
key: "buildWalletInitBusinessData",
|
|
4005
4140
|
value: function buildWalletInitBusinessData(params) {
|
|
4006
|
-
var _this$store$order9, _params$order_wait_pa,
|
|
4141
|
+
var _this$store$order9, _params$order_wait_pa, _ref41, _tempOrder$is_price_i;
|
|
4007
4142
|
var snapshot = (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getOrderSnapshot();
|
|
4008
4143
|
var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
4009
4144
|
var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
@@ -4019,7 +4154,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4019
4154
|
},
|
|
4020
4155
|
products: this.getWalletProductList(),
|
|
4021
4156
|
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
4022
|
-
is_price_include_tax: (
|
|
4157
|
+
is_price_include_tax: (_ref41 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref41 !== void 0 ? _ref41 : 1
|
|
4023
4158
|
}, snapshot.identity.orderId ? {
|
|
4024
4159
|
payment_order_id: String(snapshot.identity.orderId)
|
|
4025
4160
|
} : {});
|
|
@@ -4109,9 +4244,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4109
4244
|
var walletPassName = fundRecord.wallet_pass_name;
|
|
4110
4245
|
var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
|
|
4111
4246
|
var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
|
|
4112
|
-
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (
|
|
4113
|
-
var
|
|
4114
|
-
paymentCode =
|
|
4247
|
+
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref42) {
|
|
4248
|
+
var _ref43 = _slicedToArray(_ref42, 2),
|
|
4249
|
+
paymentCode = _ref43[1];
|
|
4115
4250
|
return paymentCode === code;
|
|
4116
4251
|
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
|
|
4117
4252
|
return {
|
|
@@ -4612,7 +4747,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4612
4747
|
key: "getCashPaymentConfig",
|
|
4613
4748
|
value: (function () {
|
|
4614
4749
|
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
|
|
4615
|
-
var _this$store$order12, _this$store$order12$g, _this$store$order13, _this$store$order13$g, _this$
|
|
4750
|
+
var _this$store$order12, _this$store$order12$g, _this$store$order13, _this$store$order13$g, _this$otherParams34;
|
|
4616
4751
|
var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
|
|
4617
4752
|
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4618
4753
|
while (1) switch (_context49.prev = _context49.next) {
|
|
@@ -4638,7 +4773,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4638
4773
|
amountSnapshot = (_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 || (_this$store$order12$g = _this$store$order12.getOrderAmountSnapshot) === null || _this$store$order12$g === void 0 ? void 0 : _this$store$order12$g.call(_this$store$order12);
|
|
4639
4774
|
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
4640
4775
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
|
|
4641
|
-
currency = ((_this$store$order13 = this.store.order) === null || _this$store$order13 === void 0 || (_this$store$order13$g = _this$store$order13.getTempOrder) === null || _this$store$order13$g === void 0 || (_this$store$order13$g = _this$store$order13$g.call(_this$store$order13)) === null || _this$store$order13$g === void 0 ? void 0 : _this$store$order13$g.currency_code) || ((_this$
|
|
4776
|
+
currency = ((_this$store$order13 = this.store.order) === null || _this$store$order13 === void 0 || (_this$store$order13$g = _this$store$order13.getTempOrder) === null || _this$store$order13$g === void 0 || (_this$store$order13$g = _this$store$order13$g.call(_this$store$order13)) === null || _this$store$order13$g === void 0 ? void 0 : _this$store$order13$g.currency_code) || ((_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.currency) || 'USD';
|
|
4642
4777
|
recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
|
|
4643
4778
|
return _context49.abrupt("return", {
|
|
4644
4779
|
available: Boolean(paymentMethod && amountDue > 0),
|
|
@@ -4773,7 +4908,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4773
4908
|
key: "payCash",
|
|
4774
4909
|
value: (function () {
|
|
4775
4910
|
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
4776
|
-
var _this$store$order$get6, _params$actualPaidAmo, _this$
|
|
4911
|
+
var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams35, _this$window, _this$window$postMess;
|
|
4777
4912
|
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4778
4913
|
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4779
4914
|
while (1) switch (_context51.prev = _context51.next) {
|
|
@@ -4822,7 +4957,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4822
4957
|
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4823
4958
|
actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
|
|
4824
4959
|
changeAmount = Number(params.changeAmount || 0);
|
|
4825
|
-
shopWalletPassId = (_this$
|
|
4960
|
+
shopWalletPassId = (_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.shop_wallet_pass_id;
|
|
4826
4961
|
if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
|
|
4827
4962
|
_context51.next = 26;
|
|
4828
4963
|
break;
|
|
@@ -5137,7 +5272,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5137
5272
|
key: "sendCustomerPayLink",
|
|
5138
5273
|
value: (function () {
|
|
5139
5274
|
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
|
|
5140
|
-
var orderIds,
|
|
5275
|
+
var orderIds, _ref44, _ref45, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
5141
5276
|
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5142
5277
|
while (1) switch (_context54.prev = _context54.next) {
|
|
5143
5278
|
case 0:
|
|
@@ -5158,7 +5293,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5158
5293
|
});
|
|
5159
5294
|
case 6:
|
|
5160
5295
|
submitResult = _context54.sent;
|
|
5161
|
-
orderId = (
|
|
5296
|
+
orderId = (_ref44 = (_ref45 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref45 !== void 0 ? _ref45 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref44 !== void 0 ? _ref44 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
5162
5297
|
if (orderId) {
|
|
5163
5298
|
_context54.next = 10;
|
|
5164
5299
|
break;
|
|
@@ -5350,12 +5485,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5350
5485
|
});
|
|
5351
5486
|
_context57.next = 11;
|
|
5352
5487
|
return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
|
|
5353
|
-
var
|
|
5354
|
-
var
|
|
5488
|
+
var _ref47 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(_ref46) {
|
|
5489
|
+
var _ref48, groupKey, group, productsById;
|
|
5355
5490
|
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5356
5491
|
while (1) switch (_context56.prev = _context56.next) {
|
|
5357
5492
|
case 0:
|
|
5358
|
-
|
|
5493
|
+
_ref48 = _slicedToArray(_ref46, 2), groupKey = _ref48[0], group = _ref48[1];
|
|
5359
5494
|
_context56.next = 3;
|
|
5360
5495
|
return _this16.loadProductsForPriceQuery({
|
|
5361
5496
|
ids: Array.from(group.ids),
|
|
@@ -5373,7 +5508,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5373
5508
|
}, _callee56);
|
|
5374
5509
|
}));
|
|
5375
5510
|
return function (_x48) {
|
|
5376
|
-
return
|
|
5511
|
+
return _ref47.apply(this, arguments);
|
|
5377
5512
|
};
|
|
5378
5513
|
}()));
|
|
5379
5514
|
case 11:
|
|
@@ -5757,13 +5892,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5757
5892
|
key: "getProductList",
|
|
5758
5893
|
value: function () {
|
|
5759
5894
|
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66() {
|
|
5760
|
-
var _this$
|
|
5895
|
+
var _this$otherParams36;
|
|
5761
5896
|
var menu_list_ids, _this$store$products, res;
|
|
5762
5897
|
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
5763
5898
|
while (1) switch (_context66.prev = _context66.next) {
|
|
5764
5899
|
case 0:
|
|
5765
5900
|
// 可以直接通过配置里的 menu 读取
|
|
5766
|
-
menu_list_ids = ((_this$
|
|
5901
|
+
menu_list_ids = ((_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 || (_this$otherParams36 = _this$otherParams36.dineInConfig) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36['menu.associated_menus'].map(function (n) {
|
|
5767
5902
|
return Number(n.value);
|
|
5768
5903
|
})) || [];
|
|
5769
5904
|
_context66.prev = 1;
|
|
@@ -5801,21 +5936,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5801
5936
|
key: "setOtherParams",
|
|
5802
5937
|
value: function () {
|
|
5803
5938
|
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
|
|
5804
|
-
var _this$
|
|
5805
|
-
var
|
|
5806
|
-
|
|
5939
|
+
var _this$otherParams37;
|
|
5940
|
+
var _ref49,
|
|
5941
|
+
_ref49$cover,
|
|
5807
5942
|
cover,
|
|
5808
5943
|
_args67 = arguments;
|
|
5809
5944
|
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
5810
5945
|
while (1) switch (_context67.prev = _context67.next) {
|
|
5811
5946
|
case 0:
|
|
5812
|
-
|
|
5947
|
+
_ref49 = _args67.length > 1 && _args67[1] !== undefined ? _args67[1] : {}, _ref49$cover = _ref49.cover, cover = _ref49$cover === void 0 ? false : _ref49$cover;
|
|
5813
5948
|
if (cover) {
|
|
5814
5949
|
this.otherParams = _objectSpread({}, params);
|
|
5815
5950
|
} else {
|
|
5816
5951
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
5817
5952
|
}
|
|
5818
|
-
this.cacheId = (_this$
|
|
5953
|
+
this.cacheId = (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.cacheId;
|
|
5819
5954
|
_context67.next = 5;
|
|
5820
5955
|
return this.syncOtherParamsToSubModules(params, {
|
|
5821
5956
|
cover: cover
|