| 
					
				 | 
			
			
				@@ -1657,4 +1657,112 @@ class Order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return $area;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    #软件服务费导出
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function out_softorder_api(){
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $status = Dever::input('search_option_status');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $start = Dever::input('search_option_start_cdate');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $end = Dever::input('search_option_end_cdate');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $fstart = Dever::input('search_option_start_fdate');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $fend = Dever::input('search_option_end_fdate');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $where = array();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $where['state'] = 1;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if($start){
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $where['start'] = strtotime($start);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if($end){
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $where['end'] = strtotime($end);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if($fstart){
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $where['fstart'] = strtotime($fstart);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if($fend){
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $where['fend'] = strtotime($fend);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!$fstart || !$fend){
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Dever::alert('请选择时间');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $where['status'] = $status;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $header = array('合同乙方', '手机号码', '合同总期数(年)', '合同类型', '签订日期', '合同金额', '购买日期', '录入日期', '终审日期');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $data = Dever::db('agent/order')->getExcelAll($where);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $body = array();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        foreach($data as $k => $v){
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if($v['soft_cash'] && $v['soft_cash']>0){
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $role = Dever::db('setting/role')->find($v['role']);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $type = 2;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # 这里加判断
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if ($role['type'] == 2 && $role['area'] == 1) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $type = 1;   
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } elseif ($v['soft_cash'] > 6000 && $v['soft_cash'] <= 30000 && $v['soft_cash']%5000 == 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $type = 3;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } elseif ($v['soft_cash'] <= 6000 && $v['soft_cash']%1000 == 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $type = 4;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $type = 2;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # 城市代理
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if ($type == 1) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $name = '城市代理版';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $year = 1;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # 定制版
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                elseif ($type == 2) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $name = '定制版';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $year = 1;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # 升级版
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                elseif ($type == 3) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $name = '升级版';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $year = intval($v['soft_cash']/5000);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if ($year > 6) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        $year = 6;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # 基础版
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                else {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $name = '基础版';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $year = intval($v['soft_cash']/1000);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if ($year > 6) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        $year = 6;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if($v['cdate']){
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $cdate = date('Y-m-d H:i',$v['cdate']);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                     $cdate = '-';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $order_process = Dever::db('agent/order_process')->one(array('status'=>1,'order_id'=>$v['id'],'state'=>1));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if($order_process && $order_process['cdate']){
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $chu_cdate = date('Y-m-d H:i',$order_process['cdate']);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                     $chu_cdate = '-';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $order_process = Dever::db('agent/order_process')->one(array('status'=>2,'order_id'=>$v['id'],'state'=>1));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if($order_process && $order_process['cdate']){
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $zcdate = date('Y-m-d H:i',$order_process['cdate']);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $zcdate = '-';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $d = array
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                (
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $v['name'],
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $v['mobile'],
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $year,
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $zcdate,
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $v['soft_cash'],
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $cdate,
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $cdate,
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $zcdate,
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                );
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               $body[] = $d;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $file = '代理商软件服务费';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Dever::excelExport($body, $header, $file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |