作者 zhl

Merge branch 'develop' of 47.244.231.31:zhl/globalso-v6 into develop

@@ -5,6 +5,7 @@ namespace App\Console\Commands; @@ -5,6 +5,7 @@ namespace App\Console\Commands;
5 5
6 use App\Models\Devops\DevopsTaskLog; 6 use App\Models\Devops\DevopsTaskLog;
7 use App\Models\Project\Project; 7 use App\Models\Project\Project;
  8 +use App\Utils\EncryptUtils;
8 use Illuminate\Console\Command; 9 use Illuminate\Console\Command;
9 use App\Models\Devops\DevopsTask as DevopsTaskModel; 10 use App\Models\Devops\DevopsTask as DevopsTaskModel;
10 11
@@ -45,17 +46,14 @@ class DevopsTask extends Command @@ -45,17 +46,14 @@ class DevopsTask extends Command
45 */ 46 */
46 public function handle() 47 public function handle()
47 { 48 {
48 - while (true){  
49 $tasks = DevopsTaskModel::where('status', DevopsTaskModel::STATUS_PENDING)->get(); 49 $tasks = DevopsTaskModel::where('status', DevopsTaskModel::STATUS_PENDING)->get();
50 foreach ($tasks as $task){ 50 foreach ($tasks as $task){
51 - echo "Start task " . $task->id . PHP_EOL; 51 + echo "Start task " . $task->id;
52 if($task->type == DevopsTaskModel::TYPE_MYSQL){ 52 if($task->type == DevopsTaskModel::TYPE_MYSQL){
53 $this->updateTable($task); 53 $this->updateTable($task);
54 } 54 }
55 echo "End task " . $task->id . PHP_EOL; 55 echo "End task " . $task->id . PHP_EOL;
56 } 56 }
57 - sleep(10);  
58 - }  
59 } 57 }
60 58
61 public function updateTable($task){ 59 public function updateTable($task){
@@ -64,6 +62,7 @@ class DevopsTask extends Command @@ -64,6 +62,7 @@ class DevopsTask extends Command
64 echo "project " . $project->id; 62 echo "project " . $project->id;
65 $log = DevopsTaskLog::addLog($task->id, $project->id); 63 $log = DevopsTaskLog::addLog($task->id, $project->id);
66 if($log->status == DevopsTaskModel::STATUS_ACTIVE){ 64 if($log->status == DevopsTaskModel::STATUS_ACTIVE){
  65 + echo 'continue' . PHP_EOL;
67 continue; 66 continue;
68 } 67 }
69 if(!$project->mysqlConfig){ 68 if(!$project->mysqlConfig){
@@ -73,6 +72,7 @@ class DevopsTask extends Command @@ -73,6 +72,7 @@ class DevopsTask extends Command
73 continue; 72 continue;
74 } 73 }
75 //DB类是单例模式,生命周期内修改配置不会生效 74 //DB类是单例模式,生命周期内修改配置不会生效
  75 + try {
76 $conn = new \mysqli( 76 $conn = new \mysqli(
77 $project->mysqlConfig->host, 77 $project->mysqlConfig->host,
78 $project->mysqlConfig->user, 78 $project->mysqlConfig->user,
@@ -80,6 +80,13 @@ class DevopsTask extends Command @@ -80,6 +80,13 @@ class DevopsTask extends Command
80 $project->databaseName(), 80 $project->databaseName(),
81 $project->mysqlConfig->port, 81 $project->mysqlConfig->port,
82 ); 82 );
  83 + }catch (\Exception $e){
  84 + $log->remark = mb_substr('数据库连接失败:' . $e->getMessage(), 0, 500);
  85 + $log->status = DevopsTaskLog::STATUS_ERROR;
  86 + $log->save();
  87 + echo '-->' . $log->remark . PHP_EOL;
  88 + continue;
  89 + }
83 $res = $conn->query($task->sql); 90 $res = $conn->query($task->sql);
84 91
85 $log->status = $res ? DevopsTaskLog::STATUS_ACTIVE : DevopsTaskLog::STATUS_ERROR; 92 $log->status = $res ? DevopsTaskLog::STATUS_ACTIVE : DevopsTaskLog::STATUS_ERROR;
@@ -55,7 +55,7 @@ class BaseController extends Controller @@ -55,7 +55,7 @@ class BaseController extends Controller
55 public function getParam(){ 55 public function getParam(){
56 foreach ($this->param as $k => $v){ 56 foreach ($this->param as $k => $v){
57 if(is_array($v)){ 57 if(is_array($v)){
58 - continue; 58 + $this->map[$k] = $v;
59 }else{ 59 }else{
60 if(empty($v) && ($v == null)){ 60 if(empty($v) && ($v == null)){
61 unset($this->param[$k]); 61 unset($this->param[$k]);
@@ -98,4 +98,5 @@ class LoginController extends BaseController @@ -98,4 +98,5 @@ class LoginController extends BaseController
98 SmsLog::createLog($mobile, $code['code'],SmsLog::TYPE_MANAGER_LOGIN); 98 SmsLog::createLog($mobile, $code['code'],SmsLog::TYPE_MANAGER_LOGIN);
99 $this->response('success'); 99 $this->response('success');
100 } 100 }
  101 +
101 } 102 }
@@ -6,6 +6,7 @@ use App\Enums\Common\Code; @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
6 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
7 use App\Http\Logic\Aside\Manage\ManageLogic; 7 use App\Http\Logic\Aside\Manage\ManageLogic;
8 use App\Http\Requests\Aside\Manage\ManageRequest; 8 use App\Http\Requests\Aside\Manage\ManageRequest;
  9 +use App\Models\Manage\Manage;
9 use App\Models\Manage\MenuSpecial; 10 use App\Models\Manage\MenuSpecial;
10 use App\Models\User\ProjectRole; 11 use App\Models\User\ProjectRole;
11 use App\Rules\Ids; 12 use App\Rules\Ids;
@@ -28,19 +29,10 @@ class ManageController extends BaseController @@ -28,19 +29,10 @@ class ManageController extends BaseController
28 * @method :post 29 * @method :post
29 * @time :2023/8/28 10:04 30 * @time :2023/8/28 10:04
30 */ 31 */
31 - public function list(Request $request, ManageLogic $logic) 32 + public function list()
32 { 33 {
33 - $map = [];  
34 - if(!empty($this->param['search'])){  
35 - $map[] = ['name|mobile', 'like', "%{$this->param['search']}%"];  
36 - }  
37 - if(!empty($this->param['dept_id'])){  
38 - $map[] = ['dept_id', $this->param['dept_id']];  
39 - }  
40 - if(!empty($this->param['gid'])){  
41 - $map[] = ['gid', $this->param['gid']];  
42 - }  
43 - $list = $logic->getList($map,['sort' => 'desc'],['*'],$this->row); 34 + $managerModel = new Manage();
  35 + $list = $managerModel->lists($this->map,$this->page,$this->row,$this->order);
44 $this->response('success',Code::SUCCESS,$list); 36 $this->response('success',Code::SUCCESS,$list);
45 } 37 }
46 38
@@ -496,6 +496,9 @@ class ProjectController extends BaseController @@ -496,6 +496,9 @@ class ProjectController extends BaseController
496 public function getManagerList(){ 496 public function getManagerList(){
497 $hrManagerModel = new ManageHr(); 497 $hrManagerModel = new ManageHr();
498 $this->map['status'] = $hrManagerModel::STATUS_ONE; 498 $this->map['status'] = $hrManagerModel::STATUS_ONE;
  499 + if(isset($this->map['entry_position']) && is_array($this->map['entry_position'])){
  500 + $this->map['entry_position'] = ['in',$this->map['entry_position']];
  501 + }
499 $lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']); 502 $lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']);
500 $this->response('success',Code::SUCCESS,$lists); 503 $this->response('success',Code::SUCCESS,$lists);
501 } 504 }
@@ -595,6 +598,7 @@ class ProjectController extends BaseController @@ -595,6 +598,7 @@ class ProjectController extends BaseController
595 $param = [ 598 $param = [
596 "id" => $item['id'], 599 "id" => $item['id'],
597 "title" => $item['title'], 600 "title" => $item['title'],
  601 + "company" => $item['company'],
598 "type" => $item['type'], 602 "type" => $item['type'],
599 "type_text" => Project::typeMap()[$item['type']] ?? '', 603 "type_text" => Project::typeMap()[$item['type']] ?? '',
600 "channel" => $item['channel'], 604 "channel" => $item['channel'],
@@ -624,7 +628,7 @@ class ProjectController extends BaseController @@ -624,7 +628,7 @@ class ProjectController extends BaseController
624 628
625 $list[] = $param; 629 $list[] = $param;
626 } 630 }
627 -  
628 - $this->response('success',Code::SUCCESS, $list); 631 + $data['list'] = $list;
  632 + $this->response('success',Code::SUCCESS, $data);
629 } 633 }
630 } 634 }
@@ -14,7 +14,9 @@ use App\Http\Controllers\Bside\BaseController; @@ -14,7 +14,9 @@ use App\Http\Controllers\Bside\BaseController;
14 use App\Http\Logic\Bside\Setting\WebSettingLogic; 14 use App\Http\Logic\Bside\Setting\WebSettingLogic;
15 use App\Models\Com\UpdateNotify; 15 use App\Models\Com\UpdateNotify;
16 use App\Models\Com\UpdateProgress; 16 use App\Models\Com\UpdateProgress;
  17 +use App\Models\Project\Country as CountryModel;
