Commit 603eaa09 by 杨树贤

兑换红包接口

parent afeb7343
<?php
namespace App\Http\Controllers;
use App\Services\CodeService;
use Illuminate\Http\Request;
/**
* 红包码
* Class CodesController
* @package App\Http\Controllers
*/
class CodesController extends Controller
{
/**
* 兑换红包码
* @param Request $request
* @param CodeService $service
* @return array
*/
public function store(Request $request, CodeService $service)
{
$code = $request->get('code');
if (empty($code)) {
return $this->Export(self::INVALID_PARAMETER);
}
$data = [
'user_id' => $request->user->user_id,
'code' => $request->get('code'),
];
$result = $service->addCode($data);
if ($result['errcode'] === self::SUCCESS) {
return $this->Export(0, 'ok');
} else {
return $this->Export(self::EXCHANGE_CODE_FAIL);
}
}
}
\ No newline at end of file
<?php
namespace App\Services;
class CodeService
{
//回复报价需要添加流水
public function addCode($map = [])
{
$url = config('website.BaseUrl') . '/codes/add';
$result = reportCurl($url, $map, true);
$result = json_decode($result, true);
return $result;
}
}
\ No newline at end of file
...@@ -11,20 +11,11 @@ ...@@ -11,20 +11,11 @@
| |
*/ */
$router->get('/', function () use ($router) { $router->addRoute(['GET', 'POST'], '/', function () use ($router) {
return $router->app->version(); return $router->app->version();
}); });
$router->group(['middleware' => ['web', 'login']], function () use ($router) { $router->group(['middleware' => ['web', 'login']], function () use ($router) {
$router->get('/goods/add', 'ApiController@AddGoods');
$router->get('/goods/info', 'ApiController@GoodsInfo');
$router->get('/goods/save', 'ApiController@SaveGoods');
$router->get('/goods/status', 'ApiController@GoodsStatus');
$router->get('/goods/count', 'ApiController@MysqlGoodsCount');
$router->post('/goods/upload', 'ApiController@UploadGoods');
$router->options('/goods/upload', 'ApiController@UploadGoods');//前端插件需要这个请求
$router->get('/goods/upload/list', 'ApiController@UploadGoodsList');
//签到 //签到
$router->get('/check_in/list', 'CheckInController@index'); $router->get('/check_in/list', 'CheckInController@index');
$router->post('/check_in/add', 'CheckInController@add'); $router->post('/check_in/add', 'CheckInController@add');
...@@ -46,21 +37,21 @@ $router->group(['middleware' => ['web', 'login']], function () use ($router) { ...@@ -46,21 +37,21 @@ $router->group(['middleware' => ['web', 'login']], function () use ($router) {
$router->get('exchange_settings/list', 'ExchangeSettingsController@index'); $router->get('exchange_settings/list', 'ExchangeSettingsController@index');
//用户兑换接口 //用户兑换接口
$router->post('user_exchanges/exchange', 'UserExchangesController@exchange'); $router->addRoute(['GET', 'POST'], 'user_exchanges/exchange', 'UserExchangesController@exchange');
//每日分享 //每日分享
$router->post('share/add', 'ShareController@store'); $router->addRoute(['GET', 'POST'], 'share/add', 'ShareController@store');
//邀请好友 //邀请好友
$router->post('invites/add', 'InvitesController@store'); $router->addRoute(['GET', 'POST'], 'invites/add', 'InvitesController@store');
$router->get('invites/list', 'InvitesController@index'); $router->get('invites/list', 'InvitesController@index');
$router->get('invites/info', 'InvitesController@info'); $router->get('invites/info', 'InvitesController@info');
//红包兑换
$router->addRoute(['GET', 'POST'], 'codes/exchange', 'CodesController@store');
}); });
$router->group(['middleware' => 'web'], function () use ($router) {
$router->post('/oss/upload', 'OssController@upload');
$router->get('/goods/search', 'ApiController@GoodsInfo');
});
......
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