Browse Source

fix(wechatpay): 增加提现单状态校验逻辑

- 在更新提现单状态前增加状态检查
- 当前提现单状态非 APPLYING 时抛出逻辑异常- 防止非法操作导致的数据状态异常
runphp 4 tháng trước cách đây
mục cha
commit
dec96a9de7
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 4 0
      src/Entity/WechatpayTransferBillEntity.php

+ 4 - 0
src/Entity/WechatpayTransferBillEntity.php

@@ -9,6 +9,7 @@ use SixShop\WechatPay\Event\TransferBillFailedEvent;
 use think\facade\Db;
 use think\facade\Event;
 use think\Paginator;
+use function SixShop\Core\throw_logic_exception;
 
 /**
  * @mixin \SixShop\WechatPay\Model\WechatpayTransferBillModel
@@ -45,6 +46,9 @@ class WechatpayTransferBillEntity extends BaseEntity
         if ($transferBill->isEmpty()) {
             throw new Exception('提现单不存在');
         }
+        if ($transferBill->state !== TransferBillStatusEnum::APPLYING) {
+            throw_logic_exception('非法操作');
+        }
         $transferBill->state = TransferBillStatusEnum::FAIL;
         $transferBill->fail_reason = $failReason;
         Db::transaction(function () use ($transferBill) {