|
|
@@ -239,6 +239,62 @@ class BalanceLogService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 团队真实/上下分充提数据
|
|
|
+ * @param $userId 用户ID
|
|
|
+ * @param int $type
|
|
|
+ * @return array|int[]|mixed
|
|
|
+ */
|
|
|
+ public function getTeamTotalByUser($userId, $type=1)
|
|
|
+ {
|
|
|
+ $cacheKey = "caches:balanceLog:teamTotal_{$userId}_{$type}";
|
|
|
+ $data = RedisService::get($cacheKey);
|
|
|
+ if($data || RedisService::exists($cacheKey)){
|
|
|
+ return $data?$data:['recharge'=>0,'withdraw'=>0,'difference'=>0];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 真实充提
|
|
|
+ if($type == 1){
|
|
|
+ $recharge = $this->model->from('balance_logs as a')
|
|
|
+ ->leftJoin('member as b','a.user_id','b.id')
|
|
|
+ ->where(function($query) use($userId){
|
|
|
+ $query->whereRaw("FIND_IN_SET({$userId},lev_b.parent_ids)")->orWhere('a.user_id', $userId);
|
|
|
+ })
|
|
|
+ ->where(['a.type'=>1,'a.mark'=>1,'b.mark'=>1])
|
|
|
+ ->whereIn('a.status',[1,2])
|
|
|
+ ->sum('a.money');
|
|
|
+
|
|
|
+ $withdraw = $this->model->from('balance_logs as a')
|
|
|
+ ->leftJoin('member as b','a.user_id','b.id')
|
|
|
+ ->where(function($query) use($userId){
|
|
|
+ $query->whereRaw("FIND_IN_SET({$userId},lev_b.parent_ids)")->orWhere('a.user_id', $userId);
|
|
|
+ })
|
|
|
+ ->where(['a.type'=>2,'a.mark'=>1,'b.mark'=>1])
|
|
|
+ ->whereIn('a.status',[1,2])
|
|
|
+ ->sum('a.money');
|
|
|
+ }else{
|
|
|
+ // 上下分
|
|
|
+ $recharge = AccountLogModel::from('account_log as a')
|
|
|
+ ->leftJoin('member as b','a.user_id','b.id')
|
|
|
+ ->where(function($query) use($userId){
|
|
|
+ $query->whereRaw("FIND_IN_SET({$userId},lev_b.parent_ids)")->orWhere('a.user_id', $userId);
|
|
|
+ })
|
|
|
+ ->where(['a.type'=>5,'a.status'=>1,'a.mark'=>1,'b.mark'=>1])
|
|
|
+ ->sum('a.money');
|
|
|
+ $withdraw = AccountLogModel::from('account_log as a')
|
|
|
+ ->leftJoin('member as b','a.user_id','b.id')
|
|
|
+ ->where(function($query) use($userId){
|
|
|
+ $query->whereRaw("FIND_IN_SET({$userId},lev_b.parent_ids)")->orWhere('a.user_id', $userId);
|
|
|
+ })
|
|
|
+ ->where(['a.type'=>6,'a.status'=>1,'a.mark'=>1,'b.mark'=>1])
|
|
|
+ ->sum('a.money');
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = ['recharge'=>$recharge,'withdraw'=>$withdraw,'difference'=>round($recharge - $withdraw, 2)];
|
|
|
+ RedisService::set($cacheKey, $data, rand(5,10));
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 提现审核
|
|
|
* @param $params
|
|
|
* @return bool
|