Browse Source

Merge branch 'develop' of ssh://8.134.10.79:222/Leadfyy.co/hainan into develop

develop
lemon 4 years ago
parent
commit
20e853775e
  1. 23
      app/Admin/Controllers/SettingController.php
  2. 52
      app/Admin/Forms/Setting.php
  3. 3
      app/Admin/routes.php
  4. 12
      app/AdminAgent/Extensions/Grid/AuditRefund.php
  5. 12
      app/Http/Controllers/Api/SharePayController.php
  6. 25
      app/Http/Controllers/Api/WxpayController.php
  7. 20
      app/Models/AdminSetting.php

23
app/Admin/Controllers/SettingController.php

@ -0,0 +1,23 @@
<?php
namespace App\Admin\Controllers;
use App\Admin\Forms\Setting;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Widgets\Card;
/**
* 系统设置
* Class SettingController
* @package App\Admin\Controllers
*/
class SettingController extends AdminController
{
public function index(Content $content)
{
return $content
->title('系统设置')
->body(new Card(new Setting()));
}
}

52
app/Admin/Forms/Setting.php

@ -0,0 +1,52 @@
<?php
namespace App\Admin\Forms;
use Dcat\Admin\Widgets\Form;
class Setting extends Form
{
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
// dump($input);
// return $this->response()->error('Your error message.');
admin_setting($input);
return $this->response()->success('保存成功')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->tab('支付小程序配置', function () {
$this->text('payee_appid', '收款小程序APPID')->required();
$this->text('payee_appsecret', '收款小程序APP_SECRET')->required();
$this->text('payee_mchid', '收款小程序MCH_ID')->required();
$this->text('payee_mchkey', '收款小程序MCH_KEY')->required();
})->tab('小程序服务商配置', function () {
$this->text('service_appid', '小程序第三方平台APPID');
$this->text('service_appsecret', '小程序第三方平台APP_SECRET');
$this->text('service_binding_appid', '绑定小程序APPID');
});
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
return admin_setting()->toArray();
}
}

3
app/Admin/routes.php

@ -36,4 +36,7 @@ Route::group([
$router->resource('product_statistics', 'ProductStatisticsController');
$router->resource('agent_statistics', 'AgentStatisticsController');
$router->resource('supplier_statistics', 'SupplierStatisticsController');
$router->resource('setting', 'SettingController');
$router->resource('mini_program', 'MiniProgramController');
});

12
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'),

12
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);

25
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 {

20
app/Models/AdminSetting.php

@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AdminSetting extends Model
{
use HasFactory;
public static function val($slug)
{
if (is_array($slug)) {
return static::query()->whereIn('slug', $slug)->pluck('value', 'slug')->toArray() ?? [];
} else {
return static::query()->where('slug', $slug)->value('value') ?? null;
}
}
}
Loading…
Cancel
Save