Document
首页 企业大事记

企业大事记

江小白 2019-03-12 0 62
    /**
     * 企业大事记
     * @authors Jhg
     * @date    2019-02-13 11:36:21
     * @return  array
     */
    public function companyMemorabilia(){
    $condition['ac_id'] = self::GROUP_COMPANY_MEMORABILIA;
        $condition['article_show'] = 1;
        $field = 'article_year,article_month,article_content';
        $company_Memorabilia = $this->groupArticle->getCompanyMemorabilia($condition,$field);
        $data = array();
        $column_Company_Memorabilia = array_column($company_Memorabilia,'article_year');
        //年份集合
        $only = array_flip(array_flip($column_Company_Memorabilia));
        $only = array_values($only);
        foreach($company_Memorabilia as $key=>$val){
            $val['sort'] = intval($val['article_year']).'-'.intval($val['article_month']);
            $val['sort'] = strtotime($val['sort']);
            foreach ($only as $k => $v) {
                if($val['article_year'] == $v){
                    $data[$k]['year'] = $v;
                    $data[$k]['yearEvent'][] = $val;
                    $data[$k]['year_sort'] = strtotime(intval($val['article_year'])); 
                    rsort($data[$k]['yearEvent']);
                }
            }
        }

$data_Only = array_column($data, 'year_sort');
        array_multisort($data_Only,SORT_DESC,$data);

        $onlys = [];
        foreach($data as $key=>$value){
            $column_val = array_column($value['yearEvent'],'article_month');
            $onlys = array_flip(array_flip($column_val));
            foreach( $value['yearEvent'] as $k=>$val){
                foreach($onlys as $s =>&$v){
                    if($val['article_month'] == $v){
                        $value['yearEvent'][$k]['month'] = $v;
                        $value['yearEvent'][$k]['monthEvent'][] = $val;
                        $data[$key]['yearEvent'][$k]['month'] = $v;
                        $data[$key]['yearEvent'][$k]['monthEvent'][] = $val;
                    }
                }
                unset($data[$key]['yearEvent'][$k]['article_year']);
                unset($data[$key]['yearEvent'][$k]['article_month']);
                unset($data[$key]['yearEvent'][$k]['article_content']);
            }
        }


        $data = array_values($data);
        foreach ($data as $k2 => $v2) {
            $b = $e = [];
            foreach ($v2['yearEvent'] as $k => $v) {
                $b[$v['month']][] = $v['monthEvent'][0]['article_content'];
            }
            foreach ($b as $key => $value) {
                $datas['month'] = $key;
                $datas['monthEvent']['article_year'] = $v2['year'];
                $datas['monthEvent']['article_month'] = $key;
                $datas['monthEvent']['article_content'] = $value;
                $e[] = $datas;
            }
            $f['year'] = $v2['year'];
            $f['yearEvent'] = $e;
            $company_Memorabilia_Con[] = $f;
        }


        $result = array("code"=>'200',"datas"=>$company_Memorabilia_Con);
      
        $json = json_encode($result);
        echo $json;
    }
打赏作者
打赏作者 打赏作者
免责声明:本文仅代表作者个人观点,与本网站无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
作者: 2019-03-12 11:41:01

发表评论

看不清?点击更换

评论列表: