第一

请求第三方接口的工具类

例如,封装了get和post请求方法的工具类,代码如下:

<?php

class HttpClient{

    /**
     * HttpClient
     * @param array $headers HTTP header
     */
    public function __construct($headers=array()){
        $this->headers = $this->buildHeaders($headers);
        $this->connectTimeout = 60000;
        $this->socketTimeout = 60000;
        $this->conf = array();
    }

    /**
     * 连接超时
     * @param int $ms 毫秒
     */
    public function setConnectionTimeoutInMillis($ms){
        $this->connectTimeout = $ms;
    }

    /**
     * 响应超时
     * @param int $ms 毫秒
     */
    public function setSocketTimeoutInMillis($ms){
        $this->socketTimeout = $ms;
    }    

    /**
     * 配置
     * @param array $conf
     */
    public function setConf($conf){
        $this->conf = $conf;
    }

    /**
     * 请求预处理
     * @param resource $ch
     */
    public function prepare($ch){
        foreach($this->conf as $key => $value){
            curl_setopt($ch, $key, $value);
        }
    }    

    /**
     * @param  string $url
     * @param  array $data HTTP POST BODY
     * @param  array $param HTTP URL
     * @param  array $headers HTTP header
     * @return array
     */
    public function post($url, $data=array(), $params=array(), $headers=array()){
        $url = $this->buildUrl($url, $params);
        $headers = array_merge($this->headers, $this->buildHeaders($headers));

        $ch = curl_init();
        $this->prepare($ch);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POSTFIELDS, is_array($data) ? http_build_query($data) : $data);
        curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->socketTimeout);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->connectTimeout);
        $content = curl_exec($ch);
        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        if($code === 0){
            throw new Exception(curl_error($ch));
        }

        curl_close($ch);
        return array(
            'code' => $code,
            'content' => $content,
        );
    }

    /**
     * @param  string $url
     * @param  array $datas HTTP POST BODY
     * @param  array $param HTTP URL
     * @param  array $headers HTTP header
     * @return array
     */
    public function multi_post($url, $datas=array(), $params=array(), $headers=array()){
        $url = $this->buildUrl($url, $params);
        $headers = array_merge($this->headers, $this->buildHeaders($headers));

        $chs = array();
        $result = array();
        $mh = curl_multi_init();
        foreach($datas as $data){
            $ch = curl_init();
            $chs[] = $ch;
            $this->prepare($ch);
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_HEADER, false);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($ch, CURLOPT_POSTFIELDS, is_array($data) ? http_build_query($data) : $data);
            curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->socketTimeout);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->connectTimeout);
            curl_multi_add_handle($mh, $ch);
        }

        $running = null;
        do{
            curl_multi_exec($mh, $running);
            usleep(100);
        }while($running);

        foreach($chs as $ch){
            $content = curl_multi_getcontent($ch);
            $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            $result[] = array(
                'code' => $code,
                'content' => $content,
            );
            curl_multi_remove_handle($mh, $ch);
        }
        curl_multi_close($mh);

        return $result;
    }

    /**
     * @param  string $url
     * @param  array $param HTTP URL
     * @param  array $headers HTTP header
     * @return array
     */
    public function get($url, $params=array(), $headers=array()){
        $url = $this->buildUrl($url, $params);
        $headers = array_merge($this->headers, $this->buildHeaders($headers));

        $ch = curl_init();
        $this->prepare($ch);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->socketTimeout);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->connectTimeout);
        $content = curl_exec($ch);
        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        if($code === 0){
            throw new Exception(curl_error($ch));
        }

        curl_close($ch);
        return array(
            'code' => $code,
            'content' => $content,
        );
    }

    /**
     * 构造 header
     * @param  array $headers
     * @return array
     */
    private function buildHeaders($headers){
        $result = array();
        foreach($headers as $k => $v){
            $result[] = sprintf('%s:%s', $k, $v);
        }
        return $result;
    }

    /**
     *
     * @param  string $url
     * @param  array $params 参数
     * @return string
     */
    private function buildUrl($url, $params){
        if(!empty($params)){
            $str = http_build_query($params);
            return $url . (strpos($url, '?') === false ? '?' : '&') . $str;
        }else{
            return $url;
        }
    }
}

  

第二

数组求和工具类(根据列求出二维数组的该列的和)

<?php

namespace core\components;

use yii\base\Exception;

