|
|
@@ -55,22 +55,28 @@ class BalanceLogService extends BaseService
|
|
|
* @param $type 类型:1-充值,2-提现
|
|
|
* @return array|mixed
|
|
|
*/
|
|
|
- public function getCountByType(int $userId=0, $type=1, $coinType=1)
|
|
|
+ public function getCountByType(int $userId=0, $type=1, $coinType=1, $status=2)
|
|
|
{
|
|
|
- $cacheKey = "caches:balance:counts_{$userId}_{$type}_{$coinType}";
|
|
|
+ $cacheKey = "caches:balance:counts_{$userId}_{$type}_{$coinType}_{$status}";
|
|
|
$counts = RedisService::get($cacheKey);
|
|
|
if($counts){
|
|
|
return $counts;
|
|
|
}
|
|
|
|
|
|
- $where = ['user_id'=> $userId,'coin_type'=>0,'type'=>$type,'status'=>2,'mark'=>1];
|
|
|
+ $where = ['user_id'=> $userId,'coin_type'=>0,'type'=>$type,'mark'=>1];
|
|
|
if($coinType){
|
|
|
$where['coin_type'] = $coinType;
|
|
|
}else{
|
|
|
unset($where['coin_type']);
|
|
|
}
|
|
|
|
|
|
- $data = $this->model->where($where)->sum('money');
|
|
|
+ $data = $this->model->where($where)->where(function ($query)use($status){
|
|
|
+ if($status){
|
|
|
+ $query->where('status', $status);
|
|
|
+ }else{
|
|
|
+ $query->whereIn('status', [1,2]);
|
|
|
+ }
|
|
|
+ })->sum('money');
|
|
|
RedisService::set($cacheKey, $data, rand(3, 5));
|
|
|
return $data;
|
|
|
}
|