From 5542994e36df27ccbc7b8857c0c95700a0e9728a Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Tue, 7 Jan 2020 18:31:54 +0800 Subject: [PATCH 1/7] upt --- .../Controller/ArticleController.class.php | 88 ++++++- .../Admin/View/Article/pop_rule_edit.html | 90 +++++++ Application/Admin/View/Article/pop_rules.html | 238 ++++++++++++++++++ 3 files changed, 415 insertions(+), 1 deletion(-) create mode 100644 Application/Admin/View/Article/pop_rule_edit.html create mode 100644 Application/Admin/View/Article/pop_rules.html diff --git a/Application/Admin/Controller/ArticleController.class.php b/Application/Admin/Controller/ArticleController.class.php index f1fc5d94d..037e1d643 100644 --- a/Application/Admin/Controller/ArticleController.class.php +++ b/Application/Admin/Controller/ArticleController.class.php @@ -862,6 +862,92 @@ class ArticleController extends AdminController { $this->ajaxReturn(['status'=>0,'info'=>'请求有误'],'json'); } } - + + public function pop_rules($row = 10, $type = '', $tag = '', $p = 1) + { + $map = []; + $map['_string'] = " 1=1 "; + if (isset($_GET['time-start'])) { + $map['_string'] .= " and operate_time >= " . strtotime($_GET['time-start']); + } + if (isset($_GET['time-end'])) { + $map['_string'] .= " and operate_time < " . (strtotime($_GET['time-end']) + 86400); + } + if (isset($type)) { + $map['type'] = $type; + } + if (!empty($_GET['title'])) { + $map['title'] = ['like', "%{$_GET['title']}%"]; + } + $list = M('document_pop_rules')->where($map)->page($p, $row)->select(); + $count = M('document_pop_rules')->where($map)->count(); + if (!empty($list)) { + $weekDes = ["一", "二", '三', '四', '五', '六', '日']; + $statusDes = ['1'=>'执行完成', '2'=>'下架', '3'=>'待执行']; + foreach ($list as &$item) { + switch ($item['type']) { + case '1': + $item['time_desc'] = date("Y-m-d", $item['pop_time']); + break; + case '2': + $item['time_desc'] = "每周".$weekDes[$item['pop_time']]; + break; + } + } + } + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + $this->assign('list_data', $list); + $this->display('pop_rules'); + } + + public function pop_rule_edit($id=0) + { + if (IS_POST) { + if (empty($_POST['title']) || empty($_POST['desc']) || !isset($_POST['sort']) || empty($_POST['content'])) { + return $this->error("请填写完整的内容"); + } + if (!is_numeric($_POST['sort'])) { + return $this->error("权重值需为数字"); + } + if (!empty($_POST['type']) && empty($_POST['pop_time'])) { + return $this->error("请选择弹窗时间"); + } + if ($_POST['type'] == 1 ) { + $_POST['pop_time'] = strtotime($_POST['pop_time']); + } + if ($id) { + $pop_rules_model = M('document_pop_rules');//M('$this->$model_name','tab_'); + $res = $pop_rules_model->where(['id'=>$id])->save($_POST); + return $res ? $this->success("更新成功") : $this->error("更新失败"); + + } else { + $pop_rules_model = M('document_pop_rules');//M('$this->$model_name','tab_'); + $data = $_POST; + $data['operate_time'] = time(); + $data['operater_id'] = is_login(); + $data['status'] = 1; + $res = $pop_rules_model->add($data); + return $res ? $this->success("新增完成") : $this->error("新增失败"); + } + } else { + if($id) { + if ($_GET['delete']) { + $pop_rules_model = M('document_pop_rules');//M('$this->$model_name','tab_'); + $res = $pop_rules_model->where(['id'=>$id])->delete(); + return $res ? $this->success("删除成功") : $this->error("删除失败"); + } + $rule = M('document_pop_rules')->where(['id'=>$id])->find(); + if (!$rule) { + return $this->error('记录不存在'); + } + $rule['pop_time'] = date("Y-m-d", ($rule['pop_time'] <= 10 ? time() : $rule['pop_time'])); + $this->assign('rule', $rule); + } + } + $this->display('pop_rule_edit'); + } } diff --git a/Application/Admin/View/Article/pop_rule_edit.html b/Application/Admin/View/Article/pop_rule_edit.html new file mode 100644 index 000000000..6c906281b --- /dev/null +++ b/Application/Admin/View/Article/pop_rule_edit.html @@ -0,0 +1,90 @@ + + + +
+
编辑平台规则
+
    + +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • +
  • + + + + {:hook('adminArticleEdit', array('name'=>'content','value'=>$rule['content']))} + +
  • +
  • + +
  • +
+
+ + + +
+ + + if(C('COLOR_STYLE')=='blue_color') echo ' + + '; + + + + + + + + \ No newline at end of file diff --git a/Application/Admin/View/Article/pop_rules.html b/Application/Admin/View/Article/pop_rules.html new file mode 100644 index 000000000..b3798c942 --- /dev/null +++ b/Application/Admin/View/Article/pop_rules.html @@ -0,0 +1,238 @@ + + + + + + + + + + + + +
+ + +
+
+ +
+
+ +  -  + +
+
+ +
+ +
+ +
+ + +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID标题描述时间操作
aOh! 暂时还没有内容!
{$data.id}{$data.title}{$data.desc}{$data.time_desc} + 编辑 + 删除 +
+
+
+
+ {$_page|default=''} +
+ +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ' + + '; + + + + + + + + From e3f0a24e4370725fd31311719054ea61e687879c Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Wed, 8 Jan 2020 17:20:56 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=BC=B9=E7=AA=97=E6=8E=A8=E5=B9=BF?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/View/Article/pop_rule_edit.html | 5 +- .../Controller/PromoteController.class.php | 50 ++++++- .../Home/View/default/Promote/index.html | 60 ++++++++ .../Home/View/default/Promote/msg_list.html | 45 +++++- .../View/default/Promote/pop_rule_detail.html | 129 ++++++++++++++++++ 5 files changed, 282 insertions(+), 7 deletions(-) create mode 100644 Application/Home/View/default/Promote/pop_rule_detail.html diff --git a/Application/Admin/View/Article/pop_rule_edit.html b/Application/Admin/View/Article/pop_rule_edit.html index 6c906281b..6385b498e 100644 --- a/Application/Admin/View/Article/pop_rule_edit.html +++ b/Application/Admin/View/Article/pop_rule_edit.html @@ -15,8 +15,9 @@
  • - - + + + *排序越小越靠前
  • diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index d43e3250f..1d3156628 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -213,6 +213,24 @@ class PromoteController extends BaseController $this->assign('todayAddSpendData', $todayAddSpendData); $this->assign('mounthAddSpendData', $mounthAddSpendData); + // 规则弹窗事宜 + $rules = M("document_pop_rules") + //->where("(type = 1 and pop_time = {$currentTime}) or (type = 2 and pop_time = {$week})") + ->order("sort asc, id desc") + ->limit('0, 5') + ->select(); + $this->assign("rules", $rules); + $this->assign("rules_count", count($rules)); + + $currentTime = strtotime(date('Y-m-d')); + $weekArray = [7,1,2,3,4,5,6]; + $week = $weekArray[date("w")]; + $match_rules = M("document_pop_rules") + ->field('id') + ->where("(type = 1 and pop_time = {$currentTime}) or (type = 2 and pop_time = {$week})") + ->order("sort asc, id desc") + ->select(); + $this->assign("match_rules_id", $match_rules ? json_encode(array_column($match_rules, 'id')) : []); $this->assign("user_count", $user_count); $this->assign("total_money", $total_money); @@ -238,6 +256,30 @@ class PromoteController extends BaseController $this->display(); } + public function popRuleDetail($id=0, $p=1, $row=1, $force=false) + { + $result = M("document_pop_rules")->where("id in ({$id})")->page($p, $row)->select(); + if (empty($result)) { + return $this->error("未找到数据", [], true); + } + $count = M("document_pop_rules")->where("id in ({$id})")->count(); + if ($p + 1 <= $count) { + $this->assign("next_page",$p+1); + } + if ($p - 1 >= 0) { + $this->assign("preview_page",$p-1); + } + if ($p + 1 > $count) { + $this->assign("close_btn", true); + } + $this->assign("count", $count); + $this->assign("force", $force); + // return $this->success("获取数据成功", $result, true); + //$this->show("

    {$result['title']}

    ".$result['content']); + $this->assign("rule",$result[0]); + $this->display('pop_rule_detail'); + } + private function caculateSpend($pay_time, $condition, $create = [], $type = 0) { $map['promote_id'] = array('egt', 0); @@ -543,7 +585,12 @@ class PromoteController extends BaseController } $count = M("protect_log","tab_")->field($field)->count(); - }*/ else { + }*/ + else if ($type == 57) { + $data_list = M('document_pop_rules')->order("sort asc, id desc")->page($p, $row)->select(); + $count = count(M('document_pop_rules')->count()); + } + else { $data_list = M("document", "sys_")->join("left join sys_document_article a on a.id=sys_document.id")->limit('0,50')->where("category_id=56 and status=1 and a.id is not null")->order("update_time desc")->page($page, $row)->select(); //游戏公告 $count = M("document", "sys_")->where("category_id=56 and status=1")->count(); } @@ -563,7 +610,6 @@ class PromoteController extends BaseController $gg_ReadDocument = M("document_read", "sys_")->where($gg_where)->count(); // var_dump($gg_ReadDocument);die(); - $zx_data = M("document", "sys_")->join("left join sys_document_article a on a.id=sys_document.id")->where("category_id=51 and status=1 and a.id is not null")->order("update_time desc")->select(); $zx_Count = count($zx_data); $zx_data = implode(',', array_column($zx_data, 'id')); diff --git a/Application/Home/View/default/Promote/index.html b/Application/Home/View/default/Promote/index.html index 0c550f33c..2d9564276 100644 --- a/Application/Home/View/default/Promote/index.html +++ b/Application/Home/View/default/Promote/index.html @@ -72,6 +72,13 @@ + 平台规则 + + + +
    查看更多> @@ -123,6 +130,18 @@ +
    + + 暂无平台规则 + + +

    + {$rule.title} + {$rule.operate_time|date="Y/m/d",###} +

    +
    +
    +
  • @@ -186,6 +205,47 @@ \ No newline at end of file diff --git a/Application/Home/View/default/Promote/pop_rule_detail.html b/Application/Home/View/default/Promote/pop_rule_detail.html new file mode 100644 index 000000000..ae07b7b33 --- /dev/null +++ b/Application/Home/View/default/Promote/pop_rule_detail.html @@ -0,0 +1,129 @@ + + + + + + + 充值查询列表|----软件管理平台 + + + + + + + + + + + + + +
    + + + + +

    {$rule.title}

    +
    {$rule.content}
    +
    + + + + if(C('COLOR_STYLE')=='blue_color') echo ' + + '; + + + + + + + \ No newline at end of file From ed9ddd2d67c79dfff924e3169088868f08e4f679 Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Wed, 8 Jan 2020 17:28:37 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A3=80=E7=B4=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/ArticleController.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Application/Admin/Controller/ArticleController.class.php b/Application/Admin/Controller/ArticleController.class.php index 037e1d643..1a148ef3f 100644 --- a/Application/Admin/Controller/ArticleController.class.php +++ b/Application/Admin/Controller/ArticleController.class.php @@ -863,7 +863,7 @@ class ArticleController extends AdminController { } } - public function pop_rules($row = 10, $type = '', $tag = '', $p = 1) + public function pop_rules($row = 10, $p = 1) { $map = []; $map['_string'] = " 1=1 "; @@ -873,8 +873,8 @@ class ArticleController extends AdminController { if (isset($_GET['time-end'])) { $map['_string'] .= " and operate_time < " . (strtotime($_GET['time-end']) + 86400); } - if (isset($type)) { - $map['type'] = $type; + if (isset($_GET['type'])) { + $map['type'] = $_GET['type']; } if (!empty($_GET['title'])) { $map['title'] = ['like', "%{$_GET['title']}%"]; @@ -890,7 +890,7 @@ class ArticleController extends AdminController { $item['time_desc'] = date("Y-m-d", $item['pop_time']); break; case '2': - $item['time_desc'] = "每周".$weekDes[$item['pop_time']]; + $item['time_desc'] = "每周".$weekDes[$item['pop_time']-1]; break; } } From 56b0216ff082d83fe7fc6b1c248794c62232ecee Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Thu, 9 Jan 2020 09:49:22 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Home/Controller/PromoteController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index 1d3156628..8c92a6ad2 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -230,7 +230,7 @@ class PromoteController extends BaseController ->where("(type = 1 and pop_time = {$currentTime}) or (type = 2 and pop_time = {$week})") ->order("sort asc, id desc") ->select(); - $this->assign("match_rules_id", $match_rules ? json_encode(array_column($match_rules, 'id')) : []); + $this->assign("match_rules_id", $match_rules ? json_encode(array_column($match_rules, 'id')) : 'null'); $this->assign("user_count", $user_count); $this->assign("total_money", $total_money); From 7ea2a465bfd7d41cb3a6e9895a83de439a35c1cb Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Thu, 9 Jan 2020 16:56:36 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ArticleController.class.php | 4 +- .../Admin/View/Article/pop_rule_edit.html | 17 +++++--- .../Controller/PromoteController.class.php | 39 +++++++++++++++---- .../View/default/Promote/pop_rule_detail.html | 22 +++++------ ThinkPHP/Library/Org/RedisSDK/Redis.class.php | 5 +++ 5 files changed, 61 insertions(+), 26 deletions(-) diff --git a/Application/Admin/Controller/ArticleController.class.php b/Application/Admin/Controller/ArticleController.class.php index 1a148ef3f..e85f25567 100644 --- a/Application/Admin/Controller/ArticleController.class.php +++ b/Application/Admin/Controller/ArticleController.class.php @@ -930,7 +930,7 @@ class ArticleController extends AdminController { $data['operater_id'] = is_login(); $data['status'] = 1; $res = $pop_rules_model->add($data); - return $res ? $this->success("新增完成") : $this->error("新增失败"); + return $res ? $this->success("新增完成", U('Article/pop_rules')) : $this->error("新增失败"); } } else { if($id) { @@ -943,7 +943,7 @@ class ArticleController extends AdminController { if (!$rule) { return $this->error('记录不存在'); } - $rule['pop_time'] = date("Y-m-d", ($rule['pop_time'] <= 10 ? time() : $rule['pop_time'])); + $rule['pop_time'] = $rule['type'] == 1 ? date("Y-m-d", $rule['pop_time']) : $rule['pop_time']; $this->assign('rule', $rule); } } diff --git a/Application/Admin/View/Article/pop_rule_edit.html b/Application/Admin/View/Article/pop_rule_edit.html index 6385b498e..3232af106 100644 --- a/Application/Admin/View/Article/pop_rule_edit.html +++ b/Application/Admin/View/Article/pop_rule_edit.html @@ -21,7 +21,7 @@
  • - @@ -37,6 +37,7 @@
  • +
  • @@ -65,27 +66,33 @@ \ No newline at end of file diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index 8c92a6ad2..d532ed431 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -26,6 +26,8 @@ use Home\Model\PromoteModel; use Base\Service\PromoteService; use Base\Service\ApplyService; +use Org\RedisSDK\Redis; + /** * 前台首页控制器 * 主要获取首页聚合数据 @@ -222,14 +224,22 @@ class PromoteController extends BaseController $this->assign("rules", $rules); $this->assign("rules_count", count($rules)); - $currentTime = strtotime(date('Y-m-d')); - $weekArray = [7,1,2,3,4,5,6]; - $week = $weekArray[date("w")]; - $match_rules = M("document_pop_rules") - ->field('id') - ->where("(type = 1 and pop_time = {$currentTime}) or (type = 2 and pop_time = {$week})") - ->order("sort asc, id desc") - ->select(); + $redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]); + $cacheKey = "pop:rule:set"; + if (!$redis->sIsMember($cacheKey, get_pid())) { + $currentTime = strtotime(date('Y-m-d')); + $weekArray = [7,1,2,3,4,5,6]; + $week = $weekArray[date("w")]; + $match_rules = M("document_pop_rules") + ->field('id') + ->where("(type = 1 and pop_time = {$currentTime}) or (type = 2 and pop_time = {$week})") + ->order("sort asc, id desc") + ->select(); + } else { + $match_rules = []; + } + + $this->assign("match_rules_id", $match_rules ? json_encode(array_column($match_rules, 'id')) : 'null'); $this->assign("user_count", $user_count); @@ -280,6 +290,19 @@ class PromoteController extends BaseController $this->display('pop_rule_detail'); } + public function popRuleFinish() + { + $redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]); + $cacheKey = "pop:rule:set"; + if ($redis->exists($cacheKey)) { + $redis->sadd($cacheKey, get_pid()); + } else { + $redis->sadd($cacheKey, get_pid()); + $redis->exprieAt($cacheKey, strtotime(date('Y-m-d')) + 86400); + } + return $this->success("成功", [], true); + } + private function caculateSpend($pay_time, $condition, $create = [], $type = 0) { $map['promote_id'] = array('egt', 0); diff --git a/Application/Home/View/default/Promote/pop_rule_detail.html b/Application/Home/View/default/Promote/pop_rule_detail.html index ae07b7b33..5cb08a123 100644 --- a/Application/Home/View/default/Promote/pop_rule_detail.html +++ b/Application/Home/View/default/Promote/pop_rule_detail.html @@ -90,6 +90,8 @@