作者 张关杰

Merge branch 'akun' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

@@ -220,17 +220,24 @@ class VideoTask extends Command @@ -220,17 +220,24 @@ class VideoTask extends Command
220 if (count($productIds)<7){ 220 if (count($productIds)<7){
221 $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray(); 221 $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
222 $number = 40; 222 $number = 40;
223 - $product_id = array_rand($product_all_id, min($product_all_id, $number-count($productIds)));  
224 - $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();  
225 - $products = $productsQuery->merge($randomData); 223 + $array_count = count($product_all_id);
  224 + if ($array_count > 0) {
  225 + $product_id = array_rand($product_all_id, min($array_count, $number - count($productIds)));
  226 + $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
  227 + $products = $productsQuery->merge($randomData);
  228 + }
226 }else{ 229 }else{
227 $products = $productsQuery; 230 $products = $productsQuery;
228 } 231 }
229 }else{ 232 }else{
230 $product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray(); 233 $product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
231 $number = 40; 234 $number = 40;
232 - $product_id = array_rand($product_all_id, min($product_all_id, $number-count($productIds)));  
233 - $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); 235 + $array_count = count($product_all_id);
  236 + if ($array_count > 0)
  237 + {
  238 + $product_id = array_rand($product_all_id, min($array_count, $number-count($productIds)));
  239 + $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
  240 + }
234 } 241 }
235 } 242 }
236 $data = []; 243 $data = [];
@@ -242,10 +249,11 @@ class VideoTask extends Command @@ -242,10 +249,11 @@ class VideoTask extends Command
242 if(count($data) > 13){ 249 if(count($data) > 13){
243 break; 250 break;
244 } 251 }
245 - if (strpos($item->keyword_id, ','.$productKeyword->id.',') === false) { 252 + $keyword_id = implode(',',$item->keyword_id);
  253 + if (strpos(','.$keyword_id.',', ','.$productKeyword->id.',') === false) {
246 //不包含 254 //不包含
247 $productModel = new Product(); 255 $productModel = new Product();
248 - $keyword_id = $item->keyword_id . $productKeyword->id.','; 256 + $keyword_id = $keyword_id . $productKeyword->id.',';
249 $productModel->edit(['keyword_id'=>$keyword_id],['id'=>$item->id]); 257 $productModel->edit(['keyword_id'=>$keyword_id],['id'=>$item->id]);
250 } 258 }
251 $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title]; 259 $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
@@ -16,6 +16,7 @@ use App\Models\RouteMap\RouteMap; @@ -16,6 +16,7 @@ use App\Models\RouteMap\RouteMap;
16 use App\Models\User\User; 16 use App\Models\User\User;
17 use App\Services\ProjectServer; 17 use App\Services\ProjectServer;
18 use Illuminate\Http\Request; 18 use Illuminate\Http\Request;
  19 +use Illuminate\Support\Facades\DB;
19 20
20 /** 21 /**
21 * Class PrivateController 22 * Class PrivateController
@@ -127,4 +128,18 @@ class PrivateController extends BaseController @@ -127,4 +128,18 @@ class PrivateController extends BaseController
127 128
128 return $this->success($result); 129 return $this->success($result);
129 } 130 }
  131 +
  132 + /**
  133 + * v6 有效用户
  134 + * @param Request $request
  135 + * @return false|string
  136 + */
  137 + public function validUser(Request $request)
  138 + {
  139 + // 排除演示项目数据
  140 + $valid_user = User::select(['gl_project_user.mobile'])->leftJoin('gl_project', 'gl_project.id', '=', 'gl_project_user.project_id')->where(['delete_status' => 0, 'is_upgrade' => Project::IS_UPGRADE_FALSE])->where('gl_project.id', '>', 1)->pluck('mobile')->toArray();
  141 + $upgrade_user = User::select(['gl_project_user.mobile'])->leftJoin('gl_project', 'gl_project.id', '=', 'gl_project_user.project_id')->where(['delete_status' => 0, 'is_upgrade' => Project::IS_UPGRADE_TRUE])->where('gl_project.type', '>', Project::TYPE_ONE)->pluck('mobile')->toArray();
  142 + $user = array_unique(array_merge($valid_user, $upgrade_user));
  143 + return $this->success($user);
  144 + }
130 } 145 }
@@ -18,6 +18,7 @@ use App\Models\Project\Project; @@ -18,6 +18,7 @@ use App\Models\Project\Project;
18 use App\Models\RouteMap\RouteMap; 18 use App\Models\RouteMap\RouteMap;
19 use App\Models\WebSetting\WebLanguage; 19 use App\Models\WebSetting\WebLanguage;
20 use Illuminate\Http\Request; 20 use Illuminate\Http\Request;
  21 +use Illuminate\Support\Facades\DB;
