|  | @@ -489,63 +489,49 @@ class Cron
 | 
	
		
			
				|  |  |          $w['end'] = $end;
 | 
	
		
			
				|  |  |          $w['status'] = '2,3,4,5,6';
 | 
	
		
			
				|  |  |          $data = Dever::db('shop/sell_order')->getAllByDate($w);
 | 
	
		
			
				|  |  | -        print_r($data);die;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if ($data) {
 | 
	
		
			
				|  |  |              $where = array();
 | 
	
		
			
				|  |  | +            $result = array();
 | 
	
		
			
				|  |  |              foreach ($data as $k => $v) {
 | 
	
		
			
				|  |  |                  $day = Dever::maketime(date('Y-m-d 00:00:00', $v['cdate']));
 | 
	
		
			
				|  |  | -                $where['shop_id'] = $v['shop_id'];
 | 
	
		
			
				|  |  | -                $where['day'] = $day;
 | 
	
		
			
				|  |  | -                $where['clear'] = true;
 | 
	
		
			
				|  |  | -                $info = Dever::db('shop/shop_stat')->find($where);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                if (!$info) {
 | 
	
		
			
				|  |  | -                    $up = $where;
 | 
	
		
			
				|  |  | -                    $up['num'] = $v['num'];
 | 
	
		
			
				|  |  | -                    $up['cash'] = $v['total'];
 | 
	
		
			
				|  |  | -                    Dever::db('shop/shop_stat')->insert($up);
 | 
	
		
			
				|  |  | -                } else {
 | 
	
		
			
				|  |  | -                    
 | 
	
		
			
				|  |  | +                $key = $v['shop_id'] . '_' . $day . '_' . $v['mobile'];
 | 
	
		
			
				|  |  | +                if (!isset($result[$key])) {
 | 
	
		
			
				|  |  | +                    $result[$key] = array();
 | 
	
		
			
				|  |  | +                    $result[$key]['num'] = 0;
 | 
	
		
			
				|  |  | +                    $result[$key]['cash'] = 0;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        $shop = Dever::db('shop/info')->select();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        foreach ($shop as $k => $v) {
 | 
	
		
			
				|  |  | -            $where = array();
 | 
	
		
			
				|  |  | -            $where['status'] = '2,3,4,5,6';
 | 
	
		
			
				|  |  | -            $where['shop_id'] = $v['id'];
 | 
	
		
			
				|  |  | -            for($i=0; $i<=$day; $i++) {
 | 
	
		
			
				|  |  | -                $where['start'] = $start + 86400*$i;
 | 
	
		
			
				|  |  | -                $where['end'] = $start + 86400*$i + 86399;
 | 
	
		
			
				|  |  | -                $data = array();
 | 
	
		
			
				|  |  | -                $data['shop_id'] = $v['id'];
 | 
	
		
			
				|  |  | -                $data['day'] = $where['start'];
 | 
	
		
			
				|  |  | -                $info = Dever::db('shop/shop_stat')->find($data);
 | 
	
		
			
				|  |  | -                $cash = Dever::db('shop/sell_order')->getCashNum($where);
 | 
	
		
			
				|  |  | -                $data['sell_cash'] = round($cash['total'], 2);
 | 
	
		
			
				|  |  | -                $data['sell_num'] = Dever::db('shop/sell_order')->getOrderNum($where);
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | -                $where['type'] = 1;
 | 
	
		
			
				|  |  | -                $where['type_id'] = $v['id'];
 | 
	
		
			
				|  |  | -                $cash = Dever::db('shop/buy_order')->getCashNum($where);
 | 
	
		
			
				|  |  | -                $data['buy_cash'] = round($cash['total'], 2);
 | 
	
		
			
				|  |  | -                $data['buy_num'] = Dever::db('shop/buy_order')->getOrderNum($where);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                $data['sl_num'] = 0;
 | 
	
		
			
				|  |  | +                $result[$key]['num'] += $v['num'];
 | 
	
		
			
				|  |  | +                $result[$key]['cash'] = $v['total'];
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                $data['area'] = $v['area'];
 | 
	
		
			
				|  |  | -                $data['province'] = $v['province'];
 | 
	
		
			
				|  |  | -                $data['city'] = $v['city'];
 | 
	
		
			
				|  |  | -                $data['county'] = $v['county'];
 | 
	
		
			
				|  |  | -                $data['town'] = $v['town'];
 | 
	
		
			
				|  |  | -                if (!$info) {
 | 
	
		
			
				|  |  | -                    Dever::db('shop/shop_stat')->insert($data);
 | 
	
		
			
				|  |  | -                } else {
 | 
	
		
			
				|  |  | -                    $data['where_id'] = $info['id'];
 | 
	
		
			
				|  |  | -                    Dever::db('shop/shop_stat')->update($data);
 | 
	
		
			
				|  |  | +            if ($result) {
 | 
	
		
			
				|  |  | +                foreach ($result as $k => $v) {
 | 
	
		
			
				|  |  | +                    $temp = explode('_', $k);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    $where['shop_id'] = $temp[0];
 | 
	
		
			
				|  |  | +                    $where['day'] = $temp[1];
 | 
	
		
			
				|  |  | +                    $where['mobile'] = $temp[2];
 | 
	
		
			
				|  |  | +                    $where['clear'] = true;
 | 
	
		
			
				|  |  | +                    $info = Dever::db('shop/user_rank_stat')->find($where);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    $up = array();
 | 
	
		
			
				|  |  | +                    if (!$info) {
 | 
	
		
			
				|  |  | +                        $up = $where;
 | 
	
		
			
				|  |  | +                        $shop = Dever::db('shop/info')->one($where['shop_id']);
 | 
	
		
			
				|  |  | +                        $up['area'] = $shop['area'];
 | 
	
		
			
				|  |  | +                        $up['num'] = $v['num'];
 | 
	
		
			
				|  |  | +                        $up['cash'] = $v['cash'];
 | 
	
		
			
				|  |  | +                        Dever::db('shop/user_rank_stat')->insert($up);
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        $up = array();
 | 
	
		
			
				|  |  | +                        $up['where_id'] = $info['id'];;
 | 
	
		
			
				|  |  | +                        $up['num'] = $v['num'];
 | 
	
		
			
				|  |  | +                        $up['cash'] = $v['cash'];
 | 
	
		
			
				|  |  | +                        Dever::db('shop/user_rank_stat')->update($up);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 |