Your Name 2 years ago
parent
commit
dca1e6f75f

+ 1 - 1
service/agent/src/My.php

@@ -880,7 +880,7 @@ class My extends Core
         }
         Dever::alert('合同不存在');
     }
-
+    
     # 获取我的业绩统计
     public function getSell()
     {

+ 1 - 1
service/bill/database/sell.php

@@ -258,7 +258,7 @@ return array
                 'state' => 1,
             ),
             'type' => 'all',
-            'group' => 'mid',
+            'group' => 'mid,type',
             'col' => '*,sum(num) as num',
         ),
 

+ 23 - 2
service/bill/database/sell_stat.php

@@ -121,15 +121,36 @@ return array
         'new_num'      => array
         (
             'type'      => 'float-11,2',
-            'name'      => '本⽉新增业绩',
+            'name'      => '本⽉新增团队业绩',
             'default'   => '0',
-            'desc'      => '本⽉新增业绩',
+            'desc'      => '本⽉新增团队业绩',
             'match'     => 'is_numeric',
             'update'    => 'text',
             'list'      => true,
             //'list'      => 'Dever::load("bill/lib/manage.getSellNewNum", "{num}", "{month}", "{mid}")',
         ),
+        'zt_num'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '直推业绩',
+            'default'   => '0',
+            'desc'      => '直推业绩',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+        ),
 
+        'new_ztnum'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '本⽉新增直推业绩',
+            'default'   => '0',
+            'desc'      => '本⽉新增直推业绩',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+            //'list'      => 'Dever::load("bill/lib/manage.getSellNewNum", "{num}", "{month}", "{mid}")',
+        ),
         'state'     => array
         (
             'type'      => 'tinyint-1',

+ 41 - 19
service/bill/lib/Cron.php

@@ -24,34 +24,56 @@ class Cron
 
     public function sell_api()
     {
-    	# 按月份统计团队业绩
+    	# 按月份统计团队业绩和直推业绩
         $month = Dever::input('month', date('Y-m'));
         $start_time = $month .'-01 00:00:00';
 		$end_time = date('Y-m-d', strtotime($start_time. ' +1 month -1 day')).' 23:59:59';
-		$where['type'] = '2';
+		// $where['type'] = '2';
         $where['start'] = Dever::maketime($start_time);
         $where['end'] = Dever::maketime($end_time);
         $data = Dever::db('bill/sell')->getNumByTime($where);
         if ($data) {
         	foreach ($data as $k => $v) {
-        		if ($v['num'] > 0) {
+                if($v['type']==2){
+                    if ($v['num'] > 0) {
+                        $w = array();
+                        $w['mid'] = $v['mid'];
+                        $w['month'] = $where['start'];
+                        $info = Dever::db('bill/sell_stat')->find($w);
+                        $w['new_num'] = $v['num'];
+                        $where['mid'] = $v['mid'];
+                        $total = Dever::db('bill/sell')->getNumByTimeOne($where);
+                        if ($total) {
+                            $w['num'] = $total['num'];
+                        }
+                        if ($info) {
+                            $w['where_id'] = $info['id'];
+                            Dever::db('bill/sell_stat')->update($w);
+                        } else {
+                            Dever::db('bill/sell_stat')->insert($w);
+                        }
+                    }
+                }else{
+                    if ($v['num'] > 0) {
                     $w = array();
-        			$w['mid'] = $v['mid'];
-        			$w['month'] = $where['start'];
-        			$info = Dever::db('bill/sell_stat')->find($w);
-        			$w['new_num'] = $v['num'];
-        			$where['mid'] = $v['mid'];
-        			$total = Dever::db('bill/sell')->getNumByTimeOne($where);
-        			if ($total) {
-        				$w['num'] = $total['num'];
-        			}
-        			if ($info) {
-        				$w['where_id'] = $info['id'];
-        				Dever::db('bill/sell_stat')->update($w);
-        			} else {
-        				Dever::db('bill/sell_stat')->insert($w);
-        			}
-        		}
+                    $w['mid'] = $v['mid'];
+                    $w['month'] = $where['start'];
+                    $info = Dever::db('bill/sell_stat')->find($w);
+                    $w['new_ztnum'] = $v['num'];
+                    $where['mid'] = $v['mid'];
+                    $total = Dever::db('bill/sell')->getNumByTimeOne($where);
+                    if ($total) {
+                        $w['zt_num'] = $total['num'];
+                    }
+                    if ($info) {
+                        $w['where_id'] = $info['id'];
+                        Dever::db('bill/sell_stat')->update($w);
+                    } else {
+                        Dever::db('bill/sell_stat')->insert($w);
+                    }
+                }
+                }
+        		
         	}
         }