Browse Source

支付

master
jianglong 2 years ago
parent
commit
25bd0ff97f
  1. 8
      app/admin/controller/vote/Vote.php
  2. 110
      app/admin/controller/vote/VoteCategory.php
  3. 160
      app/admin/logic/vote/VoteCategoryLogic.php
  4. 7
      app/admin/logic/vote/VoteLogic.php
  5. 36
      app/admin/logic/vote/VotePlayerLogic.php
  6. 12
      app/admin/view/vote/vote/add.html
  7. 12
      app/admin/view/vote/vote/edit.html
  8. 15
      app/admin/view/vote/vote/lists.html
  9. 24
      app/admin/view/vote/vote_category/add.html
  10. 23
      app/admin/view/vote/vote_category/edit.html
  11. 151
      app/admin/view/vote/vote_category/lists.html
  12. 7
      app/admin/view/vote/vote_player/add.html
  13. 7
      app/admin/view/vote/vote_player/edit.html
  14. 3
      app/admin/view/vote/vote_player/lists.html
  15. 14
      app/api/controller/Vote.php
  16. 57
      app/api/logic/VoteLogic.php
  17. 1
      app/common/enum/MenuEnum.php
  18. 8
      app/common/model/vote/Vote.php
  19. 12
      app/common/model/vote/VoteCategory.php

8
app/admin/controller/vote/Vote.php

@ -8,6 +8,7 @@ use app\admin\logic\content\HelpCategoryLogic;
use app\admin\logic\content\HelpLogic;
use app\admin\logic\content\ResourceCategoryLogic;
use app\admin\logic\content\ResourceLogic;
use app\admin\logic\vote\VoteCategoryLogic;
use app\admin\logic\vote\VoteLogic;
use app\admin\validate\content\HelpValidate;
use app\common\basics\AdminBase;
@ -27,7 +28,9 @@ class Vote extends AdminBase
return JsonServer::success("获取成功", $lists);
}
return view('');
return view('',[
'category' => VoteCategoryLogic::getCategory(),
]);
}
/**
@ -47,7 +50,7 @@ class Vote extends AdminBase
}
return view('');
return view('',['category' => VoteCategoryLogic::getCategory(),]);
}
/**
@ -72,6 +75,7 @@ class Vote extends AdminBase
return view('', [
'detail' => $detail,
'category' => VoteCategoryLogic::getCategory(),
]);
}

110
app/admin/controller/vote/VoteCategory.php

@ -0,0 +1,110 @@
<?php
namespace app\admin\controller\vote;
use app\admin\logic\content\ArticleCategoryLogic;
use app\admin\logic\content\ResourceCategoryLogic;
use app\admin\logic\content\ResourceLogic;
use app\admin\logic\vote\VoteCategoryLogic;
use app\admin\logic\vote\VoteLogic;
use app\admin\validate\content\ArticleCategoryValidate;
use app\common\basics\AdminBase;
use app\common\server\JsonServer;
class VoteCategory extends AdminBase
{
/**
* @NOTES: 资源分类列表
* @author: 张无忌
*/
public function lists()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = VoteCategoryLogic::lists($get);
return JsonServer::success("获取成功", $lists);
}
return view();
}
/**
* @NOTES: 添加资源分类
* @author: 张无忌
*/
public function add()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$res = VoteCategoryLogic::add($post);
if ($res === false) {
$error = VoteCategoryLogic::getError() ?: '新增失败';
return JsonServer::error($error);
}
return JsonServer::success('新增成功');
}
return view('');
}
/**
* @NOTES: 编辑分类
* @author: 张无忌
*/
public function edit()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$res = VoteCategoryLogic::edit($post);
if ($res === false) {
$error = VoteCategoryLogic::getError() ?: '编辑失败';
return JsonServer::error($error);
}
return JsonServer::success('编辑成功');
}
$id = $this->request->get('id');
return view('', [
'detail' => VoteCategoryLogic::detail($id)
]);
}
/**
* @NOTES: 删除分类
* @author: 张无忌
*/
public function del()
{
if ($this->request->isAjax()) {
$id = $this->request->post('id');
$res = VoteCategoryLogic::del($id);
if ($res === false) {
$error = VoteCategoryLogic::getError() ?: '删除失败';
return JsonServer::error($error);
}
return JsonServer::success('删除成功');
}
return JsonServer::error('异常');
}
/**
* @Notes: 隐藏分类
* @Author: 张无忌
*/
public function hide()
{
if ($this->request->isAjax()) {
$id = $this->request->post('id');
$res = VoteCategoryLogic::hide($id);
if ($res === false) {
$error = VoteCategoryLogic::getError() ?: '操作失败';
return JsonServer::error($error);
}
return JsonServer::success('操作成功');
}
return JsonServer::success('异常');
}
}

