Your Name 2 years ago
parent
commit
81a7699a10

+ 20 - 0
service/agent/database/order.php

@@ -823,6 +823,24 @@ return array
             'col' => 'sum(agent_cash) as total',
         ),
 
+        #期权价值
+        'getOptionPrice' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'fstart' => array('yes-fdate', '>='),
+                'fend' => array('yes-fdate', '<='),
+                'status' => array('yes', 'in'),
+                'role'  => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(option_price) as total',
+        ),
+
         'getSoftCash' => array
         (
             # 匹配的正则或函数 选填项
@@ -931,6 +949,8 @@ return array
             (
                 'start' => array('yes-fdate', '>='),
                 'end' => array('yes-fdate', '<='),
+                'fstart' => array('yes-fdate', '>='),
+                'fend' => array('yes-fdate', '<='),
                 'status' => array('yes', 'in'),
                 'role' => 'yes',
                 'state' => 1,

+ 26 - 2
service/agent/database/soft_cash.php

@@ -21,6 +21,16 @@ $type = array
     2 => '已签署',
     3 => '已作废',
 );
+$role = function()
+{
+    $array = array();
+    $data = Dever::load('setting/role-state');
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
 
 $insert = false;
 $col = Dever::input('col');
@@ -114,6 +124,19 @@ return array
             'list_order' => 1,
         ),
 
+        'role'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '代理角色',
+            'default'   => '',
+            'desc'      => '代理角色',
+            'match'     => 'is_numeric',
+            // 'search'    => 'select',
+            // 'update'    => 'select',
+            'option'    => $role,
+            'list'      => true,
+        ),
+
         'agreement_id'      => array
         (
             'type'      => 'int-11',
@@ -323,9 +346,10 @@ return array
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'fstart' => array('yes-zdate', '>='),
-                'fend' => array('yes-zdate', '<='),
+                'fstart' => array('yes-fdate', '>='),
+                'fend' => array('yes-fdate', '<='),
                 'status' => array('yes', 'in'),
+                'role' =>'yes',
                 'state' => 1,
             ),
             'type' => 'one',

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

@@ -29,6 +29,7 @@ Class Soft_cash
             // print_R($info);die;
             $update['where_id'] = $id;
             $update['set_mid'] = $info['id'];
+            $update['set_role'] = $info['role'];
             if (!$soft['order_num']) {
                 $update['set_order_num'] = $this->getOrderId($id);
             }
@@ -480,4 +481,16 @@ Class Soft_cash
         $file = '软件服务费';
         Dever::excelExport($body, $header, $file);
     }
+
+    public function update_role_api(){
+        $data = Dever::db('agent/soft_cash')->state();
+        foreach($data as $k => $v){
+            if(!$v['role']){
+                $member = Dever::db('agent/member')->find($v['mid']);
+                $where['where_id'] = $v['id'];
+                $where['set_role'] = $member['role'];
+                Dever::db('agent/soft_cash')->update($where);
+            }
+        }
+    }
 }

+ 176 - 0
service/mail/assets/pc/html/census.html

