rabin %!s(int64=3) %!d(string=hai) anos
pai
achega
7fcec9146e
Modificáronse 2 ficheiros con 25 adicións e 24 borrados
  1. 1 1
      app/shop/database/sell_order_goods.php
  2. 24 23
      app/shop/lib/Cron.php

+ 1 - 1
app/shop/database/sell_order_goods.php

@@ -302,7 +302,7 @@ return array
                     'on' => array('order_id','id'),
                 ),
             ),
-            'type' => 'one',
+            'type' => 'all',
             'group' => 't_2.shop_id, t_1.goods_id',
             'col' => 'id,t_2.shop_id, t_1.goods_id,sum(t_1.price*t_1.num) as cash,sum(t_1.num) as num',
         ),

+ 24 - 23
app/shop/lib/Cron.php

@@ -424,31 +424,32 @@ class Cron
             $where['start'] = $start + 86400*$i;
             $where['end'] = $start + 86400*$i + 86399;
             $num = Dever::db('shop/sell_order_goods')->getNum($where);
-            $data['cash'] = $data['num'] = 0;
             if ($num) {
-                $data = array();
-                $data['shop_id'] = $num['shop_id'];
-                $data['goods_id'] = $num['goods_id'];
-                $data['day'] = $where['start'];
-                $info = Dever::db('shop/goods_stat')->find($data);
-
-                $shop = Dever::db('shop/info')->find($data['shop_id']);
-                if ($shop) {
-                    $data['area'] = $shop['area'];
-                }
-                $goods_info = Dever::db('goods/info')->find($data['goods_id']);
-                if ($goods_info) {
-                    $data['category'] = $goods_info['category'];
-                }
-                
-                $data['cash'] = round($num['cash'], 2);
-                $data['num'] = round($num['num'], 2);
+                foreach ($num as $k => $v) {
+                    $data = array();
+                    $data['shop_id'] = $v['shop_id'];
+                    $data['goods_id'] = $v['goods_id'];
+                    $data['day'] = $where['start'];
+                    $info = Dever::db('shop/goods_stat')->find($data);
+
+                    $shop = Dever::db('shop/info')->find($data['shop_id']);
+                    if ($shop) {
+                        $data['area'] = $shop['area'];
+                    }
+                    $goods_info = Dever::db('goods/info')->find($data['goods_id']);
+                    if ($goods_info) {
+                        $data['category'] = $goods_info['category'];
+                    }
+                    
+                    $data['cash'] = round($v['cash'], 2);
+                    $data['num'] = round($v['num'], 2);
 
-                if (!$info) {
-                    Dever::db('shop/goods_stat')->insert($data);
-                } else {
-                    $data['where_id'] = $info['id'];
-                    Dever::db('shop/goods_stat')->update($data);
+                    if (!$info) {
+                        Dever::db('shop/goods_stat')->insert($data);
+                    } else {
+                        $data['where_id'] = $info['id'];
+                        Dever::db('shop/goods_stat')->update($data);
+                    }
                 }
             }
         }