Commit c124e07c by 杨树贤

完成 红包获取列表和红包兑换列表的接口

parent e5a5c571
...@@ -29,7 +29,8 @@ class CheckInController extends Controller ...@@ -29,7 +29,8 @@ class CheckInController extends Controller
public function add(Request $request) public function add(Request $request)
{ {
$map = [ $map = [
'user_id' => $request->user->user_id, 'user_id' => 77,
// 'user_id' => $request->user->user_id,
]; ];
$result = $this->service->addCheckIn($map); $result = $this->service->addCheckIn($map);
if ($result) { if ($result) {
......
<?php
namespace App\Http\Controllers;
use App\Services\IntegralBillsService;
use Illuminate\Http\Request;
use App\Http\Transformers\IntegralBillTransformer;
class IntegralBillsController extends Controller
{
private $service;
public function __construct(IntegralBillsService $service)
{
$this->service = $service;
}
public function index(Request $request, IntegralBillTransformer $transformer)
{
$map = [
'user_id' => $request->user->user_id,
];
$result = $this->service->getIntegralBillList($map);
$result = $transformer->transform($result);
return $this->Export(0, 'ok', $result);
}
}
\ No newline at end of file
<?php
namespace App\Http\Controllers;
use App\Http\Transformers\UserExchangeTransformer;
use App\Services\UserExchangeService;
use Illuminate\Http\Request;
class UserExchangesController extends Controller
{
private $service;
public function __construct(UserExchangeService $service)
{
$this->service = $service;
}
public function index(Request $request, UserExchangeTransformer $transformer)
{
$map = [
'user_id' => $request->user->user_id,
];
$result = $this->service->getUserExchangeList($map);
// dd($result);
$result = $transformer->transform($result);
return $this->Export(0, 'ok', $result);
}
}
\ No newline at end of file
<?php
namespace App\Http\Transformers;
class IntegralBillTransformer
{
public function transform($data = [])
{
if (isset($data['data'])) {
foreach ($data['data'] as $key => $value) {
$data['data'][$key] = [
'id' => array_get($value, 'id'),
'name' => array_get($value['integral'], 'name'),
'add_time' => array_get($value, 'add_time'),
'amount' => array_get($value['integral'], 'amount'),
];
}
}
return $data;
}
}
\ No newline at end of file
<?php
namespace App\Http\Transformers;
class UserExchangeTransformer
{
public function transform($data = [])
{
if (isset($data['data'])) {
foreach ($data['data'] as $key => $value) {
$data['data'][$key] = [
'id' => array_get($value, 'id'),
'amount' => array_get($value, 'amount'),
'name' => array_get($value['exchange_setting'], 'name'),
'add_time' => array_get($value, 'add_time'),
];
}
}
return $data;
}
}
\ No newline at end of file
<?php
namespace App\Services;
class IntegralBillsService
{
public function getIntegralBillList($map = [])
{
$url = config('website.BaseUrl') . '/integral_bills/list';
$result = reportCurl($url, $map, true);
$result = json_decode($result, true);
return $result;
}
}
\ No newline at end of file
<?php
namespace App\Services;
class UserExchangeService
{
public function getUserExchangeList($map = [])
{
$url = config('website.BaseUrl') . '/user_exchanges/list';
$result = reportCurl($url, $map, true);
$result = json_decode($result, true);
return $result;
}
}
\ No newline at end of file
...@@ -27,7 +27,11 @@ $router->group(['middleware' => ['web', 'login']], function () use ($router) { ...@@ -27,7 +27,11 @@ $router->group(['middleware' => ['web', 'login']], function () use ($router) {
//签到 //签到
$router->get('/check_in/list', 'CheckInController@index'); $router->get('/check_in/list', 'CheckInController@index');
$router->post('/check_in/add', 'CheckInController@add');
//红包获取流水
$router->get('integral_bills/list', 'IntegralBillsController@index');
//红包兑换流水
$router->get('user_exchanges/list', 'UserExchangesController@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');
...@@ -37,3 +41,7 @@ $router->group(['middleware' => 'web'], function () use ($router) { ...@@ -37,3 +41,7 @@ $router->group(['middleware' => 'web'], function () use ($router) {
//红包活动信息 //红包活动信息
$router->get('/integrals/list', 'IntegralsController@index'); $router->get('/integrals/list', 'IntegralsController@index');
$router->post('/check_in/add', 'CheckInController@add');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment