|
@@ -14,6 +14,7 @@ namespace App\Services;
|
|
|
use App\Models\ActionLogModel;
|
|
use App\Models\ActionLogModel;
|
|
|
use App\Models\MemberModel;
|
|
use App\Models\MemberModel;
|
|
|
use App\Models\TradeModel;
|
|
use App\Models\TradeModel;
|
|
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
use function GuzzleHttp\Psr7\str;
|
|
use function GuzzleHttp\Psr7\str;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -25,6 +26,8 @@ use function GuzzleHttp\Psr7\str;
|
|
|
*/
|
|
*/
|
|
|
class TradeService extends BaseService
|
|
class TradeService extends BaseService
|
|
|
{
|
|
{
|
|
|
|
|
+ protected static $instance = null;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 构造函数
|
|
* 构造函数
|
|
|
* @author wesmiler
|
|
* @author wesmiler
|
|
@@ -37,6 +40,18 @@ class TradeService extends BaseService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 静态入口
|
|
|
|
|
+ * @return TradeService|null
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function make(){
|
|
|
|
|
+ if(!self::$instance){
|
|
|
|
|
+ self::$instance = new TradeService();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return self::$instance;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 获取列表
|
|
* 获取列表
|
|
|
* @return array
|
|
* @return array
|
|
|
* @since 2020/11/11
|
|
* @since 2020/11/11
|
|
@@ -162,6 +177,30 @@ class TradeService extends BaseService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 消费排名
|
|
|
|
|
+ * @return mixed
|
|
|
|
|
+ */
|
|
|
|
|
+ public function ranks(){
|
|
|
|
|
+ $dataList = $this->model::from('account_logs as a')
|
|
|
|
|
+ ->leftJoin('member as m', 'm.id', '=', 'a.user_id')
|
|
|
|
|
+ ->where(['a.mark'=> 1,'m.mark'=> 1,'a.status'=> 1,'a.coin_type'=> 2,'a.pay_type'=> 2,'a.change_type'=> 2])
|
|
|
|
|
+ ->select(['m.avatar','m.nickname','a.id','a.user_id', \DB::raw('sum(a.money) as total')])
|
|
|
|
|
+ ->group('a.user_id')
|
|
|
|
|
+ ->orderBy(\DB::raw('sum(a.money)'),'desc')
|
|
|
|
|
+ ->orderBy('m.create_time','asc')
|
|
|
|
|
+ ->take(50)
|
|
|
|
|
+ ->get();
|
|
|
|
|
+ if($dataList){
|
|
|
|
|
+ foreach ($dataList as &$item){
|
|
|
|
|
+ $item['avatar'] = $item['avatar']? get_image_url($item['avatar']) : '';
|
|
|
|
|
+ }
|
|
|
|
|
+ unset($item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $dataList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 统计
|
|
* 统计
|
|
|
* @param $params
|
|
* @param $params
|
|
|
* @return mixed
|
|
* @return mixed
|