rabin 2 years ago
parent
commit
00cef614c1
2 changed files with 35 additions and 12 deletions
  1. 19 12
      service/agent/lib/Member.php
  2. 16 0
      service/bill/database/sell.php

+ 19 - 12
service/agent/lib/Member.php

@@ -680,23 +680,30 @@ class Member
         if($end){
             $where['end'] = $end;
         }
-        $where['parent_mid'] = $id;
+        $where['mid'] = $id;
         $where['state'] = 1;
-        $info = Dever::db('agent/member')->getNewParent($where);
+        $where['type'] = 2;
+        $info = Dever::db('bill/sell')->getNewChildParent($where);
         $temp = array();
         $sell = 0;
-        foreach ($info as $key => $val) {
-            $temp[] = $val['group_sell']; // 用一个空数组来承接字段
-            $sell += $val['group_sell'];
-        }
-        if($temp){
-            // if($info['title_id'] == 4 || $info['title_id'] == 5){
+        $max = count($info);
+        if ($max > 1) {
+            foreach ($info as $key => $val) {
+                $temp[] = $val['total']; // 用一个空数组来承接字段
+                $sell += $val['total'];
+            }
+            if($temp){
                 $total = sprintf ('%01.2f',$sell - max($temp));
-            // }
-            
-        }else{
-            $total = sprintf ('%01.2f',$sell);
+            }else{
+                $total = sprintf ('%01.2f',$sell);
+            }
+        } else {
+            $total = 0;
+            foreach ($info as $key => $val) {
+                $total += $val['total'];
+            }
         }
+        
         return $total;
     }
     #新增正常业绩

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

@@ -308,6 +308,22 @@ return array
             'col' => 'sum(num) as total',
         ),
 
+        'getNewChildParent' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate','>='),
+                'end' => array('yes-cdate','<='),
+                'mid' => 'yes',
+                'type' => 'yes',
+                'state' => 1,
+            ),
+            'group' => 'child_mid',
+            'type' => 'all',
+            'col' => 'child_mid,sum(num) as total|child_mid',
+        ),
+
         'getChildData' => array
         (
             # 匹配的正则或函数 选填项