|
@@ -4,6 +4,7 @@ namespace app\admin\controller;
|
|
|
|
|
|
use app\BaseController;
|
|
|
use think\App;
|
|
|
+use think\facade\Db;
|
|
|
|
|
|
class Business extends BaseController
|
|
|
{
|
|
@@ -30,6 +31,239 @@ class Business extends BaseController
|
|
|
if($inv_legaler==""){
|
|
|
return error_show(1002,"参数inv_legaler不能为空");
|
|
|
}
|
|
|
-
|
|
|
+ $inv_time = isset($this->post['inv_time'])&&$this->post['inv_time']!== "" ? $this->post['inv_time']:date("Y-m-d H:i:s");
|
|
|
+ if($inv_time==""){
|
|
|
+ return error_show(1005,'参数inv_time不能为空');
|
|
|
+ }
|
|
|
+ $inv_addr = isset($this->post['inv_addr']) && $this->post['inv_addr'] !==""? trim($this->post['inv_addr']):"";
|
|
|
+ if($inv_addr==""){
|
|
|
+ return error_show(1002,"参数inv_addr不能为空");
|
|
|
+ }
|
|
|
+ $inv_bank = isset($this->post['inv_bank']) && $this->post['inv_bank'] !==""? trim($this->post['inv_bank']):"";
|
|
|
+ if($inv_bank==""){
|
|
|
+ return error_show(1002,"参数inv_bank不能为空");
|
|
|
+ }
|
|
|
+ $inv_bankNo = isset($this->post['inv_bankNo']) && $this->post['inv_bankNo'] !==""? trim($this->post['inv_bankNo']):"";
|
|
|
+ if($inv_bankNo==""){
|
|
|
+ return error_show(1002,"参数inv_bankNo不能为空");
|
|
|
+ }
|
|
|
+ $contactor = isset($this->post['contactor']) && $this->post['contactor'] !==""? trim($this->post['contactor']):"";
|
|
|
+ if($contactor==""){
|
|
|
+ return error_show(1002,"参数contactor不能为空");
|
|
|
+ }
|
|
|
+ $mobile = isset($this->post['mobile']) && $this->post['mobile'] !==""? trim($this->post['mobile']):"";
|
|
|
+ if($mobile==""){
|
|
|
+ return error_show(1002,"参数mobile不能为空");
|
|
|
+ }
|
|
|
+ $addr = isset($this->post['addr']) && $this->post['addr'] !==""? trim($this->post['addr']):"";
|
|
|
+ if($addr==""){
|
|
|
+ return error_show(1002,"参数addr不能为空");
|
|
|
+ }
|
|
|
+ $inv_scope = isset($this->post['inv_scope']) && $this->post['inv_scope'] !==""? trim($this->post['inv_scope']):"";
|
|
|
+ if($inv_scope==""){
|
|
|
+ return error_show(1002,"参数inv_scope不能为空");
|
|
|
+ }
|
|
|
+ $license_img = isset($this->post['license_img']) && $this->post['license_img'] !==""? trim($this->post['license_img']):"";
|
|
|
+ if($license_img==""){
|
|
|
+ return error_show(1002,"参数license_img不能为空");
|
|
|
+ }
|
|
|
+ $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
|
|
|
+ if($token==''){
|
|
|
+ return error_show(1005,"参数token不能为空");
|
|
|
+ }
|
|
|
+ $user =GetUserInfo($token);
|
|
|
+ if(empty($user)||$user['code']!=0){
|
|
|
+ return error_show(1002,"创建人数据不存在");
|
|
|
+ }
|
|
|
+ $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"=>date("Y-m-d H:i:s"),
|
|
|
+ "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,"新建失败");
|
|
|
+ }
|
|
|
+ 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]];
|
|
|
+ $company = isset($this->post['company']) && $this->post['company'] !=="" ? trim($this->post['company']):"";
|
|
|
+ if($company!=""){
|
|
|
+ $where[]=['company',"like","%$company%"];
|
|
|
+ }
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"";
|
|
|
+ if($status!=""){
|
|
|
+ $where[]=['status',"=",$status];
|
|
|
+ }
|
|
|
+ $creater = isset($this->post['creater']) && $this->post['creater'] !=="" ? intval($this->post['creater']):"";
|
|
|
+ if($creater!=""){
|
|
|
+ $where[]=['creater',"like","%$creater%"];
|
|
|
+ }
|
|
|
+ $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
|
|
|
+ if($start!==""){
|
|
|
+ $where[]=['addtime',">=",date('Y-m-d H:i:s',strtotime($start))];
|
|
|
+ }
|
|
|
+ $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
|
|
|
+ if($end!==""){
|
|
|
+ $where[]=['addtime',"<",date('Y-m-d H:i:s',strtotime($end)+24*3600)];
|
|
|
+ }
|
|
|
+ $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]);
|
|
|
+ }
|
|
|
+ public function edit(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
|
|
|
+ if($id==""){
|
|
|
+ return error_show(1002,"参数id不能为空");
|
|
|
+ }
|
|
|
+ $idinfo = Db::name('business')->where(['id'=>$id,'is_del'=>0])->find();
|
|
|
+ if($idinfo==""){
|
|
|
+ return error_show(1003,"未找到数据");
|
|
|
+ }
|
|
|
+ $company = isset($this->post['company']) && $this->post['company'] !==""? trim($this->post['company']):"";
|
|
|
+ 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不能为空");
|
|
|
+ }
|
|
|
+ $inv_code = isset($this->post['inv_code']) && $this->post['inv_code'] !==""? trim($this->post['inv_code']):"";
|
|
|
+ if($inv_code==""){
|
|
|
+ return error_show(1002,"参数inv_code不能为空");
|
|
|
+ }
|
|
|
+ $inv_legaler = isset($this->post['inv_legaler']) && $this->post['inv_legaler'] !==""? trim($this->post['inv_legaler']):"";
|
|
|
+ if($inv_legaler==""){
|
|
|
+ return error_show(1002,"参数inv_legaler不能为空");
|
|
|
+ }
|
|
|
+ $inv_time = isset($this->post['inv_time'])&&$this->post['inv_time']!== "" ? $this->post['inv_time']:date("Y-m-d H:i:s");
|
|
|
+ if($inv_time==""){
|
|
|
+ return error_show(1005,'参数inv_time不能为空');
|
|
|
+ }
|
|
|
+ $inv_addr = isset($this->post['inv_addr']) && $this->post['inv_addr'] !==""? trim($this->post['inv_addr']):"";
|
|
|
+ if($inv_addr==""){
|
|
|
+ return error_show(1002,"参数inv_addr不能为空");
|
|
|
+ }
|
|
|
+ $inv_bank = isset($this->post['inv_bank']) && $this->post['inv_bank'] !==""? trim($this->post['inv_bank']):"";
|
|
|
+ if($inv_bank==""){
|
|
|
+ return error_show(1002,"参数inv_bank不能为空");
|
|
|
+ }
|
|
|
+ $inv_bankNo = isset($this->post['inv_bankNo']) && $this->post['inv_bankNo'] !==""? trim($this->post['inv_bankNo']):"";
|
|
|
+ if($inv_bankNo==""){
|
|
|
+ return error_show(1002,"参数inv_bankNo不能为空");
|
|
|
+ }
|
|
|
+ $contactor = isset($this->post['contactor']) && $this->post['contactor'] !==""? trim($this->post['contactor']):"";
|
|
|
+ if($contactor==""){
|
|
|
+ return error_show(1002,"参数contactor不能为空");
|
|
|
+ }
|
|
|
+ $mobile = isset($this->post['mobile']) && $this->post['mobile'] !==""? trim($this->post['mobile']):"";
|
|
|
+ if($mobile==""){
|
|
|
+ return error_show(1002,"参数mobile不能为空");
|
|
|
+ }
|
|
|
+ $addr = isset($this->post['addr']) && $this->post['addr'] !==""? trim($this->post['addr']):"";
|
|
|
+ if($addr==""){
|
|
|
+ return error_show(1002,"参数addr不能为空");
|
|
|
+ }
|
|
|
+ $inv_scope = isset($this->post['inv_scope']) && $this->post['inv_scope'] !==""? trim($this->post['inv_scope']):"";
|
|
|
+ if($inv_scope==""){
|
|
|
+ return error_show(1002,"参数inv_scope不能为空");
|
|
|
+ }
|
|
|
+ $license_img = isset($this->post['license_img']) && $this->post['license_img'] !==""? trim($this->post['license_img']):"";
|
|
|
+ if($license_img==""){
|
|
|
+ return error_show(1002,"参数license_img不能为空");
|
|
|
+ }
|
|
|
+ $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
|
|
|
+ if($token==''){
|
|
|
+ return error_show(1005,"参数token不能为空");
|
|
|
+ }
|
|
|
+ $user =GetUserInfo($token);
|
|
|
+ if(empty($user)||$user['code']!=0){
|
|
|
+ return error_show(1002,"创建人数据不存在");
|
|
|
+ }
|
|
|
+ $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"=>date("Y-m-d H:i:s"),
|
|
|
+ "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,"更新失败");
|
|
|
+ }
|
|
|
+ public function del(){
|
|
|
+ $id = $this->post['id'] && $this->post['id'] !=="" ? intval($this->post['id']) :"";
|
|
|
+ if($id===""){
|
|
|
+ return error_show(1004,"参数id不能为空");
|
|
|
+ }
|
|
|
+ $str= Db::name('business')->where(['id'=>$id,'is_del'=>0])->find();
|
|
|
+ if(empty($str)){
|
|
|
+ return error_show(1002,"未找到数据");
|
|
|
+ }
|
|
|
+ $end = Db::name('business')->update(['id'=>$id,'is_del'=>1]);
|
|
|
+ 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("business")->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;
|
|
|
+ $msg = $status==0?"启用":"禁用";
|
|
|
+ $update = Db::name("business")->save($info);
|
|
|
+ return $update? error_show(0,"{$msg}成功"):error_show(1004,"{$msg}失败");
|
|
|
}
|
|
|
}
|