|
@@ -27,14 +27,39 @@ use think\App;class CatPlat extends Base{
|
|
|
if($platform==false){
|
|
|
return error_show(1004,"平台信息不存在");
|
|
|
}
|
|
|
- $rate =isset($post['rate'])&&$post['rate']!=="" ? floor($post['rate']):"";
|
|
|
+ $rate =isset($post['rate'])&&$post['rate']!=="" ? floor($post['rate']):"";
|
|
|
if($rate==""){
|
|
|
return error_show(1004,"参数 rate 不能为空");
|
|
|
+ }
|
|
|
+ $origin_rate =isset($post['origin_rate'])&&$post['origin_rate']!=="" ? floor($post['origin_rate']):"";
|
|
|
+ if($origin_rate==""){
|
|
|
+ return error_show(1004,"参数 origin_rate 不能为空");
|
|
|
+ }
|
|
|
+ $charge_rate =isset($post['charge_rate'])&&$post['charge_rate']!=="" ? floor($post['charge_rate']):"";
|
|
|
+ if($charge_rate==""){
|
|
|
+ return error_show(1004,"参数 charge_rate 不能为空");
|
|
|
+ }
|
|
|
+ $financial_rate =isset($post['financial_rate'])&&$post['financial_rate']!=="" ? floor($post['financial_rate']):"";
|
|
|
+ if($financial_rate==""){
|
|
|
+ return error_show(1004,"参数 financial_rate 不能为空");
|
|
|
+ }
|
|
|
+ $low_rate =isset($post['low_rate'])&&$post['low_rate']!=="" ? floor($post['low_rate']):"";
|
|
|
+ if($low_rate==""){
|
|
|
+ return error_show(1004,"参数 low_rate 不能为空");
|
|
|
+ }
|
|
|
+ $fund_code =isset($post['fund_code'])&&$post['fund_code']!=="" ? $post['fund_code']:"";
|
|
|
+ if($fund_code==""){
|
|
|
+ return error_show(1004,"参数 fund_code 不能为空");
|
|
|
}
|
|
|
$data=[
|
|
|
"cat_id"=>$catid,
|
|
|
"platform_id"=>$plat_id,
|
|
|
"rate"=>$rate,
|
|
|
+ "origin_rate"=>$origin_rate,
|
|
|
+ "charge_rate"=>$charge_rate,
|
|
|
+ "financial_rate"=>$financial_rate,
|
|
|
+ "low_rate"=>$low_rate,
|
|
|
+ "fund_code"=>$fund_code,
|
|
|
"status"=>1,
|
|
|
"is_del"=>0,
|
|
|
"apply_id"=>$this->uid,
|
|
@@ -48,18 +73,22 @@ use think\App;class CatPlat extends Base{
|
|
|
|
|
|
public function edit(){
|
|
|
$post = $this->post;
|
|
|
- $catid =isset($post['cat_id'])&&$post['cat_id']!=="" ? intval($post['cat_id']):"";
|
|
|
+ $catid =isset($post['id'])&&$post['id']!=="" ? intval($post['id']):"";
|
|
|
if($catid==""){
|
|
|
- return error_show(1004,"参数 cat_id 不能为空");
|
|
|
+ return error_show(1004,"参数 id 不能为空");
|
|
|
}
|
|
|
- $catinfo = Db::name("cat")->where(["id"=>$catid,"is_del"=>0])->find();
|
|
|
+ $cat = Db::name("cat_plat")->where(["id"=>$catid,"is_del"=>0])->find();
|
|
|
+ if($cat==false){
|
|
|
+ return error_show(1004,"未找到平台分类信息");
|
|
|
+ }
|
|
|
+ $cat_id =isset($post['cat_id'])&&$post['cat_id']!=="" ? intval($post['cat_id']):"";
|
|
|
+ if($cat_id==""){
|
|
|
+ return error_show(1004,"参数 cat_id 不能为空");
|
|
|
+ }
|
|
|
+ $catinfo = Db::name("cat")->where(["id"=>$cat_id,"is_del"=>0])->find();
|
|
|
if($catinfo==false){
|
|
|
return error_show(1004,"分类信息不存在");
|
|
|
}
|
|
|
- $cat = Db::name("cat_plat")->where(["cat_id"=>$catid,"is_del"=>0])->find();
|
|
|
- if($cat==false){
|
|
|
- return error_show(1004,"分类未设置平台毛利率");
|
|
|
- }
|
|
|
|
|
|
$plat_id =isset($post['platform_id'])&&$post['platform_id']!=="" ? intval($post['platform_id']):"";
|
|
|
if($plat_id==""){
|
|
@@ -73,10 +102,39 @@ use think\App;class CatPlat extends Base{
|
|
|
if($rate==""){
|
|
|
return error_show(1004,"参数 rate 不能为空");
|
|
|
}
|
|
|
+ $ist = Db::name("cat_plat")->where([["cat_id","=",$cat_id],["platform_id","=",$plat_id],["id","<>",$catid],["is_del","=",0]])->find();
|
|
|
+ if($ist!=false){
|
|
|
+ return error_show(1004,"该平台下已存在此分类");
|
|
|
+ }
|
|
|
+ $origin_rate =isset($post['origin_rate'])&&$post['origin_rate']!=="" ? floor($post['origin_rate']):"";
|
|
|
+ if($origin_rate==""){
|
|
|
+ return error_show(1004,"参数 origin_rate 不能为空");
|
|
|
+ }
|
|
|
+ $charge_rate =isset($post['charge_rate'])&&$post['charge_rate']!=="" ? floor($post['charge_rate']):"";
|
|
|
+ if($charge_rate==""){
|
|
|
+ return error_show(1004,"参数 charge_rate 不能为空");
|
|
|
+ }
|
|
|
+ $financial_rate =isset($post['financial_rate'])&&$post['financial_rate']!=="" ? floor($post['financial_rate']):"";
|
|
|
+ if($financial_rate==""){
|
|
|
+ return error_show(1004,"参数 financial_rate 不能为空");
|
|
|
+ }
|
|
|
+ $low_rate =isset($post['low_rate'])&&$post['low_rate']!=="" ? floor($post['low_rate']):"";
|
|
|
+ if($low_rate==""){
|
|
|
+ return error_show(1004,"参数 low_rate 不能为空");
|
|
|
+ }
|
|
|
+ $fund_code =isset($post['fund_code'])&&$post['fund_code']!=="" ? $post['fund_code']:"";
|
|
|
+ if($fund_code==""){
|
|
|
+ return error_show(1004,"参数 fund_code 不能为空");
|
|
|
+ }
|
|
|
$data=[
|
|
|
"cat_id"=>$catid,
|
|
|
"platform_id"=>$plat_id,
|
|
|
"rate"=>$rate,
|
|
|
+ "origin_rate"=>$origin_rate,
|
|
|
+ "charge_rate"=>$charge_rate,
|
|
|
+ "financial_rate"=>$financial_rate,
|
|
|
+ "low_rate"=>$low_rate,
|
|
|
+ "fund_code"=>$fund_code,
|
|
|
"apply_id"=>$this->uid,
|
|
|
"apply_name"=>$this->uname,
|
|
|
"updatetime"=>date("Y-m-d H:i:s")
|
|
@@ -107,13 +165,17 @@ use think\App;class CatPlat extends Base{
|
|
|
$page = $total> $page ? $page: intval($total);
|
|
|
$list =Db::name("cat_plat")->where($condition)->page($page,$size)->select()->toArray();
|
|
|
$catKey=[];
|
|
|
+ $platKey=[];
|
|
|
if(!empty($list)){
|
|
|
- $catArr = array_column("cat_id",$list);
|
|
|
+ $catArr = array_column($list,"cat_id");
|
|
|
+ $platArr = array_column($list,"platform_id");
|
|
|
$catKey= Db::name("cat")->where(["id"=>$catArr,"is_del"=>0])->column("cat_name","id");
|
|
|
+ $platKey= Db::name("platform")->where(["id"=>$platArr,"is_del"=>0])->column("platform_name","id");
|
|
|
}
|
|
|
$data=[];
|
|
|
foreach ($list as $key=>$value){
|
|
|
$value['cat_name'] = isset($catKey[$value['cat_id']]) ?$catKey[$value['cat_id']]:"";
|
|
|
+ $value['platform_name'] = isset($platKey[$value['platform_id']]) ?$platKey[$value['platform_id']]:"";
|
|
|
$data[]=$value;
|
|
|
}
|
|
|
return app_show(0,"获取成功",["list"=>$data,"count"=>$count]);
|
|
@@ -121,17 +183,13 @@ use think\App;class CatPlat extends Base{
|
|
|
//启禁用分类平台信息
|
|
|
public function status(){
|
|
|
$post = $this->post;
|
|
|
- $catid =isset($post['cat_id'])&&$post['cat_id']!=="" ? intval($post['cat_id']):"";
|
|
|
+ $catid =isset($post['id'])&&$post['id']!=="" ? intval($post['id']):"";
|
|
|
if($catid==""){
|
|
|
- return error_show(1004,"参数 cat_id 不能为空");
|
|
|
- }
|
|
|
- $catinfo = Db::name("cat")->where(["id"=>$catid,"is_del"=>0])->find();
|
|
|
- if($catinfo==false){
|
|
|
- return error_show(1004,"分类信息不存在");
|
|
|
+ return error_show(1004,"参数 id 不能为空");
|
|
|
}
|
|
|
- $cat = Db::name("cat_plat")->where(["cat_id"=>$catid,"is_del"=>0])->find();
|
|
|
+ $cat = Db::name("cat_plat")->where(["id"=>$catid,"is_del"=>0])->find();
|
|
|
if($cat==false){
|
|
|
- return error_show(1004,"分类未设置平台毛利率");
|
|
|
+ return error_show(1004,"未找到平台分类信息");
|
|
|
}
|
|
|
$status = isset($post['status'])&&$post['status']!=="" ? intval($post['status']):"";
|
|
|
if($status===""){
|
|
@@ -148,17 +206,13 @@ use think\App;class CatPlat extends Base{
|
|
|
//删除分类平台信息
|
|
|
public function delete(){
|
|
|
$post = $this->post;
|
|
|
- $catid =isset($post['cat_id'])&&$post['cat_id']!=="" ? intval($post['cat_id']):"";
|
|
|
+ $catid =isset($post['id'])&&$post['id']!=="" ? intval($post['id']):"";
|
|
|
if($catid==""){
|
|
|
- return error_show(1004,"参数 cat_id 不能为空");
|
|
|
- }
|
|
|
- $catinfo = Db::name("cat")->where(["id"=>$catid,"is_del"=>0])->find();
|
|
|
- if($catinfo==false){
|
|
|
- return error_show(1004,"分类信息不存在");
|
|
|
+ return error_show(1004,"参数 id 不能为空");
|
|
|
}
|
|
|
- $cat = Db::name("cat_plat")->where(["cat_id"=>$catid,"is_del"=>0])->find();
|
|
|
+ $cat = Db::name("cat_plat")->where(["id"=>$catid,"is_del"=>0])->find();
|
|
|
if($cat==false){
|
|
|
- return error_show(1004,"分类未设置平台毛利率");
|
|
|
+ return error_show(1004,"未找到平台分类信息");
|
|
|
}
|
|
|
$cat['is_del']=1;
|
|
|
$cat['updatetime']=date("Y-m-d H:i:s");
|