class ArrayHelper extends \yii\helpers\ArrayHelper{

    public static function sumByColumn($data_arr, $column){
        if (!is_array($data_arr)){
            throw new Exception('传入参数1不是数组');
        }
        if (empty($data_arr)){
            return 0;
        }
        if (!in_array($column, array_keys($data_arr[0]))){
            throw new Exception('传入参数2不是数组的键');
        }

        $sum = 0;
        foreach ($data_arr as $data_row){
            $add_num = $data_row[$column];
            $sum += $add_num;
        }
        return $sum;
    }

    /**
     * 二维数组的唯一化
     * @param $array
     * @param $key
     * @return array
     */
    public static function uniqueMultidimArray($array, $key){
         $temp_array = array();
         $i = 0;
         $key_array = array();

         foreach($array as $val){
             if(!in_array($val[$key],$key_array)){
                 $key_array[$i] = $val[$key];
                 $temp_array[$i] = $val;
             }
            $i++;
        }
        return $temp_array;
    }

    public static function filterMultidimArray($array, $key){
        $temp_array = array();
         $i = 0;
         $key_array = array();

         foreach($array as $val){
             if(!empty($val[$key])){
                 $temp_array[$i] = $val;
             }
            $i++;
        }
        return $temp_array;
    }

}

  

第三

php-excel相关的关于导出excel及上传excel数据到数据库的工具类

<?php

namespace core\components;

use PHPExcel;
use PHPExcel_IOFactory;
use PHPExcel_Style_Alignment;
use PHPExcel_Reader_Excel5;
use PHPExcel_RichText;

class MyExcelHelper extends \yii\base\Component{

    /**
     * 将二维数组的数据转化为excel表格导出
     * @param $data
     * @param $excel_name
     * @param $headers
     * @param $options
     */
    public static function array2excel($data, $excel_name, $headers, $options, $style_options){
        $objPHPExcel = new PHPExcel();
        ob_start();

        if (!isset($options['creator'])){
            $objPHPExcel->getProperties()->setCreator('creator');
        }else{
            $objPHPExcel->getProperties()->setCreator($options['creator']);
        }

        if (isset($options['last_modified_by'])){
            $objPHPExcel->getProperties()->setCreator('last_modified_by');
        }else{
            $objPHPExcel->getProperties()->setCreator($options['last_modified_by']);
        }

        if (isset($options['title'])){
            $objPHPExcel->getProperties()->setCreator('title');
        }else{
            $objPHPExcel->getProperties()->setCreator($options['title']);
        }

        if (isset($options['subject'])){
            $objPHPExcel->getProperties()->setCreator('subject');
        }else{
            $objPHPExcel->getProperties()->setCreator($options['subject']);
        }

        if (isset($options['description'])){
            $objPHPExcel->getProperties()->setCreator('description');
        }else{
            $objPHPExcel->getProperties()->setCreator($options['description']);
        }

        if (isset($options['keywords'])){
            $objPHPExcel->getProperties()->setCreator('keywords');
        }else{
            $objPHPExcel->getProperties()->setCreator($options['keywords']);
        }

        if (isset($options['category'])){
            $objPHPExcel->getProperties()->setCreator('category');
        }else{
            $objPHPExcel->getProperties()->setCreator($options['category']);
        }

        $header_keys = array_keys($headers);

        foreach ($header_keys as $header_index => $header_key){
            $index_ascii = $header_index + 65;
            $index_chr = chr($index_ascii);
            $header_value = $headers[$header_key];
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue($index_chr.'1', $header_value);
            $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension($index_chr)->setWidth(20);
            $objPHPExcel->setActiveSheetIndex(0)->getStyle($index_chr.'1')->applyFromArray([
                'font'=>[
                    'bold' => true
                ],
                'alignment'=>[
                    'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER
                ]
            ]);
            if (isset($style_options['h_align'][$header_key])){
                if ($style_options['h_align'][$header_key] == 'left'){
                    $h_align = PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
                }elseif ($style_options['h_align'][$header_key] == 'center'){
                    $h_align = PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
                }elseif ($style_options['h_align'][$header_key] == 'right'){
                    $h_align = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
                }else{
                    $h_align = PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
                }
                $objPHPExcel->setActiveSheetIndex(0)->getStyle($index_chr)->applyFromArray([
                    'alignment'=>[
                        'horizontal' => $h_align
                    ]
                ]);
            }
        }

        $data_row_index = 2;
        foreach ($data as $row_index => $row){
            $data_keys = array_keys($row);
            foreach ($data_keys as $column_index => $data_key){
                if ($column_index>=26){
                    throw new \yii\base\Exception('EXCEL表格超过26列');
                }
                $index_ascii = $column_index + 65;
                $index_chr = chr($index_ascii);
                $value = $row[$data_key];
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue($index_chr . $data_row_index, $value);
            }
            $data_row_index++;
        }

        if (isset($options['summary'])){
            $summary_keys = array_keys($options['summary']);
            foreach ($summary_keys as $summary_index => $summary_key){
                $index_ascii = $summary_index + 65;
                $index_chr = chr($index_ascii);
                $summary_flag = $options['summary'][$summary_key];
                if ($summary_flag){
                    $summary_value = \core\components\ArrayHelper::sumByColumn($data, $summary_key);
                    $objPHPExcel->setActiveSheetIndex(0)->setCellValue($index_chr . $data_row_index, $summary_value);
                }
            }
        }

        $objPHPExcel->setActiveSheetIndex(0);

        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

        ob_end_clean();

        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment;filename="' . $excel_name . '.xls"');
        header('Cache-Control: max-age=0');

        $objWriter->save('php://output');
        exit;
    }

