request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $condition=[]; isset($post['company'])&&$post['company']!=""? $condition[]=['companyName|contactor',"like","%{$post['company']}%"] : ""; // isset($post['company'])&&$post['company']!=""? $condition[]=['companyName',"like","%{$post['company']}%"] : // ""; isset($post['contactor'])&&$post['contactor']!=""? $condition[]=['contactor',"like","%{$post['contactor']}%"] : ""; $page = isset($post['page'])&& $post['page']!="" ? intval($post['page']) :1; $size = isset($post['size'])&& $post['size']!="" ? intval($post['size']) :10; $count = Db::name("customer_info")->where($condition)->count(); $total = ceil($count/$size)>1 ? ceil($count/$size) : 1; $page = $page>=$total?intval($total):$page; if( isset($post['company'])&&$post['company']!=""){ $list = Db::name("customer_info")->where($condition)->page($page,$size)->field("companyNo,companyName,parent,area,contactor,depart,mobile,addtime,updatetime,LENGTH(companyName) as weight") ->order('weight asc')->select(); }else{ $list = Db::name("customer_info")->where($condition)->page($page,$size)->field("companyNo,companyName,parent,area,contactor,depart,mobile,addtime,updatetime") ->select(); } $data =[]; foreach ($list as $key=>$value){ $total_fee = Db::name("invoice_pool")->where([["status","=",5],["is_del","=",0],["type_check","=",2], ["trade_status","in",[1,2]],["wtrade_fee",">",0],["inv_in","=",$value['companyNo']]])->sum("wtrade_fee"); $value["trade_inv"]=$total_fee; $value["trade_inv_status"]=$total_fee>0 ? 1 :0; $data[]=$value; } return app_show(0,"获取成功",['list'=>$data,"count"=>$count]); } /** * 显示创建资源表单页. * * @return \think\Response */ public function info() { $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $companyNo= isset($post['companyNo'])&&$post['companyNo']!='' ? $post['companyNo'] : ""; if($companyNo==""){ return error_show(1003,"参数companyNo 不能为空"); } $info = Db::name("customer_info")->where("companyNo","=",$companyNo)->find(); if(empty($info)){ return error_show(1004,"未找到客户数据"); } $trade = Db::name("trade_pool")->where([["companyNo","=",$companyNo],["is_del","=",0]])->field("sum(order_fee) as aorder_fee,sum(worder_fee) as worder_fee,sum(inv_fee) as inv_fee,sum(winv_fee) as winv_fee") ->find(); $inv = Db::name("invoice_pool")->where([["inv_in","=",$companyNo],["is_del","=",0]])->field("sum(aorder_fee) as aorder_fee,sum(worder_fee) as worder_fee,sum(atrade_fee) as atrade_fee,sum(wtrade_fee) as wtrade_fee") ->find(); $order = Db::name("qrd")->where([["companyNo","=",$companyNo]])->field("sum(apay_fee) as apay_fee,sum(wpay_fee) as wpay_fee,sum(ainv_fee) as ainv_fee,sum(winv_fee) as winv_fee") ->find(); array_walk($order,function (&$value){ if(is_null($value)){ $value=0; } }); array_walk($inv,function (&$value){ if(is_null($value)){ $value=0; } }); array_walk($trade,function (&$value){ if(is_null($value)){ $value=0; } }); $balance = $order["apay_fee"] - $order["ainv_fee"]; $order["trade_inv"]=$balance >0 ?$balance :0 ; $order["inv_trade"]= $balance <0 ? $order["ainv_fee"]-$order["apay_fee"] :0; $data=["trade"=>$trade,"inv"=>$inv,"order"=>$order]; return app_show(0,"获取成功",$data); } /** * 保存新建的资源 * * @param \think\Request $request * @return \think\Response */ public function save(Request $request) { // } /** * 显示指定的资源 * * @param int $id * @return \think\Response */ public function read() { $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $companyNo= isset($post['companyNo'])&&$post['companyNo']!='' ? $post['companyNo'] : ""; if($companyNo==""){ return error_show(1003,"参数companyNo 不能为空"); } $info = Db::name("customer_info")->where("companyNo","=",$companyNo)->find(); if(empty($info)){ 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(); if(!empty($list)){ $info['invoice_title'] = $list['invoice_title']; $info['invoice_people'] = $list['invoice_people']; $info['invoice_addr'] = $list['invoice_addr']; $info['invoice_mobile'] = $list['invoice_mobile']; $info['invoice_code'] = $list['invoice_code']; $info['invoice_bank'] = $list['invoice_bank']; $info['invoice_bankNo'] = $list['invoice_bankNo']; } } return app_show(0,"获取成功",$info); } /** * 显示编辑资源表单页. * * @param int $id * @return \think\Response */ public function invoice() { $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $companyNo= isset($post['name'])&&$post['name']!='' ? $post['name'] : ""; if($companyNo==""){ return error_show(1003,"参数name 不能为空"); } $condition = [['invoice_title','like',"%{$companyNo}%"],['is_del',"=",0]]; $list = Db::name("customer_invoice")->where($condition)->page(1,100)->field("id,invoice_title,invoice_people,invoice_addr,invoice_mobile,invoice_code,invoice_bank,invoice_bankNo,LENGTH(invoice_title) as weight") ->order('weight asc')->select(); if(empty($list)){ return error_show(1004,"未找到企业财务信息数据"); } return app_show(0,"获取成功",$list); } /** * 保存更新的资源 * * @param \think\Request $request * @param int $id * @return \think\Response */ public function update(Request $request, $id) { // } /** * 删除指定资源 * * @param int $id * @return \think\Response */ public function delete($id) { // } }