|
@@ -420,40 +420,28 @@ class Cron
|
|
|
$end = Dever::maketime($end . ' 23:59:59');
|
|
|
$day = intval(($end - $start)/86400);
|
|
|
|
|
|
- $shop = Dever::db('shop/info')->select();
|
|
|
+ for($i=0; $i<=$day; $i++) {
|
|
|
+ $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);
|
|
|
|
|
|
- foreach ($shop as $k => $v) {
|
|
|
- $where['shop_id'] = $v['id'];
|
|
|
- $goods = Dever::db('shop/goods')->select(array('shop_id' => $v['id']));
|
|
|
- if ($goods) {
|
|
|
- foreach ($goods as $k1 => $v1) {
|
|
|
- $where['goods_id'] = $v1['goods_id'];
|
|
|
- $goods_info = Dever::db('goods/info')->one($v1['goods_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['goods_id'] = $v1['goods_id'];
|
|
|
- $data['day'] = $where['start'];
|
|
|
- $info = Dever::db('shop/goods_stat')->find($data);
|
|
|
- $num = Dever::db('shop/sell_order_goods')->getNum($where);
|
|
|
- $data['cash'] = $data['num'] = 0;
|
|
|
- if ($num) {
|
|
|
- $data['cash'] = round($num['cash'], 2);
|
|
|
- $data['num'] = round($num['num'], 2);
|
|
|
- }
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ $data['area'] = $v['area'];
|
|
|
+ $data['category'] = $goods_info['category'];
|
|
|
+ $data['cash'] = round($num['cash'], 2);
|
|
|
+ $data['num'] = round($num['num'], 2);
|
|
|
+
|
|
|
+ if (!$info) {
|
|
|
+ Dever::db('shop/goods_stat')->insert($data);
|
|
|
+ } else {
|
|
|
+ $data['where_id'] = $info['id'];
|
|
|
+ Dever::db('shop/goods_stat')->update($data);
|
|
|
}
|
|
|
}
|
|
|
}
|