作者 刘锟

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

... ... @@ -94,14 +94,12 @@ DSE1504F,Rectifier/Super fast Recovery Rectifier,ITO-220AC,400,15,Single Positiv
if(!empty($array1[1])){
$cate_ids = '';
$cate_arr = explode('/',$array1[1]);
echo date('Y-m-d H:i:s') . 'json_fenle:' . json_encode($cate_arr) . PHP_EOL;
foreach ($cate_arr as $cateV){
$catInfo = $customModuleCategoryModel->read(['name'=>$cateV]);
if($catInfo !== false){
$cate_ids = $cate_ids.','.$catInfo['id'];
}
}
echo date('Y-m-d H:i:s') . '处理后的fenle:' . $cate_ids . PHP_EOL;
$contentData['category_id'] = empty($cate_ids) ? '' : $cate_ids.',';
}else{
$catInfo = $customModuleCategoryModel->read(['name'=>$array1[1]]);
... ...
... ... @@ -294,17 +294,22 @@ class RelayInquiry extends Command
$this->output('没有独立站转发对象');
return 0;
}
//是否有必选的
$require_data = [];
foreach ($task['target'] as $item){
if(!empty($item['is_require'])){
$require_data[] = $item;
//是否有必选的渠道 渠道有一个及以上必选 就在组内随机一个
$require_agent_group = [];
foreach ($task['target'] as $item) {
if (!empty($item['is_require'])) {
$require_agent_group[] = $item['agent_group'];
}
}
$require_agent_group = array_unique($require_agent_group);
$require_agent_group_data = collect($task['target'])->whereIn('agent_group', $require_agent_group)->groupBy('agent_group');
$require_data = $require_agent_group_data->keys()->random(count($require_agent_group))->map(function ($group) use ($require_agent_group_data) {
return $require_agent_group_data[$group]->random();
})->all();
//代理商组 一个组只发一个
$agent_group = collect($task['target'])->whereNotIn('agent_group', array_column($require_data, 'agent_group'))->groupBy('agent_group');
$agent_group = collect($task['target'])->whereNotIn('agent_group', $require_agent_group)->groupBy('agent_group');
// 获取转发对象 重置num数量, array_rand数量不足会报错
$task['num'] = $task['num'] - count($require_data);
$task['num'] = $task['num'] - count($require_agent_group);
$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();
... ...
... ... @@ -22,6 +22,7 @@ use App\Models\Project\Project;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
... ... @@ -68,8 +69,28 @@ class AdsController extends BaseController
$item['requiry_num'] = ReInquiryDetail::where('task_id', $item['id'])->where('status', ReInquiryDetail::STATUS_SUCCESS)->count();
$item['form_num'] = ReInquiryForm::whereIn('ad_id', explode(',', $item['ad_id']))->count();
//关联网站是否有重复的
if($item['fob_pro']){
$fb_projects = ReInquiryCount::getFobProjects();
foreach ($item['fob_pro'] as $k => $fob_pro){
$repeat = ReInquiryTask::where('fob_pro', 'like', '%"'.$fob_pro.'"%')->where('id', '<>', $item['id'])->first();
$fob_info = collect($fb_projects)->where('postid', $fob_pro)->first();
$item['fob_pro_list'][$k] = [
'is_repeat' => $repeat ? 1 : 0,
'project' => $fob_info['company'] . '('.$fob_info['plan'].')'
];
}
}
if($item['shop_site']) {
foreach ($item['shop_site'] as $k => $site) {
$repeat = ReInquiryTask::where('target', 'like', '%"' . $site . '"%')->where('id', '<>', $item['id'])->first();
$item['shop_site_list'][$k] = [
'is_repeat' => $repeat ? 1 : 0,
'url' => $site,
];
}
}
foreach ($item['target'] as $k=>$target){
$repeat = ReInquiryTask::where('target', 'like', '%'.$target['url'].'%')->where('id', '<>', $item['id'])->first();
$repeat = ReInquiryTask::where('target', 'like', '%"'.$target['url'].'"%')->where('id', '<>', $item['id'])->first();
$item['target'][$k]['is_repeat'] = $repeat ? 1 : 0;
}
$item['cost'] = ReInquiryCost::getCostByAdIds($item['ad_id']);
... ... @@ -134,10 +155,12 @@ class AdsController extends BaseController
if(!$task){
return $this->response('广告不存在!', Code::USER_ERROR, []);
}
if(empty($target)){
return $this->response('请添加关联网站!', Code::USER_ERROR, []);
}
$is_require_num = 0;
foreach ($target as $k=>$v){
if(empty($item['url'])){
unset($target[$k]);
}
}
foreach ($target as &$item){
if(empty($item['url'])){
return $this->response('网站域名不能为空!', Code::USER_ERROR, []);
... ...
... ... @@ -176,17 +176,6 @@ class ReplaceHtmlLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在');
}
if($info['source'] == 0){//当前数据是替换的所有页面
$data = $this->sourceTypeInfo($info['project_id']);
$typeInfo = $data[$this->param['name']];
if($typeInfo['source'] != 0){//回滚页面
$info['source'] = $typeInfo['source'];
$info['is_custom'] = $typeInfo['is_custom'];
$info['is_list'] = $typeInfo['is_list'];
$replaceId = $this->saveResultReplaceHtml($info);
return $this->success(['id'=>$replaceId]);
}
}
$replaceId = $this->saveResultReplaceHtml($info);
return $this->success(['id'=>$replaceId]);
}
... ...