【增加】详情接口
This commit is contained in:
parent
85116901dd
commit
6d14f5d6fa
|
|
@ -28,13 +28,13 @@ class Futures extends BaseApi{
|
||||||
|
|
||||||
switch($status){
|
switch($status){
|
||||||
case 'miaosha':
|
case 'miaosha':
|
||||||
$condition[] = ['status', '=', '2'];
|
$condition[] = ['a.status', '=', '2'];
|
||||||
break;
|
break;
|
||||||
case 'jianlou':
|
case 'jianlou':
|
||||||
$condition[] = ['status', '=', '7'];
|
$condition[] = ['a.status', '=', '7'];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$condition[] = ['status', '=', '2'];
|
$condition[] = ['a.status', '=', '2'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,12 +141,12 @@ class Futures extends BaseApi{
|
||||||
$id = input('id', 0);
|
$id = input('id', 0);
|
||||||
$price = input('price', 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)){
|
if(empty($date)){
|
||||||
return $this->response($this->error('','发布失败'));
|
return $this->response($this->error('','发布失败'));
|
||||||
}
|
}
|
||||||
if($price <= $date['unit_price'] * (1 + 0 / 100) || $price >= $date['unit_price'] * (1 + 8 / 100)){//TODO 后台配置范围
|
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 拆单
|
//TODO 拆单
|
||||||
|
|
||||||
|
|
@ -164,7 +164,7 @@ class Futures extends BaseApi{
|
||||||
|
|
||||||
$id = input('id', 0);
|
$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)){
|
if(empty($date)){
|
||||||
return $this->response($this->error('','下架失败'));
|
return $this->response($this->error('','下架失败'));
|
||||||
}
|
}
|
||||||
|
|
@ -174,5 +174,20 @@ class Futures extends BaseApi{
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO 提货
|
//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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ namespace addon\futures\model;
|
||||||
use app\model\system\Config as ConfigModel;
|
use app\model\system\Config as ConfigModel;
|
||||||
use app\model\BaseModel;
|
use app\model\BaseModel;
|
||||||
use think\facade\Cache;
|
use think\facade\Cache;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
class Futures extends BaseModel{
|
class Futures extends BaseModel{
|
||||||
|
|
||||||
|
|
@ -23,6 +24,45 @@ class Futures extends BaseModel{
|
||||||
$list = model('futures')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
$list = model('futures')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||||
return $this->success($list);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布
|
* 发布
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue