作者 lyh

gx

<?php
namespace App\Helper;
class Country
{
public static $tls_list = [
'en' => [
'text' => '英语',
'lang_text' => 'English',
'con_flag' => 'con_flag/en.jfif',
'shop_lang' => 'en-gb',
],
'zh' => [
'text' => '中文',
'lang_text' => '简体中文',
'con_flag' => 'con_flag/zh.jfif',
'shop_lang' => 'zh-cn',
],
'fr' => [
'text' => '法语',
'lang_text' => 'En français',
'con_flag' => '',
],
'de' => [
'text' => '德语',
'lang_text' => 'Das ist Deutsch.',
'con_flag' => '',
],
'ko' => [
'text' => '韩语',
'lang_text' => '',
'con_flag' => '',
],
'ja' => [
'text' => '日语',
'lang_text' => '',
'con_flag' => '',
],
'es' => [
'text' => '西班牙语',
'lang_text' => 'Español.',
'con_flag' => '',
],
'ar' => [
'text' => '阿拉伯语',
'lang_text' => '',
'con_flag' => '',
],
'pt' => [
'text' => '葡萄牙语(葡萄牙、巴西)',
'lang_text' => 'Língua portuguesa',
'con_flag' => '',
],
'ru' => [
'text' => '俄语',
'lang_text' => '',
'con_flag' => '',
],
'af' => [
'text' => '南非荷兰语',
'lang_text' => '',
'con_flag' => '',
],
'sq' => [
'text' => '阿尔巴尼亚语',
'lang_text' => '',
'con_flag' => '',
],
'am' => [
'text' => '阿姆哈拉语',
'lang_text' => '',
'con_flag' => '',
],
'hy' => [
'text' => '亚美尼亚语',
'lang_text' => '',
'con_flag' => '',
],
'az' => [
'text' => '阿塞拜疆语',
'lang_text' => '',
'con_flag' => '',
],
'eu' => [
'text' => '巴斯克语',
'lang_text' => '',
'con_flag' => '',
],
'be' => [
'text' => '白俄罗斯语',
'lang_text' => '',
'con_flag' => '',
],
'bn' => [
'text' => '孟加拉语',
'lang_text' => '',
'con_flag' => '',
],
'bs' => [
'text' => '波斯尼亚语',
'lang_text' => '',
'con_flag' => '',
],
'bg' => [
'text' => '保加利亚语',
'lang_text' => '',
'con_flag' => '',
],
'ca' => [
'text' => '加泰罗尼亚语',
'lang_text' => '',
'con_flag' => '',
],
'ceb' => [
'text' => '宿务语',
'lang_text' => '',
'con_flag' => '',
],
'zh-CN' => [
'text' => '中文(简体)',
'lang_text' => '简体中文',
'con_flag' => 'con_flag/zh.jfif',
'shop_lang' => 'zh-cn',
],
'zh-TW' => [
'text' => '中文(繁体)',
'lang_text' => '繁体中文',
'con_flag' => 'con_flag/zh.jfif',
],
'co' => [
'text' => '科西嘉语',
'lang_text' => '',
'con_flag' => '',
],
'hr' => [
'text' => '克罗地亚语',
'lang_text' => '',
'con_flag' => '',
],
'cs' => [
'text' => '捷克语',
'lang_text' => '',
'con_flag' => '',
],
'da' => [
'text' => '丹麦语',
'lang_text' => '',
'con_flag' => '',
],
'nl' => [
'text' => '荷兰语',
'lang_text' => '',
'con_flag' => '',
],
'eo' => [
'text' => '世界语',
'lang_text' => '',
'con_flag' => '',
],
'et' => [
'text' => '爱沙尼亚语',
'lang_text' => '',
'con_flag' => '',
],
'fi' => [
'text' => '芬兰语',
'lang_text' => '',
'con_flag' => '',
],
'fy' => [
'text' => '弗里斯兰语',
'lang_text' => '',
'con_flag' => '',
],
'gl' => [
'text' => '加利西亚语',
'lang_text' => '',
'con_flag' => '',
],
'ka' => [
'text' => '格鲁吉亚语',
'lang_text' => '',
'con_flag' => '',
],
'el' => [
'text' => '希腊语',
'lang_text' => '',
'con_flag' => '',
],
'gu' => [
'text' => '古吉拉特语',
'lang_text' => '',
'con_flag' => '',
],
'ht' => [
'text' => '海地克里奥尔语',
'lang_text' => '',
'con_flag' => '',
],
'ha' => [
'text' => '豪萨语',
'lang_text' => '',
'con_flag' => '',
],
'haw' => [
'text' => '夏威夷语',
'lang_text' => '',
'con_flag' => '',
],
'iw' => [
'text' => '希伯来语',
'lang_text' => '',
'con_flag' => '',
],
'hi' => [
'text' => '印地语',
'lang_text' => '',
'con_flag' => '',
],
'hmn' => [
'text' => '苗语',
'lang_text' => '',
'con_flag' => '',
],
'hu' => [
'text' => '匈牙利语',
'lang_text' => '',
'con_flag' => '',
],
'is' => [
'text' => '冰岛语',
'lang_text' => '',
'con_flag' => '',
],
'ig' => [
'text' => '伊博语',
'lang_text' => '',
'con_flag' => '',
],
'id' => [
'text' => '印度尼西亚语',
'lang_text' => 'Bahasa Indonesia',
'con_flag' => 'con_flag/id.jfif',
'shop_lang' => 'id',
],
'ga' => [
'text' => '爱尔兰语',
'lang_text' => '',
'con_flag' => '',
],
'it' => [
'text' => '意大利语',
'lang_text' => 'Lingua italiana',
'con_flag' => '',
],
'jw' => [
'text' => '爪哇语',
'lang_text' => '',
'con_flag' => '',
],
'kn' => [
'text' => '卡纳达语',
'lang_text' => '',
'con_flag' => '',
],
'kk' => [
'text' => '哈萨克语',
'lang_text' => '',
'con_flag' => '',
],
'km' => [
'text' => '高棉语',
'lang_text' => '',
'con_flag' => '',
],
'rw' => [
'text' => '卢旺达语',
'lang_text' => '',
'con_flag' => '',
],
'ku' => [
'text' => '库尔德语',
'lang_text' => '',
'con_flag' => '',
],
'ky' => [
'text' => '吉尔吉斯语',
'lang_text' => '',
'con_flag' => '',
],
'lo' => [
'text' => '老挝文',
'lang_text' => '',
'con_flag' => '',
],
'la' => [
'text' => '拉丁文',
'lang_text' => '',
'con_flag' => '',
],
'lv' => [
'text' => '拉脱维亚语',
'lang_text' => '',
'con_flag' => '',
],
'lt' => [
'text' => '立陶宛语',
'lang_text' => '',
'con_flag' => '',
],
'lb' => [
'text' => '卢森堡语',
'lang_text' => '',
'con_flag' => '',
],
'mk' => [
'text' => '马其顿语',
'lang_text' => '',
'con_flag' => '',
],
'mg' => [
'text' => '马尔加什语',
'lang_text' => '',
'con_flag' => '',
],
'ms' => [
'text' => '马来语',
'lang_text' => 'Bahasa Melayu',
'con_flag' => 'con_flag/ms.jfif',
'shop_lang' => 'ms-my',
],
'ml' => [
'text' => '马拉雅拉姆文',
'lang_text' => '',
'con_flag' => '',
],
'mt' => [
'text' => '马耳他语',
'lang_text' => '',
'con_flag' => '',
],
'mi' => [
'text' => '毛利语',
'lang_text' => '',
'con_flag' => '',
],
'mr' => [
'text' => '马拉地语',
'lang_text' => '',
'con_flag' => '',
],
'mn' => [
'text' => '蒙古文',
'lang_text' => '',
'con_flag' => '',
],
'my' => [
'text' => '缅甸语',
'lang_text' => '',
'con_flag' => '',
],
'ne' => [
'text' => '尼泊尔语',
'lang_text' => '',
'con_flag' => '',
],
'no' => [
'text' => '挪威语',
'lang_text' => '',
'con_flag' => '',
],
'ny' => [
'text' => '尼杨扎语(齐切瓦语)',
'lang_text' => '',
'con_flag' => '',
],
'or' => [
'text' => '奥里亚语(奥里亚)',
'lang_text' => '',
'con_flag' => '',
],
'ps' => [
'text' => '普什图语',
'lang_text' => '',
'con_flag' => '',
],
'fa' => [
'text' => '波斯语',
'lang_text' => '',
'con_flag' => '',
],
'pl' => [
'text' => '波兰语',
'lang_text' => '',
'con_flag' => '',
],
'pa' => [
'text' => '旁遮普语',
'lang_text' => '',
'con_flag' => '',
],
'ro' => [
'text' => '罗马尼亚语',
'lang_text' => '',
'con_flag' => '',
],
'sm' => [
'text' => '萨摩亚语',
'lang_text' => '',
'con_flag' => '',
],
'gd' => [
'text' => '苏格兰盖尔语',
'lang_text' => '',
'con_flag' => '',
],
'sr' => [
'text' => '塞尔维亚语',
'lang_text' => '',
'con_flag' => '',
],
'st' => [
'text' => '塞索托语',
'lang_text' => '',
'con_flag' => '',
],
'sn' => [
'text' => '修纳语',
'lang_text' => '',
'con_flag' => '',
],
'sd' => [
'text' => '信德语',
'lang_text' => '',
'con_flag' => '',
],
'si' => [
'text' => '僧伽罗语',
'lang_text' => '',
'con_flag' => '',
],
'sk' => [
'text' => '斯洛伐克语',
'lang_text' => '',
'con_flag' => '',
],
'sl' => [
'text' => '斯洛文尼亚语',
'lang_text' => '',
'con_flag' => '',
],
'so' => [
'text' => '索马里语',
'lang_text' => '',
'con_flag' => '',
],
'su' => [
'text' => '巽他语',
'lang_text' => '',
'con_flag' => '',
],
'sw' => [
'text' => '斯瓦希里语',
'lang_text' => '',
'con_flag' => '',
],
'sv' => [
'text' => '瑞典语',
'lang_text' => '',
'con_flag' => '',
],
'tl' => [
'text' => '塔加路语(菲律宾语)',
'lang_text' => 'Pilipino',
'con_flag' => 'con_flag/tl.jfif',
'shop_lang' => 'tl',
],
'tg' => [
'text' => '塔吉克语',
'lang_text' => '',
'con_flag' => '',
],
'ta' => [
'text' => '泰米尔语',
'lang_text' => '',
'con_flag' => '',
],
'tt' => [
'text' => '鞑靼语',
'lang_text' => '',
'con_flag' => '',
],
'te' => [
'text' => '泰卢固语',
'lang_text' => '',
'con_flag' => '',
],
'th' => [
'text' => '泰文',
'lang_text' => 'ไทย',
'con_flag' => 'con_flag/th.jfif',
'shop_lang' => 'th',
],
'tr' => [
'text' => '土耳其语',
'lang_text' => '',
'con_flag' => '',
],
'tk' => [
'text' => '土库曼语',
'lang_text' => '',
'con_flag' => '',
],
'uk' => [
'text' => '乌克兰语',
'lang_text' => '',
'con_flag' => '',
],
'ur' => [
'text' => '乌尔都语',
'lang_text' => '',
'con_flag' => '',
],
'ug' => [
'text' => '维吾尔语',
'lang_text' => '',
'con_flag' => '',
],
'uz' => [
'text' => '乌兹别克语',
'lang_text' => '',
'con_flag' => '',
],
'vi' => [
'text' => '越南语',
'lang_text' => '',
'con_flag' => '',
],
'cy' => [
'text' => '威尔士语',
'lang_text' => '',
'con_flag' => '',
],
'xh' => [
'text' => '班图语',
'lang_text' => '',
'con_flag' => '',
],
'yi' => [
'text' => '意第绪语',
'lang_text' => '',
'con_flag' => '',
],
'yo' => [
'text' => '约鲁巴语',
'lang_text' => '',
'con_flag' => '',
],
'zu' => [
'text' => '祖鲁语',
'lang_text' => '',
'con_flag' => '',
],
];
}
... ...
... ... @@ -2,17 +2,54 @@
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingFromLogic;
class WebSettingFromController extends BaseController
{
/**
* @name :lists
* @name :(表单设置详情)info
* @author :lyh
* @method :post
* @time :2023/5/4 13:44
*/
public function info(WebSettingFromLogic $webSettingFromLogic){
$info = $webSettingFromLogic->setting_from_info();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name :(添加或编辑表单设置)lists
* @author :lyh
* @method :post
* @time :2023/4/28 14:41
*/
public function lists(){
public function save(WebSettingFromLogic $webSettingFromLogic){
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
}
$webSettingFromLogic->setting_from_save();
$this->response('success');
}
/**
* @name :(删除表单)del
* @author :lyh
* @method :post
* @time :2023/5/4 13:38
*/
public function del(WebSettingFromLogic $webSettingFromLogic){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$webSettingFromLogic->setting_from_del();
$this->response('success');
}
}
... ...
... ... @@ -2,17 +2,20 @@
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingHtmlLogic;
class WebSettingHtmlController extends BaseController
{
/**
* @name :lists
* @name :(获取并设置第三方代码)read
* @author :lyh
* @method :post
* @time :2023/4/28 14:45
*/
public function lists(){
public function save(WebSettingHtmlLogic $webSettingHtmlLogic){
$info = $webSettingHtmlLogic->setting_html_save();
$this->response('success',Code::SUCCESS,$info);
}
}
... ...
... ... @@ -2,7 +2,9 @@
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingServiceLogic;
class WebSettingServiceController extends BaseController
{
... ... @@ -10,9 +12,31 @@ class WebSettingServiceController extends BaseController
* @name :lists
* @author :lyh
* @method :post
* @time :2023/5/4 11:28
*/
public function lists(WebSettingServiceLogic $webSettingServiceLogic){
$lists = $webSettingServiceLogic->setting_service_info();
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :save
* @author :lyh
* @method :post
* @time :2023/4/28 14:46
*/
public function lists(){
public function save(WebSettingServiceLogic $webSettingServiceLogic){
$webSettingServiceLogic->setting_service_save();
$this->response('success');
}
/**
* @name :del
* @author :lyh
* @method :post
* @time :2023/5/4 11:28
*/
public function del(WebSettingServiceLogic $webSettingServiceLogic){
$webSettingServiceLogic->setting_service_del();
$this->response('success');
}
}
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside;
use App\Enums\Common\Code;
use App\Exceptions\BsideGlobalException;
use App\Helper\Common;
use App\Http\Controllers\ImageLogic;
use App\Http\Logic\Logic;
use App\Models\Image as ImageModel;
use Illuminate\Http\Request;
... ... @@ -98,30 +99,8 @@ class BaseLogic extends Logic
* @method
*/
public function upload(){
$image = $this->request->file('image');
if(empty($image)){
return $this->fail('没有上传图片');
}
$hash = hash_file('md5', $image->getPathname());
$url = './../uploads/images/';
$filename = date('ymdHis').rand(10000,99999);
$res = $this->request->file('image')->move($url,$filename);
if ($res === false) {
return $this->fail($image->getError());
}
$imageModel = new ImageModel();
$data = [
'path' => $url.$filename,
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash.$filename,
'type'=>$image->getClientOriginalExtension(),
];
$rs = $imageModel->add($data);
if ($rs === false) {
return $this->fail('error');
}
return $hash.$filename;
$imageLogic = new ImageLogic();
return $imageLogic->upload();
}
/**
... ...
... ... @@ -110,7 +110,7 @@ class BlogLogic extends BaseLogic
//TODO::删除资源
$imageModel = new Image();
$image_info = $imageModel->read(['hash'=>$info['image']],['id','path']);
shell_exec('sudo rm -rf '.$image_info['path'] .'./../uploads/images/cache_'. $info['image'] . '*');
shell_exec('sudo rm -rf '.$image_info['path'] .' ./../uploads/images/cache_'. $info['image'] . '*');
$imageModel->del(['hash'=>$info['image']]);
}
$this->param['image'] = $this->upload();
... ...
... ... @@ -14,4 +14,52 @@ class WebSettingFromLogic extends BaseLogic
$this->model = new WebSettingForm();
$this->param = $this->requestAll;
}
/**
* @name :(获取表单设置详情)setting_from_info
* @author :lyh
* @method :post
* @time :2023/5/4 13:43
*/
public function setting_from_info(){
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->fail('当前数据不存在,或者已被删除');
}
return $this->success($info);
}
/**
* @name :(表单设置)setting_from_save
* @param :(is_required是否必填,name名称)
* @author :lyh
* @method :post
* @time :2023/5/4 10:39
*/
public function setting_from_save(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$rs = $this->model->add($this->param);
}
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @name :(删除表单设置)setting_from_del
* @param : (id主键)
* @author :lyh
* @method :post
* @time :2023/5/4 11:01
*/
public function setting_from_del(){
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
}
... ...
... ... @@ -14,4 +14,30 @@ class WebSettingHtmlLogic extends BaseLogic
$this->model = new WebSettingHtml();
$this->param = $this->requestAll;
}
/**
* @name :(设置第三方代码)setting_html_info
* @param : (head_html头,body_html中,footer_html尾)
* @author :lyh
* @method :post
* @time :2023/5/4 10:18
*/
public function setting_html_save(){
if(isset($this->param) && !empty($this->param)){
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->param['project_id'] = $this->user['project_id'];
$rs = $this->model->add($this->param);
}else{
$rs = $this->model->edit($this->param,['project_id'=>$this->user['project_id']]);
}
if($rs === false){
$this->fail('error');
}
$info = $this->param;
}else{
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
}
return $this->success($info);
}
}
... ...
... ... @@ -2,8 +2,11 @@
namespace App\Http\Logic\Bside\Setting;
use App\Http\Controllers\ImageLogic;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Image;
use App\Models\WebSetting\WebSettingService;
use Illuminate\Support\Facades\DB;
class WebSettingServiceLogic extends BaseLogic
{
... ... @@ -14,4 +17,58 @@ class WebSettingServiceLogic extends BaseLogic
$this->model = new WebSettingService();
$this->param = $this->requestAll;
}
/**
* @name : (客服设置列表)setting_service_list
* @author :lyh
* @method :post
* @time :2023/5/4 11:23
*/
public function setting_service_info(){
$info = $this->model->read(['project_id'=>$this->param['project_id']]);
return $this->success($info);
}
/**
* @name : (客服设置)setting_service_save
* @author :lyh
* @method :post
* @time :2023/5/4 11:10
*/
public function setting_service_save(){
if(isset($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$rs = $this->model->add($this->param);
}
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @name :(删除客服图片)setting_service_del
* @author :lyh
* @method :post
* @time :2023/5/4 11:29
*/
public function setting_service_del(){
DB::beginTransaction();
try {
//获取当前图片资源
$image = new Image();
$info = $image->read(['hash'=>$this->param['hash']]);
if($info !== false){
$image->del(['id'=>$info['id']]);
//删除资源文件
shell_exec('rm -rf '.$info['path']);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
}
}
}
... ...
... ... @@ -7,6 +7,7 @@ use App\Models\Image as ImageModel;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
... ... @@ -70,6 +71,34 @@ class ImageLogic
}
return $hash.$filename;
}
/**
* @name :(删除资源及对应表数据)del
* @author :lyh
* @method :post
* @time :2023/5/4 14:57
*/
public function del($hash){
DB::beginTransaction();
$imageModel = new ImageModel();
try {
if(is_array($hash)){
foreach ($hash as $k => $v){
$this->del($v);
}
}else{
$info = $imageModel->read(['hash'=>$hash]);
if($info !== false){
shell_exec('sudo rm -rf '.$info['path']. ' '.$this->path . $info['hash'] .'*');
}
}
$imageModel->del(['hash'=>['in',$hash]]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->response('error',Code::USER_ERROR);
}
}
/**
* 生成缩略图缓存
* @param type $info
... ...
... ... @@ -7,4 +7,19 @@ class Image extends Base
protected $table = 'gl_image';
public $timestamps = true;
/**
* @param $hash
* @name :(获取图片详情)image_read
* @author :lyh
* @method :post
* @time :2023/5/4 11:50
*/
public function image_read($hash){
$info = $this->read(['hash'=>$hash]);
if(empty($info)){
return false;
}
return $info;
}
}
... ...
... ... @@ -111,13 +111,27 @@ Route::middleware(['bloginauth'])->group(function () {
//首页设置
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'lists'])->name('web_setting_lists');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'save'])->name('web_setting_save');
//第三方代码获取与设置
Route::prefix('html')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingHtmlController::class, 'save'])->name('web_setting_html_save');
});
//表单设置
Route::prefix('from')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingFromController::class, 'info'])->name('web_setting_from_info');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingFromController::class, 'save'])->name('web_setting_from_info');
});
//多语言设置
Route::prefix('country')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingCountryController::class, 'lists'])->name('web_setting_country_lists');
//项目多语言设置详情
Route::any('/info', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'info'])->name('web_setting_country_info');
Route::any('/edit', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'edit'])->name('web_setting_country_edit');
});
//客服设置
Route::prefix('service')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingServiceController::class, 'lists'])->name('web_setting_service_lists');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingServiceController::class, 'save'])->name('web_setting_service_save');
Route::any('/del', [\App\Http\Controllers\Bside\Setting\WebSettingServiceController::class, 'del'])->name('web_setting_service_del');
});
});
//产品
... ...