作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -264,15 +264,23 @@ class VideoTask extends Command
}
if (count($productIds) < 13){
$product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20 - count($productIds))->pluck('id')->toArray();
if(empty($product_all_id)){
$randomData = [];
}else{
$randomData = Product::whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get();
}
$products = $productsQuery->merge($randomData);
}else{
$products = $productsQuery;
}
}else{
$product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray();
if(empty($product_all_id)){
$products = [];
}else{
$products = Product::whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get();
}
}
$data = [];
if (!empty($products)){
foreach ($products as $item){
... ...
... ... @@ -72,7 +72,7 @@ class RankData extends BaseCommands
}
}
return !$error;
} catch (\Exception $e) {
} catch (\Exception|\Throwable $e) {
Log::channel('rank_data')->error('排名数据任务失败 ' . $e->getMessage());
throw new \Exception($e->getMessage());
}
... ...
... ... @@ -56,7 +56,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[1871]]]);
$list = $projectModel->list(['id'=>['in',[2350]]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
... ... @@ -222,18 +222,18 @@ class UpdateRoute extends Command
if(!empty($lists)){
foreach ($lists as $v){
if(!empty($v['route'])){
$tag = "-product";
if (!(substr($v['route'], -strlen($tag)) === $tag)) {
echo date('Y-m-d H:i:s') . '拼接'.$tag . PHP_EOL;
$route = $v['route'].$tag;
// 如果不是以 '-product' 结尾,则拼接上 '-product'
$route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']);
$productModel->edit(['route'=>$route],['id'=>$v['id']]);
}else{
// $tag = "-product";
// if (!(substr($v['route'], -strlen($tag)) === $tag)) {
// echo date('Y-m-d H:i:s') . '拼接'.$tag . PHP_EOL;
// $route = $v['route'].$tag;
// // 如果不是以 '-product' 结尾,则拼接上 '-product'
// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']);
// $productModel->edit(['route'=>$route],['id'=>$v['id']]);
// }else{
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']);
$productModel->edit(['route'=>$route],['id'=>$v['id']]);
}
// }
continue;
}else{
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
... ...
... ... @@ -135,6 +135,9 @@ class Common
if(isset($cache) && ($cache['is_cache'] == true)){
if(is_array($id)){
foreach ($id as $v){
if(is_array($v)){
continue;
}
$key = 'cache_'.$table.'_'.$v.'_type';
Cache::store('file')->pull($key);
}
... ...
... ... @@ -281,6 +281,13 @@ class ProjectController extends BaseController
if(isset($this->map['site_status'])){
$query = $query->where('gl_project.site_status',$this->map['site_status']);
}
if(isset($this->map['domain'])){
if($this->map['domain'] == 0){
$query = $query->where('gl_project_deploy_optimize.domain',null);
}else{
$query = $query->where('gl_project_deploy_optimize.domain',null);
}
}
return $query;
}
... ...
... ... @@ -12,6 +12,8 @@ namespace App\Http\Controllers\Bside\BCom;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Log\OperationHeartbeat;
use App\Models\Manage\Manage;
use App\Models\User\User;
class OperationHeartbeatController extends BaseController
{
... ... @@ -36,6 +38,7 @@ class OperationHeartbeatController extends BaseController
'is_custom.required' => '是否为扩展模版',
'is_template.required' => '详情页/可视化',
]);
$condition = ['project_id'=>$this->user['project_id'],'source'=>$this->param['source'],'source_id'=>$this->param['source_id'],
'is_list'=>$this->param['is_list'],'is_custom'=>$this->param['is_custom'],'is_template'=>$this->param['is_template']];
$operationHeartbeatModel = new OperationHeartbeat();
... ... @@ -44,9 +47,11 @@ class OperationHeartbeatController extends BaseController
if($info === false){
$condition['operator_id'] = $this->user['id'];
$condition['project_id'] = $this->user['project_id'];
$condition['ip'] = $this->request->ip();
$condition['manager_id'] = $this->user['manager_id'] ?? 0;
$operationHeartbeatModel->addReturnId($condition);
}else{
$operationHeartbeatModel->edit(['status'=>$condition['status'] ?? 0],['id'=>$info['id']]);
$operationHeartbeatModel->edit(['status'=>$condition['status'] ?? 0,'ip'=>$this->request->ip(),'manager_id'=> $this->user['manager_id'] ?? 0],['id'=>$info['id']]);
}
$this->response('success');
}
... ... @@ -75,15 +80,33 @@ class OperationHeartbeatController extends BaseController
$condition = ['project_id'=>$this->user['project_id'],'source'=>$this->param['source'],'source_id'=>$this->param['source_id'],
'is_list'=>$this->param['is_list'],'is_custom'=>$this->param['is_custom'],'is_template'=>$this->param['is_template']];
$operationHeartbeatModel = new OperationHeartbeat();
$info = $operationHeartbeatModel->read($condition,['id','status','updated_at']);
$info = $operationHeartbeatModel->read($condition,['id','status','manager_id','ip','operator_id','updated_at']);
if($info === false){
$info = [];
}else{
$date_time = strtotime($info['updated_at']) + 7200;
if($date_time < time()){
$operationHeartbeatModel->edit(['status'=>0],$condition);
$operationHeartbeatModel->edit(['status'=>0,'ip'=>'127.0.0.1'],$condition);
$info['status'] = 0;
}
if($info['status'] == 1){
//当前登录为切入登录
if(isset($this->user['manager_id']) && !empty($this->user['manager_id'])){
//上一次验证也是切入登录
if($info['manager_id'] != 0){
$managerModel = new Manage();
$managerInfo = $managerModel->read(['id'=>$info['manager_id']],['name']);
$info['message'] = '此页面数据已有人在编辑,请勿重复操作!操作人ip:'.$info['ip'].'操作的管理员为:'.$managerInfo['name'];
}else{
//账号密码登录
$userModel = new User();
$userInfo = $userModel->read(['id'=>$info['operator_id']],['name']);
$info['message'] = '此页面数据已有人在编辑,请勿重复操作!'.$userInfo['name'].'用户登录在操作。';
}
}else{
$info['message'] = '此页面数据已有人在编辑,请勿重复操作!';
}
}
}
$this->response('success',Code::SUCCESS,$info);
}
... ...
... ... @@ -47,14 +47,24 @@ class InquiryController extends BaseController
$data = $logic->getApiList();
}
if(!empty($data) && !empty($data['list'])){
foreach ($data['list'] as $k => &$v){
if(isset($v['phone']) && !empty($v['phone'])){
$phoneInfo = (new PhoneData())->read(['phone'=>$v['phone']]);
if($phoneInfo === false){
$v['phone_data'] = [];
}else{
$v['phone_data'] = json_decode($phoneInfo['data']);
$phone = [];
foreach ($data['list'] as $v){
if(!empty($v['phone'])){
$phone[] = $v['phone'];
}
}
if(!empty($phone)){
$phoneDataModel = new PhoneData();
$phoneDataList = $phoneDataModel->list(['phone'=>['in',$phone]]);
foreach ($data['list'] as $key => $value){
$value['phone_data'] = [];
foreach ($phoneDataList as $valuePhone){
if($value['phone'] == $valuePhone['phone']){
$value['phone_data'] = $valuePhone;
break;
}
}
$data['list'][$key] = $value;
}
}
}
... ...
... ... @@ -297,8 +297,7 @@ class LoginController extends BaseController
];
}
}
$info = $logic->autologin($data);
$info = $logic->autologin($data,User::LOGIN_OTHER_SOURCE);
$this->response('success',Code::SUCCESS,['info'=>$info]);
}
... ...
... ... @@ -788,7 +788,7 @@ class ProductController extends BaseController
'keyword_id'=>'required|array',
],[
'id.required' => '产品ID不能为空',
'category_id.required' => '关键词ID不能为空',
'keyword_id.required' => '关键词ID不能为空',
]);
$logic->batchSetKeyword();
$this->response('success');
... ...
... ... @@ -185,19 +185,29 @@ class InquiryLogic extends BaseLogic
*/
public function sendMobileVerifyData($phone){
$phoneDataModel = new PhoneData();
$info = $phoneDataModel->read(['phone'=>$phone]);
if($info === false){
$num_phone = preg_replace('/\D/', '',$phone) ?? ''; // \D 匹配所有非数字字符
$data = $phoneDataModel->read(['num_phone'=>$num_phone]);
if($data === false){
$url = 'https://fob.ai.cc/api/mobile_verify_data/'.$phone;
$data = http_get($url);
if(!empty($data)){
$param = [
'phone'=>$phone,
'data'=>json_encode($data,true)
'num_phone'=>$num_phone,
'wa_status'=>$data['wa_status'] ?? 0,
'wa_phone'=>$data['wa_phone'] ?? '',
'wa_name'=>$data['wa_name'] ?? '',
'wa_profile_pic'=>$data['wa_profile_pic'] ?? '',
'phone_status'=>$data['phone_status'] ?? 0,
'phone_type'=>$data['phone_type'] ?? '',
'country_code'=>$data['country_code'] ?? '',
'phone_region'=>$data['phone_region'] ?? '',
];
(new PhoneData())->addReturnId($param);
}else{
$data = json_decode($info['data']);
return $this->success($param);
}
}
return $this->success(['data'=>$data]);
return $this->success($data);
}
}
... ...
... ... @@ -107,7 +107,7 @@ class UserLoginLogic
* @method :post
* @time :2023/9/18 11:00
*/
public function autologin($data)
public function autologin($data,$login_source = User::LOGIN_AUTO_SOURCE)
{
//项目自动登录
if(isset($data['project_id']) && !empty($data['project_id'])){
... ... @@ -120,7 +120,7 @@ class UserLoginLogic
if ($has_user === false) {
$this->fail('该项目未找到注册账号');
}
$info = $this->autoAssembleParam($has_user);
$info = $this->autoAssembleParam($has_user,$login_source);
//生成新token
$token = md5(uniqid().$info['id']);
//存储缓存
... ... @@ -160,7 +160,7 @@ class UserLoginLogic
* @method :post
* @time :2023/6/12 15:34
*/
public function autoAssembleParam($info){
public function autoAssembleParam($info,$login_source = User::LOGIN_AUTO_SOURCE){
$project = $this->getProjectInfo($info['project_id']);
if($project['site_status'] != 0){//关闭站点
$this->fail('当前网站已过期,请联系管理员及时续费。');
... ... @@ -206,7 +206,7 @@ class UserLoginLogic
$is_amp = $amp_info ? $amp_info['amp_status'] : 0;
}
$info['is_amp'] = $is_amp;
$info['login_source'] = $login_source;
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,12 * 3600);
return $this->success($info);
... ... @@ -316,6 +316,7 @@ class UserLoginLogic
$is_amp = $amp_info ? $amp_info['amp_status'] : 0;
}
$info['is_amp'] = $is_amp;
$info['login_source'] = User::LOGIN_PASSWORD_SOURCE;
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,12 * 3600);
return $this->success($info);
... ... @@ -363,7 +364,7 @@ class UserLoginLogic
];
}else {
//获取项目详情
$info = $this->autoAssembleParam($info);
$info = $this->autoAssembleParam($info,User::LOGIN_PASSWORD_SOURCE);
if(isset($info['token']) && !empty($info['token'])){
//清除上一次用户缓存
Cache::pull($info['token']);
... ...
... ... @@ -14,4 +14,18 @@ use App\Models\Base;
class PhoneData extends Base
{
protected $table = 'gl_phone_data';
const STATUS_VALID = 1;
const STATUS_INVALID = 2;
const STATUS_ERROR = 9;
public static function statusMapping()
{
return [
self::STATUS_VALID => '有效WA',
self::STATUS_INVALID => '无效WA',
self::STATUS_ERROR => '查询失败',
];
}
}
... ...
... ... @@ -17,6 +17,9 @@ class User extends Base
//自动维护create_at创建时间 updated_at修改时间
public $timestamps = true;
const LOGIN_AUTO_SOURCE = 1;//自动登录
const LOGIN_PASSWORD_SOURCE = 2;//账号密码登录
const LOGIN_OTHER_SOURCE = 3;//其他平台切入
/**
* The attributes that should be cast.
*
... ...
... ... @@ -111,7 +111,7 @@ class SyncSubmitTaskService
* @date 2024/8/27
*/
public function subscribe($data, $date){
$email = $data['data']['data']['email'];
$email = $data['data']['email'];
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$model = new Email();
$model->email = $email;
... ... @@ -273,7 +273,7 @@ class SyncSubmitTaskService
$config = InquiryFilterConfig::getCacheInfoByProjectId($project_id);
//没配置 则默认开启且使用全局
if($config){
if(!$config){
$config['is_global_rule'] = 1;
$config['status'] = 1;
}
... ... @@ -284,11 +284,11 @@ class SyncSubmitTaskService
self::inquiryFilter(Project::DEMO_PROJECT_ID, $data);
}
//过滤国家
if($config['filter_countries'] && in_array($data['country'], $config['filter_countries'])){
if(!empty($config['filter_countries']) && in_array($data['country'], $config['filter_countries'])){
throw new InquiryFilterException( '过滤国家:' . $data['country']);
}
//过滤ip
if($config['black_ips']){
if(!empty($config['black_ips'])){
$black_ips = $config['black_ips'];
//后端获取的ip
if(in_array($data['ip'], $black_ips)){
... ... @@ -302,7 +302,7 @@ class SyncSubmitTaskService
//过滤内容
if(!empty($data['data']['message'])) {
//过滤内容关键字
if ($config['filter_contents']){
if (!empty($config['filter_contents'])){
foreach ($config['filter_contents'] as $filter_content) {
if (Str::contains(strtolower($data['data']['message']), strtolower($filter_content))) {
throw new InquiryFilterException('过滤内容:' . $filter_content);
... ... @@ -310,14 +310,14 @@ class SyncSubmitTaskService
}
}
//是否允许包含链接
if(!$config['is_allow_link']){
if(isset($config['is_allow_link']) && !$config['is_allow_link']){
if (Str::contains(strtolower($data['data']['message']), ['http://', 'https://', 'www.'])) {
throw new InquiryFilterException('不允许包含链接');
}
}
}
//过滤来源
if($config['filter_referers']){
if(!empty($config['filter_referers'])){
//只比较path路径
$paths = array_map(function ($v){
return trim(parse_url(Url::to($v), PHP_URL_PATH), '/');
... ... @@ -333,7 +333,7 @@ class SyncSubmitTaskService
}
}
//过滤邮箱
if($config['filter_emails'] && !empty($data['data']['email'])){
if(!empty($config['filter_emails']) && !empty($data['data']['email'])){
foreach ($config['filter_emails'] as $filter_email){
if(Str::contains(strtolower($data['data']['email']), strtolower($filter_email))){
throw new InquiryFilterException( '过滤邮箱:' . $filter_email);
... ... @@ -341,7 +341,7 @@ class SyncSubmitTaskService
}
}
//过滤电话
if($config['filter_mobiles'] && !empty($data['data']['phone'])){
if(!empty($config['filter_mobiles']) && !empty($data['data']['phone'])){
foreach ($config['filter_mobiles'] as $filter_mobile){
if(Str::contains(strtolower($data['data']['phone']), strtolower($filter_mobile))){
throw new InquiryFilterException( '过滤电话:' . $filter_mobile);
... ... @@ -349,7 +349,7 @@ class SyncSubmitTaskService
}
}
//过滤姓名
if($config['filter_names'] && !empty($data['data']['name'])){
if(!empty($config['filter_names']) && !empty($data['data']['name'])){
foreach ($config['filter_names'] as $filter_name){
if( Str::contains(strtolower($data['data']['name']), strtolower($filter_name))){
throw new InquiryFilterException( '过滤姓名:' . $filter_name);
... ...