Kaynağa Gözat

wesmiler 抢表商城

APPLE 3 yıl önce
ebeveyn
işleme
c9db1b20bf

+ 39 - 0
app/Models/OrderModel.php

@@ -0,0 +1,39 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Models;
+
+/**
+ * 积分商城订单管理-模型
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class OrderModel
+ * @package App\Models
+ */
+class OrderModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'orders';
+
+    /**
+     * 获取信息
+     * @param int $id
+     * @return array|string
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function getInfo($id)
+    {
+        $info = parent::getInfo($id); // TODO: Change the autogenerated stub
+        return $info;
+    }
+
+}

+ 6 - 0
app/Services/Common/MemberService.php

@@ -84,6 +84,12 @@ class MemberService extends BaseService
             if(isset($info['login_shop_id']) && $info['login_shop_id']){
                 $info['shop_info'] = ShopService::make()->getInfo($info['login_shop_id']);
             }
+
+            // 交易订单统计
+            $info['orderCounts'] = TradeService::make()->getNewTradeCountByStatus($info['id'],[1,2,3]);
+
+            // 积分订单统计
+            $info['scoreOrderCount'] = OrderService::make()->getNewTradeCount($info['id'],[1,2,3,4,5]);
         }
 
         return $info;

+ 84 - 0
app/Services/Common/OrderService.php

@@ -0,0 +1,84 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\OrderModel;
+use App\Services\BaseService;
+
+/**
+ * 积分商城订单管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class OrderService
+ * @package App\Services\Common
+ */
+class OrderService extends BaseService
+{
+    // 静态对象
+    protected static $instance = null;
+
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * OrderService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new OrderModel();
+    }
+
+    /**
+     * 静态入口
+     * @return static|null
+     */
+    public static function make()
+    {
+        if (!self::$instance) {
+            self::$instance = (new static());
+        }
+        return self::$instance;
+    }
+
+    /**
+     * 添加或编辑
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function edit()
+    {
+        $data = request()->all();
+        return parent::edit($data); // TODO: Change the autogenerated stub
+    }
+
+    /**
+     * 抢拍交易订单数
+     * @param $userId 用户ID
+     * @param int $status 状态
+     * @return mixed
+     */
+    public function getNewTradeCount($userId, $status=0, $time=30)
+    {
+        $where = ['user_id'=>$userId,'mark'=>1,'is_read'=>1];
+        return $this->model->where($where)
+            ->where(function($query) use($status){
+                $query->whereIn('status',is_array($status)? $status:[$status]);
+            })
+            ->where(function($query) use($time){
+                if($time){
+                    $query->where('update_time','>', $time);
+                }
+            })
+            ->count('id');
+    }
+}

+ 23 - 1
app/Services/Common/TradeService.php

@@ -18,7 +18,7 @@ use App\Services\BaseService;
  * 交易管理-服务类
  * @author laravel开发员
  * @since 2020/11/11
- * Class AccountService
+ * Class TradeService
  * @package App\Services\Common
  */
 class TradeService extends BaseService
@@ -94,4 +94,26 @@ class TradeService extends BaseService
         return $this->model->where($where)
             ->count('id');
     }
+
+    /**
+     * 抢拍交易订单数
+     * @param $userId 用户ID
+     * @param int $status 状态
+     * @return mixed
+     */
+    public function getNewTradeCountByStatus($userId, $status=0, $time=30)
+    {
+        $where = ['user_id'=>$userId,'mark'=>1,'is_read'=>1];
+        return $this->model->where($where)
+            ->where(function($query) use($status){
+                $query->whereIn('status',is_array($status)? $status:[$status]);
+            })
+            ->where(function($query) use($time){
+                if($time){
+                    $query->where('update_time','>', $time);
+                }
+            })
+            ->groupBy('status')
+            ->count('id');
+    }
 }