作者 刘锟

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

@@ -94,14 +94,12 @@ DSE1504F,Rectifier/Super fast Recovery Rectifier,ITO-220AC,400,15,Single Positiv @@ -94,14 +94,12 @@ DSE1504F,Rectifier/Super fast Recovery Rectifier,ITO-220AC,400,15,Single Positiv
94 if(!empty($array1[1])){ 94 if(!empty($array1[1])){
95 $cate_ids = ''; 95 $cate_ids = '';
96 $cate_arr = explode('/',$array1[1]); 96 $cate_arr = explode('/',$array1[1]);
97 - echo date('Y-m-d H:i:s') . 'json_fenle:' . json_encode($cate_arr) . PHP_EOL;  
98 foreach ($cate_arr as $cateV){ 97 foreach ($cate_arr as $cateV){
99 $catInfo = $customModuleCategoryModel->read(['name'=>$cateV]); 98 $catInfo = $customModuleCategoryModel->read(['name'=>$cateV]);
100 if($catInfo !== false){ 99 if($catInfo !== false){
101 $cate_ids = $cate_ids.','.$catInfo['id']; 100 $cate_ids = $cate_ids.','.$catInfo['id'];
102 } 101 }
103 } 102 }
104 - echo date('Y-m-d H:i:s') . '处理后的fenle:' . $cate_ids . PHP_EOL;  
105 $contentData['category_id'] = empty($cate_ids) ? '' : $cate_ids.','; 103 $contentData['category_id'] = empty($cate_ids) ? '' : $cate_ids.',';
106 }else{ 104 }else{
107 $catInfo = $customModuleCategoryModel->read(['name'=>$array1[1]]); 105 $catInfo = $customModuleCategoryModel->read(['name'=>$array1[1]]);
@@ -294,17 +294,22 @@ class RelayInquiry extends Command @@ -294,17 +294,22 @@ class RelayInquiry extends Command
294 $this->output('没有独立站转发对象'); 294 $this->output('没有独立站转发对象');
295 return 0; 295 return 0;
296 } 296 }
297 - //是否有必选的  
298 - $require_data = [];  
299 - foreach ($task['target'] as $item){  
300 - if(!empty($item['is_require'])){  
301 - $require_data[] = $item; 297 + //是否有必选的渠道 渠道有一个及以上必选 就在组内随机一个
  298 + $require_agent_group = [];
  299 + foreach ($task['target'] as $item) {
  300 + if (!empty($item['is_require'])) {
  301 + $require_agent_group[] = $item['agent_group'];
302 } 302 }
303 } 303 }
  304 + $require_agent_group = array_unique($require_agent_group);
  305 + $require_agent_group_data = collect($task['target'])->whereIn('agent_group', $require_agent_group)->groupBy('agent_group');
  306 + $require_data = $require_agent_group_data->keys()->random(count($require_agent_group))->map(function ($group) use ($require_agent_group_data) {
  307 + return $require_agent_group_data[$group]->random();
  308 + })->all();
304 //代理商组 一个组只发一个 309 //代理商组 一个组只发一个
305 - $agent_group = collect($task['target'])->whereNotIn('agent_group', array_column($require_data, 'agent_group'))->groupBy('agent_group'); 310 + $agent_group = collect($task['target'])->whereNotIn('agent_group', $require_agent_group)->groupBy('agent_group');
306 // 获取转发对象 重置num数量, array_rand数量不足会报错 311 // 获取转发对象 重置num数量, array_rand数量不足会报错
307 - $task['num'] = $task['num'] - count($require_data); 312 + $task['num'] = $task['num'] - count($require_agent_group);
308 $num = $task['num'] > count($agent_group) ? count($agent_group) : $task['num']; 313 $num = $task['num'] > count($agent_group) ? count($agent_group) : $task['num'];
309 $random_data = $agent_group->keys()->random($num)->map(function ($group) use ($agent_group) { 314 $random_data = $agent_group->keys()->random($num)->map(function ($group) use ($agent_group) {
310 return $agent_group[$group]->random(); 315 return $agent_group[$group]->random();
@@ -22,6 +22,7 @@ use App\Models\Project\Project; @@ -22,6 +22,7 @@ use App\Models\Project\Project;
22 use App\Utils\HttpUtils; 22 use App\Utils\HttpUtils;
23 use GuzzleHttp\Exception\GuzzleException; 23 use GuzzleHttp\Exception\GuzzleException;
24 use Illuminate\Http\Request; 24 use Illuminate\Http\Request;
  25 +use Illuminate\Support\Collection;
25 use Illuminate\Support\Facades\DB; 26 use Illuminate\Support\Facades\DB;
26 use Illuminate\Support\Facades\Http; 27 use Illuminate\Support\Facades\Http;
27 28
@@ -68,8 +69,28 @@ class AdsController extends BaseController @@ -68,8 +69,28 @@ class AdsController extends BaseController
68 $item['requiry_num'] = ReInquiryDetail::where('task_id', $item['id'])->where('status', ReInquiryDetail::STATUS_SUCCESS)->count(); 69 $item['requiry_num'] = ReInquiryDetail::where('task_id', $item['id'])->where('status', ReInquiryDetail::STATUS_SUCCESS)->count();
69 $item['form_num'] = ReInquiryForm::whereIn('ad_id', explode(',', $item['ad_id']))->count(); 70 $item['form_num'] = ReInquiryForm::whereIn('ad_id', explode(',', $item['ad_id']))->count();
70 //关联网站是否有重复的 71 //关联网站是否有重复的
  72 + if($item['fob_pro']){
  73 + $fb_projects = ReInquiryCount::getFobProjects();
  74 + foreach ($item['fob_pro'] as $k => $fob_pro){
  75 + $repeat = ReInquiryTask::where('fob_pro', 'like', '%"'.$fob_pro.'"%')->where('id', '<>', $item['id'])->first();
  76 + $fob_info = collect($fb_projects)->where('postid', $fob_pro)->first();
  77 + $item['fob_pro_list'][$k] = [
  78 + 'is_repeat' => $repeat ? 1 : 0,
  79 + 'project' => $fob_info['company'] . '('.$fob_info['plan'].')'
  80 + ];
  81 + }
  82 + }
  83 + if($item['shop_site']) {
  84 + foreach ($item['shop_site'] as $k => $site) {
  85 + $repeat = ReInquiryTask::where('target', 'like', '%"' . $site . '"%')->where('id', '<>', $item['id'])->first();
  86 + $item['shop_site_list'][$k] = [
  87 + 'is_repeat' => $repeat ? 1 : 0,
  88 + 'url' => $site,
  89 + ];
  90 + }
  91 + }
71 foreach ($item['target'] as $k=>$target){ 92 foreach ($item['target'] as $k=>$target){
72 - $repeat = ReInquiryTask::where('target', 'like', '%'.$target['url'].'%')->where('id', '<>', $item['id'])->first(); 93 + $repeat = ReInquiryTask::where('target', 'like', '%"'.$target['url'].'"%')->where('id', '<>', $item['id'])->first();
73 $item['target'][$k]['is_repeat'] = $repeat ? 1 : 0; 94 $item['target'][$k]['is_repeat'] = $repeat ? 1 : 0;
74 } 95 }
75 $item['cost'] = ReInquiryCost::getCostByAdIds($item['ad_id']); 96 $item['cost'] = ReInquiryCost::getCostByAdIds($item['ad_id']);
@@ -134,10 +155,12 @@ class AdsController extends BaseController @@ -134,10 +155,12 @@ class AdsController extends BaseController
134 if(!$task){ 155 if(!$task){
135 return $this->response('广告不存在!', Code::USER_ERROR, []); 156 return $this->response('广告不存在!', Code::USER_ERROR, []);
136 } 157 }
137 - if(empty($target)){  
138 - return $this->response('请添加关联网站!', Code::USER_ERROR, []);  
139 - }  
140 $is_require_num = 0; 158 $is_require_num = 0;
  159 + foreach ($target as $k=>$v){
  160 + if(empty($item['url'])){
  161 + unset($target[$k]);
  162 + }
  163 + }
141 foreach ($target as &$item){ 164 foreach ($target as &$item){
142 if(empty($item['url'])){ 165 if(empty($item['url'])){
143 return $this->response('网站域名不能为空!', Code::USER_ERROR, []); 166 return $this->response('网站域名不能为空!', Code::USER_ERROR, []);
@@ -176,17 +176,6 @@ class ReplaceHtmlLogic extends BaseLogic @@ -176,17 +176,6 @@ class ReplaceHtmlLogic extends BaseLogic
176 if($info === false){ 176 if($info === false){
177 $this->fail('当前数据不存在'); 177 $this->fail('当前数据不存在');
178 } 178 }
179 - if($info['source'] == 0){//当前数据是替换的所有页面  
180 - $data = $this->sourceTypeInfo($info['project_id']);  
181 - $typeInfo = $data[$this->param['name']];  
182 - if($typeInfo['source'] != 0){//回滚页面  
183 - $info['source'] = $typeInfo['source'];  
184 - $info['is_custom'] = $typeInfo['is_custom'];  
185 - $info['is_list'] = $typeInfo['is_list'];  
186 - $replaceId = $this->saveResultReplaceHtml($info);  
187 - return $this->success(['id'=>$replaceId]);  
188 - }  
189 - }  
190 $replaceId = $this->saveResultReplaceHtml($info); 179 $replaceId = $this->saveResultReplaceHtml($info);
191 return $this->success(['id'=>$replaceId]); 180 return $this->success(['id'=>$replaceId]);
192 } 181 }