21 22
22 23
23 /** 24 /**
@@ -169,7 +170,9 @@ class CNoticeController extends BaseController @@ -169,7 +170,9 @@ class CNoticeController extends BaseController
169 $ids = explode(',',$info['country_lists']); 170 $ids = explode(',',$info['country_lists']);
170 } 171 }
171 $languageModel = new WebLanguage(); 172 $languageModel = new WebLanguage();
172 - $lists = $languageModel->list(['id'=>['in',$ids]]); 173 + //根据排序查询选中的小语种
  174 + $lists = $languageModel->whereIn('id', $ids)->orderByRaw(DB::raw("FIND_IN_SET(id,'" . implode(',', $ids) . "'" . ')'))->get()->toArray();
  175 +// $lists = $languageModel->list(['id'=>['in',$ids]]);
173 $this->response('success',Code::SUCCESS,$lists); 176 $this->response('success',Code::SUCCESS,$lists);
174 } 177 }
175 178
@@ -235,9 +235,15 @@ class LoginController extends BaseController @@ -235,9 +235,15 @@ class LoginController extends BaseController
235 * @time :2023/8/24 17:37 235 * @time :2023/8/24 17:37
236 */ 236 */
237 public function globalSo_v6_login(UserLoginLogic $logic){ 237 public function globalSo_v6_login(UserLoginLogic $logic){
238 - $common = new Common();  
239 - $arr = $common->decrypt(urldecode($this->param['token']));  
240 - if(empty($arr)){ 238 + $this->param = $this->request->validate([
  239 + 'token' => 'required',
  240 + ],[
  241 + 'token.required' => 'token不能为空',
  242 + ]);
  243 + try {
  244 + $common = new Common();
  245 + $arr = $common->decrypt(urldecode($this->param['token']));
  246 + }catch (\Exception $e){
241 $this->response('非法请求!',Code::USER_ERROR); 247 $this->response('非法请求!',Code::USER_ERROR);
242 } 248 }
243 if (empty($arr['timestamp']) || time() - $arr['timestamp'] > 60) { 249 if (empty($arr['timestamp']) || time() - $arr['timestamp'] > 60) {
@@ -42,7 +42,7 @@ class HttpUtils @@ -42,7 +42,7 @@ class HttpUtils
42 public static function get($url, $data, $headers = []) 42 public static function get($url, $data, $headers = [])
43 { 43 {
44 LogUtils::info("HttpUtils-GET请求URL:" . $url); 44 LogUtils::info("HttpUtils-GET请求URL:" . $url);
45 - $response = Http::withHeaders($headers)->get($url, $data); 45 + $response = Http::timeout(20)->withHeaders($headers)->get($url, $data);
46 self::checkSuccess($response); 46 self::checkSuccess($response);
47 return $response->getBody()->getContents(); 47 return $response->getBody()->getContents();
48 } 48 }
@@ -50,7 +50,7 @@ class HttpUtils @@ -50,7 +50,7 @@ class HttpUtils
50 public static function post($url, $data, $headers = []) 50 public static function post($url, $data, $headers = [])
51 { 51 {
52 LogUtils::info("HttpUtils-POST请求URL:" . $url); 52 LogUtils::info("HttpUtils-POST请求URL:" . $url);
53 - $response = Http::withHeaders($headers)->post($url, $data); 53 + $response = Http::timeout(20)->withHeaders($headers)->post($url, $data);
54 self::checkSuccess($response); 54 self::checkSuccess($response);
55 return $response->getBody()->getContents(); 55 return $response->getBody()->getContents();
56 } 56 }
@@ -28,3 +28,5 @@ Route::any('getOptimizationReport', [\App\Http\Controllers\Api\OptimizationRepor @@ -28,3 +28,5 @@ Route::any('getOptimizationReport', [\App\Http\Controllers\Api\OptimizationRepor
28 Route::post('video_task_callback', [\App\Http\Controllers\Api\NoticeController::class, 'videoTaskCallback'])->name('api.video_task_callback'); 28 Route::post('video_task_callback', [\App\Http\Controllers\Api\NoticeController::class, 'videoTaskCallback'])->name('api.video_task_callback');
29 // 验证是否为6.0用户 29 // 验证是否为6.0用户
30 Route::any('has_user', [\App\Http\Controllers\Api\PrivateController::class, 'hasUser'])->name('api.has_user'); 30 Route::any('has_user', [\App\Http\Controllers\Api\PrivateController::class, 'hasUser'])->name('api.has_user');
  31 +// 6.0有效用户用户
  32 +Route::any('valid_user', [\App\Http\Controllers\Api\PrivateController::class, 'validUser'])->name('api.valid_user');