|
@@ -116,8 +116,8 @@ class Customer extends BaseController
|
|
|
return error_show(1004,"未找到客户数据");
|
|
|
}
|
|
|
if($info['invoice_code']!=""){
|
|
|
- $list = Db::name("customer_invoice")->where("invoice_code","=",$info['invoice_code'])->field("id,invoice_title,invoice_people,invoice_addr,invoice_mobile,invoice_code,invoice_bank,invoice_bankNo")
|
|
|
- ->find();
|
|
|
+ $list = Db::name("customer_invoice")->where([["invoice_code","=",$info['invoice_code']],["is_del","=",0]])
|
|
|
+ ->field("id,invoice_title,invoice_people,invoice_addr,invoice_mobile,invoice_code,invoice_bank,invoice_bankNo")->find();
|
|
|
if(!empty($list)){
|
|
|
$info['invoice_title'] = $list['invoice_title'];
|
|
|
$info['invoice_people'] = $list['invoice_people'];
|
|
@@ -152,27 +152,147 @@ class Customer extends BaseController
|
|
|
}
|
|
|
return app_show(0,"获取成功",$list);
|
|
|
}
|
|
|
+ //客户开票信息列表翻译
|
|
|
+ public function invoicelist(){
|
|
|
+ $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']):15 ;
|
|
|
+ $where =[['is_del',"=",0]];
|
|
|
+ $title = isset($this->post['invoice_title'])&&$this->post['invoice_title']!=''?trim($this->post['invoice_title']) :"";
|
|
|
+ if($title!=''){
|
|
|
+ $where[]=["invoice_title","like","%$title"];
|
|
|
+ }
|
|
|
+ $code = isset($this->post['invoice_code'])&&$this->post['invoice_code']!=''?trim($this->post['invoice_code']):"";
|
|
|
+ if($code!=''){
|
|
|
+ $where[]=["invoice_code","like","%$code"];
|
|
|
+ }
|
|
|
+ $count=Db::name("customer_invoice")->where($where)->count();
|
|
|
+ $total =ceil($count/$size);
|
|
|
+ $page= $page>=$total ? intval($total) :$page;
|
|
|
+ $list = Db::name("customer_invoice")->where($where)->page($page,$size)->order("id desc")->select();
|
|
|
+ return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 保存更新的资源
|
|
|
- *
|
|
|
- * @param \think\Request $request
|
|
|
- * @param int $id
|
|
|
- * @return \think\Response
|
|
|
- */
|
|
|
- public function update(Request $request, $id)
|
|
|
- {
|
|
|
- //
|
|
|
- }
|
|
|
+ //客户开票信息列表翻译
|
|
|
+ public function invoiceAdd(){
|
|
|
|
|
|
- /**
|
|
|
- * 删除指定资源
|
|
|
- *
|
|
|
- * @param int $id
|
|
|
- * @return \think\Response
|
|
|
- */
|
|
|
- public function delete($id)
|
|
|
- {
|
|
|
- //
|
|
|
- }
|
|
|
+ $title = isset($this->post['invoice_title'])&&$this->post['invoice_title']!=''?trim($this->post['invoice_title']) :"";
|
|
|
+ if($title==''){
|
|
|
+ return error_show(1004,"参数 invoice_title 不能为空");
|
|
|
+ }
|
|
|
+ $code = isset($this->post['invoice_code'])&&$this->post['invoice_code']!=''?trim($this->post['invoice_code']):"";
|
|
|
+ if($code==''){
|
|
|
+ return error_show(1004,"参数 invoice_code 不能为空");
|
|
|
+ }
|
|
|
+ $people = isset($this->post['invoice_people'])&&$this->post['invoice_people']!=''?trim($this->post['invoice_people']):"";
|
|
|
+ if($people==''){
|
|
|
+ return error_show(1004,"参数 invoice_people 不能为空");
|
|
|
+ }
|
|
|
+ $invoice_addr = isset($this->post['invoice_addr'])&&$this->post['invoice_addr']!=''?trim($this->post['invoice_addr']):"";
|
|
|
+ if($invoice_addr==''){
|
|
|
+ return error_show(1004,"参数 invoice_addr 不能为空");
|
|
|
+ }
|
|
|
+ $invoice_mobile = isset($this->post['invoice_mobile'])&&$this->post['invoice_mobile']!=''?trim($this->post['invoice_mobile']):"";
|
|
|
+ if($invoice_mobile==''){
|
|
|
+ return error_show(1004,"参数 invoice_mobile 不能为空");
|
|
|
+ }
|
|
|
+ $invoice_bank = isset($this->post['invoice_bank'])&&$this->post['invoice_bank']!=''?trim($this->post['invoice_bank']):"";
|
|
|
+ if($invoice_bank==''){
|
|
|
+ return error_show(1004,"参数 invoice_bank 不能为空");
|
|
|
+ }
|
|
|
+ $invoice_bankNo = isset($this->post['invoice_bankNo'])&&$this->post['invoice_bankNo']!=''?trim($this->post['invoice_bankNo']):"";
|
|
|
+ if($invoice_bankNo==''){
|
|
|
+ return error_show(1004,"参数 invoice_bankNo 不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ $isTr =Db::name("customer_invoice")->where(["invoice_code"=>$code,"is_del"=>0])->find();
|
|
|
+ if($isTr){
|
|
|
+ return error_show(1004,"开票信息已存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ $data=[
|
|
|
+ "invoice_title"=>$title,
|
|
|
+ "invoice_code"=>$code,
|
|
|
+ "invoice_people"=>$people,
|
|
|
+ "invoice_addr"=>$invoice_addr,
|
|
|
+ "invoice_mobile"=>$invoice_mobile,
|
|
|
+ "invoice_bank"=>$invoice_bank,
|
|
|
+ "invoice_bankNo"=>$invoice_bankNo,
|
|
|
+ "apply_id"=>$this->uid,
|
|
|
+ "apply_name"=>$this->uname,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $ind =Db::name("customer_invoice")->insert($data);
|
|
|
+ if($ind) return app_show(0,"新建成功"); else return error_show(1004,"新建失败");
|
|
|
+ }
|
|
|
+ //编辑开票信息
|
|
|
+ public function invoiceSave(){
|
|
|
+ $id =isset($this->post['id'])&&$this->post['id']!='' ? intval($this->post['id']):"";
|
|
|
+ if($id==''){
|
|
|
+ return error_show(1004,"参数 id 不能为空");
|
|
|
+ }
|
|
|
+ $isTr =Db::name("customer_invoice")->where(["id"=>$id,"is_del"=>0])->find();
|
|
|
+ if($isTr==false){
|
|
|
+ return error_show(1004,"开票信息不存在");
|
|
|
+ }
|
|
|
+ $title = isset($this->post['invoice_title'])&&$this->post['invoice_title']!=''?trim($this->post['invoice_title']) :"";
|
|
|
+ if($title==''){
|
|
|
+ return error_show(1004,"参数 invoice_title 不能为空");
|
|
|
+ }
|
|
|
+ $code = isset($this->post['invoice_code'])&&$this->post['invoice_code']!=''?trim($this->post['invoice_code']):"";
|
|
|
+ if($code==''){
|
|
|
+ return error_show(1004,"参数 invoice_code 不能为空");
|
|
|
+ }
|
|
|
+ $isTrs =Db::name("customer_invoice")->where([["invoice_code","=",$code,"is_del","=",0],["id","<>",$id]])
|
|
|
+ ->find();
|
|
|
+ if($isTrs){
|
|
|
+ return error_show(1004,"开票信息已存在");
|
|
|
+ }
|
|
|
+ $people = isset($this->post['invoice_people'])&&$this->post['invoice_people']!=''?trim($this->post['invoice_people']):"";
|
|
|
+ if($people==''){
|
|
|
+ return error_show(1004,"参数 invoice_people 不能为空");
|
|
|
+ }
|
|
|
+ $invoice_addr = isset($this->post['invoice_addr'])&&$this->post['invoice_addr']!=''?trim($this->post['invoice_addr']):"";
|
|
|
+ if($invoice_addr==''){
|
|
|
+ return error_show(1004,"参数 invoice_addr 不能为空");
|
|
|
+ }
|
|
|
+ $invoice_mobile = isset($this->post['invoice_mobile'])&&$this->post['invoice_mobile']!=''?trim($this->post['invoice_mobile']):"";
|
|
|
+ if($invoice_mobile==''){
|
|
|
+ return error_show(1004,"参数 invoice_mobile 不能为空");
|
|
|
+ }
|
|
|
+ $invoice_bank = isset($this->post['invoice_bank'])&&$this->post['invoice_bank']!=''?trim($this->post['invoice_bank']):"";
|
|
|
+ if($invoice_bank==''){
|
|
|
+ return error_show(1004,"参数 invoice_bank 不能为空");
|
|
|
+ }
|
|
|
+ $invoice_bankNo = isset($this->post['invoice_bankNo'])&&$this->post['invoice_bankNo']!=''?trim($this->post['invoice_bankNo']):"";
|
|
|
+ if($invoice_bankNo==''){
|
|
|
+ return error_show(1004,"参数 invoice_bankNo 不能为空");
|
|
|
+ }
|
|
|
+ $data=[
|
|
|
+ "invoice_title"=>$title,
|
|
|
+ "invoice_code"=>$code,
|
|
|
+ "invoice_people"=>$people,
|
|
|
+ "invoice_addr"=>$invoice_addr,
|
|
|
+ "invoice_mobile"=>$invoice_mobile,
|
|
|
+ "invoice_bank"=>$invoice_bank,
|
|
|
+ "invoice_bankNo"=>$invoice_bankNo,
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $ind =Db::name("customer_invoice")->where($isTr)->update($data);
|
|
|
+ if($ind) return app_show(0,"更新成功"); else return error_show(1004,"更新失败");
|
|
|
+ }
|
|
|
+ //开票信息删除
|
|
|
+ public function invoiceDel(){
|
|
|
+ $id =isset($this->post['id'])&&$this->post['id']!='' ? intval($this->post['id']):"";
|
|
|
+ if($id==''){
|
|
|
+ return error_show(1004,"参数 id 不能为空");
|
|
|
+ }
|
|
|
+ $isTr =Db::name("customer_invoice")->where(["id"=>$id,"is_del"=>0])->find();
|
|
|
+ if($isTr==false){
|
|
|
+ return error_show(1004,"开票信息不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ $ind =Db::name("customer_invoice")->where($isTr)->update(["is_del"=>1,"updatetime"=>date("Y-m-d H:i:s")]);
|
|
|
+ if($ind) return app_show(0,"删除成功"); else return error_show(1004,"删除失败");
|
|
|
+ }
|
|
|
}
|