Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
ic_welfare_api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7bc97129
authored
Sep 05, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
丰富好友助力列表的返回信息
parent
ed9df7eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
6 deletions
app/Http/Controllers/AssistsController.php
app/Services/AssistService.php
app/Http/Controllers/AssistsController.php
View file @
7bc97129
...
...
@@ -4,6 +4,7 @@
namespace
App\Http\Controllers
;
use
App\Services\AssistService
;
use
App\Services\UserExchangeService
;
use
Illuminate\Http\Request
;
/**
...
...
@@ -35,12 +36,25 @@ class AssistsController extends Controller
*/
public
function
index
(
Request
$request
)
{
$userId
=
$request
->
user
->
user_id
;
$exchangeId
=
$request
->
get
(
'exchange_id'
);
$map
=
[
'user_id'
=>
$
request
->
user
->
user_i
d
,
'user_id'
=>
$
userI
d
,
'is_api'
=>
1
,
'exchange_id'
=>
$
request
->
get
(
'exchange_id'
)
,
'exchange_id'
=>
$
exchangeId
,
];
$result
=
$this
->
service
->
getAssistList
(
$map
);
$list
=
$this
->
service
->
getAssistList
(
$map
);
$result
[
'data'
][
'assist_list'
]
=
$list
;
$userExchangeService
=
new
UserExchangeService
();
$userExchange
=
array_get
(
$userExchangeService
->
getUserExchange
([
'id'
=>
$exchangeId
]),
'data'
);
$result
[
'data'
][
'amount'
]
=
array_get
(
$userExchange
,
'amount'
,
'0'
);
$user
=
$this
->
service
->
getUserInfo
(
$userId
);
$result
[
'data'
][
'user_info'
]
=
[
'avatar'
=>
array_get
(
$user
,
'avatar'
),
'company_name'
=>
array_get
(
$user
,
'company_name'
,
''
),
];
$needAssistCount
=
2
;
$result
[
'data'
][
'need_assist_count'
]
=
$needAssistCount
-
count
(
$list
);
return
$this
->
Export
(
0
,
'ok'
,
$result
);
}
...
...
app/Services/AssistService.php
View file @
7bc97129
...
...
@@ -4,6 +4,8 @@
namespace
App\Services
;
use
Common\Model\RedisModel
;
class
AssistService
extends
BaseService
{
public
function
getAssistList
(
$map
=
[])
...
...
@@ -11,23 +13,25 @@ class AssistService extends BaseService
$url
=
config
(
'website.BaseUrl'
)
.
'/assists/list'
;
$result
=
reportCurl
(
$url
,
$map
,
true
);
$result
=
json_decode
(
$result
,
true
);
$userNames
=
[];
$userNames
=
$userAvatars
=
[];
if
(
isset
(
$result
[
'data'
])
&&
$result
[
'data'
])
{
//获取到被邀请人的信息
$ids
=
array_column
(
$result
[
'data'
],
'assist_user_id'
);
$users
=
$this
->
getUsersFromRedis
(
$ids
);
foreach
(
$users
as
$user
)
{
$userNames
[
$user
[
'user_id'
]]
=
isset
(
$user
[
'company_name'
])
?:
$user
[
'mobile'
];
$userAvatars
[
$user
[
'user_id'
]]
=
$user
[
'avatar'
];
}
$result
[
'data'
]
=
array_map
(
function
(
$value
)
use
(
$userNames
)
{
$result
[
'data'
]
=
array_map
(
function
(
$value
)
use
(
$userNames
,
$userAvatars
)
{
$value
[
'assist_user_name'
]
=
$userNames
[
$value
[
'assist_user_id'
]];
$value
[
'assist_user_avatar'
]
=
$userAvatars
[
$value
[
'assist_user_id'
]];
return
$value
;
},
$result
[
'data'
]);
}
return
$result
;
return
$result
[
'data'
]
;
}
public
function
addAssist
(
$map
=
[])
...
...
@@ -38,4 +42,13 @@ class AssistService extends BaseService
return
$result
;
}
//获取用户信息
public
function
getUserInfo
(
$userId
)
{
$redis
=
new
RedisModel
();
$user
=
json_decode
(
$redis
->
hget
(
'ic_user'
,
$userId
),
true
);
return
$user
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment