@pisell/pisellos 0.0.196 → 0.0.200
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.
|
@@ -1245,30 +1245,41 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1245
1245
|
_context15.next = 8;
|
|
1246
1246
|
return this.dbManager.update('order', order);
|
|
1247
1247
|
case 8:
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1248
|
+
if (!(paymentData.payments.length === 0)) {
|
|
1249
|
+
_context15.next = 12;
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
console.log("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u5217\u8868\u4E3A\u7A7A\uFF0C\u8DF3\u8FC7\u961F\u5217\u63A8\u9001"));
|
|
1253
|
+
this.logWarning('Empty payment queue submission', {
|
|
1254
|
+
orderUuid: order.uuid,
|
|
1255
|
+
orderId: order.order_info.order_id
|
|
1256
|
+
});
|
|
1257
|
+
return _context15.abrupt("return");
|
|
1253
1258
|
case 12:
|
|
1254
1259
|
_context15.next = 14;
|
|
1260
|
+
return this.addToSyncQueue(order, paymentData);
|
|
1261
|
+
case 14:
|
|
1262
|
+
_context15.next = 16;
|
|
1263
|
+
return this.core.effects.emit(PaymentHooks.OnPaymentSubmitted, order);
|
|
1264
|
+
case 16:
|
|
1265
|
+
_context15.next = 18;
|
|
1255
1266
|
return this.core.effects.emit(PaymentHooks.OnOrderChanged, {
|
|
1256
1267
|
action: 'submit',
|
|
1257
1268
|
order: order
|
|
1258
1269
|
});
|
|
1259
|
-
case
|
|
1260
|
-
_context15.next =
|
|
1270
|
+
case 18:
|
|
1271
|
+
_context15.next = 24;
|
|
1261
1272
|
break;
|
|
1262
|
-
case
|
|
1263
|
-
_context15.prev =
|
|
1273
|
+
case 20:
|
|
1274
|
+
_context15.prev = 20;
|
|
1264
1275
|
_context15.t0 = _context15["catch"](0);
|
|
1265
1276
|
console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"), _context15.t0);
|
|
1266
1277
|
throw _context15.t0;
|
|
1267
|
-
case
|
|
1278
|
+
case 24:
|
|
1268
1279
|
case "end":
|
|
1269
1280
|
return _context15.stop();
|
|
1270
1281
|
}
|
|
1271
|
-
}, _callee15, this, [[0,
|
|
1282
|
+
}, _callee15, this, [[0, 20]]);
|
|
1272
1283
|
}));
|
|
1273
1284
|
function submitSingleOrderPayment(_x19) {
|
|
1274
1285
|
return _submitSingleOrderPayment.apply(this, arguments);
|
|
@@ -317,7 +317,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
317
317
|
|
|
318
318
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
319
319
|
sortedProductList.forEach(function (originProduct, i) {
|
|
320
|
-
var _product$discount_lis4, _product$discount_lis5, _product$
|
|
320
|
+
var _product$discount_lis4, _product$discount_lis5, _product$discount_lis7, _product$discount_lis8, _product$discount_lis9, _product$discount_lis10;
|
|
321
321
|
var product = _this3.hooks.getProduct(originProduct);
|
|
322
322
|
if (product !== null && product !== void 0 && product.booking_id && (_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.length && product !== null && product !== void 0 && (_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.every(function (discount) {
|
|
323
323
|
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
|
|
@@ -328,11 +328,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
328
328
|
|
|
329
329
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
330
330
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
331
|
+
var _product$discount_lis6;
|
|
331
332
|
// 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
|
|
332
333
|
// 商品券时主商品价格为0不可用
|
|
333
334
|
if ((Number(product.price) === 0 || !product.price) && (discount.tag || discount.type) === 'good_pass') return false;
|
|
334
335
|
// 折扣卡时总价为0时不可用
|
|
335
|
-
if ((Number(product.total) === 0 || !product.total) && (
|
|
336
|
+
if ((Number(product.total) === 0 || !product.total) && !((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.find(function (n) {
|
|
337
|
+
var _n$discount;
|
|
338
|
+
return ((_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.resource_id) === discount.id;
|
|
339
|
+
})) && (discount.tag || discount.type) !== 'good_pass') return false;
|
|
336
340
|
// 如果优惠券已被使用,则跳过
|
|
337
341
|
var targetUsedDiscounts = usedDiscounts.get(discount.id);
|
|
338
342
|
if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
|
|
@@ -356,12 +360,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
356
360
|
var selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
|
|
357
361
|
|
|
358
362
|
// 如果是手动折扣,则不适用优惠券
|
|
359
|
-
var isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (!((_product$
|
|
363
|
+
var isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (!((_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.length) || (product === null || product === void 0 || (_product$discount_lis8 = product.discount_list) === null || _product$discount_lis8 === void 0 || (_product$discount_lis9 = _product$discount_lis8.every) === null || _product$discount_lis9 === void 0 ? void 0 : _product$discount_lis9.call(_product$discount_lis8, function (item) {
|
|
360
364
|
return item.type === 'product';
|
|
361
365
|
})));
|
|
362
366
|
|
|
363
367
|
// 勾选时覆盖手动折扣
|
|
364
|
-
if (options !== null && options !== void 0 && options.discountId && (_product$
|
|
368
|
+
if (options !== null && options !== void 0 && options.discountId && (_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.some(function (item) {
|
|
365
369
|
var _item$discount;
|
|
366
370
|
return ((_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) === options.discountId;
|
|
367
371
|
})) {
|
|
@@ -423,7 +427,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
423
427
|
}));
|
|
424
428
|
}
|
|
425
429
|
for (var _i = 0; _i < splitCount; _i++) {
|
|
426
|
-
var _originProduct$_produ, _product$
|
|
430
|
+
var _originProduct$_produ, _product$discount_lis11;
|
|
427
431
|
// 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
|
|
428
432
|
var _selectedDiscount = selectedDiscountCard || applicableDiscounts[_i];
|
|
429
433
|
// 标记优惠券为已使用
|
|
@@ -439,7 +443,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
439
443
|
productOriginTotal = product.total;
|
|
440
444
|
}
|
|
441
445
|
// 如果当前 product 有 discount_list,则必须从 origin_total 拿
|
|
442
|
-
if ((_product$
|
|
446
|
+
if ((_product$discount_lis11 = product.discount_list) !== null && _product$discount_lis11 !== void 0 && _product$discount_lis11.length && product.origin_total) {
|
|
443
447
|
productOriginTotal = product.origin_total;
|
|
444
448
|
}
|
|
445
449
|
|
|
@@ -588,6 +588,14 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
588
588
|
}
|
|
589
589
|
paymentData.payment_status = order.payment_status === import_types.PaymentStatus.Finished ? "paid" : "partially_paid";
|
|
590
590
|
await this.dbManager.update("order", order);
|
|
591
|
+
if (paymentData.payments.length === 0) {
|
|
592
|
+
console.log(`[PaymentModule] 订单 ${order.uuid} 支付列表为空,跳过队列推送`);
|
|
593
|
+
this.logWarning("Empty payment queue submission", {
|
|
594
|
+
orderUuid: order.uuid,
|
|
595
|
+
orderId: order.order_info.order_id
|
|
596
|
+
});
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
591
599
|
await this.addToSyncQueue(order, paymentData);
|
|
592
600
|
await this.core.effects.emit(import_types.PaymentHooks.OnPaymentSubmitted, order);
|
|
593
601
|
await this.core.effects.emit(import_types.PaymentHooks.OnOrderChanged, {
|
|
@@ -214,9 +214,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
214
214
|
return;
|
|
215
215
|
}
|
|
216
216
|
const applicableDiscounts = sortedDiscountList.filter((discount) => {
|
|
217
|
+
var _a2;
|
|
217
218
|
if ((Number(product.price) === 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
|
|
218
219
|
return false;
|
|
219
|
-
if ((Number(product.total) === 0 || !product.total) && (
|
|
220
|
+
if ((Number(product.total) === 0 || !product.total) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
|
|
221
|
+
var _a3;
|
|
222
|
+
return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
|
|
223
|
+
})) && (discount.tag || discount.type) !== "good_pass")
|
|
220
224
|
return false;
|
|
221
225
|
const targetUsedDiscounts = usedDiscounts.get(discount.id);
|
|
222
226
|
if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
|