作者 赵彬吉
@@ -143,6 +143,7 @@ class VideoTask extends Command @@ -143,6 +143,7 @@ class VideoTask extends Command
143 ], 143 ],
144 'task_id' => $task_id, 144 'task_id' => $task_id,
145 'callback_url' => env('APP_URL') . '/api/video_task_callback', 145 'callback_url' => env('APP_URL') . '/api/video_task_callback',
  146 + 'is_ytb'=>true
146 ]; 147 ];
147 $result = Http::post('http://216.250.255.116:7866/create_task', $data); 148 $result = Http::post('http://216.250.255.116:7866/create_task', $data);
148 $val->task_id = $task_id; 149 $val->task_id = $task_id;
@@ -215,28 +216,33 @@ class VideoTask extends Command @@ -215,28 +216,33 @@ class VideoTask extends Command
215 $productIds[] = $item->id; 216 $productIds[] = $item->id;
216 } 217 }
217 if (count($productIds)<7){ 218 if (count($productIds)<7){
218 - $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",1)->pluck('id')->toArray();  
219 - $product_id = array_rand($product_all_id, 13-count($productIds)); 219 + $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
  220 + $number = 40;
  221 + $product_id = array_rand($product_all_id, min(count($product_all_id, $number-count($productIds))));
220 $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); 222 $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
221 $products = $productsQuery->merge($randomData); 223 $products = $productsQuery->merge($randomData);
222 }else{ 224 }else{
223 $products = $productsQuery; 225 $products = $productsQuery;
224 } 226 }
225 }else{ 227 }else{
226 - $product_all_id = Product::where("project_id", $project_id)->where("status",1)->pluck('id')->toArray();  
227 - $product_id = array_rand($product_all_id, 13); 228 + $product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
  229 + $product_id = array_rand($product_all_id, 40);
228 $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); 230 $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
229 } 231 }
230 } 232 }
231 $data = []; 233 $data = [];
232 if (!empty($products)){ 234 if (!empty($products)){
233 foreach ($products as $item){ 235 foreach ($products as $item){
234 - $data[] = !empty($item->thumb) && $item->thumb['url'] != "" ? getImageUrl($item->thumb['url']) : ""; 236 + if(empty($item->thumb) || ($item->thumb['url'] == "")){
  237 + continue;
  238 + }
  239 + if(count($data) > 13){
  240 + break;
  241 + }
  242 + $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
235 } 243 }
236 } 244 }
237 return $data; 245 return $data;
238 } 246 }
239 247
240 -  
241 -  
242 } 248 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :Notice.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/3/6 16:01
  8 + */
  9 +
  10 +namespace App\Console\Commands\Notice;
  11 +
  12 +use App\Models\Com\KeywordVideoTaskLog;
  13 +use App\Models\Domain\DomainInfo;
  14 +use Illuminate\Console\Command;
  15 +use Illuminate\Support\Facades\DB;
  16 +
  17 +/**
  18 + * @remark :通知C端生成界面
  19 + * @name :Notice
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2024/3/6 16:01
  23 + */
  24 +class Notice extends Command
  25 +{
  26 + /**
  27 + * The name and signature of the console command.
  28 + *
  29 + * @var string
  30 + */
  31 + protected $signature = 'notice_c';
  32 +
  33 + /**
  34 + * The console command description.
  35 + *
  36 + * @var string
  37 + */
  38 + protected $description = '通知C端生成界面';
  39 +
  40 + /**
  41 + * @remark :通知C端生成界面
  42 + * @name :handle
  43 + * @author :lyh
  44 + * @method :post
  45 + * @time :2023/11/20 15:13
  46 + */
  47 + public function handle(){
  48 + $yesterday = date('Y-m-d', strtotime('yesterday'));
  49 + $keywordVideoModel = new KeywordVideoTaskLog();
  50 + $list = $keywordVideoModel->select('project_id')
  51 + ->groupBy('project_id')->whereBetween('created_at', [$yesterday.' 00:00:00',$yesterday.' 23:59:59'])->get()->toArray();
  52 + $project_arr = [];
  53 + if(empty($list)){
  54 + echo date('Y-m-d H:i:s') . '无需通知' . PHP_EOL;
  55 + return false;
  56 + }
  57 + foreach ($list as $k => $v){
  58 + $project_arr[] = $v['project_id'];
  59 + }
  60 + $domainModel = new DomainInfo();
  61 + $domainList = $domainModel->formatQuery(['project_id'=>['in',$project_arr]])->get()->toArray();
  62 + if(empty($domainList)){
  63 + echo date('Y-m-d H:i:s') . '无域名:'.json_encode($domainList) . PHP_EOL;
  64 + return false;
  65 + }
  66 + foreach ($domainList as $v1){
  67 + //TODO::通知C端
  68 + $this->curlDelRoute($v1['domain'],$v1['project_id']);
  69 + }
  70 + return true;
  71 + }
  72 +
  73 + /**
  74 + * @remark :删除路由通知C端
  75 + * @name :curlDelRoute
  76 + * @author :lyh
  77 + * @method :post
  78 + * @time :2023/11/30 14:43
  79 + */
  80 + public function curlDelRoute($domain,$project_id){
  81 + if (strpos($domain, 'https://') === false) {
  82 + $domain = 'https://' . $domain . '/';
  83 + }
  84 + $url = $domain.'api/update_page/?project_id='.$project_id.'&route=6';
  85 + shell_exec('curl -k "'.$url.'"');
  86 + return true;
  87 + }
  88 +}
@@ -44,6 +44,7 @@ class Kernel extends ConsoleKernel @@ -44,6 +44,7 @@ class Kernel extends ConsoleKernel
44 $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次 44 $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次
45 45
46 $schedule->command('recommended_suppliers')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商 46 $schedule->command('recommended_suppliers')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
  47 + $schedule->command('notice_c')->dailyAt('02:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
47 } 48 }
48 49
49 /** 50 /**
@@ -211,7 +211,7 @@ class OptimizeController extends BaseController @@ -211,7 +211,7 @@ class OptimizeController extends BaseController
211 $query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]); 211 $query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]);
212 } 212 }
213 if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at']) && is_array($this->map['online_updated_at'])){ 213 if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at']) && is_array($this->map['online_updated_at'])){
214 - $query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']); 214 + $query = $query->where('gl_project_deploy_optimize.start_date','>=' ,$this->map['online_updated_at'][0])->where('gl_project_deploy_optimize.start_date','<' ,$this->map['online_updated_at'][1]);
215 } 215 }
216 if(isset($this->map['special'])){ 216 if(isset($this->map['special'])){
217 $query = $query->whereRaw("FIND_IN_SET(?, gl_project_deploy_optimize.special) > 0", [$this->map['special']]); 217 $query = $query->whereRaw("FIND_IN_SET(?, gl_project_deploy_optimize.special) > 0", [$this->map['special']]);
@@ -328,25 +328,5 @@ class ComController extends BaseController @@ -328,25 +328,5 @@ class ComController extends BaseController
328 $this->response('success',Code::SUCCESS,$data); 328 $this->response('success',Code::SUCCESS,$data);
329 } 329 }
330 330
331 - /**  
332 - * @remark :推荐采购商  
333 - * @name :recommendedPurchaser  
334 - * @author :lyh  
335 - * @method :post  
336 - * @time :2024/3/4 10:10  
337 - */  
338 - public function recommendedPurchaser(){  
339 - $purchaserModel = new Purchaser();  
340 - $data = [];  
341 - $lists = $purchaserModel->list(['project_id'=>$this->user['project_id']]);  
342 - if(!empty($lists)){  
343 - foreach ($lists as $v){  
344 - $resultData = json_decode($v['data']);  
345 - foreach ($resultData as $value){  
346 - $data[] = $value;  
347 - }  
348 - }  
349 - }  
350 - $this->response('success',Code::SUCCESS,$data);  
351 - } 331 +
352 } 332 }
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Bside\Setting; @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Bside\Setting;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
  7 +use App\Http\Logic\Aside\Domain\DomainInfoLogic;
7 use App\Http\Logic\Bside\Setting\ProjectCountryLogic; 8 use App\Http\Logic\Bside\Setting\ProjectCountryLogic;
8 9
9 /** 10 /**
@@ -32,4 +33,59 @@ class ProjectCountryController extends BaseController @@ -32,4 +33,59 @@ class ProjectCountryController extends BaseController
32 $projectCountryLogic->country_save(); 33 $projectCountryLogic->country_save();
33 $this->response('success'); 34 $this->response('success');
34 } 35 }
  36 +
  37 + /**
  38 + * 设置语种自定义跳转链接
  39 + * @param DomainInfoLogic $domainInfoLogic
  40 + * @author Akun
  41 + * @date 2024/03/05 9:47
  42 + */
  43 + public function custom_save(DomainInfoLogic $domainInfoLogic){
  44 + $this->request->validate([
  45 + 'language_id'=>'required',
  46 + 'custom_domain'=>'required',
  47 + 'is_create'=>'required'
  48 + ],[
  49 + 'language_id.required' => 'language_id不能为空',
  50 + 'custom_domain.required' => 'custom_domain不能为空',
  51 + 'is_create.required' => 'is_create不能为空'
  52 + ]);
  53 + $domainInfoLogic->country_custom($this->user['project_id']);
  54 + $this->response('success');
  55 + }
  56 +
  57 +
  58 + /**
  59 + * 清除语种自定义跳转链接
  60 + * @param ProjectCountryLogic $projectCountryLogic
  61 + * @author Akun
  62 + * @date 2024/03/05 10:20
  63 + */
  64 + public function custom_del(ProjectCountryLogic $projectCountryLogic){
  65 + $this->request->validate([
  66 + 'language_id'=>'required'
  67 + ],[
  68 + 'language_id.required' => 'language_id不能为空'
  69 + ]);
  70 +
  71 + $projectCountryLogic->country_custom_del();
  72 + $this->response('success');
  73 + }
  74 +
  75 + /**
  76 + * 获取语种自定义跳转链接详情
  77 + * @param ProjectCountryLogic $projectCountryLogic
  78 + * @author Akun
  79 + * @date 2024/03/06 14:37
  80 + */
  81 + public function custom_info(ProjectCountryLogic $projectCountryLogic){
  82 + $this->request->validate([
  83 + 'language_id'=>'required'
  84 + ],[
  85 + 'language_id.required' => 'language_id不能为空'
  86 + ]);
  87 +
  88 + $info = $projectCountryLogic->country_custom_info();
  89 + $this->response('success',Code::SUCCESS,$info);
  90 + }
35 } 91 }
@@ -29,7 +29,7 @@ class WebSettingReceivingController extends BaseController @@ -29,7 +29,7 @@ class WebSettingReceivingController extends BaseController
29 * @time :2023/5/8 16:23 29 * @time :2023/5/8 16:23
30 */ 30 */
31 public function save(WebSettingReceivingLogic $webSettingReceivingLogic){ 31 public function save(WebSettingReceivingLogic $webSettingReceivingLogic){
32 - $webSettingReceivingLogic->setting_receiving_save();  
33 - $this->response('success'); 32 + $result = $webSettingReceivingLogic->setting_receiving_save();
  33 + $this->response('success',Code::SUCCESS,$result);
34 } 34 }
35 } 35 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :SuppliersController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/3/7 9:23
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Suppliers;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Models\Com\Purchaser;
  15 +
  16 +/**
  17 + * @remark :推荐采购商
  18 + * @name :SuppliersController
  19 + * @author :lyh
  20 + * @method :post
  21 + * @time :2024/3/7 9:23
  22 + */
  23 +class SuppliersController extends BaseController
  24 +{
  25 + public $domain = 'https://admin.hagro.cn/';
  26 +
  27 + /**
  28 + * @remark :推荐采购商
  29 + * @name :recommendedPurchaser
  30 + * @author :lyh
  31 + * @method :post
  32 + * @time :2024/3/4 10:10
  33 + */
  34 + public function recommendedPurchaser(){
  35 + $purchaserModel = new Purchaser();
  36 + $data = [];
  37 + $lists = $purchaserModel->list(['project_id'=>$this->user['project_id']]);
  38 + if(!empty($lists)){
  39 + foreach ($lists as $v){
  40 + $resultData = json_decode($v['data']);
  41 + foreach ($resultData as $value){
  42 + $data[] = $value;
  43 + }
  44 + }
  45 + }
  46 + $this->response('success',Code::SUCCESS,$data);
  47 + }
  48 +
  49 + /**
  50 + * @remark :请求黑格公共方法
  51 + * @name :_action
  52 + * @author :lyh
  53 + * @method :post
  54 + * @time :2024/3/7 9:30
  55 + */
  56 + public function _action($api_url,$action_name,$param){
  57 + $url = $this->domain.$api_url;
  58 + ksort($param);
  59 + $token = $action_name. '+' .date('Y-m-d'). '+' .http_build_query($param);
  60 + $param['token'] = md5($token);
  61 + $res = http_post($url,json_encode($param));
  62 + if($res['code'] != 200){
  63 + $this->response($res['message'],Code::SYSTEM_ERROR);
  64 + }
  65 + return $this->success($res['data']);
  66 + }
  67 + /**
  68 + * @remark :按名字搜索公司
  69 + * @name :company_domain
  70 + * @author :lyh
  71 + * @method :post
  72 + * @time :2024/3/7 9:27
  73 + */
  74 + public function company_domain(){
  75 + $api_url = 'api/company_domain';
  76 + $action_name = 'company_domain';
  77 + $param = [
  78 + 'search'=>$this->param['search'],
  79 + ];
  80 + $res = $this->_action($api_url,$action_name,$param ?? []);
  81 + $this->response('success',Code::SUCCESS,$res);
  82 + }
  83 +
  84 + /**
  85 + * @remark :通过域名获取公司信息
  86 + * @name :company_detail
  87 + * @author :lyh
  88 + * @method :post
  89 + * @time :2024/3/7 9:46
  90 + */
  91 + public function company_detail(){
  92 + $api_url = 'api/company_detail';
  93 + $action_name = 'company_detail';
  94 + $param = [
  95 + 'domain'=>$this->param['domain'],
  96 + ];
  97 + $res = $this->_action($api_url,$action_name,$param);
  98 + $this->response('success',Code::SUCCESS,$res);
  99 + }
  100 +
  101 + /**
  102 + * @remark :领英决策人员
  103 + * @name :company_linked
  104 + * @author :lyh
  105 + * @method :post
  106 + * @time :2024/3/7 9:48
  107 + */
  108 + public function company_linked(){
  109 + $api_url = 'api/company_linked';
  110 + $action_name = 'company_linked';
  111 + $param = [
  112 + 'domain'=>$this->param['domain'],
  113 + 'page'=>$this->page,
  114 + 'page_size'=>$this->row,
  115 + ];
  116 + if(isset($this->param['keyword'])){
  117 + $param['keyword'] = $this->param['keyword'];
  118 + }
  119 + if(isset($this->param['position'])){
  120 + $param['position'] = $this->param['position'];
  121 + }
  122 + $res = $this->_action($api_url,$action_name,$param);
  123 + $this->response('success',Code::SUCCESS,$res);
  124 + }
  125 +
  126 + /**
  127 + * @remark :海关数据信息
  128 + * @name :trade_trend
  129 + * @author :lyh
  130 + * @method :post
  131 + * @time :2024/3/7 9:51
  132 + */
  133 + public function trade_trend(){
  134 + $api_url = 'api/trade_trend';
  135 + $action_name = 'trade_trend';
  136 + $param = [
  137 + 'prod_desc'=>$this->param['prod_desc'] ?? '',
  138 + ];
  139 + $res = $this->_action($api_url,$action_name,$param);
  140 + $this->response('success',Code::SUCCESS,$res);
  141 + }
  142 +
  143 + /**
  144 + * @remark :供应商区域分布
  145 + * @name :supplier_area
  146 + * @author :lyh
  147 + * @method :post
  148 + * @time :2024/3/7 9:52
  149 + */
  150 + public function supplier_area(){
  151 + $api_url = 'api/supplier_area';
  152 + $action_name = 'supplier_area';
  153 + $param = [
  154 + 'prod_desc'=>$this->param['prod_desc'] ?? '',
  155 + 'start_date'=>$this->param['start_date'] ?? '',
  156 + 'end_date'=>$this->param['end_date'] ?? '',
  157 + ];
  158 + $res = $this->_action($api_url,$action_name,$param);
  159 + $this->response('success',Code::SUCCESS,$res);
  160 + }
  161 +
  162 + /**
  163 + * @remark :贸易伙伴
  164 + * @name :trade_partner
  165 + * @author :lyh
  166 + * @method :post
  167 + * @time :2024/3/7 9:54
  168 + */
  169 + public function trade_partner(){
  170 + $api_url = 'api/trade_partner';
  171 + $action_name = 'trade_partner';
  172 + $param = [
  173 + 'com_id'=>$this->param['com_id'] ?? '',
  174 + 'com_role'=>$this->param['com_role'] ?? '',
  175 + ];
  176 + $res = $this->_action($api_url,$action_name,$param);
  177 + $this->response('success',Code::SUCCESS,$res);
  178 + }
  179 +
  180 + /**
  181 + * @remark :贸易明细
  182 + * @name :trade_detail
  183 + * @author :lyh
  184 + * @method :post
  185 + * @time :2024/3/7 9:55
  186 + */
  187 + public function trade_detail(){
  188 + $api_url = 'api/trade_detail';
  189 + $action_name = 'trade_detail';
  190 + $param = [
  191 + 'prod_desc'=>$this->param['prod_desc'] ?? '',
  192 + ];
  193 + $res = $this->_action($api_url,$action_name,$param);
  194 + $this->response('success',Code::SUCCESS,$res);
  195 + }
  196 +
  197 + /**
  198 + * @remark :提单详情
  199 + * @name :bill_detail
  200 + * @author :lyh
  201 + * @method :post
  202 + * @time :2024/3/7 9:56
  203 + */
  204 + public function bill_detail(){
  205 + $api_url = 'api/bill_detail';
  206 + $action_name = 'bill_detail';
  207 + $param = [
  208 + 'prod_desc'=>$this->param['prod_desc'] ?? '',
  209 + 'page'=>$this->page,
  210 + 'page_size'=>$this->row,
  211 + ];
  212 + $res = $this->_action($api_url,$action_name,$param);
  213 + $this->response('success',Code::SUCCESS,$res);
  214 + }
  215 +
  216 + /**
  217 + * @remark :进口产品信息
  218 + * @name :import_product
  219 + * @author :lyh
  220 + * @method :post
  221 + * @time :2024/3/7 9:59
  222 + */
  223 + public function import_product(){
  224 + $api_url = 'api/import_product';
  225 + $action_name = 'import_product';
  226 + $param = [
  227 + 'com_id'=>$this->param['com_id'] ?? '',
  228 + 'com_role'=>$this->param['com_role'] ?? '',
  229 + ];
  230 + $res = $this->_action($api_url,$action_name,$param);
  231 + $this->response('success',Code::SUCCESS,$res);
  232 + }
  233 +}
