From 67f510404632f5c44fe446c4576fa09817d10b22 Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Tue, 23 Jul 2024 23:33:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=95=86=E5=9F=8E=E5=BF=AB?= =?UTF-8?q?=E8=AE=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Goods.php | 69 +++++++-------------------------- app/api/controller/MallNews.php | 22 +++++++++++ app/api/logic/MallNewsLogic.php | 37 ++++++++++++++++++ 3 files changed, 74 insertions(+), 54 deletions(-) create mode 100644 app/api/controller/MallNews.php create mode 100644 app/api/logic/MallNewsLogic.php diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index d7ca6f1c..75c149a1 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -101,18 +101,18 @@ class Goods extends Api $set = Procurementset::where("u_id",$p_id)->where("set_state",1)->order("set_update desc")->limit(1)->find(); } $set_price_type = 0; - if ($set != null&&$settpye!=1) { - if($set['price_type']==1){ - $set_price_type = 1; - } - if($set['price_type']==2){ - $set_price_type = 2; - } - if($set['price_type']==3){ - $set_price_type = 3; - } + if ($set != null&&$settpye!=1) { + if($set['price_type']==1){ + $set_price_type = 1; + } + if($set['price_type']==2){ + $set_price_type = 2; + } + if($set['price_type']==3){ + $set_price_type = 3; + } if ($set['set_pro'] != 0) { -// $set_price_type = 1; + // $set_price_type = 1; if ($set['set_pro_type'] == 1) { $goodsDetail['purchase_price'] = round($goodsDetail['purchase_price'] * (100 + $set['set_pro']) / 100, 2); } @@ -121,7 +121,7 @@ class Goods extends Api } } if ($set['set_issued'] != 0) { -// $set_price_type = 2; + // $set_price_type = 2; if ($set['set_issued_type'] == 1) { $goodsDetail['issuing_price'] = round($goodsDetail['issuing_price'] * (100 + $set['set_issued']) / 100, 2); } @@ -130,7 +130,7 @@ class Goods extends Api } } if ($set['set_wholesale'] != 0) { -// $set_price_type = 3; + // $set_price_type = 3; if ($set['set_wholesale_type'] == 1) { $goodsDetail['wholesale_price'] = round($goodsDetail['wholesale_price'] * (100 + $set['set_wholesale']) / 100, 2); } @@ -185,7 +185,7 @@ class Goods extends Api } } } - $goodsDetail['set_price_type'] = $set_price_type; + $goodsDetail['set_price_type'] = $set_price_type; $rst = Mprocurement::where("user_id",$this->user_id)->where("u_state",1)->where("u_examine_state",1)->where("wholesale_state",2)->find(); if($rst==null){ // foreach($goodsDetail['goods_item'] as $k => $v){ @@ -214,6 +214,7 @@ class Goods extends Api return JsonServer::error('请求方式错误'); } } + // 备用接口调整集采规格 public function getPurchasesku(){ $post = $this->request->post(); $purchase_sku= Goodspurchase::where('item_id', $post['id'])->select(); @@ -288,44 +289,4 @@ class Goods extends Api return JsonServer::error('请求方式错误'); } } - public function pdTypeList(){ - $result = GoodsLogic::getGoodsTypeList(); - $data = $this -> list_to_tree($result,'id','pid'); - if(!empty($result)){ - return JsonServer::success('获取成功', $data); - }else{ - return JsonServer::error('暂无数据'); - } - } - //无限级栏目 - function list_to_tree($list, $pk='type_id',$pid = 'type_parents',$child = 'msg_sub_menu',$root=0) { - // 创建Tree - $tree = array(); - if(is_array($list)) { - // 创建基于主键的数组引用 - $refer = array(); - foreach ($list as $key => $data) { - $refer[$data[$pk]] =& $list[$key]; - - } - //循环所有的结果集 - foreach ($list as $key => $data) { - // 判断是否存在parent - $parentId = $data[$pid]; - //如果ID是0,那么就是根目录 - if ($root == $parentId) { - - $list[$key][$child] = array(); - $tree[] =& $list[$key]; - }else{ - if (isset($refer[$parentId])) { - $parent =& $refer[$parentId]; - $parent[$child][] =& $list[$key]; - } - - } - } - } - return $tree; - } } \ No newline at end of file diff --git a/app/api/controller/MallNews.php b/app/api/controller/MallNews.php new file mode 100644 index 00000000..957354b2 --- /dev/null +++ b/app/api/controller/MallNews.php @@ -0,0 +1,22 @@ +request->isGet()) { + $page = $this->request->get('page_no', $this->page_no); + $size = $this->request->get('page_size', $this->page_size); + $data = MallNewsLogic::lists($page, $size); + return JsonServer::success('获取成功', $data); + }else{ + return JsonServer::error('请求方式错误'); + } + } +} \ No newline at end of file diff --git a/app/api/logic/MallNewsLogic.php b/app/api/logic/MallNewsLogic.php new file mode 100644 index 00000000..328059ca --- /dev/null +++ b/app/api/logic/MallNewsLogic.php @@ -0,0 +1,37 @@ +where(['is_top' => 1, 'delete_time' => 0])->field('title, desc')->select(); + + $list = Db::name('mall_news') + ->where(['is_top' => 0, 'delete_time' => 0]) + ->field('title, desc') + ->order('sort desc, create_time desc') + ->page($page,$size) + ->select(); + + $count = Db::name('mall_news') + ->where(['is_top' => 0, 'delete_time' => 0]) + ->field('title, desc') + ->count(); + + $more = is_more($count, $page, $size); //是否有下一页 + + return [ + 'list' => $list, + 'page_no' => $page, + 'page_size' => $size, + 'count' => $count, + 'more' => $more, + 'top' => $top, + ]; + } +} \ No newline at end of file