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
48660cee
authored
Aug 21, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
将数据库操作挪到model里面,同时删除多余的业务
parent
01a0b3ba
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
209 additions
and
178 deletions
app/Http/Controllers/ExchangeSettingsController.php
app/Http/Controllers/IntegralTypesController.php
app/Http/Controllers/IntegralsController.php
app/Http/Controllers/UserExchangesController.php
app/Http/Controllers/UserIntegralsController.php
app/Models/ExchangeSetting.php
app/Models/Integral.php
app/Models/IntegralType.php
app/Models/UserExchange.php
app/Models/UserIntegral.php
storage/laravels.json
storage/laravels.pid
app/Http/Controllers/ExchangeSettingsController.php
View file @
48660cee
...
@@ -17,7 +17,6 @@ use Illuminate\Support\Facades\Log;
...
@@ -17,7 +17,6 @@ use Illuminate\Support\Facades\Log;
*/
*/
class
ExchangeSettingsController
extends
Controller
class
ExchangeSettingsController
extends
Controller
{
{
/**
/**
* 单个红包兑换项详细信息
* 单个红包兑换项详细信息
* @param Request $request
* @param Request $request
...
@@ -34,40 +33,38 @@ class ExchangeSettingsController extends Controller
...
@@ -34,40 +33,38 @@ class ExchangeSettingsController extends Controller
/**
/**
* 红包兑换项列表
* 红包兑换项列表
* @param Request $request
* @param Request $request
* @param ExchangeSetting $exchangeSetting
* @param ExchangeSettingFilter $filter
* @param ExchangeSettingFilter $filter
* @return array
* @return array
*/
*/
public
function
index
(
Request
$request
,
ExchangeSettingFilter
$filter
)
public
function
index
(
Request
$request
,
ExchangeSetting
$exchangeSetting
,
ExchangeSetting
Filter
$filter
)
{
{
$page
=
$request
->
has
(
'page'
)
?
$request
->
page
:
self
::
DEFAULT_PAGE
;
$page
=
$request
->
has
(
'page'
)
?
$request
->
page
:
self
::
DEFAULT_PAGE
;
$page
_s
ize
=
$request
->
has
(
'page_size'
)
?
$request
->
page_size
:
self
::
DEFAULT_PAGE_SIZE
;
$page
S
ize
=
$request
->
has
(
'page_size'
)
?
$request
->
page_size
:
self
::
DEFAULT_PAGE_SIZE
;
$settings
=
ExchangeSetting
::
filter
(
$filter
)
$result
=
$exchangeSetting
->
getExchangeSettingList
(
$page
,
$pageSize
,
$filter
);
->
page
(
$page
,
$page_size
)
->
orderBy
(
'id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
ExchangeSetting
::
filter
(
$filter
)
->
count
();
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$settings
,
'count'
=>
$count
]
);
return
$this
->
Export
(
0
,
'ok'
,
$result
);
}
}
/**
/**
* 存储新增的红包配置项
* 存储新增的红包配置项
* @param Request $request
* @param Request $request
* @param ExchangeSetting $exchangeSetting
* @return array
* @return array
*/
*/
public
function
store
(
Request
$request
)
public
function
store
(
Request
$request
,
ExchangeSetting
$exchangeSetting
)
{
{
$
res
=
DB
::
table
(
'exchange_settings'
)
->
insert
(
[
$
data
=
[
'name'
=>
$request
->
name
,
'name'
=>
$request
->
name
,
'stock'
=>
$request
->
stock
,
'stock'
=>
$request
->
stock
,
'amount'
=>
$request
->
amount
,
'amount'
=>
$request
->
amount
,
'type'
=>
$request
->
type
,
'type'
=>
$request
->
type
,
'add_time'
=>
time
(),
'add_time'
=>
time
(),
'status'
=>
$request
->
status
,
'status'
=>
$request
->
status
,
]
)
;
];
$res
=
$exchangeSetting
->
addExchangeSetting
(
$data
);
if
(
$res
)
{
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
}
else
{
...
@@ -78,9 +75,10 @@ class ExchangeSettingsController extends Controller
...
@@ -78,9 +75,10 @@ class ExchangeSettingsController extends Controller
/**
/**
* 更新红包配置项
* 更新红包配置项
* @param Request $request
* @param Request $request
* @param ExchangeSetting $exchangeSetting
* @return array
* @return array
*/
*/
public
function
update
(
Request
$request
)
public
function
update
(
Request
$request
,
ExchangeSetting
$exchangeSetting
)
{
{
$id
=
$request
->
id
;
$id
=
$request
->
id
;
$data
=
[
$data
=
[
...
@@ -91,8 +89,7 @@ class ExchangeSettingsController extends Controller
...
@@ -91,8 +89,7 @@ class ExchangeSettingsController extends Controller
'status'
=>
$request
->
status
,
'status'
=>
$request
->
status
,
'update_time'
=>
time
(),
'update_time'
=>
time
(),
];
];
$res
=
DB
::
table
(
'exchange_settings'
)
->
where
(
'id'
,
$id
)
$res
=
$exchangeSetting
->
updateExchangeSetting
(
$id
,
$data
);
->
update
(
$data
);
if
(
!
$res
)
{
if
(
!
$res
)
{
return
$this
->
Export
(
042
,
'更新红包配置项失败'
);
return
$this
->
Export
(
042
,
'更新红包配置项失败'
);
}
else
{
}
else
{
...
@@ -104,9 +101,10 @@ class ExchangeSettingsController extends Controller
...
@@ -104,9 +101,10 @@ class ExchangeSettingsController extends Controller
/**
/**
* 修改配置项是否可用状态
* 修改配置项是否可用状态
* @param Request $request
* @param Request $request
* @param ExchangeSetting $exchangeSetting
* @return array
* @return array
*/
*/
public
function
updateStatus
(
Request
$request
)
public
function
updateStatus
(
Request
$request
,
ExchangeSetting
$exchangeSetting
)
{
{
$id
=
$request
->
id
;
$id
=
$request
->
id
;
$status
=
$request
->
status
;
$status
=
$request
->
status
;
...
@@ -114,8 +112,7 @@ class ExchangeSettingsController extends Controller
...
@@ -114,8 +112,7 @@ class ExchangeSettingsController extends Controller
'status'
=>
$status
,
'status'
=>
$status
,
'update_time'
=>
time
(),
'update_time'
=>
time
(),
];
];
$res
=
DB
::
table
(
'exchange_settings'
)
->
where
(
'id'
,
$id
)
$res
=
$exchangeSetting
->
updateExchangeSetting
(
$id
,
$data
);
->
update
(
$data
);
if
(
$res
)
{
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
return
$this
->
Export
(
0
,
'ok'
);
...
@@ -127,13 +124,14 @@ class ExchangeSettingsController extends Controller
...
@@ -127,13 +124,14 @@ class ExchangeSettingsController extends Controller
/**
/**
* 删除红包配置项
* 删除红包配置项
* @param Request $request
* @param Request $request
* @param ExchangeSetting $exchangeSetting
* @return array
* @return array
*/
*/
public
function
destroy
(
Request
$request
)
public
function
destroy
(
Request
$request
,
ExchangeSetting
$exchangeSetting
)
{
{
$ids
=
$request
->
ids
;
$ids
=
$request
->
ids
;
$ids
=
explode
(
','
,
trim
(
$ids
));
$ids
=
explode
(
','
,
trim
(
$ids
));
$res
=
DB
::
table
(
'exchange_settings'
)
->
whereIn
(
'id'
,
$ids
)
->
delete
(
);
$res
=
$exchangeSetting
->
deleteExchangeSetting
(
$ids
);
if
(
$res
)
{
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
}
else
{
...
@@ -144,19 +142,17 @@ class ExchangeSettingsController extends Controller
...
@@ -144,19 +142,17 @@ class ExchangeSettingsController extends Controller
/**
/**
* 批量更新红包配置项状态
* 批量更新红包配置项状态
* @param Request $request
* @param Request $request
* @param ExchangeSetting $exchangeSetting
* @return array
* @return array
*/
*/
public
function
batchUpdateStatus
(
Request
$request
)
public
function
batchUpdateStatus
(
Request
$request
,
ExchangeSetting
$exchangeSetting
)
{
{
$ids
=
$request
->
ids
;
$ids
=
$request
->
ids
;
if
(
!
is_array
(
$ids
))
{
if
(
!
is_array
(
$ids
))
{
return
Log
::
Info
(
'批量修改参数不是数组'
);
return
Log
::
Info
(
'批量修改参数不是数组'
);
}
}
$status
=
$request
->
status
;
$status
=
$request
->
status
;
$res
=
DB
::
table
(
'exchange_settings'
)
$res
=
$exchangeSetting
->
batchUpdateStatus
(
$status
,
$ids
);
->
whereIn
(
'id'
,
$ids
)
->
update
([
'status'
=>
(
int
)
$status
,
'update_time'
=>
time
()]);
if
(
$res
)
{
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
}
else
{
...
...
app/Http/Controllers/IntegralTypesController.php
deleted
100644 → 0
View file @
01a0b3ba
<?php
namespace
App\Http\Controllers
;
use
App\Models\IntegralType
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
/**
* 红包类型管理
* Class IntegralTypesController
* @package App\Http\Controllers
*/
class
IntegralTypesController
extends
Controller
{
/**红包类型列表
* @return array
*/
public
function
index
()
{
$integrals
=
IntegralType
::
all
()
->
toArray
();
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$integrals
]);
}
/**
* 创建红包类型
* @param Request $request
* @return array
*/
public
function
create
(
Request
$request
)
{
$res
=
DB
::
table
(
'integral_types'
)
->
insert
([
'name'
=>
$request
->
name
,
'add_time'
=>
time
(),
'status'
=>
1
,
]);
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
return
$this
->
Export
(
ErrorCode
(
011
,
5
),
'新增红包分类失败'
);
}
}
/**
* 更新红包类型
* @param Request $request
* @return array
*/
public
function
update
(
Request
$request
)
{
$id
=
$request
->
id
;
$res
=
DB
::
table
(
'integral_types'
)
->
where
(
'id'
,
$id
)
->
update
([
'name'
=>
$request
->
name
,
'status'
=>
$request
->
status
,
]);
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
return
$this
->
Export
(
ErrorCode
(
012
,
5
),
'更新红包分类失败'
);
}
}
/**
* 删除红包类型
* @param Request $request
* @return array
*/
public
function
destroy
(
Request
$request
)
{
$ids
=
$request
->
ids
;
$ids
=
explode
(
','
,
trim
(
$ids
));
$res
=
DB
::
table
(
'integral_types'
)
->
whereIn
(
'id'
,
$ids
)
->
delete
();
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
return
$this
->
Export
(
ErrorCode
(
013
,
5
),
'删除红包分类失败'
);
}
}
}
\ No newline at end of file
app/Http/Controllers/IntegralsController.php
View file @
48660cee
...
@@ -33,39 +33,37 @@ class IntegralsController extends Controller
...
@@ -33,39 +33,37 @@ class IntegralsController extends Controller
/**
/**
* 红包列表
* 红包列表
* @param Request $request
* @param Request $request
* @param Integral $integral
* @param IntegralFilter $filter
* @param IntegralFilter $filter
* @return array
* @return array
*/
*/
public
function
index
(
Request
$request
,
IntegralFilter
$filter
)
public
function
index
(
Request
$request
,
Integral
$integral
,
Integral
Filter
$filter
)
{
{
$page
=
$request
->
has
(
'page'
)
?
$request
->
page
:
self
::
DEFAULT_PAGE
;
$page
=
$request
->
has
(
'page'
)
?
$request
->
page
:
self
::
DEFAULT_PAGE
;
$page
_s
ize
=
$request
->
has
(
'page_size'
)
?
$request
->
page_size
:
self
::
DEFAULT_PAGE_SIZE
;
$page
S
ize
=
$request
->
has
(
'page_size'
)
?
$request
->
page_size
:
self
::
DEFAULT_PAGE_SIZE
;
$integrals
=
Integral
::
with
(
'integralType:id,name'
)
$result
=
$integral
->
getIntegralList
(
$page
,
$pageSize
,
$filter
);
->
filter
(
$filter
)
->
page
(
$page
,
$page_size
)
->
orderBy
(
'id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
Integral
::
count
();
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$integrals
,
'count'
=>
$count
]
);
return
$this
->
Export
(
0
,
'ok'
,
$result
);
}
}
/**
/**
* 创建红包
* 创建红包
* @param Request $request
* @param Request $request
* @param Integral $integral
* @return array
* @return array
*/
*/
public
function
create
(
Request
$request
)
public
function
create
(
Request
$request
,
Integral
$integral
)
{
{
$
res
=
DB
::
table
(
'integrals'
)
->
insert
(
[
$
data
=
[
'name'
=>
$request
->
name
,
'name'
=>
$request
->
name
,
'daily_limit'
=>
$request
->
daily_limit
,
'daily_limit'
=>
$request
->
daily_limit
,
'amount'
=>
$request
->
amount
,
'amount'
=>
$request
->
amount
,
'add_time'
=>
time
(),
'add_time'
=>
time
(),
'status'
=>
$request
->
status
,
'status'
=>
$request
->
status
,
]
)
;
];
$res
=
$integral
->
addIntegral
(
$data
);
if
(
$res
)
{
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
}
else
{
...
@@ -76,9 +74,10 @@ class IntegralsController extends Controller
...
@@ -76,9 +74,10 @@ class IntegralsController extends Controller
/**
/**
* 更新红包
* 更新红包
* @param Request $request
* @param Request $request
* @param Integral $integral
* @return array
* @return array
*/
*/
public
function
update
(
Request
$request
)
public
function
update
(
Request
$request
,
Integral
$integral
)
{
{
$id
=
$request
->
id
;
$id
=
$request
->
id
;
$data
=
[
$data
=
[
...
@@ -88,8 +87,8 @@ class IntegralsController extends Controller
...
@@ -88,8 +87,8 @@ class IntegralsController extends Controller
'daily_limit'
=>
$request
->
daily_limit
,
'daily_limit'
=>
$request
->
daily_limit
,
'update_time'
=>
time
(),
'update_time'
=>
time
(),
];
];
$res
=
DB
::
table
(
'integrals'
)
->
where
(
'id'
,
$id
)
->
update
(
$data
);
$res
=
$integral
->
updateIntegral
(
$id
,
$data
);
if
(
!
$res
)
{
if
(
!
$res
)
{
return
$this
->
Export
(
002
,
'更新红包信息失败'
);
return
$this
->
Export
(
002
,
'更新红包信息失败'
);
}
else
{
}
else
{
...
@@ -100,9 +99,10 @@ class IntegralsController extends Controller
...
@@ -100,9 +99,10 @@ class IntegralsController extends Controller
/**
/**
* 更新红包是否可用状态
* 更新红包是否可用状态
* @param Request $request
* @param Request $request
* @param Integral $integral
* @return array
* @return array
*/
*/
public
function
updateStatus
(
Request
$request
)
public
function
updateStatus
(
Request
$request
,
Integral
$integral
)
{
{
$id
=
$request
->
id
;
$id
=
$request
->
id
;
$status
=
$request
->
status
;
$status
=
$request
->
status
;
...
@@ -110,9 +110,8 @@ class IntegralsController extends Controller
...
@@ -110,9 +110,8 @@ class IntegralsController extends Controller
'status'
=>
$status
,
'status'
=>
$status
,
'update_time'
=>
time
(),
'update_time'
=>
time
(),
];
];
$res
=
DB
::
table
(
'integrals'
)
->
where
(
'id'
,
$id
)
->
update
(
$data
);
$res
=
$integral
->
updateIntegral
(
$id
,
$data
);
if
(
$res
)
{
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
}
else
{
...
@@ -123,18 +122,18 @@ class IntegralsController extends Controller
...
@@ -123,18 +122,18 @@ class IntegralsController extends Controller
/**
/**
* 批量更改状态
* 批量更改状态
* @param Request $request
* @param Request $request
* @param Integral $integral
* @return array
* @return array
*/
*/
public
function
batchUpdateStatus
(
Request
$request
)
public
function
batchUpdateStatus
(
Request
$request
,
Integral
$integral
)
{
{
$ids
=
$request
->
ids
;
$ids
=
$request
->
ids
;
if
(
!
is_array
(
$ids
))
{
if
(
!
is_array
(
$ids
))
{
return
Log
::
Info
(
'批量修改参数不是数组'
);
return
Log
::
Info
(
'批量修改参数不是数组'
);
}
}
$status
=
$request
->
status
;
$status
=
$request
->
status
;
$res
=
DB
::
table
(
'integrals'
)
$data
=
[
'status'
=>
$status
,
'update_time'
=>
time
()];
->
whereIn
(
'id'
,
$ids
)
$res
=
$integral
->
batchUpdateStatus
(
$ids
,
$data
);
->
update
([
'status'
=>
(
int
)
$status
,
'update_time'
=>
time
()]);
if
(
!
$res
)
{
if
(
!
$res
)
{
return
$this
->
Export
(
004
,
'批量更新红包信息状态失败'
);
return
$this
->
Export
(
004
,
'批量更新红包信息状态失败'
);
...
@@ -146,13 +145,14 @@ class IntegralsController extends Controller
...
@@ -146,13 +145,14 @@ class IntegralsController extends Controller
/**
/**
* 删除红包
* 删除红包
* @param Request $request
* @param Request $request
* @param Integral $integral
* @return array
* @return array
*/
*/
public
function
destroy
(
Request
$request
)
public
function
destroy
(
Request
$request
,
Integral
$integral
)
{
{
$ids
=
$request
->
ids
;
$ids
=
$request
->
ids
;
$ids
=
explode
(
','
,
trim
(
$ids
));
$ids
=
explode
(
','
,
trim
(
$ids
));
$res
=
DB
::
table
(
'integrals'
)
->
whereIn
(
'id'
,
$ids
)
->
delete
(
);
$res
=
$integral
->
deleteIntegral
(
$ids
);
if
(
!
$res
)
{
if
(
!
$res
)
{
return
$this
->
Export
(
ErrorCode
(
003
,
5
),
'删除红包信息失败'
);
return
$this
->
Export
(
ErrorCode
(
003
,
5
),
'删除红包信息失败'
);
}
else
{
}
else
{
...
...
app/Http/Controllers/UserExchangesController.php
View file @
48660cee
...
@@ -32,21 +32,18 @@ class UserExchangesController extends Controller
...
@@ -32,21 +32,18 @@ class UserExchangesController extends Controller
/**
/**
* 用户兑换红包列表
* 用户兑换红包列表
* @param Request $request
* @param Request $request
* @param UserExchange $userExchange
* @param UserExchangeFilter $filter
* @param UserExchangeFilter $filter
* @return array
* @return array
*/
*/
public
function
index
(
Request
$request
,
UserExchangeFilter
$filter
)
public
function
index
(
Request
$request
,
UserExchange
$userExchange
,
UserExchange
Filter
$filter
)
{
{
$page
=
$request
->
has
(
'page'
)
?
$request
->
page
:
self
::
DEFAULT_PAGE
;
$page
=
$request
->
has
(
'page'
)
?
$request
->
page
:
self
::
DEFAULT_PAGE
;
$pageSize
=
$request
->
has
(
'page_size'
)
?
$request
->
page_size
:
self
::
DEFAULT_PAGE_SIZE
;
$pageSize
=
$request
->
has
(
'page_size'
)
?
$request
->
page_size
:
self
::
DEFAULT_PAGE_SIZE
;
$userExchanges
=
UserExchange
::
with
([
'exchange_setting'
,
'user_integral'
])
->
filter
(
$filter
)
->
page
(
$page
,
$res
=
$userExchange
->
getUserExchangeList
(
$page
,
$pageSize
,
$filter
);
$pageSize
)
->
orderBy
(
'id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
UserExchange
::
filter
(
$filter
)
->
count
();
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$userExchanges
,
'count'
=>
$count
]
);
return
$this
->
Export
(
0
,
'ok'
,
$res
);
}
}
...
@@ -78,6 +75,7 @@ class UserExchangesController extends Controller
...
@@ -78,6 +75,7 @@ class UserExchangesController extends Controller
/**
/**
* 批量审核
* 批量审核
* @param Request $request
* @param Request $request
* @param UserExchange $userExchange
* @return array
* @return array
*/
*/
public
function
batchAuditReject
(
Request
$request
,
UserExchange
$userExchange
)
public
function
batchAuditReject
(
Request
$request
,
UserExchange
$userExchange
)
...
...
app/Http/Controllers/UserIntegralsController.php
View file @
48660cee
...
@@ -8,7 +8,6 @@ use App\Http\Filters\UserIntegralFilter;
...
@@ -8,7 +8,6 @@ use App\Http\Filters\UserIntegralFilter;
use
App\Models\IntegralBill
;
use
App\Models\IntegralBill
;
use
App\Models\UserIntegral
;
use
App\Models\UserIntegral
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Log
;
/**
/**
...
@@ -37,62 +36,63 @@ class UserIntegralsController extends Controller
...
@@ -37,62 +36,63 @@ class UserIntegralsController extends Controller
/**
/**
* 用户红包详情列表
* 用户红包详情列表
* @param Request $request
* @param Request $request
* @param UserIntegral $userIntegral
* @param UserIntegralFilter $filter
* @param UserIntegralFilter $filter
* @return array
* @return array
*/
*/
public
function
index
(
Request
$request
,
UserIntegralFilter
$filter
)
public
function
index
(
Request
$request
,
UserIntegral
$userIntegral
,
UserIntegral
Filter
$filter
)
{
{
$integrals
=
UserIntegral
::
filter
(
$filter
)
->
page
(
$request
->
page
,
$request
->
page_size
)
$page
=
$request
->
has
(
'page'
)
?
$request
->
page
:
self
::
DEFAULT_PAGE
;
->
orderBy
(
'id'
,
'desc'
)
$pageSize
=
$request
->
has
(
'page_size'
)
?
$request
->
page_size
:
self
::
DEFAULT_PAGE_SIZE
;
->
get
()
->
toArray
();
$count
=
UserIntegral
::
filter
(
$filter
)
->
count
();
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$integrals
,
'count'
=>
$count
]);
$res
=
$userIntegral
->
getUserIntegralList
(
$page
,
$pageSize
,
$filter
);
return
$this
->
Export
(
0
,
'ok'
,
$res
);
}
}
/**
/**
* 更新用户红包可领取状态
* 更新用户红包可领取状态
* @param Request $request
* @param Request $request
* @param UserIntegral $userIntegral
* @return array
* @return array
*/
*/
public
function
updateStatus
(
Request
$request
)
public
function
updateStatus
(
Request
$request
,
UserIntegral
$userIntegral
)
{
{
$id
=
$request
->
id
;
$id
=
$request
->
id
;
$status
=
$request
->
status
;
$data
=
[
$data
=
[
'status'
=>
$status
,
'status'
=>
$
request
->
status
,
'update_time'
=>
time
(),
'update_time'
=>
time
(),
];
];
$res
=
DB
::
table
(
'user_integrals'
)
->
where
(
'id'
,
$id
)
->
update
(
$data
);
$res
=
$userIntegral
->
updateUserIntegral
(
$id
,
$data
);
if
(
$res
)
{
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
}
else
{
return
$this
->
Export
(
0
5
1
,
'修改用户红包可领取状态失败'
);
return
$this
->
Export
(
0
1
1
,
'修改用户红包可领取状态失败'
);
}
}
}
}
/**
/**
* 批量修改用户是否能够领取红包
* 批量修改用户是否能够领取红包
* @param Request $request
* @param Request $request
* @param UserIntegral $userIntegral
* @return array
* @return array
*/
*/
public
function
batchUpdateStatus
(
Request
$request
)
public
function
batchUpdateStatus
(
Request
$request
,
UserIntegral
$userIntegral
)
{
{
$ids
=
$request
->
ids
;
$ids
=
$request
->
ids
;
if
(
!
is_array
(
$ids
))
{
if
(
!
is_array
(
$ids
))
{
return
Log
::
Info
(
'批量修改参数不是数组'
);
return
Log
::
Info
(
'批量修改参数不是数组'
);
}
}
$status
=
$request
->
status
;
$res
=
DB
::
table
(
'user_integrals'
)
->
whereIn
(
'id'
,
$ids
)
->
update
([
'status'
=>
(
int
)
$status
,
'update_time'
=>
time
()]);
$data
=
[
'status'
=>
(
int
)
$request
->
status
,
'update_time'
=>
time
()];
$res
=
$userIntegral
->
batchUpdateStatus
(
$ids
,
$data
);
if
(
$res
)
{
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
}
else
{
return
$this
->
Export
(
0
5
2
,
'批量修改用户是否可领取红包失败'
);
return
$this
->
Export
(
0
1
2
,
'批量修改用户是否可领取红包失败'
);
}
}
}
}
...
...
app/Models/ExchangeSetting.php
View file @
48660cee
...
@@ -6,6 +6,7 @@ namespace App\Models;
...
@@ -6,6 +6,7 @@ namespace App\Models;
use
App\Http\Filters\QueryFilter
;
use
App\Http\Filters\QueryFilter
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Support\Facades\DB
;
class
ExchangeSetting
extends
Model
class
ExchangeSetting
extends
Model
{
{
...
@@ -20,4 +21,54 @@ class ExchangeSetting extends Model
...
@@ -20,4 +21,54 @@ class ExchangeSetting extends Model
{
{
return
$filters
->
apply
(
$query
);
return
$filters
->
apply
(
$query
);
}
}
public
function
getExchangeSettingList
(
$page
,
$pageSize
,
$filter
)
{
$settings
=
ExchangeSetting
::
filter
(
$filter
)
->
page
(
$page
,
$pageSize
)
->
orderBy
(
'id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
ExchangeSetting
::
filter
(
$filter
)
->
count
();
return
[
'data'
=>
$settings
,
'count'
=>
$count
];
}
public
function
addExchangeSetting
(
$data
=
[])
{
$result
=
DB
::
table
(
'exchange_settings'
)
->
insert
(
$data
);
return
$result
;
}
public
function
updateExchangeSetting
(
$id
,
$data
=
[])
{
$result
=
DB
::
table
(
'exchange_settings'
)
->
where
(
'id'
,
$id
)
->
update
(
$data
);
return
$result
;
}
public
function
deleteExchangeSetting
(
$ids
=
[])
{
$res
=
DB
::
table
(
'exchange_settings'
)
->
whereIn
(
'id'
,
$ids
)
->
delete
();
return
$res
;
}
/**
* 批量修改状态
* @param $status
* @param array $ids
* @return bool
*/
public
function
batchUpdateStatus
(
$status
,
$ids
=
[])
{
$res
=
DB
::
table
(
'exchange_settings'
)
->
whereIn
(
'id'
,
$ids
)
->
update
([
'status'
=>
(
int
)
$status
,
'update_time'
=>
time
()]);
return
$res
;
}
}
}
\ No newline at end of file
app/Models/Integral.php
View file @
48660cee
...
@@ -6,6 +6,7 @@ namespace App\Models;
...
@@ -6,6 +6,7 @@ namespace App\Models;
use
App\Http\Filters\QueryFilter
;
use
App\Http\Filters\QueryFilter
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Support\Facades\DB
;
class
Integral
extends
Model
class
Integral
extends
Model
{
{
...
@@ -27,4 +28,45 @@ class Integral extends Model
...
@@ -27,4 +28,45 @@ class Integral extends Model
{
{
return
$this
->
belongsTo
(
IntegralType
::
class
,
'integral_type_id'
,
'id'
);
return
$this
->
belongsTo
(
IntegralType
::
class
,
'integral_type_id'
,
'id'
);
}
}
public
function
getIntegralList
(
$page
,
$pageSize
,
$filter
)
{
$integrals
=
Integral
::
with
(
'integralType:id,name'
)
->
filter
(
$filter
)
->
page
(
$page
,
$pageSize
)
->
orderBy
(
'id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
Integral
::
count
();
return
[
'data'
=>
$integrals
,
'count'
=>
$count
];
}
public
function
addIntegral
(
$data
=
[])
{
$res
=
DB
::
table
(
'integrals'
)
->
insert
(
$data
);
return
$res
;
}
public
function
updateIntegral
(
$id
,
$data
=
[])
{
$res
=
DB
::
table
(
'integrals'
)
->
where
(
'id'
,
$id
)
->
update
(
$data
);
return
$res
;
}
public
function
batchUpdateStatus
(
$ids
=
[],
$data
=
[])
{
$res
=
DB
::
table
(
'integrals'
)
->
whereIn
(
'id'
,
$ids
)
->
update
(
$data
);
return
$res
;
}
public
function
deleteIntegral
(
$ids
=
[])
{
$res
=
DB
::
table
(
'integrals'
)
->
whereIn
(
'id'
,
$ids
)
->
delete
();
return
$res
;
}
}
}
\ No newline at end of file
app/Models/IntegralType.php
deleted
100644 → 0
View file @
01a0b3ba
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Model
;
class
IntegralType
extends
Model
{
public
$timestamps
=
false
;
protected
$fillable
=
[
'name'
,
'status'
];
}
\ No newline at end of file
app/Models/UserExchange.php
View file @
48660cee
...
@@ -33,6 +33,18 @@ class UserExchange extends Model
...
@@ -33,6 +33,18 @@ class UserExchange extends Model
}
}
public
function
getUserExchangeList
(
$page
,
$pageSize
,
$filter
)
{
$userExchanges
=
UserExchange
::
with
([
'exchange_setting'
,
'user_integral'
])
->
filter
(
$filter
)
->
page
(
$page
,
$pageSize
)
->
orderBy
(
'id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
UserExchange
::
filter
(
$filter
)
->
count
();
return
[
'data'
=>
$userExchanges
,
'count'
=>
$count
];
}
//审核用户的兑换
//审核用户的兑换
public
function
auditUserExchange
(
$id
,
$exchangedAmount
,
$data
=
[])
public
function
auditUserExchange
(
$id
,
$exchangedAmount
,
$data
=
[])
{
{
...
...
app/Models/UserIntegral.php
View file @
48660cee
...
@@ -6,6 +6,7 @@ namespace App\Models;
...
@@ -6,6 +6,7 @@ namespace App\Models;
use
App\Http\Filters\QueryFilter
;
use
App\Http\Filters\QueryFilter
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Support\Facades\DB
;
class
UserIntegral
extends
Model
class
UserIntegral
extends
Model
{
{
...
@@ -20,4 +21,32 @@ class UserIntegral extends Model
...
@@ -20,4 +21,32 @@ class UserIntegral extends Model
{
{
return
$filters
->
apply
(
$query
);
return
$filters
->
apply
(
$query
);
}
}
public
function
getUserIntegralList
(
$page
,
$pageSize
,
$filter
)
{
$settings
=
UserIntegral
::
filter
(
$filter
)
->
page
(
$page
,
$pageSize
)
->
orderBy
(
'id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
UserIntegral
::
filter
(
$filter
)
->
count
();
return
[
'data'
=>
$settings
,
'count'
=>
$count
];
}
public
function
updateUserIntegral
(
$id
,
$data
=
[])
{
$res
=
DB
::
table
(
'user_integrals'
)
->
where
(
'id'
,
$id
)
->
update
(
$data
);
return
$res
;
}
public
function
batchUpdateStatus
(
$ids
=
[],
$data
=
[])
{
$res
=
DB
::
table
(
'user_integrals'
)
->
whereIn
(
'id'
,
$ids
)
->
update
(
$data
);
return
$res
;
}
}
}
\ No newline at end of file
storage/laravels.json
View file @
48660cee
This diff is collapsed.
Click to expand it.
storage/laravels.pid
View file @
48660cee
17991
18264
\ No newline at end of file
\ 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