    /**
     * 将excel表格转化为二维数组的数据
     * @param $excel_path
     * @param $data
     * @param $header
     */
    public static function excel2array($excel_path, $header_keys){

        if(!file_exists($excel_path)){
            throw new \yii\base\Exception('该EXCEL不存在!');
        }
        $PHPReader = new \PHPExcel_Reader_Excel2007();
        if(!$PHPReader->canRead($excel_path)){
            $PHPReader = new PHPExcel_Reader_Excel5();
            if(!$PHPReader->canRead($excel_path)){
                throw new \yii\base\Exception('该EXCEL不可读');
            }
        }

        $PHPExcel = $PHPReader->load($excel_path);
        $currentSheet = $PHPExcel->getSheet(0);

        $max_column_index = $currentSheet->getHighestColumn();
        $max_row_index = $currentSheet->getHighestRow();

        $data = array();
        for($row_index=2; $row_index<=$max_row_index; $row_index++ ){
            for($column_chr='A'; $column_chr<=$max_column_index; $column_chr++){
                $column_ord = ord($column_chr);
                $column_index = $column_ord - 65;
                $key = $column_chr.$row_index;
                $value = $currentSheet->getCell($key)->getValue();
                if($value instanceof PHPExcel_RichText){
                    $value = $value->__toString();
                }

                $data[$row_index-1][$header_keys[$column_index]] = $value;
            }
        }
        return $data;
    }
}

  例如:执行命令将EXCEL的数据导入到数据库,代码如下:

<?php

namespace console\controllers;

use yii\console\Controller;
use Yii;

class SalesContractController extends Controller
{
    public function actionUploadExcel(){
        $excel_path = './console/excels/sales_contract.xlsx';
        $header_keys = ['sales_contract_code', 'sales_customers_name', 'sales_contract_sum_weight'];
        $data = \core\components\MyExcelHelper::excel2array($excel_path, $header_keys);
        if (!empty($data)){
            foreach ($data as $sales_contract){
                $salesContractModel = \core\models\SalesContract::find()->where([
                    'sales_contract_code'=>$sales_contract['sales_contract_code'],
                ])->one();
                if (!empty($salesContractModel)){
                    $salesContractModel->sales_contract_sum_weight = \common\models\Base::weightBcmul($sales_contract['sales_contract_sum_weight']);
                    if ($salesContractModel->save()){
                        echo PHP_EOL.'导入销售合同'.$sales_contract['sales_contract_code'].'更新数据成功!';
                    }
                }
            }
        }
    }
}

  

第四

二维数据的条件过滤

<?php

namespace core\models;

class WmsInAndOutFinanceDetailAdapter extends \core\models\WmsInAndOut{

