|
@@ -573,4 +573,130 @@ class Manage
|
|
|
$data['total_price'] = $data['a_price'] + $data['a_noprice'];
|
|
|
return Dever::render('soft_cash', $data);
|
|
|
}
|
|
|
+
|
|
|
+ public function area_api(){
|
|
|
+ $month = Dever::input('month', date('Y-m'));
|
|
|
+ $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';
|
|
|
+ $where['start'] = Dever::maketime($start_time);
|
|
|
+ $where['end'] = Dever::maketime($end_time);
|
|
|
+ $where['state'] = 1;
|
|
|
+
|
|
|
+ $data = array();
|
|
|
+ $shop = Dever::db('shop/info')->getAreaAll(array('state'=>1));
|
|
|
+ foreach($shop as $k=>$v){
|
|
|
+ $data[$v['city']]=$v;
|
|
|
+ }
|
|
|
+ $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;
|
|
|
+ $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);
|
|
|
+
|
|
|
+ $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']));
|
|
|
+ if(!$shop){
|
|
|
+ Dever::db('mail/area_stat')->insert($w);
|
|
|
+ }else{
|
|
|
+ $w['where_id'] = $shop['id'];
|
|
|
+ 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'];
|
|
|
+ $wh['county'] = $v['county'];
|
|
|
+ $data[$k]['countys']['num'] = Dever::db('shop/info')->getSerachNum($wh);
|
|
|
+
|
|
|
+ $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);
|
|
|
+
|
|
|
+ $w['mid'] = $data[$k]['countys']['mid'];
|
|
|
+ $w['area'] = $data[$k]['countys']['area'];
|
|
|
+ $w['price'] = $data[$k]['countys']['price'];
|
|
|
+ $w['num'] = $data[$k]['countys']['num'];
|
|
|
+ $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'];
|
|
|
+ $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);
|
|
|
+ }else{
|
|
|
+ $w['where_id'] = $shop['id'];
|
|
|
+ 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;
|
|
|
+ $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);
|
|
|
+
|
|
|
+ $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']));
|
|
|
+ if(!$shop){
|
|
|
+ Dever::db('mail/area_stat')->insert($w);
|
|
|
+ }else{
|
|
|
+ $w['where_id'] = $shop['id'];
|
|
|
+ Dever::db('mail/area_stat')->update($w);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 'ok';
|
|
|
+ }
|
|
|
+ public function area_member($id){
|
|
|
+ $info = Dever::db('mail/area_stat')->find($id);
|
|
|
+ if($info['mid']){
|
|
|
+ $member = Dever::db('agent/member')->find($info['mid']);
|
|
|
+ $res = $member['name'].'<br/>'.$member['mobile'];
|
|
|
+ }else{
|
|
|
+ $res = '-';
|
|
|
+ }
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
}
|