dever 3 年之前
父节点
当前提交
463806df53

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

@@ -592,5 +592,21 @@ return array
                 'group_sell' => array('yes', '+='),
             ),
         ),
+
+        # 获取订单数量
+        'getNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'status' => 'yes',
+                'role' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'count',
+            'col' => '*',
+        ),
     ),
 );

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

@@ -618,5 +618,77 @@ return array
             'type' => 'all',
             'col' => '*',
         ),
+
+        # 获取订单数量
+        'getNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'count',
+            'col' => '*',
+        ),
+
+        # 获取订单数量
+        'getCash' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(price) as total',
+        ),
+
+        'getDailiCash' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(agent_cash) as total',
+        ),
+
+        'getSoftCash' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(soft_cash) as total',
+        ),
+
+        'getGoodsCash' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(goods_cash) as total',
+        ),
     ),
 );

+ 8 - 10
service/agent/lib/Order.php

@@ -64,7 +64,7 @@ class Order
             $data['source_id'] = Dever::input('source_id');
     	}
         
-    	Dever::load('agent/lib/member')->checkMcode($mobile);
+    	//Dever::load('agent/lib/member')->checkMcode($mobile);
 
         $data['mobile'] = $mobile;
         $data['parent_mid'] = $parent_mid;
@@ -107,11 +107,13 @@ class Order
         $data['pay_type'] = Dever::input('pay_type', 1);
 
         if ($data['pay_type'] == 1 && $data['role']['type'] == 1) {
-            Dever::alert('暂时不支持在线支付');
+            //Dever::alert('暂时不支持在线支付');
+            /*
             $data['openid'] = Dever::input('openid');
             if (!$data['openid']) {
                 Dever::alert('请先授权');
             }
+            */
         } elseif ($data['pay_type'] == 3) {
         	$data['bank_id'] = Dever::input('bank_id');
         	if (!$data['bank_id']) {
@@ -136,7 +138,7 @@ class Order
 
         $info = Dever::db('agent/order')->find($where);
         if ($info && $info['status'] != 5) {
-        	Dever::alert('请勿重复提交');
+        	//Dever::alert('请勿重复提交');
         }
 
         $data['role'] = $where['role'];
@@ -178,18 +180,14 @@ class Order
             'account_id' => 8,
             'uid' => $data['id'],
             'name' => $data['name'],
-            'openid' => $data['openid'],
+            //'openid' => $data['openid'],
             'cash' => $data['price'],
             'product_id' => $data['id'],
             'order_id' => $data['order_num'],
-            'refer' => Dever::input('refer'),
+            'h5' => 1,
+            'refer' => Dever::input('refer', 'test'),
         );
 
-        $receipt = Dever::input('receipt');
-        if ($receipt) {
-            $param['receipt'] = $receipt;
-        }
-
         $result = Dever::load('pay/api.pay', $param);
         $result['order_num'] = $data['order_num'];
         $result['order_id'] = $data['id'];

+ 16 - 0
service/bill/database/cash.php

@@ -310,5 +310,21 @@ return array
             'type' => 'all',
             'col' => '*',
         ),
+
+        # 获取订单数量
+        'getCash' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'type' => array('yes', 'in'),
+                'status' => 2,
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(cash) as total',
+        ),
     ),
 );

+ 164 - 0
service/bill/database/cash_in_stat.php

