afa hace 5 meses
padre
commit
df1174241f
Se han modificado 1 ficheros con 6 adiciones y 5 borrados
  1. 6 5
      app/admin/controller/shop/ShopDelivery.php

+ 6 - 5
app/admin/controller/shop/ShopDelivery.php

@@ -19,7 +19,6 @@ class ShopDelivery extends Backend
         parent::_initialize();
         $this->model = new ShopDeliveryModel();
         $this->assign('platformList', site_config('addonsd.platform_list'));
-      
         $this->relationField=['customer','user','shops', 'variety', 'specs'];
     }
 
@@ -46,10 +45,12 @@ class ShopDelivery extends Backend
             ->paginate($limit);
 
         //表格底部要有汇总:发货数量汇总  重量汇总 总价汇总
-        $total_num = $this->model->where($where)->sum('num');
-        $total_weigh = $this->model->where($where)->sum('weigh');
-        $total_price = $this->model->where($where)->sum('total_price');
-        $result = ['total' => $list->total(), 'rows' => $list->items(), 'total_num' => $total_num, 'total_weigh' => $total_weigh, 'total_price' => $total_price];
+        $count = $this->model->field('sum(num) total_num, sum(weigh) total_weigh, sum(total_price) total_price')->select()->toArray();
+
+        $result = ['total' => $list->total(), 'rows' => $list->items(), 
+        'total_num'    => $count[0]['total_num']??0, 
+        'total_weigh'  => $count[0]['total_weigh']??0, 
+        'total_price'  => $count[0]['total_price']??0];
         return json($result);
     }
 }