Your Name 2 năm trước cách đây
mục cha
commit
4db88c41d8
2 tập tin đã thay đổi với 90 bổ sung48 xóa
  1. 15 0
      app/shop/database/buy_order.php
  2. 75 48
      service/mail/lib/Manage.php

+ 15 - 0
app/shop/database/buy_order.php

@@ -915,6 +915,21 @@ $config = array
         ),
          # 区域查询
         'getSerachMoney' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'area' => array('yes', 'like'),
+                'type' => 1,
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(price) as total',
+        ),
+        'getSerachTMoney' => array
         (
             # 匹配的正则或函数 选填项
             'option' => array

+ 75 - 48
service/mail/lib/Manage.php

@@ -576,6 +576,7 @@ class Manage
     #区域分润
     public function area_api(){
         $month = Dever::input('month', date('Y-m'));
+        $month = '2022-05-01';
         $start_time = $month .'-01 00:00:00';
         $where = array();
         $end_time = date('Y-m-d', strtotime($start_time. ' +1 month -1 day')).' 23:59:59';
@@ -591,30 +592,40 @@ class Manage
         $data = array_values($data);
         foreach($data as $k => $v){
             $w['month'] = $where['start'];
-            #街道
-            if($v['town']>0){
-                $where['area'] = $v['town'];
-                $data[$k]['towns']['area'] = $v['province'].','.$v['city'].','.$v['county'].','.$v['town'];
-                $data[$k]['towns']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
-                $data[$k]['towns']['price']= round($data[$k]['towns']['money']['total']) * 0.3*0.05;
+            #城市
+            if($v['city']>0){
+                $where['area'] = $v['city'];
+                $data[$k]['citys']['area'] = $v['province'].','.$v['city'];
+                $data[$k]['citys']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
+
+                $data[$k]['citys']['price']= round($data[$k]['citys']['money']['total']) * 0.3*0.01;
                 $mid = Dever::db('agent/member')->getAreaAll($where);
-                $data[$k]['towns']['mid'] = $mid['id'];
-                $whe['town'] = $v['town'];
-                $data[$k]['towns']['num'] = Dever::db('shop/info')->getSerachNum($whe);
+                $w['citys']['area'] = $v['city'];
+                $data[$k]['citys']['mid'] = $mid['id'];
+                $where['city'] = $v['city'];
+                $data[$k]['citys']['num'] = Dever::db('shop/info')->getSerachNum($where);
                 #体验店
-                $t_shop = Dever::db('shop/info')->getAreaAll(array('town'=>$v['town'],'type'=>1,'state'=>1));
-                $data[$k]['towns']['type'] = array_column($t_shop,'id');
-                $where['type_id'] = implode(',',$data[$k]['towns']['type']);
-                $data[$k]['towns']['t_price'] = Dever::db('shop/buy_order')->getSerachMoney($where);
-                $data[$k]['towns']['t_num'] = Dever::db('shop/info')->getSerachTNum($where);
-                $w['mid'] = $data[$k]['towns']['mid'];
-                $w['area'] = $data[$k]['towns']['area'];
-                $w['price'] = $data[$k]['towns']['price'];
-                $w['num'] = $data[$k]['towns']['num'];
-                $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'];
-                $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['towns']['area']));
+                $t_shop = Dever::db('shop/info')->getAreaAll(array('city'=>$v['city'],'type'=>1,'state'=>1));
+                $data[$k]['citys']['type'] = array_column($t_shop,'id');
+                $where['type_id'] = implode(',',$data[$k]['citys']['type']);
+                $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')->getSerachMoney($where);
+                    
+                }else{
+                    $data[$k]['citys']['t_price'] = 0;
+                }
+                
+                
+                // Dever::db('shop/info')->getSerachTNum($where);
+                $w['mid'] = $data[$k]['citys']['mid'];
+                $w['area'] = $data[$k]['citys']['area'];
+                $w['price'] = $data[$k]['citys']['price'];
+                $w['c_price'] = $data[$k]['citys']['money']['total'];
+                $w['num'] = $data[$k]['citys']['num'];
+                $w['t_num'] = $data[$k]['citys']['t_num'];
+                $w['t_price'] = $data[$k]['citys']['t_price']['total'];
+                $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['citys']['area']));
                 if(!$shop){
                     Dever::db('mail/area_stat')->insert($w);
                 }else{
@@ -622,11 +633,13 @@ class Manage
                     Dever::db('mail/area_stat')->update($w);
                 }
             }
+            
             #区县
             if($v['county']>0){
                 $where['area'] = $v['county'];
                 $data[$k]['countys']['area'] = $v['province'].','.$v['city'].','.$v['county'];
                 $data[$k]['countys']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
+
                 $data[$k]['countys']['price']= round($data[$k]['countys']['money']['total']) * 0.3*0.03;
                 $mid = Dever::db('agent/member')->getAreaAll($where);
                 $data[$k]['countys']['mid'] = $mid['id'];
@@ -636,8 +649,15 @@ class Manage
                 $t_shop = Dever::db('shop/info')->getAreaAll(array('county'=>$v['county'],'type'=>1,'state'=>1));
                 $data[$k]['countys']['type'] = array_column($t_shop,'id');
                 $where['type_id'] = implode(',',$data[$k]['countys']['type']);
-                $data[$k]['countys']['t_price'] = Dever::db('shop/buy_order')->getSerachMoney($where);
-                $data[$k]['countys']['t_num'] = Dever::db('shop/info')->getSerachTNum($where);
+                $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);
+                }else{
+                    $data[$k]['countys']['t_price'] = 0;
+                }
+                
+                
+                // Dever::db('shop/info')->getSerachTNum($where);
 
                 $w['mid'] = $data[$k]['countys']['mid'];
                 $w['area'] = $data[$k]['countys']['area'];
@@ -654,39 +674,46 @@ class Manage
                     Dever::db('mail/area_stat')->update($w);
                 }
             }
-            #城市
-            if($v['city']>0){
-                $where['area'] = $v['city'];
-                $data[$k]['citys']['area'] = $v['province'].','.$v['city'];
-                $data[$k]['citys']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
-                $data[$k]['citys']['price']= round($data[$k]['citys']['money']['total']) * 0.3*0.01;
+            #街道
+            if($v['town']>0){
+                $where['area'] = $v['town'];
+                $data[$k]['towns']['area'] = $v['province'].','.$v['city'].','.$v['county'].','.$v['town'];
+                $data[$k]['towns']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
+                $data[$k]['towns']['price']= round($data[$k]['towns']['money']['total']) * 0.3*0.05;
                 $mid = Dever::db('agent/member')->getAreaAll($where);
-                $w['citys']['area'] = $v['city'];
-                $data[$k]['citys']['mid'] = $mid['id'];
-                $where['city'] = $v['city'];
-                $data[$k]['citys']['num'] = Dever::db('shop/info')->getSerachNum($where);
+                $data[$k]['towns']['mid'] = $mid['id'];
+                $whe['town'] = $v['town'];
+                $data[$k]['towns']['num'] = Dever::db('shop/info')->getSerachNum($whe);
                 #体验店
-                $t_shop = Dever::db('shop/info')->getAreaAll(array('city'=>$v['city'],'type'=>1,'state'=>1));
-                $data[$k]['citys']['type'] = array_column($t_shop,'id');
-                $where['type_id'] = implode(',',$data[$k]['citys']['type']);
-                $data[$k]['citys']['t_price'] = Dever::db('shop/buy_order')->getSerachMoney($where);
-                $data[$k]['citys']['t_num'] = Dever::db('shop/info')->getSerachTNum($where);
-                $w['mid'] = $data[$k]['citys']['mid'];
-                $w['area'] = $data[$k]['citys']['area'];
-                $w['price'] = $data[$k]['citys']['price'];
-                $w['c_price'] = $data[$k]['citys']['money']['total'];
-                $w['num'] = $data[$k]['citys']['num'];
-                $w['t_num'] = $data[$k]['citys']['t_num'];
-                $w['t_price'] = $data[$k]['citys']['t_price']['total'];
-                $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['citys']['area']));
+                $t_shop = Dever::db('shop/info')->getAreaAll(array('town'=>$v['town'],'type'=>1,'state'=>1));
+                $data[$k]['towns']['type'] = array_column($t_shop,'id');
+                $where['type_id'] = implode(',',$data[$k]['towns']['type']);
+                $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);
+                }else{
+                    $data[$k]['towns']['t_price'] = 0;
+                }
+                
+                
+                // Dever::db('shop/info')->getSerachTNum($where);
+                $w['mid'] = $data[$k]['towns']['mid'];
+                $w['area'] = $data[$k]['towns']['area'];
+                $w['price'] = $data[$k]['towns']['price'];
+                $w['num'] = $data[$k]['towns']['num'];
+                $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'];
+                $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);
                 }else{
                     $w['where_id'] = $shop['id'];
                     Dever::db('mail/area_stat')->update($w);
                 }
-            } 
+            }
         }
+        print_R($data);die;
         return 'ok';
     }
     public function area_member($id){