From d33d0c3f464f2a3c3cf5a6e0df96cdf71d8dd697 Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Wed, 15 Jan 2020 10:50:03 +0800 Subject: [PATCH 1/9] upt --- .../Admin/Controller/GameController.class.php | 33 +++++++++++ .../Admin/View/Game/devide_warn_edit.html | 55 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 Application/Admin/View/Game/devide_warn_edit.html diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index 5a1cbf4dd..f22beeeea 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -439,6 +439,7 @@ class GameController extends ThinkController M('Game', 'tab_')->where($map)->data(array('relation_game_id' => $anogame['id']))->save(); } + $pic = M('Picture')->find($gda['icon']); $count = M('Game', 'tab_')->where(array('icon' => $gda['icon']))->count();//统计icon是否为多个游戏的图标 if ($pic != '' && $count == 1) { //只有一个游戏指向这个图标 @@ -761,4 +762,36 @@ class GameController extends ThinkController } + public function companyGames($id) + { + $games = M('Game', 'tab_') + ->where(['partner_id'=>$id]) + ->join("tab_cp_game_ratio on tab_game.id = tab_cp_game_ratio.game_id and begin_total_amount = 0 and is_del = 0", "left") + ->field("relation_game_name, game_id, tab_cp_game_ratio.ratio") + ->group('relation_game_id')->select(); + echo M()->getLastSql(); + var_dump($games); + } + + public function devide_warn_list() + { + + } + + public function devide_warn_edit($id=0) + { + if (IS_POST) { + + } else { + $partners = M('partner', 'tab_')->field("id, partner")->where(['status'=>1])->order('last_up_time desc')->select(); + $this->assign('partners', $partners); + if ($id) { + $warnInfo = M('partner_divide_warn', 'tab_')->where(['id'=>$id])->find(); + if (!$warnInfo) return $this->error('未找到该记录'); + $this->assign('warnInfo', $warnInfo); + } + $this->display(); + } + } + } diff --git a/Application/Admin/View/Game/devide_warn_edit.html b/Application/Admin/View/Game/devide_warn_edit.html new file mode 100644 index 000000000..3fc7b48fe --- /dev/null +++ b/Application/Admin/View/Game/devide_warn_edit.html @@ -0,0 +1,55 @@ + + + +
+
预警编辑
+
    + +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + + 分成比例 + % + + + + +
  • +
  • + +
  • +
