Commit 2a575cd4 by 杨树贤

删除签到ç‰接口,同时对活动列表里面的签到类型添加更多逻辑和字段

parent 52201f9b
<?php
namespace App\Http\Controllers;
use App\Services\CheckInService;
use App\Services\UserIntegralService;
use Carbon\Carbon;
use Illuminate\Http\Request;
/**
* 用户签到
* Class CheckInController
* @package App\Http\Controllers
*/
class CheckInController extends Controller
{
/**
* @var CheckInService
*/
private $service;
/**
* CheckInController constructor.
* @param CheckInService $service
*/
public function __construct(CheckInService $service)
{
$this->service = $service;
}
/**
* 用户签到列表
* @param Request $request
* @return array|false|string
*/
public function index(Request $request)
{
$map = [
'user_id' => $request->user->user_id,
];
$result = $this->service->getCheckInList($map);
return $this->Export(0, 'ok', $result);
}
/**
* 用户签到
* @param Request $request
* @return array|false|string
*/
public function add(Request $request)
{
$map = [
'user_id' => $request->user->user_id,
];
$result = $this->service->addCheckIn($map);
if ($result['errcode'] === self::SUCCESS) {
return $this->Export(0, 'ok');
} else {
return $this->Export(self::CHECK_IN_FAIL);
}
}
}
\ No newline at end of file
<?php
namespace App\Services;
class CheckInService
{
public function getCheckInList($map = [])
{
$url = config('website.BaseUrl') . '/check_in/list';
$result = reportCurl($url, $map, true);
$result = json_decode($result, true);
return $result;
}
public function addCheckIn($map = [])
{
$url = config('website.BaseUrl') . '/check_in/add';
$result = reportCurl($url, $map, true);
$result = json_decode($result, true);
return $result;
}
}
\ No newline at end of file
......@@ -47,7 +47,14 @@ class IntegralService
$result['data'][$key]['button_text'] = '去报价';
break;
case self::INTEGRAL_TYPE_CHECK_IN:
$result['data'][$key]['button_text'] = '签到';
//去判断是否已经签到了,同时去修改文字还有返回签到状态
$redis = new RedisModel();
$hashKey = 'ic_check_in_' . date('Ymd');
$exists = $redis->hexists($hashKey, $map['user_id']);
$buttonText = $exists ? '已签到' : '签到';
$checkInStatus = $exists ? 1 : 0;
$result['data'][$key]['button_text'] = $buttonText;
$result['data'][$key]['check_in_status'] = $checkInStatus;
break;
}
}
......
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