@@ -6,6 +6,7 @@ namespace App\Http\Logic\Aside\Domain; @@ -6,6 +6,7 @@ namespace App\Http\Logic\Aside\Domain;
6 use App\Http\Logic\Aside\BaseLogic; 6 use App\Http\Logic\Aside\BaseLogic;
7 use App\Models\Devops\ServerConfig; 7 use App\Models\Devops\ServerConfig;
8 use App\Models\Domain\DomainInfo; 8 use App\Models\Domain\DomainInfo;
  9 +use App\Models\Project\CountryCustom;
9 use App\Models\Project\DeployOptimize; 10 use App\Models\Project\DeployOptimize;
10 use App\Models\Project\Project; 11 use App\Models\Project\Project;
11 use App\Utils\HttpUtils; 12 use App\Utils\HttpUtils;
@@ -350,4 +351,68 @@ class DomainInfoLogic extends BaseLogic @@ -350,4 +351,68 @@ class DomainInfoLogic extends BaseLogic
350 } 351 }
351 return false; 352 return false;
352 } 353 }
  354 +
  355 + /**
  356 + * 设置语种自定义跳转链接
  357 + * @param $project_id
  358 + * @return array
  359 + * @author Akun
  360 + * @date 2024/03/05 9:48
  361 + */
  362 + public function country_custom($project_id){
  363 + $project_model = new Project();
  364 + $project_info = $project_model->read(['id'=>$project_id],'serve_id');
  365 + if($project_info === false){
  366 + $this->fail('获取项目数据失败');
  367 + }
  368 +
  369 + $custom_model = new CountryCustom();
  370 + if($this->param['is_create']){
  371 + //需要创建站点
  372 + $server_model = new ServerConfig();
  373 + $server_info = $server_model->read(['id'=>$project_info['serve_id']],['init_domain', 'host']);
  374 + if($server_info === false){
  375 + $this->fail('获取服务器数据失败');
  376 + }
  377 +
  378 + //域名是否都已经解析
  379 + if(strpos($this->param['custom_domain'],'//') === false){
  380 + $this->param['custom_domain'] = '//'.$this->param['custom_domain'];
  381 + }
  382 + $domain_arr = parse_url($this->param['custom_domain']);
  383 + if(!isset($domain_arr['host'])){
  384 + $this->fail('自定义域名填写错误');
  385 + }
  386 + $this->param['custom_domain'] = $domain_arr['host'];
  387 + //判断域名是否已经被使用
  388 + $has_info = $custom_model->read(['custom_domain'=>$this->param['custom_domain']]);
  389 + if($has_info && ($has_info['project_id'] != $project_id || $has_info['language_id'] != $this->param['language_id'])){
  390 + $this->fail('自定义域名已被使用');
  391 + }
  392 + if(!$this->check_cname($this->param['custom_domain'], $server_info)){
  393 + $this->fail('域名' . $this->param['custom_domain'] . '未解析至目标服务器');
  394 + }
  395 + }else{
  396 + $this->param['custom_domain'] = str_replace('https://','',$this->param['custom_domain']);
  397 + $this->param['custom_domain'] = str_replace('http://','',$this->param['custom_domain']);
  398 + $this->param['custom_domain'] = str_replace('//','',$this->param['custom_domain']);
  399 + }
  400 +
  401 + $info = $custom_model->read(['project_id'=>$project_id,'language_id'=>$this->param['language_id']]);
  402 + if($info === false){
  403 + $this->param['project_id'] = $project_id;
  404 + $custom_model->add($this->param);
  405 + }else{
  406 + $custom_model->edit($this->param,['id'=>$info['id']]);
  407 + }
  408 +
  409 + if($this->param['is_create']){
  410 + //创建站点,设置证书
  411 + $this->param['key'] = $this->param['private_key'] ?? '';
  412 + $this->param['cert'] = $this->param['private_cert'] ?? '';
  413 + $this->setDomainSsl($server_info['init_domain'],$this->param['custom_domain'],[],[],0);
  414 + }
  415 +
  416 + return $this->success();
  417 + }
