From a910069bfe33af9941db77a053b3b7ac52d61096 Mon Sep 17 00:00:00 2001
From: lccsw <1127794702@qq.com>
Date: Fri, 27 Aug 2021 15:25:39 +0800
Subject: [PATCH] edit-admin-clues-nearby-biz
---
admin/controllers/receiver/Clues.php | 6 ++
admin/controllers/receiver/Customer.php | 4 ++
admin/views/receiver/clues/edit.php | 19 ++++--
admin/views/receiver/customer/lists.php | 80 ++++++++++++++++++++++++-
common/models/biz/Biz_model.php | 21 +++++++
5 files changed, 121 insertions(+), 9 deletions(-)
diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php
index 3777d52c..d3b5a01b 100644
--- a/admin/controllers/receiver/Clues.php
+++ b/admin/controllers/receiver/Clues.php
@@ -184,6 +184,12 @@ class Clues extends HD_Controller
}
}
$info_show['cus_bizs'] = implode($biz_arr,',');
+ //附近门店
+ if($re['lat']&&$re['lng']){
+ $info_show['near_bizs'] = $this->biz_model->nearby($re['lat'],$re['lng'],1,3,'id,biz_name');
+ }else{
+ $info_show['near_bizs'] = $this->biz_model->select(['city_id'=>$re['city_id'],'county_id'=>$re['county_id'],'status'=>1],'id desc',1,3,'id,biz_name');
+ }
$this->data['info'] = $dataInfo;
$this->data['info_show'] = $info_show;
$this->data['_title'] = '线索详情';
diff --git a/admin/controllers/receiver/Customer.php b/admin/controllers/receiver/Customer.php
index a9b40ba9..d4fffc19 100644
--- a/admin/controllers/receiver/Customer.php
+++ b/admin/controllers/receiver/Customer.php
@@ -34,6 +34,9 @@ class Customer extends HD_Controller
$status_arr = $this->customers_model->get_status();
unset($status_arr['-1']);
$params = $this->input->get();
+ !$params['city_id'] && $params['city_id'] = '';
+ !$params['county_id'] && $params['county_id'] = '';
+ !$params['biz_id'] && $params['biz_id'] = '';
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
@@ -55,6 +58,7 @@ class Customer extends HD_Controller
}
}
strlen($params['status']) && $where["status"] = $params['status'];
+ $params['biz_id'] && $where['biz_id'] = $params['biz_id'];
$count = $this->customers_model->count($where);
$lists = [];
diff --git a/admin/views/receiver/clues/edit.php b/admin/views/receiver/clues/edit.php
index 590f2a97..0590ebbb 100644
--- a/admin/views/receiver/clues/edit.php
+++ b/admin/views/receiver/clues/edit.php
@@ -100,12 +100,6 @@
-
- |
-
- |
-
- |
|
@@ -215,6 +209,14 @@
|
+
+
+ |
@@ -503,6 +505,11 @@
},
});
},
+ randClass:function(){
+ var classArr = ['label-default','label-primary','label-success','label-info','label-warning','label-danger'];
+ var rand = Math.floor( Math.random() * classArr.length );
+ return classArr[rand]
+ }
},
watch:{
'info.city_id':function(nv, ov){
diff --git a/admin/views/receiver/customer/lists.php b/admin/views/receiver/customer/lists.php
index 92ee3e17..f5396720 100644
--- a/admin/views/receiver/customer/lists.php
+++ b/admin/views/receiver/customer/lists.php
@@ -34,6 +34,34 @@
+
+
@@ -150,20 +178,66 @@
data: {
params: [],
searchTpAry: [],
- lists: []
+ lists: [],
+ cityAry:[],
+ countyAry:[],
+ bizList:[],
},
mounted: function () {
var vm = this;
vm.params = =json_encode($params)?>;
vm.searchTpAry = =json_encode($searchTpAry)?>;
vm.lists = =json_encode($lists)?>;
+ this.init_citys();
},
methods: {
saveEdit: function () {
$("form").submit();
- }
+ },
+ init_citys:function(){
+ var vm = this;
+ $.get('common/area',{id:'350',key:'city',type:1},function(response){
+ if (response.code == 1) {
+ vm.cityAry = response.data;
+ }
+ });
+ if(vm.params.city_id>0){
+ $.get('common/area',{id:vm.params.city_id,key:'county',type:1},function(response){
+ if (response.code == 1) {
+ vm.countyAry = response.data;
+ }
+ });
+ }
+ },
},
- watch: {}
+ watch: {
+ 'params.city_id':function(nv, ov){
+ var that = this;
+ that.county_id = '';
+ if(nv == ''){
+ that.countyAry = [];
+ } else {
+ $.get('common/area',{id:nv,key:'county',type:1},function(response){
+ if (response.code == 1) {
+ that.countyAry = response.data;
+ }
+ });
+ $.post('receiver/clues/get_adviser',{city_id:that.params.city_id,county_id:that.params.county_id},function(response){
+ if (response.code == 1) {
+ that.bizList = response.data.bizList;
+ }
+ });
+ }
+ },
+ 'params.county_id':function(nv, ov){
+ var that = this;
+ $.post('receiver/clues/get_adviser',{city_id:that.params.city_id,county_id:that.params.county_id},function(response){
+ if (response.code == 1) {
+ that.bizList = response.data.bizList;
+ }
+ });
+ },
+ }
});
diff --git a/common/models/biz/Biz_model.php b/common/models/biz/Biz_model.php
index 59009e01..3b2d536b 100755
--- a/common/models/biz/Biz_model.php
+++ b/common/models/biz/Biz_model.php
@@ -49,4 +49,25 @@ class Biz_model extends HD_Model
return $map;
}
+ /**
+ * 根据经纬度获取附近门店
+ * @param $lat float 纬度
+ * @param $lng float 经度
+ * @param $page int 页码
+ * @param $size int 分页大小
+ */
+ public function nearby($lat,$lng,$page=1,$size=20,$filed='*' ){
+ $lat = (float)$lat;
+ $lng = (float)$lng;
+ $where = "status=1 and lat>0 and lng>0";
+
+ if($page){
+ $offset = ($page - 1) * $size;
+ $limit = $size;
+ }
+
+ $sql = "select {$filed},round(sqrt(pow(lat-{$lat},2)+pow(lng-{$lng},2)),5)*80000 as dis from lc_biz where {$where} order by dis asc limit {$offset},{$limit}";
+ $rows = $this->db->query($sql)->result_array();
+ return $rows;
+ }
}
|