|
@@ -19,9 +19,9 @@ class Business extends BaseController
|
|
|
if($company==""){
|
|
|
return error_show(1002,"参数company不能为空");
|
|
|
}
|
|
|
- $company_type = isset($this->post['company_type']) && $this->post['company_type'] !==""? trim($this->post['company_type']):"";
|
|
|
- if($company_type==""){
|
|
|
- return error_show(1002,"参数company_type不能为空");
|
|
|
+ $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==""){
|
|
@@ -78,29 +78,44 @@ class Business extends BaseController
|
|
|
$createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
|
|
|
$creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
|
|
|
$status = isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']):"0";
|
|
|
- $data =[
|
|
|
- "company"=>$company,
|
|
|
- "inv_code"=>$inv_code,
|
|
|
- "company_type"=>$company_type,
|
|
|
- "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,
|
|
|
- "creater"=>$creater,
|
|
|
- "createrid"=>$createrid,
|
|
|
- "inv_scope"=>$inv_scope,
|
|
|
- "license_img"=>$license_img,
|
|
|
- "status"=>$status,
|
|
|
- "is_del"=>0,
|
|
|
- "addtime"=>date("Y-m-d H:i:s"),
|
|
|
- "updatetime"=>date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $datainfo = Db::name('business')->insert($data);
|
|
|
- return $datainfo? error_show(0,"新建成功"):error_show(1004,"新建失败");
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+
|
|
|
+ $data =[
|
|
|
+ "company"=>$company,
|
|
|
+ "inv_code"=>$inv_code,
|
|
|
+ "type"=>$type,
|
|
|
+ "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,
|
|
|
+ "creater"=>$creater,
|
|
|
+ "createrid"=>$createrid,
|
|
|
+ "inv_scope"=>$inv_scope,
|
|
|
+ "license_img"=>$license_img,
|
|
|
+ "status"=>$status,
|
|
|
+ "is_del"=>0,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $datainfo = Db::name('business')->insert($data);
|
|
|
+ if($datainfo){
|
|
|
+ Db::commit();
|
|
|
+ return error_show(0,"新建成功");
|
|
|
+ }else{
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,"新建失败");
|
|
|
+ }
|
|
|
+ }catch (\Exception $e) {
|
|
|
+ }
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1005, $e->getMessage());
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
public function list(){
|
|
|
$page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']):"1";
|
|
@@ -129,8 +144,15 @@ class Business extends BaseController
|
|
|
$count = Db::name('business') ->where($where)->count();
|
|
|
$total = ceil($count / $size);
|
|
|
$page = $page >= $total ? $total : $page;
|
|
|
- $list = Db::name('business')->where($where)->page($page,$size)->field("company,status,creater,addtime")->order("addtime desc")->select();
|
|
|
- return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
|
|
|
+ $list = Db::name('business')->where($where)->page($page,$size)->field("company,status,creater,addtime,type")->order("addtime desc")->select();
|
|
|
+ $data=[];
|
|
|
+ foreach ($list as $value){
|
|
|
+ $info = Db::name('company_type')->where(['id'=>$value['type'],"is_del"=>0])->find();
|
|
|
+ $data['companytype']=isset($info['company_type'])?$info['company_type']:"";
|
|
|
+ $data[]=$value;
|
|
|
+ }
|
|
|
+
|
|
|
+ return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
|
|
|
}
|
|
|
public function edit(){
|
|
|
$id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
|
|
@@ -145,9 +167,9 @@ class Business extends BaseController
|
|
|
if($company==""){
|
|
|
return error_show(1002,"参数company不能为空");
|
|
|
}
|
|
|
- $company_type = isset($this->post['company_type']) && $this->post['company_type'] !==""? trim($this->post['company_type']):"";
|
|
|
- if($company_type==""){
|
|
|
- return error_show(1002,"参数company_type不能为空");
|
|
|
+ $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==""){
|
|
@@ -204,30 +226,45 @@ class Business extends BaseController
|
|
|
$createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
|
|
|
$creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
|
|
|
$status = isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']):"0";
|
|
|
- $data = [
|
|
|
- "id"=>$id,
|
|
|
- "company"=>$company,
|
|
|
- "inv_code"=>$inv_code,
|
|
|
- "company_type"=>$company_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,
|
|
|
- "addtime"=>date("Y-m-d H:i:s"),
|
|
|
- "updatetime"=>date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $info = Db::name('business')->save($data);
|
|
|
- return $info ? error_show(0,"更新成功") : error_show(1002,"更新失败");
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $data = [
|
|
|
+ "id"=>$id,
|
|
|
+ "company"=>$company,
|
|
|
+ "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,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $info = Db::name('business')->save($data);
|
|
|
+ if($info){
|
|
|
+ Db::commit();
|
|
|
+ return error_show(0,"更新成功");
|
|
|
+ }else{
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002,"更新失败");
|
|
|
+ }
|
|
|
+ }catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1005, $e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
public function del(){
|
|
|
$id = $this->post['id'] && $this->post['id'] !=="" ? intval($this->post['id']) :"";
|
|
@@ -275,6 +312,23 @@ class Business extends BaseController
|
|
|
if($tod==""){
|
|
|
return error_show(1002,"未找到数据");
|
|
|
}
|
|
|
+ $info = Db::name('company_type')->where(['id'=>$tod['type'],"is_del"=>0])->find();
|
|
|
+
|
|
|
+ $tod['companytype']=isset($info['company_type'])?$info['company_type']:"" ;
|
|
|
+
|
|
|
return app_show(0,"获取成功",$tod);
|
|
|
}
|
|
|
+ public function title(){
|
|
|
+ $where = [["is_del","=",0]];
|
|
|
+ $company_type = isset($this->post['company_type']) && $this->post['company_type'] !=="" ? intval($this->post['company_type']):"";
|
|
|
+ if($company_type!=""){
|
|
|
+ $where[]=['company_type',"like","%$company_type%"];
|
|
|
+ }
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"";
|
|
|
+ if($status!=""){
|
|
|
+ $where[]=['status',"=",$status];
|
|
|
+ }
|
|
|
+ $list = Db::name('company_type')->where($where)->select();
|
|
|
+ return app_show(0,"获取成功",$list);
|
|
|
+ }
|
|
|
}
|