|
|
@@ -3210,671 +3210,671 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
}
|
|
|
$cate_num = min($cate_num, 24);
|
|
|
// return Result::success($data);
|
|
|
- $tempalte['index'] = $this->randomWeb($data,$rule);
|
|
|
- return Result::success($tempalte);
|
|
|
+ // $tempalte['index'] = $this->randomWeb($data,$rule);
|
|
|
+ // return Result::success($tempalte);
|
|
|
if(isset($data['page']) && !empty($data['page'])){
|
|
|
- $tempalte['index'] = $this->randomPage($data,$cate_num,$rule);
|
|
|
+ $tempalte['index'] = $this->randomWeb($data,$rule);
|
|
|
}else{
|
|
|
$data['page'] = 1;
|
|
|
$ruleIndex = json_decode($rule->index_rule);
|
|
|
- $tempalte['index'] = $this->randomPage($data, $cate_num, $ruleIndex);
|
|
|
+ $tempalte['index'] = $this->randomWeb($data, $ruleIndex);
|
|
|
$data['page'] = 2;
|
|
|
$ruleClass = json_decode($rule->class_rule);
|
|
|
// $class_cate_num = $query->where('pid','!=',0)->groupBy('pid')->selectRaw('pid, count(*) as count')->get()->pluck('count','pid');
|
|
|
// $cate_num = max($class_cate_num);
|
|
|
- $tempalte['class'] = $this->randomPage($data, $cate_num, $ruleClass);
|
|
|
+ $tempalte['class'] = $this->randomWeb($data, $ruleClass);
|
|
|
$data['page'] = 3;
|
|
|
$ruleList = json_decode($rule->list_rule);
|
|
|
- $tempalte['list'] = $this->randomPage($data,$cate_num,$ruleList);
|
|
|
+ $tempalte['list'] = $this->randomWeb($data,$ruleList);
|
|
|
$data['page'] = 4;
|
|
|
$ruleInfo = json_decode($rule->info_rule);
|
|
|
- $tempalte['info'] = $this->randomPage($data,$cate_num,$ruleInfo);
|
|
|
+ $tempalte['info'] = $this->randomWeb($data,$ruleInfo);
|
|
|
$data['page'] = 5;
|
|
|
$ruleSearch = json_decode($rule->search_rule);
|
|
|
- $tempalte['search'] = $this->randomPage($data,$cate_num,$ruleSearch);
|
|
|
+ $tempalte['search'] = $this->randomWeb($data,$ruleSearch);
|
|
|
$data['page'] = 6;
|
|
|
$ruleFooterlist = json_decode($rule->footerlist_rule);
|
|
|
- $tempalte['footerlist'] = $this->randomPage($data,$cate_num,$ruleFooterlist);
|
|
|
+ $tempalte['footerlist'] = $this->randomWeb($data,$ruleFooterlist);
|
|
|
$data['page'] = 7;
|
|
|
$ruleFooterinfo = json_decode($rule->footerinfo_rule);
|
|
|
- $tempalte['footerinfo'] = $this->randomPage($data,$cate_num,$ruleFooterinfo);
|
|
|
+ $tempalte['footerinfo'] = $this->randomWeb($data,$ruleFooterinfo);
|
|
|
}
|
|
|
// $index = $this->randomPage($data);
|
|
|
return Result::success($tempalte);
|
|
|
}
|
|
|
- public function randomPage($data, $cate_num, $rule)
|
|
|
- {
|
|
|
- // return $rule;
|
|
|
- $page = $data['page'];
|
|
|
- $sectors = Sector::where('sector.template_id', $data['template_id'])
|
|
|
- ->where('sector.page_type', 'like', '%' . $page . '%')
|
|
|
- ->leftJoin('sector_place', function ($join) {
|
|
|
- $join->on('sector.place_type', '=', 'sector_place.sector_type')
|
|
|
- ->where('sector_place.type_id', 1);
|
|
|
- })
|
|
|
- ->whereNotNull('sector_place.sector_type')
|
|
|
- ->select(
|
|
|
- 'sector.sector_name',
|
|
|
- 'sector.sector_id',
|
|
|
- 'sector.pic_height',
|
|
|
- 'sector.sector_img',
|
|
|
- 'sector.sector_type',
|
|
|
- 'sector.sector_code',
|
|
|
- 'sector.id',
|
|
|
- 'sector.sector_width',
|
|
|
- 'sector.component_num',
|
|
|
- 'sector.cat_num',
|
|
|
- )
|
|
|
- ->orderBy('id')
|
|
|
- ->get()->all();
|
|
|
- if (empty($sectors)) {
|
|
|
- return Result::error('通栏不存在!');
|
|
|
- }
|
|
|
- // return $sectors;
|
|
|
- // 获取每个类别的通栏数量
|
|
|
- // $type_num = array_count_values(array_column($sectors, 'sector_type'));
|
|
|
- // 此页面通栏的所有类别
|
|
|
- // $all_sector_types = array_keys($type_num);
|
|
|
- //获取每个通栏类别在其中的位置 -------暂时不考虑先,应该是必需通栏类型或者非必需通栏类型,每个类型应该取一个,其余取可重复的通栏
|
|
|
- $all_sector_type = array_column($sectors, 'sector_type');
|
|
|
- $grouped = array_reduce(
|
|
|
- array_keys($sectors),
|
|
|
- function ($carry, $idx) use ($sectors) {
|
|
|
- $carry[$sectors[$idx]['sector_type']][] = $idx;
|
|
|
- return $carry;
|
|
|
- },
|
|
|
- );
|
|
|
+ // public function randomPage($data, $cate_num, $rule)
|
|
|
+ // {
|
|
|
+ // // return $rule;
|
|
|
+ // $page = $data['page'];
|
|
|
+ // $sectors = Sector::where('sector.template_id', $data['template_id'])
|
|
|
+ // ->where('sector.page_type', 'like', '%' . $page . '%')
|
|
|
+ // ->leftJoin('sector_place', function ($join) {
|
|
|
+ // $join->on('sector.place_type', '=', 'sector_place.sector_type')
|
|
|
+ // ->where('sector_place.type_id', 1);
|
|
|
+ // })
|
|
|
+ // ->whereNotNull('sector_place.sector_type')
|
|
|
+ // ->select(
|
|
|
+ // 'sector.sector_name',
|
|
|
+ // 'sector.sector_id',
|
|
|
+ // 'sector.pic_height',
|
|
|
+ // 'sector.sector_img',
|
|
|
+ // 'sector.sector_type',
|
|
|
+ // 'sector.sector_code',
|
|
|
+ // 'sector.id',
|
|
|
+ // 'sector.sector_width',
|
|
|
+ // 'sector.component_num',
|
|
|
+ // 'sector.cat_num',
|
|
|
+ // )
|
|
|
+ // ->orderBy('id')
|
|
|
+ // ->get()->all();
|
|
|
+ // if (empty($sectors)) {
|
|
|
+ // return Result::error('通栏不存在!');
|
|
|
+ // }
|
|
|
+ // // return $sectors;
|
|
|
+ // // 获取每个类别的通栏数量
|
|
|
+ // // $type_num = array_count_values(array_column($sectors, 'sector_type'));
|
|
|
+ // // 此页面通栏的所有类别
|
|
|
+ // // $all_sector_types = array_keys($type_num);
|
|
|
+ // //获取每个通栏类别在其中的位置 -------暂时不考虑先,应该是必需通栏类型或者非必需通栏类型,每个类型应该取一个,其余取可重复的通栏
|
|
|
+ // $all_sector_type = array_column($sectors, 'sector_type');
|
|
|
+ // $grouped = array_reduce(
|
|
|
+ // array_keys($sectors),
|
|
|
+ // function ($carry, $idx) use ($sectors) {
|
|
|
+ // $carry[$sectors[$idx]['sector_type']][] = $idx;
|
|
|
+ // return $carry;
|
|
|
+ // },
|
|
|
+ // );
|
|
|
|
|
|
- // 对 all_sector_type 去重后,每个类型随机挑一个 sector 索引
|
|
|
- $unipue_sector_keys = array_combine(
|
|
|
- array_keys($grouped),
|
|
|
- array_map(
|
|
|
- function ($type) use ($grouped) {
|
|
|
- // 随机取一个索引
|
|
|
- return $grouped[$type][array_rand($grouped[$type])];
|
|
|
- },
|
|
|
- array_keys($grouped)
|
|
|
- )
|
|
|
- );
|
|
|
+ // // 对 all_sector_type 去重后,每个类型随机挑一个 sector 索引
|
|
|
+ // $unipue_sector_keys = array_combine(
|
|
|
+ // array_keys($grouped),
|
|
|
+ // array_map(
|
|
|
+ // function ($type) use ($grouped) {
|
|
|
+ // // 随机取一个索引
|
|
|
+ // return $grouped[$type][array_rand($grouped[$type])];
|
|
|
+ // },
|
|
|
+ // array_keys($grouped)
|
|
|
+ // )
|
|
|
+ // );
|
|
|
|
|
|
- // 1. 必需通栏:同一类型只随机保留一条
|
|
|
- $rule_must_type = $rule->must_type;
|
|
|
- $sector_num = $rule->max_num;
|
|
|
- $unique_sector_type = array_flip($unipue_sector_keys);
|
|
|
- $must_type = array_unique(array_intersect($unique_sector_type,$rule_must_type));
|
|
|
- // 先求交集,去重后统计
|
|
|
- $is_must = count($must_type);
|
|
|
- if ($is_must != count(array_unique($must_type))) {
|
|
|
- return '此页面缺少必要通栏!';
|
|
|
- }
|
|
|
- // 先按类型把 sectors 分组,key 为 sector_type,value 为对应 sector 数组
|
|
|
+ // // 1. 必需通栏:同一类型只随机保留一条
|
|
|
+ // $rule_must_type = $rule->must_type;
|
|
|
+ // $sector_num = $rule->max_num;
|
|
|
+ // $unique_sector_type = array_flip($unipue_sector_keys);
|
|
|
+ // $must_type = array_unique(array_intersect($unique_sector_type,$rule_must_type));
|
|
|
+ // // 先求交集,去重后统计
|
|
|
+ // $is_must = count($must_type);
|
|
|
+ // if ($is_must != count(array_unique($must_type))) {
|
|
|
+ // return '此页面缺少必要通栏!';
|
|
|
+ // }
|
|
|
+ // // 先按类型把 sectors 分组,key 为 sector_type,value 为对应 sector 数组
|
|
|
|
|
|
- // return [
|
|
|
- // 'unipue_sector_keys'=>$unipue_sector_keys,
|
|
|
- // 'grouped'=>$grouped,
|
|
|
- // ];
|
|
|
- // 最终保留的 must_type 数组(去重且随机保留一个)
|
|
|
+ // // return [
|
|
|
+ // // 'unipue_sector_keys'=>$unipue_sector_keys,
|
|
|
+ // // 'grouped'=>$grouped,
|
|
|
+ // // ];
|
|
|
+ // // 最终保留的 must_type 数组(去重且随机保留一个)
|
|
|
|
|
|
- // return [
|
|
|
- // 'must_key'=>$must_key,'must_type'=>$must_type,
|
|
|
- // 'must_sector_keys'=>$must_sector_keys
|
|
|
- // ];
|
|
|
- // $must_sector_keys = array_intersect_key($unipue_sector_keys,$must_type);
|
|
|
- $must_sector = array_values(array_intersect_key($sectors,$must_type));
|
|
|
- $must_count = count($must_sector);
|
|
|
- // return $sector_comnum;
|
|
|
- // $must_sector = array_column($must_sector,'sector_type');
|
|
|
- // 目前按照首页必需通栏的数量进行处理,若是存在必需通栏的数量大于查询到的通栏数量,则返回必需通栏的数量
|
|
|
- if ($must_count > $sector_num) {
|
|
|
- return $must_sector;
|
|
|
- }
|
|
|
- // 必需通栏中的栏目数量
|
|
|
- if($page == 1){
|
|
|
- $must_cat_num = array_sum(array_column($must_sector,'cat_num'));
|
|
|
- if($must_cat_num>$cate_num){
|
|
|
- return '栏目数量过少,无法完成必需通栏随机!';
|
|
|
- }
|
|
|
- }
|
|
|
+ // // return [
|
|
|
+ // // 'must_key'=>$must_key,'must_type'=>$must_type,
|
|
|
+ // // 'must_sector_keys'=>$must_sector_keys
|
|
|
+ // // ];
|
|
|
+ // // $must_sector_keys = array_intersect_key($unipue_sector_keys,$must_type);
|
|
|
+ // $must_sector = array_values(array_intersect_key($sectors,$must_type));
|
|
|
+ // $must_count = count($must_sector);
|
|
|
+ // // return $sector_comnum;
|
|
|
+ // // $must_sector = array_column($must_sector,'sector_type');
|
|
|
+ // // 目前按照首页必需通栏的数量进行处理,若是存在必需通栏的数量大于查询到的通栏数量,则返回必需通栏的数量
|
|
|
+ // if ($must_count > $sector_num) {
|
|
|
+ // return $must_sector;
|
|
|
+ // }
|
|
|
+ // // 必需通栏中的栏目数量
|
|
|
+ // if($page == 1){
|
|
|
+ // $must_cat_num = array_sum(array_column($must_sector,'cat_num'));
|
|
|
+ // if($must_cat_num>$cate_num){
|
|
|
+ // return '栏目数量过少,无法完成必需通栏随机!';
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
- // var_dump(['must_cat_num'=>$must_cat_num,'cate_num'=>$cate_num]);
|
|
|
- // 2.非必须通栏的随机处理
|
|
|
- $not_must_type = array_unique(array_diff($unique_sector_type, $must_type));
|
|
|
+ // // var_dump(['must_cat_num'=>$must_cat_num,'cate_num'=>$cate_num]);
|
|
|
+ // // 2.非必须通栏的随机处理
|
|
|
+ // $not_must_type = array_unique(array_diff($unique_sector_type, $must_type));
|
|
|
|
|
|
- $total = count($not_must_type);
|
|
|
- $randomCount = mt_rand(0, $total); // 可能为0(无元素)或任意数量,最多等于数组长度
|
|
|
- $and_type = $rule->and_type ?? [];
|
|
|
- // return $not_must_type;
|
|
|
+ // $total = count($not_must_type);
|
|
|
+ // $randomCount = mt_rand(0, $total); // 可能为0(无元素)或任意数量,最多等于数组长度
|
|
|
+ // $and_type = $rule->and_type ?? [];
|
|
|
+ // // return $not_must_type;
|
|
|
|
|
|
- if ($randomCount === 0) {
|
|
|
- $random_sector = [];
|
|
|
- $rand_count = 0;
|
|
|
- } else {
|
|
|
- // 随机获取指定数量的键名(保留原键)
|
|
|
- $randomKeys = array_rand($not_must_type, $randomCount);
|
|
|
- // 处理单元素情况(array_rand返回字符串,需转为数组)
|
|
|
- if (!is_array($randomKeys)) {
|
|
|
- $randomKeys = [$randomKeys];
|
|
|
- }
|
|
|
+ // if ($randomCount === 0) {
|
|
|
+ // $random_sector = [];
|
|
|
+ // $rand_count = 0;
|
|
|
+ // } else {
|
|
|
+ // // 随机获取指定数量的键名(保留原键)
|
|
|
+ // $randomKeys = array_rand($not_must_type, $randomCount);
|
|
|
+ // // 处理单元素情况(array_rand返回字符串,需转为数组)
|
|
|
+ // if (!is_array($randomKeys)) {
|
|
|
+ // $randomKeys = [$randomKeys];
|
|
|
+ // }
|
|
|
|
|
|
- // 通栏关联性规则暂时无法实现---------------即若是随机了头条通栏必须要有轮播图通栏(皆为非必须通栏)
|
|
|
- // 假设 $oneDimensionalArray 是一维数组,$randomKeys 是随机数组
|
|
|
- // 判断 $oneDimensionalArray 是否为一维数组
|
|
|
- // if (isset($and_type) && is_array($and_type) && !array_is_list(array_filter($and_type, 'is_array'))) {
|
|
|
- // 判断是否存在有关联通栏的交集
|
|
|
- // if (isset($and_type) && !empty($and_type) && count(array_intersect($and_type, $randomKeys)) > 0) {
|
|
|
- // // var_dump("11111",$and_type);
|
|
|
- // // var_dump("22222",$randomKeys);
|
|
|
- // // 将一维数组中的值都放到随机数组中
|
|
|
- // $randomKeys = array_merge($randomKeys, $and_type);
|
|
|
- // }
|
|
|
- // var_dump(count(array_intersect($and_type, $randomKeys)));
|
|
|
- // }
|
|
|
- // -----------------------------
|
|
|
- // 根据随机键名提取元素(保留原键值关系)
|
|
|
- // $randomKeys = array_intersect($sector_type_keys,$randomKeys);
|
|
|
- // var_dump("randomKeys",$randomKeys);
|
|
|
- $random_sector = array_values(array_intersect_key($sectors, array_flip($randomKeys)));
|
|
|
- $rand_count = count($random_sector);
|
|
|
- }
|
|
|
- if($page == 1){
|
|
|
- $random_cat_num = array_sum(array_column($random_sector,'cat_num'));
|
|
|
- $random_cat_num += $must_cat_num;
|
|
|
- if($random_cat_num>$cate_num){
|
|
|
- return '栏目数量过少,无法完成随机!';
|
|
|
- }
|
|
|
- }
|
|
|
- // var_dump("randomKeys",$randomKeys);
|
|
|
- // var_dump("random_sector",$random_sector);
|
|
|
- // var_dump("rand_count", $rand_count);
|
|
|
- // var_dump("random_cat_num", $random_cat_num);
|
|
|
- // return $random_sector;
|
|
|
- // var_dump("must_sector",$must_sector);
|
|
|
- // var_dump("sector_num",$sector_num);
|
|
|
- // var_dump("must_count",$must_count);
|
|
|
- // return ['random_sector'=>$random_sector,'random_cat_num'=>$random_cat_num,'cate_num'=>$cate_num];
|
|
|
+ // // 通栏关联性规则暂时无法实现---------------即若是随机了头条通栏必须要有轮播图通栏(皆为非必须通栏)
|
|
|
+ // // 假设 $oneDimensionalArray 是一维数组,$randomKeys 是随机数组
|
|
|
+ // // 判断 $oneDimensionalArray 是否为一维数组
|
|
|
+ // // if (isset($and_type) && is_array($and_type) && !array_is_list(array_filter($and_type, 'is_array'))) {
|
|
|
+ // // 判断是否存在有关联通栏的交集
|
|
|
+ // // if (isset($and_type) && !empty($and_type) && count(array_intersect($and_type, $randomKeys)) > 0) {
|
|
|
+ // // // var_dump("11111",$and_type);
|
|
|
+ // // // var_dump("22222",$randomKeys);
|
|
|
+ // // // 将一维数组中的值都放到随机数组中
|
|
|
+ // // $randomKeys = array_merge($randomKeys, $and_type);
|
|
|
+ // // }
|
|
|
+ // // var_dump(count(array_intersect($and_type, $randomKeys)));
|
|
|
+ // // }
|
|
|
+ // // -----------------------------
|
|
|
+ // // 根据随机键名提取元素(保留原键值关系)
|
|
|
+ // // $randomKeys = array_intersect($sector_type_keys,$randomKeys);
|
|
|
+ // // var_dump("randomKeys",$randomKeys);
|
|
|
+ // $random_sector = array_values(array_intersect_key($sectors, array_flip($randomKeys)));
|
|
|
+ // $rand_count = count($random_sector);
|
|
|
+ // }
|
|
|
+ // if($page == 1){
|
|
|
+ // $random_cat_num = array_sum(array_column($random_sector,'cat_num'));
|
|
|
+ // $random_cat_num += $must_cat_num;
|
|
|
+ // if($random_cat_num>$cate_num){
|
|
|
+ // return '栏目数量过少,无法完成随机!';
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // // var_dump("randomKeys",$randomKeys);
|
|
|
+ // // var_dump("random_sector",$random_sector);
|
|
|
+ // // var_dump("rand_count", $rand_count);
|
|
|
+ // // var_dump("random_cat_num", $random_cat_num);
|
|
|
+ // // return $random_sector;
|
|
|
+ // // var_dump("must_sector",$must_sector);
|
|
|
+ // // var_dump("sector_num",$sector_num);
|
|
|
+ // // var_dump("must_count",$must_count);
|
|
|
+ // // return ['random_sector'=>$random_sector,'random_cat_num'=>$random_cat_num,'cate_num'=>$cate_num];
|
|
|
|
|
|
|
|
|
|
|
|
- // 3.计算随机之后减去必需的通栏,查询重复通栏可用数量;(目前的这些通栏没有重复的同类别通栏)
|
|
|
- $repeat_num = $sector_num - $rand_count - $must_count;
|
|
|
- // 组合起来通栏
|
|
|
- $sector_zuhe1 = array_merge($must_sector, $random_sector);
|
|
|
- $sector_zuhe1_type = array_column($sector_zuhe1, 'sector_type');
|
|
|
- $sector_ids = array_column($sector_zuhe1, 'id');
|
|
|
- if($repeat_num > 0){
|
|
|
- $rule_repeat = (array)$rule->type_max;
|
|
|
- $sector_zuhe1_type = array_count_values(array_column($sector_zuhe1,'sector_type'));
|
|
|
- // $sector_arr = array_intersect_key($rule_repeat,$sector_zuhe1_type);
|
|
|
- foreach ($rule_repeat as $key => $value) {
|
|
|
- if (in_array($key, array_keys($sector_zuhe1_type))) {
|
|
|
- $rule_repeat[$key] = $value - 1;
|
|
|
- }
|
|
|
- }
|
|
|
- // var_dump("repeat_num", $repeat_num);
|
|
|
- // 剩余通栏进行重复处理
|
|
|
- $rule_repeat = (array)$rule->type_max;
|
|
|
- // 取到可以重复的通栏类别
|
|
|
- $rule_repaet_type = array_keys($rule_repeat);
|
|
|
- $repeat_type = array_intersect($rule_repaet_type, $unique_sector_type);
|
|
|
- // 获取可以随机重复的通栏
|
|
|
- $repaet_key = 0;
|
|
|
- $type = [];
|
|
|
- // return $rule_repaet_type;
|
|
|
- // 防止无限循环,设置最大迭代次数
|
|
|
- $max_iterations = 10;
|
|
|
- $iteration_count = 0;
|
|
|
- // 剩余的栏目数量
|
|
|
- if($page == 1){
|
|
|
- $sector_cate_comnum = $cate_num - $random_cat_num;
|
|
|
- if($sector_cate_comnum < 0){
|
|
|
- return '栏目数量过少,无法完成随机!';
|
|
|
- }
|
|
|
- }
|
|
|
+ // // 3.计算随机之后减去必需的通栏,查询重复通栏可用数量;(目前的这些通栏没有重复的同类别通栏)
|
|
|
+ // $repeat_num = $sector_num - $rand_count - $must_count;
|
|
|
+ // // 组合起来通栏
|
|
|
+ // $sector_zuhe1 = array_merge($must_sector, $random_sector);
|
|
|
+ // $sector_zuhe1_type = array_column($sector_zuhe1, 'sector_type');
|
|
|
+ // $sector_ids = array_column($sector_zuhe1, 'id');
|
|
|
+ // if($repeat_num > 0){
|
|
|
+ // $rule_repeat = (array)$rule->type_max;
|
|
|
+ // $sector_zuhe1_type = array_count_values(array_column($sector_zuhe1,'sector_type'));
|
|
|
+ // // $sector_arr = array_intersect_key($rule_repeat,$sector_zuhe1_type);
|
|
|
+ // foreach ($rule_repeat as $key => $value) {
|
|
|
+ // if (in_array($key, array_keys($sector_zuhe1_type))) {
|
|
|
+ // $rule_repeat[$key] = $value - 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // // var_dump("repeat_num", $repeat_num);
|
|
|
+ // // 剩余通栏进行重复处理
|
|
|
+ // $rule_repeat = (array)$rule->type_max;
|
|
|
+ // // 取到可以重复的通栏类别
|
|
|
+ // $rule_repaet_type = array_keys($rule_repeat);
|
|
|
+ // $repeat_type = array_intersect($rule_repaet_type, $unique_sector_type);
|
|
|
+ // // 获取可以随机重复的通栏
|
|
|
+ // $repaet_key = 0;
|
|
|
+ // $type = [];
|
|
|
+ // // return $rule_repaet_type;
|
|
|
+ // // 防止无限循环,设置最大迭代次数
|
|
|
+ // $max_iterations = 10;
|
|
|
+ // $iteration_count = 0;
|
|
|
+ // // 剩余的栏目数量
|
|
|
+ // if($page == 1){
|
|
|
+ // $sector_cate_comnum = $cate_num - $random_cat_num;
|
|
|
+ // if($sector_cate_comnum < 0){
|
|
|
+ // return '栏目数量过少,无法完成随机!';
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
- // return [
|
|
|
- // // 'repeat_type'=>$repeat_type,
|
|
|
- // // 'repeat_num'=>$repeat_num,
|
|
|
- // 'must_count'=>$must_count,
|
|
|
- // 'rand_count'=>$rand_count,
|
|
|
- // 'repeat_num'=>$repeat_num,
|
|
|
- // 'sector_num'=>$sector_num,
|
|
|
- // 'cate_num'=>$cate_num,
|
|
|
- // 'sector_comnum'=>$sector_cate_comnum,
|
|
|
- // 'random_cat_num'=>$random_cat_num,
|
|
|
- // // 'rule_repeat'=>$rule_repeat,
|
|
|
- // // 'unique_sector_type'=>$unique_sector_type,
|
|
|
- // // 'all_sector_type'=>$all_sector_type,
|
|
|
- // // 'sector_zuhe1' =>$sector_zuhe1
|
|
|
- // ];
|
|
|
+ // // return [
|
|
|
+ // // // 'repeat_type'=>$repeat_type,
|
|
|
+ // // // 'repeat_num'=>$repeat_num,
|
|
|
+ // // 'must_count'=>$must_count,
|
|
|
+ // // 'rand_count'=>$rand_count,
|
|
|
+ // // 'repeat_num'=>$repeat_num,
|
|
|
+ // // 'sector_num'=>$sector_num,
|
|
|
+ // // 'cate_num'=>$cate_num,
|
|
|
+ // // 'sector_comnum'=>$sector_cate_comnum,
|
|
|
+ // // 'random_cat_num'=>$random_cat_num,
|
|
|
+ // // // 'rule_repeat'=>$rule_repeat,
|
|
|
+ // // // 'unique_sector_type'=>$unique_sector_type,
|
|
|
+ // // // 'all_sector_type'=>$all_sector_type,
|
|
|
+ // // // 'sector_zuhe1' =>$sector_zuhe1
|
|
|
+ // // ];
|
|
|
|
|
|
- // -----新添加的代码-----
|
|
|
- $re_sector = array_intersect($all_sector_type,$repeat_type);
|
|
|
- $re_sector_key = array_keys($re_sector);
|
|
|
- $every_repeattype_num = array_count_values($re_sector);
|
|
|
- // $re_sector_key = array_keys($re_sector,1);
|
|
|
- $repaet_key = 0;
|
|
|
- $re_type_keys = [];
|
|
|
+ // // -----新添加的代码-----
|
|
|
+ // $re_sector = array_intersect($all_sector_type,$repeat_type);
|
|
|
+ // $re_sector_key = array_keys($re_sector);
|
|
|
+ // $every_repeattype_num = array_count_values($re_sector);
|
|
|
+ // // $re_sector_key = array_keys($re_sector,1);
|
|
|
+ // $repaet_key = 0;
|
|
|
+ // $re_type_keys = [];
|
|
|
|
|
|
|
|
|
- $one_sector_key = array_search(1,$re_sector);
|
|
|
- $two_sector_key = array_search(2,$re_sector);
|
|
|
- $three_sector_key = array_search(3,$re_sector);
|
|
|
- $all_cat_num = array_column($sectors,'cat_num');
|
|
|
- $repeat_sector_key = [];
|
|
|
- // $rule_repeat['1'] = 1;
|
|
|
- // return $rule_repeat;
|
|
|
- // $three_sector_key = array_search(3,$re_sector);
|
|
|
- // $min_one_sector = max(array_column('cat_num',$all_sector));
|
|
|
- // 随机重复通栏-----
|
|
|
- // $rule_repeat['1'] = 1;
|
|
|
- // // 找出 all_sector_type 中值为 1 的键
|
|
|
- while ($repaet_key <= $repeat_num-1 && $iteration_count < $max_iterations) {
|
|
|
- // 剩余通栏数量>0 若不是首页则继续;若是首页则需要判断剩余栏目数量是否>3
|
|
|
- if ($repeat_num-$repaet_key > 0 && ($page != 1 || (isset($sector_cate_comnum) && $sector_cate_comnum > 3))) {
|
|
|
- foreach($repeat_type as $key => $value){
|
|
|
- $type_key = strval($value);
|
|
|
- if(!isset($re_type_keys[$value])){
|
|
|
- $re_type_keys[$value] = [];
|
|
|
- }
|
|
|
- // 剩余的通栏数量>0 并且 剩余的此类通栏数量>0
|
|
|
- if($repeat_num-$repaet_key > 0 && $rule_repeat[$type_key]- count($re_type_keys[$value]) > 0 && ($page != 1 || (isset($sector_cate_comnum) && $sector_cate_comnum > 3))){
|
|
|
- // var_dump("0000",array_keys($re_sector,$value));
|
|
|
- $one_sector_type = array_keys($re_sector,$value);
|
|
|
- // 若是此类通栏的数量>1 则随机取一个对应的键值
|
|
|
- if(count($one_sector_type) > 1){
|
|
|
- // 从 $one_sector_type 数组中随机取一个键名,并取其对应值
|
|
|
- $cat_key = $one_sector_type[array_rand($one_sector_type)];
|
|
|
- }else{
|
|
|
- $cat_key = $one_sector_type[0];
|
|
|
- }
|
|
|
- $repeat_sector_key[$repaet_key] = $cat_key;
|
|
|
- $repaet_key++;
|
|
|
- // var_dump("1115----------cat_key",$cat_key);
|
|
|
- if($page == 1){
|
|
|
- $sector_cate_comnum -= $all_cat_num[$cat_key];
|
|
|
- }
|
|
|
- if(!in_array($repaet_key,$re_type_keys[$value])){
|
|
|
- $re_type_keys[$value][] = $repaet_key;
|
|
|
- // var_dump("1117----------re_type_keys",$re_type_keys);
|
|
|
- }
|
|
|
- }else{
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- break;
|
|
|
- }
|
|
|
- $iteration_count++;
|
|
|
- }
|
|
|
- // var_dump("num", $num);
|
|
|
- // var_dump("repeat_sector_key", $repeat_sector_key);
|
|
|
- // 若是首页的通栏没有到10个,栏目还有剩余1~3个,则继续随机(已知当剩余栏目为4还会随机)
|
|
|
- if($page == 1 && count($repeat_sector_key) < $repeat_num && $sector_cate_comnum > 0){
|
|
|
- if($sector_cate_comnum == 1){
|
|
|
- array_push($repeat_sector_key,$one_sector_key);
|
|
|
- }else if($sector_cate_comnum == 2){
|
|
|
- array_push($repeat_sector_key,$two_sector_key);
|
|
|
- }else{
|
|
|
- array_push($repeat_sector_key,$three_sector_key);
|
|
|
- }
|
|
|
- }
|
|
|
- // 随机的重复通栏键值转换成真正的通栏
|
|
|
- $repeat_sector = [];
|
|
|
- if (isset($repeat_sector_key) && !empty($repeat_sector_key) && is_array($repeat_sector_key)) {
|
|
|
+ // $one_sector_key = array_search(1,$re_sector);
|
|
|
+ // $two_sector_key = array_search(2,$re_sector);
|
|
|
+ // $three_sector_key = array_search(3,$re_sector);
|
|
|
+ // $all_cat_num = array_column($sectors,'cat_num');
|
|
|
+ // $repeat_sector_key = [];
|
|
|
+ // // $rule_repeat['1'] = 1;
|
|
|
+ // // return $rule_repeat;
|
|
|
+ // // $three_sector_key = array_search(3,$re_sector);
|
|
|
+ // // $min_one_sector = max(array_column('cat_num',$all_sector));
|
|
|
+ // // 随机重复通栏-----
|
|
|
+ // // $rule_repeat['1'] = 1;
|
|
|
+ // // // 找出 all_sector_type 中值为 1 的键
|
|
|
+ // while ($repaet_key <= $repeat_num-1 && $iteration_count < $max_iterations) {
|
|
|
+ // // 剩余通栏数量>0 若不是首页则继续;若是首页则需要判断剩余栏目数量是否>3
|
|
|
+ // if ($repeat_num-$repaet_key > 0 && ($page != 1 || (isset($sector_cate_comnum) && $sector_cate_comnum > 3))) {
|
|
|
+ // foreach($repeat_type as $key => $value){
|
|
|
+ // $type_key = strval($value);
|
|
|
+ // if(!isset($re_type_keys[$value])){
|
|
|
+ // $re_type_keys[$value] = [];
|
|
|
+ // }
|
|
|
+ // // 剩余的通栏数量>0 并且 剩余的此类通栏数量>0
|
|
|
+ // if($repeat_num-$repaet_key > 0 && $rule_repeat[$type_key]- count($re_type_keys[$value]) > 0 && ($page != 1 || (isset($sector_cate_comnum) && $sector_cate_comnum > 3))){
|
|
|
+ // // var_dump("0000",array_keys($re_sector,$value));
|
|
|
+ // $one_sector_type = array_keys($re_sector,$value);
|
|
|
+ // // 若是此类通栏的数量>1 则随机取一个对应的键值
|
|
|
+ // if(count($one_sector_type) > 1){
|
|
|
+ // // 从 $one_sector_type 数组中随机取一个键名,并取其对应值
|
|
|
+ // $cat_key = $one_sector_type[array_rand($one_sector_type)];
|
|
|
+ // }else{
|
|
|
+ // $cat_key = $one_sector_type[0];
|
|
|
+ // }
|
|
|
+ // $repeat_sector_key[$repaet_key] = $cat_key;
|
|
|
+ // $repaet_key++;
|
|
|
+ // // var_dump("1115----------cat_key",$cat_key);
|
|
|
+ // if($page == 1){
|
|
|
+ // $sector_cate_comnum -= $all_cat_num[$cat_key];
|
|
|
+ // }
|
|
|
+ // if(!in_array($repaet_key,$re_type_keys[$value])){
|
|
|
+ // $re_type_keys[$value][] = $repaet_key;
|
|
|
+ // // var_dump("1117----------re_type_keys",$re_type_keys);
|
|
|
+ // }
|
|
|
+ // }else{
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // $iteration_count++;
|
|
|
+ // }
|
|
|
+ // // var_dump("num", $num);
|
|
|
+ // // var_dump("repeat_sector_key", $repeat_sector_key);
|
|
|
+ // // 若是首页的通栏没有到10个,栏目还有剩余1~3个,则继续随机(已知当剩余栏目为4还会随机)
|
|
|
+ // if($page == 1 && count($repeat_sector_key) < $repeat_num && $sector_cate_comnum > 0){
|
|
|
+ // if($sector_cate_comnum == 1){
|
|
|
+ // array_push($repeat_sector_key,$one_sector_key);
|
|
|
+ // }else if($sector_cate_comnum == 2){
|
|
|
+ // array_push($repeat_sector_key,$two_sector_key);
|
|
|
+ // }else{
|
|
|
+ // array_push($repeat_sector_key,$three_sector_key);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // // 随机的重复通栏键值转换成真正的通栏
|
|
|
+ // $repeat_sector = [];
|
|
|
+ // if (isset($repeat_sector_key) && !empty($repeat_sector_key) && is_array($repeat_sector_key)) {
|
|
|
|
|
|
- foreach ($repeat_sector_key as $key => $value) {
|
|
|
- if (isset($sectors[$value])) {
|
|
|
- $repeat_sector[$key] = $sectors[$value];
|
|
|
- }else{
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $repeat_count = count($repeat_sector);
|
|
|
- // var_dump("repeat_count", $repeat_count);
|
|
|
- // return [
|
|
|
- // 'not_repeat_num'=>$rand_count + $must_count,
|
|
|
- // // 'repeat_count'=>$repeat_count,
|
|
|
- // 'repeat_num'=>$repeat_num,
|
|
|
- // 'repeat_sector'=>$repeat_sector,
|
|
|
- // 'repeat_type'=>$repeat_type,
|
|
|
- // '$repaet_key'=>$repaet_key,
|
|
|
- // 'all_sector_type'=>$all_sector_type,
|
|
|
- // 're_sector'=>$re_sector,
|
|
|
- // 're_sector_key'=>$re_sector_key,
|
|
|
- // 'resdfddd'=>$every_repeattype_num,
|
|
|
- // 'repeat_sector_key'=>$repeat_sector_key,
|
|
|
- // // 'ddd'=>$ddd,
|
|
|
- // // 'sector_num'=>$sector_num,
|
|
|
- // // 'sector_zuhe1'=>count($sector_zuhe1),
|
|
|
- // // // 'repeat_sector'=>$repeat_sector,
|
|
|
- // // 'cate_num'=>$cate_num,
|
|
|
- // // 'random_cat_num'=>$random_cat_num,
|
|
|
- // 'rule_repeat' => $rule_repeat
|
|
|
- // ];
|
|
|
- // // var_dump("repeat_sector", $repeat_sector);
|
|
|
- // return $repeat_sector;
|
|
|
+ // foreach ($repeat_sector_key as $key => $value) {
|
|
|
+ // if (isset($sectors[$value])) {
|
|
|
+ // $repeat_sector[$key] = $sectors[$value];
|
|
|
+ // }else{
|
|
|
+ // continue;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // $repeat_count = count($repeat_sector);
|
|
|
+ // // var_dump("repeat_count", $repeat_count);
|
|
|
+ // // return [
|
|
|
+ // // 'not_repeat_num'=>$rand_count + $must_count,
|
|
|
+ // // // 'repeat_count'=>$repeat_count,
|
|
|
+ // // 'repeat_num'=>$repeat_num,
|
|
|
+ // // 'repeat_sector'=>$repeat_sector,
|
|
|
+ // // 'repeat_type'=>$repeat_type,
|
|
|
+ // // '$repaet_key'=>$repaet_key,
|
|
|
+ // // 'all_sector_type'=>$all_sector_type,
|
|
|
+ // // 're_sector'=>$re_sector,
|
|
|
+ // // 're_sector_key'=>$re_sector_key,
|
|
|
+ // // 'resdfddd'=>$every_repeattype_num,
|
|
|
+ // // 'repeat_sector_key'=>$repeat_sector_key,
|
|
|
+ // // // 'ddd'=>$ddd,
|
|
|
+ // // // 'sector_num'=>$sector_num,
|
|
|
+ // // // 'sector_zuhe1'=>count($sector_zuhe1),
|
|
|
+ // // // // 'repeat_sector'=>$repeat_sector,
|
|
|
+ // // // 'cate_num'=>$cate_num,
|
|
|
+ // // // 'random_cat_num'=>$random_cat_num,
|
|
|
+ // // 'rule_repeat' => $rule_repeat
|
|
|
+ // // ];
|
|
|
+ // // // var_dump("repeat_sector", $repeat_sector);
|
|
|
+ // // return $repeat_sector;
|
|
|
|
|
|
- $sector = array_merge($repeat_sector,$sector_zuhe1);
|
|
|
- }else{
|
|
|
- $sector = $sector_zuhe1;
|
|
|
- }
|
|
|
- // var_dump("sector_ids",$sector_ids);
|
|
|
- //
|
|
|
- // 各类型通栏最大数量数量限制 = 规则最大数量-已经存在的通栏数量(目前的通栏不会有重复的,所以只是-1)
|
|
|
+ // $sector = array_merge($repeat_sector,$sector_zuhe1);
|
|
|
+ // }else{
|
|
|
+ // $sector = $sector_zuhe1;
|
|
|
+ // }
|
|
|
+ // // var_dump("sector_ids",$sector_ids);
|
|
|
+ // //
|
|
|
+ // // 各类型通栏最大数量数量限制 = 规则最大数量-已经存在的通栏数量(目前的通栏不会有重复的,所以只是-1)
|
|
|
|
|
|
- // var_dump("sector",$sector);
|
|
|
- // 处理头条及轮播图在随机通栏中的特殊位置特殊处理
|
|
|
- $sector_specal_sort = array_column($sector,'sector_type');
|
|
|
- if(in_array(6,$sector_specal_sort) || in_array(7,$sector_specal_sort) || in_array(5,$sector_specal_sort)){
|
|
|
+ // // var_dump("sector",$sector);
|
|
|
+ // // 处理头条及轮播图在随机通栏中的特殊位置特殊处理
|
|
|
+ // $sector_specal_sort = array_column($sector,'sector_type');
|
|
|
+ // if(in_array(6,$sector_specal_sort) || in_array(7,$sector_specal_sort) || in_array(5,$sector_specal_sort)){
|
|
|
|
|
|
- $toutiao_key = array_search(6,$sector_specal_sort) ?? null;
|
|
|
- $pic_key = array_search(7,$sector_specal_sort) ?? null;
|
|
|
- $cat_key = array_search(5,$sector_specal_sort) ?? null;
|
|
|
- $toutiao = $sector[$toutiao_key];
|
|
|
- $pic = $sector[$pic_key];
|
|
|
- $cat = $sector[$cat_key];
|
|
|
- $sort_1 = $sector[0];
|
|
|
- $sort_2 = $sector[1];
|
|
|
- $sort_3 = $sector[2];
|
|
|
+ // $toutiao_key = array_search(6,$sector_specal_sort) ?? null;
|
|
|
+ // $pic_key = array_search(7,$sector_specal_sort) ?? null;
|
|
|
+ // $cat_key = array_search(5,$sector_specal_sort) ?? null;
|
|
|
+ // $toutiao = $sector[$toutiao_key];
|
|
|
+ // $pic = $sector[$pic_key];
|
|
|
+ // $cat = $sector[$cat_key];
|
|
|
+ // $sort_1 = $sector[0];
|
|
|
+ // $sort_2 = $sector[1];
|
|
|
+ // $sort_3 = $sector[2];
|
|
|
|
|
|
- // return $sector_specal_sort;
|
|
|
- // return [
|
|
|
- // 'sector_ids' => array_column($sector_zuhe1,'id'),
|
|
|
- // // 'repeat_sector' => $repeat_sector,
|
|
|
- // 'sector_id' => array_column($sector,'id'),
|
|
|
- // 'array_intersect' => count(array_intersect($sector,$must_sector)),
|
|
|
- // 'old' => [ $toutiao_key,$pic_key,$cat_key],
|
|
|
- // 'new' => [ $sort_1,$sort_2,$sort_3]
|
|
|
- // ];
|
|
|
- if($data['page'] == 1 || $data['page'] == '1'){
|
|
|
- if($toutiao_key && $pic_key){
|
|
|
- $sector[0] = $toutiao;
|
|
|
- $sector[$toutiao_key] = $sort_1;
|
|
|
- $sector[1] = $pic;
|
|
|
- $sector[$pic_key] = $sort_2;
|
|
|
- }else if($pic_key){
|
|
|
- $sector[0] = $pic;
|
|
|
- $sector[$pic_key] = $sort_1;
|
|
|
- }else{
|
|
|
- $sector[0] = $toutiao;
|
|
|
- $sector[$toutiao_key] = $sort_1;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($data['page'] == '2' || $data['page'] == 2 || in_array(5, $sector_specal_sort)) {
|
|
|
- $sector[0] = $cat;
|
|
|
- $sector[$cat_key] = $sort_1;
|
|
|
- if ($toutiao_key && $pic_key) {
|
|
|
- $sector[1] = $toutiao;
|
|
|
- $sector[$toutiao_key] = $sort_2;
|
|
|
- $sector[2] = $pic;
|
|
|
- $sector[$pic_key] = $sort_3;
|
|
|
- }else if ($pic_key) {
|
|
|
- $sector[1] = $pic;
|
|
|
- $sector[$pic_key] = $sort_2;
|
|
|
- }else if($toutiao_key){
|
|
|
- $sector[1] = $toutiao;
|
|
|
- $sector[$toutiao_key] = $sort_2;
|
|
|
- }
|
|
|
- }
|
|
|
+ // // return $sector_specal_sort;
|
|
|
+ // // return [
|
|
|
+ // // 'sector_ids' => array_column($sector_zuhe1,'id'),
|
|
|
+ // // // 'repeat_sector' => $repeat_sector,
|
|
|
+ // // 'sector_id' => array_column($sector,'id'),
|
|
|
+ // // 'array_intersect' => count(array_intersect($sector,$must_sector)),
|
|
|
+ // // 'old' => [ $toutiao_key,$pic_key,$cat_key],
|
|
|
+ // // 'new' => [ $sort_1,$sort_2,$sort_3]
|
|
|
+ // // ];
|
|
|
+ // if($data['page'] == 1 || $data['page'] == '1'){
|
|
|
+ // if($toutiao_key && $pic_key){
|
|
|
+ // $sector[0] = $toutiao;
|
|
|
+ // $sector[$toutiao_key] = $sort_1;
|
|
|
+ // $sector[1] = $pic;
|
|
|
+ // $sector[$pic_key] = $sort_2;
|
|
|
+ // }else if($pic_key){
|
|
|
+ // $sector[0] = $pic;
|
|
|
+ // $sector[$pic_key] = $sort_1;
|
|
|
+ // }else{
|
|
|
+ // $sector[0] = $toutiao;
|
|
|
+ // $sector[$toutiao_key] = $sort_1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if ($data['page'] == '2' || $data['page'] == 2 || in_array(5, $sector_specal_sort)) {
|
|
|
+ // $sector[0] = $cat;
|
|
|
+ // $sector[$cat_key] = $sort_1;
|
|
|
+ // if ($toutiao_key && $pic_key) {
|
|
|
+ // $sector[1] = $toutiao;
|
|
|
+ // $sector[$toutiao_key] = $sort_2;
|
|
|
+ // $sector[2] = $pic;
|
|
|
+ // $sector[$pic_key] = $sort_3;
|
|
|
+ // }else if ($pic_key) {
|
|
|
+ // $sector[1] = $pic;
|
|
|
+ // $sector[$pic_key] = $sort_2;
|
|
|
+ // }else if($toutiao_key){
|
|
|
+ // $sector[1] = $toutiao;
|
|
|
+ // $sector[$toutiao_key] = $sort_2;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
|
|
|
- }
|
|
|
- $sector_id = array_column($sector,'id');
|
|
|
+ // }
|
|
|
+ // $sector_id = array_column($sector,'id');
|
|
|
|
|
|
- // if(count(array_intersect($sector,$must_sector)) != count($must_sector)){
|
|
|
- // return '此页面缺少必要通栏!';
|
|
|
- // }
|
|
|
- // return Result::success([
|
|
|
- // // 'sector_id'=>$sector_id,
|
|
|
- // 'sector'=>$sector,
|
|
|
- // // 'cate_num'=>$cate_num,
|
|
|
- // ]);
|
|
|
- // $data['page'] = $page;
|
|
|
- $component[] = $this->randomComponent($sector_id,$data,$sector);
|
|
|
- var_dump("sector_id",$sector_id);
|
|
|
- return [
|
|
|
- // 'sector'=>$sector,
|
|
|
- // 'must_sector'=>$must_sector,
|
|
|
- // 'sector_count'=>count($sector),
|
|
|
- // 'sectors'=>$sectors,
|
|
|
- // 'sector_comnum'=>$sector_comnum,
|
|
|
- // 'com_num'=>$com_num,
|
|
|
- // 'cate_num'=>$cate_num,
|
|
|
- // '$sector_zuhe1_comnum'=>$sector_zuhe1_comnum+$com_num,
|
|
|
- 'component'=>$component,
|
|
|
- // 'sector'=>$sector,
|
|
|
- ];
|
|
|
- }
|
|
|
- public function randomComponent($sector_id, $data, $sector)
|
|
|
- {
|
|
|
- $rawResults = SectorComponent::whereIn('sector_component.sectorid', $sector_id)
|
|
|
- ->leftJoin('component', 'component.component_type', 'sector_component.component_id')
|
|
|
- ->leftJoin('component_img', function ($join) use ($data) {
|
|
|
- $join->on('component_img.component_id', '=', 'component.component_type')
|
|
|
- ->where('component_img.template_id', '=', $data['template_id'] ?? 0);
|
|
|
- })
|
|
|
- ->select(
|
|
|
- 'component.*',
|
|
|
- 'component_img.img_name',
|
|
|
- 'component_img.img_id',
|
|
|
- 'component_img.img_url',
|
|
|
- 'sector_component.sort_id',
|
|
|
- 'sector_component.sectorid'
|
|
|
- )
|
|
|
- ->orderBy('sector_component.sort_id')
|
|
|
- ->orderBy('component.component_type')
|
|
|
- ->get()->all();
|
|
|
- // return $rawResults;
|
|
|
- $img_key = 0;
|
|
|
- $com_key = 0;
|
|
|
- foreach( $rawResults as $key => $value){
|
|
|
- $component_id = $value['component_type'];
|
|
|
- $sort_id = $value['sort_id']-1;
|
|
|
- $img_id = intval($value['img_id']);
|
|
|
- $sector_id = $value['sectorid'];
|
|
|
- $component_data = json_decode($value['component_data'] ?? '[]',true);
|
|
|
- $component_column = json_decode($value['component_column'] ?? '[]',true);
|
|
|
- $component_json['componentData'] = $component_data['componentData'] ?? [];
|
|
|
- // 组件类型:1:头条;2:轮播图;3:推荐图;4:最新资讯;5:推荐资讯;6:热点资讯;7:栏目资讯类;
|
|
|
- // 8:列表类;9:详情类;10:二级导航栏类;11:广告类;12:静态类;13:单页导航类;14:资讯广告混合类;
|
|
|
- // 15:滚动图文类;16:搜索框类;17:单页列表类;18:单页详情类;19-24:选项卡3-7
|
|
|
- if(!in_array($value['type_id'],[10,11,12,16,])){
|
|
|
- $component_json['componentData']['listType'] = $component_column['listType'] ?? '';
|
|
|
- }
|
|
|
- if(!isset($component_img[$component_id])){
|
|
|
- $component_img[$component_id] = [];
|
|
|
- $com_key = 0;
|
|
|
- }else{
|
|
|
- $com_key++;
|
|
|
- }
|
|
|
- if(!isset($component_img[$component_id][$sort_id])){
|
|
|
- $component_img[$component_id][$sort_id] = [];
|
|
|
- $img_key = 0;
|
|
|
- }else{
|
|
|
- $img_key++;
|
|
|
- }
|
|
|
- if(!empty($img_id)){
|
|
|
- $component_img[$component_id][$sort_id][$img_key] =
|
|
|
- [
|
|
|
- 'component_id' => $value['component_type'],
|
|
|
- 'img_id' => $value['img_id'],
|
|
|
- 'component_imgurl' => $value['img_url'],
|
|
|
- ];
|
|
|
- }
|
|
|
- // else{
|
|
|
- // $component_img[$component_id][$sort_id][$img_key] = [];
|
|
|
- // }
|
|
|
- // $component_img = array_values($component_img[$component_id][$sort_id]);
|
|
|
- if(in_array($value['type_id'],[19, 20, 21, 22, 23, 24])){
|
|
|
- $groupedResults[$sector_id][$sort_id] =
|
|
|
- [
|
|
|
- 'component_type' => $component_id,
|
|
|
- 'sort' => $value['sort_id'],
|
|
|
- 'type_id' => $value['type_id'],
|
|
|
- 'componentData' => [
|
|
|
- $component_json['componentData'],
|
|
|
- $component_json['componentData'],
|
|
|
- ],
|
|
|
- 'images' => $component_img[$component_id][$sort_id]
|
|
|
- ];
|
|
|
- }else{
|
|
|
- $groupedResults[$sector_id][$sort_id] =
|
|
|
- [
|
|
|
- 'component_type' => $component_id,
|
|
|
- 'sort' => $value['sort_id'],
|
|
|
- 'type_id' => $value['type_id'],
|
|
|
- 'componentData' => $component_json['componentData'],
|
|
|
- 'images' => $component_img[$component_id][$sort_id]
|
|
|
- ];
|
|
|
- }
|
|
|
+ // // if(count(array_intersect($sector,$must_sector)) != count($must_sector)){
|
|
|
+ // // return '此页面缺少必要通栏!';
|
|
|
+ // // }
|
|
|
+ // // return Result::success([
|
|
|
+ // // // 'sector_id'=>$sector_id,
|
|
|
+ // // 'sector'=>$sector,
|
|
|
+ // // // 'cate_num'=>$cate_num,
|
|
|
+ // // ]);
|
|
|
+ // // $data['page'] = $page;
|
|
|
+ // $component[] = $this->randomComponent($sector_id,$data,$sector);
|
|
|
+ // var_dump("sector_id",$sector_id);
|
|
|
+ // return [
|
|
|
+ // // 'sector'=>$sector,
|
|
|
+ // // 'must_sector'=>$must_sector,
|
|
|
+ // // 'sector_count'=>count($sector),
|
|
|
+ // // 'sectors'=>$sectors,
|
|
|
+ // // 'sector_comnum'=>$sector_comnum,
|
|
|
+ // // 'com_num'=>$com_num,
|
|
|
+ // // 'cate_num'=>$cate_num,
|
|
|
+ // // '$sector_zuhe1_comnum'=>$sector_zuhe1_comnum+$com_num,
|
|
|
+ // 'component'=>$component,
|
|
|
+ // // 'sector'=>$sector,
|
|
|
+ // ];
|
|
|
+ // }
|
|
|
+ // public function randomComponent($sector_id, $data, $sector)
|
|
|
+ // {
|
|
|
+ // $rawResults = SectorComponent::whereIn('sector_component.sectorid', $sector_id)
|
|
|
+ // ->leftJoin('component', 'component.component_type', 'sector_component.component_id')
|
|
|
+ // ->leftJoin('component_img', function ($join) use ($data) {
|
|
|
+ // $join->on('component_img.component_id', '=', 'component.component_type')
|
|
|
+ // ->where('component_img.template_id', '=', $data['template_id'] ?? 0);
|
|
|
+ // })
|
|
|
+ // ->select(
|
|
|
+ // 'component.*',
|
|
|
+ // 'component_img.img_name',
|
|
|
+ // 'component_img.img_id',
|
|
|
+ // 'component_img.img_url',
|
|
|
+ // 'sector_component.sort_id',
|
|
|
+ // 'sector_component.sectorid'
|
|
|
+ // )
|
|
|
+ // ->orderBy('sector_component.sort_id')
|
|
|
+ // ->orderBy('component.component_type')
|
|
|
+ // ->get()->all();
|
|
|
+ // // return $rawResults;
|
|
|
+ // $img_key = 0;
|
|
|
+ // $com_key = 0;
|
|
|
+ // foreach( $rawResults as $key => $value){
|
|
|
+ // $component_id = $value['component_type'];
|
|
|
+ // $sort_id = $value['sort_id']-1;
|
|
|
+ // $img_id = intval($value['img_id']);
|
|
|
+ // $sector_id = $value['sectorid'];
|
|
|
+ // $component_data = json_decode($value['component_data'] ?? '[]',true);
|
|
|
+ // $component_column = json_decode($value['component_column'] ?? '[]',true);
|
|
|
+ // $component_json['componentData'] = $component_data['componentData'] ?? [];
|
|
|
+ // // 组件类型:1:头条;2:轮播图;3:推荐图;4:最新资讯;5:推荐资讯;6:热点资讯;7:栏目资讯类;
|
|
|
+ // // 8:列表类;9:详情类;10:二级导航栏类;11:广告类;12:静态类;13:单页导航类;14:资讯广告混合类;
|
|
|
+ // // 15:滚动图文类;16:搜索框类;17:单页列表类;18:单页详情类;19-24:选项卡3-7
|
|
|
+ // if(!in_array($value['type_id'],[10,11,12,16,])){
|
|
|
+ // $component_json['componentData']['listType'] = $component_column['listType'] ?? '';
|
|
|
+ // }
|
|
|
+ // if(!isset($component_img[$component_id])){
|
|
|
+ // $component_img[$component_id] = [];
|
|
|
+ // $com_key = 0;
|
|
|
+ // }else{
|
|
|
+ // $com_key++;
|
|
|
+ // }
|
|
|
+ // if(!isset($component_img[$component_id][$sort_id])){
|
|
|
+ // $component_img[$component_id][$sort_id] = [];
|
|
|
+ // $img_key = 0;
|
|
|
+ // }else{
|
|
|
+ // $img_key++;
|
|
|
+ // }
|
|
|
+ // if(!empty($img_id)){
|
|
|
+ // $component_img[$component_id][$sort_id][$img_key] =
|
|
|
+ // [
|
|
|
+ // 'component_id' => $value['component_type'],
|
|
|
+ // 'img_id' => $value['img_id'],
|
|
|
+ // 'component_imgurl' => $value['img_url'],
|
|
|
+ // ];
|
|
|
+ // }
|
|
|
+ // // else{
|
|
|
+ // // $component_img[$component_id][$sort_id][$img_key] = [];
|
|
|
+ // // }
|
|
|
+ // // $component_img = array_values($component_img[$component_id][$sort_id]);
|
|
|
+ // if(in_array($value['type_id'],[19, 20, 21, 22, 23, 24])){
|
|
|
+ // $groupedResults[$sector_id][$sort_id] =
|
|
|
+ // [
|
|
|
+ // 'component_type' => $component_id,
|
|
|
+ // 'sort' => $value['sort_id'],
|
|
|
+ // 'type_id' => $value['type_id'],
|
|
|
+ // 'componentData' => [
|
|
|
+ // $component_json['componentData'],
|
|
|
+ // $component_json['componentData'],
|
|
|
+ // ],
|
|
|
+ // 'images' => $component_img[$component_id][$sort_id]
|
|
|
+ // ];
|
|
|
+ // }else{
|
|
|
+ // $groupedResults[$sector_id][$sort_id] =
|
|
|
+ // [
|
|
|
+ // 'component_type' => $component_id,
|
|
|
+ // 'sort' => $value['sort_id'],
|
|
|
+ // 'type_id' => $value['type_id'],
|
|
|
+ // 'componentData' => $component_json['componentData'],
|
|
|
+ // 'images' => $component_img[$component_id][$sort_id]
|
|
|
+ // ];
|
|
|
+ // }
|
|
|
|
|
|
- if(in_array($value['type_id'],[11,14,24])){
|
|
|
- $groupedResults[$sector_id][$sort_id]['ad'] = json_decode($value['ad'],JSON_UNESCAPED_UNICODE);
|
|
|
- }
|
|
|
- // [$img_id-1] = $value['img_id'];
|
|
|
- }
|
|
|
- // return ['groupedResults'=>$groupedResults,
|
|
|
- // 'component_data'=>$component_data];
|
|
|
- $y_num = 0;
|
|
|
- foreach ($sector as $key => $value) {
|
|
|
- // array_push($value['sort_id'],$key);
|
|
|
- // $sector_id_ = $value['sector_id'];
|
|
|
- $sectorid = $value['id'];
|
|
|
- $template_data[$key] = [
|
|
|
- 'sectorName' => $value['sector_id'],
|
|
|
- 'sort' => $key + 1,
|
|
|
- ];
|
|
|
- $date = date('mdHisu'); // 获取时分秒微秒,转换为纯数字格式
|
|
|
- // $date = 11010630021;
|
|
|
- if (substr($date, 0, 1) == 0) {
|
|
|
- $date = substr($date, 0, 10); // 截取前9位
|
|
|
- } else {
|
|
|
- $date = substr($date, 0, 9); // 截取前9位
|
|
|
- }
|
|
|
- $random_num = intval(intval($date) . rand(1000, 9999)); // 拼接4位随机数,组成13位随机数
|
|
|
- $y_num = $y_num + $value['pic_height'];
|
|
|
- $sector_width = $value['sector_width'] / 100;
|
|
|
- $canvas_data[$key] = [
|
|
|
- 'i' => $random_num,
|
|
|
- 'x' => 0,
|
|
|
- 'y' => $y_num,
|
|
|
- 'w' => $sector_width,
|
|
|
- 'h' => $value['pic_height'],
|
|
|
- 'type' => $value['sector_id'],
|
|
|
- 'content' => [
|
|
|
- 'sectorName' => $value['sector_id'],
|
|
|
- ]
|
|
|
+ // if(in_array($value['type_id'],[11,14,24])){
|
|
|
+ // $groupedResults[$sector_id][$sort_id]['ad'] = json_decode($value['ad'],JSON_UNESCAPED_UNICODE);
|
|
|
+ // }
|
|
|
+ // // [$img_id-1] = $value['img_id'];
|
|
|
+ // }
|
|
|
+ // // return ['groupedResults'=>$groupedResults,
|
|
|
+ // // 'component_data'=>$component_data];
|
|
|
+ // $y_num = 0;
|
|
|
+ // foreach ($sector as $key => $value) {
|
|
|
+ // // array_push($value['sort_id'],$key);
|
|
|
+ // // $sector_id_ = $value['sector_id'];
|
|
|
+ // $sectorid = $value['id'];
|
|
|
+ // $template_data[$key] = [
|
|
|
+ // 'sectorName' => $value['sector_id'],
|
|
|
+ // 'sort' => $key + 1,
|
|
|
+ // ];
|
|
|
+ // $date = date('mdHisu'); // 获取时分秒微秒,转换为纯数字格式
|
|
|
+ // // $date = 11010630021;
|
|
|
+ // if (substr($date, 0, 1) == 0) {
|
|
|
+ // $date = substr($date, 0, 10); // 截取前9位
|
|
|
+ // } else {
|
|
|
+ // $date = substr($date, 0, 9); // 截取前9位
|
|
|
+ // }
|
|
|
+ // $random_num = intval(intval($date) . rand(1000, 9999)); // 拼接4位随机数,组成13位随机数
|
|
|
+ // $y_num = $y_num + $value['pic_height'];
|
|
|
+ // $sector_width = $value['sector_width'] / 100;
|
|
|
+ // $canvas_data[$key] = [
|
|
|
+ // 'i' => $random_num,
|
|
|
+ // 'x' => 0,
|
|
|
+ // 'y' => $y_num,
|
|
|
+ // 'w' => $sector_width,
|
|
|
+ // 'h' => $value['pic_height'],
|
|
|
+ // 'type' => $value['sector_id'],
|
|
|
+ // 'content' => [
|
|
|
+ // 'sectorName' => $value['sector_id'],
|
|
|
+ // ]
|
|
|
|
|
|
- ];
|
|
|
- // $sector_key[$key] = array_keys($value );
|
|
|
- $sector_component = [];
|
|
|
- if (isset($groupedResults[$sectorid]) && !empty($groupedResults[$sectorid]) && is_array($groupedResults[$sectorid])) {
|
|
|
- $componet_key = 0;
|
|
|
- foreach ($groupedResults[$sectorid] as $sortId => $components) {
|
|
|
- // // // // 通栏某一位置的随机组件
|
|
|
- // if (count($components) > 1) {
|
|
|
- // $componentIds = count($components);
|
|
|
- // $selectedComponentId = rand(0, $componentIds - 1);
|
|
|
- // } else {
|
|
|
- // $selectedComponentId = 0;
|
|
|
- // }
|
|
|
- // // var_dump($components[$selectedComponentId]);
|
|
|
- // $Component = $components;
|
|
|
- $Component['component_type'] = $components['component_type'] ?? 0;
|
|
|
- $Component['sort'] = $components['sort'] ?? 1;
|
|
|
- $Component['type_id'] = $components['type_id'] ?? 0;
|
|
|
- // // 通栏某一位置的随机组件样式图
|
|
|
- // // 检查 $Component['images'] 是否存在且为数组
|
|
|
- if (isset($components['images']) && is_array($components['images'])) {
|
|
|
- // var_dump('action1-------------------------------------sortId',$sortId);
|
|
|
- $images = count($components['images']);
|
|
|
- $selectedImage = 0;
|
|
|
- if ($images > 1) {
|
|
|
- $selectedImage = rand(0, $images - 1);
|
|
|
- }
|
|
|
- if (isset($components['images'][$selectedImage])) {
|
|
|
- $Component['component_style'] = is_object($components['images'][$selectedImage]) ? $components['images'][$selectedImage]->img_id : $components['images'][$selectedImage]['img_id'];
|
|
|
- }
|
|
|
- }
|
|
|
- if(isset($components['images'][$selectedImage])){
|
|
|
- $image_info[$key] = is_object($components['images'][$selectedImage]) ? $components['images'][$selectedImage] : $components['images'][$selectedImage];
|
|
|
- }
|
|
|
- // var_dump($images);
|
|
|
- // if(isset($components['type_id']) && in_array($components['type_id'], [19, 20, 21, 22, 23, 24])){
|
|
|
- // // $Component['componentData'][0] = $components['componentData'] ?? [];
|
|
|
- // // $Component['componentData'][1] = $components['componentData'] ?? [];
|
|
|
- // }else{
|
|
|
- $Component['componentData'] = $components['componentData'] ?? [];
|
|
|
- // }
|
|
|
- if ($data['page'] == 1 && (isset($components['type_id']) && in_array($components['type_id'], [7, 14, 15, 23, 24]))) {
|
|
|
- if(in_array($components['type_id'], [23, 24])){
|
|
|
- $Component['componentData'][0]['name'] = '请选择栏目';
|
|
|
- $Component['componentData'][1]['name'] = '请选择栏目';
|
|
|
- }else{
|
|
|
- $Component['componentData']['name'] = '请选择栏目';
|
|
|
- }
|
|
|
- }
|
|
|
- if ($data['page'] == 2 && (isset($components['type_id']) && in_array($components['type_id'], [7, 14, 15, 23, 24]))) {
|
|
|
- if(in_array($components['type_id'], [23, 24])){
|
|
|
- $Component['componentData'][0]['name'] = '自动生成';
|
|
|
- $Component['componentData'][1]['name'] = '自动生成';
|
|
|
- }else{
|
|
|
- $Component['componentData']['name'] = '自动生成';
|
|
|
- }
|
|
|
- }
|
|
|
- if (isset($components['type_id']) && $components['type_id'] == 11) {
|
|
|
- $ad = $components['ad'];
|
|
|
- $ad['thumb'] = $image_info[$key]['component_imgurl'] ?? '';
|
|
|
- $template_data[$key]['ad'] = $ad;
|
|
|
- $canvas_adinfo[$key] = $ad;
|
|
|
- $canvas_data[$key]['content']['ad'] = $canvas_adinfo[$key];
|
|
|
- // // 确保 $ad 和 $canvas_adinfo[$key] 元素数量一致,直接组合
|
|
|
- // $canvas_data[$key]['ad'] = array_combine($ad, $canvas_adinfo[$key]);
|
|
|
- $Component['componentData'] = [];
|
|
|
- }
|
|
|
- if (isset($components['type_id']) && $components['type_id'] == 14) {
|
|
|
- $ad = $components['ad'];
|
|
|
- $ad['thumb'] = $image_info[$key]['component_imgurl'] ?? '';
|
|
|
- $template_data[$key]['ad'] = $ad;
|
|
|
- $canvas_adinfo[$key] = $ad;
|
|
|
- $canvas_data[$key]['content']['ad'] = $canvas_adinfo[$key];
|
|
|
- // $canvas_data[$key]['ad'] = array_combine($ad, $canvas_adinfo[$key]);
|
|
|
+ // ];
|
|
|
+ // // $sector_key[$key] = array_keys($value );
|
|
|
+ // $sector_component = [];
|
|
|
+ // if (isset($groupedResults[$sectorid]) && !empty($groupedResults[$sectorid]) && is_array($groupedResults[$sectorid])) {
|
|
|
+ // $componet_key = 0;
|
|
|
+ // foreach ($groupedResults[$sectorid] as $sortId => $components) {
|
|
|
+ // // // // // 通栏某一位置的随机组件
|
|
|
+ // // if (count($components) > 1) {
|
|
|
+ // // $componentIds = count($components);
|
|
|
+ // // $selectedComponentId = rand(0, $componentIds - 1);
|
|
|
+ // // } else {
|
|
|
+ // // $selectedComponentId = 0;
|
|
|
+ // // }
|
|
|
+ // // // var_dump($components[$selectedComponentId]);
|
|
|
+ // // $Component = $components;
|
|
|
+ // $Component['component_type'] = $components['component_type'] ?? 0;
|
|
|
+ // $Component['sort'] = $components['sort'] ?? 1;
|
|
|
+ // $Component['type_id'] = $components['type_id'] ?? 0;
|
|
|
+ // // // 通栏某一位置的随机组件样式图
|
|
|
+ // // // 检查 $Component['images'] 是否存在且为数组
|
|
|
+ // if (isset($components['images']) && is_array($components['images'])) {
|
|
|
+ // // var_dump('action1-------------------------------------sortId',$sortId);
|
|
|
+ // $images = count($components['images']);
|
|
|
+ // $selectedImage = 0;
|
|
|
+ // if ($images > 1) {
|
|
|
+ // $selectedImage = rand(0, $images - 1);
|
|
|
+ // }
|
|
|
+ // if (isset($components['images'][$selectedImage])) {
|
|
|
+ // $Component['component_style'] = is_object($components['images'][$selectedImage]) ? $components['images'][$selectedImage]->img_id : $components['images'][$selectedImage]['img_id'];
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if(isset($components['images'][$selectedImage])){
|
|
|
+ // $image_info[$key] = is_object($components['images'][$selectedImage]) ? $components['images'][$selectedImage] : $components['images'][$selectedImage];
|
|
|
+ // }
|
|
|
+ // // var_dump($images);
|
|
|
+ // // if(isset($components['type_id']) && in_array($components['type_id'], [19, 20, 21, 22, 23, 24])){
|
|
|
+ // // // $Component['componentData'][0] = $components['componentData'] ?? [];
|
|
|
+ // // // $Component['componentData'][1] = $components['componentData'] ?? [];
|
|
|
+ // // }else{
|
|
|
+ // $Component['componentData'] = $components['componentData'] ?? [];
|
|
|
+ // // }
|
|
|
+ // if ($data['page'] == 1 && (isset($components['type_id']) && in_array($components['type_id'], [7, 14, 15, 23, 24]))) {
|
|
|
+ // if(in_array($components['type_id'], [23, 24])){
|
|
|
+ // $Component['componentData'][0]['name'] = '请选择栏目';
|
|
|
+ // $Component['componentData'][1]['name'] = '请选择栏目';
|
|
|
+ // }else{
|
|
|
+ // $Component['componentData']['name'] = '请选择栏目';
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if ($data['page'] == 2 && (isset($components['type_id']) && in_array($components['type_id'], [7, 14, 15, 23, 24]))) {
|
|
|
+ // if(in_array($components['type_id'], [23, 24])){
|
|
|
+ // $Component['componentData'][0]['name'] = '自动生成';
|
|
|
+ // $Component['componentData'][1]['name'] = '自动生成';
|
|
|
+ // }else{
|
|
|
+ // $Component['componentData']['name'] = '自动生成';
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (isset($components['type_id']) && $components['type_id'] == 11) {
|
|
|
+ // $ad = $components['ad'];
|
|
|
+ // $ad['thumb'] = $image_info[$key]['component_imgurl'] ?? '';
|
|
|
+ // $template_data[$key]['ad'] = $ad;
|
|
|
+ // $canvas_adinfo[$key] = $ad;
|
|
|
+ // $canvas_data[$key]['content']['ad'] = $canvas_adinfo[$key];
|
|
|
+ // // // 确保 $ad 和 $canvas_adinfo[$key] 元素数量一致,直接组合
|
|
|
+ // // $canvas_data[$key]['ad'] = array_combine($ad, $canvas_adinfo[$key]);
|
|
|
+ // $Component['componentData'] = [];
|
|
|
+ // }
|
|
|
+ // if (isset($components['type_id']) && $components['type_id'] == 14) {
|
|
|
+ // $ad = $components['ad'];
|
|
|
+ // $ad['thumb'] = $image_info[$key]['component_imgurl'] ?? '';
|
|
|
+ // $template_data[$key]['ad'] = $ad;
|
|
|
+ // $canvas_adinfo[$key] = $ad;
|
|
|
+ // $canvas_data[$key]['content']['ad'] = $canvas_adinfo[$key];
|
|
|
+ // // $canvas_data[$key]['ad'] = array_combine($ad, $canvas_adinfo[$key]);
|
|
|
|
|
|
- // // $Component['componentData'] = [];
|
|
|
- }
|
|
|
- if (isset($components['type_id']) && $components['type_id'] == 24) {
|
|
|
- $ad = $components['ad'][0];
|
|
|
- // $ad['thumb'] = $image_info[$key]['component_imgurl'] ?? '';
|
|
|
- $template_data[$key]['ad'][0] = $ad;
|
|
|
- $template_data[$key]['ad'][1] = $ad;
|
|
|
- $canvas_adinfo[$key] = $ad;
|
|
|
- $canvas_data[$key]['content']['ad'][0] = $canvas_adinfo[$key];
|
|
|
- $canvas_data[$key]['content']['ad'][1] = $canvas_adinfo[$key];
|
|
|
+ // // // $Component['componentData'] = [];
|
|
|
+ // }
|
|
|
+ // if (isset($components['type_id']) && $components['type_id'] == 24) {
|
|
|
+ // $ad = $components['ad'][0];
|
|
|
+ // // $ad['thumb'] = $image_info[$key]['component_imgurl'] ?? '';
|
|
|
+ // $template_data[$key]['ad'][0] = $ad;
|
|
|
+ // $template_data[$key]['ad'][1] = $ad;
|
|
|
+ // $canvas_adinfo[$key] = $ad;
|
|
|
+ // $canvas_data[$key]['content']['ad'][0] = $canvas_adinfo[$key];
|
|
|
+ // $canvas_data[$key]['content']['ad'][1] = $canvas_adinfo[$key];
|
|
|
|
|
|
- // $canvas_data[$key]['ad'] = array_combine($ad, $canvas_adinfo[$key]);
|
|
|
+ // // $canvas_data[$key]['ad'] = array_combine($ad, $canvas_adinfo[$key]);
|
|
|
|
|
|
- // // $Component['componentData'] = [];
|
|
|
- }
|
|
|
- // // var_dump('---------------------------',$components[$selectedComponentId]);
|
|
|
- $sector_component[$componet_key] = $Component;
|
|
|
- $componet_key++;
|
|
|
- }
|
|
|
- // var_dump("image",$image);
|
|
|
- }
|
|
|
- $template_data[$key]['componentList'] = $sector_component;
|
|
|
- $canvas_data[$key]['content']['componentList'] = $sector_component;
|
|
|
- // $canvas_data[$key]['ad'] = $key;
|
|
|
- $canvas_data[$key]['dataSort'] = $key;
|
|
|
- $canvas_data[$key]['moved'] = false;
|
|
|
- // $page['template'][$key][$sector_key]['componentData'] = $result[$sectorId];
|
|
|
- }
|
|
|
- // return $canvas_data;
|
|
|
- return [
|
|
|
- 'template_data' => $template_data,
|
|
|
- 'canvas_data' => $canvas_data,
|
|
|
- ];
|
|
|
- }
|
|
|
+ // // // $Component['componentData'] = [];
|
|
|
+ // }
|
|
|
+ // // // var_dump('---------------------------',$components[$selectedComponentId]);
|
|
|
+ // $sector_component[$componet_key] = $Component;
|
|
|
+ // $componet_key++;
|
|
|
+ // }
|
|
|
+ // // var_dump("image",$image);
|
|
|
+ // }
|
|
|
+ // $template_data[$key]['componentList'] = $sector_component;
|
|
|
+ // $canvas_data[$key]['content']['componentList'] = $sector_component;
|
|
|
+ // // $canvas_data[$key]['ad'] = $key;
|
|
|
+ // $canvas_data[$key]['dataSort'] = $key;
|
|
|
+ // $canvas_data[$key]['moved'] = false;
|
|
|
+ // // $page['template'][$key][$sector_key]['componentData'] = $result[$sectorId];
|
|
|
+ // }
|
|
|
+ // // return $canvas_data;
|
|
|
+ // return [
|
|
|
+ // 'template_data' => $template_data,
|
|
|
+ // 'canvas_data' => $canvas_data,
|
|
|
+ // ];
|
|
|
+ // }
|
|
|
public function randomWeb($data,$rule)
|
|
|
{
|
|
|
$page = $data['page'];
|