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
558cef37
authored
Sep 16, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
删除签到相关的代码
parent
d8f82dbe
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1 additions
and
138 deletions
app/Http/Controllers/CheckInController.php
app/Http/Controllers/CodesController.php
app/Http/Controllers/Controller.php
app/Http/Filters/CheckInFilter.php
app/Models/CheckIn.php
app/Http/Controllers/CheckInController.php
deleted
100644 → 0
View file @
d8f82dbe
<?php
namespace
App\Http\Controllers
;
use
App\Http\Filters\CheckInFilter
;
use
App\Models\CheckIn
;
use
App\Models\ExchangeSetting
;
use
App\Models\Integral
;
use
App\Models\UserIntegral
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
class
CheckInController
extends
Controller
{
public
function
index
(
Request
$request
,
CheckIn
$checkIn
,
CheckInFilter
$filter
)
{
$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
);
return
$this
->
Export
(
0
,
'ok'
,
$checkIns
);
}
public
function
store
(
Request
$request
,
CheckIn
$checkIn
,
Integral
$integral
)
{
$data
=
[
'user_id'
=>
$request
->
user_id
,
'add_time'
=>
time
(),
];
$canCheckIn
=
$integral
->
checkIntegralLimit
(
$data
[
'user_id'
],
Integral
::
INTEGRAL_TYPE_CHECK_IN
);
if
(
$canCheckIn
)
{
$res
=
$checkIn
->
addCheckIn
(
$data
);
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
return
$this
->
Export
(
ErrorCode
(
18
,
5
),
'新增签到记录失败'
);
}
}
return
$this
->
Export
(
0
,
'ok'
);
}
}
\ No newline at end of file
app/Http/Controllers/CodesController.php
View file @
558cef37
...
...
@@ -3,9 +3,7 @@
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
App\Tasks\SendNoticeTask
;
...
...
app/Http/Controllers/Controller.php
View file @
558cef37
...
...
@@ -45,7 +45,7 @@ class Controller extends BaseController
const
AUDIT_USER_EXCHANGE_FAIL
=
16
;
//审核批量拒绝兑换失败
const
BATCH_AUDIT_REJECT_USER_EXCHANGE
=
17
;
//新增签到记录失败
//新增签到记录失败
(废弃字段)
const
ADD_CHECK_IN_FAIL
=
18
;
//新增邀请好友记录失败
const
ADD_INVITE_FAIL
=
19
;
...
...
app/Http/Filters/CheckInFilter.php
deleted
100644 → 0
View file @
d8f82dbe
<?php
namespace
App\Http\Filters
;
class
CheckInFilter
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
);
}
}
\ No newline at end of file
app/Models/CheckIn.php
deleted
100644 → 0
View file @
d8f82dbe
<?php
namespace
App\Models
;
use
App\Http\Filters\QueryFilter
;
use
App\Tasks\IntegralBillTask
;
use
Common\Model\RedisModel
;
use
Carbon\Carbon
;
use
Hhxsv5\LaravelS\Swoole\Task\Task
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Log
;
class
CheckIn
extends
Model
{
protected
$table
=
'check_in'
;
public
$timestamps
=
false
;
public
function
scopePage
(
$query
,
$page
=
1
,
$pageSize
=
10
)
{
$pageSize
=
$pageSize
<
50
?
$pageSize
:
50
;
return
$query
->
offset
((
$page
-
1
)
*
$pageSize
)
->
limit
(
$pageSize
);
}
public
function
scopeFilter
(
$query
,
QueryFilter
$filters
)
{
return
$filters
->
apply
(
$query
);
}
//获取签到记录
public
function
getCheckInList
(
$page
,
$pageSize
,
$filter
)
{
$checkIns
=
CheckIn
::
filter
(
$filter
)
->
page
(
$page
,
$pageSize
)
->
orderBy
(
'id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
CheckIn
::
filter
(
$filter
)
->
count
();
return
[
'data'
=>
$checkIns
,
'count'
=>
$count
];
}
//添加签到记录
public
function
addCheckIn
(
$data
)
{
$result
=
DB
::
transaction
(
function
()
use
(
$data
)
{
$result
=
DB
::
table
(
'check_in'
)
->
insert
(
$data
);
if
(
!
$result
)
{
return
false
;
}
//使用异步任务去添加流水
$integralBill
=
new
IntegralBill
();
$data
[
'integral_id'
]
=
Integral
::
INTEGRAL_TYPE_CHECK_IN
;
$result
=
$integralBill
->
createIntegralBill
(
$data
);
if
(
!
$result
)
{
return
false
;
}
return
true
;
});
return
$result
;
}
}
\ 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