|
@@ -16,7 +16,7 @@ public function __construct(App $app)
|
|
$this->post=$this->request->post();
|
|
$this->post=$this->request->post();
|
|
}
|
|
}
|
|
public function list(){
|
|
public function list(){
|
|
- $where=[];
|
|
|
|
|
|
+ $where=[["is_del","=",0]];
|
|
$pid = isset($this->post['pid']) &&$this->post['pid']!=="" ?intval($this->post['pid']): "0";
|
|
$pid = isset($this->post['pid']) &&$this->post['pid']!=="" ?intval($this->post['pid']): "0";
|
|
$where[]=["pid","=",$pid];
|
|
$where[]=["pid","=",$pid];
|
|
|
|
|
|
@@ -34,7 +34,7 @@ public function list(){
|
|
public function plist(){
|
|
public function plist(){
|
|
$page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']) :"1";
|
|
$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";
|
|
$size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']) :"10";
|
|
- $where =[];
|
|
|
|
|
|
+ $where =[["is_del","=",0]];
|
|
$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']) :"";
|
|
if($cat_name!==""){
|
|
if($cat_name!==""){
|
|
$where[]=['cat_name',"like","%$cat_name%"];
|
|
$where[]=['cat_name',"like","%$cat_name%"];
|
|
@@ -53,6 +53,23 @@ public function plist(){
|
|
$list = Db::name('cat')->where($where)->page($page, $size)->select();
|
|
$list = Db::name('cat')->where($where)->page($page, $size)->select();
|
|
return app_show(0, "获取成功", ['list' => $list, 'count' => $count]);
|
|
return app_show(0, "获取成功", ['list' => $list, 'count' => $count]);
|
|
}
|
|
}
|
|
|
|
+public function title(){
|
|
|
|
+ $where =[["is_del","=",0]];
|
|
|
|
+ $cat_name=isset($this->post['cat_name']) && $this->post['cat_name'] !==""? trim($this->post['cat_name']) :"";
|
|
|
|
+ if($cat_name!==""){
|
|
|
|
+ $where[]=['cat_name',"like","%$cat_name%"];
|
|
|
|
+ }
|
|
|
|
+ $pid=isset($this->post['pid']) && $this->post['pid'] !==""? intval($this->post['pid']) :"";
|
|
|
|
+ if($pid!==""){
|
|
|
|
+ $where[]=['pid',"=",$pid];
|
|
|
|
+ }
|
|
|
|
+ $status=isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']) :"";
|
|
|
|
+ if($status!==""){
|
|
|
|
+ $where[]=['status',"=",$status];
|
|
|
|
+ }
|
|
|
|
+ $list = Db::name('cat')->where($where)->select();
|
|
|
|
+ return app_show(0, "获取成功", $list);
|
|
|
|
+}
|
|
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']) : "";
|
|
@@ -63,7 +80,7 @@ public function create()
|
|
if ($pid === "") {
|
|
if ($pid === "") {
|
|
return error_show(1002, "参数pid不能为空");
|
|
return error_show(1002, "参数pid不能为空");
|
|
}
|
|
}
|
|
- //$level = isset($this->post['level']) && $this->post['level'] !== "" ? intval($this->post['level']) : "";
|
|
|
|
|
|
+ $cat_desc = isset($this->post['cat_desc']) && $this->post['cat_desc'] !== "" ? trim($this->post['cat_desc']) : "";
|
|
|
|
|
|
$levl=Db::name('cat')->where(['id'=>$pid])->find();
|
|
$levl=Db::name('cat')->where(['id'=>$pid])->find();
|
|
$level =1;
|
|
$level =1;
|
|
@@ -100,16 +117,16 @@ public function create()
|
|
"rate" => $rate,
|
|
"rate" => $rate,
|
|
"weight" => $weight,
|
|
"weight" => $weight,
|
|
"status" => $status,
|
|
"status" => $status,
|
|
|
|
+ "cat_desc"=>$cat_desc,
|
|
|
|
+ "is_del"=>0,
|
|
"addtime" => date("Y-m-d H:i:s"),
|
|
"addtime" => date("Y-m-d H:i:s"),
|
|
"updatetime" => date("Y-m-d H:i:s")
|
|
"updatetime" => date("Y-m-d H:i:s")
|
|
];
|
|
];
|
|
$datainfo = Db::name('cat')->insert($data,true);
|
|
$datainfo = Db::name('cat')->insert($data,true);
|
|
$vat =[];
|
|
$vat =[];
|
|
-
|
|
|
|
if ($datainfo>0) {
|
|
if ($datainfo>0) {
|
|
$stx = ["order_code"=>$pid,"status"=>$status,"action_remark"=>'',"action_type"=>"create"];
|
|
$stx = ["order_code"=>$pid,"status"=>$status,"action_remark"=>'',"action_type"=>"create"];
|
|
ActionLog::logAdd($this->post['token'],$stx,"sxd",$status,$stx);
|
|
ActionLog::logAdd($this->post['token'],$stx,"sxd",$status,$stx);
|
|
-
|
|
|
|
$spc =[];
|
|
$spc =[];
|
|
$spc['cat_id']=$datainfo;
|
|
$spc['cat_id']=$datainfo;
|
|
$spc['exam_status']=0;
|
|
$spc['exam_status']=0;
|
|
@@ -119,7 +136,6 @@ public function create()
|
|
$spc['is_del']=0;
|
|
$spc['is_del']=0;
|
|
$spc['addtime']=date("Y-m-d H:i:d");
|
|
$spc['addtime']=date("Y-m-d H:i:d");
|
|
$spc['updatetime']=date("Y-m_d H:i:s");
|
|
$spc['updatetime']=date("Y-m_d H:i:s");
|
|
-
|
|
|
|
$vpn = Db::name('cat_spec')->insert($spc,true);
|
|
$vpn = Db::name('cat_spec')->insert($spc,true);
|
|
if ($vpn == "") {
|
|
if ($vpn == "") {
|
|
Db::rollback();
|
|
Db::rollback();
|
|
@@ -133,9 +149,7 @@ public function create()
|
|
$item['addtime']=date("Y-m-d H:i:s");
|
|
$item['addtime']=date("Y-m-d H:i:s");
|
|
$vat[] = $item;
|
|
$vat[] = $item;
|
|
}
|
|
}
|
|
-
|
|
|
|
$vp = Db::name('cat_specs')->insertAll($vat);
|
|
$vp = Db::name('cat_specs')->insertAll($vat);
|
|
- // var_dump(Db::name('cat_specs')->getLastSql());
|
|
|
|
if ($vp==0) {
|
|
if ($vp==0) {
|
|
Db::rollback();
|
|
Db::rollback();
|
|
return error_show(1005, "新建失败");
|
|
return error_show(1005, "新建失败");
|
|
@@ -156,7 +170,6 @@ public function create()
|
|
public function edit(){
|
|
public function edit(){
|
|
$id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :"";
|
|
$id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :"";
|
|
$idinfo = Db::name('cat')->where(['id'=>$id])->find();
|
|
$idinfo = Db::name('cat')->where(['id'=>$id])->find();
|
|
- // var_dump($idinfo);
|
|
|
|
if($idinfo==""){
|
|
if($idinfo==""){
|
|
return error_show(1002,"未找到商品数据");
|
|
return error_show(1002,"未找到商品数据");
|
|
}
|
|
}
|
|
@@ -168,6 +181,8 @@ public function edit(){
|
|
if($pid==""){
|
|
if($pid==""){
|
|
return error_show(1002,"参数pid不能为空");
|
|
return error_show(1002,"参数pid不能为空");
|
|
}
|
|
}
|
|
|
|
+ $cat_desc = isset($this->post['cat_desc']) && $this->post['cat_desc'] !=="" ? trim($this->post['cat_desc']) :"";
|
|
|
|
+
|
|
$specs_id = isset($this->post['specs_id']) && $this->post['specs_id'] !== "" ? $this->post['specs_id'] : [];
|
|
$specs_id = isset($this->post['specs_id']) && $this->post['specs_id'] !== "" ? $this->post['specs_id'] : [];
|
|
if (empty($specs_id)) {
|
|
if (empty($specs_id)) {
|
|
return error_show(1002, "参数specs_id不能为空");
|
|
return error_show(1002, "参数specs_id不能为空");
|
|
@@ -194,6 +209,8 @@ public function edit(){
|
|
"level"=>$level,
|
|
"level"=>$level,
|
|
"weight"=>$weight,
|
|
"weight"=>$weight,
|
|
"status"=>$status,
|
|
"status"=>$status,
|
|
|
|
+ "cat_desc"=>$cat_desc,
|
|
|
|
+ "is_del"=>0,
|
|
"updatetime"=>date("Y-m-d H:i:s")
|
|
"updatetime"=>date("Y-m-d H:i:s")
|
|
];
|
|
];
|
|
$strinfo = Db::name('cat')->where(['id'=>$id])->save($str);
|
|
$strinfo = Db::name('cat')->where(['id'=>$id])->save($str);
|
|
@@ -203,17 +220,16 @@ public function edit(){
|
|
|
|
|
|
$spc =[];
|
|
$spc =[];
|
|
$vp = Db::name('cat_spec')->where(['cat_id'=>$idinfo['id'],'is_del'=>0])->find();
|
|
$vp = Db::name('cat_spec')->where(['cat_id'=>$idinfo['id'],'is_del'=>0])->find();
|
|
|
|
+ $str ="";
|
|
if($vp!=false){
|
|
if($vp!=false){
|
|
- //var_dump($vp);
|
|
|
|
isset($vp['id']) && $vp['id'] !== "" ? $spc['id'] = $vp['id'] : '';
|
|
isset($vp['id']) && $vp['id'] !== "" ? $spc['id'] = $vp['id'] : '';
|
|
$spc['cat_id']=$idinfo['id'];
|
|
$spc['cat_id']=$idinfo['id'];
|
|
$spc['exam_status']=0;
|
|
$spc['exam_status']=0;
|
|
$spc['status']=0;
|
|
$spc['status']=0;
|
|
- // $spc['creater']=$creater;
|
|
|
|
- // $spc['createrid']=$createrid;
|
|
|
|
$spc['is_del']=0;
|
|
$spc['is_del']=0;
|
|
- //$spc['addtime']=date("Y-m-d H:i:d");
|
|
|
|
$spc['updatetime']=date("Y-m_d H:i:s");
|
|
$spc['updatetime']=date("Y-m_d H:i:s");
|
|
|
|
+ $str=$vp['id'];
|
|
|
|
+ $vpn = Db::name('cat_spec')->save($spc);
|
|
}else{
|
|
}else{
|
|
|
|
|
|
$spc['cat_id']=$idinfo['id'];
|
|
$spc['cat_id']=$idinfo['id'];
|
|
@@ -224,29 +240,45 @@ public function edit(){
|
|
$spc['is_del']=0;
|
|
$spc['is_del']=0;
|
|
$spc['addtime']=date("Y-m-d H:i:d");
|
|
$spc['addtime']=date("Y-m-d H:i:d");
|
|
$spc['updatetime']=date("Y-m_d H:i:s");
|
|
$spc['updatetime']=date("Y-m_d H:i:s");
|
|
- }
|
|
|
|
-
|
|
|
|
- $vpn = Db::name('cat_spec')->save($spc);
|
|
|
|
|
|
|
|
|
|
+ $vpn = Db::name('cat_spec')->insert($spc,true);
|
|
|
|
+ $str=$vpn;
|
|
|
|
+ }
|
|
if ($vpn == false) {
|
|
if ($vpn == false) {
|
|
Db::rollback();
|
|
Db::rollback();
|
|
return error_show(1002, "更新失败");
|
|
return error_show(1002, "更新失败");
|
|
}
|
|
}
|
|
- foreach ($specs_id as $value){
|
|
|
|
- $item =[];
|
|
|
|
- $item['id']=$value;
|
|
|
|
- $item['cat_spec_id']=$vpn;
|
|
|
|
- $item['specs_id']=$value;
|
|
|
|
- $item['is_del']=0;
|
|
|
|
- isset($value['id']) && $value['id'] !== "" ? '' : $item['addtime'] = date("Y-m-d H:i:s");
|
|
|
|
- $vat[] = $item;
|
|
|
|
|
|
+ $db = Db::name('cat_specs')->where(['cat_spec_id'=>$str,'is_del'=>0])->column("specs_id");
|
|
|
|
+ if(empty($db)){
|
|
|
|
+ $db=[];
|
|
|
|
+ }
|
|
|
|
+ $sn = array_diff($specs_id,$db);
|
|
|
|
+
|
|
|
|
+ $st = array_diff($db,$specs_id);
|
|
|
|
+ if(!empty($st)){
|
|
|
|
+ $int['is_del']=1;
|
|
|
|
+ $dn = Db::name('cat_specs')->where(['specs_id'=>$st,'is_del'=>0])->save($int);
|
|
|
|
+ if ($dn==false) {
|
|
|
|
+ Db::rollback();
|
|
|
|
+ return error_show(1002, "编辑失败");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- $vp = Db::name('cat_specs')->save($vat);
|
|
|
|
- if ($vp) {
|
|
|
|
- Db::rollback();
|
|
|
|
- return error_show(1002, "编辑失败");
|
|
|
|
|
|
+ if(!empty($sn)){
|
|
|
|
+ $vat=[];
|
|
|
|
+ foreach ($sn as $value){
|
|
|
|
+ $item=[];
|
|
|
|
+ $item['cat_spec_id']=$str;
|
|
|
|
+ $item['specs_id']=$value;
|
|
|
|
+ $item['is_del']=0;
|
|
|
|
+ $item['addtime'] = date("Y-m-d H:i:s");
|
|
|
|
+ $vat[] = $item;
|
|
|
|
+ }
|
|
|
|
+ $vp = Db::name('cat_specs')->insertAll($vat);
|
|
|
|
+ if ($vp==0) {
|
|
|
|
+ Db::rollback();
|
|
|
|
+ return error_show(1002, "编辑失败");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
Db::commit();
|
|
Db::commit();
|
|
return error_show(0,"编辑成功");
|
|
return error_show(0,"编辑成功");
|
|
}else{
|
|
}else{
|