17 use App\Models\RouteMap\RouteMap; 18 use App\Models\RouteMap\RouteMap;
  19 +use App\Models\WebSetting\WebSettingCountry;
18 use Illuminate\Http\Request; 20 use Illuminate\Http\Request;
19 21
20 /** 22 /**
@@ -32,53 +34,98 @@ class CNoticeController extends BaseController @@ -32,53 +34,98 @@ class CNoticeController extends BaseController
32 * @param WebSettingLogic $webSettingLogic 34 * @param WebSettingLogic $webSettingLogic
33 */ 35 */
34 public function sendNotify(){ 36 public function sendNotify(){
35 - $type = $this->request->input('type', UpdateNotify::TYPE_MASTER);  
36 - if (FALSE == in_array($type, [UpdateNotify::TYPE_MASTER, UpdateNotify::TYPE_MINOR])){  
37 - $this->response('非法参数!', Code::USER_ERROR); 37 + $updateProgressModel = new UpdateProgress();
  38 + $progressInfo = $updateProgressModel->formatQuery(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']])->orderBy('id','desc')->first();
  39 + if((!empty($progressInfo))){
  40 + $progressInfo = $progressInfo->toArray();
  41 + if(($progressInfo['total_num'] > $progressInfo['current_num'])){
  42 + $this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$progressInfo);
38 } 43 }
39 - $page = $this->request->input('page', UpdateNotify::PAGE_ALL);  
40 - if (FALSE == in_array($type, [UpdateNotify::PAGE_ALL, UpdateNotify::PAGE_SINGLE])){  
41 - $this->response('非法参数!', Code::USER_ERROR);  
42 } 44 }
43 - $data = $this->sendNotifyMessage($type,$page);  
44 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($data, true) . PHP_EOL, FILE_APPEND);  
45 - if(!empty($data)){  
46 - $this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$data); 45 + //通知更新
  46 + if($this->param['type'] == UpdateNotify::TYPE_MASTER){
  47 + $this->updateMaster();
  48 + }else{
  49 + $this->updateMinorLanguages();
47 } 50 }
  51 + $urlStr = $this->getString($this->param['type'],$this->param['page']);
  52 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($urlStr, true) . PHP_EOL, FILE_APPEND);
  53 + $this->curlGet($urlStr);
