Browse Source

数据看板保存

wufeng 2 years ago
parent
commit
a7cffbcc48
1 changed files with 24 additions and 9 deletions
  1. 24 9
      app/admin/controller/Data.php

+ 24 - 9
app/admin/controller/Data.php

@@ -15,19 +15,34 @@ class Data extends Base
         $data = [];
 
         //1.今日销量(单数、金额)
+        $today_sales_volume = Db::name('sale')
+            ->field('count(id) orders_number,sum(total_price) money')
+            ->where('is_del',0)
+            ->whereDay('addtime','today')
+            ->find();
+
         $data['today_sales_volume'] = [
-            'orders_number' => '0',
-            'money' => '00.00'
+            'orders_number' => isset($today_sales_volume['orders_number'])?$today_sales_volume['orders_number']:0,
+            'money' =>  isset($today_sales_volume['money'])?$today_sales_volume['money']:0,
         ];
 
         //2.今日销冠(部门、姓名、单数、金额)
-        $data['today_sales_champion'] = [
-            'company_id' => '0',
-            'company' => 'xxx部',
-            'nickname' => '张三',
-            'orders' => '0',
-            'money' => '00.00'
-        ];
+        $temp = Db::name('sale')
+            ->field('count(id) orders,sum(total_price) money,apply_id')
+            ->where('is_del',0)
+            ->whereDay('addtime','today')
+            ->group('apply_id')
+            ->order('money','desc')
+            ->limit(1)
+            ->buildSql();
+
+        $data['today_sales_champion'] = Db::table($temp)
+            ->alias('t')
+            ->field('t.apply_id,t.orders,t.money,u.itemid company_id,	c.`name` company,	u.nickname')
+            ->leftJoin('depart_user u','u.uid=t.apply_id AND u.is_del=0')
+            ->leftJoin('company_item c','c.id=u.itemid AND c.is_del=0')
+            ->select()
+            ->toArray();
 
         //3.今日采购(采购订单数量、商品数量、竞价单数、反馈商品数)
         $data['today_purchase'] = [