作者 王智

daima

... ... @@ -309,43 +309,39 @@ class Index extends Api
}
$rult = Db::name('seller')->where($map3)->where($map)->where($map2)->order('weight asc')->page($param['pages'], $param['rows'])->select();
$count = Db::name('seller')->where($map3)->where($map)->where($map2)->order('weight asc')->select();
//asc
if (empty($rult)) {
//如果为空
$list = [
'count' => 0,
'list' => []
];
} else
{
} else {
//计算距离 KM
foreach ($rult as $k => $v)
{
$ruestul[$k]['id'] = $v['id'];
$ruestul[$k]['title'] = $v['title'];
$ruestul[$k]['address'] = $v['address'];
$ruestul[$k]['avatar'] = cdnurl($v['avatar']);
$ruestul[$k]['order'] = $v['order'];
if (empty($param['lng']) || $param['lng'] == null || $param['lng'] == '' || $param['lng'] == "")
{
$ruestul[$k]['from'] = '暂无距离信息';
}
else {
foreach ($rult as $k => $v) {
$ruestul[$k]['id'] = $v['id'];
$ruestul[$k]['title'] = $v['title'];
$ruestul[$k]['address'] = $v['address'];
$ruestul[$k]['avatar'] = cdnurl($v['avatar']);
$ruestul[$k]['order'] = $v['order'];
if (empty($param['lng']) || $param['lng'] == null || $param['lng'] == '' || $param['lng'] == "") {
$ruestul[$k]['from'] = '暂无距离信息';
} else {
$ruestul[$k]['from'] = $this->getDistance($param['lng'], $param['lat'], $v['lng'], $v['lat']) . 'km';
}
$ruestul[$k]['talk_num'] = $v['talk_num'];
}
$newarr = array_column($ruestul, 'from');
array_multisort($newarr, SORT_ASC, $ruestul);
$list = [
}
$ruestul[$k]['talk_num'] = $v['talk_num'];
}
$newarr = array_column($ruestul, 'from');
array_multisort($newarr, SORT_ASC, $ruestul);
$list = [
'count' => count($count),
'list' => $ruestul
];
}
$this->success('成功', $list);
}
];
}
$this->success('成功', $list);
}
/**
/**
* 首页接口
* @ApiTitle (首页接口-店铺详情)
* @ApiSummary (店铺详情)
... ... @@ -357,39 +353,38 @@ $this->success('成功', $list);
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": {
"id": 3,
"avatar": "http://xiche.qiniu.bronet.cn/uploads/20200831/FsGkAQhqnwBodzLvJyn1rtbZIFUd.png",
"title": "这是第三个店铺",
"opentime": "8:00-9:00",
"address": "北京市北京市海淀区吴玉章路",
"mobile": "1391929399",
"content": "<p>这是第三个商家的详情</p>",
"num": 3, //平均评分
"talkList": {
"count": 1,//评论总数
"talk": [
{
"id": 1, //评论id
"num": 3, //评分
"createtime": "1970-05-09", //评论时间
"avatar": "https://thirdwx.qlogo.cn/mmopen/vi_32/0wpUDw5m0LRvdDueia3uMWmrYb53GXRaTnYwMWC18kRmX6P6PIaPDgQqarEIfwroicx1z51D6bjQicOV0PibBx2PqQ/132",
"nickname": "Gody",
"images": [ //评论图
"http://xiche.qiniu.bronet.cn/uploads/20200831/FsGkAQhqnwBodzLvJyn1rtbZIFUd.png",
"http://xiche.qiniu.bronet.cn/uploads/20200831/FsGkAQhqnwBodzLvJyn1rtbZIFUd.png"
]
}
]
}
}
})
'code':'1',
'msg':'返回成功',
"data": {
"id": 3,
"avatar": "http://xiche.qiniu.bronet.cn/uploads/20200831/FsGkAQhqnwBodzLvJyn1rtbZIFUd.png",
"title": "这是第三个店铺",
"opentime": "8:00-9:00",
"address": "北京市北京市海淀区吴玉章路",
"mobile": "1391929399",
"content": "<p>这是第三个商家的详情</p>",
"num": 3, //平均评分
"talkList": {
"count": 1,//评论总数
"talk": [
{
"id": 1, //评论id
"num": 3, //评分
"createtime": "1970-05-09", //评论时间
"avatar": "https://thirdwx.qlogo.cn/mmopen/vi_32/0wpUDw5m0LRvdDueia3uMWmrYb53GXRaTnYwMWC18kRmX6P6PIaPDgQqarEIfwroicx1z51D6bjQicOV0PibBx2PqQ/132",
"nickname": "Gody",
"images": [ //评论图
"http://xiche.qiniu.bronet.cn/uploads/20200831/FsGkAQhqnwBodzLvJyn1rtbZIFUd.png",
"http://xiche.qiniu.bronet.cn/uploads/20200831/FsGkAQhqnwBodzLvJyn1rtbZIFUd.png"
]
}
]
}
}
})
*/
public
function SellerCon()
{
public function SellerCon()
{
$param = $this->request->param();
$seller_arr = Db::name('seller')->where('id', $param['id'])->find();
if (empty($seller_arr)) {
... ... @@ -458,10 +453,10 @@ function SellerCon()
];
}
$this->success('成功', $list);
}
}
/**
/**
* 首页接口
* @ApiTitle (首页接口-添加评论)
* @ApiSummary (添加评论)
... ... @@ -475,13 +470,12 @@ function SellerCon()
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
})
'code':'1',
'msg':'返回成功',
})
*/
public
function TalkSave()
{
public function TalkSave()
{
$param = $this->request->param();
$user_id = $this->is_token($this->request->header());
$data = [
... ... @@ -496,10 +490,10 @@ function TalkSave()
$talk_num = Db::name('seller')->where('id', $param['seller_id'])->value('talk_num');
Db::name('seller')->where('id', $param['seller_id'])->update(['talk_num' => $talk_num + 1]);
$this->res($res);
}
}
/**
/**
* 首页接口
* @ApiTitle (首页接口-联系客服文字)
* @ApiSummary (联系客服文字)
... ... @@ -508,14 +502,13 @@ function TalkSave()
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
})
'code':'1',
'msg':'返回成功',
})
*/
public
function Lianxi()
{
public function Lianxi()
{
$title = Db::name('lianxi')->where('id', 1)->value('title');
$this->success('成功', $title);
}
}
}
... ...