From feda780069d64479c0c20493603717e100655da9 Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Fri, 05 Dec 2025 18:26:25 +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..a2814c0 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,$product_ids)
+    {
+        $model = new static();
+        //搜索时间段
+        if (!empty($postData['create_time'])) {
+            $sta_time = array_shift($postData['create_time']);
+            $end_time = array_pop($postData['create_time']);
+            $model = $model->whereBetweenTime('order.create_time', $sta_time, date('Y-m-d 23:59:59', 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.product_id', 'in', $product_ids)
+            ->group('o_product.product_id')
+            ->sum("total_num");
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.2