作者 董瑞恩
1 个管道 的构建 通过 耗费 1 秒

cost

@@ -38,6 +38,32 @@ class AdminCostController extends AdminBaseController{ @@ -38,6 +38,32 @@ class AdminCostController extends AdminBaseController{
38 38
39 public function editPost(){ 39 public function editPost(){
40 $param=$this->request->param(); 40 $param=$this->request->param();
41 - dump($param); 41 + if (empty($param['free'])){
  42 + $param['free']=0;
  43 + }else{
  44 + $param['free']=1;
  45 + }
  46 + $cost=[
  47 + 'free' => $param['free'],
  48 + 'cost' => $param['cost'],
  49 + 'ceiling' => $param['ceiling'],
  50 + 'update_time' => time()
  51 + ];
  52 + $interval=[
  53 + 'start_time' => $param['start_time'],
  54 + 'end_time' =>$param['end_time'],
  55 + 'price' => $param['price'],
  56 + 'update_time' => time()
  57 + ];
  58 + try{
  59 + Db::startTrans();
  60 + Db::name('cost')->where('id',1)->update($cost);
  61 + Db::name('interval')->where('id',1)->update($interval);
  62 + }catch (\Exception $exception){
  63 + Db::rollback();
  64 + $this->error('保存失败');
  65 + }
  66 + Db::commit();
  67 + $this->success('保存成功');
42 } 68 }
43 } 69 }
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 <li class="active"><a>费用管理</a></li> 11 <li class="active"><a>费用管理</a></li>
12 </ul> 12 </ul>
13 <!--js-ajax-form margin-top-20--> 13 <!--js-ajax-form margin-top-20-->
14 - <form action="{:url('AdminCost/editPost')}" method="post" class="form-horizontal"> 14 + <form action="{:url('AdminCost/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
15 <div class="row"> 15 <div class="row">
16 <div class="col-md-3"> 16 <div class="col-md-3">
17 <table class="table table-bordered"> 17 <table class="table table-bordered">