+
+ + + +
+ + + \ No newline at end of file From 076b4393ebf8997053fb46e7953fb37ce1286e46 Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Wed, 15 Jan 2020 11:47:42 +0800 Subject: [PATCH 2/9] upt --- .../Admin/Controller/GameController.class.php | 29 ++++++++ .../Admin/View/Game/devide_warn_edit.html | 73 ++++++++++++++++--- 2 files changed, 92 insertions(+), 10 deletions(-) diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index 21f98e68d..859dd8682 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -783,13 +783,42 @@ class GameController extends ThinkController public function devide_warn_edit($id=0) { if (IS_POST) { + if ($_POST['phones']) { + $_POST['phones'] = array_unique($_POST['phones']); + foreach ($_POST['phones'] as $phone) { + if (!preg_match('/^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/', $phone)) { + return $this->error("请输入正确的手机号码:{$phone}"); + } + } + $_POST['phones'] = json_encode($_POST['phones']); + } else { + $_POST['phones'] = '[]'; + } + if (!is_numeric($_POST['advance_amount']) || !is_numeric($_POST['warming_amount']) || !is_numeric($_POST['warn_frequency'])) { + return $this->error("金额需为数字!"); + } + if ($_POST['advance_amount'] < $_POST['warming_amount']) { + return $this->error("预警金额不能大于预付金额"); + } + if ($_POST['warming_amount'] < $_POST['warn_frequency']) { + return $this->error("预警金额频率不能大于预警金额"); + } + if ($id) { + $upt = M('partner_divide_warn', 'tab_')->where(['id'=>$id])->save($_POST); + return $upt ? $this->success("更新成功") : $this->error("更新失败"); + } else { + if (M('partner_divide_warn', 'tab_')->where(['partner_id'=>$_POST['partner_id']])) + $ins = M('partner_divide_warn', 'tab_')->add($_POST); + return $ins ? $this->success("新增成功") : $this->error("新增失败"); + } } else { $partners = M('partner', 'tab_')->field("id, partner")->where(['status'=>1])->order('last_up_time desc')->select(); $this->assign('partners', $partners); if ($id) { $warnInfo = M('partner_divide_warn', 'tab_')->where(['id'=>$id])->find(); if (!$warnInfo) return $this->error('未找到该记录'); + $warnInfo['phones'] = json_decode($warnInfo['phones'], true); $this->assign('warnInfo', $warnInfo); } $this->display(); diff --git a/Application/Admin/View/Game/devide_warn_edit.html b/Application/Admin/View/Game/devide_warn_edit.html index 3fc7b48fe..e0de85749 100644 --- a/Application/Admin/View/Game/devide_warn_edit.html +++ b/Application/Admin/View/Game/devide_warn_edit.html @@ -1,14 +1,43 @@ + + + + + -
+ + + +
预警编辑
    - +
  • - @@ -23,15 +52,32 @@
  • + + +
  • + + $phone):?> + +
  • + + + +
  • + +
  • - - 分成比例 - % - - - - + + +
  • + + + +
  • + + +
  • +
  • @@ -51,5 +97,12 @@ \ No newline at end of file From 0ebe11027e1791286d6f26eebc0a49accfa2761b Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Thu, 16 Jan 2020 10:00:47 +0800 Subject: [PATCH 3/9] upt --- .../Admin/Controller/GameController.class.php | 63 +++++- .../Admin/View/Game/devide_warn_edit.html | 36 ++- .../Admin/View/Game/devide_warn_list.html | 205 ++++++++++++++++++ 3 files changed, 290 insertions(+), 14 deletions(-) create mode 100644 Application/Admin/View/Game/devide_warn_list.html diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index 859dd8682..1ce81082f 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -775,14 +775,47 @@ class GameController extends ThinkController var_dump($games); } - public function devide_warn_list() + public function devide_warn_list($row = 10, $p = 1) { - + $map = ['pdw.status'=>1]; + if (!empty($_GET['partner_id'])) { + $map['pdw.partner_id'] = $_GET['partner_id']; + } + if (!empty($_GET['relation_game_id'])) { + $partner = M('Game', 'tab_')->field('partner_id')->where(['relation_game_id'=>$_GET['relation_game_id']])->find(); + $map['pdw.partner_id'] = $partner['partner_id']; + } + $list = M('partner_divide_warn', 'tab_') + ->alias('pdw')->field("pdw.*, p.partner, sum(s.pay_amount) as total_amount, group_concat(distinct(g.relation_game_name)) as game_name") + ->join("tab_partner p on p.id = pdw.partner_id") + ->join("tab_game g on pdw.partner_id = g.partner_id", 'left') + ->join('tab_spend s on s.game_id = g.id', 'left') + ->where(array_merge($map, ['s.pay_status'=>1])) + ->group('pdw.id, p.partner') + ->page($p, $row)->select(); + $count = M('partner_divide_warn', 'tab_')->alias('pdw')->join("tab_game g on pdw.partner_id = g.partner_id", 'left')->where($map)->count(); + // if (!empty($list)) { + // foreach ($list as &$item) { + // $item['create_time'] = date('Y-m-d', $item['create_time']); + // $item['upt_time'] = date('Y-m-d', $item['upt_time']); + // } + // } + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + $partners = M('partner', 'tab_')->field("id, partner")->where(['status'=>1])->order('last_up_time desc')->select(); + $this->assign('partners', $partners); + $this->assign('list_data', $list); + $this->display(); } - public function devide_warn_edit($id=0) + public function devide_warn_edit($id=0, $delete=0) { if (IS_POST) { + if (empty($_POST['advance_amount']) || empty($_POST['warming_amount']) || empty($_POST['warn_frequency']) || empty($_POST['phones'])) { + return $this->error("请填写必填数据"); + } if ($_POST['phones']) { $_POST['phones'] = array_unique($_POST['phones']); foreach ($_POST['phones'] as $phone) { @@ -805,10 +838,16 @@ class GameController extends ThinkController } if ($id) { + $_POST['upt_time'] = $_POST['create_time'] = time(); + $_POST['operater_id'] = is_login(); $upt = M('partner_divide_warn', 'tab_')->where(['id'=>$id])->save($_POST); return $upt ? $this->success("更新成功") : $this->error("更新失败"); } else { - if (M('partner_divide_warn', 'tab_')->where(['partner_id'=>$_POST['partner_id']])) + if (M('partner_divide_warn', 'tab_')->where(['partner_id'=>$_POST['partner_id'], 'status'=>1])->find()) { + return $this->error('已有当前合作伙伴的预警设置'); + } + $_POST['upt_time'] = $_POST['create_time'] = time(); + $_POST['operater_id'] = is_login(); $ins = M('partner_divide_warn', 'tab_')->add($_POST); return $ins ? $this->success("新增成功") : $this->error("新增失败"); } @@ -816,10 +855,18 @@ class GameController extends ThinkController $partners = M('partner', 'tab_')->field("id, partner")->where(['status'=>1])->order('last_up_time desc')->select(); $this->assign('partners', $partners); if ($id) { - $warnInfo = M('partner_divide_warn', 'tab_')->where(['id'=>$id])->find(); - if (!$warnInfo) return $this->error('未找到该记录'); - $warnInfo['phones'] = json_decode($warnInfo['phones'], true); - $this->assign('warnInfo', $warnInfo); + if ($delete) { + $_POST['upt_time'] = $_POST['create_time'] = time(); + $_POST['operater_id'] = is_login(); + $_POST['status'] = 2; + $del = M('partner_divide_warn', 'tab_')->where(['id'=>$id])->save($_POST); + return $del ? $this->success("删除成功") : $this->error("删除失败"); + } else { + $warnInfo = M('partner_divide_warn', 'tab_')->where(['id'=>$id])->find(); + if (!$warnInfo) return $this->error('未找到该记录'); + $warnInfo['phones'] = json_decode($warnInfo['phones'], true); + $this->assign('warnInfo', $warnInfo); + } } $this->display(); } diff --git a/Application/Admin/View/Game/devide_warn_edit.html b/Application/Admin/View/Game/devide_warn_edit.html index e0de85749..ad8a2c464 100644 --- a/Application/Admin/View/Game/devide_warn_edit.html +++ b/Application/Admin/View/Game/devide_warn_edit.html @@ -23,6 +23,28 @@ color: #4DB361; } + @@ -39,28 +61,28 @@
  • - + *
  • - + *
  • - + *
  • $phone):?>
  • - + *
  • @@ -74,12 +96,13 @@
  • - + *
  • +