@@ -0,0 +1,176 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>厨人意料代理商每日汇总</title>
+<meta name="renderer" content="webkit">
+<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+<meta name="apple-mobile-web-app-status-bar-style" content="black"> 
+<meta name="apple-mobile-web-app-capable" content="yes">
+<meta name="format-detection" content="telephone=no">
+<link rel="stylesheet" type="text/css" href="../script/lib/layui/css/layui.css" />
+<script src="../script/lib/jquery/jquery.min.js"></script>
+<script src="../script/lib/layui/layui.js"></script>
+<script src="../script/lib/echarts/echarts.common.min.js"></script>
+<script><{Dever::script()}></script>
+<script src="../script/dever/core.js"></script>
+<style>
+.dever-upload-pic
+{
+  width:100px;
+}
+h5 {
+    margin-bottom: 10px;
+}
+</style>
+
+</head>
+<body>
+<div class="layui-container">
+<div class="layui-card">
+
+  <div class="layui-card-header" style="font-size: 20px"><{$day['time']}></div>
+  
+  <div class="layui-card-body">
+      <h5>已确认代理商数据:<br/>代理商:<{$day['num']}>,总金额:¥<{$day['money']}><br/>代理费:<{$day['dl_money']}>,软件服务费:¥<{$day['cash']}>,期权价值:¥<{$day['option_money']}></h5>
+     
+     
+    <table class="table layui-table layui-table-body" id="table">
+          <thead id="list-thead">
+              <tr>
+                <th data-priority="1">角色</th>
+                <th data-priority="1">数量</th>
+                <th data-priority="1">金额</th>
+                <th data-priority="1">软件服务费</th>
+                <th data-priority="1">期权价值</th>
+              </tr>
+          </thead>
+            <tbody>
+              <{foreach($money as $k => $v):}>
+                <tr>
+                  <td><{$v['name']}></td>
+                  <td><{$v['num']}></td>
+                  <td><{$v['money']}></td>
+                  <td><{$v['cash']}></td>
+                  <td><{$v['option_money']}></td>
+                </tr>
+                  <{endforeach}>
+          </tbody> 
+      </table>
+</div>
+</div>
+<div class="layui-card">
+      <div class="layui-card-header" style="font-size: 20px"><{$all['time']}></div>
+  <div class="layui-card-body">
+      <h5>已确认代理商数据:<br/>代理商:<{$all['num']}>,总金额:¥<{$all['money']}><br/>代理费:<{$all['dl_money']}>,软件服务费:¥<{$all['cash']}>,期权价值:¥<{$all['option_money']}></h5>
+    <table class="table layui-table layui-table-body" id="table">
+          <thead id="list-thead">
+              <tr>
+                <th data-priority="1">角色</th>
+                <th data-priority="1">数量</th>
+                <th data-priority="1">金额</th>
+                <th data-priority="1">软件服务费</th>
+                <th data-priority="1">期权价值</th>
+              </tr>
+          </thead>
+            <tbody>
+              <{foreach($all_money as $k => $v):}>
+                <tr>
+                  <td><{$v['name']}></td>
+                  <td><{$v['num']}></td>
+                  <td><{$v['money']}></td>
+                  <td><{$v['cash']}></td>
+                  <td><{$v['option_money']}></td>
+                </tr>
+                  <{endforeach}>
+          </tbody> 
+      </table>
+      </div>
+      </div>
+      <div class="layui-card">
+            <div class="layui-card-header" style="font-size: 20px">当月趋势:</div>
+        <div class="layui-card-body">
+      <div id="main" style="width:100%;height:600px;"></div>
+      <div id="money" style="width:100%;height:600px;"></div>
+      </div>
+      </div>
+        
+
+      </div>
+      </div>
+      
+
+</div>
+<script>
+
+  var chartDom = document.getElementById('main');
+var myChart = echarts.init(chartDom);
+var option;
+
+option = {
+  title: {
+    text: '数据趋势'
+  },
+  tooltip: {
+    trigger: 'axis'
+  },
+
+  grid: {
+    left: '3%',
+    right: '4%',
+    bottom: '3%',
+    containLabel: true
+  },
+  toolbox: {
+    feature: {
+      saveAsImage: {}
+    }
+  },
+  xAxis: {
+    type: 'category',
+    boundaryGap: false,
+    data: <{$zhou}>
+  },
+  yAxis: {
+    type: 'value'
+  },
+  series: <{$data}>
+};
+option && myChart.setOption(option);
+var chart = document.getElementById('money');
+var myChart = echarts.init(chart);
+var option;
+options = {
+  title: {
+    text: '金额趋势'
+  },
+  tooltip: {
+    trigger: 'axis'
+  },
+
+  grid: {
+    left: '3%',
+    right: '4%',
+    bottom: '3%',
+    containLabel: true
+  },
+  toolbox: {
+    feature: {
+      saveAsImage: {}
+    }
+  },
+  xAxis: {
+    type: 'category',
+    boundaryGap: false,
+    data: <{$zhou}>
+  },
+  yAxis: {
+    type: 'value'
+  },
+  series: <{$qu_money}>
+};
+options && myChart.setOption(options);
+</script>
+</body>
+</html>