    //这是按照条件过滤的函数
    public static function _filterZero($item_arr){
        if (empty($item_arr['begin_balance_weight'])
            && empty($item_arr['going_balance_weight_increase'])
            && empty($item_arr['going_balance_weight_decrease'])
            && empty($item_arr['going_balance_weight'])
            && empty($item_arr['end_balance_weight'])){
            return false;
        }else{
            return true;
        }
    }
    public static function getMaterialBeginList($common_producer_info_id, $common_producer_herb_info_id, $common_producer_grade_info_id, $wms_statistics_begin_at, $wms_statistics_end_at){
        $begin_material_in_list = \core\models\WmsInAndOut::getMaterialInList($common_producer_info_id, $common_producer_herb_info_id, $common_producer_grade_info_id, 0, $wms_statistics_begin_at);
        foreach ($begin_material_in_list as &$begin_material_in){
            $begin_material_in['detail_type'] = \backend\models\FinanceDetailSearch::DETAIL_TYPE_MATERIAL;
            if ($begin_material_in['in_sheet_type'] == '二次加工'){
                $begin_material_in['detail_type_option'] = \core\models\FinanceDetail::DETAIL_TYPE_MATERIAL_IN_TWO;
            }elseif ($begin_material_in['in_sheet_type'] == '采购入库'){
                $begin_material_in['detail_type_option'] = \core\models\FinanceDetail::DETAIL_TYPE_MATERIAL_IN_PURCHASE;
            }else{
                $begin_material_in['detail_type_option'] = \core\models\FinanceDetail::DETAIL_TYPE_MATERIAL_IN_PURCHASE;
            }

            $unit_price = $begin_material_in['unit_price'];
            $weight = $begin_material_in['weight'];
            $sum_price = $begin_material_in['sum_price'];

            $begin_material_in['begin_balance_unit_price'] = $unit_price;
            $begin_material_in['begin_balance_weight'] = $weight;
            $begin_material_in['begin_balance_sum_price'] = $sum_price;

            $begin_material_in['going_balance_unit_price'] = $unit_price;
            $begin_material_in['going_balance_weight_increase'] = 0;
            $begin_material_in['going_balance_weight_decrease'] = 0;
            $begin_material_in['going_balance_weight'] = 0;
            $begin_material_in['going_balance_sum_price_increase'] = 0;
            $begin_material_in['going_balance_sum_price_decrease'] = 0;
            $begin_material_in['going_balance_sum_price'] = 0;

            $begin_material_in['end_balance_unit_price'] = $unit_price;
            $begin_material_in['end_balance_weight'] = $weight;
            $begin_material_in['end_balance_sum_price'] = $sum_price;
        }

        $begin_material_out_list = \core\models\WmsInAndOut::getMaterialOutList($common_producer_info_id, $common_producer_herb_info_id, $common_producer_grade_info_id, 0, $wms_statistics_begin_at);
        foreach ($begin_material_out_list as &$begin_material_out){
            $begin_material_out['detail_type'] = \backend\models\FinanceDetailSearch::DETAIL_TYPE_MATERIAL;
            if ($begin_material_out['out_sheet_type'] == '0'){
                $begin_material_out['detail_type_option'] = \core\models\FinanceDetail::DETAIL_TYPE_MATERIAL_OUT_PRODUCE;
            }elseif($begin_material_out['out_sheet_type'] == '取样'){
                $begin_material_out['detail_type_option'] = \core\models\FinanceDetail::DETAIL_TYPE_MATERIAL_OUT_SAMPLE;
            }else{
                $begin_material_out['detail_type_option'] = \core\models\FinanceDetail::DETAIL_TYPE_MATERIAL_OUT_PRODUCE;
            }

            $unit_price = $begin_material_out['unit_price'];
            $weight = $begin_material_out['weight'];
            $sum_price = $begin_material_out['sum_price'];

            $begin_material_out['begin_balance_unit_price'] = $unit_price;
            $begin_material_out['begin_balance_weight'] = 0 - $weight;
            $begin_material_out['begin_balance_sum_price'] = 0 - $sum_price;

            $begin_material_out['going_balance_unit_price'] = $unit_price;
            $begin_material_out['going_balance_weight_increase'] = 0;
            $begin_material_out['going_balance_weight_decrease'] = 0;
            $begin_material_out['going_balance_weight'] = 0;
            $begin_material_out['going_balance_sum_price_increase'] = 0;
            $begin_material_out['going_balance_sum_price_decrease'] = 0;
            $begin_material_out['going_balance_sum_price'] = 0;

            $begin_material_out['end_balance_unit_price'] = $unit_price;
            $begin_material_out['end_balance_weight'] = 0 - $weight;
            $begin_material_out['end_balance_sum_price'] = 0 - $sum_price;
        }
        $detail_list = array_merge($begin_material_in_list, $begin_material_out_list);

        //这里调用过滤函数,实现过滤。
        $detail_list = array_filter($detail_list, array(\core\models\WmsInAndOutFinanceDetailAdapter::class, '_filterZero'));
        return $detail_list;
    }
}

  

第五

无限极分类

<?php
namespace core\components;

/**
 * 无限极分类-二维无限分类数组处理类
 **/

class Category extends \yii\base\Component
{
    //无限分类数组,其中必须要有id和pid
    public static $list = [];
    //id => pid 数组
    private static $_sp_list = [];
    //子分类key
    private static $_sk;
    //父分类key
    private static $_pk;

    /**
     *对数组进行初始化处理
     * $cat_list 无限分类数组
     * $skey 数组中子分类的key值
     * $pkey 数组中父分类的key值
     * @return mixed array
     **/
    public function __construct($cat_list, $skey = 'id', $pkey = 'pid')
    {
        parent::init();
        self::$_sk = $skey;
        self::$_pk = $pkey;
        $this->init($cat_list);
    }

    /**
     *对数组进行初始化处理
     * @return mixed array
     **/
    public function init($cat_list)
    {
        if (empty($cat_list))
        {
            return false;
        }
        //对数组进行预处理
        foreach ($cat_list as $key => $val)
        {
            //生成sid => pid 数组
            self::$_sp_list[$val[self::$_sk]] = $val[self::$_pk];
            //以数组的子分类值作为索引
            self::$list[$val[self::$_sk]] = $val;
        }
        unset($cat_list);
    }

    /**
     * 获取格式化的树形数据
     * @param $pid int $list中顶级分类id
     * @param $level int $list中顶级分类的层级
     * @param $html string 上下层级之间的标示符号
     * @return mixed
     **/
    public static function sort($pid = 0, $level = 0, $html = '-')
    {
        if (empty(self::$list))
        {
            return false;
        }
        static $tree = array();
        foreach (self::$list as $v)
        {
            if ($v[self::$_pk] == $pid)
            {
                $v['sort'] = $level + 1;
                $v['html'] = str_repeat($html, $level);
                $tree[$v[self::$_sk]] = $v;
                self::sort($v[self::$_sk], $level + 1);
            }
        }
        return $tree;
    }

    /**
     * 获取分类的无限极子分类,以树型结构显示
     * @param $son string 子节点节点名
     * @return mixed
     **/
    public static function tree($son = 'son')
    {
        if (empty(self::$list))
        {
            return false;
        }
        $list = self::$list;
        foreach ($list as $item)
        {
            $list[$item[self::$_pk]][$son][$item[self::$_sk]] = &$list[$item[self::$_sk]];
        }
        return isset($list[0][$son]) ? $list[0][$son] : array();
    }

    /**
     * 获取分类的祖先分类
     * @param $id int 分类id
     * @param $type bool true-返回祖先分类数组 false-返回祖先分类id
     * @return mixed
     **/
    public static function ancestor($id, $type = true)
    {
        if (empty(self::$list) || empty(self::$_sp_list))
        {
            return false;
        }
        while (self::$_sp_list[$id])
        {
            $id = self::$_sp_list[$id];
        }
        return $type && isset(self::$list[$id]) ? self::$list[$id] : $id;
    }

    /**
     * 获取所有父级分类对应层级关系
     * @param $id int 分类id
     * @param $type bool true-返回分类数组 false-返回分类id
     * @return mixed
     **/
    public static function parents($id, $type = true)
    {
        if (empty(self::$list))
        {
            return false;
        }
        $info = [];
        while (isset(self::$_sp_list[$id]))
        {
            $info[] = $type ? self::$list[$id] : $id;
            $id = self::$_sp_list[$id];
        }
        return $info;
    }

    /**
     * 获取所有子级分类对应层级关系
     * @param $id int 子分类id
     * @param $type bool true-返回分类数组 false-返回分类id
     * @return mixed
     **/
    public static function sons($id, $type = true)
    {
        if (empty(self::$list))
        {
            return false;
        }
        static $info = [];
        foreach (self::$list as $val)
        {
            if ($val[self::$_pk] == $id)
            {
                $info[$val[self::$_sk]] = $type ? $val : $val[self::$_sk];
                if (self::has_son($val[self::$_sk]))
                {
                    self::sons($val[self::$_sk], $type);
                }
            }
        }
        return $info;
    }

