From 5fa22cfa40e3420ab4c42d323207320a7b4d616f Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Mon, 13 Apr 2020 11:35:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ArticleController.class.php | 9 +++ .../Admin/View/Article/pop_rule_edit.html | 7 +- .../Controller/PromoteController.class.php | 74 +++++++++++-------- .../Home/View/default/Promote/index.html | 27 ++++--- .../View/default/Promote/pop_rule_detail.html | 3 +- 5 files changed, 75 insertions(+), 45 deletions(-) diff --git a/Application/Admin/Controller/ArticleController.class.php b/Application/Admin/Controller/ArticleController.class.php index 464fd307a..cf37c0992 100644 --- a/Application/Admin/Controller/ArticleController.class.php +++ b/Application/Admin/Controller/ArticleController.class.php @@ -944,6 +944,14 @@ class ArticleController extends AdminController { if (!$rule) { return $this->error('记录不存在'); } + if (empty($rule['document_route'])) { + $doc = "当前无文档"; + }else { + $document_route_arr = explode("/", $rule['document_route']); + $doc = $document_route_arr[2]; + } + + $this->assign("doc", $doc); $rule['pop_time'] = $rule['type'] == 1 ? date("Y-m-d", $rule['pop_time']) : $rule['pop_time']; $this->assign('rule', $rule); } @@ -973,6 +981,7 @@ class ArticleController extends AdminController { $updateres = M('document_pop_rules')->where(['id' => $id])->save($data); if ($updateres) { $backData['code'] = 10000; + $backData['filename'] = $name; }else { $backData['code'] = 10001; } diff --git a/Application/Admin/View/Article/pop_rule_edit.html b/Application/Admin/View/Article/pop_rule_edit.html index f7120294f..c019ce359 100644 --- a/Application/Admin/View/Article/pop_rule_edit.html +++ b/Application/Admin/View/Article/pop_rule_edit.html @@ -27,8 +27,9 @@ + 当前文档:{$doc} - +
  • @@ -101,9 +102,11 @@ if (res.code == 10000) { document.getElementById('uploadstatus').style.display = 'block' document.getElementById('uploadstatus1').style.display = 'none' + document.getElementById('aa').style.display = 'none' }else { document.getElementById('uploadstatus1').style.display = 'block' document.getElementById('uploadstatus').style.display = 'none' + document.getElementById('aa').style.display = 'none' } } @@ -135,7 +138,7 @@ } else if (type_val == 2) { //$('#li-pop-time').show(); - $("#li-pop-time").html(''); + $("#li-pop-time").html(''); } } checkPopTime(1); diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index c08990848..c0b46c8d2 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -241,47 +241,51 @@ class PromoteController extends BaseController }else { $belongs_tag = 1; } + // if (intval($promoteBelong) == $belongs_tag) { + // $redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]); + // $newcacheKey = "pop:newrule:set"; + // if (!$redis->sIsMember($newcacheKey, get_pid())) { + // $currentTime = strtotime(date('Y-m-d')); + // $weekArray = [7,1,2,3,4,5,6]; + // $week = $weekArray[date("w")]; + // $match_newrules = M("document_pop_rules") + // ->field('id') + // ->where(['id' => 2]) + // ->order("sort asc, id desc") + // ->select(); + // } else { + // $match_newrules = []; + // } + // } else { + // $match_newrules = []; + // } + // $match_newrules_route = M("document_pop_rules") + // ->where(['id' => 2]) + // ->getField('document_route'); if (intval($promoteBelong) == $belongs_tag) { $redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]); - $newcacheKey = "pop:newrule:set"; - if (!$redis->sIsMember($newcacheKey, get_pid())) { + $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_newrules = M("document_pop_rules") - ->field('id') - ->where(['id' => 2]) + $match_rules = M("document_pop_rules") + ->field('id,document_route,pop_time') + ->where("(type = 1 and pop_time = {$currentTime}) or (type = 2 and pop_time = {$week})") ->order("sort asc, id desc") ->select(); - } else { - $match_newrules = []; + } else { + $match_rules = []; } - } else { - $match_newrules = []; - } - $match_newrules_route = M("document_pop_rules") - ->where(['id' => 2]) - ->getField('document_route'); - $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 = []; - } + }else {$match_rules = [];} + $this->assign("match_rules_id", $match_rules ? json_encode(array_column($match_rules, 'id')) : 'null'); - $this->assign("match_newrules_id", $match_newrules ? json_encode(array_column($match_newrules, 'id')) : 'null'); - $this->assign("match_newrules_route", $match_newrules_route); + //$this->assign("match_newrules_id", $match_newrules ? json_encode(array_column($match_newrules, 'id')) : 'null'); + $this->assign("match_rules_route", $match_rules ? json_encode(array_column($match_rules, 'document_route')) : 'null'); + $this->assign("pop_time1", $match_rules ? json_encode(array_column($match_rules, 'pop_time')) : 'null'); $this->assign("user_count", $user_count); $this->assign("total_money", $total_money); @@ -309,7 +313,7 @@ class PromoteController extends BaseController $this->display(); } - public function popRuleDetail($id=0, $p=1, $row=1, $force=false) + public function popRuleDetail($id=0, $p=1, $row=1, $force=false, $pop = false) { $result = M("document_pop_rules")->where("id in ({$id})")->page($p, $row)->select(); if (empty($result)) { @@ -327,6 +331,7 @@ class PromoteController extends BaseController } $this->assign("count", $count); $this->assign("force", $force); + $this->assign("pop", $pop); // return $this->success("获取数据成功", $result, true); //$this->show("

    {$result['title']}

    ".$result['content']); $this->assign("rule",$result[0]); @@ -370,7 +375,7 @@ class PromoteController extends BaseController } - public function popRuleFinish() + public function popRuleFinish($pop = false) { $redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]); $cacheKey = "pop:rule:set"; @@ -378,7 +383,12 @@ class PromoteController extends BaseController $redis->sadd($cacheKey, get_pid()); } else { $redis->sadd($cacheKey, get_pid()); - $redis->exprieAt($cacheKey, strtotime(date('Y-m-d')) + 86400); + if ($pop) { + $redis->exprieAt($cacheKey, strtotime('next sunday') + 24*3600); + }else { + $redis->exprieAt($cacheKey, strtotime(date('Y-m-d')) + 86400); + } + } return $this->success("成功", [], true); } diff --git a/Application/Home/View/default/Promote/index.html b/Application/Home/View/default/Promote/index.html index 7c7ef1579..1b31bae2c 100644 --- a/Application/Home/View/default/Promote/index.html +++ b/Application/Home/View/default/Promote/index.html @@ -19,7 +19,7 @@ @@ -204,7 +204,7 @@ - +
    {$_page}
    @@ -216,11 +216,15 @@