fix:网站设置/基本设置/支付设置/验证码设置
This commit is contained in:
@@ -52,6 +52,26 @@ class SystemInit extends Command
|
||||
private function config_data(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'slug' => 'web_site_title',
|
||||
'value' => '蚂蚁快链-智慧引流工具',
|
||||
'desc' => '网站名称',
|
||||
],
|
||||
[
|
||||
'slug' => 'web_site_logo',
|
||||
'value' => '/image/toplogo.png',
|
||||
'desc' => '网站logo浅色',
|
||||
],
|
||||
[
|
||||
'slug' => 'web_site_bottom_logo',
|
||||
'value' => '/image/toplogo.png',
|
||||
'desc' => '网站logo深色',
|
||||
],
|
||||
[
|
||||
'slug' => 'web_site_customer_service',
|
||||
'value' => '/image/web-qr.png',
|
||||
'desc' => '客服二维码',
|
||||
],
|
||||
[
|
||||
'slug' => 'is_give_vip',
|
||||
'value' => 1,
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms;
|
||||
|
||||
use App\Services\SystemConfig;
|
||||
use Illuminate\Http\Request;
|
||||
use Ugly\Base\Contracts\SimpleForm;
|
||||
|
||||
class PaymentSet implements SimpleForm
|
||||
{
|
||||
public function policy(Request $request): array
|
||||
{
|
||||
return $request->validate([
|
||||
'wechat_pay_app_id' => 'nullable',
|
||||
'wechat_pay_mch_id' => 'nullable',
|
||||
'wechat_pay_secret_key' => 'nullable',
|
||||
'wechat_pay_private_cert' => 'nullable',
|
||||
'wechat_pay_certificate' => 'nullable',
|
||||
]);
|
||||
}
|
||||
|
||||
// 保存
|
||||
public function handle(array $input): void
|
||||
{
|
||||
SystemConfig::set($input);
|
||||
}
|
||||
|
||||
public function default(): array
|
||||
{
|
||||
return [
|
||||
'wechat_pay_app_id' => SystemConfig::get('wechat_pay_app_id'),
|
||||
'wechat_pay_mch_id' => SystemConfig::get('wechat_pay_mch_id'),
|
||||
'wechat_pay_secret_key' => SystemConfig::get('wechat_pay_secret_key'),
|
||||
'wechat_pay_private_cert' => SystemConfig::get('wechat_pay_secret_key'), // 私钥证书
|
||||
'wechat_pay_certificate' => SystemConfig::get('wechat_pay_certificate'), // 公钥证书
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms;
|
||||
|
||||
use App\Services\SystemConfig;
|
||||
use Illuminate\Http\Request;
|
||||
use Ugly\Base\Contracts\SimpleForm;
|
||||
|
||||
class VerifyCode implements SimpleForm
|
||||
{
|
||||
public function policy(Request $request): array
|
||||
{
|
||||
return $request->validate([
|
||||
'verify_code_is_open' => 'nullable|boolen',
|
||||
'send_code_mode' => 'nullable',
|
||||
'ali_sms_key' => 'nullable',
|
||||
'ali_sms_secret' => 'nullable',
|
||||
'ali_sms_sign_name' => 'nullable',
|
||||
|
||||
'mail_from_name' => 'nullable',
|
||||
'mail_host' => 'nullable',
|
||||
'mail_port' => 'nullable',
|
||||
'mail_from_address' => 'nullable',
|
||||
'mail_username' => 'nullable',
|
||||
'mail_password' => 'nullable',
|
||||
]);
|
||||
}
|
||||
|
||||
// 保存
|
||||
public function handle(array $input): void
|
||||
{
|
||||
SystemConfig::set($input);
|
||||
}
|
||||
|
||||
public function default(): array
|
||||
{
|
||||
return [
|
||||
'verify_code_is_open' => SystemConfig::get('verify_code_is_open'), // 开启
|
||||
'send_code_mode' => SystemConfig::get('send_code_mode'), //
|
||||
|
||||
'ali_sms_key' => SystemConfig::get('ali_sms_key'),
|
||||
'ali_sms_secret' => SystemConfig::get('ali_sms_secret'),
|
||||
'ali_sms_sign_name' => SystemConfig::get('ali_sms_sign_name'),
|
||||
|
||||
'mail_from_name' => SystemConfig::get('mail_from_name'),
|
||||
'mail_host' => SystemConfig::get('mail_host'),
|
||||
'mail_port' => SystemConfig::get('mail_port'),
|
||||
'mail_from_address' => SystemConfig::get('mail_from_address'),
|
||||
'mail_username' => SystemConfig::get('mail_username'),
|
||||
'mail_password' => SystemConfig::get('mail_password'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms;
|
||||
|
||||
use App\Services\SystemConfig;
|
||||
use Illuminate\Http\Request;
|
||||
use Ugly\Base\Contracts\SimpleForm;
|
||||
|
||||
class WebSite implements SimpleForm
|
||||
{
|
||||
public function policy(Request $request): array
|
||||
{
|
||||
return $request->validate([
|
||||
'web_site_customer_service' => 'nullable',
|
||||
'web_site_title' => 'nullable',
|
||||
'web_site_logo' => 'nullable',
|
||||
'web_site_bottom_logo' => 'nullable',
|
||||
]);
|
||||
}
|
||||
|
||||
// 保存
|
||||
public function handle(array $input): void
|
||||
{
|
||||
SystemConfig::set($input);
|
||||
}
|
||||
|
||||
public function default(): array
|
||||
{
|
||||
return [
|
||||
'web_site_customer_service' => SystemConfig::get('web_site_customer_service'),
|
||||
'web_site_title' => SystemConfig::get('web_site_title'),
|
||||
'web_site_logo' => SystemConfig::get('web_site_logo'),
|
||||
'web_site_bottom_logo' => SystemConfig::get('web_site_bottom_logo'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,17 @@
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Forms\BaseConfig;
|
||||
use App\Forms\PaymentSet;
|
||||
use App\Forms\VerifyCode;
|
||||
use App\Forms\WebSite;
|
||||
use Ugly\Base\Http\Controllers\SimpleFormController;
|
||||
|
||||
class ConfigController extends SimpleFormController
|
||||
{
|
||||
protected array $form = [
|
||||
'base' => BaseConfig::class,
|
||||
'web_site' => WebSite::class,
|
||||
'payment' => PaymentSet::class,
|
||||
'verify_code' => VerifyCode::class,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -114,19 +114,22 @@ class IndexController extends Controller
|
||||
$configs = [
|
||||
'code_mode' => SystemConfig::get('send_code_mode'),
|
||||
'package' => VipPackage::query()->orderBy('level')->get(['id', 'name', 'price', 'config']),
|
||||
'web_site_customer_service' => SystemConfig::get('web_site_customer_service'),
|
||||
'web_site_title' => SystemConfig::get('web_site_title'),
|
||||
'web_site_logo' => SystemConfig::get('web_site_logo'),
|
||||
'web_site_bottom_logo' => SystemConfig::get('web_site_bottom_logo'),
|
||||
'asset_url' => Storage::url(''), // 图片路径
|
||||
];
|
||||
|
||||
$user = auth('api')->user();
|
||||
if ($user) {
|
||||
// 图片路径
|
||||
$configs['asset_url'] = Storage::url('');
|
||||
// 安全域名
|
||||
// $configs['domains'] = Domain::query()->where('enable', true)->get(['id', 'title']);
|
||||
// 小程序 (区分是否有权限使用平台小程序池)
|
||||
$configs['mini_programs'] = MiniProgram::query()
|
||||
->where(
|
||||
fn($query) => $query->where('user_id', $user->id)
|
||||
->when($user->getPackageConfig('pre_min'), fn($query) => $query->orWhere('is_pre_min', true))
|
||||
fn ($query) => $query->where('user_id', $user->id)
|
||||
->when($user->getPackageConfig('pre_min'), fn ($query) => $query->orWhere('is_pre_min', true))
|
||||
)
|
||||
->get(['id', 'name']);
|
||||
}
|
||||
|
||||
@@ -23,17 +23,26 @@ class LoginRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$code_mode = SystemConfig::get('send_code_mode');
|
||||
$rule = $code_mode == CodeMode::Email->value ? 'email' : 'regex:/^1[3-9]\d{9}$/';
|
||||
|
||||
return [
|
||||
$rules = [
|
||||
'username' => [
|
||||
'required',
|
||||
'exclude_if:username,admin',
|
||||
$rule,
|
||||
'exists:users,username',
|
||||
],
|
||||
'password' => 'required|min:6',
|
||||
];
|
||||
$is_open = SystemConfig::get('verify_code_is_open');
|
||||
if ($is_open) {
|
||||
$code_mode = SystemConfig::get('send_code_mode');
|
||||
$rule = $code_mode == CodeMode::Email->value ? 'email' : 'regex:/^1[3-9]\d{9}$/';
|
||||
|
||||
$rules['username'] = [
|
||||
'required',
|
||||
'exists:users,username',
|
||||
$rule,
|
||||
];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
|
||||
@@ -24,33 +24,50 @@ class RegisterRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$code_mode = SystemConfig::get('send_code_mode');
|
||||
$rule = $code_mode == CodeMode::Email->value ? 'email' : 'regex:/^1[3-9]\d{9}$/';
|
||||
$is_open = SystemConfig::get('verify_code_is_open');
|
||||
if ($is_open) {
|
||||
$code_mode = SystemConfig::get('send_code_mode');
|
||||
$rule = ($code_mode == CodeMode::Email->value) ? 'email' : 'regex:/^1[3-9]\d{9}$/';
|
||||
|
||||
return [
|
||||
'username' => [
|
||||
'required',
|
||||
$rule,
|
||||
'unique:users,username',
|
||||
],
|
||||
'password' => 'required|min:6|confirmed',
|
||||
'captcha' => ['required', function (string $attribute, mixed $value, \Closure $fail) {
|
||||
$test_code = config('services.ali_sms.test_code');
|
||||
if (empty($test_code) || $value != $test_code) {
|
||||
$tel = $this->input('username');
|
||||
$captcha = Cache::get('sms_captcha_'.$tel);
|
||||
if ((int) $captcha !== (int) $value) {
|
||||
$fail('验证码错误!');
|
||||
}
|
||||
}
|
||||
}],
|
||||
'referral_code' => '', // 推荐码
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'username' => [
|
||||
'required',
|
||||
$rule,
|
||||
'unique:users,username',
|
||||
],
|
||||
'password' => 'required|min:6|confirmed',
|
||||
'captcha' => ['required', function (string $attribute, mixed $value, \Closure $fail) {
|
||||
$test_code = config('services.ali_sms.test_code');
|
||||
if (empty($test_code) || $value != $test_code) {
|
||||
$tel = $this->input('username');
|
||||
$captcha = Cache::get('sms_captcha_'.$tel);
|
||||
if ((int) $captcha !== (int) $value) {
|
||||
$fail('验证码错误!');
|
||||
}
|
||||
}
|
||||
}],
|
||||
'referral_code' => '', // 推荐码
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
$txt = CodeMode::Email->value ? '邮箱' : '手机号';
|
||||
$code_mode = SystemConfig::get('send_code_mode');
|
||||
$is_open = SystemConfig::get('verify_code_is_open');
|
||||
$txt = '用户名';
|
||||
if (! empty($is_open)) {
|
||||
$txt = ($code_mode === CodeMode::Email->value) ? '邮箱' : '手机号';
|
||||
}
|
||||
|
||||
return [
|
||||
'username.required' => "请输入{$txt}!",
|
||||
|
||||
@@ -4,11 +4,13 @@ namespace App\Jobs;
|
||||
|
||||
use App\Jobs\Middleware\RateLimited;
|
||||
use App\Mail\SendEmail;
|
||||
use App\Services\SystemConfig;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Throwable;
|
||||
|
||||
@@ -31,6 +33,13 @@ class SendEmailJobs implements ShouldQueue
|
||||
$this->to = $to;
|
||||
$this->code = $code;
|
||||
$this->title = $title ?? '邮箱验证码';
|
||||
|
||||
Config::set('mail.mailers.smtp.host', SystemConfig::get('mail_host'));
|
||||
Config::set('mail.mailers.smtp.port', SystemConfig::get('mail_port'));
|
||||
Config::set('mail.mailers.smtp.username', SystemConfig::get('mail_username'));
|
||||
Config::set('mail.mailers.smtp.password', SystemConfig::get('mail_password'));
|
||||
Config::set('mail.from.address', SystemConfig::get('mail_from_address'));
|
||||
Config::set('mail.from.name', SystemConfig::get('mail_from_name'));
|
||||
}
|
||||
|
||||
public function middleware()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\PayChannels;
|
||||
|
||||
use App\Services\SystemConfig;
|
||||
use EasyWeChat\Pay\Application;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -17,7 +18,21 @@ class WeChatPayNative
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->payApp = new Application(config('services.wechat_pay'));
|
||||
$config = [
|
||||
'appid' => SystemConfig::get('wechat_pay_app_id'),
|
||||
'mch_id' => SystemConfig::get('wechat_pay_mch_id'),
|
||||
'secret_key' => SystemConfig::get('wechat_pay_secret_key'),
|
||||
// 商户证书
|
||||
'private_key' => SystemConfig::get('wechat_pay_secret_key'),
|
||||
'certificate' => SystemConfig::get('wechat_pay_certificate'),
|
||||
/*'platform_certs' => [
|
||||
storage_path('/certs/wechatpay.pem'),
|
||||
],*/
|
||||
'http' => [
|
||||
'throw' => false,
|
||||
],
|
||||
];
|
||||
$this->payApp = new Application($config);
|
||||
}
|
||||
|
||||
// 支付
|
||||
|
||||
@@ -17,7 +17,13 @@ class AliDySms
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = config('services.ali_sms');
|
||||
$config = [
|
||||
'key' => SystemConfig::get('ali_sms_key'),
|
||||
'secret' => SystemConfig::get('ali_sms_secret'),
|
||||
'sign_name' => SystemConfig::get('ali_sms_sign_name'),
|
||||
'test_code' => env('ALI_SMS_TEST_CODE'),
|
||||
];
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<script>
|
||||
// window.location = '/web/#/login'
|
||||
</script>
|
||||
<title>火星快链-智慧引流工具</title>
|
||||
<title>{!! \App\Services\SystemConfig::get('web_site_title') !!}</title>
|
||||
<link rel="stylesheet" href="/css/css.css">
|
||||
<link rel="stylesheet" href="/css/boot.css">
|
||||
<style>
|
||||
@@ -452,7 +452,7 @@
|
||||
<div class="footer hide-below-1000">
|
||||
<div class="mainCard d-flex justify-content-between p-4">
|
||||
<div>
|
||||
<img class="logo" src="/image/logo.png">
|
||||
<img class="logo" src="{!! \App\Services\SystemConfig::get('web_site_bottom_logo') !!}">
|
||||
</div>
|
||||
<div class="d-flex justify-content-between flex-1">
|
||||
<div class="line" style="margin-left: 100px"></div>
|
||||
@@ -471,7 +471,7 @@
|
||||
<div class="line" style="margin-right: 100px"></div>
|
||||
</div>
|
||||
<div>
|
||||
<img class="weixin" src="/image/web-qr.png">
|
||||
<img class="weixin" src="{!! \App\Services\SystemConfig::get('web_site_customer_service') !!}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="xlin"></div>
|
||||
@@ -480,7 +480,7 @@
|
||||
<div class="show-below-1000 phoneFooter" style="display: none">
|
||||
<div class="row row-cols-sm-2 p-4">
|
||||
<div>
|
||||
<img class="weixin" src="/image/web-qr.png">
|
||||
<img class="weixin" src="{!! \App\Services\SystemConfig::get('web_site_customer_service') !!}">
|
||||
<div class="mt-3">
|
||||
<div class="font-20 text-white">联系我们</div>
|
||||
<div class="mt-2 text-secondary font-14">公司地址:××××××××××</div>
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Console Routes
|
||||
|
||||
@@ -3,12 +3,18 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\CommissionType;
|
||||
use App\Jobs\SendEmailJobs;
|
||||
use App\Models\User;
|
||||
use App\Models\VipPackage;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UserTest extends TestCase
|
||||
{
|
||||
public function test_send_mail()
|
||||
{
|
||||
SendEmailJobs::dispatch('724323954@qq.com', '123321');
|
||||
}
|
||||
|
||||
public function test_get_token()
|
||||
{
|
||||
dd($this->get_admin_token());
|
||||
|
||||
Reference in New Issue
Block a user