|
@@ -14,7 +14,7 @@ class Title extends BaseController
|
|
|
parent::__construct($app);
|
|
|
$this->post= $this->request->post();
|
|
|
}
|
|
|
- public function creater(){
|
|
|
+ public function create(){
|
|
|
$companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !==""? trim($this->post['companyNo']):"";
|
|
|
if($companyNo==""){
|
|
|
return error_show(1002,"参数companyNo不能为空");
|
|
@@ -23,10 +23,10 @@ class Title extends BaseController
|
|
|
if($invoice_title==""){
|
|
|
return error_show(1002,"参数invoice_title不能为空");
|
|
|
}
|
|
|
- $invoice_people = isset($this->post['invoice_people']) && $this->post['invoice_people'] !== ""? trim($this->post['invoice_people']):"";
|
|
|
- if($invoice_people==""){
|
|
|
- return error_show(1002,"参数invoice_people不能为空");
|
|
|
- }
|
|
|
+// $invoice_people = isset($this->post['invoice_people']) && $this->post['invoice_people'] !== ""? trim($this->post['invoice_people']):"";
|
|
|
+// if($invoice_people==""){
|
|
|
+// return error_show(1002,"参数invoice_people不能为空");
|
|
|
+// }
|
|
|
$invoice_code = isset($this->post['invoice_code']) && $this->post['invoice_code'] !==""? trim($this->post['invoice_code']):"";
|
|
|
if($invoice_code==""){
|
|
|
return error_show(1002,"参数invoice_code不能为空");
|
|
@@ -51,7 +51,7 @@ class Title extends BaseController
|
|
|
$data =[
|
|
|
"companyNo"=>$companyNo,
|
|
|
"invoice_title"=>$invoice_title,
|
|
|
- "invoice_people"=>$invoice_people,
|
|
|
+ // "invoice_people"=>$invoice_people,
|
|
|
"invoice_code"=>$invoice_code,
|
|
|
"invoice_bank"=>$invoice_bank,
|
|
|
"invoice_bankNo"=>$invoice_bankNo,
|
|
@@ -72,7 +72,157 @@ class Title extends BaseController
|
|
|
public function list(){
|
|
|
$page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']) :"1";
|
|
|
$size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']) :"10";
|
|
|
- $where =[["is_del","=",0]];
|
|
|
-
|
|
|
+ $where =[["a.is_del","=",0]];
|
|
|
+ $invoice_title = isset($this->post['invoice_title']) && $this->post['invoice_title'] !=="" ? trim($this->post['invoice_title']):"";
|
|
|
+ if($invoice_title!=""){
|
|
|
+ $where[]=['a.invoice_title',"like","%$invoice_title%"];
|
|
|
+ }
|
|
|
+ $invoice_code = isset($this->post['invoice_code']) && $this->post['invoice_code'] !=="" ? trim($this->post['invoice_code']):"";
|
|
|
+ if($invoice_code!=""){
|
|
|
+ $where[]=['a.invoice_code',"like","%$invoice_code%"];
|
|
|
+ }
|
|
|
+ $invoice_mobile = isset($this->post['invoice_mobile']) && $this->post['invoice_mobile'] !=="" ? trim($this->post['invoice_mobile']):"";
|
|
|
+ if($invoice_mobile !=""){
|
|
|
+ $where[] =['a.invoice_code',"like","%$invoice_mobile%"];
|
|
|
+ }
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !=="" ? trim($this->post['status']):"";
|
|
|
+ if($status !=""){
|
|
|
+ $where[] =['a.status',"=",$status];
|
|
|
+ }
|
|
|
+ $companyName = isset($this->post['companyName']) && $this->post['companyName'] !=="" ? trim($this->post['companyName']):"";
|
|
|
+ if($companyName!=""){
|
|
|
+ $where[]=['b.companyName',"like","%$companyName%"];
|
|
|
+ }
|
|
|
+ $creater = isset($this->post['creater']) && $this->post['creater'] !=="" ? trim($this->post['creater']):"";
|
|
|
+ if($creater!=""){
|
|
|
+ $where[]=['b.creater',"like","%$creater%"];
|
|
|
+ }
|
|
|
+ $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
|
|
|
+ if($start!==""){
|
|
|
+ $where[]=['a.addtime',">=",date('Y-m-d H:i:s',strtotime($start))];
|
|
|
+ }
|
|
|
+ $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
|
|
|
+ if($end!==""){
|
|
|
+ $where[]=['a.addtime',"<",date('Y-m-d H:i:s',strtotime($end)+24*3600)];
|
|
|
+ }
|
|
|
+ $count = Db::name('customer_title')->alias("a")
|
|
|
+ ->join("business b","b.companyNo=a.companyNo","left")->where($where)->count();
|
|
|
+ $total = ceil($count / $size);
|
|
|
+ $page = $page >= $total ? $total : $page;
|
|
|
+ $list = Db::name('customer_title')->alias("a")
|
|
|
+ ->join("customer_info b","b.companyNo=a.companyNo","left")
|
|
|
+ ->where($where)->page($page,$size)->order("a.addtime desc")->field("a.*,b.companyName,b.creater")->select();
|
|
|
+ return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
|
|
|
+ }
|
|
|
+ public function edit(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
|
|
|
+ if($id ==""){
|
|
|
+ return error_show(1002,"参数id不能为空");
|
|
|
+ }
|
|
|
+ $info= Db::name('customer_title')->where(['id'=>$id,'is_del'=>0])->find();
|
|
|
+ if($info==""){
|
|
|
+ return error_show(1002,"未找到数据");
|
|
|
+ }
|
|
|
+// $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !==""? trim($this->post['companyNo']):"";
|
|
|
+// if($companyNo==""){
|
|
|
+// return error_show(1002,"参数companyNo不能为空");
|
|
|
+// }
|
|
|
+ $invoice_title = isset($this->post['invoice_title']) && $this->post['invoice_title'] !=="" ? trim($this->post['invoice_title']):"";
|
|
|
+ if($invoice_title==""){
|
|
|
+ return error_show(1002,"参数invoice_title不能为空");
|
|
|
+ }
|
|
|
+// $invoice_people = isset($this->post['invoice_people']) && $this->post['invoice_people'] !== ""? trim($this->post['invoice_people']):"";
|
|
|
+// if($invoice_people==""){
|
|
|
+// return error_show(1002,"参数invoice_people不能为空");
|
|
|
+// }
|
|
|
+ $invoice_code = isset($this->post['invoice_code']) && $this->post['invoice_code'] !==""? trim($this->post['invoice_code']):"";
|
|
|
+ if($invoice_code==""){
|
|
|
+ return error_show(1002,"参数invoice_code不能为空");
|
|
|
+ }
|
|
|
+ $invoice_bank = isset($this->post['invoice_bank']) && $this->post['invoice_bank'] !==""? trim($this->post['invoice_bank']):"";
|
|
|
+ if($invoice_bank==""){
|
|
|
+ return error_show(1002,"参数invoice_bank不能为空");
|
|
|
+ }
|
|
|
+ $invoice_bankNo = isset($this->post['invoice_bankNo']) && $this->post['invoice_bankNo'] !==""? trim($this->post['invoice_bankNo']):"";
|
|
|
+ if($invoice_bankNo==""){
|
|
|
+ return error_show(1002,"参数invoice_bankNo不能为空");
|
|
|
+ }
|
|
|
+ $invoice_addr = isset($this->post['invoice_addr']) && $this->post['invoice_addr'] !==""? trim($this->post['invoice_addr']):"";
|
|
|
+ if($invoice_addr==""){
|
|
|
+ return error_show(1002,"参数invoice_addr不能为空");
|
|
|
+ }
|
|
|
+ $invoice_mobile = isset($this->post['invoice_mobile']) && $this->post['invoice_mobile'] !==""? trim($this->post['invoice_mobile']):"";
|
|
|
+ if($invoice_mobile==""){
|
|
|
+ return error_show(1002,"参数invoice_mobile不能为空");
|
|
|
+ }
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !==""? trim($this->post['status']):"1";
|
|
|
+ $data =[
|
|
|
+ "id"=>$id,
|
|
|
+ "invoice_title"=>$invoice_title,
|
|
|
+ // "invoice_people"=>$invoice_people,
|
|
|
+ "invoice_code"=>$invoice_code,
|
|
|
+ "invoice_bank"=>$invoice_bank,
|
|
|
+ "invoice_bankNo"=>$invoice_bankNo,
|
|
|
+ "invoice_addr"=>$invoice_addr,
|
|
|
+ "invoice_mobile"=>$invoice_mobile,
|
|
|
+ "status"=>$status,
|
|
|
+ "is_del"=>0,
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $temp = Db::name('customer_title')->save($data);
|
|
|
+ if($temp){
|
|
|
+ return error_show(0,"更新成功");
|
|
|
+ }else{
|
|
|
+ return error_show(1002,"更新失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function info(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
|
|
|
+ if($id ==""){
|
|
|
+ return error_show(1002,"参数id不能为空");
|
|
|
+ }
|
|
|
+ $info= Db::name('customer_title')->where(['id'=>$id,'is_del'=>0])->find();
|
|
|
+ if($info==""){
|
|
|
+ return error_show(1002,"未找到数据");
|
|
|
+ }
|
|
|
+ return app_show(0,"获取成功",$info);
|
|
|
+ }
|
|
|
+ public function del(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
|
|
|
+ if($id ==""){
|
|
|
+ return error_show(1002,"参数id不能为空");
|
|
|
+ }
|
|
|
+ $info= Db::name('customer_title')->where(['id'=>$id,'is_del'=>0])->find();
|
|
|
+ if($info==""){
|
|
|
+ return error_show(1002,"未找到数据");
|
|
|
+ }
|
|
|
+ $end = Db::name('customer_title')->update(['id'=>$id,'is_del'=>1,'updatetime'=>date("Y-m-d H:i:s")]);
|
|
|
+ if($end){
|
|
|
+ return error_show(0,"删除成功");
|
|
|
+ }else{
|
|
|
+ return error_show(1002,"删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function status(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
|
|
|
+ if($id==""){
|
|
|
+ return error_show(1002,"参数id不能为空");
|
|
|
+ }
|
|
|
+ $info= Db::name('customer_title')->where(['id'=>$id,'is_del'=>0])->find();
|
|
|
+ if($info==""){
|
|
|
+ return error_show(1002,"未找到数据");
|
|
|
+ }
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"";
|
|
|
+ if($status===""){
|
|
|
+ return error_show(1002,"参数status不能为空");
|
|
|
+ }
|
|
|
+ if(!in_array($status,[0,1])){
|
|
|
+ return error_show(1002,"参数status无效");
|
|
|
+ }
|
|
|
+ $info['status']=$status;
|
|
|
+ $info['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $msg = $status==0?"启用":"禁用";
|
|
|
+ $temp = Db::name("customer_title")->save($info);
|
|
|
+ return $temp ? error_show(0,"{$msg}成功"):error_show(1002,"{$msg}失败");
|
|
|
}
|
|
|
}
|