Your Name 2 years ago
parent
commit
c1a1d9b759
3 changed files with 107 additions and 8 deletions
  1. 30 0
      service/agent/src/My.php
  2. 56 0
      service/mail/database/area_stat.php
  3. 21 8
      service/mail/lib/Manage.php

+ 30 - 0
service/agent/src/My.php

@@ -94,6 +94,8 @@ class My extends Core
                 list($temp, $this->data['user']['agreement_4']) = Dever::load('agent/lib/agreement')->name($agreement[4], $order, $order['role'], 1, 2);
             }
         }
+        #获取区域分润
+        $this->data['fenrun'] = Dever::db('mail/area_stat')->getMoney(array('mid'=>$this->uid));
         
         return $this->data;
     }
@@ -1126,4 +1128,32 @@ class My extends Core
         $id = Dever::input('id');
         return Dever::load('agent/address')->del($this->uid, $id, 2);
     }
+    #获取体验店和零售店区域分润
+    public function getAreastat(){
+        $this->data['data'] = Dever::db('mail/area_stat')->getTy(array('mid'=>$this->uid));
+        return $this->data;
+    }
+    #获取体验店和零售店区域分润列表
+    public function getAreadesc(){
+        $type = Dever::input('type');#1=体验店,2=零售店
+        $data = array();
+        if (!$type) {
+            $type = 1;
+        }
+        $res = Dever::db('mail/area_stat')->getTy(array('mid'=>$this->uid));
+        $data['list'] = Dever::db('mail/area_stat')->getTiyan(array('mid'=>$this->uid));
+        if ($type == 1) {
+            $price = 't_fprice';
+        } else {
+            $price = 'l_fprice';
+        }
+        $data['total']= $res[$price];
+        if ($data['list']) {
+            foreach ($data['list'] as $k => $v) {
+                $data['list'][$k]['month'] = date('Y年m月',$v['month']);
+                $data['list'][$k]['price'] = $v[$price];
+            }
+        }
+        return $data;
+    }
 }

+ 56 - 0
service/mail/database/area_stat.php

@@ -129,6 +129,16 @@ return array
             // 'update'    => 'text',
             'list'      => true,
         ),
+        't_fprice'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '体验店分润金额',
+            'default'   => '0',
+            'desc'      => '体验店分润金额',
+            'match'     => 'is_numeric',
+            // 'update'    => 'text',
+            'list'      => true,
+        ),
 
         'price'      => array
         (
@@ -164,6 +174,17 @@ return array
             'list'      => true,
         ),
 
+        'l_fprice'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '零售店分润金额',
+            'default'   => '0',
+            'desc'      => '零售店分润金额',
+            'match'     => 'is_numeric',
+            // 'update'    => 'text',
+            // 'list'      => true,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -221,5 +242,40 @@ return array
             # 允许自定义以上配置
             'config' => true,
         ),
+        'getMoney' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'mid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(price) as  price',
+        ),
+        'getTy' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'mid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'group' => 'mid',
+            'col' => 'sum(t_fprice) as t_fprice,sum(l_fprice) as l_fprice',
+        ),
+        'getTiyan' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'mid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('month'=>'desc'),
+            'col' => 't_fprice,l_fprice,month',
+        ),
     ),
 );

+ 21 - 8
service/mail/lib/Manage.php

@@ -659,16 +659,17 @@ class Manage
                 $data[$k]['citys']['t_num'] = count($t_shop);
                 if($data[$k]['citys']['t_num']>0){
                     $data[$k]['citys']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
-                    
+                    $data[$k]['citys']['t_fprice'] = $data[$k]['citys']['t_price']['total'] * 0.01;
                 }else{
                     $data[$k]['citys']['t_price'] = 0;
+                    $data[$k]['citys']['t_fprice'] = 0;
                 }
                 #零售店
                 $shop_area = $this->ls($where,1);
-                // print_R($where);die;
-                $data[$k]['citys']['l_price'] =$shop_area['price'] * 0.01;
+                $data[$k]['citys']['l_price'] =$shop_area['price'];
+                $data[$k]['citys']['l_fprice'] =$shop_area['price'] * 0.01;
                 $data[$k]['citys']['l_num'] = $shop_area['num'];
-                $data[$k]['citys']['price'] = $data[$k]['citys']['price'] + $data[$k]['citys']['l_price'];
+                $data[$k]['citys']['price'] = $data[$k]['citys']['price'] + $data[$k]['citys']['l_fprice'];
                 $w['mid'] = $data[$k]['citys']['mid'];
                 $w['area'] = $data[$k]['citys']['area'];
                 $w['price'] = $data[$k]['citys']['price'];
