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
08072c4c
authored
Aug 30, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加判断是否可兑换
parent
ccd55a8b
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
2 deletions
.env
app/Http/Controllers/AssistsController.php
app/Http/Controllers/Controller.php
app/Http/Controllers/ExchangeSettingsController.php
app/Http/Controllers/UserExchangesController.php
app/Services/UserExchangeService.php
config/language.php
.env
View file @
08072c4c
...
...
@@ -7,7 +7,7 @@ SYSTEM_CODE=09
SYSTEM_NAME=商品Api
ELK_NAME=ic_welfare_api
BaseUrl=http://192.168.10.
2
0:61009
BaseUrl=http://192.168.10.
1
0:61009
#BaseUrl=http://ic_server_welfare.test
ES_URL=http://soapi.icsales.com:8001
authapi=http://authapi.icsales.cc
...
...
app/Http/Controllers/AssistsController.php
View file @
08072c4c
app/Http/Controllers/Controller.php
View file @
08072c4c
...
...
@@ -11,7 +11,11 @@ class Controller extends BaseController
const
SUCCESS
=
0
;
//请求参数错误
const
INVALID_PARAMETER
=
109000
;
const
INVALID_PARAMETER
=
109004
;
//用户无法进行兑换,未认证
const
CAN_NOT_EXCHANGE
=
109005
;
const
EXCHANGED_TODAY
=
109100
;
//这个是服务那边返回的错误码,代表已经超出了每日每人可领取的对应项的数额(比如每人每天只能签到一次)
const
INTEGRAL_LIMIT
=
509000
;
...
...
app/Http/Controllers/ExchangeSettingsController.php
View file @
08072c4c
...
...
@@ -5,6 +5,8 @@ namespace App\Http\Controllers;
use
App\Http\Transformers\ExchangeSettingTransformer
;
use
App\Services\ExchangeSettingService
;
use
App\Services\UserExchangeService
;
use
App\Services\UserIntegralService
;
use
Common\Model\RedisModel
;
use
Illuminate\Http\Request
;
...
...
@@ -44,6 +46,10 @@ class ExchangeSettingsController extends Controller
$user
=
json_decode
(
$redis
->
hget
(
'ic_user'
,
$userId
),
true
);
$integral
=
array_get
(
$user
,
'integral'
);
$exchangeSettings
[
'integral'
]
=
$integral
;
$userExchangeService
=
new
UserExchangeService
();
$canExchangeStatus
=
$userExchangeService
->
checkCanExchange
(
$userId
);
$exchangeSettings
[
'can_exchange'
]
=
$canExchangeStatus
;
return
$this
->
Export
(
0
,
'ok'
,
$exchangeSettings
);
}
...
...
app/Http/Controllers/UserExchangesController.php
View file @
08072c4c
...
...
@@ -60,6 +60,14 @@ class UserExchangesController extends Controller
$exchangeId
=
1
;
$userId
=
$request
->
user
->
user_id
;
//判断是否可以兑换
$exchangeStatus
=
$service
->
checkCanExchange
(
$userId
);
if
(
$exchangeStatus
===
-
1
)
{
return
$this
->
Export
(
self
::
CAN_NOT_EXCHANGE
);
}
elseif
(
$exchangeStatus
===
0
)
{
return
$this
->
Export
(
self
::
EXCHANGED_TODAY
);
}
if
(
empty
(
$exchangeId
)
||
empty
(
$type
))
{
return
$this
->
Export
(
self
::
INVALID_PARAMETER
);
}
...
...
app/Services/UserExchangeService.php
View file @
08072c4c
...
...
@@ -28,4 +28,32 @@ class UserExchangeService
return
$result
;
}
//检查用户是否可以进行兑换
public
function
checkCanExchange
(
$userId
)
{
//判断用户是否可以进行兑换
$exchangeStatus
=
1
;
$redis
=
new
RedisModel
();
$user
=
json_decode
(
$redis
->
hget
(
'ic_user'
,
$userId
),
true
);
//第一个是未认证的用户不可兑换,
if
(
isset
(
$user
[
'auth_type'
]))
{
if
(
$user
[
'auth_type'
]
==
0
)
{
$exchangeStatus
=
-
1
;
}
}
else
{
$exchangeStatus
=
-
1
;
}
//再判断今天是否已经兑换过
$time
=
date
(
'Ymd'
);
$key
=
'ic_exchanges_quota_'
.
$time
;
$exchangeId
=
$redis
->
hget
(
$key
,
$userId
);
//第二个是今天已经兑换过的,不允许兑换
if
(
$exchangeId
)
{
$exchangeStatus
=
0
;
}
return
$exchangeStatus
;
}
}
\ No newline at end of file
config/language.php
View file @
08072c4c
...
...
@@ -12,6 +12,7 @@ return [
109002
=>
'Hprose请求失败'
,
109003
=>
'登录失败'
,
109004
=>
'请求参数不正确'
,
109005
=>
'用户无法兑换,用户未认证'
,
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