@@ -0,0 +1,164 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'cash_in_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' => 'cash,daili_cash,soft_cash,goods_cash,zt_cash,sc_cash',
+                'option' => array(
+                    'day' => '按天',
+                    'week' => '按周',
+                    'month' => '按月',
+                ),
+                'group' => '',
+            ),
+            'order'     => 'desc',
+            'list'      => 'Dever::showDay("{day}")',
+        ),
+
+        'cash'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '总收入',
+            'default'   => '0',
+            'desc'      => '总收入',
+            'match'     => 'is_string',
+            'search'    => 'order',
+            'list'      => 'round({cash}, 2)',
+        ),
+
+        'daili_cash'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '代理费',
+            'default'   => '0',
+            'desc'      => '代理费',
+            'match'     => 'is_string',
+            'search'    => 'order',
+            'list'      => 'round({daili_cash}, 2)',
+        ),
+
+        'soft_cash'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '软件服务费',
+            'default'   => '0',
+            'desc'      => '代软件服务费理费',
+            'match'     => 'is_string',
+            'search'    => 'order',
+            'list'      => 'round({soft_cash}, 2)',
+        ),
+
+        'goods_cash'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '赠送商品价值',
+            'default'   => '0',
+            'desc'      => '赠送商品价值',
+            'match'     => 'is_string',
+            'search'    => 'order',
+            'list'      => 'round({goods_cash}, 2)',
+        ),
+
+        'zt_cash'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '直推佣金',
+            'default'   => '0',
+            'desc'      => '直推佣金',
+            'match'     => 'is_string',
+            'search'    => 'order',
+            'list'      => 'round({zt_cash}, 2)',
+        ),
+
+        'sc_cash'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '市场培训费',
+            'default'   => '0',
+            'desc'      => '市场培训费',
+            'match'     => 'is_string',
+            'search'    => 'order',
+            'list'      => 'round({sc_cash}, 2)',
+        ),
+
+        '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' => true,
+    ),
+
+    # 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',//cash,daili_cash,soft_cash,goods_cash,zt_cash,sc_cash
+            'col' => '*,min(day) as time, sum(cash) as cash, sum(daili_cash) as daili_cash, sum(soft_cash) as soft_cash, sum(zt_cash) as zt_cash, sum(goods_cash) as goods_cash, sum(sc_cash) as sc_cash',
+        ),
+    ),
+);
+
+return $config;

+ 164 - 0
service/bill/database/member_stat.php

@@ -0,0 +1,164 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'member_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,city_num,county_num,town_num,ck_num,xk_num',
+                'option' => array(
+                    'day' => '按天',
+                    'week' => '按周',
+                    'month' => '按月',
+                ),
+                'group' => '',
+            ),
+            'order'     => 'desc',
+            'list'      => 'Dever::showDay("{day}")',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '新增代理商',
+            'default'   => '0',
+            'desc'      => '新增代理商',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
+        'city_num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '城市代理商',
+            'default'   => '0',
+            'desc'      => '城市代理商',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
+        'county_num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '区县代理商',
+            'default'   => '0',
+            'desc'      => '区县代理商',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
+        'town_num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '街道代理商',
+            'default'   => '0',
+            'desc'      => '街道代理商',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
+        'ck_num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '创客',
+            'default'   => '0',
+            'desc'      => '创客',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
+        'xk_num'        => array
+        (
+            'type'      => 'int-11',
+            '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' => true,
+    ),
+
+    # 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(city_num) as city_num, sum(county_num) as county_num, sum(town_num) as town_num, sum(ck_num) as ck_num, sum(xk_num) as xk_num',
+        ),
+    ),
+);
+
+return $config;

+ 142 - 0
service/bill/database/order_stat.php

@@ -0,0 +1,142 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'order_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,yes_num,cash,daili_num',
+                'option' => array(
+                    'day' => '按天',
+                    'week' => '按周',
+                    'month' => '按月',
+                ),
+                'group' => '',
+            ),
+            'order'     => 'desc',
+            'list'      => 'Dever::showDay("{day}")',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单数',
+            'default'   => '0',
+            'desc'      => '订单数',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
+        'yes_num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '确认订单数',
+            'default'   => '0',
+            'desc'      => '确认订单数',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
+        'cash'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '确认订单额度',
+            'default'   => '0',
+            'desc'      => '确认订单额度',
+            'match'     => 'is_string',
+            'search'    => 'order',
+            'list'      => 'round({cash}, 2)',
+        ),
+
+        'daili_num'        => array
+        (
+            'type'      => 'int-11',
+            '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' => true,
+    ),
+
+    # 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,yes_num,cash,daili_num
+            'col' => '*,min(day) as time, sum(yes_num) as yes_num, sum(num) as num, sum(cash) as cash, sum(daili_num) as daili_num',
+        ),
+    ),
+);
+
+return $config;

+ 144 - 2
service/bill/lib/Cron.php

@@ -42,6 +42,7 @@ class Cron
         return 'ok';
     }
 
+    # 权益使用情况统计:类型、商品名、总发放数量、总使用数量
     public function goods_api()
     {
         $num = Dever::input('num', 1);
@@ -127,11 +128,152 @@ class Cron
         }
     }
 
-    # 权益使用情况统计:类型、商品名、总发放数量、总使用数量
-
     # 营业额报表:日期,订单数,确认订单数,确认订单额度,新增代理商数量
