Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
ic_server_welfare
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
8a1d4a72
authored
Sep 06, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加签到列表,助力列表,邀请好友列表服务接口
parent
50d7d83f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
6 deletions
app/Http/Controllers/AssistsController.php
app/Http/Controllers/CheckInController.php
app/Http/Controllers/CodesController.php
app/Http/Filters/AssistFilter.php
app/Http/Filters/CodeFilter.php
app/Http/Controllers/AssistsController.php
View file @
8a1d4a72
...
...
@@ -8,6 +8,7 @@ use App\Http\Filters\AssistFilter;
use
App\Models\Assist
;
use
App\Models\UserExchange
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Log
;
/**
* 好友助力
...
...
@@ -34,7 +35,7 @@ class AssistsController extends Controller
$result
=
$assist
->
getAssistList
(
$page
,
$pageSize
,
$filter
);
}
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$result
]
);
return
$this
->
Export
(
0
,
'ok'
,
$result
);
}
/**
...
...
@@ -56,6 +57,12 @@ class AssistsController extends Controller
'add_time'
=>
time
(),
'exchange_id'
=>
$exchangeId
,
];
//自己不能助力自己
if
(
$userId
==
$assistUserId
)
{
return
$this
->
Export
(
ErrorCode
(
8
,
1
),
'自己无法助力自己'
);
}
//因为最多是两个好友对一条兑换进行助力
$canAssist
=
$assist
->
checkCanAssist
(
$exchangeId
,
$assistUserId
);
if
(
$canAssist
)
{
...
...
@@ -65,6 +72,8 @@ class AssistsController extends Controller
}
else
{
return
$this
->
Export
(
ErrorCode
(
20
,
5
),
'新增好友助力记录失败'
);
}
}
else
{
return
$this
->
Export
(
ErrorCode
(
9
,
1
),
'你已助力过或助力人数已足够'
);
}
return
$this
->
Export
(
0
,
'ok'
);
...
...
app/Http/Controllers/CheckInController.php
View file @
8a1d4a72
...
...
@@ -16,8 +16,8 @@ class CheckInController extends Controller
{
public
function
index
(
Request
$request
,
CheckIn
$checkIn
,
CheckInFilter
$filter
)
{
$page
=
$request
->
has
(
'page'
)
?
$request
->
page
:
self
::
DEFAULT_PAGE
;
$pageSize
=
$request
->
has
(
'page_size'
)
?
$request
->
page_size
:
self
::
DEFAULT_PAGE_SIZE
;
$page
=
$request
->
get
(
'page'
)
?
$request
->
page
:
self
::
DEFAULT_PAGE
;
$pageSize
=
$request
->
get
(
'page_size'
)
?
$request
->
page_size
:
self
::
DEFAULT_PAGE_SIZE
;
$checkIns
=
$checkIn
->
getCheckInList
(
$page
,
$pageSize
,
$filter
);
...
...
app/Http/Controllers/CodesController.php
View file @
8a1d4a72
...
...
@@ -3,12 +3,45 @@
namespace
App\Http\Controllers
;
use
App\Http\Filters\CheckInFilter
;
use
App\Http\Filters\CodeFilter
;
use
App\Models\CheckIn
;
use
App\Models\Code
;
use
App\Models\Integral
;
use
Illuminate\Http\Request
;
//红包码兑换管理
/**
* Class CodesController
* @package App\Http\Controllers
*/
class
CodesController
extends
Controller
{
/**
* 获取红包码兑换列表
* @param Request $request
* @param Code $code
* @param CodeFilter $filter
* @return array
*/
public
function
index
(
Request
$request
,
Code
$code
,
CodeFilter
$filter
)
{
$page
=
$request
->
get
(
'page'
)
?
$request
->
page
:
self
::
DEFAULT_PAGE
;
$pageSize
=
$request
->
get
(
'page_size'
)
?
$request
->
page_size
:
self
::
DEFAULT_PAGE_SIZE
;
$codes
=
$code
->
getCodeList
(
$page
,
$pageSize
,
$filter
);
return
$this
->
Export
(
0
,
'ok'
,
$codes
);
}
/**
* 添加红包码兑换
* @param Request $request
* @param Code $code
* @return array
*/
public
function
store
(
Request
$request
,
Code
$code
)
{
$data
=
[
...
...
@@ -26,8 +59,8 @@ class CodesController extends Controller
}
else
{
return
$this
->
Export
(
ErrorCode
(
21
,
5
),
'红包码兑换失败'
);
}
}
else
{
return
$this
->
Export
(
ErrorCode
(
7
,
1
),
'你已兑换过红包码,不能再兑换'
);
}
return
$this
->
Export
(
0
,
'ok'
);
}
}
\ No newline at end of file
app/Http/Filters/AssistFilter.php
View file @
8a1d4a72
...
...
@@ -15,4 +15,14 @@ class AssistFilter extends QueryFilter
{
return
$this
->
builder
->
where
(
'exchange_id'
,
$exchangeId
);
}
public
function
add_time
(
$addTime
=
''
)
{
$addTime
=
explode
(
'~'
,
urldecode
(
$addTime
));
foreach
(
$addTime
as
$key
=>
$value
)
{
$addTime
[
$key
]
=
strtotime
(
$value
);
}
return
$this
->
builder
->
whereBetween
(
'add_time'
,
$addTime
);
}
}
\ No newline at end of file
app/Http/Filters/CodeFilter.php
0 → 100644
View file @
8a1d4a72
<?php
namespace
App\Http\Filters
;
class
CodeFilter
extends
QueryFilter
{
public
function
user_id
(
$userId
=
0
)
{
return
$this
->
builder
->
where
(
'user_id'
,
$userId
);
}
public
function
add_time
(
$addTime
=
''
)
{
$addTime
=
explode
(
'~'
,
urldecode
(
$addTime
));
foreach
(
$addTime
as
$key
=>
$value
)
{
$addTime
[
$key
]
=
strtotime
(
$value
);
}
return
$this
->
builder
->
whereBetween
(
'add_time'
,
$addTime
);
}
public
function
code
(
$code
=
''
)
{
return
$this
->
builder
->
where
(
'code'
,
$code
);
}
}
\ 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