|
@@ -116,13 +116,21 @@ class Index extends Controller
|
|
|
'uid' => $user['uid'],
|
|
'uid' => $user['uid'],
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
+ $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
|
|
|
|
|
+ ->where('end_at', '>=', time())->find();
|
|
|
|
|
+
|
|
|
|
|
+ $isBeginActivity = 1;
|
|
|
|
|
+ if (empty($activity)) {
|
|
|
|
|
+ $isBeginActivity = 0;
|
|
|
|
|
+ }
|
|
|
// 缓存用户信息1天
|
|
// 缓存用户信息1天
|
|
|
Cache::set('u:' . $token, json_encode($cacheUser), 86400);
|
|
Cache::set('u:' . $token, json_encode($cacheUser), 86400);
|
|
|
return $this->successResponse([
|
|
return $this->successResponse([
|
|
|
'user' => $user,
|
|
'user' => $user,
|
|
|
'token' => $token,
|
|
'token' => $token,
|
|
|
'isShare' => $isShare,
|
|
'isShare' => $isShare,
|
|
|
- 'count' => $count
|
|
|
|
|
|
|
+ 'count' => $count,
|
|
|
|
|
+ 'isBeginActivity' => $isBeginActivity
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -134,6 +142,12 @@ class Index extends Controller
|
|
|
*/
|
|
*/
|
|
|
public function checkRole()
|
|
public function checkRole()
|
|
|
{
|
|
{
|
|
|
|
|
+ $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
|
|
|
|
|
+ ->where('end_at', '>=', time())->find();
|
|
|
|
|
+ if (empty($activity)) {
|
|
|
|
|
+ return $this->response(5002, '活动末开始');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$userInfo = Db::table('awards_user_info')->where('uid', Safe::$user['uid'])->find();
|
|
$userInfo = Db::table('awards_user_info')->where('uid', Safe::$user['uid'])->find();
|
|
|
$count = Db::table('awards_user_task_log')->where('uid', Safe::$user['uid'])->count('id');
|
|
$count = Db::table('awards_user_task_log')->where('uid', Safe::$user['uid'])->count('id');
|
|
|
return $this->successResponse([
|
|
return $this->successResponse([
|
|
@@ -153,6 +167,12 @@ class Index extends Controller
|
|
|
*/
|
|
*/
|
|
|
public function submitTask()
|
|
public function submitTask()
|
|
|
{
|
|
{
|
|
|
|
|
+ $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
|
|
|
|
|
+ ->where('end_at', '>=', time())->find();
|
|
|
|
|
+ if (empty($activity)) {
|
|
|
|
|
+ return $this->response(5002, '活动末开始');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// if (empty(Safe::$body)) {
|
|
// if (empty(Safe::$body)) {
|
|
|
// return $this->response(5003, '参数有误');
|
|
// return $this->response(5003, '参数有误');
|
|
|
// }
|
|
// }
|
|
@@ -207,6 +227,12 @@ class Index extends Controller
|
|
|
*/
|
|
*/
|
|
|
public function submitShare()
|
|
public function submitShare()
|
|
|
{
|
|
{
|
|
|
|
|
+ $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
|
|
|
|
|
+ ->where('end_at', '>=', time())->find();
|
|
|
|
|
+ if (empty($activity)) {
|
|
|
|
|
+ return $this->response(5002, '活动末开始');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$userInfo = Db::table('awards_user_info')->where('uid', Safe::$user['uid'])->find();
|
|
$userInfo = Db::table('awards_user_info')->where('uid', Safe::$user['uid'])->find();
|
|
|
if (empty($userInfo)) {
|
|
if (empty($userInfo)) {
|
|
|
return $this->response(403, '没有登录');
|
|
return $this->response(403, '没有登录');
|
|
@@ -241,6 +267,12 @@ class Index extends Controller
|
|
|
*/
|
|
*/
|
|
|
public function ranking()
|
|
public function ranking()
|
|
|
{
|
|
{
|
|
|
|
|
+ $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
|
|
|
|
|
+ ->where('end_at', '>=', time())->find();
|
|
|
|
|
+ if (empty($activity)) {
|
|
|
|
|
+ return $this->response(5002, '活动末开始');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$ranking = Db::table('awards_user_task_log')->alias("l")
|
|
$ranking = Db::table('awards_user_task_log')->alias("l")
|
|
|
->leftJoin('awards_user_info u', 'l.uid = u.uid')
|
|
->leftJoin('awards_user_info u', 'l.uid = u.uid')
|
|
|
->field(['u.nickname', 'u.portrait', 'u.uid', 'l.duration', 'l.number'])
|
|
->field(['u.nickname', 'u.portrait', 'u.uid', 'l.duration', 'l.number'])
|
|
@@ -275,6 +307,12 @@ class Index extends Controller
|
|
|
*/
|
|
*/
|
|
|
public function newRanking()
|
|
public function newRanking()
|
|
|
{
|
|
{
|
|
|
|
|
+ $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
|
|
|
|
|
+ ->where('end_at', '>=', time())->find();
|
|
|
|
|
+ if (empty($activity)) {
|
|
|
|
|
+ return $this->response(5002, '活动末开始');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$ranking = Db::table('awards_user_task_log')->alias("l")
|
|
$ranking = Db::table('awards_user_task_log')->alias("l")
|
|
|
->leftJoin('awards_user_info u', 'l.uid = u.uid')
|
|
->leftJoin('awards_user_info u', 'l.uid = u.uid')
|
|
|
->field(['u.nickname', 'u.portrait', 'u.uid', 'l.duration', 'l.number'])
|
|
->field(['u.nickname', 'u.portrait', 'u.uid', 'l.duration', 'l.number'])
|
|
@@ -310,6 +348,12 @@ class Index extends Controller
|
|
|
*/
|
|
*/
|
|
|
public function submitReceive()
|
|
public function submitReceive()
|
|
|
{
|
|
{
|
|
|
|
|
+ $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
|
|
|
|
|
+ ->where('end_at', '>=', time())->find();
|
|
|
|
|
+ if (empty($activity)) {
|
|
|
|
|
+ return $this->response(5002, '活动末开始');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$name = trim(Request::post("name"));
|
|
$name = trim(Request::post("name"));
|
|
|
$mobile = trim(Request::post("mobile"));
|
|
$mobile = trim(Request::post("mobile"));
|
|
|
$address = trim(Request::post("address"));
|
|
$address = trim(Request::post("address"));
|
|
@@ -339,6 +383,7 @@ class Index extends Controller
|
|
|
'mobile' => $mobile,
|
|
'mobile' => $mobile,
|
|
|
'address' => $address,
|
|
'address' => $address,
|
|
|
'gift_at' => $giftId,
|
|
'gift_at' => $giftId,
|
|
|
|
|
+ 'type' => $type,
|
|
|
'create_at' => time(),
|
|
'create_at' => time(),
|
|
|
];
|
|
];
|
|
|
if (0 == Db::table('awards_order')->insert($order)) {
|
|
if (0 == Db::table('awards_order')->insert($order)) {
|
|
@@ -359,6 +404,12 @@ class Index extends Controller
|
|
|
*/
|
|
*/
|
|
|
public function getWinAward() {
|
|
public function getWinAward() {
|
|
|
|
|
|
|
|
|
|
+ $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
|
|
|
|
|
+ ->where('end_at', '>=', time())->find();
|
|
|
|
|
+ if (empty($activity)) {
|
|
|
|
|
+ return $this->response(5002, '活动末开始');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$orders = Db::table('awards_order')->alias('o')
|
|
$orders = Db::table('awards_order')->alias('o')
|
|
|
->leftJoin('awards_user_info u', 'o.uid = u.uid')
|
|
->leftJoin('awards_user_info u', 'o.uid = u.uid')
|
|
|
->leftJoin('awards_gift g', 'o.gift_id = g.id')
|
|
->leftJoin('awards_gift g', 'o.gift_id = g.id')
|