Your Name 2 years ago
parent
commit
2cce91effb

+ 1 - 1
service/agent/database/member.php

@@ -758,7 +758,7 @@ return array
             'option' => array
             (
                 'id' => 'yes',
-                'role' => 'yes',
+                'role' => array('yes','in'),
                 'prize_type' => 'yes',
                 'state' => 1,
             ),

+ 15 - 1
service/agent/database/order.php

@@ -903,7 +903,7 @@ return array
                 'start' => array('yes-cdate','>='),
                 'end' => array('yes-cdate','<='),
                 'mid' => 'yes',
-                'role' => 'yes',
+                'role' => array('yes','in'),
                 'state' => 1,
             ),
             'type' => 'one',
@@ -924,5 +924,19 @@ return array
             'type' => 'all',
             'col' => '*',
         ),
+        'getSum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-fdate', '>='),
+                'end' => array('yes-fdate', '<='),
+                'status' => array('yes', 'in'),
+                'role' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(price) as total',
+        ),
     ),
 );

+ 36 - 1
service/agent/database/soft_cash.php

@@ -14,6 +14,13 @@ $manage_audit = array
     2 => '已审核',
     3 => '已作废',
 );
+$type = array
+(
+    -1 => '请选择',
+    1 => '未签署',
+    2 => '已签署',
+    3 => '已作废',
+);
 
 $insert = false;
 $col = Dever::input('col');
@@ -28,6 +35,7 @@ return array
     'lang' => '软件服务费',
     'menu' => true,
     'config_status' => $status,
+    'config_type' => $type,
     'start' => array
     (
         'insert' => 'agent/lib/soft_cash.insertSoft',
@@ -152,7 +160,10 @@ return array
             'match'     => 'is_numeric',
             // 'update'    => 'radio',
             'option'    => $status,
-            'list'      => true,
+            'search'    => 'select',
+            'list_name' =>'订单状态<br/>合同签署状态<br/>终审时间',
+            'list'      => 'Dever::load("agent/lib/soft_cash.list",{id})',
+
         ),
         'audit'        => array
         (
@@ -180,6 +191,20 @@ return array
             'show'      => 'audit=3',
         ),
 
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '合同签署状态',
+            'default'   => '-1',
+            'desc'      => '合同签署状态',
+            'match'     => 'is_numeric',
+            // 'update'    => 'radio',
+            'option'    => $type,
+            'search'    => 'select',
+            // 'list'      => 'Dever::load("agent/lib/soft_cash.agreement",{id})',
+
+        ),
+
         'admin_desc'      => array
         (
             'type'      => 'varchar-600',
@@ -203,6 +228,16 @@ return array
             // 'list'        => '{buy_date} > 0 ? date("Y-m-d H:i", {buy_date}) : "无"',
         ),
 
+        'zdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '终审时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            // 'search'    => 'date',
+            'desc'      => '',
+            // 'list'      => 'date("Y-m-d H:i:s", {zdate})',
+        ),
         'state'     => array
         (
             'type'      => 'tinyint-1',

+ 26 - 1
service/agent/lib/Soft_cash.php

@@ -56,9 +56,10 @@ Class Soft_cash
                
                 if($audit == 3){
                     $update['set_status'] = 4;
+
                 }elseif($audit == 2){
                     $update['set_status'] = 3;
-
+                    $update['set_zdate'] = time();
                     $order['role'] = $info['role'];
                     $order['soft_cash'] = $cash;
                     $order['price'] = $cash;
@@ -329,4 +330,28 @@ Class Soft_cash
             return '';
         }
     }
