Commit c293ed35 by 杨树贤

去除签到相关的页面和逻辑

parent 20e98654
<?php
namespace App\Http\Controllers\Api;
use App\Http\Requests\ExchangeSettingApiRequest;
use App\Http\Services\CheckInService;
use App\Http\Services\ExchangeSettingService;
use App\Http\Transformers\CheckInTransformer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class CheckInApiController extends Controller
{
protected $service;
public function __construct(CheckInService $service)
{
$this->service = $service;
}
public function checkInListApi(Request $request,CheckInTransformer $transformer)
{
$params = $this->getListParams($request);
$params = urldecode(http_build_query($params));
$data = $this->service->getCheckInList('/check_in/list?' . $params);
$data = $transformer->transform($data);
return $this->apiReturn(0, 'ok', [
'data' => $data['data'],
'count' => $data['count'],
]);
}
private function getListParams(Request $request)
{
//因为数据库没有存mobile,所以要根据mobile去获取userId
$userId = $this->service->getUserIdByMobile($request->mobile);
$params = array_merge($request->toArray(), ['user_id' => $userId]);
if ($request->has('mobile') && $request->mobile) {
$params['user_id'] = $params['user_id'] ?: 0;
}
unset($params['mobile']);
return $params;
}
}
<?php
namespace App\Http\Controllers;
use App\Http\Services\ExchangeSettingService;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
//用户签到
class CheckInController extends Controller
{
protected $service;
public function __construct(ExchangeSettingService $service)
{
$this->service = $service;
}
public function Entrance(Request $request, $id = 'index')
{
if ($request->path() == '/') {
$path = 'web/index';
} else {
$path = $request->path();
}
$this->data = [
'menus' => $request->menus,
'header' => $request->user->header,
'username' => $request->user->email,
'useremail' => $request->user->email,
'uri' => '/' . $path,
'id' => $id,
];
return $this->$id($request);
}
public function __call($method, $parameters)
{
return $this->errhtml('NotFind', '没有这个页面');
}
public function checkInList()
{
$this->data['title'] = '签到列表';
return $this->view();
}
}
<?php
namespace App\Http\Services;
class CheckInService extends BaseService
{
public function getCheckInList($path)
{
return $this->apiPost($path);
}
}
\ No newline at end of file
<?php
namespace App\Http\Transformers;
use App\Http\Services\BaseService;
class CheckInTransformer
{
protected $service;
public function __construct(BaseService $service)
{
$this->service = $service;
}
public function transform($data)
{
if (isset($data['data'])) {
$userIds = array_column($data['data'], 'user_id');
if ($userIds) {
$users = $this->service->getUsersFromRedis($userIds);
$mobiles = [];
foreach ($users as $user) {
$mobiles[$user['user_id']] = $user['mobile'];
}
foreach ($data['data'] as &$item) {
$item['mobile'] = array_get($mobiles, $item['user_id']);
$item['add_time'] = date('Y-m-d H:i:s', $item['add_time']);
}
}
unset($item);
}
return $data;
}
}
\ No newline at end of file
......@@ -19,7 +19,6 @@ Route::group(['middleware' => 'web'], function () {
Route::match(['get', 'post'], '/integral_bills/{key}', 'IntegralBillsController@Entrance');
Route::match(['get', 'post'], '/exchange/settings/{key}', 'ExchangeSettingsController@Entrance');
Route::match(['get', 'post'], '/user_exchanges/{key}', 'UserExchangesController@Entrance');
Route::match(['get', 'post'], '/check_in/{key}', 'CheckInController@Entrance');
Route::match(['get', 'post'], '/codes/{key}', 'CodesController@Entrance');
Route::match(['get', 'post'], '/invites/{key}', 'InvitesController@Entrance');
Route::match(['get', 'post'], '/assists/{key}', 'AssistsController@Entrance');
......@@ -72,10 +71,6 @@ Route::namespace('Api')->group(function () {
Route::match(['get', 'post'], '/user_exchanges/api/auditUserExchangeApi',
'UserExchangesApiController@auditUserExchangeApi');
//用户签到管理
Route::match(['get', 'post'], '/check_in/api/checkInListApi',
'CheckInApiController@checkInListApi');
//红包码兑换管理
Route::match(['get', 'post'], '/codes/api/codeListApi',
'CodesApiController@codeListApi');
......
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