zory 1 hafta önce
ebeveyn
işleme
c99fc5515b
2 değiştirilmiş dosya ile 61 ekleme ve 2 silme
  1. 61 0
      app/controller/Dashboard.php
  2. 0 2
      app/extra/basic/Base.php

+ 61 - 0
app/controller/Dashboard.php

@@ -0,0 +1,61 @@
+<?php
+
+namespace app\controller;
+
+use app\extra\basic\Base;
+use app\middleware\AuthMiddleware;
+use app\model\saas\SaasOrderLife;
+use app\model\saas\SaasStore;
+use LinFly\Annotation\Route\Controller;
+use LinFly\Annotation\Route\Middleware;
+use LinFly\Annotation\Route\Route;
+use support\Response;
+
+
+#[Controller(prefix: "/api/dashboard"),Middleware(AuthMiddleware::class)]
+class Dashboard extends Base
+{
+
+
+    /**
+     *
+     * @return Response
+     */
+    #[Route(path: "manage",methods: "get")]
+    public function getManageData(): Response
+    {
+        try {
+            $total = (new SaasOrderLife)->where("status","in",[1,2,3,6])->whereDay("create_at")->field("ROUND(sum(pay_amount)/100,2) as money,count(id) as num")->find();
+            $today = [
+                "order_money"   => $total['money']??0, // 营业额
+                "order_num"     => $total['num']??0, // 订单数
+                "order_done"    => "", // 已核销
+                "order_send"    => "",  // 待发货
+                "store_num"     => (new SaasStore)->count(), // 总店铺数量
+            ];
+            $moneys = $orders = [];
+            $fields = ['ROUND(sum(pay_amount)/100,2)' => 'total','substr(create_at,1,10)' => 'mday'];
+            $orderMoney = (new SaasOrderLife)->field($fields)->where("status","in",[1,3,4,5])->whereTime('create_at', '-15 days')->group('mday')->select()->column(null, 'mday');
+            for ($i = 15; $i >= 0; $i--) {
+                $date = date('Y-m-d', strtotime("-{$i}days"));
+                $moneys[] = [
+                    '当天日期' => date('Y-m-d', strtotime("-{$i}days")),
+                    '订单金额' => ($orderMoney[$date] ?? [])['total'] ?? 0,
+                ];
+            }
+            $field = ['count(1)' => 'count', 'substr(create_at,1,10)' => 'mday'];
+            $orderNum = (new SaasOrderLife)->field($field)->where("status","in",[1,3,4,5])->whereTime('create_at', '-15 days')->group('mday')->select()->column(null, 'mday');
+            for ($i = 15; $i >= 0; $i--) {
+                $date = date('Y-m-d', strtotime("-{$i}days"));
+                $orders[] = [
+                    '当天日期' => date('Y-m-d', strtotime("-{$i}days")),
+                    '订单数量' => ($orderNum[$date] ?? [])['count'] ?? 0,
+                ];
+            }
+            return success("ok",compact("today","moneys","orders"));
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+}

+ 0 - 2
app/extra/basic/Base.php

@@ -70,7 +70,6 @@ class Base
                                 "groupon_type"  => $certificates['sku_info']['groupon_type'],
                                 "certificate_id"  => $certificates['certificate_id']??'',
                                 "start_time"    => date("Y-m-d H:i:s",$certificates['start_time']),
-                                "status"        => 1
                             ];
                             $orderLog[$key] = [
                                 "order_id"  => $val['order_id'],
@@ -86,7 +85,6 @@ class Base
                                 "groupon_type"  => $certificates['sku_info']['groupon_type'],
                                 "certificate_id"  => $certificates['certificate_id']??'',
                                 "start_time"    => date("Y-m-d H:i:s",$certificates['start_time']),
-                                "status"        => 1
                             ]);
                         }
                     }