+    public function agreement($id){
+        $info = Dever::db('agent/soft_cash')->find($id);
+        $status = '';
+        if($info['status'] == 3 && $info['agreement_id']){
+            $agreement = Dever::db('agent/member_agreement')->find(array('id' => $info['agreement_id']));
+            $status = $agreement['status'];
+        }
+        $where['id'] = $id;
+        $where['type'] = $status;
+        dever::db('agent/soft_cash')->update($where);
+    }
+    public function list($id){
+        $this->agreement($id);
+        $info = Dever::db('agent/soft_cash')->find($id);
+         $config_status = Dever::db('agent/soft_cash')->config['config_status'];
+        $data['status'] = Dever::status($config_status,$info['status']);
+        $config_type = Dever::db('agent/soft_cash')->config['config_type'];
+        $data['type'] = Dever::status($config_type,$info['type']);
+        $data['zdate'] = date('Y-m-d H:i',$info['zdate']);
+         $html = $data['status'];
+        $html .= '<br />' . $data['type'];
+        $html .= '<br />' . $data['zdate'];
+        return $html; 
+    }
 }

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

@@ -131,6 +131,17 @@ $config = array
             'list'      => true,
         ),
 
+        'jt_cash'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '间推佣金',
+            'default'   => '0',
+            'desc'      => '间推佣金',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',

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

@@ -125,6 +125,17 @@ $config = array
             'list'      => true,
         ),
 
+        'cv_num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '创V',
+            'default'   => '0',
+            'desc'      => '创V',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',

+ 99 - 40
service/bill/lib/Cron.php

@@ -243,6 +243,9 @@ class Cron
             $where['role'] = 6;
             $data['ck_num'] = Dever::db('agent/member')->getNum($where);
 
