| xqd
@@ -220,7 +220,7 @@ class UserService
|
|
|
->limit($limit)
|
|
|
->get();
|
|
|
|
|
|
- if($list->isEmpty()){
|
|
|
+ if ($list->isEmpty()) {
|
|
|
return [];
|
|
|
}
|
|
|
$list = $list->toArray();
|
| xqd
@@ -330,7 +330,7 @@ class UserService
|
|
|
->orderBy('user_follows.updated_at', 'desc')
|
|
|
->get();
|
|
|
|
|
|
- if($list->isEmpty()){
|
|
|
+ if ($list->isEmpty()) {
|
|
|
return [];
|
|
|
}
|
|
|
$list = $list->toArray();
|
| xqd
@@ -352,7 +352,7 @@ class UserService
|
|
|
->orderBy('user_follows.updated_at', 'desc')
|
|
|
->get();
|
|
|
|
|
|
- if($list->isEmpty()){
|
|
|
+ if ($list->isEmpty()) {
|
|
|
return [];
|
|
|
}
|
|
|
$list = $list->toArray();
|
| xqd
@@ -401,7 +401,7 @@ class UserService
|
|
|
->orderBy('id', 'desc')
|
|
|
->get();
|
|
|
|
|
|
- if($list->isEmpty()){
|
|
|
+ if ($list->isEmpty()) {
|
|
|
return [];
|
|
|
}
|
|
|
$list = $list->toArray();
|
| xqd
@@ -533,13 +533,13 @@ class UserService
|
|
|
}
|
|
|
|
|
|
//用户积分变化
|
|
|
- public function changeIntegral($userId, $amount=0, $type=1)
|
|
|
+ public function changeIntegral($userId, $amount = 0, $type = 1)
|
|
|
{
|
|
|
DB::beginTransaction();
|
|
|
- try{
|
|
|
- if($type == '+'){
|
|
|
+ try {
|
|
|
+ if ($type == '+') {
|
|
|
UserExtra::query()->where('user_id', $userId)->increment('integral', $amount);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
UserExtra::query()->where('user_id', $userId)->decrement('integral', $amount);
|
|
|
}
|
|
|
|
| xqd
@@ -554,10 +554,32 @@ class UserService
|
|
|
$userIntegral->save();
|
|
|
|
|
|
DB::commit();
|
|
|
- }catch (Exception $exception){
|
|
|
+ } catch (Exception $exception) {
|
|
|
ErrorMsgServive::write($exception, request()->url());
|
|
|
DB::rollBack();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //积分变化记录
|
|
|
+ public function getIntegrals($userId, $page)
|
|
|
+ {
|
|
|
+ $limit = 20;
|
|
|
+ $offset = ($page - 1) * $offset;
|
|
|
+ $list = UserIntegral::query()
|
|
|
+ ->where('user_id', $userId)
|
|
|
+ ->limit($limit)
|
|
|
+ ->offset($offset)
|
|
|
+ ->get();
|
|
|
+
|
|
|
+ if ($list->isEmpty()) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ $list = $list->toArray();
|
|
|
+ foreach ($list as $key => &$val) {
|
|
|
+ $val['type_name'] = UserIntegral::getTypeName($val['type']);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $list;
|
|
|
+ }
|
|
|
+
|
|
|
}
|