Browse Source

修改业务公司时只允许修改4个开票相关字段

wufeng 2 years ago
parent
commit
a6ecad3a1f
1 changed files with 79 additions and 89 deletions
  1. 79 89
      app/admin/controller/Business.php

+ 79 - 89
app/admin/controller/Business.php

@@ -109,7 +109,7 @@ class Business extends Base
 
         $userCommon = new \app\admin\common\User();
         $rs = $userCommon->handle('bCreate', $data);
-        return json_show($rs['code'], $rs['message'],$rs['data']);
+        return json_show($rs['code'], $rs['message'], $rs['data']);
 //           $datainfo = Db::name('business')->insert($data);
 //           if($datainfo){
 //               Db::commit();
@@ -168,7 +168,7 @@ class Business extends Base
 
         $userCommon = new \app\admin\common\User();
         $rs = $userCommon->handle('bGetList', $param);
-        return json_show($rs['code'], $rs['message'],$rs['data']);
+        return json_show($rs['code'], $rs['message'], $rs['data']);
 
 //        $count = Db::name('business')
 //            ->alias('b')
@@ -195,64 +195,81 @@ class Business extends Base
 
     public function edit()
     {
-        $id = isset($this->post['id']) && $this->post['id'] !== "" ? intval($this->post['id']) : "";
-        if ($id == "") {
-            return error_show(1002, "参数id不能为空");
-        }
+
+        $param = $this->request->only(['id', 'inv_addr', 'inv_bank', 'inv_bankNo', 'mobile'], 'post', 'trim');
+
+        $val = Validate::rule([
+            'id' => 'require|number|gt:0',
+            'inv_addr' => 'require|max:255',
+            'inv_bank' => 'require|max:255',
+            'inv_bankNo' => 'require|max:255',
+            'mobile' => 'require|max:255',
+        ]);
+
+        if ($val->check($param) == false) return json_show(1005, $val->getError());
+
+        $userCommon = new \app\admin\common\User();
+        $rs = $userCommon->handle('bEdit', $param);
+        return json_show($rs['code'], $rs['message'], $rs['data']);
+
+//        $id = isset($this->post['id']) && $this->post['id'] !== "" ? intval($this->post['id']) : "";
+//        if ($id == "") {
+//            return error_show(1002, "参数id不能为空");
+//        }
 //       $idinfo = Db::name('business')->where(['id'=>$id,'is_del'=>0])->find();
 //       if($idinfo==""){
 //           return error_show(1003,"未找到数据");
 //       }
 //       $companyNo = makeNo("GS");
-        $company = isset($this->post['company']) && $this->post['company'] !== "" ? trim($this->post['company']) : "";
-        if ($company == "") {
-            return error_show(1002, "参数company不能为空");
-        }
-        $type = isset($this->post['type']) && $this->post['type'] !== "" ? trim($this->post['type']) : "";
-        if ($type == "") {
-            return error_show(1002, "参数type不能为空");
-        }
-        $inv_code = isset($this->post['inv_code']) && $this->post['inv_code'] !== "" ? trim($this->post['inv_code']) : "";
-        if ($inv_code == "") {
-            return error_show(1002, "参数inv_code不能为空");
-        }
-        $inv_legaler = isset($this->post['inv_legaler']) && $this->post['inv_legaler'] !== "" ? trim($this->post['inv_legaler']) : "";
-        if ($inv_legaler == "") {
-            return error_show(1002, "参数inv_legaler不能为空");
-        }
-        $inv_time = isset($this->post['inv_time']) && $this->post['inv_time'] !== "" ? $this->post['inv_time'] : "";
-        if ($inv_time == "") {
-            return error_show(1005, '参数inv_time不能为空');
-        }
-        $inv_addr = isset($this->post['inv_addr']) && $this->post['inv_addr'] !== "" ? trim($this->post['inv_addr']) : "";
-        if ($inv_addr == "") {
-            return error_show(1002, "参数inv_addr不能为空");
-        }
-        $inv_bank = isset($this->post['inv_bank']) && $this->post['inv_bank'] !== "" ? trim($this->post['inv_bank']) : "";
-        if ($inv_bank == "") {
-            return error_show(1002, "参数inv_bank不能为空");
-        }
-        $inv_bankNo = isset($this->post['inv_bankNo']) && $this->post['inv_bankNo'] !== "" ? trim($this->post['inv_bankNo']) : "";
-        if ($inv_bankNo == "") {
-            return error_show(1002, "参数inv_bankNo不能为空");
-        }
-        $contactor = isset($this->post['contactor']) && $this->post['contactor'] !== "" ? trim($this->post['contactor']) : "";
-        if ($contactor == "") {
-            return error_show(1002, "参数contactor不能为空");
-        }
-        $mobile = isset($this->post['mobile']) && $this->post['mobile'] !== "" ? trim($this->post['mobile']) : "";
-        if ($mobile == "") {
-            return error_show(1002, "参数mobile不能为空");
-        }
-        $addr = isset($this->post['addr']) && $this->post['addr'] !== "" ? trim($this->post['addr']) : "";
-        if ($addr == "") {
-            return error_show(1002, "参数addr不能为空");
-        }
-        $inv_scope = isset($this->post['inv_scope']) && $this->post['inv_scope'] !== "" ? trim($this->post['inv_scope']) : "";
-        if ($inv_scope == "") {
-            return error_show(1002, "参数inv_scope不能为空");
-        }
-        $license_img = isset($this->post['license_img']) && $this->post['license_img'] !== "" ? trim($this->post['license_img']) : "";
+//        $company = isset($this->post['company']) && $this->post['company'] !== "" ? trim($this->post['company']) : "";
+//        if ($company == "") {
+//            return error_show(1002, "参数company不能为空");
+//        }
+//        $type = isset($this->post['type']) && $this->post['type'] !== "" ? trim($this->post['type']) : "";
+//        if ($type == "") {
+//            return error_show(1002, "参数type不能为空");
+//        }
+//        $inv_code = isset($this->post['inv_code']) && $this->post['inv_code'] !== "" ? trim($this->post['inv_code']) : "";
+//        if ($inv_code == "") {
+//            return error_show(1002, "参数inv_code不能为空");
+//        }
+//        $inv_legaler = isset($this->post['inv_legaler']) && $this->post['inv_legaler'] !== "" ? trim($this->post['inv_legaler']) : "";
+//        if ($inv_legaler == "") {
+//            return error_show(1002, "参数inv_legaler不能为空");
+//        }
+//        $inv_time = isset($this->post['inv_time']) && $this->post['inv_time'] !== "" ? $this->post['inv_time'] : "";
+//        if ($inv_time == "") {
+//            return error_show(1005, '参数inv_time不能为空');
+//        }
+//        $inv_addr = isset($this->post['inv_addr']) && $this->post['inv_addr'] !== "" ? trim($this->post['inv_addr']) : "";
+//        if ($inv_addr == "") {
+//            return error_show(1002, "参数inv_addr不能为空");
+//        }
+//        $inv_bank = isset($this->post['inv_bank']) && $this->post['inv_bank'] !== "" ? trim($this->post['inv_bank']) : "";
+//        if ($inv_bank == "") {
+//            return error_show(1002, "参数inv_bank不能为空");
+//        }
+//        $inv_bankNo = isset($this->post['inv_bankNo']) && $this->post['inv_bankNo'] !== "" ? trim($this->post['inv_bankNo']) : "";
+//        if ($inv_bankNo == "") {
+//            return error_show(1002, "参数inv_bankNo不能为空");
+//        }
+//        $contactor = isset($this->post['contactor']) && $this->post['contactor'] !== "" ? trim($this->post['contactor']) : "";
+//        if ($contactor == "") {
+//            return error_show(1002, "参数contactor不能为空");
+//        }
+//        $mobile = isset($this->post['mobile']) && $this->post['mobile'] !== "" ? trim($this->post['mobile']) : "";
+//        if ($mobile == "") {
+//            return error_show(1002, "参数mobile不能为空");
+//        }
+//        $addr = isset($this->post['addr']) && $this->post['addr'] !== "" ? trim($this->post['addr']) : "";
+//        if ($addr == "") {
+//            return error_show(1002, "参数addr不能为空");
+//        }
+//        $inv_scope = isset($this->post['inv_scope']) && $this->post['inv_scope'] !== "" ? trim($this->post['inv_scope']) : "";
+//        if ($inv_scope == "") {
+//            return error_show(1002, "参数inv_scope不能为空");
+//        }
+//        $license_img = isset($this->post['license_img']) && $this->post['license_img'] !== "" ? trim($this->post['license_img']) : "";
 //        if($license_img==""){
 //            return error_show(1002,"参数license_img不能为空");
 //        }
@@ -264,38 +281,11 @@ class Business extends Base
 //        if(empty($user)||$user['code']!=0){
 //            return error_show(102,"创建人数据不存在");
 //        }
-        $createrid = $this->uid;//isset($user["data"]['id']) ?  $user["data"]['id'] : "";
-        $creater = $this->uname;//isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
-        $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "0";
+//        $createrid = $this->uid;//isset($user["data"]['id']) ?  $user["data"]['id'] : "";
+//        $creater = $this->uname;//isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
+//        $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "0";
 //        Db::startTrans();
 //        try{
-        $data = [
-            "id" => $id,
-            "company" => $company,
-            // "companyNo"=>$companyNo,
-            "inv_code" => $inv_code,
-            "type" => $type,
-            "creater" => $creater,
-            "createrid" => $createrid,
-            "inv_legaler" => $inv_legaler,
-            "inv_time" => $inv_time,
-            "inv_addr" => $inv_addr,
-            "inv_bank" => $inv_bank,
-            "inv_bankNo" => $inv_bankNo,
-            "contactor" => $contactor,
-            "mobile" => $mobile,
-            "addr" => $addr,
-            "inv_scope" => $inv_scope,
-            "license_img" => $license_img,
-            "status" => $status,
-            "is_del" => 0,
-            "updatetime" => date("Y-m-d H:i:s")
-        ];
-
-        $userCommon = new \app\admin\common\User();
-        $rs = $userCommon->handle('bEdit', $data);
-        return json_show($rs['code'], $rs['message'],$rs['data']);
-
 //            $info = Db::name('business')->save($data);
 //            if($info){
 //                Db::commit();
@@ -337,7 +327,7 @@ class Business extends Base
             'updater' => $this->uname,
             'updaterid' => $this->uid,
         ]);
-        return json_show($rs['code'], $rs['message'],$rs['data']);
+        return json_show($rs['code'], $rs['message'], $rs['data']);
     }
 
     public function status()
@@ -380,7 +370,7 @@ class Business extends Base
             'updater' => $this->uname,
             'updaterid' => $this->uid,
         ]);
-        return json_show($rs['code'], $rs['message'],$rs['data']);
+        return json_show($rs['code'], $rs['message'], $rs['data']);
     }
 
     public function info()
@@ -391,7 +381,7 @@ class Business extends Base
 
         $userCommon = new \app\admin\common\User();
         $rs = $userCommon->handle('bInfo', $param);
-        return json_show($rs['code'], $rs['message'],$rs['data']);
+        return json_show($rs['code'], $rs['message'], $rs['data']);
 
 //        if($companyNo==""){
 //            return error_show(1004,"参数companyNo不能为空");
@@ -424,6 +414,6 @@ class Business extends Base
 
         $userCommon = new \app\admin\common\User();
         $rs = $userCommon->handle('bTitle', $param);
-        return json_show($rs['code'], $rs['message'],$rs['data']);
+        return json_show($rs['code'], $rs['message'], $rs['data']);
     }
 }