diff --git a/Application/Admin/Controller/PresidentDepositController.class.php b/Application/Admin/Controller/PresidentDepositController.class.php index f2979972f..20aaa4397 100644 --- a/Application/Admin/Controller/PresidentDepositController.class.php +++ b/Application/Admin/Controller/PresidentDepositController.class.php @@ -181,7 +181,7 @@ class PresidentDepositController extends ThinkController public function edit() { - $this->meta_title = '编辑/查看会长押金'; + $this->meta_title = '编辑会长押金'; $id = I('id', 0); $promote = M('promote', 'tab_')->field(['account', 'id'])->where(['id' => $id])->find(); $record = M('president_deposit', 'tab_')->where(['promote_id' => $id])->find(); @@ -192,6 +192,19 @@ class PresidentDepositController extends ThinkController $this->display('form'); } + public function show() + { + $this->meta_title = '查看会长押金'; + $id = I('id', 0); + $promote = M('promote', 'tab_')->field(['account', 'id'])->where(['id' => $id])->find(); + $record = M('president_deposit', 'tab_')->where(['promote_id' => $id])->find(); + $this->assign('payWays', PresidentDepositService::$payWays); + $this->assign('payTypes', PresidentDepositService::$payTypes); + $this->assign('promote', $promote); + $this->assign('record', $record); + $this->display('show'); + } + public function save() { $payWay = I('pay_way', 0); @@ -205,14 +218,18 @@ class PresidentDepositController extends ThinkController $promoteData = M('promote', 'tab_')->field('account')->where(['id' => $promoteId])->find(); - if (!$record) { + if ($payType == 0) { + return $this->error('请选择押金付款方式'); + } + if ($payType == 3) { + $this->handleNoDeposit($promoteId); + return $this->success('保存成功', U('records')); + } + if ($payType != 2 && $payWay == 0) { + return $this->error('请选择付款方式'); + } - if ($payType == 0) { - return $this->error('请选择押金付款方式'); - } - if ($payType != 2 && $payWay == 0) { - return $this->error('请选择付款方式'); - } + if (!$record) { if ($amount !== '') { if (!is_numeric($amount)) { return $this->error('请输入正确金额'); @@ -237,13 +254,12 @@ class PresidentDepositController extends ThinkController M('president_deposit', 'tab_')->add($data); addOperationLog(['op_type'=>0,'key'=>$promoteData['account'].'/'.$amount,'op_name'=>'新增会长押金','url'=>U('PresidentDeposit/edit',['id'=>$promoteId]),'menu'=>'推广员-结算单管理-奖罚记录管理-新增会长押金']); - - return $this->success('保存成功', U('PresidentDeposit/records')); + return $this->success('保存成功', U('records')); } - if ($record['status'] != 0) { + /* if ($record['status'] != 0) { return $this->error('该状态下不可编辑/修改'); - } + } */ if ($amount === '') { return $this->error('请输入金额'); @@ -265,6 +281,8 @@ class PresidentDepositController extends ThinkController } $data = []; + $data['pay_way'] = $payType == 2 ? 4 : $payWay; + $data['pay_type'] = $payType; $data['pay_account'] = $payAccount; $data['amount'] = floatval($amount); $data['payer'] = $payer; @@ -273,7 +291,7 @@ class PresidentDepositController extends ThinkController addOperationLog(['op_type'=>1,'key'=>$promoteData['account'].'/'.$amount,'op_name'=>'编辑会长押金','url'=>U('PresidentDeposit/edit',['id'=>$promoteId]),'menu'=>'推广员-结算单管理-会长押金管理-编辑会长押金']); - return $this->success('保存成功'); + return $this->success('保存成功', U('records')); } public function delete() @@ -289,28 +307,34 @@ class PresidentDepositController extends ThinkController ]); } - public function noDeposit() + public function handleNoDeposit($promoteId) { - $promoteId = I('id', 0); $record = M('president_deposit', 'tab_')->where(['promote_id' => $promoteId])->find(); + $data = []; + $data['pay_way'] = 0; + $data['pay_type'] = PresidentDepositService::PAY_TYPE_NONE; + $data['pay_account'] = ''; + $data['amount'] = 0; + $data['payer'] = ''; + $data['create_time'] = time(); + $data['update_time'] = time(); + if (!$record) { - $data = []; - $data['pay_way'] = 0; - $data['pay_type'] = PresidentDepositService::PAY_TYPE_NONE; $data['promote_id'] = $promoteId; - $data['pay_account'] = ''; - $data['amount'] = 0; - $data['payer'] = ''; - $data['create_time'] = time(); - $data['update_time'] = time(); M('president_deposit', 'tab_')->add($data); - - $promoteData = M('promote', 'tab_')->field('account')->where(['id' => $promoteId])->find(); - - addOperationLog(['op_type'=>1,'key'=>$promoteData['account'],'op_name'=>'编辑无需押金','url'=>U('PresidentDeposit/records'),'menu'=>'推广员-结算单管理-会长押金管理-无需押金']); - + } else { + M('president_deposit', 'tab_')->where(['promote_id' => $promoteId])->save($data); } + + $promoteData = M('promote', 'tab_')->field('account')->where(['id' => $promoteId])->find(); + addOperationLog(['op_type'=>1,'key'=>$promoteData['account'],'op_name'=>'编辑无需押金','url'=>U('PresidentDeposit/records'),'menu'=>'推广员-结算单管理-会长押金管理-无需押金']); + } + + public function noDeposit() + { + $promoteId = I('id', 0); + $this->handleNoDeposit($promoteId); $this->ajaxReturn([ 'status' => 1, 'message' => '操作成功' diff --git a/Application/Admin/View/PresidentDeposit/form.html b/Application/Admin/View/PresidentDeposit/form.html index b97f932d3..5912f2511 100644 --- a/Application/Admin/View/PresidentDeposit/form.html +++ b/Application/Admin/View/PresidentDeposit/form.html @@ -90,7 +90,7 @@