Commit 8a1d4a72 by 杨树贤

添加签到列表,助力列表,邀请好友列表服务接口

parent 50d7d83f
...@@ -8,6 +8,7 @@ use App\Http\Filters\AssistFilter; ...@@ -8,6 +8,7 @@ use App\Http\Filters\AssistFilter;
use App\Models\Assist; use App\Models\Assist;
use App\Models\UserExchange; use App\Models\UserExchange;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
/** /**
* 好友助力 * 好友助力
...@@ -34,7 +35,7 @@ class AssistsController extends Controller ...@@ -34,7 +35,7 @@ class AssistsController extends Controller
$result = $assist->getAssistList($page, $pageSize, $filter); $result = $assist->getAssistList($page, $pageSize, $filter);
} }
return $this->Export(0, 'ok', ['data' => $result]); return $this->Export(0, 'ok', $result);
} }
/** /**
...@@ -56,6 +57,12 @@ class AssistsController extends Controller ...@@ -56,6 +57,12 @@ class AssistsController extends Controller
'add_time' => time(), 'add_time' => time(),
'exchange_id' => $exchangeId, 'exchange_id' => $exchangeId,
]; ];
//自己不能助力自己
if ($userId == $assistUserId) {
return $this->Export(ErrorCode(8, 1), '自己无法助力自己');
}
//因为最多是两个好友对一条兑换进行助力 //因为最多是两个好友对一条兑换进行助力
$canAssist = $assist->checkCanAssist($exchangeId, $assistUserId); $canAssist = $assist->checkCanAssist($exchangeId, $assistUserId);
if ($canAssist) { if ($canAssist) {
...@@ -65,6 +72,8 @@ class AssistsController extends Controller ...@@ -65,6 +72,8 @@ class AssistsController extends Controller
} else { } else {
return $this->Export(ErrorCode(20, 5), '新增好友助力记录失败'); return $this->Export(ErrorCode(20, 5), '新增好友助力记录失败');
} }
} else {
return $this->Export(ErrorCode(9, 1), '你已助力过或助力人数已足够');
} }
return $this->Export(0, 'ok'); return $this->Export(0, 'ok');
......
...@@ -16,8 +16,8 @@ class CheckInController extends Controller ...@@ -16,8 +16,8 @@ class CheckInController extends Controller
{ {
public function index(Request $request, CheckIn $checkIn, CheckInFilter $filter) public function index(Request $request, CheckIn $checkIn, CheckInFilter $filter)
{ {
$page = $request->has('page') ? $request->page : self::DEFAULT_PAGE; $page = $request->get('page') ? $request->page : self::DEFAULT_PAGE;
$pageSize = $request->has('page_size') ? $request->page_size : self::DEFAULT_PAGE_SIZE; $pageSize = $request->get('page_size') ? $request->page_size : self::DEFAULT_PAGE_SIZE;
$checkIns = $checkIn->getCheckInList($page, $pageSize, $filter); $checkIns = $checkIn->getCheckInList($page, $pageSize, $filter);
......
...@@ -3,12 +3,45 @@ ...@@ -3,12 +3,45 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Http\Filters\CheckInFilter;
use App\Http\Filters\CodeFilter;
use App\Models\CheckIn;
use App\Models\Code; use App\Models\Code;
use App\Models\Integral; use App\Models\Integral;
use Illuminate\Http\Request; use Illuminate\Http\Request;
//红包码兑换管理
/**
* Class CodesController
* @package App\Http\Controllers
*/
class CodesController extends Controller class CodesController extends Controller
{ {
/**
* 获取红包码兑换列表
* @param Request $request
* @param Code $code
* @param CodeFilter $filter
* @return array
*/
public function index(Request $request, Code $code, CodeFilter $filter)
{
$page = $request->get('page') ? $request->page : self::DEFAULT_PAGE;
$pageSize = $request->get('page_size') ? $request->page_size : self::DEFAULT_PAGE_SIZE;
$codes = $code->getCodeList($page, $pageSize, $filter);
return $this->Export(0, 'ok', $codes);
}
/**
* 添加红包码兑换
* @param Request $request
* @param Code $code
* @return array
*/
public function store(Request $request, Code $code) public function store(Request $request, Code $code)
{ {
$data = [ $data = [
...@@ -26,8 +59,8 @@ class CodesController extends Controller ...@@ -26,8 +59,8 @@ class CodesController extends Controller
} else { } else {
return $this->Export(ErrorCode(21, 5), '红包码兑换失败'); return $this->Export(ErrorCode(21, 5), '红包码兑换失败');
} }
} else {
return $this->Export(ErrorCode(7, 1), '你已兑换过红包码,不能再兑换');
} }
return $this->Export(0, 'ok');
} }
} }
\ No newline at end of file
...@@ -15,4 +15,14 @@ class AssistFilter extends QueryFilter ...@@ -15,4 +15,14 @@ class AssistFilter extends QueryFilter
{ {
return $this->builder->where('exchange_id', $exchangeId); return $this->builder->where('exchange_id', $exchangeId);
} }
public function add_time($addTime = '')
{
$addTime = explode('~', urldecode($addTime));
foreach ($addTime as $key => $value) {
$addTime[$key] = strtotime($value);
}
return $this->builder->whereBetween('add_time', $addTime);
}
} }
\ No newline at end of file
<?php
namespace App\Http\Filters;
class CodeFilter extends QueryFilter
{
public function user_id($userId = 0)
{
return $this->builder->where('user_id', $userId);
}
public function add_time($addTime = '')
{
$addTime = explode('~', urldecode($addTime));
foreach ($addTime as $key => $value) {
$addTime[$key] = strtotime($value);
}
return $this->builder->whereBetween('add_time', $addTime);
}
public function code($code = '')
{
return $this->builder->where('code', $code);
}
}
\ No newline at end of file
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