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']); } // $userinfo = GetUserInfo($token); // if(!isset($userinfo['code'])|| $userinfo['code']!=0){ // return error_show(101,'未能获取用户信息'); // } // $check = checkRole($userinfo['data']['roleid'],38); // if($check){ // $condition .=" and creater = {$userinfo['data']['id']}"; // $companylist = Db // // } $companyNo = isset($post['companyNo'])&& $post['companyNo']!="" ? trim($post['companyNo']) :""; if($companyNo==""){ return error_show(1004,"参数companyNo 不能为空"); } $company = Db::name("company_info")->where("companyNo","=",$companyNo)->find(); if(empty($company)){ return error_show(1004,"未找到对应的数据"); } return app_show(0,"获取成功",$company); } /** * 显示创建资源表单页. * * @return \think\Response */ public function create() { $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 = makeNo("CMP"); $name = isset($post['company_name'])&&$post['company_name']!="" ? trim($post['company_name']) :""; if($name==""){ return error_show(1004,"参数company_name 不能为空"); } $title = isset($post['company_license'])&&$post['company_license']!="" ? trim($post['company_license']) :""; if($title==""){ return error_show(1004,"参数company_license 不能为空"); } $bank = isset($post['bank_name'])&&$post['bank_name']!="" ? trim($post['bank_name']) :""; if($bank==""){ return error_show(1004,"参数bank_name 不能为空"); } $bankNo = isset($post['bankNo'])&&$post['bankNo']!="" ? trim($post['bankNo']) :""; if($bankNo==""){ return error_show(1004,"参数bankNo 不能为空"); } $is_bank = Db::name("company_info")->where([["bankNo","=",$bankNo],["status","=",1]])->find(); if(!empty($is_bank)){ return error_show(1004,"银行卡号已存在!"); } $address = isset($post['company_address'])&&$post['company_address']!="" ? trim($post['company_address']) :""; if($address==""){ return error_show(1004,"参数company_address 不能为空"); } $contector = isset($post['contector'])&&$post['contector']!="" ? trim($post['contector']) :""; $mobile = isset($post['mobile'])&&$post['mobile']!="" ? trim($post['mobile']) :""; $img = isset($post['company_img'])&&$post['company_img']!="" ? trim($post['company_img']) :""; if($mobile!=""){ if(!checkTel($mobile)&&!checkMobile($mobile)){ return error_show(1004,"手机号/电话格式不正确"); } } $data = [ "companyNo"=>$companyNo, "company_name"=>$name, "company_address"=>$address, "company_license"=>$title, "bank_name"=>$bank, "bankNo"=>$bankNo, "contector"=>$contector, "mobile"=>$mobile, "company_img"=>$img, "status"=>1, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; $result = Db::name("company_info")->insert($data); return $result? app_show(0,"新建成功"):error_show(1005,"新建失败"); } /** * 保存新建的资源 * * @param \think\Request $request * @return \think\Response */ public function save() { $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 = makeNo("CMP"); $companyNo = isset($post['companyNo'])&&$post['companyNo']!="" ? trim($post['companyNo']) :""; if($companyNo==""){ return error_show(1004,"参数companyNo 不能为空"); } $name = isset($post['company_name'])&&$post['company_name']!="" ? trim($post['company_name']) :""; if($name==""){ return error_show(1004,"参数company_name 不能为空"); } $title = isset($post['company_license'])&&$post['company_license']!="" ? trim($post['company_license']) :""; if($title==""){ return error_show(1004,"参数company_license 不能为空"); } $bank = isset($post['bank_name'])&&$post['bank_name']!="" ? trim($post['bank_name']) :""; if($bank==""){ return error_show(1004,"参数bank_name 不能为空"); } $bankNo = isset($post['bankNo'])&&$post['bankNo']!="" ? trim($post['bankNo']) :""; if($bankNo==""){ return error_show(1004,"参数bankNo 不能为空"); } $address = isset($post['company_address'])&&$post['company_address']!="" ? trim($post['company_address']) :""; $contector = isset($post['contector'])&&$post['contector']!="" ? trim($post['contector']) :""; $mobile = isset($post['mobile'])&&$post['mobile']!="" ? trim($post['mobile']) :""; $img = isset($post['company_img'])&&$post['company_img']!="" ? trim($post['company_img']) :""; if($mobile!=""){ if(!checkTel($mobile)&&!checkMobile($mobile)){ return error_show(1004,"手机号/电话格式不正确"); } } $data = [ "company_name"=>$name, "company_address"=>$address, "company_license"=>$title, "bank_name"=>$bank, "bankNo"=>$bankNo, "contector"=>$contector, "mobile"=>$mobile, "company_img"=>$img, "updatetime"=>date("Y-m-d H:i:s") ]; $result = Db::name("company_info")->where("companyNo","=",$companyNo)->update($data); return $result? app_show(0,"更新成功"):error_show(1005,"更新失败"); } /** * 显示指定的资源 * * @param int $id * @return \think\Response */ public function status() { $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 = makeNo("CMP"); $companyNo = isset($post['companyNo'])&&$post['companyNo']!="" ? trim($post['companyNo']) :""; if($companyNo==""){ return error_show(1004,"参数companyNo 不能为空"); } $status = isset($post['status'])&&$post['status']!="" ? trim($post['status']) :""; if($status==""){ return error_show(1004,"参数status 不能为空"); } if(!in_array($status,[0,1])){ return error_show(1004,"参数status 无效"); } $message = $status==1 ?"启用" :"禁用"; $data = [ "status"=>$status, "updatetime"=>date("Y-m-d H:i:s") ]; $result = Db::name("company_info")->where("companyNo","=",$companyNo)->update($data); return $result? app_show(0,"{$message}成功"):error_show(1005,"{$message}失败"); } /** * 显示编辑资源表单页. * * @param int $id * @return \think\Response */ public function list() { $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']); } $condition = []; $page = isset($post['page'])&& $post['page']!="" ? intval($post['page']) :1; $size = isset($post['size'])&& $post['size']!="" ? intval($post['size']) :10; $count = Db::name("company_info")->where($condition)->count(); $total = ceil($count/$size)>1 ? ceil($count/$size) : 1; $page = $page>=$total?intval($total):$page; $list = Db::name("company_info")->where($condition)->page($page,$size)->select(); return app_show(0,"获取成功",['list'=>$list,"count"=>$count]); } /** * 保存更新的资源 * * @param \think\Request $request * @param int $id * @return \think\Response */ public function all() { $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']); } $condition = []; $list = Db::name("company_info")->where($condition)->field("companyNo,company_name,status,bank_name,bankNo, company_license")->select(); return app_show(0,"获取成功",$list); } /** * 删除指定资源 * * @param int $id * @return \think\Response */ public function relation() { $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']!="" ? trim($post['companyNo']) :""; if($companyNo==""){ return error_show(1004,"参数companyNo 不能为空"); } $company =Db::name("company_info")->where("companyNo","=",$companyNo)->find(); if(empty($company)){ return error_show(1004,"未找到数据"); } if($company['status']==0){ return error_show(1004,"企业数据已禁用"); } $uid = isset($post['uid'])&&$post['uid']!="" ? intval($post['uid']) :""; if($uid=="" || $uid==0){ return error_show(1004,"参数uid 不能为空"); } $isRe= Db::name("company_user")->where([["uid","=",$uid],['is_del',"=",1],["companyNo","=",$companyNo]])->find(); if(!empty($isRe)){ return error_show(1004,"企业信息已关联"); } $data =["uid"=>$uid,"companyNo"=>$companyNo,"addtime"=>date("Y-m-d H:i:s"),"updatetime"=>date("Y-m-d H:i:s")]; $result = Db::name("company_user")->insert($data); return $result?app_show(0,"企业信息关联成功"):error_show(1005,"企业信息关联失败"); } /** * @return \think\response\Json|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function DelRela(){ $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']); } $id= isset($post['id'])&&$post["id"]!="" ? intval($post['id']) :""; if($id==""){ return error_show(1004,"参数id 不能为空"); } $company =Db::name("company_user")->where("id","=",$id)->find(); if(empty($company)){ return error_show(1004,"未找到数据"); } if($company['is_del']==1){ return error_show(1004,"关联信息已解除"); } $data =["id"=>$id,"is_del"=>0,"updatetime"=>date("Y-m-d H:i:s")]; $result = Db::name("company_user")->save($data); return $result?app_show(0,"企业信息关联解除成功"):error_show(1005,"企业信息关联解除失败"); } public function RateList(){ // $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']); // } $list=Db::name("order_rate")->where("status","=",1)->select(); return app_show(0,"获取成功",$list); } }