48 $this->response('success'); 54 $this->response('success');
49 } 55 }
50 56
51 /** 57 /**
52 - * 通知c端  
53 - * @param string $type  
54 - * @return array 58 + * @remark :主键通知
  59 + * @name :updateMaster
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2023/9/12 14:46
55 */ 63 */
56 - public function sendNotifyMessage($type,$page){  
57 - $updateProgressModel = new UpdateProgress();  
58 - $progressInfo = $updateProgressModel->formatQuery(['project_id'=>$this->user['project_id'],'type'=>$type])->orderBy('id','desc')->first();  
59 - if((!empty($progressInfo))){  
60 - $progressInfo = $progressInfo->toArray();  
61 - if(($progressInfo['total_num'] > $progressInfo['current_num'])){  
62 - return $progressInfo; 64 + public function updateMaster(){
  65 + try {
  66 + $updateNotifyModel = new UpdateNotify();
  67 + if($this->param['page'] == UpdateNotify::PAGE_ALL){
  68 + //如果是更新所有
  69 + $routeMapModel = new RouteMap();
  70 + $count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count();
  71 + $updateNotifyModel->edit(['status' => 1], ['project_id' => $this->user['project_id'], 'status' => 0]);
  72 + $this->addProgress($count,$this->param['type'],$this->param['page']);
  73 + }elseif($this->param['page'] == UpdateNotify::PAGE_SINGLE){
  74 + //更新所有已修改的更新
  75 + $count = $updateNotifyModel->formatQuery(['project_id' => $this->user['project_id'], 'status' => 0])->count();
  76 + $updateNotifyModel->edit(['status' => 1], ['project_id' => $this->user['project_id'], 'status' => 0]);
  77 + $this->addProgress($count,$this->param['type'],$this->param['page']);
  78 + }else{
  79 + //根据传递的参数更新
  80 + $count = count($this->param['url']);
  81 + $extent = json_encode(['url'=>$this->param['url']]);
  82 + $this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
63 } 83 }
  84 + }catch (\Exception $e){
  85 + $this->response('error',Code::USER_ERROR);
64 } 86 }
  87 + return true;
  88 + }
  89 +
  90 + /**
  91 + * @remark :更新小语种
  92 + * @name :updateMinorLanguages
  93 + * @author :lyh
  94 + * @method :post
  95 + * @time :2023/9/12 14:48
  96 + */
  97 + public function updateMinorLanguages(){
65 $updateNotifyModel = new UpdateNotify(); 98 $updateNotifyModel = new UpdateNotify();
66 - $field = ($type == UpdateNotify::TYPE_MINOR) ? 'minor_languages_status' : 'status';  
67 - if($page == UpdateNotify::PAGE_ALL){ 99 + try {
  100 + if($this->param['page'] == UpdateNotify::PAGE_ALL){
  101 + $this->request->validate([
  102 + 'language' => 'required',
  103 + ], [
  104 + 'language.required' => '请选择语种',
  105 + ]);
68 //如果是更新所有 106 //如果是更新所有
69 $routeMapModel = new RouteMap(); 107 $routeMapModel = new RouteMap();
70 $count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count(); 108 $count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count();
  109 + $updateNotifyModel->edit(['minor_languages_status' => 1], ['project_id' => $this->user['project_id'], 'minor_languages_status' => 0]);
  110 + $extent = json_encode(['language'=>$this->param['language']]);
  111 + $this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
71 }else{ 112 }else{
72 - $count = $updateNotifyModel->formatQuery(['project_id' => $this->user['project_id'], $field => 0])->count(); 113 + $this->request->validate([
  114 + 'url'=>'required',
  115 + 'language' => 'required',
  116 + ], [
  117 + 'url.required' => '请输入更新链接',
  118 + 'language.required' => '请选择语种',
  119 + ]);
  120 + //根据传递的参数更新
  121 + $count = count($this->param['url']);
  122 + $extent = json_encode(['url'=>$this->param['url'],'language'=>$this->param['language']]);
  123 + $this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
73 } 124 }
74 - if($count == 0){  
75 - return []; 125 + }catch (\Exception $e){
  126 + $this->response('error',Code::USER_ERROR);
76 } 127 }
77 - $this->addProgress($count,$type);  
78 - $updateNotifyModel->edit([$field => 1], ['project_id' => $this->user['project_id'], $field => 0]);  
79 - $urlStr = $this->getString($type,$page);  
80 - $this->curlGet($urlStr);  
81 - return []; 128 + return true;
82 } 129 }
83 130
84 /** 131 /**
@@ -89,19 +136,22 @@ class CNoticeController extends BaseController @@ -89,19 +136,22 @@ class CNoticeController extends BaseController
89 * @time :2023/9/12 10:10 136 * @time :2023/9/12 10:10
90 */ 137 */
91 public function curlGet($url){ 138 public function curlGet($url){
92 - $curl = curl_init();  
93 - curl_setopt_array($curl, array(  
94 - CURLOPT_URL => $url,  
95 - CURLOPT_RETURNTRANSFER => true,  
96 - CURLOPT_ENCODING => '',  
97 - CURLOPT_MAXREDIRS => 10,  
98 - CURLOPT_TIMEOUT => 0,  
99 - CURLOPT_FOLLOWLOCATION => true,  
100 - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,  
101 - CURLOPT_CUSTOMREQUEST => 'GET',  
102 - ));  
103 - $response = curl_exec($curl);  
104 - curl_close($curl); 139 + $ch1 = curl_init();
  140 + $timeout = 0;
  141 + curl_setopt($ch1, CURLOPT_URL, $url);
  142 + curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
  143 + curl_setopt($ch1, CURLOPT_ENCODING, '');
  144 + curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
  145 + curl_setopt($ch1, CURLOPT_HTTPHEADER, array());
  146 + curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
  147 + curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, FALSE);
  148 + curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, FALSE);
  149 + curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
  150 + curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET');
  151 + curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  152 + $access_txt = curl_exec($ch1);
  153 + curl_close($ch1);
  154 + return json_decode($access_txt, true);
