Browse Source

Merge branch 'master' of http://git.dever.cc/dever-product/churen

Your Name 2 years ago
parent
commit
d3f6276fe5

+ 19 - 0
service/agent/database/member.php

@@ -815,6 +815,25 @@ return array
             'col' => '*',
         ),
 
+        # 获取余额
+        'getCash' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'fstart' => array('yes-rdate', '>='),
+                'fend' => array('yes-rdate', '<='),
+                'status' => 'yes',
+                'role' => 'yes',
+                'parent_mid' =>'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(cash) as total',
+        ),
+
         'getSearch' => array
         (
             # 匹配的正则或函数 选填项

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

@@ -816,6 +816,7 @@ return array
                 'end' => array('yes-cdate', '<='),
                 'fstart' => array('yes-fdate', '>='),
                 'fend' => array('yes-fdate', '<='),
+                'role' => 'yes',
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -833,6 +834,7 @@ return array
                 'end' => array('yes-cdate', '<='),
                 'fstart' => array('yes-fdate', '>='),
                 'fend' => array('yes-fdate', '<='),
+                'role' => 'yes',
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),

+ 185 - 0
service/bill/database/role_stat.php

@@ -0,0 +1,185 @@
+<?php
+
+if (Dever::load('manage/auth')->checkFunc('bill.role_stat', 'out_bill_role', '导出数据')) {
+    $excel = true;
+}else{
+    $excel = false;
+}
+$role = function()
+{
+    $array = array();
+    $data = Dever::load('setting/role-state');
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
+$config = array
+(
+    # 表名
+    'name' => 'role_stat',
+    # 显示给用户看的名称
+    'lang' => '角色统计',
+    'order' => -10,
+
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'day'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '日期',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'    => 'day',
+            'search_button' => array
+            (
+                'sum' => 'num,cash,touru,shouru',
+                'option' => array(
+                    'day' => '按天',
+                    'week' => '按周',
+                    'month' => '按月',
+                ),
+                'group' => '',
+            ),
+            'order'     => 'desc',
+            'list'      => 'Dever::showDay("{day}")',
+        ),
+
+        'role'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '代理角色',
+            'default'   => '',
+            'desc'      => '代理角色',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'update'    => 'select',
+            'option'    => $role,
+            'list'      => true,
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '数量',
+            'default'   => '0',
+            'desc'      => '数量',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
+        'cash'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '金额',
+            'default'   => '0',
+            'desc'      => '金额',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
+        'touru'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '投入成本',
+            'default'   => '0',
+            'desc'      => '投入成本',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
+        'shouru'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '角色收入',
+            'default'   => '0',
+            'desc'      => '角色收入',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            '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,
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        'list' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start_day' => array('yes-day', '>='),
+                'end_day' => array('yes-day', '<='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('time' => 'desc', 'cdate' => 'desc'),
+            'page' => array(20, 'list'),
+            'group' => 'day',//num,city_num,county_num,town_num,ck_num,xk_num
+            'col' => '*,min(day) as time, sum(num) as num, sum(cash) as cash, sum(touru) as touru, sum(shouru) as shouru',
+        ),
+
+        'all' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start_day' => array('yes-day', '>='),
+                'end_day' => array('yes-day', '<='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('time' => 'desc', 'cdate' => 'desc'),
+            'group' => 'day',//num,city_num,county_num,town_num,ck_num,xk_num
+            'col' => '*,min(day) as time, sum(num) as num, sum(cash) as cash, sum(touru) as touru, sum(shouru) as shouru',
+        ),
+    ),
+);
+
+return $config;

+ 53 - 0
service/bill/lib/Cron.php

@@ -611,4 +611,57 @@ class Cron
         }     
         return 'ok';
     }
+
+    # 角色统计
+    public function role_api()
+    {
+        $num = Dever::input('num', 5);
+        $start = Dever::input('start', date('Y-m-d', strtotime('-'.$num.' day')));
+        $end = Dever::input('end', date('Y-m-d'));
+
+        $start = Dever::maketime($start . ' 00:00:00');
+        $end = Dever::maketime($end . ' 23:59:59');
+        $day = intval(($end - $start)/86400);
+        $status = 4;
+
+        $role = Dever::load('setting/role-state');
+
+        for($i=0; $i<=$day; $i++) {
+            $where = array();
+            $where['fstart'] = $start + 86400*$i;
+            $where['fend'] = $start + 86400*$i + 86399;
+            $where['status'] = 4;
+
+            foreach ($role as $k => $v) {
+                $data = array();
+                $data['day'] = $where['fstart'];
+                $data['role'] = $v['id'];
+                $where['role'] = $v['id'];
+                $info = Dever::db('bill/role_stat')->find($data);
+                $data['num'] = Dever::db('agent/order')->getNum($where);
+
+                $cash = Dever::db('agent/order')->getCash($where);
+                if ($cash) {
+                    $data['cash'] = $cash['total'];
+                } else {
+                    $data['cash'] = 0;
+                }
+                $data['touru'] = $data['cash'];
+                $cash = Dever::db('agent/member')->getCash($where);
+                if ($cash) {
+                    $data['shouru'] = $cash['total'];
+                } else {
+                    $data['shouru'] = 0;
+                }
+                if (!$info) {
+                    Dever::db('bill/role_stat')->insert($data);
+                } else {
+                    $data['where_id'] = $info['id'];
+                    Dever::db('bill/role_stat')->update($data);
+                }
+            }
+        }
+
+        return 'ok';
+    }
 }