first commit
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* The file was created by Assimon.
|
||||
*
|
||||
* @author ZhangYiQiu<me@zhangyiqiu.net>
|
||||
* @copyright ZhangYiQiu<me@zhangyiqiu.net>
|
||||
* @link http://zhangyiqiu.net/
|
||||
*/
|
||||
|
||||
namespace App\Admin\Forms;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Mail\MailServiceProvider;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class EmailTest extends Form
|
||||
{
|
||||
/**
|
||||
* Handle the form request.
|
||||
*
|
||||
* @param array $input
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(array $input)
|
||||
{
|
||||
$to = $input['to'];
|
||||
$title = $input['title'];
|
||||
$body = $input['body'];
|
||||
$sysConfig = cache('system-setting');
|
||||
$mailConfig = [
|
||||
'driver' => $sysConfig['driver'] ?? 'smtp',
|
||||
'host' => $sysConfig['host'] ?? '',
|
||||
'port' => $sysConfig['port'] ?? '465',
|
||||
'username' => $sysConfig['username'] ?? '',
|
||||
'from' => [
|
||||
'address' => $sysConfig['from_address'] ?? '',
|
||||
'name' => $sysConfig['from_name'] ?? '独角发卡'
|
||||
],
|
||||
'password' => $sysConfig['password'] ?? '',
|
||||
'encryption' => $sysConfig['encryption'] ?? 'ssl'
|
||||
];
|
||||
// 覆盖 mail 配置
|
||||
config([
|
||||
'mail' => array_merge(config('mail'), $mailConfig)
|
||||
]);
|
||||
// 重新注册驱动
|
||||
(new MailServiceProvider(app()))->register();
|
||||
try
|
||||
{
|
||||
Mail::send(['html' => 'email.mail'], ['body' => $body], function ($message) use ($to, $title){
|
||||
$message->to($to)->subject($title);
|
||||
});
|
||||
}
|
||||
catch(\Exception $e)
|
||||
{
|
||||
return $this
|
||||
->response()
|
||||
->error($e->getMessage());
|
||||
}
|
||||
return $this
|
||||
->response()
|
||||
->success(admin_trans('email-test.labels.success'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form here.
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
$this->tab(admin_trans('menu.titles.email_test'), function () {
|
||||
$this->text('to', admin_trans('email-test.labels.to'))->required();
|
||||
$this->text('title', admin_trans('email-test.labels.title'))->default('这是一条测试邮件')->required();
|
||||
$this->editor('body', admin_trans('email-test.labels.body'))->default("这是一条测试邮件的正文内容<br/><br/>正文比较长<br/><br/>非常长<br/><br/>测试测试测试")->required();
|
||||
});
|
||||
}
|
||||
|
||||
public function default()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Forms;
|
||||
|
||||
use App\Models\Carmis;
|
||||
use App\Models\Goods;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ImportCarmis extends Form
|
||||
{
|
||||
|
||||
/**
|
||||
* Handle the form request.
|
||||
*
|
||||
* @param array $input
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(array $input)
|
||||
{
|
||||
if (empty($input['carmis_list']) && empty($input['carmis_txt'])) {
|
||||
return $this->response()->error(admin_trans('carmis.rule_messages.carmis_list_and_carmis_txt_can_not_be_empty'));
|
||||
}
|
||||
$carmisContent = "";
|
||||
if (!empty($input['carmis_txt'])) {
|
||||
$carmisContent = Storage::disk('public')->get($input['carmis_txt']);
|
||||
}
|
||||
if (!empty($input['carmis_list'])) {
|
||||
$carmisContent = $input['carmis_list'];
|
||||
}
|
||||
$carmisData = [];
|
||||
$tempList = explode(PHP_EOL, $carmisContent);
|
||||
foreach ($tempList as $val) {
|
||||
if (trim($val) != "") {
|
||||
$carmisData[] = [
|
||||
'goods_id' => $input['goods_id'],
|
||||
'carmi' => trim($val),
|
||||
'status' => Carmis::STATUS_UNSOLD,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
if ($input['remove_duplication'] == 1) {
|
||||
$carmisData = assoc_unique($carmisData, 'carmi');
|
||||
}
|
||||
Carmis::query()->insert($carmisData);
|
||||
// 删除文件
|
||||
Storage::disk('public')->delete($input['carmis_txt']);
|
||||
return $this
|
||||
->response()
|
||||
->success(admin_trans('carmis.rule_messages.import_carmis_success'))
|
||||
->location('/carmis');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form here.
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
$this->confirm(admin_trans('carmis.fields.are_you_import_sure'));
|
||||
$this->select('goods_id')->options(
|
||||
Goods::query()->where('type', Goods::AUTOMATIC_DELIVERY)->pluck('gd_name', 'id')
|
||||
)->required();
|
||||
$this->textarea('carmis_list')
|
||||
->rows(20)
|
||||
->help(admin_trans('carmis.helps.carmis_list'));
|
||||
$this->file('carmis_txt')
|
||||
->disk('public')
|
||||
->uniqueName()
|
||||
->accept('txt')
|
||||
->maxSize(5120)
|
||||
->help(admin_trans('carmis.helps.carmis_list'));
|
||||
$this->switch('remove_duplication');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Forms;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class SystemSetting extends Form
|
||||
{
|
||||
/**
|
||||
* Handle the form request.
|
||||
*
|
||||
* @param array $input
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(array $input)
|
||||
{
|
||||
Cache::put('system-setting', $input);
|
||||
return $this
|
||||
->response()
|
||||
->success(admin_trans('system-setting.rule_messages.save_system_setting_success'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form here.
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
$this->tab(admin_trans('system-setting.labels.base_setting'), function () {
|
||||
$this->text('title', admin_trans('system-setting.fields.title'))->required();
|
||||
$this->image('img_logo', admin_trans('system-setting.fields.img_logo'));
|
||||
$this->text('text_logo', admin_trans('system-setting.fields.text_logo'));
|
||||
$this->text('keywords', admin_trans('system-setting.fields.keywords'));
|
||||
$this->textarea('description', admin_trans('system-setting.fields.description'));
|
||||
$this->select('template', admin_trans('system-setting.fields.template'))
|
||||
->options(config('dujiaoka.templates'))
|
||||
->required();
|
||||
$this->select('language', admin_trans('system-setting.fields.language'))
|
||||
->options(config('dujiaoka.language'))
|
||||
->required();
|
||||
$this->text('manage_email', admin_trans('system-setting.fields.manage_email'));
|
||||
$this->number('order_expire_time', admin_trans('system-setting.fields.order_expire_time'))
|
||||
->default(5)
|
||||
->required();
|
||||
$this->switch('is_open_anti_red', admin_trans('system-setting.fields.is_open_anti_red'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->switch('is_open_img_code', admin_trans('system-setting.fields.is_open_img_code'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->switch('is_open_search_pwd', admin_trans('system-setting.fields.is_open_search_pwd'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->switch('is_open_google_translate', admin_trans('system-setting.fields.is_open_google_translate'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->editor('notice', admin_trans('system-setting.fields.notice'));
|
||||
$this->textarea('footer', admin_trans('system-setting.fields.footer'));
|
||||
});
|
||||
$this->tab(admin_trans('system-setting.labels.order_push_setting'), function () {
|
||||
$this->switch('is_open_server_jiang', admin_trans('system-setting.fields.is_open_server_jiang'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->text('server_jiang_token', admin_trans('system-setting.fields.server_jiang_token'));
|
||||
$this->switch('is_open_telegram_push', admin_trans('system-setting.fields.is_open_telegram_push'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->text('telegram_bot_token', admin_trans('system-setting.fields.telegram_bot_token'));
|
||||
$this->text('telegram_userid', admin_trans('system-setting.fields.telegram_userid'));
|
||||
$this->switch('is_open_bark_push', admin_trans('system-setting.fields.is_open_bark_push'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->switch('is_open_bark_push_url', admin_trans('system-setting.fields.is_open_bark_push_url'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->text('bark_server', admin_trans('system-setting.fields.bark_server'));
|
||||
$this->text('bark_token', admin_trans('system-setting.fields.bark_token'));
|
||||
$this->switch('is_open_qywxbot_push', admin_trans('system-setting.fields.is_open_qywxbot_push'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->text('qywxbot_key', admin_trans('system-setting.fields.qywxbot_key'));
|
||||
});
|
||||
$this->tab(admin_trans('system-setting.labels.mail_setting'), function () {
|
||||
$this->text('driver', admin_trans('system-setting.fields.driver'))->default('smtp')->required();
|
||||
$this->text('host', admin_trans('system-setting.fields.host'));
|
||||
$this->text('port', admin_trans('system-setting.fields.port'))->default(587);
|
||||
$this->text('username', admin_trans('system-setting.fields.username'));
|
||||
$this->text('password', admin_trans('system-setting.fields.password'));
|
||||
$this->text('encryption', admin_trans('system-setting.fields.encryption'));
|
||||
$this->text('from_address', admin_trans('system-setting.fields.from_address'));
|
||||
$this->text('from_name', admin_trans('system-setting.fields.from_name'));
|
||||
});
|
||||
$this->tab(admin_trans('system-setting.labels.geetest'), function () {
|
||||
$this->text('geetest_id', admin_trans('system-setting.fields.geetest_id'));
|
||||
$this->text('geetest_key', admin_trans('system-setting.fields.geetest_key'));
|
||||
$this->switch('is_open_geetest', admin_trans('system-setting.fields.is_open_geetest'))->default(BaseModel::STATUS_CLOSE);
|
||||
});
|
||||
$this->confirm(
|
||||
admin_trans('dujiaoka.warning_title'),
|
||||
admin_trans('system-setting.rule_messages.change_reboot_php_worker')
|
||||
);
|
||||
}
|
||||
|
||||
public function default()
|
||||
{
|
||||
return Cache::get('system-setting');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user