353 } 418 }
@@ -4,6 +4,8 @@ namespace App\Http\Logic\Bside\Setting; @@ -4,6 +4,8 @@ namespace App\Http\Logic\Bside\Setting;
4 4
5 use App\Http\Logic\Bside\BaseLogic; 5 use App\Http\Logic\Bside\BaseLogic;
6 use App\Models\Project\Country as CountryModel; 6 use App\Models\Project\Country as CountryModel;
  7 +use App\Models\Project\CountryCustom;
  8 +use App\Models\WebSetting\WebLanguage;
7 9
8 class ProjectCountryLogic extends BaseLogic 10 class ProjectCountryLogic extends BaseLogic
9 { 11 {
@@ -24,8 +26,11 @@ class ProjectCountryLogic extends BaseLogic @@ -24,8 +26,11 @@ class ProjectCountryLogic extends BaseLogic
24 $lists = $this->model->read(['project_id'=>$this->user['project_id']]); 26 $lists = $this->model->read(['project_id'=>$this->user['project_id']]);
25 if (empty($lists)){ 27 if (empty($lists)){
26 $lists['country_lists'] = ''; 28 $lists['country_lists'] = '';
  29 + $lists['country_sort'] = '';
27 } 30 }
28 $lists['country_lists'] = $this->countryListsFormat($lists['country_lists']); 31 $lists['country_lists'] = $this->countryListsFormat($lists['country_lists']);
  32 + $lists['country_sort'] = $this->countrySortFormat($lists['country_sort']);
  33 +
29 return $this->success($lists); 34 return $this->success($lists);
30 } 35 }
31 36
@@ -41,6 +46,12 @@ class ProjectCountryLogic extends BaseLogic @@ -41,6 +46,12 @@ class ProjectCountryLogic extends BaseLogic
41 $this->param['country_lists'] = ''; 46 $this->param['country_lists'] = '';
42 } 47 }
43 $this->param['country_lists'] = $this->countryListsFormat($this->param['country_lists']); 48 $this->param['country_lists'] = $this->countryListsFormat($this->param['country_lists']);
  49 +
  50 + if(!isset($this->param['country_sort']) || empty($this->param['country_sort'])){
  51 + $this->param['country_sort'] = '';
  52 + }
  53 + $this->param['country_sort'] = $this->countrySortFormat($this->param['country_sort']);
  54 +
