diff --git a/app/AdminAgent/Extensions/Grid/AuditRefund.php b/app/AdminAgent/Extensions/Grid/AuditRefund.php index fb23e37..4398b34 100644 --- a/app/AdminAgent/Extensions/Grid/AuditRefund.php +++ b/app/AdminAgent/Extensions/Grid/AuditRefund.php @@ -2,6 +2,7 @@ namespace App\AdminAgent\Extensions\Grid; use App\Common\OrderStatus; +use App\Models\AdminSetting; use App\Models\Order; use App\Models\UserMoneyLog; use Dcat\Admin\Admin; @@ -64,12 +65,17 @@ class AuditRefund extends RowAction throw new \Exception('未查询到该笔订单的支付信息,退款失败'); } + $setting = AdminSetting::val(['payee_appid', 'payee_mchid', 'payee_mchkey']); + if (!isset($setting['payee_appid'], $setting['payee_mchid'], $setting['payee_mchkey'])) { + return $this->response()->error('获取系统配置失败'); + } + //将微信发起退款申请 $config = config('wechat.payment.default'); $config = array_merge($config, [ - 'app_id' => 'wxb35ef055a4dd8ad4', - 'mch_id' => '1606181693', - 'key' => 'lfyyhyz8888888888888888888888888', + 'app_id' => $setting['payee_appid'], + 'mch_id' => $setting['payee_mchid'], + 'key' => $setting['payee_mchkey'], 'notify_url' => route('wxpay_refund', $agent->id), 'cert_path' => env('WECHAT_CERT'), 'key_path' => env('WECHAT_KEY'), diff --git a/app/Http/Controllers/Api/SharePayController.php b/app/Http/Controllers/Api/SharePayController.php index 246a3ce..9bf6412 100644 --- a/app/Http/Controllers/Api/SharePayController.php +++ b/app/Http/Controllers/Api/SharePayController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api; use App\Common\OrderStatus as Status; use App\Common\PayType; use App\Http\Controllers\Controller; +use App\Models\AdminSetting; use App\Models\Agent; use App\Models\AgentProduct; use App\Models\Order; @@ -56,11 +57,16 @@ class SharePayController extends Controller $price = $this->calc($order->price, $order->num, $order->pay_type, $order->agentProduct); } + $setting = AdminSetting::val(['payee_appid', 'payee_mchid', 'payee_mchkey']); + if (!isset($setting['payee_appid'], $setting['payee_mchid'], $setting['payee_mchkey'])) { + return $this->error('获取系统配置失败'); + } + $config = config('wechat.payment.default'); $config = array_merge($config, [ - 'app_id' => 'wxb35ef055a4dd8ad4', - 'mch_id' => '1606181693', - 'key' => 'lfyyhyz8888888888888888888888888', + 'app_id' => $setting['payee_appid'], + 'mch_id' => $setting['payee_mchid'], + 'key' => $setting['payee_mchkey'], ]); $app = Factory::payment($config); diff --git a/app/Http/Controllers/Api/WxpayController.php b/app/Http/Controllers/Api/WxpayController.php index 626bec9..f84494e 100644 --- a/app/Http/Controllers/Api/WxpayController.php +++ b/app/Http/Controllers/Api/WxpayController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Api; use App\Common\PayType; +use App\Models\AdminSetting; use App\Models\Agent; use App\Models\AgentProduct; use App\Models\AgentSetting; @@ -20,13 +21,18 @@ class WxpayController public function notify() { $agent_id = request()->route('agent_id'); - $agent = Agent::find($agent_id); +// $agent = Agent::find($agent_id); + + $setting = AdminSetting::val(['payee_appid', 'payee_mchid', 'payee_mchkey']); + if (!isset($setting['payee_appid'], $setting['payee_mchid'], $setting['payee_mchkey'])) { + return '获取系统配置失败'; + } $config = config('wechat.payment.default'); $config = array_merge($config, [ - 'app_id' => $agent->appid, - 'mch_id' => $agent->mchid, - 'key' => $agent->mchkey, + 'app_id' => $setting['payee_appid'], + 'mch_id' => $setting['payee_mchid'], + 'key' => $setting['payee_mchkey'], ]); $app = Factory::payment($config); try { @@ -147,11 +153,16 @@ class WxpayController $agent_id = request()->route('agent_id'); // $agent = Agent::find($agent_id); + $setting = AdminSetting::val(['payee_appid', 'payee_mchid', 'payee_mchkey']); + if (!isset($setting['payee_appid'], $setting['payee_mchid'], $setting['payee_mchkey'])) { + return '获取系统配置失败'; + } + $config = config('wechat.payment.default'); $config = array_merge($config, [ - 'app_id' => 'wxb35ef055a4dd8ad4', - 'mch_id' => '1606181693', - 'key' => 'lfyyhyz8888888888888888888888888', + 'app_id' => $setting['payee_appid'], + 'mch_id' => $setting['payee_mchid'], + 'key' => $setting['payee_mchkey'], ]); $app = Factory::payment($config); try {