获取提交记录
This commit is contained in:
parent
2d31299a26
commit
a5e7e1d29b
@ -261,4 +261,13 @@ class LocalStore extends Api
|
||||
|
||||
return JsonServer::error('修改失败');
|
||||
}
|
||||
|
||||
// 本地商家提交记录
|
||||
public function record()
|
||||
{
|
||||
$page = $this->request->get('page_no', $this->page_no);
|
||||
$size = $this->request->get('page_size', $this->page_size);
|
||||
$data = LocalStoreLogic::record($page, $size, $this->user_id);
|
||||
return JsonServer::success('查询成功', $data);
|
||||
}
|
||||
}
|
||||
@ -9,20 +9,21 @@ use think\facade\Db;
|
||||
|
||||
class LocalStoreLogic extends Logic
|
||||
{
|
||||
public function getLocalList($data){
|
||||
public function getLocalList($data)
|
||||
{
|
||||
$model = new LocalStore;
|
||||
$distance = "";
|
||||
$s =$s1= "";
|
||||
if(isset($data['c_name'])){
|
||||
if($data['c_name']!=""){
|
||||
$s1 = "address like '%".$data['c_name']."%'";
|
||||
$s = "and address like '%".$data['c_name']."%'";
|
||||
$s = $s1 = "";
|
||||
if (isset($data['c_name'])) {
|
||||
if ($data['c_name'] != "") {
|
||||
$s1 = "address like '%" . $data['c_name'] . "%'";
|
||||
$s = "and address like '%" . $data['c_name'] . "%'";
|
||||
}
|
||||
}
|
||||
|
||||
$count = $model->where('is_delete',0)
|
||||
$count = $model->where('is_delete', 0)
|
||||
->where($s1)
|
||||
->where("store_state",1)
|
||||
->where("store_state", 1)
|
||||
->where("shopLogo is not null")
|
||||
->count();
|
||||
// $lists = $model->where('is_delete',0)
|
||||
@ -31,15 +32,15 @@ class LocalStoreLogic extends Logic
|
||||
// ->order('lstore_id desc')
|
||||
// ->select();
|
||||
$size = $data['page_size'];
|
||||
$page = ($data['page_no']-1)*$data['page_size'];
|
||||
$page = ($data['page_no'] - 1) * $data['page_size'];
|
||||
// $sql = "SELECT *, ST_Distance_Sphere(POINT(".$data['longitude'].",".$data['latitude']."),POINT(longitude, latitude)) AS distance
|
||||
// FROM ls_local_store where is_delete = 0 $s
|
||||
// ORDER BY distance limit $page,$size";
|
||||
$sql = "SELECT * FROM ls_local_store where is_delete = 0 and store_state = 1 and shopLogo is not null $s ORDER BY lstore_id asc limit ".$page.",".$size;
|
||||
$sql = "SELECT * FROM ls_local_store where is_delete = 0 and store_state = 1 and shopLogo is not null $s ORDER BY lstore_id asc limit " . $page . "," . $size;
|
||||
// var_dump($sql);
|
||||
$lists = Db::query($sql);
|
||||
foreach($lists as $key=>$value){
|
||||
$lists[$key]['distance'] = round($this->distance($data['latitude'], $data['longitude'], $value['latitude'], $value['longitude'])/1000,2)."公里";
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['distance'] = round($this->distance($data['latitude'], $data['longitude'], $value['latitude'], $value['longitude']) / 1000, 2) . "公里";
|
||||
$lists[$key]['store_nickname'] = $value["shopName"];
|
||||
}
|
||||
$data = [
|
||||
@ -53,7 +54,8 @@ class LocalStoreLogic extends Logic
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getLocalOrderList($data){
|
||||
public function getLocalOrderList($data)
|
||||
{
|
||||
$count = LocalStoreOrder::where(['lstore_id' => $data['lstore_id'], 'pay_shop_type' => 1, 'state' => 1])->count();
|
||||
// $count = Db::name("local_store_order")
|
||||
// ->where("lstore_id",$data['lstore_id'])
|
||||
@ -93,17 +95,18 @@ class LocalStoreLogic extends Logic
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getLocalUserOrderList($data){
|
||||
public function getLocalUserOrderList($data)
|
||||
{
|
||||
$count = Db::name("local_store_order")
|
||||
->where("user_id",$data['user_id'])
|
||||
->where("pay_shop_type",1)
|
||||
->where('state',1)
|
||||
->where("user_id", $data['user_id'])
|
||||
->where("pay_shop_type", 1)
|
||||
->where('state', 1)
|
||||
->count();
|
||||
$size = $data['page_size'];
|
||||
$page = ($data['page_no']-1)*$data['page_size'];
|
||||
$page = ($data['page_no'] - 1) * $data['page_size'];
|
||||
$sql = "SELECT * FROM ls_local_store_order where state = 1 and
|
||||
pay_shop_type = 1 and user_id = ".$data['user_id']."
|
||||
ORDER BY lstore_id desc limit ".$page.",".$size;
|
||||
pay_shop_type = 1 and user_id = " . $data['user_id'] . "
|
||||
ORDER BY lstore_id desc limit " . $page . "," . $size;
|
||||
$lists = Db::query($sql);
|
||||
$data = [
|
||||
'list' => $lists,
|
||||
@ -114,7 +117,9 @@ class LocalStoreLogic extends Logic
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
function distance($lat1, $lon1, $lat2, $lon2) {
|
||||
|
||||
function distance($lat1, $lon1, $lat2, $lon2)
|
||||
{
|
||||
$earthRadius = 6371000; // 地球平均半径,单位为米
|
||||
|
||||
// 将经纬度转换为弧度
|
||||
@ -124,12 +129,28 @@ class LocalStoreLogic extends Logic
|
||||
$lon2 = deg2rad($lon2);
|
||||
|
||||
// 使用haversine公式计算距离
|
||||
$diffLat = $lat2-$lat1;
|
||||
$diffLon = $lon2-$lon1;
|
||||
$diffLat = $lat2 - $lat1;
|
||||
$diffLon = $lon2 - $lon1;
|
||||
$a = sin($diffLat / 2) * sin($diffLat / 2) + cos($lat1) * cos($lat2) * sin($diffLon / 2) * sin($diffLon / 2);
|
||||
$c = 2 * atan2(sqrt($a), sqrt(1-$a));
|
||||
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
|
||||
$distance = $earthRadius * $c;
|
||||
|
||||
return $distance;
|
||||
}
|
||||
|
||||
public static function record($page, $size, $user_id)
|
||||
{
|
||||
$list = LocalStore::where(['user_id' => $user_id, 'is_delete' => 0])->page($page, $size)->order('id desc')->select()->toArray();
|
||||
$count = LocalStore::where(['user_id' => $user_id, 'is_delete' => 0])->count();
|
||||
|
||||
$more = is_more($count, $page, $size); //是否有下一页
|
||||
|
||||
return [
|
||||
'list' => $list,
|
||||
'page_no' => $page,
|
||||
'page_size' => $size,
|
||||
'count' => $count,
|
||||
'more' => $more,
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user