@pisell/pisellos 2.2.192 → 2.2.194
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/walletPass/utils.js +7 -4
- package/dist/modules/Order/index.d.ts +12 -9
- package/dist/modules/Order/index.js +503 -580
- package/dist/modules/Order/types.d.ts +5 -5
- package/dist/modules/Order/utils/manualProductDiscount.js +1 -1
- package/dist/modules/Order/utils.js +3 -3
- package/dist/modules/Payment/utils.js +2 -1
- package/dist/modules/SalesSummary/index.d.ts +0 -25
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +2 -25
- package/dist/modules/SalesSummary/utils.js +529 -160
- package/dist/server/index.d.ts +8 -1
- package/dist/server/index.js +653 -466
- package/dist/server/modules/order/index.d.ts +3 -2
- package/dist/server/modules/order/index.js +68 -52
- package/dist/server/modules/products/index.js +4 -4
- package/dist/solution/BaseSales/index.d.ts +2 -1
- package/dist/solution/BaseSales/index.js +116 -122
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -1
- package/dist/solution/ScanOrder/index.js +3 -1
- package/lib/model/strategy/adapter/walletPass/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +12 -9
- package/lib/modules/Order/index.js +124 -120
- package/lib/modules/Order/types.d.ts +5 -5
- package/lib/modules/Order/utils/manualProductDiscount.js +1 -1
- package/lib/modules/Order/utils.js +4 -4
- package/lib/modules/Payment/utils.js +2 -1
- package/lib/modules/SalesSummary/index.d.ts +0 -25
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +2 -25
- package/lib/modules/SalesSummary/utils.js +420 -92
- package/lib/server/index.d.ts +8 -1
- package/lib/server/index.js +145 -26
- package/lib/server/modules/order/index.d.ts +3 -2
- package/lib/server/modules/order/index.js +25 -15
- package/lib/server/modules/products/index.js +0 -4
- package/lib/solution/BaseSales/index.d.ts +2 -1
- package/lib/solution/BaseSales/index.js +53 -16
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -1
- package/lib/solution/ScanOrder/index.js +3 -1
- package/package.json +1 -1
|
@@ -589,7 +589,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
589
589
|
}()
|
|
590
590
|
/**
|
|
591
591
|
* 加载销售订单到统一 tempOrder 工作区。
|
|
592
|
-
*
|
|
592
|
+
* 统一通过 OrderModule 的 sales detail lookup 加载订单详情。
|
|
593
593
|
*
|
|
594
594
|
* 子类可在 `super.loadSalesDetail` 之后基于返回的 `sales` 做业务侧装配
|
|
595
595
|
* (比如把 `sales.customer` 写入 CustomerModule、emit 业务 hook 等)。
|
|
@@ -598,7 +598,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
598
598
|
key: "loadSalesDetail",
|
|
599
599
|
value: (function () {
|
|
600
600
|
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(orderIdOrParams) {
|
|
601
|
-
var
|
|
601
|
+
var _ref9, _params$orderId;
|
|
602
|
+
var params, externalSaleNumber, lookup, res, message, sales;
|
|
602
603
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
603
604
|
while (1) switch (_context5.prev = _context5.next) {
|
|
604
605
|
case 0:
|
|
@@ -612,102 +613,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
612
613
|
orderId: orderIdOrParams
|
|
613
614
|
};
|
|
614
615
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
615
|
-
|
|
616
|
-
|
|
616
|
+
lookup = (_ref9 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref9 !== void 0 ? _ref9 : params.orderNumber;
|
|
617
|
+
if (!(lookup === undefined || lookup === null || lookup === '')) {
|
|
618
|
+
_context5.next = 7;
|
|
617
619
|
break;
|
|
618
620
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
case 8:
|
|
626
|
-
_context5.t0 = _context5.sent;
|
|
627
|
-
_context5.next = 26;
|
|
628
|
-
break;
|
|
629
|
-
case 11:
|
|
630
|
-
if (!externalSaleNumber) {
|
|
631
|
-
_context5.next = 17;
|
|
632
|
-
break;
|
|
633
|
-
}
|
|
634
|
-
_context5.next = 14;
|
|
635
|
-
return this.store.order.getLocalOrderByExternalSaleNumber(externalSaleNumber);
|
|
636
|
-
case 14:
|
|
637
|
-
_context5.t1 = _context5.sent;
|
|
638
|
-
_context5.next = 25;
|
|
639
|
-
break;
|
|
640
|
-
case 17:
|
|
641
|
-
if (!params.orderNumber) {
|
|
642
|
-
_context5.next = 23;
|
|
643
|
-
break;
|
|
644
|
-
}
|
|
645
|
-
_context5.next = 20;
|
|
646
|
-
return this.store.order.getLocalOrderByOrderNumber(params.orderNumber);
|
|
647
|
-
case 20:
|
|
648
|
-
_context5.t2 = _context5.sent;
|
|
649
|
-
_context5.next = 24;
|
|
650
|
-
break;
|
|
651
|
-
case 23:
|
|
652
|
-
_context5.t2 = null;
|
|
653
|
-
case 24:
|
|
654
|
-
_context5.t1 = _context5.t2;
|
|
655
|
-
case 25:
|
|
656
|
-
_context5.t0 = _context5.t1;
|
|
657
|
-
case 26:
|
|
658
|
-
localRecord = _context5.t0;
|
|
659
|
-
if (!localRecord) {
|
|
660
|
-
_context5.next = 35;
|
|
661
|
-
break;
|
|
662
|
-
}
|
|
663
|
-
_context5.next = 30;
|
|
664
|
-
return this.store.order.hydrateTempOrderFromRecord(localRecord, {
|
|
665
|
-
recalcOnHydrate: false
|
|
666
|
-
});
|
|
667
|
-
case 30:
|
|
668
|
-
_sales = _context5.sent;
|
|
669
|
-
this.currentSalesDetail = _sales;
|
|
670
|
-
_context5.next = 34;
|
|
671
|
-
return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
|
|
672
|
-
sales: _sales
|
|
621
|
+
throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
|
|
622
|
+
case 7:
|
|
623
|
+
_context5.next = 9;
|
|
624
|
+
return this.store.order.getSalesOrderByLookup({
|
|
625
|
+
lookup: lookup,
|
|
626
|
+
forceRemote: params.forceRemote
|
|
673
627
|
});
|
|
674
|
-
case
|
|
675
|
-
return _context5.abrupt("return", _sales);
|
|
676
|
-
case 35:
|
|
677
|
-
if (!(params.orderId === undefined || params.orderId === null)) {
|
|
678
|
-
_context5.next = 37;
|
|
679
|
-
break;
|
|
680
|
-
}
|
|
681
|
-
throw new Error('加载销售详情需要 orderId,或本地库中存在对应 externalSaleNumber/orderNumber');
|
|
682
|
-
case 37:
|
|
683
|
-
_context5.next = 39;
|
|
684
|
-
return this.store.order.getOrderInfoByRemote(Number(params.orderId));
|
|
685
|
-
case 39:
|
|
628
|
+
case 9:
|
|
686
629
|
res = _context5.sent;
|
|
687
630
|
if (!(!res || res.code !== 200)) {
|
|
688
|
-
_context5.next =
|
|
631
|
+
_context5.next = 13;
|
|
689
632
|
break;
|
|
690
633
|
}
|
|
691
|
-
message = res && (res.message || res.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(
|
|
634
|
+
message = res && (res.message || res.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
|
|
692
635
|
throw new Error(message);
|
|
693
|
-
case
|
|
694
|
-
_context5.next =
|
|
636
|
+
case 13:
|
|
637
|
+
_context5.next = 15;
|
|
695
638
|
return this.store.order.hydrateTempOrderFromRecord(res.data, {
|
|
696
639
|
recalcOnHydrate: false
|
|
697
640
|
});
|
|
698
|
-
case
|
|
641
|
+
case 15:
|
|
699
642
|
sales = _context5.sent;
|
|
700
|
-
_context5.next = 48;
|
|
701
|
-
return this.store.order.saveDraft();
|
|
702
|
-
case 48:
|
|
703
643
|
this.currentSalesDetail = sales;
|
|
704
|
-
_context5.next =
|
|
644
|
+
_context5.next = 19;
|
|
705
645
|
return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
|
|
706
646
|
sales: sales
|
|
707
647
|
});
|
|
708
|
-
case
|
|
648
|
+
case 19:
|
|
709
649
|
return _context5.abrupt("return", sales);
|
|
710
|
-
case
|
|
650
|
+
case 20:
|
|
711
651
|
case "end":
|
|
712
652
|
return _context5.stop();
|
|
713
653
|
}
|
|
@@ -1192,6 +1132,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1192
1132
|
return !historyIds.has(discount.id);
|
|
1193
1133
|
})));
|
|
1194
1134
|
}
|
|
1135
|
+
}, {
|
|
1136
|
+
key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
|
|
1137
|
+
value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
|
|
1138
|
+
var _this6 = this;
|
|
1139
|
+
if (params.discountAction !== 'edit') return false;
|
|
1140
|
+
if (!params.products.length) return false;
|
|
1141
|
+
var hasDraftProduct = params.products.some(function (product) {
|
|
1142
|
+
return !_this6.isPersistedOrderProduct(product);
|
|
1143
|
+
});
|
|
1144
|
+
if (hasDraftProduct) return false;
|
|
1145
|
+
var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
|
|
1146
|
+
return discount.isSelected || discount.isEditMode || discount.isManualSelect;
|
|
1147
|
+
});
|
|
1148
|
+
if (hasSelectedDiscount) return false;
|
|
1149
|
+
return !params.nextDiscountList.some(function (discount) {
|
|
1150
|
+
return discount.isSelected || discount.isEditMode || discount.isManualSelect;
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1195
1153
|
}, {
|
|
1196
1154
|
key: "mergeCurrentDiscountSelectionState",
|
|
1197
1155
|
value: function mergeCurrentDiscountSelectionState(discountList, currentDiscountList) {
|
|
@@ -1222,7 +1180,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1222
1180
|
value: function () {
|
|
1223
1181
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
|
|
1224
1182
|
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
1225
|
-
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, _tempOrder$holder, _tempOrder$holder2, _orderStore$summary, holders, result, _iterator, _step, _product$metadata2, _tempOrder$_extend3, _product$metadata3, _product$metadata$sou, _product$metadata4, _product$metadata5, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
1183
|
+
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _tempOrder$holder, _tempOrder$holder2, _orderStore$summary, holders, result, _iterator, _step, _product$metadata2, _tempOrder$_extend3, _product$metadata3, _product$metadata$sou, _product$metadata4, _product$metadata5, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
1226
1184
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1227
1185
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1228
1186
|
case 0:
|
|
@@ -1285,8 +1243,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1285
1243
|
_context12.next = 31;
|
|
1286
1244
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1287
1245
|
case 31:
|
|
1246
|
+
shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
|
|
1247
|
+
discountAction: discountAction,
|
|
1248
|
+
products: tempOrder.products || [],
|
|
1249
|
+
currentDiscountList: currentDiscountList,
|
|
1250
|
+
nextDiscountList: nextDiscountList
|
|
1251
|
+
});
|
|
1252
|
+
if (!shouldSkipAutoApplyFetchedDiscounts) {
|
|
1253
|
+
_context12.next = 40;
|
|
1254
|
+
break;
|
|
1255
|
+
}
|
|
1256
|
+
_context12.next = 35;
|
|
1257
|
+
return this.store.order.recalculateSummary({
|
|
1258
|
+
createIfMissing: true
|
|
1259
|
+
});
|
|
1260
|
+
case 35:
|
|
1261
|
+
_summary = _context12.sent;
|
|
1262
|
+
this.store.order.persistTempOrder();
|
|
1263
|
+
_context12.next = 39;
|
|
1264
|
+
return this.effectsEmit('onDiscountApplied', {
|
|
1265
|
+
productList: tempOrder.products || [],
|
|
1266
|
+
discountList: nextDiscountList,
|
|
1267
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
1268
|
+
tempOrder: tempOrder
|
|
1269
|
+
});
|
|
1270
|
+
case 39:
|
|
1271
|
+
return _context12.abrupt("return", {
|
|
1272
|
+
productList: tempOrder.products || [],
|
|
1273
|
+
discountList: nextDiscountList
|
|
1274
|
+
});
|
|
1275
|
+
case 40:
|
|
1288
1276
|
if (!rulesModule) {
|
|
1289
|
-
_context12.next =
|
|
1277
|
+
_context12.next = 76;
|
|
1290
1278
|
break;
|
|
1291
1279
|
}
|
|
1292
1280
|
holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
@@ -1306,22 +1294,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1306
1294
|
tempOrder.products = result.productList;
|
|
1307
1295
|
}
|
|
1308
1296
|
_iterator = _createForOfIteratorHelper(tempOrder.products || []);
|
|
1309
|
-
_context12.prev =
|
|
1297
|
+
_context12.prev = 45;
|
|
1310
1298
|
_iterator.s();
|
|
1311
|
-
case
|
|
1299
|
+
case 47:
|
|
1312
1300
|
if ((_step = _iterator.n()).done) {
|
|
1313
|
-
_context12.next =
|
|
1301
|
+
_context12.next = 62;
|
|
1314
1302
|
break;
|
|
1315
1303
|
}
|
|
1316
1304
|
product = _step.value;
|
|
1317
1305
|
productUid = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.unique_identification_number;
|
|
1318
1306
|
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;
|
|
1319
1307
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$metadata3 = product.metadata) !== null && _product$metadata3 !== void 0 && _product$metadata3.is_manual_discount)) {
|
|
1320
|
-
_context12.next =
|
|
1308
|
+
_context12.next = 53;
|
|
1321
1309
|
break;
|
|
1322
1310
|
}
|
|
1323
|
-
return _context12.abrupt("continue",
|
|
1324
|
-
case
|
|
1311
|
+
return _context12.abrupt("continue", 60);
|
|
1312
|
+
case 53:
|
|
1325
1313
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1326
1314
|
return sum + Number(pd.amount || 0);
|
|
1327
1315
|
}, 0);
|
|
@@ -1337,58 +1325,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1337
1325
|
mainPrice: newMainSellingPrice,
|
|
1338
1326
|
bundle: product.product_bundle
|
|
1339
1327
|
});
|
|
1340
|
-
case
|
|
1341
|
-
_context12.next =
|
|
1328
|
+
case 60:
|
|
1329
|
+
_context12.next = 47;
|
|
1342
1330
|
break;
|
|
1343
|
-
case
|
|
1344
|
-
_context12.next =
|
|
1331
|
+
case 62:
|
|
1332
|
+
_context12.next = 67;
|
|
1345
1333
|
break;
|
|
1346
|
-
case
|
|
1347
|
-
_context12.prev =
|
|
1348
|
-
_context12.t0 = _context12["catch"](
|
|
1334
|
+
case 64:
|
|
1335
|
+
_context12.prev = 64;
|
|
1336
|
+
_context12.t0 = _context12["catch"](45);
|
|
1349
1337
|
_iterator.e(_context12.t0);
|
|
1350
|
-
case
|
|
1351
|
-
_context12.prev =
|
|
1338
|
+
case 67:
|
|
1339
|
+
_context12.prev = 67;
|
|
1352
1340
|
_iterator.f();
|
|
1353
|
-
return _context12.finish(
|
|
1354
|
-
case
|
|
1341
|
+
return _context12.finish(67);
|
|
1342
|
+
case 70:
|
|
1355
1343
|
if (!result.discountList) {
|
|
1356
|
-
_context12.next =
|
|
1344
|
+
_context12.next = 76;
|
|
1357
1345
|
break;
|
|
1358
1346
|
}
|
|
1359
1347
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1360
1348
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1361
|
-
_context12.next =
|
|
1349
|
+
_context12.next = 75;
|
|
1362
1350
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1363
|
-
case
|
|
1351
|
+
case 75:
|
|
1364
1352
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
1365
1353
|
return discount.isSelected;
|
|
1366
1354
|
});
|
|
1367
|
-
case
|
|
1368
|
-
_context12.next =
|
|
1355
|
+
case 76:
|
|
1356
|
+
_context12.next = 78;
|
|
1369
1357
|
return this.store.order.recalculateSummary({
|
|
1370
1358
|
createIfMissing: true
|
|
1371
1359
|
});
|
|
1372
|
-
case
|
|
1360
|
+
case 78:
|
|
1373
1361
|
summary = _context12.sent;
|
|
1374
1362
|
this.store.order.persistTempOrder();
|
|
1375
|
-
_context12.next =
|
|
1363
|
+
_context12.next = 82;
|
|
1376
1364
|
return this.effectsEmit('onDiscountApplied', {
|
|
1377
1365
|
productList: tempOrder.products || [],
|
|
1378
1366
|
discountList: nextDiscountList,
|
|
1379
1367
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
1380
1368
|
tempOrder: tempOrder
|
|
1381
1369
|
});
|
|
1382
|
-
case
|
|
1370
|
+
case 82:
|
|
1383
1371
|
return _context12.abrupt("return", {
|
|
1384
1372
|
productList: tempOrder.products || [],
|
|
1385
1373
|
discountList: nextDiscountList
|
|
1386
1374
|
});
|
|
1387
|
-
case
|
|
1375
|
+
case 83:
|
|
1388
1376
|
case "end":
|
|
1389
1377
|
return _context12.stop();
|
|
1390
1378
|
}
|
|
1391
|
-
}, _callee12, this, [[
|
|
1379
|
+
}, _callee12, this, [[45, 64, 67, 70]]);
|
|
1392
1380
|
}));
|
|
1393
1381
|
function loadDiscountConfig(_x7) {
|
|
1394
1382
|
return _loadDiscountConfig.apply(this, arguments);
|
|
@@ -1853,7 +1841,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1853
1841
|
key: "syncPaymentsToOrder",
|
|
1854
1842
|
value: function () {
|
|
1855
1843
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
1856
|
-
var
|
|
1844
|
+
var _ref10, _params$businessCode, _this$otherParams10, _this$otherParams11, _params$channel;
|
|
1857
1845
|
var businessCode, channel, syncParams, syncState, payments, syncResult;
|
|
1858
1846
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1859
1847
|
while (1) switch (_context19.prev = _context19.next) {
|
|
@@ -1864,7 +1852,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1864
1852
|
}
|
|
1865
1853
|
throw new Error('order 模块未初始化');
|
|
1866
1854
|
case 2:
|
|
1867
|
-
businessCode = (
|
|
1855
|
+
businessCode = (_ref10 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.businessCode) !== null && _ref10 !== void 0 ? _ref10 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.business_code;
|
|
1868
1856
|
channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
|
|
1869
1857
|
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
|
|
1870
1858
|
businessCode: businessCode
|
|
@@ -1948,11 +1936,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1948
1936
|
key: "addOrderPayment",
|
|
1949
1937
|
value: function addOrderPayment(payment) {
|
|
1950
1938
|
var _this$otherParams12,
|
|
1951
|
-
|
|
1939
|
+
_this7 = this;
|
|
1952
1940
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1953
1941
|
var paymentRecord = payment;
|
|
1942
|
+
var paymentAmount = new Decimal(paymentRecord.amount || 0);
|
|
1943
|
+
if (paymentAmount.isZero()) {
|
|
1944
|
+
this.logWarning('addOrderPayment: 支付金额为 0,跳过添加支付项', {
|
|
1945
|
+
payment: paymentRecord
|
|
1946
|
+
});
|
|
1947
|
+
return this.store.order.getOrderPayments();
|
|
1948
|
+
}
|
|
1954
1949
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1955
|
-
debugger;
|
|
1956
1950
|
var shopWalletPassId = (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.shop_wallet_pass_id;
|
|
1957
1951
|
if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
|
|
1958
1952
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
@@ -1973,7 +1967,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1973
1967
|
submitWhenPaid: true,
|
|
1974
1968
|
smallTicketDataFlag: 1
|
|
1975
1969
|
}).catch(function (error) {
|
|
1976
|
-
|
|
1970
|
+
_this7.logError('auto sync payments failed', {
|
|
1977
1971
|
error: error instanceof Error ? error.message : String(error)
|
|
1978
1972
|
});
|
|
1979
1973
|
});
|
|
@@ -2065,7 +2059,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2065
2059
|
key: "initWalletData",
|
|
2066
2060
|
value: function () {
|
|
2067
2061
|
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
2068
|
-
var _params$order_wait_pa,
|
|
2062
|
+
var _params$order_wait_pa, _ref11, _tempOrder$is_price_i;
|
|
2069
2063
|
var snapshot, tempOrder, amount, walletBusinessData, result;
|
|
2070
2064
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2071
2065
|
while (1) switch (_context20.prev = _context20.next) {
|
|
@@ -2108,7 +2102,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2108
2102
|
},
|
|
2109
2103
|
products: this.getWalletProductList(),
|
|
2110
2104
|
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),
|
|
2111
|
-
is_price_include_tax: (
|
|
2105
|
+
is_price_include_tax: (_ref11 = (_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 && _ref11 !== void 0 ? _ref11 : 1
|
|
2112
2106
|
}, snapshot.identity.orderId ? {
|
|
2113
2107
|
payment_order_id: String(snapshot.identity.orderId)
|
|
2114
2108
|
} : {});
|
|
@@ -2224,7 +2218,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2224
2218
|
key: "sendCustomerPayLink",
|
|
2225
2219
|
value: (function () {
|
|
2226
2220
|
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2227
|
-
var orderIds,
|
|
2221
|
+
var orderIds, _ref12, _ref13, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
2228
2222
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2229
2223
|
while (1) switch (_context22.prev = _context22.next) {
|
|
2230
2224
|
case 0:
|
|
@@ -2245,7 +2239,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2245
2239
|
});
|
|
2246
2240
|
case 6:
|
|
2247
2241
|
submitResult = _context22.sent;
|
|
2248
|
-
orderId = (
|
|
2242
|
+
orderId = (_ref12 = (_ref13 = (_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 && _ref13 !== void 0 ? _ref13 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref12 !== void 0 ? _ref12 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
2249
2243
|
if (orderId) {
|
|
2250
2244
|
_context22.next = 10;
|
|
2251
2245
|
break;
|
|
@@ -2646,14 +2640,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2646
2640
|
key: "setOtherParams",
|
|
2647
2641
|
value: function () {
|
|
2648
2642
|
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
2649
|
-
var
|
|
2650
|
-
|
|
2643
|
+
var _ref14,
|
|
2644
|
+
_ref14$cover,
|
|
2651
2645
|
cover,
|
|
2652
2646
|
_args31 = arguments;
|
|
2653
2647
|
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2654
2648
|
while (1) switch (_context31.prev = _context31.next) {
|
|
2655
2649
|
case 0:
|
|
2656
|
-
|
|
2650
|
+
_ref14 = _args31.length > 1 && _args31[1] !== undefined ? _args31[1] : {}, _ref14$cover = _ref14.cover, cover = _ref14$cover === void 0 ? false : _ref14$cover;
|
|
2657
2651
|
if (cover) {
|
|
2658
2652
|
this.otherParams = params;
|
|
2659
2653
|
} else {
|
|
@@ -145,7 +145,6 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
145
145
|
duration: payload.duration,
|
|
146
146
|
policy_id: payload.policy_id,
|
|
147
147
|
source_shop_id: payload.source_shop_id,
|
|
148
|
-
origin: origin,
|
|
149
148
|
source_product_price: sourceProductPrice,
|
|
150
149
|
main_product_selling_price: mainProductSellingPrice,
|
|
151
150
|
main_product_original_price: mainProductOriginalPrice,
|
|
@@ -2760,7 +2760,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2760
2760
|
break;
|
|
2761
2761
|
}
|
|
2762
2762
|
_context36.next = 67;
|
|
2763
|
-
return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.
|
|
2763
|
+
return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getSalesOrderByLookup({
|
|
2764
|
+
lookup: tempOrder.order_id
|
|
2765
|
+
});
|
|
2764
2766
|
case 67:
|
|
2765
2767
|
res = _context36.sent;
|
|
2766
2768
|
// 找到下单的时候输入的 entryPaxNumber
|
|
@@ -346,7 +346,8 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
346
346
|
);
|
|
347
347
|
const maxDeduction = import_decimal.default.min(
|
|
348
348
|
new import_decimal.default(usageAmount),
|
|
349
|
-
new import_decimal.default(maxDeductionAmount)
|
|
349
|
+
new import_decimal.default(maxDeductionAmount),
|
|
350
|
+
remainingOrderAmount
|
|
350
351
|
);
|
|
351
352
|
let deductionLeft = maxDeduction;
|
|
352
353
|
const deductionDetails = [];
|
|
@@ -488,7 +489,7 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
488
489
|
});
|
|
489
490
|
return;
|
|
490
491
|
}
|
|
491
|
-
const usageAmount = typeof selectedVoucher.edit_current_amount === "number" ? selectedVoucher.edit_current_amount : getRecommendedAmount(selectedVoucher);
|
|
492
|
+
const usageAmount = typeof selectedVoucher.edit_current_amount === "number" ? selectedVoucher.edit_current_amount : selectedVoucher._available_max_amount ?? getRecommendedAmount(selectedVoucher);
|
|
492
493
|
const maxDeduction = import_decimal.default.min(
|
|
493
494
|
new import_decimal.default(usageAmount),
|
|
494
495
|
new import_decimal.default(maxDeductionAmount),
|
|
@@ -13,7 +13,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
13
13
|
private store;
|
|
14
14
|
private request;
|
|
15
15
|
private logger;
|
|
16
|
-
private dbManager;
|
|
17
16
|
private window;
|
|
18
17
|
private cacheId;
|
|
19
18
|
private salesSummaryModuleName;
|
|
@@ -134,11 +133,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
134
133
|
private ensureExternalSaleNumber;
|
|
135
134
|
private ensureRequestUniqueIdempotencyToken;
|
|
136
135
|
private buildPaymentSyncIdempotencyToken;
|
|
137
|
-
hasLocalDatabase(): boolean;
|
|
138
|
-
private buildLocalOrderRecord;
|
|
139
|
-
getLocalOrderByOrderId(orderId: number | string): Promise<Record<string, any> | null>;
|
|
140
|
-
getLocalOrderByOrderNumber(orderNumber: string): Promise<Record<string, any> | null>;
|
|
141
|
-
getLocalOrderByExternalSaleNumber(externalSaleNumber: string): Promise<Record<string, any> | null>;
|
|
142
136
|
saveDraft(): Promise<void>;
|
|
143
137
|
private saveDraftInBackground;
|
|
144
138
|
private hydrateTempOrderFromLocalRecord;
|
|
@@ -147,8 +141,12 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
147
141
|
private calculatePaymentTotal;
|
|
148
142
|
private normalizePaymentSource;
|
|
149
143
|
private updateTempOrderPaymentStatus;
|
|
144
|
+
private shouldKeepPaymentStatusAfterAmountRecalc;
|
|
145
|
+
private resolveWalletPassUseValue;
|
|
146
|
+
private capVoucherPaymentsByRemainingAmount;
|
|
150
147
|
private calculatePaidPaymentSummary;
|
|
151
148
|
private calculatePaymentServiceFee;
|
|
149
|
+
private calculatePaymentGapAmount;
|
|
152
150
|
private formatSummaryMetadataMoney;
|
|
153
151
|
private syncSummaryProductMetadata;
|
|
154
152
|
private calculateSummaryAmountGap;
|
|
@@ -164,6 +162,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
164
162
|
addNewOrder(): Promise<OrderTempOrder>;
|
|
165
163
|
getOrderProducts(): OrderProduct[];
|
|
166
164
|
private getProductUid;
|
|
165
|
+
private sanitizeOrderProductForTempOrder;
|
|
166
|
+
private sanitizeTempOrderProducts;
|
|
167
167
|
private ensureExtend;
|
|
168
168
|
private captureProductRuntime;
|
|
169
169
|
private createLinkedProductAndBooking;
|
|
@@ -245,7 +245,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
245
245
|
* 提交当前 Sales tempOrder。
|
|
246
246
|
*
|
|
247
247
|
* smallTicketDataFlag 用于 B 端 checkout 小票数据返回。PaymentModal 在支付提交时
|
|
248
|
-
* 应传 1,确保 /order/sales/checkout 返回打印所需数据。
|
|
248
|
+
* 应传 1,确保 /shop/order/sales/checkout 返回打印所需数据。
|
|
249
249
|
*/
|
|
250
250
|
submitTempOrder<T = any>(params?: {
|
|
251
251
|
cacheId?: string;
|
|
@@ -287,7 +287,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
287
287
|
* Checkout 专用:创建订单到后端
|
|
288
288
|
*
|
|
289
289
|
* 专门为 Checkout 模块设计的订单创建方法,
|
|
290
|
-
*
|
|
290
|
+
* 通过 OS Server 调用 checkout 接口创建订单
|
|
291
291
|
* 接收已经处理好的订单数据,无需再处理购物车
|
|
292
292
|
*
|
|
293
293
|
* @param params Checkout 订单参数(已处理的订单数据)
|
|
@@ -302,7 +302,10 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
302
302
|
* OrderModule 只负责校验 order_ids 并调用 /order/batch-email。
|
|
303
303
|
*/
|
|
304
304
|
sendCustomerPayLink<T = any>(params: SendCustomerPayLinkParams): Promise<T>;
|
|
305
|
-
|
|
305
|
+
getSalesOrderByLookup(params: {
|
|
306
|
+
lookup: number | string;
|
|
307
|
+
forceRemote?: boolean;
|
|
308
|
+
}): Promise<any>;
|
|
306
309
|
/**
|
|
307
310
|
* 把 sqlite / 后端返回的订单记录直接恢复为 tempOrder。
|
|
308
311
|
*
|