@@ -97,6 +120,7 @@ + + + + + + + +
+ + +
+
+ +
+
+ +
+
+ +
+ + +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
预警对象游戏名称游戏总流水预付金额预警金额预警金额频率预警手机号修改时间创建时间操作人操作
aOh! 暂时还没有内容!
{$data.partner}{$data.game_name}{$data.total_amount}{$data.advance_amount}{$data.warming_amount}{$data.warn_frequency}{$data.upt_time|date='Y-m-d H:i:s',###}{$data.create_time|date='Y-m-d H:i:s',###}{:get_admin_nickname($data['operater_id'])} + 编辑 + 解除 +
+
+
+
+ {$_page|default=''} +
+ + + +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ' + + '; + + + + + + + + From 6daf38aa43df1bc1c2d709e7c1d82a0ef0587752 Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Thu, 16 Jan 2020 11:14:32 +0800 Subject: [PATCH 4/9] upt --- .../Controller/ConsoleController.class.php | 34 +++++++++++++++++++ .../Admin/View/Game/devide_warn_edit.html | 1 - 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index 69a182a70..07d87d314 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -324,4 +324,38 @@ class ConsoleController extends Think { } ); } + + public function divideWarnCheck() + { + $redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]); + $warns = M('partner_divide_warn', 'tab_')->alias('pdw') + ->field('pdw.*, cgr.ratio, sum(s.pay_amount) as total_amount') + ->join('tab_game g on pdw.partner_id = g.partner_id') + ->join('tab_cp_game_ratio cgr on cgr.game_id = g.id and begin_total_amount = 0 and is_del = 0') + ->join('tab_spend s on s.game_id = g.id') + ->where(['pdw.status'=>1, 's.pay_status'=>1]) + ->group('pdw.id') + ->select(); + if (!$warns) return; + foreach ($warns as $info) { + if (!$info['ratio']) return; + $total_amount = ceil(($info['ratio'] / 100) * $info['total_amount']); + $cacheKey = "divide:warn:check:{$info['partner_id']}"; + if (!($lastStep = $redis->get($cacheKey))) { + $lastStep = 0; + } + if ($total_amount >= $info['warming_amount']) { + if ($total_amount - $lastStep >= $info['warn_frequency']) { // 达到预警 + // 发送预警短信 + echo "发送短信"; + // 变换缓存值,如果为0,需要设置过期时间 + if ($lastStep) { + $redis->set($cacheKey, $total_amount); + } else { + $redis->setex($cacheKey, 86400 * 30, $total_amount); + } + } + } + } + } } diff --git a/Application/Admin/View/Game/devide_warn_edit.html b/Application/Admin/View/Game/devide_warn_edit.html index ad8a2c464..4b06f87c7 100644 --- a/Application/Admin/View/Game/devide_warn_edit.html +++ b/Application/Admin/View/Game/devide_warn_edit.html @@ -120,7 +120,6 @@