44 $info = $this->model->read(['project_id'=>$this->user['project_id']]); 55 $info = $this->model->read(['project_id'=>$this->user['project_id']]);
45 if($info === false){ 56 if($info === false){
46 $this->param['project_id'] = $this->user['project_id']; 57 $this->param['project_id'] = $this->user['project_id'];
@@ -51,9 +62,45 @@ class ProjectCountryLogic extends BaseLogic @@ -51,9 +62,45 @@ class ProjectCountryLogic extends BaseLogic
51 if($rs === false){ 62 if($rs === false){
52 $this->fail('当前数据不存在'); 63 $this->fail('当前数据不存在');
53 } 64 }
  65 +
  66 + $custom_model = new CountryCustom();
  67 + //将未勾选的设置了自定义跳转的语种,置为不可用
  68 + $custom_model->edit(['status'=>0],['project_id'=>$this->user['project_id'],'language_id'=>['not in',explode(',',$this->param['country_lists'])]]);
  69 + //将勾选的设置了自定义跳转的语种,置为可用
  70 + $custom_model->edit(['status'=>1],['project_id'=>$this->user['project_id'],'language_id'=>['in',explode(',',$this->param['country_lists'])]]);
  71 +
54 return $this->success(); 72 return $this->success();
55 } 73 }
56 74
  75 + /**
  76 + * 删除语种自定义跳转
  77 + * @return array
  78 + * @author Akun
  79 + * @date 2024/03/05 10:18
  80 + */
  81 + public function country_custom_del(){
  82 + $custom_model = new CountryCustom();
  83 + $rs = $custom_model->del(['project_id'=>$this->user['project_id'],'language_id'=>$this->param['language_id']]);
  84 + if($rs === false){
  85 + $this->fail('error');
  86 + }
  87 +
  88 + return $this->success();
  89 + }
  90 +
  91 + /**
  92 + * 获取语种自定义跳转详情
  93 + * @return array|bool
  94 + * @author Akun
  95 + * @date 2024/03/06 14:38
  96 + */
  97 + public function country_custom_info(){
  98 + $custom_model = new CountryCustom();
  99 + $info = $custom_model->read(['project_id'=>$this->user['project_id'],'language_id'=>$this->param['language_id']],['language_id','custom_domain','is_create','type','private_key','private_cert']);
  100 +
  101 + return $this->success($info?:[]);
  102 + }
  103 +
57 protected function countryListsFormat($country_lists) 104 protected function countryListsFormat($country_lists)
58 { 105 {
59 if(empty($country_lists)){ 106 if(empty($country_lists)){
@@ -68,4 +115,14 @@ class ProjectCountryLogic extends BaseLogic @@ -68,4 +115,14 @@ class ProjectCountryLogic extends BaseLogic
68 } 115 }
69 return implode(',', $country_lists); 116 return implode(',', $country_lists);
70 } 117 }
  118 +
  119 + protected function countrySortFormat($country_sort){
  120 + if(empty($country_sort)){
  121 + $webLanguageModel = new WebLanguage();
  122 + $all_language_ids = array_column($webLanguageModel->list([],'id',['id'],'asc'),'id');
  123 + $country_sort = implode(',',$all_language_ids);
  124 + }
  125 +
  126 + return $country_sort;
  127 + }
71 } 128 }
@@ -28,11 +28,15 @@ class WebSettingAmpLogic extends BaseLogic @@ -28,11 +28,15 @@ class WebSettingAmpLogic extends BaseLogic
28 return $this->success(); 28 return $this->success();
29 } 29 }
30 //log图处理 30 //log图处理
31 - $info['top_logo'] = getImageUrl($info['top_logo'],$this->user['storage_type'],$this->user['project_location']); 31 + $info['top_logo'] = Arr::s2a($info['top_logo']);
  32 + if(!empty($info['top_logo'])){
  33 + $info['top_logo']['url'] = getImageUrl($info['top_logo']['url'], $this->user['storage_type'], $this->user['project_location']);
  34 + }
32 //banner处理 35 //banner处理
  36 + $info['index_banner'] = Arr::s2a($info['index_banner']);
