作者 刘锟

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

... ... @@ -169,7 +169,6 @@ class RelayInquiry extends Command
while (true) {
$inquiry = $this->getInquiry();
if ($inquiry->isEmpty()){
$this->logChannel()->info('未发现待处理询盘!');
$this->output('未发现待处理询盘!');
sleep(60);
continue;
... ... @@ -272,10 +271,25 @@ class RelayInquiry extends Command
public function relayDetail($task, $form)
{
$this->output('获取转发对象');
//是否有必选的
$require_data = [];
foreach ($task['target'] as $item){
if(!empty($item['is_require'])){
$require_data[] = $item;
}
}
//代理商组 一个组只发一个
$agent_group = collect($task['target'])->whereNotIn('agent_group', array_column($require_data, 'agent_group'))->groupBy('agent_group');
// 获取转发对象 重置num数量, array_rand数量不足会报错
$task['num'] = $task['num'] > count($task['target']) ? count($task['target']) : $task['num'];
$relay_target_key = array_rand($task['target'], $task['num']);
if (empty($relay_target_key)) {
$task['num'] = $task['num'] - count($require_data);
$num = $task['num'] > count($agent_group) ? count($agent_group) : $task['num'];
$random_data = $agent_group->keys()->random($num)->map(function ($group) use ($agent_group) {
return $agent_group[$group]->random();
})->all();
$random_data = array_merge($require_data, $random_data);
if (empty($random_data)) {
$this->logChannel()->info('当前任务未发现转发对象!', ['广告任务ID:' . $task['id'], '询盘ID:' . $form->id]);
$form->status = ReInquiryForm::STATUS_FORGO;
$form->remark = '当前任务未发现转发对象,广告ID: ' . $form->ad_id . '!';
... ... @@ -283,10 +297,10 @@ class RelayInquiry extends Command
return false;
}
foreach ($relay_target_key as $key) {
foreach ($random_data as $item) {
// 推送站点
$domain = $task['target'][$key]['url'];
$is_v6 = $task['target'][$key]['is_v6'];
$domain = $item['url'];
$is_v6 = $item['is_v6'];
$re_website = 'https://' . $domain . '/';
$this->output('转发对象:' . $domain);
... ... @@ -320,19 +334,30 @@ class RelayInquiry extends Command
$page_url = [$re_website . 'contact-us/'];
}
}
// 所有可用url
$urls = $inquiry_urls = [];
$urls[] = $inquiry_urls[] = $re_website;
//入口url 首页30%,单页10%,聚合页60%
$type = getRandByRatio([30,10,60]);
$inlet = $re_website;
$type == 1 && $inlet = $page_url ? Arr::random($page_url) : $re_website;
$type == 2 && $inlet = $keywords_url ? Arr::random($keywords_url) : $re_website;
$urls[] = $inquiry_urls[] = $inlet;
$all_urls = array_merge($urls, $product_url, $product_cate_url, $keywords_url, $page_url);
$inquiry_urls = array_merge($urls, $product_cate_url, $keywords_url, $page_url);
// 随机访问1-3个页面
// 随机访问1-6个页面
$deep = rand(1,6);
if($deep > 2) {
$visit_urls = Arr::random($all_urls, rand(1, count($all_urls) > 3 ? 3 : count($all_urls)));
$urls = array_merge($urls, $visit_urls);
}
if($deep > 1) {
// 推送着落页只能是 首页、产品分类、单页面、聚合页
if(!in_array(end($urls), $inquiry_urls)){
if (!in_array(end($urls), $inquiry_urls)) {
$urls[] = Arr::random($inquiry_urls);
}
}
$this->output('获取转发ip');
// TODO 获取IP:如果是简码,查询数据库获取对应的国家, 如果是国家使用翻译, 再转化成IP
... ... @@ -352,8 +377,10 @@ class RelayInquiry extends Command
$country_name = $ip_data->ip_area;
$this->output('转发内容');
// 通过字符数量区分, 改成完全获取内置询盘内容
$message = $form->message;
$message_id = 0;
//开启文案替换 配置替换或者字符少于4个,直接替换文案
if($task['is_replace_text'] || strlen($message) <= 4) {
$use_ids = ReInquiryDetail::where(['re_website' => $domain])->where('status', '<>', ReInquiryDetail::STATUS_FAIL)->pluck('text_id')->toArray();
$text = ReInquiryText::whereNotIn('id', $use_ids)->where('status', ReInquiryText::STATUS_USABLE)->inRandomOrder()->first();
$message = $text->content;
... ... @@ -363,16 +390,17 @@ class RelayInquiry extends Command
$text->save();
//原内容非英语,转为对应语种
if(is_numeric($form->message)){ //数字会被识别为中文
if (is_numeric($form->message)) { //数字会被识别为中文
$lang = 'en';
}else{
} else {
$translateSl = Translate::translateSl($form->message);
$lang = $translateSl['texts']['sl'] ?? 'en';
}
if($lang != 'en' || $lang != 'zh-CN'){
if ($lang != 'en' && Str::contains($lang, 'zh')) {
$message = Translate::tran($message, $lang);
}
}
$this->output('获取转发设备信息');
// 客户端 头信息 来源
... ... @@ -430,7 +458,7 @@ class RelayInquiry extends Command
{
$cache_key = 'inquiry_ads_task';
$ads = Cache::get($cache_key, function () use ($cache_key) {
$ads = ReInquiryTask::where(['status' => ReInquiryTask::STATUS_OPEN])->get(['id', 'ad_id', 'num', 'target']);
$ads = ReInquiryTask::where(['status' => ReInquiryTask::STATUS_OPEN])->get(['id', 'ad_id', 'num', 'target', 'is_replace_text']);
$array = [];
foreach ($ads as $key=>$val) {
$array[$val->ad_id] = $val;
... ...
<?php
namespace App\Console\Commands\Inquiry;
use App\Models\Inquiry\ReInquiryCount;
use App\Models\Inquiry\ReInquiryDetail;
use App\Models\Inquiry\ReInquiryDetailLog;
use App\Models\Inquiry\ReInquiryForm;
... ... @@ -66,6 +67,7 @@ class postInquiry extends Command
$form = ReInquiryForm::find($detail['form_id']);
$form->success_num = $form->success_num + 1;
$form->save();
Log::channel('inquiry_relay')->info('询盘成功:',[$detail['form_id'], $val->id, getmypid()]);
}
}
}catch (\Exception $e){
... ... @@ -175,6 +177,10 @@ class postInquiry extends Command
];
$res = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data)->json();
//兼容接口返回格式
if(!empty($res['data'][0]['status'])){
$res['data'][0]['code'] = $res['data'][0]['status'] == 'success' ? 200 : 400;
}
if(empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200,300])){
$log->status = ReInquiryDetailLog::STATUS_FAIL;
$log->remark = $res['message'] ?? '';
... ... @@ -186,6 +192,10 @@ class postInquiry extends Command
}
$log->status = ReInquiryDetailLog::STATUS_SUCCESS;
$log->save();
//统计
ReInquiryCount::addInquiryNum($detail['id'], $detail['re_website']);
return true;
}
... ...
... ... @@ -56,21 +56,56 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[1148]]]);
$list = $projectModel->list(['id'=>['in',[1750]]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
// $this->getProduct();
$this->setProductKeyword();
// $this->setProductKeyword();
// $this->getBlog();
// $this->setCustomRoute($v['id']);
// $this->editProductAlt();
$this->custom_to_blogs();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :同步擴展模塊數據到blogs
* @name :custom_to_blogs
* @author :lyh
* @method :post
* @time :2024/10/28 15:45
*/
public function custom_to_blogs(){
$customContentModel = new CustomModuleContent();
$lists = $customContentModel->list(['module_id'=>9]);
foreach ($lists as $k => $v){
$data = [
'name'=>$v['name'],
'category_id'=>',1,',
'remark'=>$v['remark'],
'text'=>$v['content'],
'url'=>$v['route'],
'image'=>$v['image'],
'seo_title'=>$v['seo_title'],
'seo_description'=>$v['seo_description'],
'seo_keywords'=>$v['seo_keywords'],
'project_id'=>1750,
'operator_id'=>$v['operator_id'],
'create_id'=>$v['operator_id'],
'created_at'=>$v['created_at'],
'updated_at'=>$v['updated_at'],
'release_at'=>$v['release_at']
];
$blogModel = new Blog();
$id = $blogModel->insertGetId($data);
RouteMap::setRoute($v['route'], RouteMap::SOURCE_BLOG, $id, 1750);
}
}
public function editProductAlt(){
$productModel = new Product();
$lists = $productModel->list(['status'=>1],'id',['id','route','thumb','gallery']);
... ... @@ -242,18 +277,20 @@ 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{
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']);
// $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']]);
// }
$route = RouteMap::setRoute($v['route'], 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;
... ...
... ... @@ -266,5 +266,25 @@ class QuanqiusouApi
return $res;
}
/**
* 获取代理信息
* @param $domain
* @return array|mixed
* @author zbj
* @date 2024/10/26
*/
public function getV5Agent($domain){
$token = md5($domain.'qqs');
try {
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'https://quanqiusou.cn/extend_api/api/get_agent_by_domain.php?'.http_build_query(['token' => $token, 'domain' => $domain]), [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
return Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
errorLog('获取代理失败', [$domain], $e);
return [];
}
}
}
... ...
... ... @@ -989,6 +989,41 @@ if (!function_exists('check_domain_record')) {
}
}
/**
* 邮箱脱敏
* @author zbj
* @date 2024/10/25
*/
function email_desensitize($email){
$parts = explode('@', $email);
$username = $parts[0];
$domain = $parts[1];
$maskedUsername = substr($username, 0, -4) . '****';
$maskedDomain = '****.' . substr($domain, -5);
return $maskedUsername . '@' . $maskedDomain;
}
/**
* 按比例取值 [10,30,60]
* @author zbj
* @date 2024/10/25
*/
function getRandByRatio($proArr){
$result = '';
$proSum = array_sum($proArr);
foreach ($proArr as $key => $proCur) {
$randNum = mt_rand(1, $proSum);
if ($randNum <= $proCur) {
$result = $key;
break;
} else {
$proSum -= $proCur;
}
}
unset ($proArr);
return $result;
}
... ...
... ... @@ -95,6 +95,7 @@ class ProjectController extends BaseController
'gl_project_deploy_build.dept_id AS dept_id',
'gl_project_deploy_build.keyword_num AS key',
'gl_project_deploy_build.service_duration AS day',
'gl_project_deploy_build.is_comment AS is_comment',
'gl_project_deploy_build.leader_mid AS leader_mid',
'gl_project_deploy_build.manager_mid AS manager_mid',
'gl_project_deploy_build.designer_mid AS designer_mid',
... ...
... ... @@ -9,9 +9,11 @@ namespace App\Http\Controllers\Aside\Task;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Helper\QuanqiusouApi;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Channel\Channel;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\ReInquiryCount;
use App\Models\Inquiry\ReInquiryDetail;
use App\Models\Inquiry\ReInquiryForm;
use App\Models\Inquiry\ReInquiryTask;
... ... @@ -57,11 +59,14 @@ class AdsController extends BaseController
->paginate($page_size);
$relay_site_total = 0;
foreach ($result as $item){
foreach ($result as &$item){
$relay_site_total += count($item->target);
$item->requiry_num = ReInquiryDetail::where('task_id', $item->id)->where('status', ReInquiryDetail::STATUS_SUCCESS)->count();
$item->form_num = ReInquiryForm::where('ad_id', $item->ad_id)->count();
}
$result = $result->toArray();
$result['relay_site_total'] = $relay_site_total;
$result['default_ai_param'] = ReInquiryTask::DEFAULT_AI_PARAM;
return $this->response('success', Code::SUCCESS, $result);
}
... ... @@ -81,10 +86,27 @@ class AdsController extends BaseController
$ad_img = trim($request->input('ad_img'));
$num = intval($request->input('num'));
$status = intval($request->input('status'));
$is_replace_text = intval($request->input('is_replace_text'));
$ai_param = $request->input('ai_param');
if (empty($title) || empty($ad_id))
return $this->response('请填写完整信息!', Code::USER_ERROR, []);
ReInquiryTask::createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status);
//AI生成
if($is_replace_text == 2){
if(empty($ai_param['mkeywords'])){
return $this->response('工厂关键词不能为空!', Code::USER_ERROR, []);
}
if(empty($ai_param['characters'])){
return $this->response('随机字符数不能为空!', Code::USER_ERROR, []);
}
if(empty($ai_param['inkeywords'])){
return $this->response('询盘内容关键词不能为空!', Code::USER_ERROR, []);
}
if(empty($ai_param['suoxie'])){
return $this->response('英文缩写参考不能为空!', Code::USER_ERROR, []);
}
}
ReInquiryTask::createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status, $is_replace_text, $ai_param);
return $this->response('success', Code::SUCCESS, []);
}
... ... @@ -104,6 +126,7 @@ class AdsController extends BaseController
if(empty($target)){
return $this->response('请添加关联网站!', Code::USER_ERROR, []);
}
$is_require_num = 0;
foreach ($target as &$item){
if(empty($item['url'])){
return $this->response('网站域名不能为空!', Code::USER_ERROR, []);
... ... @@ -111,7 +134,20 @@ class AdsController extends BaseController
if(empty($item['agent'])){
return $this->response('代理不能为空!', Code::USER_ERROR, []);
}
if(empty($item['agent_group'])){
return $this->response('代理商分组不能为空!', Code::USER_ERROR, []);
}
$item['url'] = trim(str_replace(['http://', 'https://'], '', $item['url']), '/');
if(!empty($item['is_require'])){
$is_require_num++;
}
}
if($is_require_num > $task->num){
return $this->response('必选渠道不能大于转发数量!', Code::USER_ERROR, []);
}
foreach ($target as $v){
ReInquiryCount::addInquiryNum($id, $v['url'], 0);
}
$task->target = json_encode($target);
$task->save();
... ... @@ -129,28 +165,28 @@ class AdsController extends BaseController
//是否v6
$domain_info = DomainInfo::where('domain', $domain)->first();
if($domain_info){
$channel = Project::where('id', $domain_info['project_id'])->value('channel');
$channel = Project::where('id', $domain_info['project_id'])->where('delete_status', 0)->value('channel');
if($channel){
$data = [
'is_v6' => 1,
'agent' => Channel::getChannelText($channel['user_id']??0),
'agent' => trim(explode('-', Channel::getChannelText($channel['user_id']??0))[0]),
'domain' => $domain,
];
return $this->response('success', Code::SUCCESS, $data);
}
$token = md5($domain.'qqs');
try {
$res = HttpUtils::get('https://quanqiusou.cn/extend_api/api/get_agent_by_domain.php', ['token' => $token, 'domain' => $domain]);
$res = Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
return $this->response('验证失败,请稍后再试!', Code::USER_ERROR, []);
}
$res = (new QuanqiusouApi())->getV5Agent($domain);
if(empty($res['status']) || $res['status'] != 200){
return $this->response($res['msg'], Code::USER_ERROR, []);
return $this->response($res['msg'] ?? '验证失败,请稍后再试!', Code::USER_ERROR, []);
}
$agent = implode(',', array_map(function ($v){
return trim(explode('-', $v)[0]);
}, explode(',', $res['data'] ?? '')));
$data = [
'is_v6' => 0,
'agent' => $res['data'],
'agent' => $agent,
'domain' => $domain,
];
return $this->response('success', Code::SUCCESS, $data);
... ... @@ -214,4 +250,34 @@ class AdsController extends BaseController
->paginate();
return $this->response('success', Code::SUCCESS, $result);
}
public function fbRelayCount(Request $request){
$task_id = intval($request->input('task_id'));
$domain = trim($request->input('domain'));
$company = trim($request->input('company'));
$operator = trim($request->input('operator'));
$num = intval($request->input('num'));
$row = intval($request->input('row', 20));
$result = ReInquiryCount::when($task_id, function ($query, $task_id) {
return $query->WhereRaw("FIND_IN_SET({$task_id}, `task_ids`)");
})
->when($domain, function ($query, $domain) {
return $query->where('domain', 'like', '%'.$domain.'%');
})
->when($company, function ($query, $company) {
return $query->where('company', 'like', '%'.$company.'%');
})
->when($num, function ($query) use($num, $operator) {
return $query->where('num', $operator?:'=', $num);
})
->orderBy('num', 'desc')
->paginate($row);
foreach ($result as $item){
$item->tasks = $item->tasks; //调用访问器
}
return $this->response('success', Code::SUCCESS, $result);
}
}
... ...
... ... @@ -15,6 +15,7 @@ use App\Models\RouteMap\RouteMap;
use App\Models\User\ProjectMenu as ProjectMenuModel;
use App\Models\User\ProjectRole as ProjectRoleModel;
use App\Models\User\User;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Cache;
/***
... ... @@ -114,7 +115,7 @@ class ComController extends BaseController
$info['role_menu'] = trim(str_replace(',52,',',',','.$info['role_menu'].','),',');
}
$is_comment = $this->getIsComment();
if(!$is_comment){
if($is_comment != 1){
$info['role_menu'] = trim(str_replace(',55,',',',','.$info['role_menu'].','),',');
}
$this->map = [
... ... @@ -161,7 +162,7 @@ class ComController extends BaseController
$data[] = 52;
}
$is_comment = $this->getIsComment();
if(!$is_comment){
if($is_comment != 1){
$data[] = 55;
}
if(!empty($data)){
... ... @@ -246,7 +247,7 @@ class ComController extends BaseController
* @time :2024/9/14 13:32
*/
public function getIsComment(){
return $this->user['is_subscribe'] ?? 0;
return $this->user['is_comment'] ?? 0;
}
/**
... ... @@ -398,4 +399,15 @@ class ComController extends BaseController
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :
* @name :month_count
* @author :lyh
* @method :post
* @time :2024/10/28 11:51
*/
public function month_count(){
Artisan::call('month_project '.$this->user['project_id']);
$this->response('重新刷新中,请稍后刷新查询');
}
}
... ...
... ... @@ -167,6 +167,13 @@ class InquiryController extends BaseController
$data = $data['list'] ?? [];
foreach ($data as &$item){
//非正常登录的
if($this->param['login_source'] != 2){
//脱敏
$item['email'] = email_desensitize($item['email']);
$item['phone'] = substr($item['phone'], 0, -4) . '****';
}
$item['ip_address'] = "{$item['country']}({$item['ip']})";
if(!empty($this->param['form_id'])){
... ...
... ... @@ -23,7 +23,7 @@ class MailController extends BaseController
$lists = $mailModel->where('status',0)->where($this->map)
->where('user_list','like','%,'.$this->uid.',%')
->orWhere('user_list', '')
->select(['*'])->orderBy($this->order,'desc')
->orderBy($this->order,'desc')
->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
$lists = $lists->toArray();
... ...
... ... @@ -206,8 +206,12 @@ class ProductController extends BaseController
$query = $query->where('created_uid',$this->map['created_uid']);
}
if(!empty($this->param['start_at']) && !empty($this->param['end_at'])){
if($this->user['project_id'] == 2059){
$query->where('send_time', '>=' ,$this->param['start_at'].' 00:00:00')->where('send_time', '<=' ,$this->param['end_at'].' 59:59:59');
}else{
$query->where('created_at', '>=' ,$this->param['start_at'].' 00:00:00')->where('created_at', '<=' ,$this->param['end_at'].' 59:59:59');
}
}
$this->param['featured_status'] = $this->param['featured_status'] ?? 0;
if($this->param['featured_status'] != Category::STATUS_ACTIVE) {
$cateModel = new Category();
... ...
... ... @@ -46,7 +46,7 @@ class MenuSpecialLogic extends BaseLogic
* @time :2024/10/24 11:50
*/
public function searchParam(&$query,$map){
$query = $query->where('gl_manage_hr.status', $map['status'] ?? 1);
$query = $query->where('gl_manage_hr.status', null)->orWhere('gl_manage_hr.status', $map['status'] ?? 1);
return $query;
}
... ...
... ... @@ -179,7 +179,7 @@ class CountLogic extends BaseLogic
$result =array();
if(!empty($data)){
foreach ($data as $k => $v){
if(($this->project['is_record_china_visit'] != 1) && ($v['country'] == '中国')){
if(isset($v['country']) && isset($this->project['is_record_china_visit']) && ($this->project['is_record_china_visit'] != 1) && ($v['country'] == '中国')){
continue;
}else{
$v['pv'] = (int)$v['pv'];
... ...
... ... @@ -128,10 +128,31 @@ class KeywordLogic extends BaseLogic
if(!isset($param['is_video_keyword']) || $param['is_video_keyword'] == null){
$param['is_video_keyword'] = 0;
}
$param['first_word'] = $this->first_word($param['title']);
return $param;
}
/**
* @remark :获取字符串首字符
* @name :first_word
* @author :lyh
* @method :post
* @time :2024/10/28 10:47
*/
public function first_word($title){
$first_title = mb_substr($title, 0, 1);
//返回对应的键
$keywordModel = new Keyword();
$firstNumWord = $keywordModel->firstNumWord;
foreach($firstNumWord as $k => $v){
if(strtolower($v) == strtolower($first_title)){
return $k;
}
}
return 27;
}
/**
* @remark :批量添加关键词任务, 异步处理
* @name :batchAdd
* @author :lyh
... ... @@ -151,6 +172,7 @@ class KeywordLogic extends BaseLogic
$param['created_at'] = date('Y-m-d H:i:s');
$param['updated_at'] = $param['created_at'];
$param['title'] = $v;
$param['first_word'] = $this->first_word($param['title']);
$this->model->insertGetId($param);
}
}
... ... @@ -224,7 +246,7 @@ class KeywordLogic extends BaseLogic
if($v){
$keyword_info = $this->model->read(['title'=>$v]);
if(!$keyword_info){
$k_id = $this->model->addReturnId(['title'=>$v,'project_id'=>$project_id]);
$k_id = $this->model->addReturnId(['title'=>$v,'first_word' => $this->first_word($v),'project_id'=>$project_id]);
$route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $k_id, $project_id);
$this->model->edit(['route'=>$route],['id'=>$k_id]);
}else{
... ...
... ... @@ -56,7 +56,9 @@ class ProductLogic extends BaseLogic
$id = $this->param['id'];
}else{
$this->param = $this->addHandleParam($this->param);
$this->param['sort'] = $this->setNewsSort();
if($this->user['project_id'] != 2059){//2059项目不处理排序
$this->param['sort'] = $this->setProductSort();
}
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$id]);
... ... @@ -81,7 +83,7 @@ class ProductLogic extends BaseLogic
* @method :post
* @time :2023/12/25 9:27
*/
public function setNewsSort(){
public function setProductSort(){
$info = $this->model->orderBy('sort','desc')->first();
if(empty($info)){
return 1;
... ... @@ -948,8 +950,18 @@ class ProductLogic extends BaseLogic
* @time :2024/9/20 16:48
*/
public function batchSetKeyword(){
if(isset($this->param['is_cover']) && $this->param['is_cover'] == 1){//覆盖
$this->param['keyword_id'] = ','.implode(',',$this->param['keyword_id']).',';
$this->edit(['keyword_id'=>$this->param['keyword_id']],['id'=>['in',$this->param['id']]]);
}else{
foreach ($this->param['id'] as $id){
//获取当前产品的分类
$productInfo = $this->model->read(['id'=>$id],['id','keyword_id']);
$keyword_ids_arr = array_values(array_unique(array_merge($productInfo['keyword_id'],$this->param['keyword_id'])));
$keyword_ids = ','.implode(',',$keyword_ids_arr).',';
$this->model->edit(['keyword_id'=>$keyword_ids],['id'=>$id]);
}
}
return $this->success();
}
}
... ...
... ... @@ -38,7 +38,7 @@ class Base extends Model
{
$query = $this->formatQuery($map);
$query = $this->sortOrder($query,$order,$sort);
$lists = $query->select($fields)->paginate($row, ['*'], 'page', $page);
$lists = $query->select($fields)->paginate($row, $fields, 'page', $page);
if (empty($lists)) {
return [];
}
... ...
<?php
namespace App\Models\Inquiry;
use App\Helper\Arr;
use App\Helper\QuanqiusouApi;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Models\Task\TaskOwner;
use Illuminate\Database\Eloquent\Model;
/**
* Class ReInquiryCount
* @package App\Models\Inquiry
* @author zbj
* @date 2024/10/25
*/
class ReInquiryCount extends Model
{
/**
* @var string
*/
protected $table = 'gl_re_inquiry_count';
/**
* @param $task_id
* @param $domain
* @param int $num
* @author zbj
* @date 2024/10/26
*/
public static function addInquiryNum($task_id, $domain, $num = 1)
{
$model = self::where('domain', $domain)->first();
if (!$model) {
//新增时获取公司名
$company = '';
$domain_info = DomainInfo::where('domain', $domain)->first();
if ($domain_info) {
$company = Project::where('id', $domain_info['project_id'])->value('company');
} else {
$res = (new QuanqiusouApi())->getV5Agent($domain);
if (!empty($res['status']) && $res['status'] == 200) {
$company = $res['company_name'];
}
}
$model = new self();
$model->domain = $domain;
$model->company = $company;
}
$model->task_ids = $model->task_ids + [$task_id];
$model->num = $model->num + $num;
$model->save();
}
public function setTaskIdsAttribute($value)
{
$this->attributes['task_ids'] = Arr::arrToSet($value);
}
public function getTaskIdsAttribute($value)
{
return Arr::setToArr($value);
}
public function getTasksAttribute(){
$tasks = ReInquiryTask::whereIn('id', $this->task_ids)->select(['title', 'industry','target'])->get()->toArray();
foreach ($tasks as &$task){
$target = collect($task['target'])->where('url', $this->domain)->first();
$task['agent'] = $target['agent'] ?? '';
$task['is_v6'] = $target['is_v6'] ?? '';
$task['agent_group'] = $target['agent_group'] ?? '';
unset($task['target']);
}
return $tasks;
}
}
... ...
... ... @@ -7,6 +7,7 @@
*/
namespace App\Models\Inquiry;
use App\Helper\Arr;
use App\Models\Base;
use Illuminate\Database\Eloquent\Model;
... ... @@ -28,6 +29,36 @@ class ReInquiryTask extends Base
const STATUS_OPEN = 1;
const STATUS_CLOSE = 0;
const DEFAULT_AI_PARAM = [
'mkeywords' => '',
'characters' => '30
40
50
60
70
80
90
100
120
150',
'inkeywords' => 'OEM/ODM价格
FOB价格多少
最小起订量
批发价格多少
批发价格及价格梯度
本地是否招商
支持的支付方式
产品画册及类别
公司详细资质
能否WhatsApp直接联系
是否需求本地合作伙伴',
'suoxie' => 'Thanks 写成 Tks
Please 写成 Pls
As Soon As Possible 写成 ASAP
For Your Information 写成 FYI
How Much 写成 HM',
];
/**
* 创建询盘任务
* @param $id
... ... @@ -40,7 +71,7 @@ class ReInquiryTask extends Base
* @param int $status
* @return ReInquiryTask
*/
public static function createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status = self::STATUS_OPEN)
public static function createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status, $is_replace_text, $ai_param)
{
$self = self::where(['id' => $id])->first();
if (empty($self))
... ... @@ -52,6 +83,8 @@ class ReInquiryTask extends Base
$self->ad_img = $ad_img;
$self->num = $num;
$self->status = $status;
$self->is_replace_text = $is_replace_text;
$self->ai_param = $ai_param;
$self->save();
return $self;
}
... ... @@ -62,6 +95,23 @@ class ReInquiryTask extends Base
*/
public function getTargetAttribute($value)
{
return $value ? json_decode($value, true) : [];
$value = $value ? json_decode($value, true) : [];
foreach ($value as &$item){
$item['url'] = $item['url'] ?? '';
$item['agent'] = $item['agent'] ?? '';
$item['agent_group'] = $item['agent_group'] ?? '';
$item['is_require'] = $item['is_require'] ?? 0;
}
return $value;
}
public function setAiParamAttribute($value)
{
$this->attributes['ai_param'] = Arr::a2s($value);
}
public function getAiParamAttribute($value)
{
return Arr::s2a($value) ?: self::DEFAULT_AI_PARAM;
}
}
... ...
... ... @@ -17,6 +17,38 @@ class Keyword extends Base
protected $connection = 'custom_mysql';
const STATUS_ACTIVE = 1;
//获取字母对应数字
public $firstNumWord = [
0=>"0",
1=>"a",
2=>"b",
3=>"c",
4=>"d",
5=>"e",
6=>"f",
7=>"g",
8=>"h",
9=>"i",
10=>"j",
11=>"k",
12=>"l",
13=>"m",
14=>"n",
15=>"o",
16=>"p",
17=>"q",
18=>"r",
19=>"s",
20=>"t",
21=>"u",
22=>"v",
23=>"w",
24=>"x",
25=>"y",
26=>"z",
27=>"all",
];
/**
* @remark :视频
* @name :getKeywordVideoAttribute
... ...
... ... @@ -490,6 +490,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/fb_check_domain', [Aside\Task\AdsController::class, 'checkDomain'])->name('admin.fb_check_domain');
Route::any('/fb_inquiry_list', [Aside\Task\AdsController::class, 'fbInquiryList'])->name('admin.fb_ads_inquiry_list');
Route::any('/fb_relay_detail_list', [Aside\Task\AdsController::class, 'fbRelayDetail'])->name('admin.fb_ads_relay_detail_list');
Route::any('/fb_relay_count', [Aside\Task\AdsController::class, 'fbRelayCount'])->name('admin.fb_relay_count');
});
});
... ...