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
993f9f8c
authored
Oct 10, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
确认兑换接口
parent
939b4129
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
7 deletions
app/Http/Controllers/Controller.php
app/Http/Controllers/UserExchangesController.php
app/Services/UserExchangeService.php
config/language.php
app/Http/Controllers/Controller.php
View file @
993f9f8c
...
...
@@ -25,6 +25,9 @@ class Controller extends BaseController
const
CAN_NOT_ASSIST
=
109009
;
//助力类型不能是话费的兑换
const
EXCHANGE_TYPE_ERROR
=
109011
;
//助力人数不足
const
ASSIST_NO_ENOUGH
=
109012
;
//不能助力了(助力人数已满或者用户已经助力过)
const
CAN_NOT_INVITE_MYSELF
=
109010
;
...
...
@@ -57,6 +60,9 @@ class Controller extends BaseController
//好友助力失败
const
ASSIST_FAIL
=
509007
;
//确认兑换失败
const
EXCHANGE_CONFIRM_FAILED
=
509008
;
public
function
Export
(
$Errcode
=
0
,
$ErrMsg
=
''
,
$dataArr
=
[])
{
...
...
app/Http/Controllers/UserExchangesController.php
View file @
993f9f8c
...
...
@@ -103,19 +103,37 @@ class UserExchangesController extends Controller
*/
public
function
confirm
(
Request
$request
,
UserExchangeService
$service
)
{
$userId
=
$request
->
user
->
user_id
;
$exchangeId
=
$request
->
get
(
'exchange_id'
);
if
(
empty
(
$exchangeId
))
{
return
$this
->
Export
(
self
::
INVALID_PARAMETER
);
}
//判断是否可以兑换
$redis
=
new
RedisModel
();
$user
=
json_decode
(
$redis
->
hget
(
'ic_user'
,
$userId
),
true
);
//未认证的用户不可兑换
if
(
isset
(
$user
[
'auth_type'
]))
{
if
(
$user
[
'auth_type'
]
==
0
)
{
return
$this
->
Export
(
self
::
CAN_NOT_EXCHANGE
);
}
}
else
{
return
$this
->
Export
(
self
::
CAN_NOT_EXCHANGE
);
}
//好友助力需要满足两人
$assists
=
json_decode
(
$redis
->
hget
(
'ic_welfare_assists'
,
$exchangeId
),
true
);
$assistsCount
=
$assists
?
count
(
$assists
)
:
0
;
if
(
$assistsCount
<
2
)
{
return
$this
->
Export
(
self
::
ASSIST_NO_ENOUGH
);
}
$result
=
$service
->
confirmExchange
(
$exchangeId
,
$userId
);
if
(
$result
[
'errcode'
]
==
0
)
{
return
$this
->
Export
(
0
,
'ok'
);
//
// $result = $service->confirmExchange($exchangeId);
// if ($result['errcode'] == 0) {
// return $this->Export($result['errcode'], 'ok');
// } else {
// return $this->Export($result['errcode'], '确认兑换失败');
// }
}
else
{
return
$this
->
Export
(
self
::
EXCHANGE_CONFIRM_FAILED
);
}
}
}
\ No newline at end of file
app/Services/UserExchangeService.php
View file @
993f9f8c
...
...
@@ -65,4 +65,17 @@ class UserExchangeService
return
$exchangeStatus
;
}
public
function
confirmExchange
(
$exchangeId
,
$userId
)
{
$url
=
config
(
'website.BaseUrl'
)
.
'/user_exchanges/exchange/confirm'
;
$map
=
[
'exchange_id'
=>
$exchangeId
,
'user_id'
=>
$userId
,
];
$result
=
reportCurl
(
$url
,
$map
,
true
);
$result
=
json_decode
(
$result
,
true
);
return
$result
;
}
}
\ No newline at end of file
config/language.php
View file @
993f9f8c
...
...
@@ -19,6 +19,7 @@ return [
109009
=>
'助力人数已满或者您已经助力过'
,
109010
=>
'自己不能邀请自己'
,
109011
=>
'助力类型只允许用于微信转账'
,
109012
=>
'助力人数不足'
,
109100
=>
'今天已经兑换过了,请明天再来吧'
,
109101
=>
'兑换名额被抢光了'
,
...
...
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