    /**
     * 获取所有儿子分类
     * @param $p_id int 父id
     * @param $type bool true-返回分类数组 false-返回分类id
     * @return mixed
     **/
    public static function son($p_id = 0, $type = true)
    {
        if (empty(self::$list))
        {
            return false;
        }
        $_arr = [];
        foreach (self::$list as $val)
        {
            if ($val[self::$_pk] == $p_id)
            {
                $_arr[$val[self::$_sk]] = $type ? $val : $val[self::$_sk];
            }
        }
        return $_arr;
    }

    /**
     * 是否含有子分类,是否是叶子节点
     * @param $pid int 父分类id
     * @return mixed
     **/
    public static function has_son($pid)
    {
        if (empty(self::$list) || empty(self::$_sp_list))
        {
            return false;
        }
        return in_array($pid, array_values(self::$_sp_list));
    }
}

 调用方法如下:

$cat = new \core\components\Category($list);

        $tree = $cat::tree();

  案例如下:

Array
(
    [0] => Array
        (
            [id] => XSHT-170912-00006
            [sum_price] => 64125.00
            [send_out_status] =>
            [repay_status] =>
            [pid] => 0
        )

    [1] => Array
        (
            [id] => XSDD-170912-00005
            [sum_price] => 64125.00
            [send_out_status] =>
            [repay_status] =>
            [pid] => XSHT-170912-00006
        )

    [2] => Array
        (
            [id] => XSHT-170912-00007
            [sum_price] => 64125.00
            [send_out_status] =>
            [repay_status] =>
            [pid] => 0
        )

    [3] => Array
        (
            [id] => XSHT-170927-00012
            [sum_price] => 17280.00
            [send_out_status] =>
            [repay_status] =>
            [pid] => 0
        )

    [4] => Array
        (
            [id] => XSDD-170927-00009
            [sum_price] => 17280.00
            [send_out_status] =>
            [repay_status] =>
            [pid] => XSHT-170927-00012
        )

    [5] => Array
        (
            [id] => XSHT-171013-00016
            [sum_price] => 61500.00
            [send_out_status] =>
            [repay_status] =>
            [pid] => 0
        )

    [6] => Array
        (
            [id] => XSDD-171013-00016
            [sum_price] => 61500.00
            [send_out_status] =>
            [repay_status] =>
            [pid] => XSHT-171013-00016
        )

)调用无极限分裂后$tree为:
Array
(
    [XSHT-170912-00006] => Array
        (
            [id] => XSHT-170912-00006
            [sum_price] => 64125.00
            [send_out_status] =>
            [repay_status] =>
            [pid] => 0
            [son] => Array
                (
                    [XSDD-170912-00005] => Array
                        (
                            [id] => XSDD-170912-00005
                            [sum_price] => 64125.00
                            [send_out_status] =>
                            [repay_status] =>
                            [pid] => XSHT-170912-00006
                        )

                )

        )

    [XSHT-170912-00007] => Array
        (
            [id] => XSHT-170912-00007
            [sum_price] => 64125.00
            [send_out_status] =>
            [repay_status] =>
            [pid] => 0
        )

    [XSHT-170927-00012] => Array
        (
            [id] => XSHT-170927-00012
            [sum_price] => 17280.00
            [send_out_status] =>
            [repay_status] =>
            [pid] => 0
            [son] => Array
                (
                    [XSDD-170927-00009] => Array
                        (
                            [id] => XSDD-170927-00009
                            [sum_price] => 17280.00
                            [send_out_status] =>
                            [repay_status] =>
                            [pid] => XSHT-170927-00012
                        )

                )

        )

    [XSHT-171013-00016] => Array
        (
            [id] => XSHT-171013-00016
            [sum_price] => 61500.00
            [send_out_status] =>
            [repay_status] =>
            [pid] => 0
            [son] => Array
                (
                    [XSDD-171013-00016] => Array
                        (
                            [id] => XSDD-171013-00016
                            [sum_price] => 61500.00
                            [send_out_status] =>
                            [repay_status] =>
                            [pid] => XSHT-171013-00016
                        )

                )

        )

)
												

