修改店铺街接口
This commit is contained in:
parent
40fb9a40a8
commit
8b4dacbc08
@ -164,8 +164,13 @@ class LocalStoreLogic extends Logic
|
||||
}
|
||||
|
||||
$pic = LocalStoreGoodsPic::where('lsg_id', $value['id'])->field('url')->find();
|
||||
$lists[$key]['url'] = UrlServer::getFileUrl($pic['url']);
|
||||
$lists[$key]['distance'] = number_format($value['distance'], 2, '.', '') . "km";
|
||||
$lists[$key]['url'] = $pic['url'];
|
||||
|
||||
if ($value['distance'] <= 0) {
|
||||
$lists[$key]['distance'] = '<500m';
|
||||
} else {
|
||||
$lists[$key]['distance'] = number_format($value['distance'], 2, '.', '') . "km";
|
||||
}
|
||||
// $lists[$key]['distance'] = round($this->distance($data['latitude'], $data['longitude'], $value['latitude'], $value['longitude']) / 1000, 2) . "km";
|
||||
$lists[$key]['store_nickname'] = $value["shopName"];
|
||||
}
|
||||
@ -229,7 +234,7 @@ class LocalStoreLogic extends Logic
|
||||
->join('local_store_goods lsg', 'lsg.lstore_id = ls.lstore_id')
|
||||
->where(['ls.is_delete' => 0, 'ls.store_state' => 1])
|
||||
->whereNotNull('ls.shopLogo')
|
||||
->field('ls.lstore_id as ls_id, ls.shopName, ls.longitude, ls.latitude, ' . $distance_sql . ', lsg.lstore_id')
|
||||
->field('ls.lstore_id as ls_id, ls.shopLogo, ls.shopName, ls.longitude, ls.latitude, ' . $distance_sql . ', lsg.lstore_id')
|
||||
->order($order)
|
||||
->page($data['page_no'], $data['page_size'])
|
||||
->group('ls.lstore_id')
|
||||
@ -242,10 +247,16 @@ class LocalStoreLogic extends Logic
|
||||
$lists[$key]['price'] = round($value['price'] * LocalStoreGoodsLogic::$sale, 2);
|
||||
}
|
||||
|
||||
// $pic = LocalStoreGoodsPic::where('lsg_id', $value['id'])->field('url')->find();
|
||||
// $lists[$key]['url'] = UrlServer::getFileUrl($pic['url']);
|
||||
$lists[$key]['distance'] = number_format($value['distance'], 2, '.', '') . "km";
|
||||
// $lists[$key]['distance'] = round($this->distance($data['latitude'], $data['longitude'], $value['latitude'], $value['longitude']) / 1000, 2) . "km";
|
||||
// 获取商品下的商品图片
|
||||
foreach ($value['street_goods'] as &$v) {
|
||||
$v['url'] = UrlServer::getFileUrl($v['url']);
|
||||
}
|
||||
|
||||
if ($value['distance'] <= 0) {
|
||||
$lists[$key]['distance'] = '<500m';
|
||||
} else {
|
||||
$lists[$key]['distance'] = number_format($value['distance'], 2, '.', '') . "km";
|
||||
}
|
||||
$lists[$key]['store_nickname'] = $value["shopName"];
|
||||
}
|
||||
|
||||
|
||||
@ -15,8 +15,14 @@ class LocalStore extends Model
|
||||
return $this->belongsTo(User::class, 'user_id', 'id')->field('id, nickname');
|
||||
}
|
||||
|
||||
// 店铺街
|
||||
public function streetGoods()
|
||||
{
|
||||
return $this->hasMany(LocalStoreGoods::class, 'lstore_id', 'lstore_id')->field('id, lstore_id, title, price')->order('id desc')->limit(10);
|
||||
return $this->hasMany(LocalStoreGoods::class, 'lstore_id', 'lstore_id')
|
||||
->alias('lsg')
|
||||
->join('local_store_goods_pic p', 'lsg.id = p.lsg_id')
|
||||
->field('lsg.id, lsg.lstore_id, lsg.title, lsg.price, p.url')
|
||||
->order('lsg.id desc')
|
||||
->limit(10);
|
||||
}
|
||||
}
|
||||
@ -3,8 +3,14 @@
|
||||
namespace app\common\model\localstore;
|
||||
|
||||
use app\common\basics\Models;
|
||||
use app\common\server\UrlServer;
|
||||
|
||||
class LocalStoreGoodsPic extends Models
|
||||
{
|
||||
protected $table = 'ls_local_store_goods_pic';
|
||||
|
||||
public function getUrlAttr($value)
|
||||
{
|
||||
return $value ? UrlServer::getFileUrl($value) : '';
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user