160
app/admin/logic/vote/VoteCategoryLogic.php

@ -0,0 +1,160 @@
<?php
namespace app\admin\logic\vote;
use app\common\basics\Logic;
use app\common\model\vote\VoteCategory;
use Exception;
class VoteCategoryLogic extends Logic
{
/**
* 获取资源分类
* @param $get
* @return array
*/
public static function lists($get)
{
try {
$where = [
['del', '=', 0],
];
$model = new VoteCategory();
$lists = $model->field(true)
->where($where)
->order('id', 'desc')
->paginate([
'page' => $get['page'],
'list_rows' => $get['limit'],
'var_page' => 'page'
])
->toArray();
foreach ($lists['data'] as &$item) {
$item['is_show'] = $item['is_show'] ? '启用' : '停用';
}
return ['count'=>$lists['total'], 'lists'=>$lists['data']];
} catch (Exception $e) {
return ['error'=>$e->getMessage()];
}
}
/**
* @Notes: 获取分类
* @Author: 张无忌
* @return array
*/
public static function getCategory($pid=0)
{
try {
$model = new VoteCategory();
return $model->field(true)
->where(['del'=>0, 'is_show'=>1])
->order('id', 'desc')
->select()
->toArray();
} catch (\Exception $e) {
return [];
}
}
/**
* 获取文章分类详细
* @param $id
* @return array
*/
public static function detail($id)
{
$model = new VoteCategory();
return $model->field(true)->findOrEmpty($id)->toArray();
}
/**
* 添加分类
* @param $post
* @return bool
*/
public static function add($post)
{
try {
VoteCategory::create([
'name' => $post['name'],
'is_show' => $post['is_show']
]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
/**
* 编辑分类
* @param $post
* @return bool
*/
public static function edit($post)
{
try {
VoteCategory::update([
'name' => $post['name'],
'is_show' => $post['is_show']
], ['id'=>$post['id']]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
/**
* 删除分类
* @param $id
* @return bool
*/
public static function del($id)
{
try {
VoteCategory::update([
'del' => 1
], ['id'=>$id]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
/**
* @Notes: 隐藏
* @Author: 张无忌
* @param $id
* @return bool
*/
public static function hide($id)
{
try {
$model = new VoteCategory();
$category = $model->findOrEmpty($id)->toArray();
VoteCategory::update([
'is_show' => !$category['is_show'],
'update_time' => time()
], ['id'=>$id]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
}

7
app/admin/logic/vote/VoteLogic.php

@ -26,10 +26,13 @@ class VoteLogic extends Logic
if (!empty($get['title']) and trim($get['title'])!='')
$where[] = ['title', 'like', '%'.$get['title'].'%'];
if (!empty($get['cid']) and is_numeric($get['cid']))
$where[] = ['cid', '=', $get['cid']];
$model = new Vote();
$lists = $model->field(true)
->where($where)
->with(['category'])
->order('add_time', 'desc')
->paginate([
'page' => $get['page'],
@ -39,8 +42,8 @@ class VoteLogic extends Logic
->toArray();
foreach ($lists['data'] as &$item) {
$item['category'] = $item['category']['name'] ?? '未知';
$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']):"";
@ -85,6 +88,7 @@ class VoteLogic extends Logic
$post['images'] = implode(",",$post['goods_image']);
}
Vote::create([
'cid' => $post['cid'],
'title' => $post['title'],
'image' => $post['image'] ?? '',
'video' => $post['video'] ?? '',
@ -125,6 +129,7 @@ class VoteLogic extends Logic
$post['images'] = implode(",",$post['goods_image']);
}
Vote::update([
'cid' => $post['cid'],
'title' => $post['title'],
'image' => $post['image'] ?? '',
'video' => $post['video'] ?? '',

36
app/admin/logic/vote/VotePlayerLogic.php

@ -8,6 +8,7 @@ use app\common\basics\Logic;
use app\common\model\vote\Vote;
use app\common\model\vote\VotePlayer;
use Exception;
use think\Db;
class VotePlayerLogic extends Logic
{
@ -90,10 +91,17 @@ class VotePlayerLogic extends Logic
'base_visit' => $post['base_visit'] ?? 0,
'status' => $post['status'] ?? 1,
'vote_total' => 0,
'base_vote' =>$post['base_visit'] ?? 0,
'views' => 0,
'add_time' => time(),
]);
$vote_p = new VotePlayer();
$vote = new Vote();
$count = $vote_p->where(['status','=',1])->where('vote_id','=',$post['vote_id'])->sum("base_vote");
$update = [
"base_vote" => $count
];
$vote->where('id','=',$post['vote_id'])->update($update);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
@ -122,9 +130,19 @@ class VotePlayerLogic extends Logic
'intro' => $post['intro'] ?? '',
'vote_num' => $post['vote_num'] ?? 0,
'base_visit' => $post['base_visit'] ?? 0,
'base_vote' => $post['base_vote'] ?? 0,
'status' => $post['status'] ?? 1,
'update_time' => time(),
], ['id'=>$post['id']]);
$vote_p = new VotePlayer();
$vote = new Vote();
$count = $vote_p->where('status','=',1)->where('vote_id','=',$post['vote_id'])->sum("base_vote");
$update = [
"base_vote" => $count
];
$vote->where('id','=',$post['vote_id'])->update($update);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
@ -146,6 +164,14 @@ class VotePlayerLogic extends Logic
'update_time' => time()
], ['id'=>$id]);
$vote_p = new VotePlayer();
$vote = new Vote();
$count = $vote_p->where(['status','=',1])->where('vote_id','=',$id)->sum("base_vote");
$update = [
"base_vote" => $count
];
$vote->where('id','=',$id)->update($update);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
@ -167,6 +193,14 @@ class VotePlayerLogic extends Logic
'update_time' => time()
], ['id'=>$id]);
$vote_p = new VotePlayer();
$vote = new Vote();
$count = $vote_p->where(['status','=',1])->where('vote_id','=',$id)->sum("base_vote");
$update = [
"base_vote" => $count
];
$vote->where('id','=',$id)->update($update);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();

12
app/admin/view/vote/vote/add.html

@ -73,6 +73,18 @@
</div>
<div class="layui-form-item">
<label for="cid" class="layui-form-label"><span style="color:red;">*</span>活动分类:</label>
<div class="layui-input-inline">
<select name="cid" id="cid" lay-verType="tips" lay-verify="required" lay-filter="cid">
<option value="">全部</option>
{volist name="category" id="vo"}
<option value="{$vo.id}">{$vo.name}</option>
{/volist}
</select>
</div>
</div>
<div class="layui-form-item">
<label for="notice" class="layui-form-label">简介:</label>
<div class="layui-input-inline">
<input type="text" name="notice" id="notice" autocomplete="off" class="layui-input">

12
app/admin/view/vote/vote/edit.html

@ -73,6 +73,18 @@
</div>
<div class="layui-form-item">
<label for="cid" class="layui-form-label"><span style="color:red;">*</span>活动分类:</label>
<div class="layui-input-inline">
<select name="cid" id="cid" lay-verType="tips" lay-verify="required" lay-filter="cid">
<option value="">全部</option>
{volist name="category" id="vo"}
<option value="{$vo.id}" {if $detail.cid==$vo.id}selected{/if}>{$vo.name}</option>
{/volist}
</select>
</div>
</div>
<div class="layui-form-item">
<label for="notice" class="layui-form-label">简介:</label>
<div class="layui-input-inline">
<input type="text" name="notice" id="notice" autocomplete="off" class="layui-input" value="{$detail['notice']}">

15
app/admin/view/vote/vote/lists.html

@ -19,12 +19,23 @@
<div class="layui-card-body layui-form">
<div class="layui-form-item">
<div class="layui-inline">
<label for="title" class="layui-form-label">投票活动标题:</label>
<label for="title" class="layui-form-label">活动标题:</label>
<div class="layui-input-inline">
<input type="text" id="title" name="title" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label for="cid" class="layui-form-label">活动分类:</label>
<div class="layui-input-inline">
<select name="cid" id="cid">
<option value="">全部</option>
{volist name="category" id="vo"}
<option value="{$vo.id}">{$vo.name}</option>
{/volist}
</select>
</div>
</div>
<div class="layui-inline">
<a class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="search">搜索</a>
<a class="layui-btn layui-btn-sm layui-btn-primary" lay-submit lay-filter="clear-search">重置</a>
</div>
@ -62,6 +73,7 @@
like.tableLists("#like-table-lists", "{:url()}", [
{field:"id", width:60, title:"ID"}
,{field:"title", width:200, align:"center", title:"标题"}
,{field:"category", width:150, align:"center", title:"活动分类"}
,{field:"image", width:100, align:"center", title:"封面图", templet:"#table-image"}
,{field:"start_time", width:180, align:"center", title:"开始时间"}
,{field:"end_time", width:180, align:"center", title:"结束时间"}
@ -69,6 +81,7 @@
,{field:"is_redo", width:150, align:"center", title:"重复投票"}
,{field:"vote_str", width:180, align:"center", title:"投票规则"}
,{field:"vote_total", width:180, align:"center", title:"投票数"}
,{field:"base_vote", width:180, align:"center", title:"虚拟投票数"}
,{field:"views", width:180, align:"center", title:"浏览数"}
,{field:"status", width:180, align:"center", title:"状态"}
,{field:"add_time", width:180, align:"center", title:"创建时间"}

24
app/admin/view/vote/vote_category/add.html

@ -0,0 +1,24 @@
{layout name="layout2" /}
<div class="layui-card layui-form" style="box-shadow:none;">
<div class="layui-card-body">
<div class="layui-form-item">
<label for="name" class="layui-form-label"><span style="color:red;">*</span>分类名称:</label>
<div class="layui-input-block">
<input type="text" name="name" id="name" lay-verify="required" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><span style="color:red;">*</span>分类状态:</label>
<div class="layui-input-block">
<input type="radio" name="is_show" value="1" title="启用">
<input type="radio" name="is_show" value="0" title="关闭" checked>
</div>
</div>
<div class="layui-form-item layui-hide">
<input type="button" lay-submit lay-filter="addSubmit" id="addSubmit" value="确认">
</div>
</div>
</div>

23
app/admin/view/vote/vote_category/edit.html

@ -0,0 +1,23 @@
{layout name="layout2" /}
<div class="layui-card layui-form" style="box-shadow:none;">
<div class="layui-card-body">
<div class="layui-form-item">
<label for="name" class="layui-form-label"><span style="color:red;">*</span>分类名称:</label>
<div class="layui-input-block">
<input type="text" name="name" id="name" value="{$detail.name}" lay-verify="required" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><span style="color:red;">*</span>分类状态:</label>
<div class="layui-input-block">
<input type="radio" name="is_show" value="1" title="启用" {if $detail.is_show}checked{/if}>
<input type="radio" name="is_show" value="0" title="关闭" {if !$detail.is_show}checked{/if}>
</div>
</div>
<div class="layui-form-item layui-hide">
<input type="button" lay-submit lay-filter="addSubmit" id="addSubmit" value="确认">
</div>
</div>
</div>

151
app/admin/view/vote/vote_category/lists.html

@ -0,0 +1,151 @@
{layout name="layout1" /}
<div class="wrapper">
<div class="layui-card">
<!-- 操作提示 -->
<div class="layui-card-body">
<div class="layui-collapse" style="border:1px dashed #c4c4c4">
<div class="layui-colla-item">
<h2 class="layui-colla-title like-layui-colla-title">操作提示</h2>
<div class="layui-colla-content layui-show">
<p>*平台维护活动分类,方便投票活动整理。</p>
</div>
</div>
</div>
</div>
<!-- 主体区域 -->
<div class="layui-card-body">
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm layEvent" lay-event="add">新增活动分类</button>
<table id="like-table-lists" lay-filter="like-table-lists"></table>
<script type="text/html" id="table-operation">
<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">编辑</a>
{{# if(d.is_show == '启用'){ }}<a class="layui-btn layui-btn-normal layui-btn-sm layui-btn-warm" lay-event="hide">停用</a>{{# } }}
{{# if(d.is_show == '停用'){ }}<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="hide">启用</a>{{# } }}
<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
</script>
</div>
</div>
</div>
<script>
layui.use(["table"], function(){
var table = layui.table;
like.tableLists("#like-table-lists", "{:url()}", [
{field:"id", width:60, title:"ID"}
,{field:"name", width:160, align:"center", title:"资料分类"}
,{field:"is_show", width:100, align:"center", title:"资料状态"}
,{field:"create_time", width:180, align:"center", title:"创建时间"}
,{title:"操作", width:220, align:"center", fixed:"right", toolbar:"#table-operation"}
]);
var active = {
add: function() {
layer.open({
type: 2
,title: "新增活动分类"
,content: "{:url('vote.VoteCategory/add')}"
,area: ["550px", "400px"]
,btn: ["确定", "取消"]
,yes: function(index, layero){
var iframeWindow = window["layui-layer-iframe" + index];
var submit = layero.find("iframe").contents().find("#addSubmit");
iframeWindow.layui.form.on("submit(addSubmit)", function(data){
like.ajax({
url: "{:url('vote.VoteCategory/add')}",
data: data.field,
type: "POST",
success:function(res) {
if(res.code === 1) {
layui.layer.msg(res.msg);
layer.close(index);
table.reload("like-table-lists", {
where: {},
page: { cur: 1 }
});
}
}
});
});
submit.trigger("click");
}
});
},
edit: function(obj) {
layer.open({
type: 2
,title: "编辑活动分类"
,content: "{:url('vote.VoteCategory/edit')}?id=" + obj.data.id
,area: ["550px", "400px"]
,btn: ["确定", "取消"]
,yes: function(index, layero){
var iframeWindow = window["layui-layer-iframe" + index];
var submit = layero.find("iframe").contents().find("#addSubmit");
iframeWindow.layui.form.on("submit(addSubmit)", function(data){
data.field['id'] = obj.data.id;
like.ajax({
url: "{:url('vote.VoteCategory/edit')}",
data: data.field,
type: "POST",
success:function(res) {
if(res.code === 1) {
layui.layer.msg(res.msg);
layer.close(index);
table.reload("like-table-lists", {
where: {},
page: { cur: 1 }
});
}
}
});
});
submit.trigger("click");
}
});
},
del: function(obj) {
layer.confirm("确定删除活动分类:"+obj.data.name, function(index) {
like.ajax({
url: "{:url('vote.VoteCategory/del')}",
data: {id: obj.data.id},
type: "POST",
success: function (res) {
if (res.code === 1) {
layui.layer.msg(res.msg);
layer.close(index);
obj.del();
}
}
});
layer.close(index);
})
},
hide: function(obj) {
var text = obj.data.is_show === '启用' ? '确定停用:' : '确定启用:';
layer.confirm(text+obj.data.name, function(index) {
like.ajax({
url: "{:url('vote.VoteCategory/hide')}",
data: {id: obj.data.id},
type: "POST",
success: function (res) {
if (res.code === 1) {
layui.layer.msg(res.msg);
layer.close(index);
table.reload("like-table-lists", {
where: {},
page: { cur: 1 }
});
}
}
});
layer.close(index);
})
}
};
like.eventClick(active);
})
</script>

7
app/admin/view/vote/vote_player/add.html

@ -129,6 +129,13 @@
</div>
</div>
<div class="layui-form-item">
<label for="base_visit" class="layui-form-label">虚拟投票数:</label>
<div class="layui-input-inline">
<input type="number" name="base_visit" id="base_vote" lay-verType="tips" lay-verify="required" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">状态:</label>

7
app/admin/view/vote/vote_player/edit.html

@ -153,7 +153,12 @@
</div>
</div>
<div class="layui-form-item">
<label for="base_visit" class="layui-form-label">虚拟投票数:</label>
<div class="layui-input-inline">
<input type="number" name="base_vote" id="base_vote" value="{$detail.base_vote}" lay-verType="tips" lay-verify="required" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">状态:</label>
<div class="layui-input-inline">

3
app/admin/view/vote/vote_player/lists.html

@ -76,7 +76,8 @@
,{field:"name", width:200, align:"center", title:"姓名"}
,{field:"image", width:100, align:"center", title:"封面图", templet:"#table-image"}
,{field:"intro", width:180, align:"center", title:"参赛介绍"}
,{field:"vote_num", width:180, align:"center", title:"投票数"}
,{field:"vote_num", width:180, align:"center", title:"真实投票数"}
,{field:"base_vote", width:180, align:"center", title:"虚拟投票数"}
,{field:"views", width:180, align:"center", title:"浏览数"}
,{field:"status", width:180, align:"center", title:"状态"}
,{field:"add_time", width:180, align:"center", title:"创建时间"}

14
app/api/controller/Vote.php

@ -6,13 +6,25 @@ namespace app\api\controller;
use app\api\logic\ArticleLogic;
use app\api\logic\ResourceLogic;
use app\api\logic\VoteLogic;
use app\common\basics\Api;
use app\common\server\JsonServer;
class Vote extends Api
{
public $like_not_need_login = ['lists', 'detail','players','playerDetail','rank','vote'];
public $like_not_need_login = ['category','lists', 'detail','players','playerDetail','rank','vote'];
/**
* @Notes: 文章分类
* @Author: 张无忌
*/
public function category()
{
$get = $this->request->get();
$lists = VoteLogic::category($get);
return JsonServer::success('获取成功', $lists);
}
/**
* @Notes: 文章列表

57
app/api/logic/VoteLogic.php

@ -12,6 +12,7 @@ use app\common\model\content\ResourceCategory;
use app\common\model\user\User;
use app\common\model\user\UserResource;
use app\common\model\vote\Vote;
use app\common\model\vote\VoteCategory;
use app\common\model\vote\VoteLog;
use app\common\model\vote\VotePlayer;
use app\common\server\AreaServer;
@ -21,6 +22,32 @@ use think\Db;
class VoteLogic extends Logic
{
/**
* @Notes: 资料分类
* @Author: 张无忌
* @param $get
* @return array
*/
public static function category($get)
{
try {
$model = new VoteCategory();
$where = [];
if(isset($get['pid']) ){
$where[] = ['pid','=',$get['pid']];
}
return $model->field(['id', 'name'])
->where([
['del', '=', 0],
['is_show', '=', 1]
])->where($where)->select()->toArray();
} catch (\Exception $e) {
return ['error'=>$e->getMessage()];
}
}
/**
* @Notes: 文章列表
@ -33,9 +60,12 @@ class VoteLogic extends Logic
try {
$where = [
['status', '=', 1]
['status', '=', 1],
['del', '=', 0],
];
if(isset($get['cid']) && $get['cid']){
$where[] = ['cid', '=', $get['cid']];
}
$order = [
'add_time' => 'asc'
];
@ -91,7 +121,7 @@ class VoteLogic extends Logic
['vote_id',"=",$get['id']]
];
$order = [
'vote_num' => 'desc',
// 'vote_num' => 'desc',
'views' => 'desc'
];
@ -100,11 +130,16 @@ class VoteLogic extends Logic
$list = $model->alias('b')
->where($where)
->orderRaw("vote_num+base_vote desc")
->order($order)
->limit(50)
->select()
->toArray();
foreach ($list as &$item ){
$item['vote_num'] = $item['vote_num'] + $item['base_vote'];
}
$data = [
'list' => $list
];
@ -147,7 +182,7 @@ class VoteLogic extends Logic
$article['images'] = [];
}
$article['vote_total'] = $article['vote_total'] + $article['base_vote'];
$article['player_count'] = $palers->where("vote_id","=",$id)->where("status",'=',1)->where("del","=",0)->count();
}
@ -181,6 +216,7 @@ class VoteLogic extends Logic
->toArray();
foreach ($list as &$item) {
$item['can_vote'] = VoteLogic::getPlayerVoteStatus($article['id'],$item['id'],$uid,$article['is_redo']);
$item['vote_num'] = $item['vote_num'] + $item['base_vote'];
}
$more = is_more($count, $get['page_no'], $get['page_size']);
@ -216,14 +252,21 @@ class VoteLogic extends Logic
$article['images'] = [];
}
$article['rank'] = $mode->where('vote_id', $article['vote_id'])->where("vote_num",">",$article['vote_num'])->count() + 1;
//->where("vote_num",">",$article['vote_num'])
$article['rank'] = $mode->where('vote_id', $article['vote_id'])->where('(vote_num+base_vote)>'.($article['vote_num']+$article['base_vote']))->count() + 1;
if($article['rank']>1){
$last = $mode->field("*")->where('vote_id', $article['vote_id'])->where("vote_num",">",$article['vote_num'])->order("vote_num","asc")->limit(1)->select();
$article['rank_last'] = $last[0]['vote_num'] - $article['vote_num'];
$last = $mode->field("*")->where('vote_id', $article['vote_id'])
->where('(vote_num+base_vote)>'.($article['vote_num']+$article['base_vote']))
// ->where("vote_num",">",$article['vote_num'])
->orderRaw("vote_num+base_vote asc")
->limit(1)->select();
$article['rank_last'] = ($last[0]['vote_num'] +$last[0]['base_vote'] ) - ($article['vote_num']+$article['base_vote']);
}else{
$article['rank_last'] = 0;
}
$article['vote_num'] = $article['vote_num'] + $article['base_vote'];
}
return $article;

1
app/common/enum/MenuEnum.php

@ -286,6 +286,7 @@ class MenuEnum{
'link_type' => 1,
],
];
//个人中心菜单

8
app/common/model/vote/Vote.php

@ -9,6 +9,14 @@ use app\common\basics\Models;
class Vote extends Models
{
/**
* @Notes: 关联资源分类模型
* @Author:
*/
public function category()
{
return $this->hasOne('VoteCategory', 'id', 'cid');
}
}

12
app/common/model/vote/VoteCategory.php

@ -0,0 +1,12 @@
<?php
namespace app\common\model\vote;
use app\common\basics\Models;
class VoteCategory extends Models
{
}
Loading…
Cancel
Save