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
9281a9ba
authored
Aug 26, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完成兑换配置项的获取接口
parent
1c06503e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
1 deletions
app/Http/Controllers/ExchangeSettingsController.php
app/Http/Transformers/ExchangeSettingTransformer.php
app/Services/ExchangeSettingService.php
routes/web.php
app/Http/Controllers/ExchangeSettingsController.php
View file @
9281a9ba
...
@@ -3,6 +3,10 @@
...
@@ -3,6 +3,10 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\Http\Transformers\ExchangeSettingTransformer
;
use
App\Services\ExchangeSettingService
;
use
Common\Model\RedisModel
;
use
Illuminate\Http\Request
;
/**
/**
* 商品兑换配置
* 商品兑换配置
...
@@ -11,8 +15,36 @@ namespace App\Http\Controllers;
...
@@ -11,8 +15,36 @@ namespace App\Http\Controllers;
*/
*/
class
ExchangeSettingsController
extends
Controller
class
ExchangeSettingsController
extends
Controller
{
{
public
function
index
()
/**
* @var ExchangeSettingService
*/
private
$service
;
public
function
__construct
(
ExchangeSettingService
$service
)
{
$this
->
service
=
$service
;
}
/**
* 获取配置列表
* @param Request $request
* @param ExchangeSettingTransformer $transformer
* @return array|false|string
*/
public
function
index
(
Request
$request
,
ExchangeSettingTransformer
$transformer
)
{
{
$type
=
$request
->
get
(
'type'
);
//is_api是为了告诉服务器是接口去请求
$map
=
$type
?
[
'type'
=>
$type
,
'is_api'
=>
1
]
:
[];
$exchangeSettings
=
$this
->
service
->
getExchangeSettingList
(
$map
);
$exchangeSettings
=
$transformer
->
transform
(
$exchangeSettings
);
$userId
=
$request
->
user
->
user_id
;
//从redis里面取出用户的剩余红包
$redis
=
new
RedisModel
();
$user
=
json_decode
(
$redis
->
hget
(
'ic_user'
,
$userId
),
true
);
$integral
=
array_get
(
$user
,
'integral'
);
$exchangeSettings
[
'integral'
]
=
$integral
;
return
$this
->
Export
(
0
,
'ok'
,
$exchangeSettings
);
}
}
}
}
\ No newline at end of file
app/Http/Transformers/ExchangeSettingTransformer.php
0 → 100644
View file @
9281a9ba
<?php
namespace
App\Http\Transformers
;
class
ExchangeSettingTransformer
{
public
function
transform
(
$data
=
[])
{
if
(
isset
(
$data
[
'data'
])
&&
is_array
(
$data
[
'data'
]))
{
foreach
(
$data
[
'data'
]
as
$key
=>
&
$value
)
{
unset
(
$value
[
'add_time'
]);
unset
(
$value
[
'update_time'
]);
unset
(
$value
[
'status'
]);
}
unset
(
$value
);
}
return
$data
;
}
}
\ No newline at end of file
app/Services/ExchangeSettingService.php
View file @
9281a9ba
...
@@ -6,5 +6,12 @@ namespace App\Services;
...
@@ -6,5 +6,12 @@ namespace App\Services;
class
ExchangeSettingService
class
ExchangeSettingService
{
{
public
function
getExchangeSettingList
(
$map
=
[])
{
$url
=
config
(
'website.BaseUrl'
)
.
'/exchange_settings/list'
;
$result
=
reportCurl
(
$url
,
$map
,
true
);
$result
=
json_decode
(
$result
,
true
);
return
$result
;
}
}
}
\ No newline at end of file
routes/web.php
View file @
9281a9ba
...
@@ -34,6 +34,9 @@ $router->group(['middleware' => ['web', 'login']], function () use ($router) {
...
@@ -34,6 +34,9 @@ $router->group(['middleware' => ['web', 'login']], function () use ($router) {
$router
->
get
(
'integral_bills/list'
,
'IntegralBillsController@index'
);
$router
->
get
(
'integral_bills/list'
,
'IntegralBillsController@index'
);
//红包兑换流水
//红包兑换流水
$router
->
get
(
'user_exchanges/list'
,
'UserExchangesController@index'
);
$router
->
get
(
'user_exchanges/list'
,
'UserExchangesController@index'
);
//商品配置列表
$router
->
get
(
'exchange_settings/list'
,
'ExchangeSettingsController@index'
);
});
});
$router
->
group
([
'middleware'
=>
'web'
],
function
()
use
(
$router
)
{
$router
->
group
([
'middleware'
=>
'web'
],
function
()
use
(
$router
)
{
$router
->
post
(
'/oss/upload'
,
'OssController@upload'
);
$router
->
post
(
'/oss/upload'
,
'OssController@upload'
);
...
...
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