|
@@ -151,6 +151,36 @@ class Index extends Controller
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 是否可以参与游戏
|
|
|
|
|
+ * @throws ClassNotFoundException
|
|
|
|
|
+ * @throws ReflectionException
|
|
|
|
|
+ * @return mixed
|
|
|
|
|
+ */
|
|
|
|
|
+ public function checkRole()
|
|
|
|
|
+ {
|
|
|
|
|
+ $first = 0;
|
|
|
|
|
+ $date = date('Y-m-d');
|
|
|
|
|
+ $userTask = Db::table('awards_user_task')->where('uid', Safe::$user['uid'])->where('date', $date)->find();
|
|
|
|
|
+ if (empty($userTask)) {
|
|
|
|
|
+ return $this->response(403, 'not login.');
|
|
|
|
|
+ } else if ($userTask['finish_state'] == 0 && $userTask['share_add_votes'] == 0) {
|
|
|
|
|
+ $count = Db::table('awards_user_task_log')->where('uid', Safe::$user['uid'])->where('date', $date)->count('id');
|
|
|
|
|
+ if ($count < 1) {
|
|
|
|
|
+ $first = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if ($userTask['finish_state'] > 0 && $userTask['share_add_votes'] > 0) {
|
|
|
|
|
+ $count = Db::table('awards_user_task_log')->where('uid', Safe::$user['uid'])->where('date', $date)->count('id');
|
|
|
|
|
+ if ($count < 2) {
|
|
|
|
|
+ $first = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $this->successResponse([
|
|
|
|
|
+ 'first' => $first,
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 提交任务接口
|
|
* 提交任务接口
|
|
|
* @throws FuncNotFoundException
|
|
* @throws FuncNotFoundException
|
|
@@ -162,8 +192,20 @@ class Index extends Controller
|
|
|
*/
|
|
*/
|
|
|
public function submitTask()
|
|
public function submitTask()
|
|
|
{
|
|
{
|
|
|
- $duration = Request::post("duration");
|
|
|
|
|
- $number = Request::post("number");
|
|
|
|
|
|
|
+ if (empty(Safe::$body)) {
|
|
|
|
|
+ return $this->response(5003, '参数有误');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!isset(Safe::$body['duration']) || Safe::$body['duration'] < 1 || Safe::$body['duration'] > 1000) {
|
|
|
|
|
+ return $this->response(5003, '时长参数有误');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!isset(Safe::$body['number']) || Safe::$body['number'] < 0 || Safe::$body['number'] > 1000) {
|
|
|
|
|
+ return $this->response(5003, '时长参数有误');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $duration = Safe::$body['duration'];
|
|
|
|
|
+ $number = Safe::$body['number'];
|
|
|
|
|
|
|
|
$date = date('Y-m-d');
|
|
$date = date('Y-m-d');
|
|
|
|
|
|
|
@@ -177,7 +219,7 @@ class Index extends Controller
|
|
|
if ($userTask['finish_state'] == 0) {
|
|
if ($userTask['finish_state'] == 0) {
|
|
|
$count = Db::table('awards_user_task_log')->where('uid', Safe::$user['uid'])->where('date', $date)->count('id');
|
|
$count = Db::table('awards_user_task_log')->where('uid', Safe::$user['uid'])->where('date', $date)->count('id');
|
|
|
if ($count > 0) {
|
|
if ($count > 0) {
|
|
|
- return $this->response(403, '没有参与次数');
|
|
|
|
|
|
|
+ return $this->response(5002, '没有参与次数');
|
|
|
}
|
|
}
|
|
|
$log = [
|
|
$log = [
|
|
|
'uid' => Safe::$user['uid'],
|
|
'uid' => Safe::$user['uid'],
|
|
@@ -192,7 +234,7 @@ class Index extends Controller
|
|
|
} else if ($userTask['share_add_votes'] == 1) {
|
|
} else if ($userTask['share_add_votes'] == 1) {
|
|
|
$count = Db::table('awards_user_task_log')->where('uid', Safe::$user['uid'])->where('date', $date)->count('id');
|
|
$count = Db::table('awards_user_task_log')->where('uid', Safe::$user['uid'])->where('date', $date)->count('id');
|
|
|
if ($count > 1) {
|
|
if ($count > 1) {
|
|
|
- return $this->response(403, '没有参与次数');
|
|
|
|
|
|
|
+ return $this->response(5002, '没有参与次数');
|
|
|
}
|
|
}
|
|
|
$log = [
|
|
$log = [
|
|
|
'uid' => Safe::$user['uid'],
|
|
'uid' => Safe::$user['uid'],
|
|
@@ -204,7 +246,7 @@ class Index extends Controller
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (empty($log)) {
|
|
if (empty($log)) {
|
|
|
- return $this->response(403, '没有参与次数');
|
|
|
|
|
|
|
+ return $this->response(5002, '没有参与次数');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (0 == Db::table('awards_user_task_log')->insert($log)) {
|
|
if (0 == Db::table('awards_user_task_log')->insert($log)) {
|
|
@@ -243,7 +285,7 @@ class Index extends Controller
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
if ($nums) {
|
|
if ($nums) {
|
|
|
- return $this->response(601, '发布成功');
|
|
|
|
|
|
|
+ return $this->successResponse(null, '提交成功');
|
|
|
} else {
|
|
} else {
|
|
|
return $this->response(601, '发布失败');
|
|
return $this->response(601, '发布失败');
|
|
|
}
|
|
}
|