@pisell/pisellos 2.3.108 → 2.3.109
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.
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// 导出评估器
|
|
2
|
-
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
-
|
|
4
|
-
// 导出适配器
|
|
5
|
-
export { PromotionAdapter } from "./adapter";
|
|
6
|
-
export { default } from "./adapter";
|
|
7
|
-
|
|
8
|
-
// 导出策略配置示例常量
|
|
9
|
-
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -5293,8 +5293,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5293
5293
|
key: "confirmWalletPayment",
|
|
5294
5294
|
value: (function () {
|
|
5295
5295
|
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
|
|
5296
|
-
var _this$store$order$get3, _this$store$order14, _this$store$order$
|
|
5297
|
-
var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
|
|
5296
|
+
var _this$store$order$get3, _this$store$order14, _this$store$order$get5, _this$store$order$get6, _this$store$order16;
|
|
5297
|
+
var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get4, _this$store$order15, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
|
|
5298
5298
|
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5299
5299
|
while (1) switch (_context53.prev = _context53.next) {
|
|
5300
5300
|
case 0:
|
|
@@ -5306,83 +5306,103 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5306
5306
|
case 2:
|
|
5307
5307
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
5308
5308
|
pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
|
|
5309
|
+
amountSnapshot = (_this$store$order$get3 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order14);
|
|
5309
5310
|
if (!pendingWalletAmount.lte(0)) {
|
|
5310
|
-
_context53.next =
|
|
5311
|
+
_context53.next = 14;
|
|
5311
5312
|
break;
|
|
5312
5313
|
}
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5314
|
+
this.logWarning('confirmWalletPayment: 未发现待确认 Wallet 支付,跳过 Wallet 确认并按普通订单提交', {
|
|
5315
|
+
amountGap: amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap
|
|
5316
|
+
});
|
|
5317
|
+
_context53.next = 9;
|
|
5318
|
+
return this.submitSalesOrder({
|
|
5319
|
+
smallTicketDataFlag: 1
|
|
5320
|
+
});
|
|
5321
|
+
case 9:
|
|
5322
|
+
_submitResult = _context53.sent;
|
|
5323
|
+
if (!isRejectedSalesSubmitResult(_submitResult)) {
|
|
5324
|
+
_context53.next = 12;
|
|
5325
|
+
break;
|
|
5326
|
+
}
|
|
5327
|
+
throw new Error(getSalesSubmitErrorMessage(_submitResult, '订单提交失败'));
|
|
5328
|
+
case 12:
|
|
5329
|
+
_latestAmountSnapshot = (_this$store$order$get4 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order15);
|
|
5330
|
+
return _context53.abrupt("return", {
|
|
5331
|
+
submitResult: _submitResult,
|
|
5332
|
+
payments: this.store.order.getOrderPayments(),
|
|
5333
|
+
isOrderFullyPaid: new Decimal((_latestAmountSnapshot === null || _latestAmountSnapshot === void 0 ? void 0 : _latestAmountSnapshot.amountGap) || 0).lte(0)
|
|
5334
|
+
});
|
|
5335
|
+
case 14:
|
|
5316
5336
|
effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
5317
5337
|
if (!effectiveAmountDue.gt(0.01)) {
|
|
5318
|
-
_context53.next =
|
|
5338
|
+
_context53.next = 17;
|
|
5319
5339
|
break;
|
|
5320
5340
|
}
|
|
5321
5341
|
throw new Error('Wallet 支付尚未覆盖全部待支付金额');
|
|
5322
|
-
case
|
|
5323
|
-
beforePaymentStatus = (_this$store$order$
|
|
5324
|
-
_context53.prev =
|
|
5325
|
-
_context53.next =
|
|
5342
|
+
case 17:
|
|
5343
|
+
beforePaymentStatus = (_this$store$order$get5 = this.store.order.getTempOrder()) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.payment_status;
|
|
5344
|
+
_context53.prev = 18;
|
|
5345
|
+
_context53.next = 21;
|
|
5326
5346
|
return this.submitSalesOrder({
|
|
5327
5347
|
smallTicketDataFlag: 1,
|
|
5328
5348
|
confirmPendingVoucherPayments: true
|
|
5329
5349
|
});
|
|
5330
|
-
case
|
|
5350
|
+
case 21:
|
|
5331
5351
|
submitResult = _context53.sent;
|
|
5332
5352
|
if (!isRejectedSalesSubmitResult(submitResult)) {
|
|
5333
|
-
_context53.next =
|
|
5353
|
+
_context53.next = 24;
|
|
5334
5354
|
break;
|
|
5335
5355
|
}
|
|
5336
5356
|
throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
|
|
5337
|
-
case
|
|
5338
|
-
_context53.next =
|
|
5357
|
+
case 24:
|
|
5358
|
+
_context53.next = 34;
|
|
5339
5359
|
break;
|
|
5340
|
-
case
|
|
5341
|
-
_context53.prev =
|
|
5342
|
-
_context53.t0 = _context53["catch"](
|
|
5360
|
+
case 26:
|
|
5361
|
+
_context53.prev = 26;
|
|
5362
|
+
_context53.t0 = _context53["catch"](18);
|
|
5343
5363
|
this.store.order.setOrderPayments(beforePayments);
|
|
5344
5364
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
5345
5365
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
5346
5366
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
5347
5367
|
this.store.order.persistTempOrder();
|
|
5348
5368
|
}
|
|
5349
|
-
_context53.next =
|
|
5369
|
+
_context53.next = 33;
|
|
5350
5370
|
return this.store.order.recalculateSummary({
|
|
5351
5371
|
createIfMissing: true
|
|
5352
5372
|
});
|
|
5353
|
-
case
|
|
5373
|
+
case 33:
|
|
5354
5374
|
throw _context53.t0;
|
|
5355
|
-
case
|
|
5375
|
+
case 34:
|
|
5356
5376
|
if (!this.store.payment) {
|
|
5357
|
-
_context53.next =
|
|
5377
|
+
_context53.next = 45;
|
|
5358
5378
|
break;
|
|
5359
5379
|
}
|
|
5360
|
-
_context53.prev =
|
|
5380
|
+
_context53.prev = 35;
|
|
5361
5381
|
committed = this.getCommittedWalletAssets();
|
|
5362
5382
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
5363
|
-
_context53.next =
|
|
5383
|
+
_context53.next = 40;
|
|
5364
5384
|
return this.publishWalletAssetsState(walletState, 'local');
|
|
5365
|
-
case
|
|
5366
|
-
_context53.next =
|
|
5385
|
+
case 40:
|
|
5386
|
+
_context53.next = 45;
|
|
5367
5387
|
break;
|
|
5368
|
-
case
|
|
5369
|
-
_context53.prev =
|
|
5370
|
-
_context53.t1 = _context53["catch"](
|
|
5388
|
+
case 42:
|
|
5389
|
+
_context53.prev = 42;
|
|
5390
|
+
_context53.t1 = _context53["catch"](35);
|
|
5371
5391
|
this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
|
|
5372
5392
|
error: _context53.t1 instanceof Error ? _context53.t1.message : String(_context53.t1)
|
|
5373
5393
|
});
|
|
5374
|
-
case
|
|
5375
|
-
latestAmountSnapshot = (_this$store$order$
|
|
5394
|
+
case 45:
|
|
5395
|
+
latestAmountSnapshot = (_this$store$order$get6 = (_this$store$order16 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.call(_this$store$order16);
|
|
5376
5396
|
return _context53.abrupt("return", {
|
|
5377
5397
|
submitResult: submitResult,
|
|
5378
5398
|
payments: this.store.order.getOrderPayments(),
|
|
5379
5399
|
isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
|
|
5380
5400
|
});
|
|
5381
|
-
case
|
|
5401
|
+
case 47:
|
|
5382
5402
|
case "end":
|
|
5383
5403
|
return _context53.stop();
|
|
5384
5404
|
}
|
|
5385
|
-
}, _callee53, this, [[
|
|
5405
|
+
}, _callee53, this, [[18, 26], [35, 42]]);
|
|
5386
5406
|
}));
|
|
5387
5407
|
function confirmWalletPayment() {
|
|
5388
5408
|
return _confirmWalletPayment.apply(this, arguments);
|
|
@@ -5398,7 +5418,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5398
5418
|
key: "payCash",
|
|
5399
5419
|
value: (function () {
|
|
5400
5420
|
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
|
|
5401
|
-
var _this$store$order$
|
|
5421
|
+
var _this$store$order$get7, _params$actualPaidAmo, _this$otherParams35, _this$window, _this$window$postMess;
|
|
5402
5422
|
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
5403
5423
|
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5404
5424
|
while (1) switch (_context54.prev = _context54.next) {
|
|
@@ -5442,7 +5462,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5442
5462
|
throw new Error('现金支付金额超过当前待支付金额');
|
|
5443
5463
|
case 17:
|
|
5444
5464
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
5445
|
-
beforePaymentStatus = (_this$store$order$
|
|
5465
|
+
beforePaymentStatus = (_this$store$order$get7 = this.store.order.getTempOrder()) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.payment_status;
|
|
5446
5466
|
uniquePaymentNumber = createUuidV4();
|
|
5447
5467
|
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5448
5468
|
actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
|
|
@@ -5553,7 +5573,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5553
5573
|
key: "commitPaymentMethodPayment",
|
|
5554
5574
|
value: (function () {
|
|
5555
5575
|
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
5556
|
-
var _this$store$order$
|
|
5576
|
+
var _this$store$order$get8, _this$store$order17, _this$store$order$get9, _params$metadata, _params$originAmount;
|
|
5557
5577
|
var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
5558
5578
|
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5559
5579
|
while (1) switch (_context55.prev = _context55.next) {
|
|
@@ -5597,7 +5617,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5597
5617
|
}
|
|
5598
5618
|
throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
|
|
5599
5619
|
case 15:
|
|
5600
|
-
amountSnapshot = (_this$store$order$
|
|
5620
|
+
amountSnapshot = (_this$store$order$get8 = (_this$store$order17 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.call(_this$store$order17);
|
|
5601
5621
|
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
5602
5622
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
5603
5623
|
if (!amountDue.lte(0)) {
|
|
@@ -5613,7 +5633,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5613
5633
|
throw new Error('支付金额超过当前待支付金额');
|
|
5614
5634
|
case 22:
|
|
5615
5635
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
5616
|
-
beforePaymentStatus = (_this$store$order$
|
|
5636
|
+
beforePaymentStatus = (_this$store$order$get9 = this.store.order.getTempOrder()) === null || _this$store$order$get9 === void 0 ? void 0 : _this$store$order$get9.payment_status;
|
|
5617
5637
|
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5618
5638
|
metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
|
|
5619
5639
|
unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
|
|
@@ -6398,16 +6418,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6398
6418
|
}, {
|
|
6399
6419
|
key: "getUnfulfilledPromotions",
|
|
6400
6420
|
value: function getUnfulfilledPromotions() {
|
|
6401
|
-
var _this$store$
|
|
6402
|
-
return ((_this$store$
|
|
6421
|
+
var _this$store$order18;
|
|
6422
|
+
return ((_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 ? void 0 : _this$store$order18.getUnfulfilledPromotions()) || [];
|
|
6403
6423
|
}
|
|
6404
6424
|
|
|
6405
6425
|
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
6406
6426
|
}, {
|
|
6407
6427
|
key: "getLastGiftActions",
|
|
6408
6428
|
value: function getLastGiftActions() {
|
|
6409
|
-
var _this$store$
|
|
6410
|
-
return ((_this$store$
|
|
6429
|
+
var _this$store$order19;
|
|
6430
|
+
return ((_this$store$order19 = this.store.order) === null || _this$store$order19 === void 0 ? void 0 : _this$store$order19.getLastGiftActions()) || null;
|
|
6411
6431
|
}
|
|
6412
6432
|
|
|
6413
6433
|
// 获取商品列表
|
|
@@ -1 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _adapter.PromotionAdapter;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _evaluator.PromotionEvaluator;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "default", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _adapter.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var _evaluator = require("./evaluator");
|
|
43
|
+
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
+
var _examples = require("./examples");
|
|
45
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -3282,10 +3282,24 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3282
3282
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3283
3283
|
const beforePayments = (0, _lodashEs.cloneDeep)(this.store.order.getOrderPayments());
|
|
3284
3284
|
const pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
|
|
3285
|
+
const amountSnapshot = this.store.order.getOrderAmountSnapshot?.();
|
|
3285
3286
|
if (pendingWalletAmount.lte(0)) {
|
|
3286
|
-
|
|
3287
|
+
this.logWarning('confirmWalletPayment: 未发现待确认 Wallet 支付,跳过 Wallet 确认并按普通订单提交', {
|
|
3288
|
+
amountGap: amountSnapshot?.amountGap
|
|
3289
|
+
});
|
|
3290
|
+
const submitResult = await this.submitSalesOrder({
|
|
3291
|
+
smallTicketDataFlag: 1
|
|
3292
|
+
});
|
|
3293
|
+
if (isRejectedSalesSubmitResult(submitResult)) {
|
|
3294
|
+
throw new Error(getSalesSubmitErrorMessage(submitResult, '订单提交失败'));
|
|
3295
|
+
}
|
|
3296
|
+
const latestAmountSnapshot = this.store.order.getOrderAmountSnapshot?.();
|
|
3297
|
+
return {
|
|
3298
|
+
submitResult,
|
|
3299
|
+
payments: this.store.order.getOrderPayments(),
|
|
3300
|
+
isOrderFullyPaid: new _decimal.default(latestAmountSnapshot?.amountGap || 0).lte(0)
|
|
3301
|
+
};
|
|
3287
3302
|
}
|
|
3288
|
-
const amountSnapshot = this.store.order.getOrderAmountSnapshot?.();
|
|
3289
3303
|
const effectiveAmountDue = _decimal.default.max(new _decimal.default(amountSnapshot?.amountGap || 0).minus(pendingWalletAmount), 0);
|
|
3290
3304
|
if (effectiveAmountDue.gt(0.01)) {
|
|
3291
3305
|
throw new Error('Wallet 支付尚未覆盖全部待支付金额');
|