rabin 2 years ago
parent
commit
da6f40b357
2 changed files with 19 additions and 28 deletions
  1. 2 2
      service/bill/database/sell.php
  2. 17 26
      service/bill/lib/Cron.php

+ 2 - 2
service/bill/database/sell.php

@@ -261,7 +261,7 @@ return array
             (
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
-                'type' => array('yes', 'in'),
+                'type' => 'yes',
                 'state' => 1,
             ),
             'type' => 'all',
@@ -278,7 +278,7 @@ return array
                 'end' => array('yes-cdate', '<='),
                 'mid' => 'yes',
                 'stype' => 'yes',
-                'type' => array('yes', 'in'),
+                'type' => 'yes',
                 'state' => 1,
             ),
             'type' => 'one',

+ 17 - 26
service/bill/lib/Cron.php

@@ -34,37 +34,30 @@ class Cron
         $data = Dever::db('bill/sell')->getNumByTime($where);
         if ($data) {
         	foreach ($data as $k => $v) {
-                if($v['type']==2){
-                    if ($v['num'] > 0) {
-                        $w = array();
-                        $w['mid'] = $v['mid'];
-                        $w['month'] = $where['start'];
-                        $info = Dever::db('bill/sell_stat')->find($w);
-                        $w['new_num'] = $v['num'];
-                        $where['mid'] = $v['mid'];
-                        $total = Dever::db('bill/sell')->getNumByTimeOne($where);
-                        if ($total) {
-                            $w['num'] = $total['num'];
-                        }
-                        if ($info) {
-                            $w['where_id'] = $info['id'];
-                            Dever::db('bill/sell_stat')->update($w);
-                        } else {
-                            Dever::db('bill/sell_stat')->insert($w);
-                        }
-                    }
-                }else{
-                    if ($v['num'] > 0) {
+
+                if ($v['num'] > 0) {
                     $w = array();
                     $w['mid'] = $v['mid'];
                     $w['month'] = $where['start'];
+                    $w['clear'] = true;
                     $info = Dever::db('bill/sell_stat')->find($w);
-                    $w['new_ztnum'] = $v['num'];
+                    
                     $where['mid'] = $v['mid'];
+                    $where['type'] = $v['type'];
                     $total = Dever::db('bill/sell')->getNumByTimeOne($where);
-                    if ($total) {
-                        $w['zt_num'] = $total['num'];
+
+                    if ($v['type'] == 1) {
+                        $w['new_ztnum'] = $v['num'];
+                        if ($total) {
+                            $w['zt_num'] = $total['num'];
+                        }
+                    } else {
+                        $w['new_num'] = $v['num'];
+                        if ($total) {
+                            $w['num'] = $total['num'];
+                        }
                     }
+                    
                     if ($info) {
                         $w['where_id'] = $info['id'];
                         Dever::db('bill/sell_stat')->update($w);
@@ -72,8 +65,6 @@ class Cron
                         Dever::db('bill/sell_stat')->insert($w);
                     }
                 }
-                }
-        		
         	}
         }