+ 97 - 0
service/mail/database/email.php

@@ -0,0 +1,97 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'email',
+    # 显示给用户看的名称
+    'lang' => '邮件列表',
+    'order' => -10,
+
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '用户名称',
+            'default'   => '',
+            'desc'      => '用户名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'email'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '邮箱',
+            'default'   => '',
+            'desc'      => '请输入邮箱',
+            'match'     => 'option||' . Dever::rule('email'),
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '数据状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '发布时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            //'search'  => 'date',
+            //'list'        => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        // 'insert' => false,
+        // 'edit' => false,
+        // 'delete' => false,
+        // 'num' => false,
+        // 'excel' => $excel,
+        // 'button' => $button,
+        
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        // 'getExcelAll' => array
+        // (
+        //     # 匹配的正则或函数 选填项
+        //     'option' => array
+        //     (
+        //         'start' => array('yes-month', '>='),
+        //         'end' => array('yes-month', '<='),
+        //         'state' => 1,
+        //     ),
+        //     'type' => 'all',
+        //     'col' => '*',
+        // ),
+    ),
+);
+
+return $config;

+ 118 - 0
service/mail/database/feature.php

@@ -0,0 +1,118 @@
+<?php
+$email = function()
+{
+    $array = array();
+    $data = Dever::db('mail/email-state');
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
+$config = array
+(
+    # 表名
+    'name' => 'feature',
+    # 显示给用户看的名称
+    'lang' => '功能列表',
+    'order' => -10,
+
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '邮件名称',
+            'default'   => '',
+            'desc'      => '邮件名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'key'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '功能标识',
+            'default'   => '',
+            'desc'      => '功能标识',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'email_id'        => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '用户名称',
+            'default'   => '',
+            'desc'      => '用户名称',
+            'match'     => 'option',
+            'update'    => 'checkbox',
+            'option'    => $email,
+            //'list'      => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '数据状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '发布时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            //'search'  => 'date',
+            //'list'        => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        // 'insert' => false,
+        // 'edit' => false,
+        // 'delete' => false,
+        // 'num' => false,
+        // // 'excel' => $excel,
+        // 'button' => $button,
+        
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        'getExcelAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-month', '>='),
+                'end' => array('yes-month', '<='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*',
+        ),
+    ),
+);
+
+return $config;

+ 8 - 0
service/mail/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'mail');
+define('DEVER_APP_LANG', '邮件管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 10);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-component');
+include(DEVER_APP_PATH . '../boot.php');

+ 324 - 0
service/mail/lib/Manage.php