+            $where['role'] = 8;
+            $data['cv_num'] = Dever::db('agent/member')->getNum($where);
+
 
             if (!$info) {
                 Dever::db('bill/member_stat')->insert($data);
@@ -322,6 +325,13 @@ class Cron
             if ($cash) {
                 $data['sd_cash'] = $cash['total'];
             }
+            #间推
+            $where['type'] =3;
+            $whehre['jt_cash'] =0;
+            $cash = Dever::db('bill/cash')->getCash($where);
+            if ($cash) {
+                $data['jt_cash'] = $cash['total'];
+            }
 
             $data['cash'] = $data['daili_cash'] + $data['soft_cash'] - $data['goods_cash'] - $data['sc_cash'] - $data['zt_cash'] - $data['hd_cash'] - $data['sd_cash'];
 
@@ -465,58 +475,102 @@ class Cron
         $end_time = date('Y-m-d', strtotime($start_time. ' +1 month -1 day')).' 23:59:59';
         $start = Dever::maketime($start_time);
         $end = Dever::maketime($end_time);
-        $shop = Dever::db('shop/info')->getAll();
+        $shops = Dever::db('shop/info')->getAll();
+        foreach($shops as $key => $val){
+            $logs = Dever::db('agent/member_shop_log')->getGui(array('start'=>$start,'end'=>$end,'new_shop_id'=>$val['id'],'state'=>1));
+        }
+        foreach($shops as $s=>$sv){
+            foreach($logs as $l => $lv){
+                if($lv['new_shop_id'] == $sv['id']){
+                    $sv['mid'][] = $lv['mid'];
+                    $shops[] = $sv;
+                }else{
+                    unset($shops[$s]);
+                }
+            }
+        }
+        // print_R($shops);die;
+        $data=array_unique($shops, SORT_REGULAR);
+        $rest=array();
+        foreach($data as $k=>$v){
+            $rest[$v['id']]=$v;
+        }
+        $shop=array_values($rest);
         foreach($shop as $k => $v){
-            #代理商总数量
-            $shop[$k]['num'] = Dever::db('agent/member_shop_log')->getAll(array('start'=>$start,'end'=>$end,'new_shop_id'=>$v['id'],'state'=>1));
-            $log = Dever::db('agent/member_shop_log')->getGui(array('start'=>$start,'end'=>$end,'new_shop_id'=>$v['id'],'state'=>1));   
-            foreach($log as $k1 => $v1){
-                if($v['id'] == $v1['new_shop_id']){
-                    #创V数量
-                    $v_num[] = Dever::db('agent/member')->getCount(array('id'=>$v1['mid'],'role'=>8,'state'=>1));
-                    #创V名额外数量
-                    $out_num[] = Dever::db('agent/member')->getCount(array('id'=>$v1['id'],'role'=>8,'prize_type'=>1,'state'=>1));
-                    #代理商业绩
-                    $shop[$k]['money'][] = Dever::db('agent/order')->getCount(array('start'=>$start,'end'=>$end,'mid'=>$v1['mid'],'state'=>1));
-                    #创V业绩
-                    $shop[$k]['v_money'][] = Dever::db('agent/order')->getVCount(array('start'=>$start,'end'=>$end,'mid'=>$v1['mid'],'role'=>8,'state'=>1));
-                    #创V名额外业绩
-                    $out[] = Dever::db('agent/member')->find(array('id'=>$v1['mid'],'role'=>8,'prize_type'=>1,'state'=>1));
-                } 
-            }
-            if(isset($out) && $out){
+             $shop[$k]['num'] = Dever::db('agent/member_shop_log')->getAll(array('start'=>$start,'end'=>$end,'new_shop_id'=>$v['id'],'state'=>1));
+             foreach($v['mid'] as $k1 => $v1){
+                #除去创V的代理数量
+                $shop[$k]['dl_num'][] = Dever::db('agent/member')->getCount(array('id'=>$v1,'role'=>'1,2,3,4,5,6,7','state'=>1));
+                #创V数量
+                $shop[$k]['v_num'][] = Dever::db('agent/member')->getCount(array('id'=>$v1,'role'=>8,'state'=>1));
+                #创V名额外数量
+                $shop[$k]['out_num'][] = Dever::db('agent/member')->getCount(array('id'=>$v1,'role'=>8,'prize_type'=>1,'state'=>1));
+                // #创V名额内数量
+                $shop[$k]['nei_num'][] = Dever::db('agent/member')->getCount(array('id'=>$v1,'role'=>8,'prize_type'=>2,'state'=>1));
+                #代理商业绩
+                $shop[$k]['money'][] = Dever::db('agent/order')->getCount(array('start'=>$start,'end'=>$end,'mid'=>$v1,'state'=>1));
+                #除去创V的代理商业绩
+                $shop[$k]['dl_money'][] = Dever::db('agent/order')->getVCount(array('start'=>$start,'end'=>$end,'mid'=>$v1,'role'=>'1,2,3,4,5,6,7','state'=>1));
+                #创V业绩
+                $shop[$k]['v_money'][] = Dever::db('agent/order')->getVCount(array('start'=>$start,'end'=>$end,'mid'=>$v1,'role'=>8,'state'=>1));
+                #创V名额外业绩
+                $out[] = Dever::db('agent/member')->find(array('id'=>$v1,'role'=>8,'prize_type'=>1));
+                #创V名额内业绩
+                $nei[] = Dever::db('agent/member')->find(array('id'=>$v1,'role'=>8,'prize_type'=>2));
+             }
+             if(isset($out) && $out){
                 foreach($out as $a => $b){
                     if(isset($b['id']) && $b['id']){
                         $shop[$k]['out_money'][] = Dever::db('agent/order')->getVCount(array('start'=>$start,'end'=>$end,'mid'=>$b['id'],'role'=>8,'state'=>1));
                     }
                 }
             }
+            if(isset($nei) && $nei){
+                foreach($nei as $a => $b){
+                    if(isset($b['id']) && $b['id']){
+                        $shop[$k]['nei_money'][] = Dever::db('agent/order')->getVCount(array('start'=>$start,'end'=>$end,'mid'=>$b['id'],'role'=>8,'state'=>1));
+                    }
+                }
+            }
+            #除创V的代理商数量
+            if(isset($shop[$k]['dl_num']) && $shop[$k]['dl_num']){
+                $shop[$k]['dl_num'] = array_sum($shop[$k]['dl_num']);
+            }else{
+                $shop[$k]['dl_num'] = 0;
+            }
             #创V总数量
-            if(isset($v_num) && $v_num){
-                $shop[$k]['v_num'] = array_sum($v_num);
+            if(isset($shop[$k]['v_num']) && $shop[$k]['v_num']){
+                $shop[$k]['v_num'] = array_sum($shop[$k]['v_num']);
             }else{
                 $shop[$k]['v_num'] = 0;
             }
             #创V名额内外的数量
-            if(isset($out_num) && $out_num){
-                $shop[$k]['out_num'] = array_sum($out_num);
-                $shop[$k]['nei_num'] = $shop[$k]['v_num'] - $shop[$k]['out_num'];
+            if(isset($shop[$k]['out_num']) && $shop[$k]['out_num']){
+                $shop[$k]['out_num'] = array_sum($shop[$k]['out_num']);
             }else{
                 $shop[$k]['out_num'] = 0;
+            }
+             if(isset($shop[$k]['nei_num']) && $shop[$k]['nei_num']){
+                $shop[$k]['nei_num'] = array_sum($shop[$k]['nei_num']);
+            }else{
                 $shop[$k]['nei_num'] = 0;
             }
-            #除去创V的代理商总数量
-            $shop[$k]['dl_num'] = $shop[$k]['num'] - $shop[$k]['v_num'];
-            
         }
+        // print_R($shop);die;
         foreach($shop as $key => $val){
+            // print_R($val);die;
             #代理商的总业绩
             if(isset($val['money']) && $val['money']){
                 $shop[$key]['money'] = array_sum(array_map(function($val){return $val['total'];}, $val['money']));
             }else{
                 $shop[$key]['money'] = 0;
             }
-            
+            #除创V的代理商业绩
+            if(isset($val['dl_money']) && $val['dl_money']){
+                $shop[$key]['dl_money'] = array_sum(array_map(function($val){return $val['total'];}, $val['dl_money']));
+            }else{
+                $shop[$key]['dl_money'] = 0;
+            }
             #创V总业绩
             if(isset($val['v_money']) && $val['v_money']){
                 $shop[$key]['v_money'] = array_sum(array_map(function($val){return $val['total'];}, $val['v_money']));
@@ -525,13 +579,15 @@ class Cron
             }
             if(isset($val['out_money']) && $val['out_money']){
                 $shop[$key]['out_money'] = array_sum(array_map(function($val){return $val['total'];}, $val['out_money']));
-                $shop[$key]['nei_money'] = $shop[$key]['v_money'] - $shop[$key]['out_money'];
             }else{
                 $shop[$key]['out_money'] = 0;
+            }
+            if(isset($val['nei_money']) && $val['nei_money']){
+                $shop[$key]['nei_money'] = array_sum(array_map(function($val){return $val['total'];}, $val['nei_money']));
+            }else{
                 $shop[$key]['nei_money'] = 0;
             }
-            
-            $shop[$key]['dl_money'] = $shop[$key]['money']-$shop[$key]['v_money'];
+           
             $insert['shop_id'] = $val['id'];
             $insert['num'] = $val['num'];
             $insert['dl_num'] = $val['dl_num'];
@@ -545,15 +601,18 @@ class Cron
             $insert['out_money'] = $shop[$key]['out_money'];
             $insert['nei_money'] = $shop[$key]['nei_money'];
 
-            $res = Dever::db('bill/shop_stat')->find(array('month'=>$start));
-            if($res){
-                $insert['where_id'] = $res['id'];
-                Dever::db('bill/shop_stat')->update($insert);
-            }else{
-                Dever::db('bill/shop_stat')->insert($insert);
-            }
-            
-        }
+            if($insert){
+                $res = Dever::db('bill/shop_stat')->state(array('month'=>$start,'shop_id'=>$insert['shop_id']));
+                if($res){
+                    foreach($res as $k2 => $v2){
+                        $insert['where_id'] = $v2['id'];
+                        Dever::db('bill/shop_stat')->update($insert);
+                    } 
+                }else{
+                    Dever::db('bill/shop_stat')->insert($insert);
+                }     
+            }
+        }        
         return 'ok';
     }
 }