105 } 155 }
106 156
107 /** 157 /**
@@ -111,11 +161,13 @@ class CNoticeController extends BaseController @@ -111,11 +161,13 @@ class CNoticeController extends BaseController
111 * @method :post 161 * @method :post
112 * @time :2023/9/6 17:01 162 * @time :2023/9/6 17:01
113 */ 163 */
114 - public function addProgress($count,$type){ 164 + public function addProgress($count,$type,$page,$extend = ''){
115 $data = [ 165 $data = [
116 'total_num'=>$count, 166 'total_num'=>$count,
117 'current_num'=>0, 167 'current_num'=>0,
118 'type'=>$type, 168 'type'=>$type,
  169 + 'page'=>$page,
  170 + 'extends'=>$extend,
119 'project_id'=>$this->user['project_id'], 171 'project_id'=>$this->user['project_id'],
120 'created_at'=>date('Y-m-d H;i:s') 172 'created_at'=>date('Y-m-d H;i:s')
121 ]; 173 ];
@@ -139,4 +191,28 @@ class CNoticeController extends BaseController @@ -139,4 +191,28 @@ class CNoticeController extends BaseController
139 $string = http_build_query($param); 191 $string = http_build_query($param);
140 return $this->user['domain'].'api/updateHtmlNotify/?' . $string; 192 return $this->user['domain'].'api/updateHtmlNotify/?' . $string;
141 } 193 }
  194 +
  195 + /**
  196 + * @remark :获取当前项目选中的语种
  197 + * @name :getCountry
  198 + * @author :lyh
  199 + * @method :post
  200 + * @time :2023/9/12 15:20
  201 + */
  202 + public function getCountry(){
  203 + $countryModel = new CountryModel();
  204 + $info = $countryModel->read(['project_id'=>$this->user['project_id']],['id','country_lists']);
  205 + $ids = [];
  206 + if($info !== false){
  207 + $ids = explode(',',$info['country_lists']);
  208 + }
  209 + $webSettingCountryModel = new WebSettingCountry();
  210 + $lists = $webSettingCountryModel->list(['id'=>['in',$ids]],'id',['id','name','country_img']);
  211 + if (!empty($lists)){
  212 + foreach ($lists as $k => $v){
  213 + $lists[$k]['image_link'] = url('upload/country/' . $v['country_img']);
  214 + }
  215 + }
  216 + $this->response('success',Code::SUCCESS,$lists);
  217 + }