@@ -0,0 +1,324 @@
+<?php
+namespace Mail\Lib;
+
+use Dever;
+
+class Manage
+{
+	#代理商日数据统计
+	public function day_api(){
+        $start=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
+        $end=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
+        $time = Dever::maketime(date('Y-m-d'),'00:00:00');
+        $where = array();
+        $where['fstart'] = $start;
+        $where['fend'] = $end;
+        $w = array();
+        $fstart = Dever::input('start', date('Y-m-01', strtotime('-0 month')));
+        $w['fstart'] = Dever::maketime($fstart . ' 00:00:00');
+        $w['fend'] = $end;
+        $data = array();
+        $data['day'] = $this->content_api($where,1);
+        $data['money'] = $this->c_api($where);
+        $data['all'] = $this->content_api($w,2);
+        $data['all_money'] = $this->c_api($w);
+        $data['time'] = $this->day_time_api($w);
+        $data['data'] = Dever::json_encode($data['time']);
+        $data['money_time'] = $this->money_time_api($w);
+        $data['qu_money'] = Dever::json_encode($data['money_time']);
+        $data['xzhou'] = $this->button_day_api($w,1);
+        $data['zhou'] = Dever::json_encode($data['xzhou']);
+        return Dever::render('census', $data);
+	}
+    #代理商周数据
+    public function zhou_api(){
+        $start=mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));
+        $end=mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));
+        $where = array();
+        $where['fstart'] = $start;
+        $where['fend'] = $end;
+        $w = array();
+        $fstart = Dever::input('start', date('Y-m-01', strtotime('-0 month')));
+        $w['fstart'] = Dever::maketime($fstart . ' 00:00:00');
+        $w['fend'] = $end;
+        $data = array();
+        $data['day'] = $this->content_api($where,1);
+        $data['money'] = $this->c_api($where);
+        $data['all'] = $this->content_api($w,2);
+        $data['all_money'] = $this->c_api($w);
+        $data['time'] = $this->day_time_api($w);
+        $data['data'] = Dever::json_encode($data['time']);
+        $data['money_time'] = $this->money_time_api($w);
+        $data['qu_money'] = Dever::json_encode($data['money_time']);
+        $data['xzhou'] = $this->button_day_api($w,1);
+        $data['zhou'] = Dever::json_encode($data['xzhou']);
+        return Dever::render('census', $data);
+    }
+	#代理商月数据统计
+	public function month_api(){
+		$num = Dever::input('num',1);
+		$start = Dever::input('start', date('Y-m-01', strtotime('-'.$num.' month')));
+        $end = date('Y-m-d', strtotime($start." +1 month -1 day"));
+        $time = Dever::maketime(date('Y-m-01'),'00:00:00');
+    	$start = Dever::maketime($start . ' 00:00:00');
+        $end = Dever::maketime($end . ' 23:59:59');
+        $where = array();
+        $where['fstart'] = $start;
+        $where['fend'] = $end;
+        $w = array();
+        $fstart = Dever::input('start', date('Y-m-01', strtotime('-1 month')));
+        $w['fstart'] = Dever::maketime($fstart . ' 00:00:00');
+        $w['fend'] = $end;
+        $data = array();
+        $data['day'] = $this->content_api($where,1);
+        $data['money'] = $this->c_api($where);
+        $data['all'] = $this->content_api($w,2);
+        $data['all_money'] = $this->c_api($w);
+        $data['time'] = $this->day_time_api($w);
+        $data['data'] = Dever::json_encode($data['time']);
+        $data['money_time'] = $this->money_time_api($w);
+        $data['qu_money'] = Dever::json_encode($data['money_time']);
+        $data['xzhou'] = $this->button_day_api($w,2);
+        $data['zhou'] = Dever::json_encode($data['xzhou']);
+        return Dever::render('census', $data);
+	}
+    #按时间统计
+	public function content_api($where,$type){
+		$data = array();
+        // print_R($where);die;
+        if($type == 2){
+            $data['time'] = date('Y.m',$where['fstart']);
+        }else{
+            $data['time'] = date('Y.m.d',$where['fstart']);
+        }
+        
+        #确认代理商订单数
+        $where['status'] = 4;
+        $data['num'] = Dever::db('agent/order')->getNum($where);
+        #确认订单总费用
+        $money = Dever::db('agent/order')->getCash($where);
+        if($money['total']){
+        	$data['money'] = $money['total'];
+        }else{
+        	$data['money'] = 0;
+        }
+        #确认代理费
+        $dl_money = Dever::db('agent/order')->getDailiCash($where);
+        if($dl_money['total']){
+            $data['dl_money'] = $dl_money['total'];
+        }else{
+            $data['dl_money'] = 0;
+        }
+        #确认软件服务费
+        $soft_money = Dever::db('agent/order')->getSoftCash($where);
+        if($soft_money['total']){
+            $data['soft_money'] = $soft_money['total'];
+        }else{
+            $data['soft_money'] = 0;
+        }
+        $wh['status'] = 3;
+        $wh['fstart'] = $where['fstart'];
+        $wh['fend'] = $where['fend'];
+        $cash = Dever::db('agent/soft_cash')->getTotal($wh);
+        if($cash['total']){
+            $data['cash'] = $cash['total'];
+        }else{
+            $data['cash'] = 0;
+        }
+        $data['soft_cash'] = $data['soft_money'] + $data['cash'];
+
+        #期权价值
+        $option_money = Dever::db('agent/order')->getOptionPrice($where);
+        if($option_money['total']){
+            $data['option_money'] = $option_money['total'];
+        }else{
+            $data['option_money'] = 0;
+        }
+        return $data;
+    }
+    #各角色的金额,数量,原始期权价值,软件服务费
+    public function c_api($where){
+        $role = Dever::db('setting/role')->getAll(array('id'=>1,'state'=>1));
+        foreach($role as $k => $v){
+            // print_R($where);die;
+            $where['role'] = $v['id'];
+            $data[$k]['name'] = $v['name'];
+            $where['status'] = 2;
+            $data[$k]['num'] = Dever::db('agent/member')->getNum($where);
+            $where['status'] = 4;
+            $dl = Dever::db('agent/order')->getSum($where);
+            if($dl['total']){
+                $data[$k]['money'] = $dl['total'];
+            }else{
+                $data[$k]['money'] = 0;
+            }
+            #期权价值:
+            $option_money = Dever::db('agent/order')->getOptionPrice($where);
+            if($option_money['total']){
+                $data[$k]['option_money'] = $option_money['total'];
+            }else{
+                $data[$k]['option_money'] = 0;
+            }
+            #软件服务费
+            $wh['role'] = $v['id'];
+            $wh['status'] = 3;
+            $wh['fstart'] = $where['fstart'];
+            $wh['fend'] = $where['fend'];
+            $cash = Dever::db('agent/soft_cash')->getTotal($wh);
+            if($cash['total']){
+                $data[$k]['cash'] = $cash['total'];
+            }else{
+                $data[$k]['cash'] = 0;
+            }
+        }
+        return $data;
+    }
+    #数据趋势
+    public function day_time_api($w){
+      $days = ($w['fend']-$w['fstart'])/86400+1;
+      // 保存每天日期
+      $day = array();
+      $data = array();
+      for($i=0; $i<$days; $i++){
+        $day[] =  array($w['fstart']+(86400*$i),$w['fstart']+(86400*$i)+86400);
+      }
+      $res = array();
+      $res['num'] = array();
+      foreach($day as $k => $v){
+        $where['fstart'] = $v[0];
+        $where['fend'] =$v[1]-1;
+        $data[$k]['time'] = date('m.d',$v[0]);
+        #确认代理商订单数
+        $where['status'] = 4;
+        $res['num'][] = Dever::db('agent/order')->getNum($where);
+      }
+      $data = array();
+      $data['name'] = '数量';
+      $data['type'] = 'line';
+      // $data['stack'] = 'Total';
+      $data['data'] = $res['num'];
+      return $data;
+    }
+    #金额趋势
+    public function money_time_api($w){
+      $days = ($w['fend']-$w['fstart'])/86400+1;
+      // 保存每天日期
+      $day = array();
+      $data = array();
+      for($i=0; $i<$days; $i++){
+        $day[] =  array($w['fstart']+(86400*$i),$w['fstart']+(86400*$i)+86400);
+      }
+      $res = array();
+      $res['money'] = array();
+      foreach($day as $k => $v){
+        $where['fstart'] = $v[0];
+        $where['fend'] =$v[1]-1;
+        $data[$k]['time'] = date('m.d',$v[0]);
+        #确认订单总费用
+        $money = Dever::db('agent/order')->getCash($where);
+        if($money['total']){
+            $res['money'][] = $money['total'];
+        }else{
+            $res['money'][] = 0;
+        }
+      }
+      $money = array();
+      $money['name'] = '金额';
+      $money['type'] = 'line';
+      $money['data'] = $res['money'];
+      return $money;
+    }
+    #趋势底部日期
+    public function button_day_api($w,$type){
+        $days = ($w['fend']-$w['fstart'])/86400+1;
+        if($type ==1){
+            $daysd = $days-1;
+        }else{
+            $daysd = $days;
+        }
+      // 保存每天日期
+      $day = array();
+      $data = array();
+      for($i=0; $i<$daysd; $i++){
+        $day[] = date('m.d',$w['fstart']+(86400*$i));
+      }
+      $data['type'] = 'category';
+      $data['boundaryGap'] = false;
+      $data['date'] = $day;
+      return $day;
+    }
+    #代理商日统计
+    public function index_api(){
+        $title = '代理商日数据统计';
+        $data = Dever::db('mail/feature')->find(array('key'=>'lib/cron.day'));
+        $email = explode(',',$data['email_id']);
+        foreach($email as $k => $v){
+            $res[] = Dever::db('mail/email')->find(array('id'=>$v));
+        }
+        $content = $this->index_api();
+        foreach($res as $key => $val){
+            $this->send($val['email'], $val['name'], $title, $content);
+        }
+    }
+    #代理商周统计
+    public function week_api(){
+        $title = '代理商周数据统计';
+        $data = Dever::db('mail/feature')->find(array('key'=>'lib/cron.week'));
+        $email = explode(',',$data['email_id']);
+        foreach($email as $k => $v){
+            $res[] = Dever::db('mail/email')->find(array('id'=>$v));
+        }
+        $content = $this->zhou_api();
+        foreach($res as $key => $val){
+            $this->send($val['email'], $val['name'], $title, $content);
+        }
+    }
+    #代理商月统计
+    public function yue_api(){
+        $title = '代理商月数据统计';
+        $data = Dever::db('mail/feature')->find(array('key'=>'lib/cron.yue'));
+        $email = explode(',',$data['email_id']);
+        foreach($email as $k => $v){
+            $res[] = Dever::db('mail/email')->find(array('id'=>$v));
+        }
+        $content = $this->month_api();
+        if(!$content){
+            return false;
+        }
+        foreach($res as $key => $val){
+            $this->send($val['email'], $val['name'], $title, $content);
+        }
+    }
+    #代理商统计发送邮件
+    public function send($email, $username, $title, $content)
+    {
+        $config = Dever::config('base', 'project')->email;
+
+        Dever::apply('src/PHPMailer', 'email');
+        Dever::apply('src/Exception', 'email');
+        Dever::apply('src/SMTP', 'email');
+        $mail = new \PHPMailer\PHPMailer\PHPMailer();
+
+        $mail->isSMTP();
+        //$mail->SMTPDebug = 2;
+        $mail->CharSet = 'UTF-8';
+        $mail->Host = $config['smtp'];
+        $mail->Port = 465;
+        $mail->SMTPSecure = 'ssl';
+        $mail->SMTPAuth = true;
+        $mail->Username = $config['username'];
+        $mail->Password = $config['password'];
+        $mail->setFrom($config['from'][0], '统计');
+        $mail->addAddress($email, $username);
+        $mail->Subject = "=?utf-8?B?" . base64_encode($title) . "?=";
+        $mail->Body = $content;
+        $mail->isHTML(true);
+        //$mail->addAttachment($file);
+        if (!$mail->send()) {
+            Dever::alert("Mailer Error: " . $mail->ErrorInfo);
+        } else {
+            return 'ok';
+        }
+    }
+	
+}

+ 12 - 0
service/setting/database/role.php

@@ -295,5 +295,17 @@ return array
             'order' => array('reorder' => 'desc', 'id' => 'desc'),
             'col' => 'id,short_name as name,area,type,price',
         ),
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'id' => array('yes','>'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'asc'),
+            'col' => '*',
+        ),
     ),
 );