@@ -676,8 +677,10 @@ class Manage
                 $w['num'] = $data[$k]['citys']['num'];
                 $w['t_num'] = $data[$k]['citys']['t_num'];
                 $w['t_price'] = $data[$k]['citys']['t_price']['total'];
+                $w['t_fprice'] = $data[$k]['citys']['t_fprice'];
                 $w['l_num'] = $data[$k]['citys']['l_num'];
                 $w['l_price'] = $shop_area['price'];
+                $w['l_fprice'] = $data[$k]['citys']['l_fprice'];
 
                 $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['citys']['area']));
                 if(!$shop){
@@ -711,16 +714,19 @@ class Manage
                 $data[$k]['countys']['t_num'] = count($t_shop);
                 if($data[$k]['countys']['t_num']>0){
                     $data[$k]['countys']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
+                    $data[$k]['countys']['t_fprice'] = $data[$k]['countys']['t_price']['total'] * 0.03;
                 }else{
                     $data[$k]['countys']['t_price'] = 0;
+                    $data[$k]['countys']['t_fprice'] = 0;
                 }
 
                 #零售店
                 $where['county'] = $v['county'];
                 $shop_area = $this->ls($where,2);
-                $data[$k]['countys']['l_price'] = $shop_area['price'] * 0.03;
+                $data[$k]['countys']['l_price'] = $shop_area['price'];
+                $data[$k]['countys']['l_fprice'] = $shop_area['price'] * 0.03;
                 $data[$k]['countys']['l_num'] = $shop_area['num'];
-                $data[$k]['countys']['price'] = $data[$k]['countys']['price'] + $data[$k]['countys']['l_price'];
+                $data[$k]['countys']['price'] = $data[$k]['countys']['price'] + $data[$k]['countys']['l_fprice'];
 
                 $w['mid'] = $data[$k]['countys']['mid'];
                 $w['area'] = $data[$k]['countys']['area'];
@@ -729,8 +735,10 @@ class Manage
                 $w['c_price'] = $data[$k]['countys']['money']['total'];
                 $w['t_num'] = $data[$k]['countys']['t_num'];
                 $w['t_price'] = $data[$k]['countys']['t_price']['total'];
+                $w['t_fprice'] = $data[$k]['countys']['t_fprice'];
                 $w['l_num'] = $data[$k]['countys']['l_num'];
                 $w['l_price'] = $shop_area['price'];
+                $w['l_fprice'] = $data[$k]['countys']['l_fprice'];
                 $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['countys']['area']));
                 if(!$shop){
                     Dever::db('mail/area_stat')->insert($w);
@@ -763,16 +771,19 @@ class Manage
                 $data[$k]['towns']['t_num'] = count($t_shop);
                 if($data[$k]['towns']['t_num']>0){
                     $data[$k]['towns']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
+                    $data[$k]['towns']['t_fprice'] = $data[$k]['towns']['t_price']['total'] *0.05;
                 }else{
                     $data[$k]['towns']['t_price'] = 0;
+                    $data[$k]['towns']['t_fprice'] = 0;
                 }
 
                 #零售店
                 $where['town'] = $v['town'];
                 $shop_area = $this->ls($where,3);
-                $data[$k]['towns']['l_price'] =$shop_area['price'] * 0.05;
+                $data[$k]['towns']['l_price'] =$shop_area['price'];
+                $data[$k]['towns']['l_fprice'] =$shop_area['price'] * 0.05;
                 $data[$k]['towns']['l_num'] = $shop_area['num'];
-                $data[$k]['towns']['price'] = $data[$k]['towns']['price'] + $data[$k]['towns']['l_price'];
+                $data[$k]['towns']['price'] = $data[$k]['towns']['price'] + $data[$k]['towns']['l_fprice'];
 
                 $w['mid'] = $data[$k]['towns']['mid'];
                 $w['area'] = $data[$k]['towns']['area'];
@@ -781,8 +792,10 @@ class Manage
                 $w['c_price'] = $data[$k]['towns']['money']['total'];
                 $w['t_num'] = $data[$k]['towns']['t_num'];
                 $w['t_price'] = $data[$k]['towns']['t_price']['total'];
+                $w['t_fprice'] = $data[$k]['towns']['t_fprice'];
                 $w['l_num'] = $data[$k]['towns']['l_num'];
                 $w['l_price'] = $shop_area['price'];
+                $w['l_fprice'] = $data[$k]['towns']['l_fprice'];
                 $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['towns']['area']));
                 if(!$shop){
                     Dever::db('mail/area_stat')->insert($w);