rabin vor 3 Jahren
Ursprung
Commit
d8525a1693
3 geänderte Dateien mit 43 neuen und 4 gelöschten Zeilen
  1. 32 1
      app/shop/database/sell_order_goods.php
  2. 10 3
      app/shop/lib/Cron.php
  3. 1 0
      learn/active/database/info_off.php

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

@@ -260,7 +260,7 @@ return array
                 'state' => 1,
             ),
             'type' => 'one',
-            'col' => 'sum(price) as total',
+            'col' => 'sum(price*num) as total',
         ),
 
         'getGoods' => array
@@ -274,5 +274,36 @@ return array
             'type' => 'all',
             'col' => 'id,goods_id',
         ),
+
+        # 获取总金额
+        'getNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-t_2.cdate', '>='),
+                'end' => array('yes-t_2.cdate', '<='),
+                'start_o' => array('yes-t_2.operdate', '>='),
+                'end_o' => array('yes-t_2.operdate', '<='),
+                'shop_id' => array('yes-t_2.shop_id'),
+                'goods_id' => array('yes-t_1.goods_id'),
+                'status' => array('yes-t_2.status', 'in'),
+                'state_2' => array('yes-t_2.state', '=', 1),
+                'state_1' => array('yes-t_1.state', '=', 1),
+                'status_1' => array('yes-t_1.status', 'in'),
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'shop/sell_order',
+                    'type' => 'left join',
+                    'on' => array('order_id','id'),
+                ),
+            ),
+            'type' => 'one',
+            'col' => 'id,sum(t_1.price*t_1.num) as cash,sum(t_1.num) as num',
+        ),
     ),
 );

+ 10 - 3
app/shop/lib/Cron.php

@@ -300,6 +300,9 @@ class Cron
         $end = Dever::input('end', date('Y-m-d'));
 
         $where['status'] = '2,3,4,5,6';
+        //$where['state_2'] = 1;
+        //$where['state_1'] = 1;
+        $where['status_1'] = 1;
         $start = Dever::maketime($start . ' 00:00:00');
         $end = Dever::maketime($end . ' 23:59:59');
         $day = intval(($end - $start)/86400);
@@ -317,6 +320,7 @@ class Cron
                 $data['day'] = $where['start'];
                 $info = Dever::db('shop/buy_stat')->find($data);
                 $cash = Dever::db('shop/buy_order_goods')->getCashNum($where);
+                return $cash;
                 $data['cash'] = round($cash['total'], 2);
                 $cash = Dever::db('shop/buy_order_goods')->getPCashNum($where);
                 $data['p_cash'] = round($cash['total'], 2);
@@ -437,9 +441,12 @@ class Cron
                         $data['goods_id'] = $v1['goods_id'];
                         $data['day'] = $where['start'];
                         $info = Dever::db('shop/goods_stat')->find($data);
-                        $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);
+                        $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'];

+ 1 - 0
learn/active/database/info_off.php

@@ -9,6 +9,7 @@ return array
     # 后台菜单排序
     'order' => 2,
     // 'menu' => false,
+    'auto' => 100000,
     # 数据结构
     'struct' => array
     (