33 if (!empty($info['index_banner'])) { 37 if (!empty($info['index_banner'])) {
34 foreach ($info['index_banner'] as &$v) { 38 foreach ($info['index_banner'] as &$v) {
35 - $v = getImageUrl($v,$this->user['storage_type'],$this->user['project_location']); 39 + $v['url'] = getImageUrl($v['url'], $this->user['storage_type'], $this->user['project_location']);
36 } 40 }
37 } 41 }
38 return $this->success($info); 42 return $this->success($info);
@@ -48,12 +52,16 @@ class WebSettingAmpLogic extends BaseLogic @@ -48,12 +52,16 @@ class WebSettingAmpLogic extends BaseLogic
48 { 52 {
49 try { 53 try {
50 //log图处理 54 //log图处理
51 - $this->param['top_logo'] = str_replace_url($this->param['top_logo'] ?? ''); 55 + if (isset($this->param['top_logo']) && $this->param['top_logo']) {
  56 + $this->param['top_logo']['url'] = str_replace_url($this->param['top_logo']['url'] ?? '');
  57 + }
  58 + $this->param['top_logo'] = Arr::a2s($this->param['top_logo'] ?? []);
52 //banner处理 59 //banner处理
53 $index_banner = []; 60 $index_banner = [];
54 if (isset($this->param['index_banner']) && $this->param['index_banner']) { 61 if (isset($this->param['index_banner']) && $this->param['index_banner']) {
55 foreach ($this->param['index_banner'] as $v) { 62 foreach ($this->param['index_banner'] as $v) {
56 - $index_banner[] = str_replace_url($v); 63 + $v['url'] = str_replace_url($v['url'] ?? '');
  64 + $index_banner[] = $v;
57 } 65 }
58 } 66 }
59 $this->param['index_banner'] = Arr::a2s($index_banner); 67 $this->param['index_banner'] = Arr::a2s($index_banner);
@@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic; @@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic;
6 use App\Models\WebSetting\WebSettingReceiving; 6 use App\Models\WebSetting\WebSettingReceiving;
7 use App\Models\WebSetting\WebSettingText; 7 use App\Models\WebSetting\WebSettingText;
8 use App\Services\SyncService; 8 use App\Services\SyncService;
  9 +use Illuminate\Support\Facades\DB;
9 10
10 class WebSettingReceivingLogic extends BaseLogic 11 class WebSettingReceivingLogic extends BaseLogic
11 { 12 {
@@ -34,24 +35,37 @@ class WebSettingReceivingLogic extends BaseLogic @@ -34,24 +35,37 @@ class WebSettingReceivingLogic extends BaseLogic
34 * @time :2023/5/8 16:26 35 * @time :2023/5/8 16:26
35 */ 36 */
36 public function setting_receiving_save(){ 37 public function setting_receiving_save(){
  38 + $data = [];
  39 + foreach ($this->param['data'] as $v){
  40 + if($v['type'] == 1){
  41 + // 使用正则表达式匹配中国大陆手机号
  42 + $pattern = '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/';
  43 + if (!preg_match($pattern, $v['values'])) {
  44 + $this->fail('当前数据不符合规则:'.$v['values']);
  45 + }
  46 + }
  47 + if($v['type'] == 2){
  48 + // 使用正则表达式匹配中国大陆手机号
  49 + $pattern = '/^1[3456789]\d{9}$/';
  50 + if (!preg_match($pattern, $v['values'])) {
  51 + $this->fail('当前数据不符合规则:'.$v['values']);
  52 + }
  53 + }
  54 + $v['project_id'] = $this->user['project_id'];
  55 + $v['created_at'] = date('Y-m-d H:i:s');
  56 + $v['updated_at'] = date('Y-m-d H:i:s');
  57 + $data[] = $v;
  58 + }
  59 + DB::connection('custom_mysql')->beginTransaction();
37 try { 60 try {
38 $this->model->del(['project_id'=>$this->user['project_id']]); 61 $this->model->del(['project_id'=>$this->user['project_id']]);
39 - foreach ($this->param['data'] as $k => $v){  
40 - if($v['type'] == 2){  
41 - // 使用正则表达式匹配中国大陆手机号  
42 - $pattern = '/^1[3456789]\d{9}$/';  
43 - if (!preg_match($pattern, $v['values'])) {  
44 - continue;  
45 - }  
46 - }  
47 - $v['project_id'] = $this->user['project_id'];  
48 - $v['created_at'] = date('Y-m-d H:i:s');  
49 - $v['updated_at'] = date('Y-m-d H:i:s');  
50 - $this->param['data'][$k] = $v; 62 + if(!empty($data)){
  63 + $this->model->insert($data);
51 } 64 }
52 - $this->model->insert($this->param['data']); 65 + DB::connection('custom_mysql')->commit();
53 }catch (\Exception $e){ 66 }catch (\Exception $e){
54 - $this->fail('error'); 67 + DB::connection('custom_mysql')->rollBack();
  68 + $this->fail('编辑失败,请联系管理员');
55 } 69 }
56 (new SyncService())->projectAcceptAddress($this->user['project_id']); 70 (new SyncService())->projectAcceptAddress($this->user['project_id']);
57 return $this->success(); 71 return $this->success();
@@ -37,14 +37,14 @@ class WebSettingServiceLogic extends BaseLogic @@ -37,14 +37,14 @@ class WebSettingServiceLogic extends BaseLogic
37 * @time :2023/5/4 11:10 37 * @time :2023/5/4 11:10
38 */ 38 */
39 public function setting_service_save(){ 39 public function setting_service_save(){
40 - DB::beginTransaction(); 40 + DB::connection('custom_mysql')->beginTransaction();
41 try { 41 try {
42 $this->param['data'] = Common::uniqueMultiArray($this->param['data']); 42 $this->param['data'] = Common::uniqueMultiArray($this->param['data']);
43 //删除以前的数据 43 //删除以前的数据
44 $this->model->del(['project_id'=>$this->user['project_id']]); 44 $this->model->del(['project_id'=>$this->user['project_id']]);
45 $data = []; 45 $data = [];
46 foreach ($this->param['data'] as $k => $v){ 46 foreach ($this->param['data'] as $k => $v){
47 - if(isset($v['values']) && empty($v['values'])){ 47 + if(isset($v['values']) && !empty($v['values'])){
48 $v['project_id'] = $this->user['project_id']; 48 $v['project_id'] = $this->user['project_id'];
49 $v['created_at'] = date('Y-m-d H:i:s'); 49 $v['created_at'] = date('Y-m-d H:i:s');
50 $v['updated_at'] = date('Y-m-d H:i:s'); 50 $v['updated_at'] = date('Y-m-d H:i:s');
@@ -54,10 +54,9 @@ class WebSettingServiceLogic extends BaseLogic @@ -54,10 +54,9 @@ class WebSettingServiceLogic extends BaseLogic
54 if(!empty($data)){ 54 if(!empty($data)){
55 $this->model->insert($data); 55 $this->model->insert($data);
56 } 56 }
57 -  
58 - DB::commit(); 57 + DB::connection('custom_mysql')->commit();
59 }catch (\Exception $e){ 58 }catch (\Exception $e){
60 - DB::rollBack(); 59 + DB::connection('custom_mysql')->rollBack();
61 $this->fail('系统错误,请联系管理员'); 60 $this->fail('系统错误,请联系管理员');
62 } 61 }
63 return $this->success(); 62 return $this->success();
@@ -55,7 +55,7 @@ class UserLoginLogic @@ -55,7 +55,7 @@ class UserLoginLogic
55 $projectArr[] = $v['project_id']; 55 $projectArr[] = $v['project_id'];
56 } 56 }
57 $projectModel = new Project(); 57 $projectModel = new Project();
58 - $project_list = $projectModel->list(['id'=>['in',$projectArr],['delete_status'=>0]],'id',['id','title']); 58 + $project_list = $projectModel->list(['id'=>['in',$projectArr],'delete_status'=>0],'id',['id','title']);
59 //登录选择项目的有效时间 59 //登录选择项目的有效时间
60 Cache::add('login-project-'.$this->param['mobile'],1,300); 60 Cache::add('login-project-'.$this->param['mobile'],1,300);
61 return $this->success($project_list); 61 return $this->success($project_list);
  1 +<?php
  2 +
  3 +namespace App\Models\Project;
  4 +
  5 +use App\Models\Base;
  6 +use Illuminate\Database\Eloquent\SoftDeletes;
  7 +
  8 +class CountryCustom extends Base
  9 +{
  10 + use SoftDeletes;
  11 +
  12 + protected $table = 'gl_project_country_custom';
  13 +}
@@ -20,7 +20,19 @@ Route::middleware(['bloginauth'])->group(function () { @@ -20,7 +20,19 @@ Route::middleware(['bloginauth'])->group(function () {
20 Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken'); 20 Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken');
21 Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink'); 21 Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink');
22 Route::any('/getMobileProject', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getMobileProject'])->name('getMobileProject'); 22 Route::any('/getMobileProject', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getMobileProject'])->name('getMobileProject');
23 - Route::any('/recommendedPurchaser', [\App\Http\Controllers\Bside\BCom\ComController::class, 'recommendedPurchaser'])->name('recommendedPurchaser'); 23 + //黑格数据
  24 + Route::prefix('suppliers')->group(function () {
  25 + Route::any('/recommendedPurchaser', [\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'recommendedPurchaser'])->name('suppliers_recommendedPurchaser');
  26 + Route::any('/company_domain',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'company_domain'])->name('suppliers_company_domain');
  27 + Route::any('/company_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'company_detail'])->name('suppliers_company_detail');
  28 + Route::any('/company_linked',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'company_linked'])->name('suppliers_company_linked');
  29 + Route::any('/trade_trend',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'trade_trend'])->name('suppliers_trade_trend');
  30 + Route::any('/supplier_area',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'supplier_area'])->name('suppliers_supplier_area');
  31 + Route::any('/trade_partner',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'trade_partner'])->name('suppliers_trade_partner');
  32 + Route::any('/trade_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'trade_detail'])->name('suppliers_trade_detail');
  33 + Route::any('/bill_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'bill_detail'])->name('suppliers_bill_detail');
  34 + Route::any('/import_product',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'import_product'])->name('suppliers_import_product');
  35 + });
24 //用户相关路由 36 //用户相关路由
25 Route::prefix('user')->group(function () { 37 Route::prefix('user')->group(function () {
26 Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists'); 38 Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists');
@@ -156,6 +168,9 @@ Route::middleware(['bloginauth'])->group(function () { @@ -156,6 +168,9 @@ Route::middleware(['bloginauth'])->group(function () {
156 Route::prefix('country')->group(function () { 168 Route::prefix('country')->group(function () {
157 Route::any('/info', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'info'])->name('web_setting_country_info'); 169 Route::any('/info', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'info'])->name('web_setting_country_info');
158 Route::any('/save', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'save'])->name('web_setting_country_save'); 170 Route::any('/save', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'save'])->name('web_setting_country_save');
  171 + Route::any('/custom_save', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'custom_save'])->name('web_setting_country_custom_save');
  172 + Route::any('/custom_del', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'custom_del'])->name('web_setting_country_custom_del');
  173 + Route::any('/custom_info', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'custom_info'])->name('web_setting_country_custom_info');
159 }); 174 });
160 //客服设置 175 //客服设置
161 Route::prefix('service')->group(function () { 176 Route::prefix('service')->group(function () {