feat(PaymentLogic): 简化支付逻辑,移除多余的异常处理

This commit is contained in:
mkm 2024-06-05 09:45:51 +08:00
parent a5953e3170
commit aba84bb920

View File

@ -7,9 +7,7 @@ namespace app\common\logic;
use app\common\enum\PayEnum;
use app\common\model\user\UserAuth;
use app\common\service\pay\PayService;
use Illuminate\Support\Facades\Log;
use Yansongda\Artful\Exception\Exception as ExceptionException;
use Yansongda\Pay\Exception\Exception;
use Exception;
use function DI\string;
@ -57,19 +55,15 @@ class PaymentLogic extends BaseLogic
'attach' => $from
];
$wechat = new PayService(1);
// 尝试执行可能会抛出异常的代码
$result = $wechat->wechat->mini($order)->toArray();
\support\Log::info(json_encode($result));
$result = $wechat->wechat->mini($order)->toArray();
break;
default:
self::$error = '订单异常';
$result = false;
}
} catch (ExceptionException $e) {
\support\Log::info($e->getMessage());
throw new \Exception($e->getMessage());
} catch (Exception $e) {
\support\Log::info($e->extra['message']);
throw new \Exception($e->extra['message']);
}
return $result;
}
@ -103,7 +97,7 @@ class PaymentLogic extends BaseLogic
$wechat = new PayService(1);
try {
$result = $wechat->wechat->pos($order)->toArray();
} catch (ExceptionException $e) {
} catch (Exception $e) {
if (getenv('APP_DEBUG') == true) {
self::$error = $e->extra['message'] ?? $e->getMessage();
} else {
@ -135,7 +129,7 @@ class PaymentLogic extends BaseLogic
$wechat = new PayService();
try {
$result = $wechat->alipay->pos($order)->toArray();
} catch (ExceptionException $e) {
} catch (Exception $e) {
if (getenv('APP_DEBUG') == true) {
self::$error = $e->extra['message'] ?? $e->getMessage();
} else {