142 } 218 }
@@ -53,7 +53,7 @@ class BaseController extends Controller @@ -53,7 +53,7 @@ class BaseController extends Controller
53 public function getParam(){ 53 public function getParam(){
54 foreach ($this->param as $k => $v){ 54 foreach ($this->param as $k => $v){
55 if(is_array($v)){ 55 if(is_array($v)){
56 - continue; 56 + $this->map[$k] = $v;
57 }else{ 57 }else{
58 if(empty($v) && ($v == null)){ 58 if(empty($v) && ($v == null)){
59 unset($this->param[$k]); 59 unset($this->param[$k]);
@@ -300,6 +300,4 @@ class LoginController extends BaseController @@ -300,6 +300,4 @@ class LoginController extends BaseController
300 return $data; 300 return $data;
301 } 301 }
302 302
303 - public function ceshi(){  
304 - }  
305 } 303 }
@@ -79,8 +79,7 @@ class NewsController extends BaseController @@ -79,8 +79,7 @@ class NewsController extends BaseController
79 'id.required' => 'ID不能为空', 79 'id.required' => 'ID不能为空',
80 ]); 80 ]);
81 $info = $newsLogic->newsInfo(); 81 $info = $newsLogic->newsInfo();
82 - $info['url'] = $this->user['domain'] . $info['route'];  
83 - $info['image_link'] = getImageUrl($info['image']); 82 +
84 $this->response('success',Code::SUCCESS,$info); 83 $this->response('success',Code::SUCCESS,$info);
85 } 84 }
86 85
@@ -71,8 +71,8 @@ class BTemplateController extends BaseController @@ -71,8 +71,8 @@ class BTemplateController extends BaseController
71 * @time :2023/6/29 10:02 71 * @time :2023/6/29 10:02
72 */ 72 */
73 public function save(TemplateRequest $templateRequest,BTemplateLogic $BTemplateLogic){ 73 public function save(TemplateRequest $templateRequest,BTemplateLogic $BTemplateLogic){
74 - //演示项目,不允许其他号码编辑  
75 - if(($this->user['project_id'] == 1) && ($this->user['mobile'] != '15928018676' || $this->user['mobile'] != '15680871314') && ($this->param['source'] == 1)){ 74 + //演示项目,不允许其他号码编辑$this->user['mobile'] != '15928018676' ||
  75 + if(($this->user['project_id'] == 1) && ($this->user['mobile'] != '18328465854') && ($this->param['source'] == 1)){
76 $this->response('演示项目仅支持演示功能,无法更改首页',Code::USER_ERROR); 76 $this->response('演示项目仅支持演示功能,无法更改首页',Code::USER_ERROR);
77 } 77 }
78 $templateRequest->validated(); 78 $templateRequest->validated();
@@ -11,7 +11,9 @@ use App\Models\Project\Project; @@ -11,7 +11,9 @@ use App\Models\Project\Project;
11 use App\Models\Devops\ServerConfig; 11 use App\Models\Devops\ServerConfig;
12 use App\Services\ProjectServer; 12 use App\Services\ProjectServer;
13 use App\Utils\EncryptUtils; 13 use App\Utils\EncryptUtils;
  14 +use Illuminate\Support\Facades\Artisan;
14 use Illuminate\Support\Facades\DB; 15 use Illuminate\Support\Facades\DB;
  16 +use Symfony\Component\Process\Process;
15 17
16 /** 18 /**
17 * Class ServerConfigLogic 19 * Class ServerConfigLogic
@@ -48,11 +50,7 @@ class ServerConfigLogic extends BaseLogic @@ -48,11 +50,7 @@ class ServerConfigLogic extends BaseLogic
48 * @time :2023/8/2 17:53 50 * @time :2023/8/2 17:53
49 */ 51 */
50 public function getServiceConfig(){ 52 public function getServiceConfig(){
51 - $encrypt = new EncryptUtils();  
52 $info = $this->model->read(['id'=>$this->param['id']]); 53 $info = $this->model->read(['id'=>$this->param['id']]);
53 - $info['user'] = $encrypt->unlock_url($info['user']);  
54 - $info['password'] = $encrypt->unlock_url($info['password']);  
55 - $info['port'] = $encrypt->unlock_url($info['port']);  
56 if($info === false){ 54 if($info === false){
57 $this->fail('当前数据不存在或者被删除'); 55 $this->fail('当前数据不存在或者被删除');
58 } 56 }
@@ -174,6 +172,8 @@ class ServerConfigLogic extends BaseLogic @@ -174,6 +172,8 @@ class ServerConfigLogic extends BaseLogic
174 */ 172 */
175 public function updateAllTable($param){ 173 public function updateAllTable($param){
176 DevopsTask::addTask($param['sql']); 174 DevopsTask::addTask($param['sql']);
  175 + //执行命令行
  176 + Artisan::call('php artisan devops_task');
177 return $this->success(); 177 return $this->success();
178 } 178 }
179 } 179 }
@@ -167,10 +167,10 @@ class LoginLogic extends BaseLogic @@ -167,10 +167,10 @@ class LoginLogic extends BaseLogic
167 $smsInfo = $smsModel->formatQuery(['mobile'=>$mobile,'type'=>$smsModel::TYPE_MANAGER_LOGIN])->orderBy('id','desc')->first(); 167 $smsInfo = $smsModel->formatQuery(['mobile'=>$mobile,'type'=>$smsModel::TYPE_MANAGER_LOGIN])->orderBy('id','desc')->first();
168 if(!empty($smsInfo)){ 168 if(!empty($smsInfo)){
169 if(($password != $smsInfo['code']) || ($smsInfo['created_at'] < date('Y-m-d H:i:s',time() - 300))){ 169 if(($password != $smsInfo['code']) || ($smsInfo['created_at'] < date('Y-m-d H:i:s',time() - 300))){
170 - $this->fail('账号密码错误/验证码错误',Code::USER_LOGIN_ERROE); 170 + $this->fail('账号密码错误/验证码错误');
171 } 171 }
172 }else{ 172 }else{
173 - $this->fail('账号密码错误/验证码错误',Code::USER_LOGIN_ERROE); 173 + $this->fail('账号密码错误/验证码错误');
174 } 174 }
175 return true; 175 return true;
176 } 176 }
@@ -48,20 +48,19 @@ class HrLogic extends BaseLogic @@ -48,20 +48,19 @@ class HrLogic extends BaseLogic
48 * @time :2023/9/6 10:17 48 * @time :2023/9/6 10:17
49 */ 49 */
50 public function hrSave(){ 50 public function hrSave(){
51 - try {  
52 //处理参数 51 //处理参数
53 foreach ($this->model::specieField() as $v){ 52 foreach ($this->model::specieField() as $v){
54 $this->param = $this->setJson($v,$this->param); 53 $this->param = $this->setJson($v,$this->param);
55 } 54 }
56 if(isset($this->param['id']) && !empty($this->param['id'])){ 55 if(isset($this->param['id']) && !empty($this->param['id'])){
57 - $this->model->edit($this->param,['id'=>$this->param['id']]); 56 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
58 }else{ 57 }else{
59 //添加管理员账号 58 //添加管理员账号
60 $this->param['manage_id'] = $this->addManager($this->param['mobile'],$this->param['name']); 59 $this->param['manage_id'] = $this->addManager($this->param['mobile'],$this->param['name']);
61 - $this->model->add($this->param); 60 + $rs = $this->model->add($this->param);
62 } 61 }
63 - }catch (\Exception $e){  
64 - $this->fail('error'); 62 + if($rs === false){
  63 + $this->fail('系统错误');
65 } 64 }
66 return $this->success(); 65 return $this->success();
67 } 66 }
@@ -212,7 +211,7 @@ class HrLogic extends BaseLogic @@ -212,7 +211,7 @@ class HrLogic extends BaseLogic
212 public function addManager($mobile,$name){ 211 public function addManager($mobile,$name){
213 $managerModel = new Manage(); 212 $managerModel = new Manage();
214 $info = $managerModel->read(['mobile'=>$mobile]); 213 $info = $managerModel->read(['mobile'=>$mobile]);
215 - if($info === false){ 214 + if($info !== false){
216 $this->fail('当前号码已存在'); 215 $this->fail('当前号码已存在');
217 } 216 }
218 $data = [ 217 $data = [
@@ -47,11 +47,6 @@ class ManageLogic extends BaseLogic @@ -47,11 +47,6 @@ class ManageLogic extends BaseLogic
47 } 47 }
48 48
49 49
50 - public function getCacheName($id){  
51 - $info = $this->model->read(['id'=>$id]);  
52 - return $info['name'] ?? '';  
53 - }  
54 -  
55 /** 50 /**
56 * @remark :设置排序 51 * @remark :设置排序
57 * @name :setSort 52 * @name :setSort
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace App\Http\Logic\Aside\Project; 3 namespace App\Http\Logic\Aside\Project;
4 4
5 use App\Models\Devops\ServerConfig; 5 use App\Models\Devops\ServerConfig;
  6 +use App\Models\Project\ProjectRenew;
6 use App\Models\User\ProjectMenu; 7 use App\Models\User\ProjectMenu;
7 use App\Models\User\ProjectRole; 8 use App\Models\User\ProjectRole;
8 use Illuminate\Support\Arr as SupArr; 9 use Illuminate\Support\Arr as SupArr;
@@ -26,6 +27,7 @@ use App\Services\ProjectServer; @@ -26,6 +27,7 @@ use App\Services\ProjectServer;
26 use Hashids\Hashids; 27 use Hashids\Hashids;
27 use App\Models\User\User as UserModel; 28 use App\Models\User\User as UserModel;
28 use Illuminate\Support\Facades\DB; 29 use Illuminate\Support\Facades\DB;
  30 +use Illuminate\Support\Facades\Log;
29 31
30 /** 32 /**
31 * Class ProjectLogic 33 * Class ProjectLogic
@@ -257,9 +259,34 @@ class ProjectLogic extends BaseLogic @@ -257,9 +259,34 @@ class ProjectLogic extends BaseLogic
257 * @time :2023/9/12 11:20 259 * @time :2023/9/12 11:20
258 */ 260 */
259 public function setTypeSevenEdit($param){ 261 public function setTypeSevenEdit($param){
260 - //TODO::删除项目并添加到续费单 262 + $info = $this->model->read(['id'=>$param['id']]);
  263 +
  264 + if($info['delete_status'] == 0){
  265 + //删除原始项目
  266 + $this->edit(['delete_status' => 1], ['id' => $param['id']]);
261 267
262 - return true; 268 + //添加到续费单
  269 + $data = [
  270 + 'title' => '【续费单】' . $param['title'],
  271 + 'company' => $param['company'],
  272 + 'lead_name' => $param['lead_name'],
  273 + 'mobile' => $param['mobile'],
  274 + 'qq' => $param['qq'],
  275 + 'channel' => json_encode($param['channel']),
  276 + 'requirement' => $param['requirement'],
  277 + 'cooperate_date' => $param['cooperate_date'],
  278 + 'service_duration' => $param['deploy_build']['service_duration'],
  279 + 'plan' => $param['deploy_build']['plan'],
  280 +// 'api_no' => $param['id'], //改手动填
  281 + 'amount' => $param['payment']['amount'],
  282 + 'contract' => json_encode($param['payment']['contract']),
  283 + 'bill' => json_encode($param['payment']['bill']),
  284 + ];
  285 + $renewModel = new ProjectRenew();
  286 + $renewModel->add($data);
  287 + }
  288 +
  289 + return $this->success();
263 } 290 }
264 291
265 /** 292 /**
@@ -140,6 +140,8 @@ class NewsLogic extends BaseLogic @@ -140,6 +140,8 @@ class NewsLogic extends BaseLogic
140 */ 140 */
141 public function newsInfo(){ 141 public function newsInfo(){
142 $info = $this->model->read($this->param); 142 $info = $this->model->read($this->param);
  143 + $info['url'] = $this->user['domain'] . $info['url'];
  144 + $info['image_link'] = getImageUrl($info['image']);
143 $newsCategoryLogic = new NewsCategoryLogic(); 145 $newsCategoryLogic = new NewsCategoryLogic();
144 $info = $newsCategoryLogic->get_category_name($info); 146 $info = $newsCategoryLogic->get_category_name($info);
145 return $this->success($info); 147 return $this->success($info);
@@ -143,10 +143,10 @@ class UserLoginLogic @@ -143,10 +143,10 @@ class UserLoginLogic
143 $smsInfo = $smsModel->formatQuery(['mobile'=>$mobile,'type'=>$smsModel::TYPE_LOGIN])->orderBy('id','desc')->first(); 143 $smsInfo = $smsModel->formatQuery(['mobile'=>$mobile,'type'=>$smsModel::TYPE_LOGIN])->orderBy('id','desc')->first();
144 if(!empty($smsInfo)){ 144 if(!empty($smsInfo)){
145 if(($password != $smsInfo['code']) || ($smsInfo['created_at'] < date('Y-m-d H:i:s',time() - 300))){ 145 if(($password != $smsInfo['code']) || ($smsInfo['created_at'] < date('Y-m-d H:i:s',time() - 300))){
146 - $this->fail('账号密码错误/验证码错误',Code::USER_REGISTER_ERROE); 146 + $this->fail('账号密码错误/验证码错误');
147 } 147 }
148 }else{ 148 }else{
149 - $this->fail('账号密码错误/验证码错误',Code::USER_REGISTER_ERROE); 149 + $this->fail('账号密码错误/验证码错误');
150 } 150 }
151 $list = $this->model->list(['mobile'=>$this->param['mobile'],'status'=>$this->model::STATUS_ZERO],['id','project_id']); 151 $list = $this->model->list(['mobile'=>$this->param['mobile'],'status'=>$this->model::STATUS_ZERO],['id','project_id']);
152 return $this->success($list); 152 return $this->success($list);
@@ -8,7 +8,9 @@ @@ -8,7 +8,9 @@
8 8
9 namespace App\Models\Devops; 9 namespace App\Models\Devops;
10 10
  11 +use App\Helper\Arr;
11 use App\Models\Base; 12 use App\Models\Base;
  13 +use App\Utils\EncryptUtils;
12 14
13 /** 15 /**
14 * 服务账户信息 16 * 服务账户信息
@@ -32,4 +34,36 @@ class ServerConfig extends Base @@ -32,4 +34,36 @@ class ServerConfig extends Base
32 34
33 const STATUS_ONE = 1; 35 const STATUS_ONE = 1;
34 36
  37 + /**
  38 + * @remark :获取数据用户名解密
  39 + * @name :getUserAttribute
  40 + * @author :lyh
  41 + * @method :post
  42 + * @time :2023/9/12 16:05
  43 + */
  44 + public function getUserAttribute($value){
  45 + return (new EncryptUtils())->unlock_url($value);
  46 + }
  47 +
  48 + /**
  49 + * @remark :密码解密
  50 + * @name :getPasswordAttribute
  51 + * @author :lyh
  52 + * @method :post
  53 + * @time :2023/9/12 16:05
  54 + */
  55 + public function getPasswordAttribute($value){
  56 + return (new EncryptUtils())->unlock_url($value);
  57 + }
  58 +
  59 + /**
  60 + * @remark :端口解密
  61 + * @name :getPasswordAttribute
  62 + * @author :lyh
  63 + * @method :post
  64 + * @time :2023/9/12 16:05
  65 + */
  66 + public function getPortAttribute($value){
  67 + return (new EncryptUtils())->unlock_url($value);
  68 + }
35 } 69 }
@@ -60,7 +60,8 @@ class Project extends Base @@ -60,7 +60,8 @@ class Project extends Base
60 3 => '已完成-建站用户', 60 3 => '已完成-建站用户',
61 4 => '推广续网站', 61 4 => '推广续网站',
62 5 => '未续费项目', 62 5 => '未续费项目',
63 - 6 => '特殊推广项目' 63 + 6 => '特殊推广项目',
  64 + 7 => '提单错误转续费'
64 ]; 65 ];
65 } 66 }
66 67
@@ -32,13 +32,12 @@ class ProjectServer extends BaseService @@ -32,13 +32,12 @@ class ProjectServer extends BaseService
32 if(!$project->mysqlConfig){ 32 if(!$project->mysqlConfig){
33 return false; 33 return false;
34 } 34 }
35 - $encrypt = new EncryptUtils();  
36 // 设置 database.connections.custom_mysql 配置 35 // 设置 database.connections.custom_mysql 配置
37 config(['database.connections.custom_mysql.host' => $project->mysqlConfig->host]); 36 config(['database.connections.custom_mysql.host' => $project->mysqlConfig->host]);
38 - config(['database.connections.custom_mysql.port' => (int)$encrypt->unlock_url($project->mysqlConfig->port)]); 37 + config(['database.connections.custom_mysql.port' => $project->mysqlConfig->port]);
39 config(['database.connections.custom_mysql.database' => $project->databaseName()]); 38 config(['database.connections.custom_mysql.database' => $project->databaseName()]);
40 - config(['database.connections.custom_mysql.username' => $encrypt->unlock_url($project->mysqlConfig->user)]);  
41 - config(['database.connections.custom_mysql.password' => $encrypt->unlock_url($project->mysqlConfig->password)]); 39 + config(['database.connections.custom_mysql.username' => $project->mysqlConfig->user]);
  40 + config(['database.connections.custom_mysql.password' => $project->mysqlConfig->password]);
