|  | @@ -618,7 +618,6 @@ class Manage
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      #区域分润
 | 
	
		
			
				|  |  |      public function area_api(){
 | 
	
		
			
				|  |  | -        #零售店的采购金额*0.4
 | 
	
		
			
				|  |  |          $month = Dever::input('month', date('Y-m'));
 | 
	
		
			
				|  |  |          $start_time = $month .'-01 00:00:00';
 | 
	
		
			
				|  |  |          $where = array();
 | 
	
	
		
			
				|  | @@ -632,48 +631,6 @@ class Manage
 | 
	
		
			
				|  |  |          foreach($shop as $k=>$v){
 | 
	
		
			
				|  |  |              $data[$v['city']]=$v;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        // $shop_area = $this->ls($where);
 | 
	
		
			
				|  |  | -        // // Dever::db('mail/area_entry')->getAll($where);
 | 
	
		
			
				|  |  | -        // $res = array();
 | 
	
		
			
				|  |  | -        // if($shop_area){
 | 
	
		
			
				|  |  | -        //     foreach($shop_area as $k => $v){
 | 
	
		
			
				|  |  | -        //         if($v['area']){
 | 
	
		
			
				|  |  | -        //            $area = explode(',',$v['area']);
 | 
	
		
			
				|  |  | -        //            if($area && isset($area[0])){
 | 
	
		
			
				|  |  | -        //                 $res[$k]['province'] = $area[0];
 | 
	
		
			
				|  |  | -        //            }
 | 
	
		
			
				|  |  | -        //            if ($area && isset($area[1])){
 | 
	
		
			
				|  |  | -        //                 $res[$k]['city'] = $area[1];
 | 
	
		
			
				|  |  | -        //            }else{
 | 
	
		
			
				|  |  | -        //                 $res[$k]['city'] = 0;
 | 
	
		
			
				|  |  | -        //            }
 | 
	
		
			
				|  |  | -        //            if($area && isset($area[2])){
 | 
	
		
			
				|  |  | -        //                 $res[$k]['county'] = $area[2];
 | 
	
		
			
				|  |  | -        //            }else{
 | 
	
		
			
				|  |  | -        //                 $res[$k]['county'] = 0;
 | 
	
		
			
				|  |  | -        //            }
 | 
	
		
			
				|  |  | -        //            if($area && isset($area[3])){
 | 
	
		
			
				|  |  | -        //                  $res[$k]['town'] = $area[3];
 | 
	
		
			
				|  |  | -        //            }else{
 | 
	
		
			
				|  |  | -        //                 $res[$k]['town'] = 0;
 | 
	
		
			
				|  |  | -        //            }
 | 
	
		
			
				|  |  | -        //         }
 | 
	
		
			
				|  |  | -        //     }
 | 
	
		
			
				|  |  | -        // }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        // $data = array_values($data);
 | 
	
		
			
				|  |  | -        // $data = array_merge($data,$res);
 | 
	
		
			
				|  |  | -        // // print_R($data);die;
 | 
	
		
			
				|  |  | -        // $result=array_unique($data, SORT_REGULAR);
 | 
	
		
			
				|  |  | -        // $rest=array();
 | 
	
		
			
				|  |  | -        // foreach($data as $k=>$v){
 | 
	
		
			
				|  |  | -        //     $rest[$v['county']]=$v;
 | 
	
		
			
				|  |  | -        // }
 | 
	
		
			
				|  |  | -        // $data=array_values($rest);
 | 
	
		
			
				|  |  | -        // foreach ($data as $k => $v) {
 | 
	
		
			
				|  |  | -        //   $edition[] = $v['province'];
 | 
	
		
			
				|  |  | -        // }
 | 
	
		
			
				|  |  | -        // array_multisort($edition, SORT_ASC, $data);
 | 
	
		
			
				|  |  |          foreach($data as $k => $v){
 | 
	
		
			
				|  |  |              $w['month'] = $where['start'];
 | 
	
		
			
				|  |  |              #城市
 | 
	
	
		
			
				|  | @@ -711,23 +668,6 @@ class Manage
 | 
	
		
			
				|  |  |                  $data[$k]['citys']['l_price'] =$shop_area['price'] * 0.01;
 | 
	
		
			
				|  |  |                  $data[$k]['citys']['l_num'] = $shop_area['num'];
 | 
	
		
			
				|  |  |                  $data[$k]['citys']['price'] = $data[$k]['citys']['price'] + $data[$k]['citys']['l_price'];
 | 
	
		
			
				|  |  | -                // $entry = Dever::db('mail/area_entry')->getNewAll($where);
 | 
	
		
			
				|  |  | -                // print_R($entry);die;
 | 
	
		
			
				|  |  | -                // $entry = Dever::db('mail/area_entry')->getNum($where);
 | 
	
		
			
				|  |  | -                // if ($entry && $entry['num']){
 | 
	
		
			
				|  |  | -                //     $data[$k]['citys']['l_num'] = $entry['num'];
 | 
	
		
			
				|  |  | -                //     $data[$k]['citys']['num'] = $data[$k]['citys']['num'] + $data[$k]['citys']['l_num'];
 | 
	
		
			
				|  |  | -                // }else{
 | 
	
		
			
				|  |  | -                //     $data[$k]['citys']['l_num'] = 0;
 | 
	
		
			
				|  |  | -                // }
 | 
	
		
			
				|  |  | -                // $entry_price = Dever::db('mail/area_entry')->getPrice($where);
 | 
	
		
			
				|  |  | -                // if ($entry_price && $entry_price['cprice'] ){
 | 
	
		
			
				|  |  | -                //     $data[$k]['citys']['l_price'] =  $entry_price['cprice'] * 0.4;
 | 
	
		
			
				|  |  | -                //     $data[$k]['citys']['price'] = $data[$k]['citys']['price'] + $data[$k]['citys']['l_price'];
 | 
	
		
			
				|  |  | -                // }else{
 | 
	
		
			
				|  |  | -                //     $data[$k]['citys']['l_price'] = 0;
 | 
	
		
			
				|  |  | -                // }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |                  $w['mid'] = $data[$k]['citys']['mid'];
 | 
	
		
			
				|  |  |                  $w['area'] = $data[$k]['citys']['area'];
 | 
	
		
			
				|  |  |                  $w['price'] = $data[$k]['citys']['price'];
 | 
	
	
		
			
				|  | @@ -736,7 +676,7 @@ class Manage
 | 
	
		
			
				|  |  |                  $w['t_num'] = $data[$k]['citys']['t_num'];
 | 
	
		
			
				|  |  |                  $w['t_price'] = $data[$k]['citys']['t_price']['total'];
 | 
	
		
			
				|  |  |                  $w['l_num'] = $data[$k]['citys']['l_num'];
 | 
	
		
			
				|  |  | -                $w['l_price'] = $data[$k]['citys']['l_price'];
 | 
	
		
			
				|  |  | +                $w['l_price'] = $shop_area['price'];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['citys']['area']));
 | 
	
		
			
				|  |  |                  if(!$shop){
 | 
	
	
		
			
				|  | @@ -776,23 +716,9 @@ class Manage
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  #零售店
 | 
	
		
			
				|  |  |                  $shop_area = $this->ls($where);
 | 
	
		
			
				|  |  | -                $data[$k]['countys']['l_price'] =$shop_area['price'] * 0.03;
 | 
	
		
			
				|  |  | +                $data[$k]['countys']['l_price'] = $shop_area['price'] * 0.03;
 | 
	
		
			
				|  |  |                  $data[$k]['countys']['l_num'] = $shop_area['num'];
 | 
	
		
			
				|  |  |                  $data[$k]['countys']['price'] = $data[$k]['countys']['price'] + $data[$k]['countys']['l_price'];
 | 
	
		
			
				|  |  | -                // $entry = Dever::db('mail/area_entry')->getNum($where);
 | 
	
		
			
				|  |  | -                // if ($entry && $entry['num']){
 | 
	
		
			
				|  |  | -                //     $data[$k]['countys']['l_num'] = $entry['num'];
 | 
	
		
			
				|  |  | -                //     $data[$k]['countys']['num'] = $data[$k]['countys']['num'] + $data[$k]['countys']['l_num'];
 | 
	
		
			
				|  |  | -                // }else{
 | 
	
		
			
				|  |  | -                //     $data[$k]['countys']['l_num'] = 0;
 | 
	
		
			
				|  |  | -                // }
 | 
	
		
			
				|  |  | -                // $entry_price = Dever::db('mail/area_entry')->getPrice($where);
 | 
	
		
			
				|  |  | -                // if ($entry_price && $entry_price['cprice'] ){
 | 
	
		
			
				|  |  | -                //     $data[$k]['countys']['l_price'] =  $entry_price['cprice'] * 0.4;
 | 
	
		
			
				|  |  | -                //     $data[$k]['countys']['price'] = $data[$k]['countys']['price'] + $data[$k]['countys']['l_price'];
 | 
	
		
			
				|  |  | -                // }else{
 | 
	
		
			
				|  |  | -                //     $data[$k]['countys']['l_price'] = 0;
 | 
	
		
			
				|  |  | -                // }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  $w['mid'] = $data[$k]['countys']['mid'];
 | 
	
		
			
				|  |  |                  $w['area'] = $data[$k]['countys']['area'];
 | 
	
	
		
			
				|  | @@ -802,7 +728,7 @@ class Manage
 | 
	
		
			
				|  |  |                  $w['t_num'] = $data[$k]['countys']['t_num'];
 | 
	
		
			
				|  |  |                  $w['t_price'] = $data[$k]['countys']['t_price']['total'];
 | 
	
		
			
				|  |  |                  $w['l_num'] = $data[$k]['countys']['l_num'];
 | 
	
		
			
				|  |  | -                $w['l_price'] = $data[$k]['countys']['l_price'];
 | 
	
		
			
				|  |  | +                $w['l_price'] = $shop_area['price'];
 | 
	
		
			
				|  |  |                  $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['countys']['area']));
 | 
	
		
			
				|  |  |                  if(!$shop){
 | 
	
		
			
				|  |  |                      Dever::db('mail/area_stat')->insert($w);
 | 
	
	
		
			
				|  | @@ -844,20 +770,6 @@ class Manage
 | 
	
		
			
				|  |  |                  $data[$k]['towns']['l_price'] =$shop_area['price'] * 0.05;
 | 
	
		
			
				|  |  |                  $data[$k]['towns']['l_num'] = $shop_area['num'];
 | 
	
		
			
				|  |  |                  $data[$k]['towns']['price'] = $data[$k]['towns']['price'] + $data[$k]['towns']['l_price'];
 | 
	
		
			
				|  |  | -                // $entry = Dever::db('mail/area_entry')->getNum($where);
 | 
	
		
			
				|  |  | -                // if ($entry && $entry['num']){
 | 
	
		
			
				|  |  | -                //     $data[$k]['towns']['l_num'] = $entry['num'];
 | 
	
		
			
				|  |  | -                //     $data[$k]['towns']['num'] = $data[$k]['towns']['num'] + $data[$k]['towns']['l_num'];
 | 
	
		
			
				|  |  | -                // }else{
 | 
	
		
			
				|  |  | -                //     $data[$k]['towns']['l_num'] = 0;
 | 
	
		
			
				|  |  | -                // }
 | 
	
		
			
				|  |  | -                // $entry_price = Dever::db('mail/area_entry')->getPrice($where);
 | 
	
		
			
				|  |  | -                // if ($entry_price && $entry_price['cprice'] ){
 | 
	
		
			
				|  |  | -                //     $data[$k]['towns']['l_price'] =  $entry_price['cprice'] * 0.4;
 | 
	
		
			
				|  |  | -                //     $data[$k]['towns']['price'] = $data[$k]['towns']['price'] + $data[$k]['towns']['l_price'];
 | 
	
		
			
				|  |  | -                // }else{
 | 
	
		
			
				|  |  | -                //     $data[$k]['towns']['l_price'] = 0;
 | 
	
		
			
				|  |  | -                // }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  $w['mid'] = $data[$k]['towns']['mid'];
 | 
	
		
			
				|  |  |                  $w['area'] = $data[$k]['towns']['area'];
 | 
	
	
		
			
				|  | @@ -867,7 +779,7 @@ class Manage
 | 
	
		
			
				|  |  |                  $w['t_num'] = $data[$k]['towns']['t_num'];
 | 
	
		
			
				|  |  |                  $w['t_price'] = $data[$k]['towns']['t_price']['total'];
 | 
	
		
			
				|  |  |                  $w['l_num'] = $data[$k]['towns']['l_num'];
 | 
	
		
			
				|  |  | -                $w['l_price'] = $data[$k]['towns']['l_price'];
 | 
	
		
			
				|  |  | +                $w['l_price'] = $shop_area['price'];
 | 
	
		
			
				|  |  |                  $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['towns']['area']));
 | 
	
		
			
				|  |  |                  if(!$shop){
 | 
	
		
			
				|  |  |                      Dever::db('mail/area_stat')->insert($w);
 |