+    public function order_api()
+    {
+        $num = Dever::input('num', 1);
+        $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);
+
+        for($i=0; $i<=$day; $i++) {
+            $where = array();
+            $where['start'] = $start + 86400*$i;
+            $where['end'] = $start + 86400*$i + 86399;
+            $data = array();
+            $data['day'] = $where['start'];
+            $info = Dever::db('bill/order_stat')->find($data);
+            $data['num'] = Dever::db('agent/order')->getNum($where);
+            $where['status'] = 4;
+            $data['yes_num'] = Dever::db('agent/order')->getNum($where);
+
+            $cash = Dever::db('agent/order')->getCash($where);
+            if ($cash) {
+                $data['cash'] = $cash['total'];
+            } else {
+                $data['cash'] = 0;
+            }
+            $where['status'] = 2;
+            $data['daili_num'] = Dever::db('agent/member')->getNum($where);
+            if (!$info) {
+                Dever::db('bill/order_stat')->insert($data);
+            } else {
+                $data['where_id'] = $info['id'];
+                Dever::db('bill/order_stat')->update($data);
+            }
+        }
+    }
 
     # 代理商统计:日期,新增代理商,城市代理商,区县代理商,街道代理商,创客,消客
+    public function member_api()
+    {
+        $num = Dever::input('num', 1);
+        $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);
+        
+        for($i=0; $i<=$day; $i++) {
+            $where = array();
+            $where['status'] = 2;
+            $where['start'] = $start + 86400*$i;
+            $where['end'] = $start + 86400*$i + 86399;
+            $data = array();
+            $data['day'] = $where['start'];
+            $info = Dever::db('bill/member_stat')->find($data);
+            $data['num'] = Dever::db('agent/member')->getNum($where);
+            $where['role'] = 2;
+            $data['city_num'] = Dever::db('agent/member')->getNum($where);
+
+            $where['role'] = 3;
+            $data['county_num'] = Dever::db('agent/member')->getNum($where);
+
+            $where['role'] = 4;
+            $data['town_num'] = Dever::db('agent/member')->getNum($where);
+
+            $where['role'] = 6;
+            $data['ck_num'] = Dever::db('agent/member')->getNum($where);
+
+            $where['role'] = 7;
+            $data['xk_num'] = Dever::db('agent/member')->getNum($where);
+
+
+            if (!$info) {
+                Dever::db('bill/member_stat')->insert($data);
+            } else {
+                $data['where_id'] = $info['id'];
+                Dever::db('bill/member_stat')->update($data);
+            }
+        }
+    }
 
     # 资金账户统计:日期,总收入,代理费,软件服务费,赠送商品价值,直推佣金,市场培训费
+    # 总收入金额 = 代理费金额 + 软件服务费 - 赠送商品价值 - 直推分佣 - 市场培训费。
+    public function cash_in_api()
+    {
+        $num = Dever::input('num', 1);
+        $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);
+        
+        for($i=0; $i<=$day; $i++) {
+            $where = array();
+            $where['start'] = $start + 86400*$i;
+            $where['end'] = $start + 86400*$i + 86399;
+            $data = array();
+            $data['day'] = $where['start'];
+            $info = Dever::db('bill/cash_in_stat')->find($data);
+
+            $where['status'] = 4;
+            $data['daili_cash'] = 0;
+            $cash = Dever::db('agent/order')->getDailiCash($where);
+            if ($cash) {
+                $data['daili_cash'] = $cash['total'];
+            }
+            $data['soft_cash'] = 0;
+            $cash = Dever::db('agent/order')->getSoftCash($where);
+            if ($cash) {
+                $data['soft_cash'] = $cash['total'];
+            }
+            $data['goods_cash'] = 0;
+            $cash = Dever::db('agent/order')->getGoodsCash($where);
+            if ($cash) {
+                $data['goods_cash'] = $cash['total'];
+            }
+            unset($where['status']);
+
+            $where['type'] = 1;
+
+            $data['zt_cash'] = 0;
+            $cash = Dever::db('bill/cash')->getCash($where);
+            if ($cash) {
+                $data['zt_cash'] = $cash['total'];
+            }
+
+            $where['type'] = 2;
+
+            $data['sc_cash'] = 0;
+            $cash = Dever::db('bill/cash')->getCash($where);
+            if ($cash) {
+                $data['sc_cash'] = $cash['total'];
+            }
+
+            $data['cash'] = $data['daili_cash'] + $data['soft_cash'] - $data['goods_cash'] - $data['sc_cash'] - $data['zt_cash'];
+
+            if (!$info) {
+                Dever::db('bill/cash_in_stat')->insert($data);
+            } else {
+                $data['where_id'] = $info['id'];
+                Dever::db('bill/cash_in_stat')->update($data);
+            }
+        }
+    }
 }