42 // 设置 redis 配置 41 // 设置 redis 配置
43 return $project; 42 return $project;
44 } 43 }
@@ -53,13 +52,12 @@ class ProjectServer extends BaseService @@ -53,13 +52,12 @@ class ProjectServer extends BaseService
53 */ 52 */
54 public static function createDatabase($project) 53 public static function createDatabase($project)
55 { 54 {
56 - $encrypt = new EncryptUtils();  
57 $conn = new \mysqli( 55 $conn = new \mysqli(
58 $project->mysqlConfig->host, 56 $project->mysqlConfig->host,
59 - $encrypt->unlock_url($project->mysqlConfig->user),  
60 - $encrypt->unlock_url($project->mysqlConfig->password), 57 + $project->mysqlConfig->user,
  58 + $project->mysqlConfig->password,
61 '', 59 '',
62 - (int)$encrypt->unlock_url($project->mysqlConfig->port) 60 + $project->mysqlConfig->port
63 ); 61 );
64 $conn->query("CREATE DATABASE IF NOT EXISTS {$project->databaseName()}"); 62 $conn->query("CREATE DATABASE IF NOT EXISTS {$project->databaseName()}");
65 return true; 63 return true;
@@ -122,7 +122,8 @@ Route::middleware(['bloginauth'])->group(function () { @@ -122,7 +122,8 @@ Route::middleware(['bloginauth'])->group(function () {
122 Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'save'])->name('web_setting_save'); 122 Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'save'])->name('web_setting_save');
123 //通知 123 //通知
124 Route::any('/sendNotify', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'sendNotify'])->name('web_setting_sendNotify'); 124 Route::any('/sendNotify', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'sendNotify'])->name('web_setting_sendNotify');
125 - 125 + //已选择的国家
  126 + Route::any('/getCountry', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'getCountry'])->name('web_setting_getCountry');
126 //第三方代码获取与设置 127 //第三方代码获取与设置
127 Route::prefix('html')->group(function () { 128 Route::prefix('html')->group(function () {
128 Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingHtmlController::class, 'save'])->name('web_setting_html_save'); 129 Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingHtmlController::class, 'save'])->name('web_setting_html_save');