From 30563323a53b0d0260c97d08a9e8bd4cc8227a95 Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Sat, 13 Dec 2025 18:03:52 +0800
Subject: [PATCH] 完成级差奖 完成平级奖

---
 admin/app/shop/model/order/OrderProduct.php |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/admin/app/shop/model/order/OrderProduct.php b/admin/app/shop/model/order/OrderProduct.php
index 1bfcfed..98af8cb 100644
--- a/admin/app/shop/model/order/OrderProduct.php
+++ b/admin/app/shop/model/order/OrderProduct.php
@@ -103,4 +103,23 @@
         return 0;
     }
 
+    public static function getPurchaseCount($userId, $postData)
+    {
+        $model = new static();
+        //搜索时间段
+        if (!empty($postData['start_time'])) {
+            $sta_time = $postData['start_time'];
+            $end_time = $postData['end_time'];
+            $model = $model->whereBetweenTime('order.create_time', strtotime($sta_time), strtotime($end_time));
+        }
+        return $model->alias('o_product')
+            ->join('order', 'order.order_id = o_product.order_id')
+            ->where('order.pay_status', '=', OrderPayStatusEnum::SUCCESS)
+            ->where('order.order_status', '<>', OrderStatusEnum::CANCELLED)
+            ->where('o_product.user_id', '=', $userId)
+            ->where('o_product.is_vip',1)
+            ->group('o_product.product_id')
+            ->sum("total_num");
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.2