diff --git a/app/admin/controller/vote/Vote.php b/app/admin/controller/vote/Vote.php
new file mode 100644
index 0000000..78de27c
--- /dev/null
+++ b/app/admin/controller/vote/Vote.php
@@ -0,0 +1,116 @@
+request->isAjax()) {
+ $get = $this->request->get();
+ $lists = VoteLogic::lists($get);
+ return JsonServer::success("获取成功", $lists);
+ }
+
+ return view('');
+ }
+
+ /**
+ * @NOTES: 添加帮助类
+ * @author: 张无忌
+ */
+ public function add()
+ {
+ if ($this->request->isAjax()) {
+ $post = $this->request->post();
+ $res = VoteLogic::add($post);
+ if ($res === false) {
+ $error = VoteLogic::getError() ?: '新增失败';
+ return JsonServer::error($error);
+ }
+ return JsonServer::success('新增成功');
+ }
+
+
+ return view('');
+ }
+
+ /**
+ * @NOTES: 编辑帮助分类
+ * @author: 张无忌
+ */
+ public function edit()
+ {
+ if ($this->request->isAjax()) {
+ $post = $this->request->post();
+ $res = VoteLogic::edit($post);
+ if ($res === false) {
+ $error = VoteLogic::getError() ?: '编辑失败';
+ return JsonServer::error($error);
+ }
+ return JsonServer::success('编辑成功');
+ }
+
+
+ $id = $this->request->get('id');
+ $detail = VoteLogic::detail($id);
+
+ return view('', [
+ 'detail' => $detail,
+ ]);
+ }
+
+ /**
+ * @NOTES: 删除帮助分类
+ * @author: 张无忌
+ */
+ public function del()
+ {
+ if ($this->request->isAjax()) {
+ $id = $this->request->post('id');
+ $res = VoteLogic::del($id);
+ if ($res === false) {
+ $error = VoteLogic::getError() ?: '删除失败';
+ return JsonServer::error($error);
+ }
+ return JsonServer::success('删除成功');
+ }
+
+ return JsonServer::error('异常');
+ }
+
+ /**
+ * @Notes: 隐藏帮助分类
+ * @Author: 张无忌
+ */
+ public function status()
+ {
+ if ($this->request->isAjax()) {
+ $id = $this->request->post('id');
+ $status = $this->request->post('status');
+ $res = VoteLogic::status($id,$status);
+ if ($res === false) {
+ $error = VoteLogic::getError() ?: '操作失败';
+ return JsonServer::error($error);
+ }
+ return JsonServer::success('操作成功');
+ }
+
+ return JsonServer::success('异常');
+ }
+}
\ No newline at end of file
diff --git a/app/admin/controller/vote/VotePlayer.php b/app/admin/controller/vote/VotePlayer.php
new file mode 100644
index 0000000..57955c7
--- /dev/null
+++ b/app/admin/controller/vote/VotePlayer.php
@@ -0,0 +1,122 @@
+request->isAjax()) {
+ $get = $this->request->get();
+ $lists = VotePlayerLogic::lists($get);
+ return JsonServer::success("获取成功", $lists);
+ }
+
+ return view('', [
+ 'votes' => VoteLogic::getVotes()
+ ]);
+ }
+
+ /**
+ * @NOTES: 添加帮助类
+ * @author: 张无忌
+ */
+ public function add()
+ {
+ if ($this->request->isAjax()) {
+ $post = $this->request->post();
+ $res = VotePlayerLogic::add($post);
+ if ($res === false) {
+ $error = VotePlayerLogic::getError() ?: '新增失败';
+ return JsonServer::error($error);
+ }
+ return JsonServer::success('新增成功');
+ }
+
+
+ return view('', [
+ 'votes' => VoteLogic::getVotes()
+ ]);
+ }
+
+ /**
+ * @NOTES: 编辑帮助分类
+ * @author: 张无忌
+ */
+ public function edit()
+ {
+ if ($this->request->isAjax()) {
+ $post = $this->request->post();
+ $res = VotePlayerLogic::edit($post);
+ if ($res === false) {
+ $error = VotePlayerLogic::getError() ?: '编辑失败';
+ return JsonServer::error($error);
+ }
+ return JsonServer::success('编辑成功');
+ }
+
+
+ $id = $this->request->get('id');
+ $detail = VotePlayerLogic::detail($id);
+
+ return view('', [
+ 'detail' => $detail,
+ 'votes' => VoteLogic::getVotes()
+ ]);
+ }
+
+ /**
+ * @NOTES: 删除帮助分类
+ * @author: 张无忌
+ */
+ public function del()
+ {
+ if ($this->request->isAjax()) {
+ $id = $this->request->post('id');
+ $res = VotePlayerLogic::del($id);
+ if ($res === false) {
+ $error = VotePlayerLogic::getError() ?: '删除失败';
+ return JsonServer::error($error);
+ }
+ return JsonServer::success('删除成功');
+ }
+
+ return JsonServer::error('异常');
+ }
+
+ /**
+ * @Notes: 隐藏帮助分类
+ * @Author: 张无忌
+ */
+ public function status()
+ {
+ if ($this->request->isAjax()) {
+ $id = $this->request->post('id');
+ $status = $this->request->post('status');
+ $res = VotePlayerLogic::status($id,$status);
+ if ($res === false) {
+ $error = VotePlayerLogic::getError() ?: '操作失败';
+ return JsonServer::error($error);
+ }
+ return JsonServer::success('操作成功');
+ }
+
+ return JsonServer::success('异常');
+ }
+}
\ No newline at end of file
diff --git a/app/admin/logic/vote/VoteLogic.php b/app/admin/logic/vote/VoteLogic.php
new file mode 100644
index 0000000..4e23933
--- /dev/null
+++ b/app/admin/logic/vote/VoteLogic.php
@@ -0,0 +1,215 @@
+field(true)
+ ->where($where)
+ ->order('add_time', 'desc')
+ ->paginate([
+ 'page' => $get['page'],
+ 'list_rows' => $get['limit'],
+ 'var_page' => 'page'
+ ])
+ ->toArray();
+
+
+
+ foreach ($lists['data'] as &$item) {
+ $item['start_time'] = $item['start_time']? date("Y-m-d H:i:s",$item['start_time']):"";
+ $item['end_time'] = $item['end_time']? date("Y-m-d H:i:s",$item['end_time']):"";
+ $item['add_time'] = $item['add_time']? date("Y-m-d H:i:s",$item['add_time']):"";
+ $item['is_rank'] = $item['is_rank'] ? '显示' : '隐藏';
+ $item['is_redo'] = $item['is_redo']==0 ? '当天不可重复' : ($item['is_redo']==1?"全部不重复":"可重复");
+ $item['vote_str'] = ($item['vote_type']==0 ? '每天' : '总共').$item['vote_num']."票";
+ $item['status'] = $item['status'] ? '显示' : '隐藏';
+
+ }
+ return ['count'=>$lists['total'], 'lists'=>$lists['data']];
+ } catch (Exception $e) {
+ return ['error'=>$e->getMessage()];
+ }
+ }
+
+ /**
+ * @Notes: 资料详细
+ * @Author:
+ * @param $id
+ * @return array
+ */
+ public static function detail($id)
+ {
+ $model = new Vote();
+ $detail = $model->field(true)->findOrEmpty($id)->toArray();
+ $detail['start_time'] = $detail['start_time']? date("Y-m-d H:i:s",$detail['start_time']):"";
+ $detail['end_time'] = $detail['end_time']? date("Y-m-d H:i:s",$detail['end_time']):"";
+ $detail['images_arr'] = $detail['images']? explode(",",$detail['images']):[];
+ return $detail;
+ }
+
+ /**
+ * @Notes: 添加帮助
+ * @Author:
+ * @param $post
+ * @return bool
+ */
+ public static function add($post)
+ {
+ try {
+ if(isset($post['goods_image']) && count($post['goods_image']) ){
+ $post['images'] = implode(",",$post['goods_image']);
+ }
+ Vote::create([
+ 'title' => $post['title'],
+ 'image' => $post['image'] ?? '',
+ 'video' => $post['video'] ?? '',
+ 'images' => $post['images'] ?? '',
+ 'notice' => $post['notice'] ?? '',
+ 'content' => $post['content'] ?? '',
+ 'start_time' => $post['start_time'] ? strtotime($post['start_time']) : 0,
+ 'end_time' => $post['end_time'] ? strtotime($post['end_time']) : 0,
+ 'is_rank' => $post['is_rank'] ?? 1,
+ 'is_redo' => $post['is_redo'] ?? 0,
+ 'province_id' => $post['province_id'] ?? 0,
+ 'vote_type' => $post['vote_type'] ?? 0,
+ 'vote_num' => $post['vote_num'] ?? 0,
+ 'base_visit' => $post['base_visit'] ?? 0,
+ 'status' => $post['status'] ?? 1,
+ 'vote_total' => 0,
+ 'views' => 0,
+ 'add_time' => time(),
+ ]);
+
+ return true;
+ } catch (\Exception $e) {
+ static::$error = $e->getMessage();
+ return false;
+ }
+ }
+
+ /**
+ * @Notes: 编辑帮助
+ * @Author: 张无忌
+ * @param $post
+ * @return bool
+ */
+ public static function edit($post)
+ {
+ try {
+ if(isset($post['goods_image']) && count($post['goods_image'])){
+ $post['images'] = implode(",",$post['goods_image']);
+ }
+ Vote::update([
+ 'title' => $post['title'],
+ 'image' => $post['image'] ?? '',
+ 'video' => $post['video'] ?? '',
+ 'images' => $post['images'] ?? '',
+ 'notice' => $post['notice'] ?? '',
+ 'content' => $post['content'] ?? '',
+ 'start_time' => $post['start_time'] ? strtotime($post['start_time']) : 0,
+ 'end_time' => $post['end_time'] ? strtotime($post['end_time']) : 0,
+ 'is_rank' => $post['is_rank'] ?? 1,
+ 'is_redo' => $post['is_redo'] ?? 0,
+ 'province_id' => $post['province_id'] ?? 0,
+ 'vote_type' => $post['vote_type'] ?? 0,
+ 'vote_num' => $post['vote_num'] ?? 0,
+ 'base_visit' => $post['base_visit'] ?? 0,
+ 'status' => $post['status'] ?? 1,
+ 'update_time' => time(),
+ ], ['id'=>$post['id']]);
+ return true;
+ } catch (\Exception $e) {
+ static::$error = $e->getMessage();
+ return false;
+ }
+ }
+
+ /**
+ * @Notes: 删除
+ * @Author:
+ * @param $id
+ * @return bool
+ */
+ public static function del($id)
+ {
+ try {
+ Vote::update([
+ 'del' => 1,
+ 'update_time' => time()
+ ], ['id'=>$id]);
+
+ return true;
+ } catch (\Exception $e) {
+ static::$error = $e->getMessage();
+ return false;
+ }
+ }
+
+ /**
+ * @Notes: 隐藏
+ * @Author: 张无忌
+ * @param $id
+ * @return bool
+ */
+ public static function status($id,$status)
+ {
+ try {
+ Vote::update([
+ 'status' => $status,
+ 'update_time' => time()
+ ], ['id'=>$id]);
+
+ return true;
+ } catch (\Exception $e) {
+ static::$error = $e->getMessage();
+ return false;
+ }
+ }
+
+
+ /**
+ * @Notes: 获取分类
+ * @Author: 张无忌
+ * @return array
+ */
+ public static function getVotes()
+ {
+ try {
+ $model = new Vote();
+ return $model->field(true)
+ ->where(['del'=>0, 'status'=>1])
+ ->order('id', 'desc')
+ ->select()
+ ->toArray();
+
+ } catch (\Exception $e) {
+ return [];
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/admin/logic/vote/VotePlayerLogic.php b/app/admin/logic/vote/VotePlayerLogic.php
new file mode 100644
index 0000000..1842005
--- /dev/null
+++ b/app/admin/logic/vote/VotePlayerLogic.php
@@ -0,0 +1,176 @@
+field(true)
+ ->where($where)
+ ->with(['vote'])
+ ->order('id', 'desc')
+ ->paginate([
+ 'page' => $get['page'],
+ 'list_rows' => $get['limit'],
+ 'var_page' => 'page'
+ ])
+ ->toArray();
+
+ foreach ($lists['data'] as &$item) {
+ $item['vote_title'] = $item['vote']['title'] ?? '';
+ $item['add_time'] = $item['add_time']? date("Y-m-d H:i:s",$item['add_time']):"";
+ $item['status'] = $item['status'] ? '显示' : '隐藏';
+ }
+ return ['count'=>$lists['total'], 'lists'=>$lists['data']];
+ } catch (Exception $e) {
+ return ['error'=>$e->getMessage()];
+ }
+ }
+
+ /**
+ * @Notes: 资料详细
+ * @Author:
+ * @param $id
+ * @return array
+ */
+ public static function detail($id)
+ {
+ $model = new VotePlayer();
+ $detail = $model->field(true)->findOrEmpty($id)->toArray();
+ $detail['images_arr'] = $detail['images']? explode(",",$detail['images']):[];
+ return $detail;
+ }
+
+ /**
+ * @Notes: 添加帮助
+ * @Author:
+ * @param $post
+ * @return bool
+ */
+ public static function add($post)
+ {
+ try {
+ if(isset($post['goods_image']) && count($post['goods_image'])){
+ $post['images'] = implode(",",$post['goods_image']);
+ }
+ VotePlayer::create([
+ 'vote_id' => $post['vote_id']??0,
+ 'name' => $post['name'],
+ 'avatar' => $post['avatar'] ?? '',
+ 'video' => $post['video'] ?? '',
+ 'images' => $post['images'] ?? '',
+ 'intro' => $post['intro'] ?? '',
+ 'vote_num' => $post['vote_num'] ?? 0,
+ 'base_visit' => $post['base_visit'] ?? 0,
+ 'status' => $post['status'] ?? 1,
+ 'vote_total' => 0,
+ 'views' => 0,
+ 'add_time' => time(),
+ ]);
+
+ return true;
+ } catch (\Exception $e) {
+ static::$error = $e->getMessage();
+ return false;
+ }
+ }
+
+ /**
+ * @Notes: 编辑帮助
+ * @Author: 张无忌
+ * @param $post
+ * @return bool
+ */
+ public static function edit($post)
+ {
+ try {
+ if(isset($post['goods_image']) && count($post['goods_image'])){
+ $post['images'] = implode(",",$post['goods_image']);
+ }
+ VotePlayer::update([
+ 'vote_id' => $post['vote_id']??0,
+ 'name' => $post['name'],
+ 'avatar' => $post['avatar'] ?? '',
+ 'video' => $post['video'] ?? '',
+ 'images' => $post['images'] ?? '',
+ 'intro' => $post['intro'] ?? '',
+ 'vote_num' => $post['vote_num'] ?? 0,
+ 'base_visit' => $post['base_visit'] ?? 0,
+ 'status' => $post['status'] ?? 1,
+ 'update_time' => time(),
+ ], ['id'=>$post['id']]);
+ return true;
+ } catch (\Exception $e) {
+ static::$error = $e->getMessage();
+ return false;
+ }
+ }
+
+ /**
+ * @Notes: 删除
+ * @Author:
+ * @param $id
+ * @return bool
+ */
+ public static function del($id)
+ {
+ try {
+ VotePlayer::update([
+ 'del' => 1,
+ 'update_time' => time()
+ ], ['id'=>$id]);
+
+ return true;
+ } catch (\Exception $e) {
+ static::$error = $e->getMessage();
+ return false;
+ }
+ }
+
+ /**
+ * @Notes: 隐藏
+ * @Author: 张无忌
+ * @param $id
+ * @return bool
+ */
+ public static function status($id,$status)
+ {
+ try {
+ VotePlayer::update([
+ 'status' => $status,
+ 'update_time' => time()
+ ], ['id'=>$id]);
+
+ return true;
+ } catch (\Exception $e) {
+ static::$error = $e->getMessage();
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/admin/view/vote/vote/add.html b/app/admin/view/vote/vote/add.html
new file mode 100644
index 0000000..6dc0987
--- /dev/null
+++ b/app/admin/view/vote/vote/add.html
@@ -0,0 +1,304 @@
+{layout name="layout2" /}
+
+
+
+
+
\ No newline at end of file
diff --git a/app/admin/view/vote/vote/edit.html b/app/admin/view/vote/vote/edit.html
new file mode 100644
index 0000000..da42536
--- /dev/null
+++ b/app/admin/view/vote/vote/edit.html
@@ -0,0 +1,327 @@
+{layout name="layout2" /}
+
+
+
+
+
\ No newline at end of file
diff --git a/app/admin/view/vote/vote/lists.html b/app/admin/view/vote/vote/lists.html
new file mode 100644
index 0000000..bad95a3
--- /dev/null
+++ b/app/admin/view/vote/vote/lists.html
@@ -0,0 +1,207 @@
+{layout name="layout1" /}
+
+
+
+
\ No newline at end of file
diff --git a/app/admin/view/vote/vote_player/add.html b/app/admin/view/vote/vote_player/add.html
new file mode 100644
index 0000000..1cf0576
--- /dev/null
+++ b/app/admin/view/vote/vote_player/add.html
@@ -0,0 +1,221 @@
+{layout name="layout2" /}
+
+
+
+
+
\ No newline at end of file
diff --git a/app/admin/view/vote/vote_player/edit.html b/app/admin/view/vote/vote_player/edit.html
new file mode 100644
index 0000000..7d90e4f
--- /dev/null
+++ b/app/admin/view/vote/vote_player/edit.html
@@ -0,0 +1,282 @@
+{layout name="layout2" /}
+
+
+
+
+
\ No newline at end of file
diff --git a/app/admin/view/vote/vote_player/lists.html b/app/admin/view/vote/vote_player/lists.html
new file mode 100644
index 0000000..dabe615
--- /dev/null
+++ b/app/admin/view/vote/vote_player/lists.html
@@ -0,0 +1,215 @@
+{layout name="layout1" /}
+
+
+
+
\ No newline at end of file
diff --git a/app/api/controller/Article.php b/app/api/controller/Article.php
index 07f9b0a..3b30d13 100644
--- a/app/api/controller/Article.php
+++ b/app/api/controller/Article.php
@@ -11,17 +11,8 @@ use app\common\server\JsonServer;
class Article extends Api
{
- public $like_not_need_login = ['category', 'lists', 'detail'];
- /**
- * @Notes: 文章分类
- * @Author: 张无忌
- */
- public function category()
- {
- $get = $this->request->get();
- $lists = ArticleLogic::category($get);
- return JsonServer::success('获取成功', $lists);
- }
+ public $like_not_need_login = ['lists', 'detail'];
+
/**
* @Notes: 文章列表
diff --git a/app/api/controller/Vote.php b/app/api/controller/Vote.php
new file mode 100644
index 0000000..d36f821
--- /dev/null
+++ b/app/api/controller/Vote.php
@@ -0,0 +1,88 @@
+request->get();
+ $get['page_no'] = $this->page_no;
+ $get['page_size'] = $this->page_size;
+ $lists = VoteLogic::lists($get);
+ return JsonServer::success('获取成功', $lists);
+ }
+
+ /**
+ * @Notes: 文章详细
+ * @Author: 张无忌
+ */
+ public function detail()
+ {
+ $id = $this->request->get('id');
+ $detail = VoteLogic::detail($id,$this->user_id);
+ return JsonServer::success('获取成功', $detail);
+ }
+
+
+ /**
+ * @Notes: 文章详细
+ * @Author: 张无忌
+ */
+ public function players()
+ {
+ $get = $this->request->get();
+ $get['page_no'] = $this->page_no;
+ $get['page_size'] = $this->page_size;
+ $detail = VoteLogic::players($get,$this->user_id);
+ return JsonServer::success('获取成功', $detail);
+ }
+
+ /**
+ * @Notes: 文章详细
+ * @Author: 张无忌
+ */
+ public function playerDetail()
+ {
+ $id = $this->request->get('id');
+ $detail = VoteLogic::playersDetail($id,$this->user_id);
+ return JsonServer::success('获取成功', $detail);
+ }
+
+ /**
+ * @Notes: 文章详细
+ * @Author: 张无忌
+ */
+ public function vote()
+ {
+ $id = $this->request->get('id');
+ $detail = VoteLogic::vote($id,$this->user_id);
+ return JsonServer::success('获取成功', $detail);
+ }
+
+ /**
+ * @Notes: 文章详细
+ * @Author: 张无忌
+ */
+ public function rank()
+ {
+ $get = $this->request->get();
+ $lists = VoteLogic::rank($get);
+ return JsonServer::success('获取成功', $lists);
+ }
+
+}
\ No newline at end of file
diff --git a/app/api/logic/VoteLogic.php b/app/api/logic/VoteLogic.php
new file mode 100644
index 0000000..d8892e2
--- /dev/null
+++ b/app/api/logic/VoteLogic.php
@@ -0,0 +1,343 @@
+ 'asc'
+ ];
+
+ $model = new Vote();
+
+ $count = $model->alias('a')->where($where)->count();
+
+ $list = $model->alias('b')
+ ->where($where)
+ ->order($order)
+ ->page($get['page_no'], $get['page_size'])
+ ->select()
+ ->toArray();
+
+ foreach ($list as &$item) {
+ $item['status_show'] = $item['start_time']>time()?"未开始":($item['end_time']