From 3a8273283ee5e1cb03d21159234652449c6f42f9 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 19 May 2020 10:53:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E6=AF=94=E4=BE=8B=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GameRatioMouldController.class.php | 93 ++++++++++++++-- .../Admin/View/GameRatioMould/add.html | 104 +++++++++--------- 2 files changed, 135 insertions(+), 62 deletions(-) diff --git a/Application/Admin/Controller/GameRatioMouldController.class.php b/Application/Admin/Controller/GameRatioMouldController.class.php index d09f84296..902800cca 100644 --- a/Application/Admin/Controller/GameRatioMouldController.class.php +++ b/Application/Admin/Controller/GameRatioMouldController.class.php @@ -4,6 +4,15 @@ namespace Admin\Controller; class GameRatioMouldController extends AdminController { + public $admininfo; + public $DBModel; + public function _initialize() + { + $this->admininfo = $_SESSION['onethink_admin']['user_auth']; + $this->DBModel = M("game_ratio_mould","tab_"); + parent::_initialize(); + } + public function index() { @@ -15,21 +24,79 @@ class GameRatioMouldController extends AdminController if ($_POST) { $params = I('post.'); - addOperationLog(['op_type'=>1,'key'=>getPromoteName($promoteGameRatio['promote_id']).'/'.getrelationGameName($promoteGameRatio['game_id']),'op_name'=>'修改游戏分成比例申请','url'=>U('PromoteGameRatio/applyRatio',['id'=>$promoteGameRatio['id']]),'menu'=>'推广员-结算单管理-公会分成管理']); - $this->success('保存成功', U('lists')); + + if (!isset($params['ratio']) || $params['ratio'] === '') { + $this->error('默认分成比例不能为空'); + } + $save['turnover_ratio'] = []; + if (!empty(array_filter($params['turnover'])) || !empty(array_filter($params['turnover_ratio'])) ) { + if (is_array($params['turnover']) && is_array($params['turnover_ratio']) && is_array($params['instanceof'])) { + foreach ($params['turnover'] as $turnover) { + if (empty($turnover)) { + $this->error('月流水不能为空'); + } + } + foreach ($params['turnover_ratio'] as $turnoverRatio) { + if (empty($turnoverRatio)) { + $this->error('月流水分成比例不能为空'); + } + } + foreach ($params['instanceof'] as $intervalClosedStatus) { + if (!in_array($intervalClosedStatus, [1, 2])) { + $this->error('月流水分符号不能为空'); + } + } + $turnoverCount = count($params['turnover']); + $sortTurnover = $params['turnover']; + sort($sortTurnover); + if ($params['turnover'] != $sortTurnover || $turnoverCount != count(array_unique($params['turnover']))) { + $this->error('月流水必须以正序的方式填写,且必须大于上一个月流水'); + } + $ratio = $params['ratio'] ?? 0; + if ($params['turnover_ratio'][0] <= $ratio) { + $this->error('月流水分成比例必须大于默认分成比例'); + } + $turnoverRatioCount = count($params['turnover_ratio']); + $sortTurnoverRatio = $params['turnover_ratio']; + sort($sortTurnoverRatio); + if ($params['turnover_ratio'] != $sortTurnoverRatio || $turnoverRatioCount != count(array_unique($params['turnover_ratio']))) { + $this->error('月流水分成比例必须以正序的方式填写,且必须大于上一个月流水分成比例'); + } + + foreach ($params['turnover'] as $key => $turnover) { + $save['turnover_ratio'][] = [ + 'turnover' => bcdiv($turnover, 1, 2), + 'ratio' => bcdiv($params['turnover_ratio'][$key], 1, 2), + 'instanceof' => (isset($params['instanceof'][$key]) ? $params['instanceof'][$key] : 1), + ]; + } + $save['turnover_ratio'] = json_encode($save['turnover_ratio']); + } + } + $save['ratio'] = $params['ratio'] ?? 0; + $save['relation_game_id'] = $params['relation_game_id'] ?? 0; + $save['company_belong'] = $params['company_belong'] ?? 3; + $save["admin_name"]=$this->admininfo["username"]; + $save["admin_id"]=$this->admininfo["uid"]; + $save["create_time"]=\time(); + //判断是否存在 + $where = [ + "relation_game_id"=>$save['relation_game_id'], + "company_belong"=>$save['company_belong'] + ]; + $hasdb = $this->DBModel->field("count(id) count")->where($where)->find()['count']; + if($hasdb > 0){ + $this->error('该游戏与该公司类型的模板已经存在,请搜索后编辑'); + } + //保存 + $this->DBModel->add($save); + addOperationLog(['op_type'=>1,'key'=>getPromoteName($promoteGameRatio['promote_id']).'/'.getrelationGameName($promoteGameRatio['game_id']),'op_name'=>'新增游戏分成比例模板','url'=>U('GameRatioMould/index')]); + $this->ajaxReturn(["msg"=>"添加成功","code"=>1,"url"=>U("index")]); } else { $game_type = M("game_type","tab_")->field("id,type_name")->where("status=1")->select(); $this->assign("game_type",$game_type); //渠道类型 $this->assign("company_belong",getCompanyBlong()); - - - $params = I('get.'); - $id = $params['id'] ?? 0; - $id = intval($id); - $companyId = 0; - $metaTitle = '游戏分成比例申请'; - $this->display(); } } @@ -57,6 +124,12 @@ class GameRatioMouldController extends AdminController $games = M("game","tab_")->field("relation_game_id,relation_game_name,original_package_name")->where("game_type_id = '{$gameTypeId}'")->group("relation_game_name")->select(); $this->ajaxReturn($games); } + public function error($data) + { + header('Content-Type:application/json; charset=utf-8'); + $data =json_encode(['msg'=>$data,"code"=>4000],JSON_UNESCAPED_UNICODE); + exit($data); + } } \ No newline at end of file diff --git a/Application/Admin/View/GameRatioMould/add.html b/Application/Admin/View/GameRatioMould/add.html index e40a1ecb8..106fc7ef0 100644 --- a/Application/Admin/View/GameRatioMould/add.html +++ b/Application/Admin/View/GameRatioMould/add.html @@ -65,9 +65,29 @@ .iconfont-unselected:hover { background-color: #ababab; } + + input[type=number]{ + padding: 4px 6px; + font-size: 12px; + line-height: 20px; + color: #555; + vertical-align: middle; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + background-color: #fff; + border: 1px solid #ccc; + -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); + box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); + -webkit-transition: border linear .2s, box-shadow linear .2s; + -moz-transition: border linear .2s, box-shadow linear .2s; + -o-transition: border linear .2s, box-shadow linear .2s; + transition: border linear .2s, box-shadow linear .2s; + } @@ -128,7 +148,7 @@ *分成比例设定: - + % 当前需要修改成的分成比例 @@ -140,20 +160,6 @@
-
@@ -270,11 +276,17 @@ $(function(){ var obj = { "relation_game_id":["required","游戏不能为空","select"], "company_belong":["required","公司类型不能为空","select"], + "ratio":["number","默认比例必须是大于0的数字"] } var cres = CIC.checkAddInput(obj); if(!cres){ return false; } + if(cres.ratio > 100){ + layer.msg("默认比例不能大于100", {icon: 2}); + return false; + } + $(".error-message").each(function(index,elm){ var t = $(elm).css("display"); @@ -286,7 +298,6 @@ $(function(){ }) $(".turnover_money").each(function(index,elm){ var t = $(elm).val(); - console.log(t) if(t == ''){ flag = false; layer.msg("流水及比例不允许为空", {icon: 2}); @@ -300,40 +311,29 @@ $(function(){ var target = $('form').get(0).action; var query = $('form').serialize(); var that = this; - // console.log($('form')); - return false; - // $(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true); - - // $.post(target,query).success(function(data){ - // if(layer) {layer.closeAll('loading');} - // if (data.status==1) { - // if (data.url) { - // updateAlert(data.info + ' 页面即将自动跳转~'); - // }else{ - // updateAlert(data.info); - // } - // setTimeout(function(){ - // $(that).removeClass('disabled').prop('disabled',false); - // if (data.url) { - // location.href=data.url; - // }else if( $(that).hasClass('no-refresh')){ - // $('#tip').find('.tipclose').click(); - // }else{ - // location.reload(); - // } - // },1500); - // }else{ - // updateAlert(data.info,'tip_error'); - // setTimeout(function(){ - // $(that).removeClass('disabled').prop('disabled',false); - // if (data.url) { - // location.href=data.url; - // }else{ - // $('#tip').find('.tipclose').click(); - // } - // },3000); - // } - // }); + $(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true); + $.post(target,query).success(function(data){ + if(layer) {layer.closeAll('loading');} + if (data.code==1) { + if (data.url) { + updateAlert(data.msg + ' 页面即将自动跳转~'); + }else{ + updateAlert(data.msg); + } + setTimeout(function(){ + $(that).removeClass('disabled').prop('disabled',false); + if (data.url) { + location.href=data.url; + }else if( $(that).hasClass('no-refresh')){ + $('#tip').find('.tipclose').click(); + }else{ + location.reload(); + } + },1500); + }else{ + layer.msg(data.msg,{icon: 2}); + } + }); }); } @@ -408,7 +408,7 @@ $(function(){ var thatLiRatioIndex = thatLiRatio.index(); var thatTurnoverRatio = parseFloat(that.val()); - if (thatLiRatioIndex === 0) { + if (thatLiRatioIndex === 1) { prevTurnoverRatio = ratio; prevTurnoverRatioHandle(thatTurnoverRatio, prevTurnoverRatio, that, true); } else {