添加:兑换站点列表接口,并且支持定位及导航
This commit is contained in:
parent
59c49dea4e
commit
d02ba3c6f3
|
|
@ -26,6 +26,8 @@ class ExchangePickupPointRepository extends BaseRepository{
|
||||||
$info->address = $params['address'];
|
$info->address = $params['address'];
|
||||||
$info->is_show = $params['is_show'];
|
$info->is_show = $params['is_show'];
|
||||||
$info->uid_list = implode(',',$params['uid_list']);
|
$info->uid_list = implode(',',$params['uid_list']);
|
||||||
|
$info->lat = $params['lat'];
|
||||||
|
$info->lng = $params['lng'];
|
||||||
|
|
||||||
$info->save();
|
$info->save();
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +44,13 @@ class ExchangePickupPointRepository extends BaseRepository{
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getList(array $params,int $page,int $limit):array{
|
public function getList(array $params,int $page,int $limit):array{
|
||||||
|
// 查询
|
||||||
$query = $this->dao->getSearch([])
|
$query = $this->dao->getSearch([])
|
||||||
|
->when((isset($params['lng']) && $params['lng'] > 0) && (isset($params['lat']) && $params['lat'] > 0),function($query) use ($params){
|
||||||
|
$distance = "ROUND((ST_DISTANCE(point(lng, lat), point({$params['lng']}, {$params['lat']})) * 111195),2)";
|
||||||
|
$query->field("*,{$distance} as distance")
|
||||||
|
->orderRaw("{$distance} ASC");
|
||||||
|
})
|
||||||
->when((int)$params['uid'] > 0,function($query) use ($params){
|
->when((int)$params['uid'] > 0,function($query) use ($params){
|
||||||
$query->where('find_in_set(' . $params['uid'] . ',`uid_list`)');
|
$query->where('find_in_set(' . $params['uid'] . ',`uid_list`)');
|
||||||
})
|
})
|
||||||
|
|
@ -56,9 +64,16 @@ class ExchangePickupPointRepository extends BaseRepository{
|
||||||
$query->where('address', "like", "%{$params['address']}%")
|
$query->where('address', "like", "%{$params['address']}%")
|
||||||
->whereOr('title','like',"%{$params['address']}%");
|
->whereOr('title','like',"%{$params['address']}%");
|
||||||
})
|
})
|
||||||
->order('create_time DESC,id DESC');
|
->order("create_time DESC,id DESC");
|
||||||
$count = $query->count();
|
$count = $query->count();
|
||||||
$list = $query->page($page,$limit)->append(['user_list'])->select();
|
$list = $query->page($page,$limit)->append(['user_list'])->select()->each(function($item){
|
||||||
|
if($item->distance > 0){
|
||||||
|
if ($item->distance < 100) $item->distance_text = '100m以内';
|
||||||
|
else $item->distance_text = sprintf("%.2f",$item->distance / 1000).'km';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
});
|
||||||
|
|
||||||
return compact('count','list');
|
return compact('count','list');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -401,7 +401,7 @@ class Common extends BaseController
|
||||||
|
|
||||||
public function config()
|
public function config()
|
||||||
{
|
{
|
||||||
$config = systemConfig(['delivery_type', 'delivery_status', 'sms_use_type', 'hot_ranking_lv', 'hot_ranking_switch']);
|
$config = systemConfig(['delivery_type', 'delivery_status', 'sms_use_type', 'hot_ranking_lv', 'hot_ranking_switch','tx_map_key']);
|
||||||
return app('json')->success($config);
|
return app('json')->success($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -127,10 +127,11 @@ class ExchangeQuota extends BaseController
|
||||||
*/
|
*/
|
||||||
public function pickupPointEdit(){
|
public function pickupPointEdit(){
|
||||||
// 参数获取
|
// 参数获取
|
||||||
$params = $this->request->params(['id','title','address','is_show','uid_list']);
|
$params = $this->request->params(['id','title','address','is_show','uid_list','lat','lng']);
|
||||||
if(empty($params['title'])) return app('json')->fail('请输入提货点名称!');
|
if(empty($params['title'])) return app('json')->fail('请输入提货点名称!');
|
||||||
if(empty($params['address'])) return app('json')->fail('请输入提货点地址!');
|
if(empty($params['address'])) return app('json')->fail('请输入提货点地址!');
|
||||||
if(!is_array($params['uid_list']) || count($params['uid_list']) <= 0) return app('json')->fail('请至少选择一个负责人!');
|
if(!is_array($params['uid_list']) || count($params['uid_list']) <= 0) return app('json')->fail('请至少选择一个负责人!');
|
||||||
|
if(empty($params['lat']) || empty($params['lng'])) return app('json')->fail('请选择经纬度!');
|
||||||
// 判断:地址是否已经存在
|
// 判断:地址是否已经存在
|
||||||
$isHave = ExchangePickupPoint::where('address',$params['address'])
|
$isHave = ExchangePickupPoint::where('address',$params['address'])
|
||||||
->when((int)$params['id'] > 0,function($query) use ($params){
|
->when((int)$params['id'] > 0,function($query) use ($params){
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,7 @@ use app\common\repositories\user\ExchangeQuotaRepository;
|
||||||
use app\common\repositories\user\UserRepository;
|
use app\common\repositories\user\UserRepository;
|
||||||
use crmeb\basic\BaseController;
|
use crmeb\basic\BaseController;
|
||||||
use crmeb\services\QrcodeService;
|
use crmeb\services\QrcodeService;
|
||||||
use crmeb\services\wechat\MiniProgram;
|
|
||||||
use think\App;
|
use think\App;
|
||||||
use think\exception\ValidateException;
|
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
class Exchange extends BaseController{
|
class Exchange extends BaseController{
|
||||||
|
|
@ -24,7 +22,6 @@ class Exchange extends BaseController{
|
||||||
|
|
||||||
public function __construct(App $app){
|
public function __construct(App $app){
|
||||||
parent::__construct($app);
|
parent::__construct($app);
|
||||||
$this->user = $this->request->userInfo();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Common: 获取用户持有信息
|
* Common: 获取用户持有信息
|
||||||
|
|
@ -35,6 +32,7 @@ class Exchange extends BaseController{
|
||||||
public function getUserHold(){
|
public function getUserHold(){
|
||||||
$params = $this->request->params(['consume_uid']);
|
$params = $this->request->params(['consume_uid']);
|
||||||
$uid = $this->request->uid();
|
$uid = $this->request->uid();
|
||||||
|
$user = $this->request->userInfo();
|
||||||
// 判断:是否存在指定消费者,不存在则使用当前登录用户
|
// 判断:是否存在指定消费者,不存在则使用当前登录用户
|
||||||
$uid = (int)$params['consume_uid'] > 0 ? (int)$params['consume_uid'] : $uid;
|
$uid = (int)$params['consume_uid'] > 0 ? (int)$params['consume_uid'] : $uid;
|
||||||
// 获取额度
|
// 获取额度
|
||||||
|
|
@ -48,7 +46,7 @@ class Exchange extends BaseController{
|
||||||
->where('uid',$uid)
|
->where('uid',$uid)
|
||||||
->findOrEmpty();
|
->findOrEmpty();
|
||||||
$info->available = (float)$info->available;
|
$info->available = (float)$info->available;
|
||||||
$info->available_integral = (float)$this->user->exchange_integral;
|
$info->available_integral = (float)$user->exchange_integral;
|
||||||
$info->diff_rate = 30;// 差价 应补金额,默认为30%
|
$info->diff_rate = 30;// 差价 应补金额,默认为30%
|
||||||
|
|
||||||
return app('json')->success($info);
|
return app('json')->success($info);
|
||||||
|
|
@ -60,9 +58,11 @@ class Exchange extends BaseController{
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getPointList(){
|
public function getPointList(){
|
||||||
$search = $this->request->params(['uid', 'address', 'default_point_id']);
|
$search = $this->request->params(['uid', 'address', 'default_point_id','lng','lat']);
|
||||||
$search['is_show'] = 1;
|
$search['is_show'] = 1;
|
||||||
$data = app()->make(ExchangePickupPointRepository::class)->getList($search, 1, 30);
|
$make = app()->make(ExchangePickupPointRepository::class);
|
||||||
|
[$page, $limit] = $this->getPage();
|
||||||
|
$data = $make->getList($search, $page, $limit);
|
||||||
$list = $data['list'];
|
$list = $data['list'];
|
||||||
|
|
||||||
return app('json')->success($list);
|
return app('json')->success($list);
|
||||||
|
|
|
||||||
|
|
@ -349,7 +349,6 @@ Route::group('api/', function () {
|
||||||
// 商品兑换
|
// 商品兑换
|
||||||
Route::group('exchange', function () {
|
Route::group('exchange', function () {
|
||||||
// 兑换相关
|
// 兑换相关
|
||||||
Route::get('pointList', 'Exchange/getPointList');
|
|
||||||
Route::get('userHold', 'Exchange/getUserHold');
|
Route::get('userHold', 'Exchange/getUserHold');
|
||||||
Route::get('exchangeHandle', 'Exchange/exchangeHandle');
|
Route::get('exchangeHandle', 'Exchange/exchangeHandle');
|
||||||
Route::get('exchangeRecord', 'Exchange/exchangeRecord');
|
Route::get('exchangeRecord', 'Exchange/exchangeRecord');
|
||||||
|
|
@ -366,6 +365,10 @@ Route::group('api/', function () {
|
||||||
|
|
||||||
//非强制登录
|
//非强制登录
|
||||||
Route::group(function () {
|
Route::group(function () {
|
||||||
|
// 商品兑换
|
||||||
|
Route::get('exchange/pointList', 'api.user.Exchange/getPointList');
|
||||||
|
|
||||||
|
|
||||||
// 付费会员
|
// 付费会员
|
||||||
Route::group('svip', function () {
|
Route::group('svip', function () {
|
||||||
//价格列表
|
//价格列表
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue