rabin 2 gadi atpakaļ
vecāks
revīzija
67cf3cf9a8
1 mainītis faili ar 55 papildinājumiem un 44 dzēšanām
  1. 55 44
      app/shop/lib/Cron.php

+ 55 - 44
app/shop/lib/Cron.php

@@ -271,18 +271,21 @@ class Cron
                 $cash = Dever::db('shop/sell_order')->getCashNum($where);
                 $data['cash'] = round($cash['total'], 2);
                 $data['order'] = Dever::db('shop/sell_order')->getOrderNum($where);
-                $goods = Dever::db('shop/sell_order')->getGoodsNum($where);
-                $data['goods'] = $goods['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/sell_stat')->insert($data);
-                } else {
-                    $data['where_id'] = $info['id'];
-                    Dever::db('shop/sell_stat')->update($data);
+                
+                if ($data['order'] > 0) {
+                    $goods = Dever::db('shop/sell_order')->getGoodsNum($where);
+                    $data['goods'] = $goods['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/sell_stat')->insert($data);
+                    } else {
+                        $data['where_id'] = $info['id'];
+                        Dever::db('shop/sell_stat')->update($data);
+                    }
                 }
             }
         }
@@ -317,20 +320,23 @@ class Cron
                 $data['p_cash'] = round($cash['total'], 2);
 
                 $data['order'] = Dever::db('shop/buy_order')->getOrderNum($where);
-                $goods = Dever::db('shop/buy_order')->getGoodsNum($where);
 
-                $data['goods'] = $goods['total'];
+                if ($data['order'] > 0) {
+                    $goods = Dever::db('shop/buy_order')->getGoodsNum($where);
 
-                $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/buy_stat')->insert($data);
-                } else {
-                    $data['where_id'] = $info['id'];
-                    Dever::db('shop/buy_stat')->update($data);
+                    $data['goods'] = $goods['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/buy_stat')->insert($data);
+                    } else {
+                        $data['where_id'] = $info['id'];
+                        Dever::db('shop/buy_stat')->update($data);
+                    }
                 }
             }
         }
@@ -381,11 +387,14 @@ class Cron
                 $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 ($data['buy_num'] > 0) {
+                    if (!$info) {
+                        Dever::db('shop/shop_stat')->insert($data);
+                    } else {
+                        $data['where_id'] = $info['id'];
+                        Dever::db('shop/shop_stat')->update($data);
+                    }
                 }
             }
         }
@@ -427,14 +436,15 @@ class Cron
                         $cash = Dever::db('shop/sell_order_goods')->getCashNum($where);
                         $data['cash'] = round($cash['total'], 2);
                         $data['num'] = Dever::db('shop/sell_order_goods')->getOrderNum($where);
-
-                        $data['area'] = $v['area'];
-                        $data['category'] = $goods_info['category'];
-                        if (!$info) {
-                            Dever::db('shop/goods_stat')->insert($data);
-                        } else {
-                            $data['where_id'] = $info['id'];
-                            Dever::db('shop/goods_stat')->update($data);
+                        if ($data['num'] > 0) {
+                            $data['area'] = $v['area'];
+                            $data['category'] = $goods_info['category'];
+                            if (!$info) {
+                                Dever::db('shop/goods_stat')->insert($data);
+                            } else {
+                                $data['where_id'] = $info['id'];
+                                Dever::db('shop/goods_stat')->update($data);
+                            }
                         }
                     }
                 }
@@ -481,13 +491,14 @@ class Cron
 
                 $data['order_num'] = Dever::db('shop/sell_order')->getOrderNum($where);
                 
-
-                $data['area'] = $v['area'];
-                if (!$info) {
-                    Dever::db('shop/user_stat')->insert($data);
-                } else {
-                    $data['where_id'] = $info['id'];
-                    Dever::db('shop/user_stat')->update($data);
+                if ($data['num'] > 0 && $data['order_num'] > 0) {
+                    $data['area'] = $v['area'];
+                    if (!$info) {
+                        Dever::db('shop/user_stat')->insert($data);
+                    } else {
+                        $data['where_id'] = $info['id'];
+                        Dever::db('shop/user_stat')->update($data);
+                    }
                 }
             }
         }