|
@@ -15,7 +15,6 @@ class Cat extends Base
|
|
public function __construct(App $app)
|
|
public function __construct(App $app)
|
|
{
|
|
{
|
|
parent::__construct($app);
|
|
parent::__construct($app);
|
|
-// $this->post=$this->request->post();
|
|
|
|
}
|
|
}
|
|
public function list(){
|
|
public function list(){
|
|
$where=[["is_del","=",0]];
|
|
$where=[["is_del","=",0]];
|
|
@@ -177,6 +176,7 @@ public function title(){
|
|
}
|
|
}
|
|
return app_show(0, "获取成功", ['list' => $var, 'count' => $count]);
|
|
return app_show(0, "获取成功", ['list' => $var, 'count' => $count]);
|
|
}
|
|
}
|
|
|
|
+
|
|
public function create()
|
|
public function create()
|
|
{
|
|
{
|
|
$cat_name = isset($this->post['cat_name']) && $this->post['cat_name'] !== "" ? trim($this->post['cat_name']) : "";
|
|
$cat_name = isset($this->post['cat_name']) && $this->post['cat_name'] !== "" ? trim($this->post['cat_name']) : "";
|
|
@@ -226,10 +226,6 @@ public function create()
|
|
}
|
|
}
|
|
$createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
|
|
$createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
|
|
$creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
|
|
$creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
|
|
-// $rate = isset($this->post['rate']) && $this->post['rate'] !== "" ? intval($this->post['rate']) : "";
|
|
|
|
-// $order_rate = isset($this->post['order_rate']) && $this->post['order_rate'] !== "" ? intval($this->post['order_rate']) : "";
|
|
|
|
-// $sale_rate = isset($this->post['sale_rate ']) && $this->post['sale_rate '] !== "" ? intval($this->post['sale_rate ']) : "";
|
|
|
|
-// $lower_rate = isset($this->post['lower_rate']) && $this->post['lower_rate'] !== "" ? intval($this->post['lower_rate']) : "";
|
|
|
|
$weight = isset($this->post['weight']) && $this->post['weight'] !== "" ? intval($this->post['weight']) : "0";
|
|
$weight = isset($this->post['weight']) && $this->post['weight'] !== "" ? intval($this->post['weight']) : "0";
|
|
$status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "0";
|
|
$status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "0";
|
|
Db::startTrans();
|
|
Db::startTrans();
|
|
@@ -239,10 +235,6 @@ public function create()
|
|
"pid" => $pid,
|
|
"pid" => $pid,
|
|
"level" => $level,
|
|
"level" => $level,
|
|
"search" => $search,
|
|
"search" => $search,
|
|
-// "rate" => $rate,
|
|
|
|
-// "lower_rate"=>$lower_rate,
|
|
|
|
-// "order_rate"=>$order_rate,
|
|
|
|
-// "sale_rate"=>$sale_rate,
|
|
|
|
"weight" => $weight,
|
|
"weight" => $weight,
|
|
"status" => $status,
|
|
"status" => $status,
|
|
"cat_desc"=>$cat_desc,
|
|
"cat_desc"=>$cat_desc,
|
|
@@ -285,7 +277,10 @@ public function create()
|
|
Db::rollback();
|
|
Db::rollback();
|
|
return error_show(1005, "新建失败");
|
|
return error_show(1005, "新建失败");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if($level==3){
|
|
|
|
+ $catinfo=['cat_id'=>$datainfo,'apply_name'=>$creater,"apply_id"=>$createrid,"fund_code"=>$fund_code,"status"=>0];
|
|
|
|
+ $this->addPlat($catinfo);
|
|
|
|
+ }
|
|
Db::commit();
|
|
Db::commit();
|
|
return error_show(0, "新建成功");
|
|
return error_show(0, "新建成功");
|
|
} else {
|
|
} else {
|
|
@@ -432,6 +427,10 @@ public function edit(){
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$itn =sear($id);
|
|
$itn =sear($id);
|
|
|
|
+ if($level==3){
|
|
|
|
+ $catinfo=['cat_id'=>$id,'apply_name'=>$creater,"apply_id"=>$createrid,"fund_code"=>$fund_code,"status"=>$idinfo['status']];
|
|
|
|
+ $this->addPlat($catinfo);
|
|
|
|
+ }
|
|
Db::commit();
|
|
Db::commit();
|
|
return error_show(0,"编辑成功");
|
|
return error_show(0,"编辑成功");
|
|
}else{
|
|
}else{
|
|
@@ -574,24 +573,52 @@ public function status(){
|
|
$it['updatetime']=date("Y-m-d H:i:s");
|
|
$it['updatetime']=date("Y-m-d H:i:s");
|
|
$str = Db::name('cat')->where(['id'=>$cat,'is_del'=>0])->save($it);
|
|
$str = Db::name('cat')->where(['id'=>$cat,'is_del'=>0])->save($it);
|
|
if($str){
|
|
if($str){
|
|
-// $order = ["order_code"=>$id,"status"=>$pd,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
|
-// ActionLog::logAdd($this->post['token'],$order,"sxd",$stn['status'],$order);
|
|
|
|
|
|
+ if($stn['level']==3){
|
|
|
|
+ $catinfo=['cat_id'=>$id,"status"=>$status];
|
|
|
|
+ $this->addPlat($catinfo);
|
|
|
|
+ }else{
|
|
|
|
+ $catinfo=['cat_id'=> $cat,"status"=>$status];
|
|
|
|
+ $this->addPlat($catinfo);
|
|
|
|
+ }
|
|
return error_show(0,"状态更新成功");
|
|
return error_show(0,"状态更新成功");
|
|
}else{
|
|
}else{
|
|
return error_show(1002,"状态更新失败");
|
|
return error_show(1002,"状态更新失败");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-public function delete(){
|
|
|
|
- $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :"";
|
|
|
|
- $info = Db::name('cat')->where(["is_del"=>0,'id'=>$id])->find();
|
|
|
|
- if($info==false){
|
|
|
|
- return error_show(1002,"未找到数据");
|
|
|
|
|
|
+ public function delete(){
|
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :"";
|
|
|
|
+ $info = Db::name('cat')->where(["is_del"=>0,'id'=>$id])->find();
|
|
|
|
+ if($info==false){
|
|
|
|
+ return error_show(1002,"未找到数据");
|
|
|
|
+ }
|
|
|
|
+ $supp= Db::name('cat')->update(['id'=>$id,'is_del'=>1,"updatetime"=>date("Y-m-d H:i:s")]);
|
|
|
|
+ if($supp){
|
|
|
|
+ return error_show(0,"删除成功");
|
|
|
|
+ }else{
|
|
|
|
+ return error_show(1002,"删除失败");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- $supp= Db::name('cat')->update(['id'=>$id,'is_del'=>1,"updatetime"=>date("Y-m-d H:i:s")]);
|
|
|
|
- if($supp){
|
|
|
|
- return error_show(0,"删除成功");
|
|
|
|
- }else{
|
|
|
|
- return error_show(1002,"删除失败");
|
|
|
|
|
|
+ /** 平台添加分类 **/
|
|
|
|
+ private function addPlat($cat){
|
|
|
|
+ $plat =Db::name("platform")->where(["platform_type"=>1,"is_del"=>0])->select()->toArray();
|
|
|
|
+ if (empty($plat)){
|
|
|
|
+ return '';
|
|
|
|
+ }
|
|
|
|
+ foreach ($plat as $value){
|
|
|
|
+ $cat['platform_id']=$value['id'];
|
|
|
|
+ $cat['addtime']=date("Y-m-d H:i:s");
|
|
|
|
+ $cat['updatetime']=date("Y-m-d H:i:s");
|
|
|
|
+ $isT = Db::name("cat_plat")->where(["cat_id"=>$cat['cat_id'],"platform_id"=>$cat['platform_id'],"is_del"=>0])->column("cat_id");
|
|
|
|
+ if($isT){
|
|
|
|
+ $data=$cat;
|
|
|
|
+ unset($data['cat_id']);
|
|
|
|
+ unset($data['addtime']);
|
|
|
|
+ Db::name("cat_plat")->where(["cat_id"=>$cat['cat_id'],"platform_id"=>$cat['platform_id'],"is_del"=>0])->update($data);
|
|
|
|
+ }else{
|
|
|
|
+ Db::name("cat_plat")->save($cat);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
-}
|
|
|
|
}
|
|
}
|