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