From 6d14f5d6fa66bf82b9bae2ef21ebd5a3906474e4 Mon Sep 17 00:00:00 2001 From: liqianjin <949671634@qq.com> Date: Tue, 28 Feb 2023 11:25:56 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0=E3=80=91=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addon/futures/api/controller/Futures.php | 27 ++++++++++++---- addon/futures/model/Futures.php | 40 ++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/addon/futures/api/controller/Futures.php b/addon/futures/api/controller/Futures.php index 13a286cf..bb9ad1e4 100644 --- a/addon/futures/api/controller/Futures.php +++ b/addon/futures/api/controller/Futures.php @@ -28,13 +28,13 @@ class Futures extends BaseApi{ switch($status){ case 'miaosha': - $condition[] = ['status', '=', '2']; + $condition[] = ['a.status', '=', '2']; break; case 'jianlou': - $condition[] = ['status', '=', '7']; + $condition[] = ['a.status', '=', '7']; break; default: - $condition[] = ['status', '=', '2']; + $condition[] = ['a.status', '=', '2']; break; } @@ -141,12 +141,12 @@ class Futures extends BaseApi{ $id = input('id', 0); $price = input('price', 0); - $date = model('futures')->getInfo([['id', '=', $id],['seller_uid' => $this->member_id]]); + $date = model('futures')->getInfo([['id', '=', $id],['seller_uid', '=', $this->member_id]]); if(empty($date)){ return $this->response($this->error('','发布失败')); } if($price <= $date['unit_price'] * (1 + 0 / 100) || $price >= $date['unit_price'] * (1 + 8 / 100)){//TODO 后台配置范围 - return $this->response($this->error('','发布失败')); + return $this->response($this->error('','发布失败,价格不在允许范围内')); } //TODO 拆单 @@ -164,7 +164,7 @@ class Futures extends BaseApi{ $id = input('id', 0); - $date = model('futures')->getInfo([['id', '=', $id],['seller_uid' => $this->member_id]]); + $date = model('futures')->getInfo([['id', '=', $id],['seller_uid', '=', $this->member_id]]); if(empty($date)){ return $this->response($this->error('','下架失败')); } @@ -174,5 +174,20 @@ class Futures extends BaseApi{ } //TODO 提货 + /** + * 详情 + * @return false|string + */ + public function detail(){ + + $token = $this->checkToken(); + if ($token['code'] < 0) return $this->response($token); + + $id = input('id', 0); + + $futuresModel = new FuturesModel; + $detail = $futuresModel->detail($id, $this->site_id); + return $this->response($detail); + } } \ No newline at end of file diff --git a/addon/futures/model/Futures.php b/addon/futures/model/Futures.php index 3dd71d82..05f55817 100644 --- a/addon/futures/model/Futures.php +++ b/addon/futures/model/Futures.php @@ -4,6 +4,7 @@ namespace addon\futures\model; use app\model\system\Config as ConfigModel; use app\model\BaseModel; use think\facade\Cache; +use think\facade\Db; class Futures extends BaseModel{ @@ -23,6 +24,45 @@ class Futures extends BaseModel{ $list = model('futures')->pageList($condition, $field, $order, $page, $page_size, $alias, $join); return $this->success($list); } + /** + * 详情 + * @param $id + * @param $site_id + * @return array + */ + public function detail($id, $site_id){ + $condition = [ + ['a.id', '=', $id], + ['a.site_id','=',$site_id] + ]; + + // 获取内容 + $field = [ + 'seller.username as seller_username', + 'seller.nickname as seller_nickname', + 'seller.headimg as seller_headimg', + 'g.goods_name', + 'g.goods_image', + 'g.goods_content', + 'a.id', + 'a.total', + 'a.unit_price', + 'a.price', + 'a.status', + 'a.release_time', + 'a.sell_time', + 'a.created_time', + 'a.take_time', + ]; + // 表关联 + $join = [ + ['member seller', 'seller.member_id = a.seller_uid', 'left'],// 获取卖家信息 + ['goods g', 'g.goods_id = a.goods_id', 'left'],// 获取商品信息 + ]; + + $detail = model('futures')->getInfo($condition, $field, 'a', $join); + return $this->success($detail); + } /** * 发布