PHP常用工具类积累的更多相关文章

  1. js常用工具类.

    一些js的工具类 复制代码 /** * Created by sevennight on 15-1-31. * js常用工具类 */ /** * 方法作用:[格式化时间] * 使用方法 * 示例: * ...

  2. IOS开发--常用工具类收集整理(Objective-C)(持续更新)

    前言:整理和收集了IOS项目开发常用的工具类,最后也给出了源码下载链接. 这些可复用的工具,一定会给你实际项目开发工作锦上添花,会给你带来大大的工作效率. 重复造轮子的事情,除却自我多练习编码之外,就 ...

  3. Apache Commons 常用工具类整理

    其实一直都在使用常用工具类,只是从没去整理过,今天空了把一些常用的整理一下吧 怎么使用的一看就明白,另外还有注释,最后的使用pom引入的jar包 public class ApacheCommonsT ...

  4. Android 常用工具类之SPUtil,可以修改默认sp文件的路径

    参考: 1. 利用Java反射机制改变SharedPreferences存储路径    Singleton1900 2. Android快速开发系列 10个常用工具类 Hongyang import ...

  5. 封装一个简单好用的打印Log的工具类And快速开发系列 10个常用工具类

    快速开发系列 10个常用工具类 http://blog.csdn.net/lmj623565791/article/details/38965311 ------------------------- ...

  6. javaweb常用工具类及配置文件备份

    Javaweb常用工具类及配置文件备份   做一个代码备份,以后常用到的. hibernate工具类备份 package com.dly.service; /*  * hibernate获取sessi ...

  7. [C#] 常用工具类——直接在浏览器输出数据

    /// <summary> /// <para> </para> /// 常用工具类——直接在浏览器输出数据 /// <para> ---------- ...

  8. [C#] 常用工具类——加密解密类

    using System; using System.Configuration; using System.Collections.Generic; using System.Text; using ...

  9. C#常用工具类——Excel操作类

    /// 常用工具类——Excel操作类 /// <para> ------------------------------------------------</para> / ...

随机推荐

  1. Emoji表情符号在MySQL数据库中的存储

    文章转自https://www.jianshu.com/p/20740071d854 在Android手机或者iPhone的各种输入法键盘中,会自带一些Emoji表情符号,如IPhone手机系统键盘包 ...

  2. mybatis基础系列(四)——关联查询、延迟加载、一级缓存与二级缓存

    关本文是Mybatis基础系列的第四篇文章,点击下面链接可以查看前面的文章: mybatis基础系列(三)——动态sql mybatis基础系列(二)——基础语法.别名.输入映射.输出映射 mybat ...

  3. 在CentOS7服务器端启动jupyter notebook服务,在windows端使用jupyter notebook,服务器充当后台计算云端

    在CentOS7服务器端启动jupyter notebook服务,在windows端使用jupyter notebook,服务器充当后台计算云端 在服务器端启动jupyter notebook服务,在 ...

  4. 分布式计算(三)Azkaban介绍

    转载自:Azkaban学习之路 (一)Azkaban的基础介绍 目录 一.为什么需要工作流调度器 二.工作流调度实现方式 三.常见工作流调度系统 四.各种调度工具对比 五.Azkaban 与 Oozi ...

  5. ASP.NET ActiveMQ 消息队列

    1.引入 2.发送消息 3.接收消息 概述:MQ消息存放在内存,重启后,消息丢失.接收后,消息丢失(只取一次),不取,一直在且速度快. 使用前:下载apache-activemq-5.15.2-bin ...

  6. Ubuntu 上安装QTAV第三方视频库

    安装QtAV的基本环境: sudo apt-get install build-essential sudo apt-get install libgl1-mesa-dev sudo apt-get ...

  7. [01] Collection和Map

    0.写在前面的话 集合是Java的API中非常重要的概念,用来存储多个数据,并实现了不同的数据结构. Java集合框架中常见的有三大接口: Collection Map Iterator   1.Co ...

  8. 介绍一个axios调试好用的工具:axios-mock-adapter

    上一篇文章中写到用promise时应注意的问题,这一篇文章继续介绍一个可以和axios库配合的好工具: axios-mock-adapter.axios-mock-adapter可以用来拦截http请 ...

  9. select 下拉选中

    <body> <select name="" id=""> <option value="">张三< ...

  10. Luogu P1514 引水入城

    我承认我有点懒(洛谷已经发过题解了,但我发誓要坚持写博客) 这道题坑了我3天…… 首先一看就与染色问题类似,果断BFS(写DFS炸了) 先将最上面(靠近水)的一行全部扔进队列里,做一遍BFS 再对最下 ...