Your Name 2 năm trước cách đây
mục cha
commit
444c7bfcb8
2 tập tin đã thay đổi với 144 bổ sung0 xóa
  1. 27 0
      service/agent/database/soft_cash.php
  2. 117 0
      service/agent/lib/Soft_cash.php

+ 27 - 0
service/agent/database/soft_cash.php

@@ -27,6 +27,13 @@ $col = Dever::input('col');
 if (Dever::load('manage/auth')->checkFunc('agent.soft_cash', 'editnew', '新增')) {
 	$insert = true;
 }
+$button = array();
+if(Dever::load('manage/auth')->checkFunc('agent.soft_cash', 'editSoftcash', '数据导出')){
+        $button = array
+        (
+            '数据导出' => array('excel', 'agent/lib/soft_cash.out_soft_cash'),
+        );
+    }
 return array
 (
     # 表名
@@ -288,6 +295,7 @@ return array
     	'insert' => $insert,
     	'delete' => false,
     	'edit'   => false,
+        'button' => $button,
     	'list_button' => array
         (
         	 'list' => array('查看详情', '"member_prize&project=agent&id={id}&page_type=1&[refer]"'),
@@ -324,5 +332,24 @@ return array
             'col' => 'sum(cash) as total',
         ),
 
+        'getExcelAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'fstart' => array('yes-zdate', '>='),
+                'fend' => array('yes-zdate', '<='),
+                'bstart' => array('yes-buy_date', '>='),
+                'bend' => array('yes-buy_date', '<='),
+                'start' => array('yes-fdate', '>='),
+                'end' => array('yes-fdate', '<='),
+                'status' => array('yes', 'in'),
+                'type' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*',
+        ),
+
     ),
 );

+ 117 - 0
service/agent/lib/Soft_cash.php

@@ -363,4 +363,121 @@ Class Soft_cash
         $html .= '<br />' . $data['fdate'];
         return $html; 
     }
+
+    #数据导出
+    public function out_soft_cash_api(){
+        $type = Dever::input('search_option_type');
+        $status = Dever::input('search_option_status');
+        $start = Dever::input('search_option_start_zdate');
+        $end = Dever::input('search_option_end_zdate');
+        $bstart = Dever::input('search_option_start_buy_date');
+        $bend = Dever::input('search_option_end_buy_date');
+        $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($bstart){
+            $where['bstart'] = strtotime($bstart);
+        }
+        if($bend){
+            $where['bend'] = strtotime($bend);
+        }
+        if($fstart){
+            $where['fstart'] = strtotime($fstart);
+        }
+        if($fend){
+            $where['fend'] = strtotime($fend);
+        }
+        $where['status'] = $status;
+        $where['type'] = $type;
+        $header = array('合同乙方', '手机号码', '合同总期数(年)', '合同类型', '签订日期', '合同金额', '购买日期', '录入日期', '终审日期');
+        $info = Dever::db('agent/soft_cash')->getExcelAll($where);
+        // print_R($info);die;
+        $body = array();
+        foreach($info as $k => $v){
+            $member = Dever::db('agent/member')->find($v['mid']);
+            $role = Dever::db('setting/role')->find($member['role']);
+            $agreement = Dever::db('agent/member_agreement')->find(array('id'=>$v['agreement_id'],'mid'=>$v['mid']));
+            $name = Dever::db('setting/agreement')->find(array('id'=>$agreement['agreement_id']));
+            $config_type= Dever::db('setting/agreement')->config['config_type'];
+            $agreement_name = Dever::status($config_type,$name['type']);
+            $type = 2;
+
+            // if (!isset($info['soft_cash'])) {
+            //     $info['soft_cash'] = $v['cash'];
+            // }
+
+            # 这里加判断
+            if ($role['type'] == 2 && $role['area'] == 1) {
+                $type = 1;   
+            } elseif ($v['cash'] > 6000 && $v['cash'] <= 30000 && $v['cash']%5000 == 0) {
+                $type = 3;
+            } elseif ($v['cash'] <= 6000 && $v['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 = 6;
+            }
+            # 基础版
+            else {
+                $name = '基础版';
+                $year = 6;
+            }
+            if($v['fdate']){
+                $fdate = date('Y-m-d H:i',$v['fdate']);
+            }else{
+                $fdate = '-';
+            }
+            if($v['buy_date']){
+                $buy_date = date('Y-m-d H:i',$v['buy_date']);
+            }else{
+                $buy_date = '-';
+            }
+            if($v['zdate']){
+                $zdate = date('Y-m-d H:i',$v['zdate']);
+            }else{
+                $zdate = '-';
+            }
+            if($v['cdate']){
+                $cdate = date('Y-m-d H:i',$v['cdate']);
+            }else{
+                $cdate = '-';
+            }
+            $d = array
+            (
+                $member['name'],
+                $v['mobile'],
+                $year,
+                $agreement_name,
+                $fdate,
+                $v['cash'],
+                $buy_date,
+                $cdate,
+                $zdate,
+            );
+            $body[] = $d;
+        }
+        $file = '软件服务费';
+        Dever::excelExport($body, $header, $file);
+    }
 }