正在显示
1 个修改的文件
包含
189 行增加
和
196 行删除
@@ -309,213 +309,206 @@ class Index extends Api | @@ -309,213 +309,206 @@ class Index extends Api | ||
309 | } | 309 | } |
310 | $rult = Db::name('seller')->where($map3)->where($map)->where($map2)->order('weight asc')->page($param['pages'], $param['rows'])->select(); | 310 | $rult = Db::name('seller')->where($map3)->where($map)->where($map2)->order('weight asc')->page($param['pages'], $param['rows'])->select(); |
311 | $count = Db::name('seller')->where($map3)->where($map)->where($map2)->order('weight asc')->select(); | 311 | $count = Db::name('seller')->where($map3)->where($map)->where($map2)->order('weight asc')->select(); |
312 | - //asc | ||
313 | - $list = [ | ||
314 | - 'count' => 0, | ||
315 | - 'list' => [] | ||
316 | - ]; | ||
317 | - } else | ||
318 | -{ | ||
319 | - //计算距离 KM | ||
320 | -foreach ($rult as $k => $v) | ||
321 | -{ | ||
322 | -$ruestul[$k]['id'] = $v['id']; | ||
323 | -$ruestul[$k]['title'] = $v['title']; | ||
324 | -$ruestul[$k]['address'] = $v['address']; | ||
325 | -$ruestul[$k]['avatar'] = cdnurl($v['avatar']); | ||
326 | -$ruestul[$k]['order'] = $v['order']; | ||
327 | -if (empty($param['lng']) || $param['lng'] == null || $param['lng'] == '' || $param['lng'] == "") | ||
328 | -{ | ||
329 | -$ruestul[$k]['from'] = '暂无距离信息'; | ||
330 | -} | ||
331 | - | ||
332 | -else { | ||
333 | - $ruestul[$k]['from'] = $this->getDistance($param['lng'], $param['lat'], $v['lng'], $v['lat']) . 'km'; | ||
334 | -} | ||
335 | -$ruestul[$k]['talk_num'] = $v['talk_num']; | ||
336 | -} | ||
337 | -$newarr = array_column($ruestul, 'from'); | ||
338 | -array_multisort($newarr, SORT_ASC, $ruestul); | ||
339 | -$list = [ | ||
340 | - 'count' => count($count), | ||
341 | - 'list' => $ruestul | ||
342 | -]; | ||
343 | -} | ||
344 | -$this->success('成功', $list); | ||
345 | -} | 312 | + if (empty($rult)) { |
313 | + //如果为空 | ||
314 | + $list = [ | ||
315 | + 'count' => 0, | ||
316 | + 'list' => [] | ||
317 | + ]; | ||
318 | + } else { | ||
319 | + //计算距离 KM | ||
320 | + foreach ($rult as $k => $v) { | ||
321 | + $ruestul[$k]['id'] = $v['id']; | ||
322 | + $ruestul[$k]['title'] = $v['title']; | ||
323 | + $ruestul[$k]['address'] = $v['address']; | ||
324 | + $ruestul[$k]['avatar'] = cdnurl($v['avatar']); | ||
325 | + $ruestul[$k]['order'] = $v['order']; | ||
326 | + if (empty($param['lng']) || $param['lng'] == null || $param['lng'] == '' || $param['lng'] == "") { | ||
327 | + $ruestul[$k]['from'] = '暂无距离信息'; | ||
328 | + } else { | ||
329 | + $ruestul[$k]['from'] = $this->getDistance($param['lng'], $param['lat'], $v['lng'], $v['lat']) . 'km'; | ||
330 | + } | ||
331 | + $ruestul[$k]['talk_num'] = $v['talk_num']; | ||
332 | + } | ||
333 | + $newarr = array_column($ruestul, 'from'); | ||
334 | + array_multisort($newarr, SORT_ASC, $ruestul); | ||
335 | + $list = [ | ||
336 | + 'count' => count($count), | ||
337 | + 'list' => $ruestul | ||
338 | + ]; | ||
339 | + } | ||
340 | + $this->success('成功', $list); | ||
341 | + } | ||
346 | 342 | ||
347 | 343 | ||
348 | -/** | ||
349 | - * 首页接口 | ||
350 | - * @ApiTitle (首页接口-店铺详情) | ||
351 | - * @ApiSummary (店铺详情) | ||
352 | - * @ApiMethod (POST) | ||
353 | - * @ApiRoute (/api/Index/SellerCon) | ||
354 | - * @ApiParams (name="id", type="int", required=true, description="店铺ID") | ||
355 | - * @ApiParams (name="pages", type="int", required=true, description="pages") | ||
356 | - * @ApiParams (name="rows", type="int", required=true, description="rows") | ||
357 | - * @ApiReturnParams (name="code", type="integer", required=true, sample="0") | ||
358 | - * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功") | ||
359 | - * @ApiReturn ({ | ||
360 | -'code':'1', | ||
361 | -'msg':'返回成功', | ||
362 | -"data": { | ||
363 | -"id": 3, | ||
364 | -"avatar": "http://xiche.qiniu.bronet.cn/uploads/20200831/FsGkAQhqnwBodzLvJyn1rtbZIFUd.png", | ||
365 | -"title": "这是第三个店铺", | ||
366 | -"opentime": "8:00-9:00", | ||
367 | -"address": "北京市北京市海淀区吴玉章路", | ||
368 | -"mobile": "1391929399", | ||
369 | -"content": "<p>这是第三个商家的详情</p>", | ||
370 | -"num": 3, //平均评分 | ||
371 | -"talkList": { | ||
372 | -"count": 1,//评论总数 | ||
373 | -"talk": [ | ||
374 | -{ | ||
375 | -"id": 1, //评论id | ||
376 | -"num": 3, //评分 | ||
377 | -"createtime": "1970-05-09", //评论时间 | ||
378 | -"avatar": "https://thirdwx.qlogo.cn/mmopen/vi_32/0wpUDw5m0LRvdDueia3uMWmrYb53GXRaTnYwMWC18kRmX6P6PIaPDgQqarEIfwroicx1z51D6bjQicOV0PibBx2PqQ/132", | ||
379 | -"nickname": "Gody", | ||
380 | -"images": [ //评论图 | ||
381 | -"http://xiche.qiniu.bronet.cn/uploads/20200831/FsGkAQhqnwBodzLvJyn1rtbZIFUd.png", | ||
382 | -"http://xiche.qiniu.bronet.cn/uploads/20200831/FsGkAQhqnwBodzLvJyn1rtbZIFUd.png" | ||
383 | -] | ||
384 | -} | ||
385 | -] | ||
386 | -} | ||
387 | -} | ||
388 | -}) | ||
389 | - */ | ||
390 | -public | ||
391 | -function SellerCon() | ||
392 | -{ | ||
393 | - $param = $this->request->param(); | ||
394 | - $seller_arr = Db::name('seller')->where('id', $param['id'])->find(); | ||
395 | - if (empty($seller_arr)) { | ||
396 | - $this->error('参数错误', 0); | ||
397 | - die; | 344 | + /** |
345 | + * 首页接口 | ||
346 | + * @ApiTitle (首页接口-店铺详情) | ||
347 | + * @ApiSummary (店铺详情) | ||
348 | + * @ApiMethod (POST) | ||
349 | + * @ApiRoute (/api/Index/SellerCon) | ||
350 | + * @ApiParams (name="id", type="int", required=true, description="店铺ID") | ||
351 | + * @ApiParams (name="pages", type="int", required=true, description="pages") | ||
352 | + * @ApiParams (name="rows", type="int", required=true, description="rows") | ||
353 | + * @ApiReturnParams (name="code", type="integer", required=true, sample="0") | ||
354 | + * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功") | ||
355 | + * @ApiReturn ({ | ||
356 | + 'code':'1', | ||
357 | + 'msg':'返回成功', | ||
358 | + "data": { | ||
359 | + "id": 3, | ||
360 | + "avatar": "http://xiche.qiniu.bronet.cn/uploads/20200831/FsGkAQhqnwBodzLvJyn1rtbZIFUd.png", | ||
361 | + "title": "这是第三个店铺", | ||
362 | + "opentime": "8:00-9:00", | ||
363 | + "address": "北京市北京市海淀区吴玉章路", | ||
364 | + "mobile": "1391929399", | ||
365 | + "content": "<p>这是第三个商家的详情</p>", | ||
366 | + "num": 3, //平均评分 | ||
367 | + "talkList": { | ||
368 | + "count": 1,//评论总数 | ||
369 | + "talk": [ | ||
370 | + { | ||
371 | + "id": 1, //评论id | ||
372 | + "num": 3, //评分 | ||
373 | + "createtime": "1970-05-09", //评论时间 | ||
374 | + "avatar": "https://thirdwx.qlogo.cn/mmopen/vi_32/0wpUDw5m0LRvdDueia3uMWmrYb53GXRaTnYwMWC18kRmX6P6PIaPDgQqarEIfwroicx1z51D6bjQicOV0PibBx2PqQ/132", | ||
375 | + "nickname": "Gody", | ||
376 | + "images": [ //评论图 | ||
377 | + "http://xiche.qiniu.bronet.cn/uploads/20200831/FsGkAQhqnwBodzLvJyn1rtbZIFUd.png", | ||
378 | + "http://xiche.qiniu.bronet.cn/uploads/20200831/FsGkAQhqnwBodzLvJyn1rtbZIFUd.png" | ||
379 | + ] | ||
398 | } | 380 | } |
399 | - $list = [ | ||
400 | - 'id' => $seller_arr['id'], | ||
401 | - 'avatar' => cdnurl($seller_arr['avatar']), | ||
402 | - 'title' => $seller_arr['title'], | ||
403 | - 'opentime' => $seller_arr['opentime'], | ||
404 | - 'address' => $seller_arr['address'], | ||
405 | - 'lng' => $seller_arr['lng'], | ||
406 | - 'lat' => $seller_arr['lat'], | ||
407 | - 'mobile' => $seller_arr['mobile'], | ||
408 | - 'content' => $seller_arr['content'] | ||
409 | - ]; | ||
410 | - $talk_arr = Db::name('seller_talk') | ||
411 | - ->alias('s') | ||
412 | - ->join('user u', 'u.id=s.user_id') | ||
413 | - ->where('seller_id', $param['id']) | ||
414 | - ->order('id desc') | ||
415 | - ->page($param['pages'], $param['rows']) | ||
416 | - ->field('s.id,s.num,s.title,s.images,s.createtime,u.avatar,u.nickname') | ||
417 | - ->select(); | ||
418 | - $count = Db::name('seller_talk') | ||
419 | - ->alias('s') | ||
420 | - ->join('user u', 'u.id=s.user_id') | ||
421 | - ->where('seller_id', $param['id']) | ||
422 | - ->order('id desc') | ||
423 | - ->field('s.id,s.num,s.title,s.images,s.createtime,u.avatar,u.nickname') | ||
424 | - ->select(); | ||
425 | - if (empty($talk_arr)) { | ||
426 | - $list['num'] = 5; | ||
427 | - $list['talkList'] = [ | ||
428 | - 'count' => 0, | ||
429 | - 'talk' => [] | 381 | + ] |
382 | + } | ||
383 | + } | ||
384 | + }) | ||
385 | + */ | ||
386 | + public function SellerCon() | ||
387 | + { | ||
388 | + $param = $this->request->param(); | ||
389 | + $seller_arr = Db::name('seller')->where('id', $param['id'])->find(); | ||
390 | + if (empty($seller_arr)) { | ||
391 | + $this->error('参数错误', 0); | ||
392 | + die; | ||
393 | + } | ||
394 | + $list = [ | ||
395 | + 'id' => $seller_arr['id'], | ||
396 | + 'avatar' => cdnurl($seller_arr['avatar']), | ||
397 | + 'title' => $seller_arr['title'], | ||
398 | + 'opentime' => $seller_arr['opentime'], | ||
399 | + 'address' => $seller_arr['address'], | ||
400 | + 'lng' => $seller_arr['lng'], | ||
401 | + 'lat' => $seller_arr['lat'], | ||
402 | + 'mobile' => $seller_arr['mobile'], | ||
403 | + 'content' => $seller_arr['content'] | ||
430 | ]; | 404 | ]; |
431 | - } else { | ||
432 | - $sum = array_sum(array_column($count, 'num')); | ||
433 | - $list['num'] = ($sum + 5) / (count($count) + 1); | ||
434 | - foreach ($talk_arr as $k => $v) { | ||
435 | - $talkList[$k]['id'] = $v['id']; | ||
436 | - $talkList[$k]['num'] = $v['num']; | ||
437 | - $talkList[$k]['createtime'] = date('Y-m-d', $v['createtime']); | ||
438 | - $talkList[$k]['avatar'] = $v['avatar']; | ||
439 | - $talkList[$k]['nickname'] = $v['nickname']; | ||
440 | - $talkList[$k]['title'] = $v['title']; | ||
441 | - if (empty($v['images'])) { | ||
442 | - $talkList[$k]['images'] = []; | ||
443 | - } else { | ||
444 | - if (strstr($v['images'], ',')) { | ||
445 | - $image = explode(',', $v['images']); | 405 | + $talk_arr = Db::name('seller_talk') |
406 | + ->alias('s') | ||
407 | + ->join('user u', 'u.id=s.user_id') | ||
408 | + ->where('seller_id', $param['id']) | ||
409 | + ->order('id desc') | ||
410 | + ->page($param['pages'], $param['rows']) | ||
411 | + ->field('s.id,s.num,s.title,s.images,s.createtime,u.avatar,u.nickname') | ||
412 | + ->select(); | ||
413 | + $count = Db::name('seller_talk') | ||
414 | + ->alias('s') | ||
415 | + ->join('user u', 'u.id=s.user_id') | ||
416 | + ->where('seller_id', $param['id']) | ||
417 | + ->order('id desc') | ||
418 | + ->field('s.id,s.num,s.title,s.images,s.createtime,u.avatar,u.nickname') | ||
419 | + ->select(); | ||
420 | + if (empty($talk_arr)) { | ||
421 | + $list['num'] = 5; | ||
422 | + $list['talkList'] = [ | ||
423 | + 'count' => 0, | ||
424 | + 'talk' => [] | ||
425 | + ]; | ||
426 | + } else { | ||
427 | + $sum = array_sum(array_column($count, 'num')); | ||
428 | + $list['num'] = ($sum + 5) / (count($count) + 1); | ||
429 | + foreach ($talk_arr as $k => $v) { | ||
430 | + $talkList[$k]['id'] = $v['id']; | ||
431 | + $talkList[$k]['num'] = $v['num']; | ||
432 | + $talkList[$k]['createtime'] = date('Y-m-d', $v['createtime']); | ||
433 | + $talkList[$k]['avatar'] = $v['avatar']; | ||
434 | + $talkList[$k]['nickname'] = $v['nickname']; | ||
435 | + $talkList[$k]['title'] = $v['title']; | ||
436 | + if (empty($v['images'])) { | ||
437 | + $talkList[$k]['images'] = []; | ||
446 | } else { | 438 | } else { |
447 | - $image = explode(' ', $v['images']); | 439 | + if (strstr($v['images'], ',')) { |
440 | + $image = explode(',', $v['images']); | ||
441 | + } else { | ||
442 | + $image = explode(' ', $v['images']); | ||
443 | + } | ||
444 | + foreach ($image as $k1 => $v1) { | ||
445 | + $image[$k1] = cdnurl($v1); | ||
446 | + } | ||
447 | + $talkList[$k]['images'] = $image; | ||
448 | } | 448 | } |
449 | - foreach ($image as $k1 => $v1) { | ||
450 | - $image[$k1] = cdnurl($v1); | ||
451 | - } | ||
452 | - $talkList[$k]['images'] = $image; | ||
453 | } | 449 | } |
450 | + $list['talkList'] = [ | ||
451 | + 'count' => count($count), | ||
452 | + 'talk' => $talkList | ||
453 | + ]; | ||
454 | } | 454 | } |
455 | - $list['talkList'] = [ | ||
456 | - 'count' => count($count), | ||
457 | - 'talk' => $talkList | ||
458 | - ]; | 455 | + $this->success('成功', $list); |
459 | } | 456 | } |
460 | - $this->success('成功', $list); | ||
461 | -} | ||
462 | 457 | ||
463 | 458 | ||
464 | -/** | ||
465 | - * 首页接口 | ||
466 | - * @ApiTitle (首页接口-添加评论) | ||
467 | - * @ApiSummary (添加评论) | ||
468 | - * @ApiMethod (POST) | ||
469 | - * @ApiRoute (/api/Index/TalkSave) | ||
470 | - * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
471 | - * @ApiParams (name="seller_id", type="int", required=true, description="商家ID") | ||
472 | - * @ApiParams (name="title", type="int", required=true, description="评论内容") | ||
473 | - * @ApiParams (name="images", type="int", required=true, description="评论图") | ||
474 | - * @ApiParams (name="num", type="int", required=true, description="评分") | ||
475 | - * @ApiReturnParams (name="code", type="integer", required=true, sample="0") | ||
476 | - * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功") | ||
477 | - * @ApiReturn ({ | ||
478 | -'code':'1', | ||
479 | -'msg':'返回成功', | ||
480 | -}) | ||
481 | - */ | ||
482 | -public | ||
483 | -function TalkSave() | ||
484 | -{ | ||
485 | - $param = $this->request->param(); | ||
486 | - $user_id = $this->is_token($this->request->header()); | ||
487 | - $data = [ | ||
488 | - 'seller_id' => $param['seller_id'], | ||
489 | - 'user_id' => $user_id, | ||
490 | - 'title' => $param['title'], | ||
491 | - 'num' => $param['num'], | ||
492 | - 'images' => $param['images'], | ||
493 | - 'createtime' => time(), | ||
494 | - ]; | ||
495 | - $res = Db::name('seller_talk')->insert($data); | ||
496 | - $talk_num = Db::name('seller')->where('id', $param['seller_id'])->value('talk_num'); | ||
497 | - Db::name('seller')->where('id', $param['seller_id'])->update(['talk_num' => $talk_num + 1]); | ||
498 | - $this->res($res); | ||
499 | -} | 459 | + /** |
460 | + * 首页接口 | ||
461 | + * @ApiTitle (首页接口-添加评论) | ||
462 | + * @ApiSummary (添加评论) | ||
463 | + * @ApiMethod (POST) | ||
464 | + * @ApiRoute (/api/Index/TalkSave) | ||
465 | + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
466 | + * @ApiParams (name="seller_id", type="int", required=true, description="商家ID") | ||
467 | + * @ApiParams (name="title", type="int", required=true, description="评论内容") | ||
468 | + * @ApiParams (name="images", type="int", required=true, description="评论图") | ||
469 | + * @ApiParams (name="num", type="int", required=true, description="评分") | ||
470 | + * @ApiReturnParams (name="code", type="integer", required=true, sample="0") | ||
471 | + * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功") | ||
472 | + * @ApiReturn ({ | ||
473 | + 'code':'1', | ||
474 | + 'msg':'返回成功', | ||
475 | + }) | ||
476 | + */ | ||
477 | + public function TalkSave() | ||
478 | + { | ||
479 | + $param = $this->request->param(); | ||
480 | + $user_id = $this->is_token($this->request->header()); | ||
481 | + $data = [ | ||
482 | + 'seller_id' => $param['seller_id'], | ||
483 | + 'user_id' => $user_id, | ||
484 | + 'title' => $param['title'], | ||
485 | + 'num' => $param['num'], | ||
486 | + 'images' => $param['images'], | ||
487 | + 'createtime' => time(), | ||
488 | + ]; | ||
489 | + $res = Db::name('seller_talk')->insert($data); | ||
490 | + $talk_num = Db::name('seller')->where('id', $param['seller_id'])->value('talk_num'); | ||
491 | + Db::name('seller')->where('id', $param['seller_id'])->update(['talk_num' => $talk_num + 1]); | ||
492 | + $this->res($res); | ||
493 | + } | ||
500 | 494 | ||
501 | 495 | ||
502 | -/** | ||
503 | - * 首页接口 | ||
504 | - * @ApiTitle (首页接口-联系客服文字) | ||
505 | - * @ApiSummary (联系客服文字) | ||
506 | - * @ApiMethod (POST) | ||
507 | - * @ApiRoute (/api/Index/Lianxi) | ||
508 | - * @ApiReturnParams (name="code", type="integer", required=true, sample="0") | ||
509 | - * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功") | ||
510 | - * @ApiReturn ({ | ||
511 | -'code':'1', | ||
512 | -'msg':'返回成功', | ||
513 | -}) | ||
514 | - */ | ||
515 | -public | ||
516 | -function Lianxi() | ||
517 | -{ | ||
518 | - $title = Db::name('lianxi')->where('id', 1)->value('title'); | ||
519 | - $this->success('成功', $title); | ||
520 | -} | 496 | + /** |
497 | + * 首页接口 | ||
498 | + * @ApiTitle (首页接口-联系客服文字) | ||
499 | + * @ApiSummary (联系客服文字) | ||
500 | + * @ApiMethod (POST) | ||
501 | + * @ApiRoute (/api/Index/Lianxi) | ||
502 | + * @ApiReturnParams (name="code", type="integer", required=true, sample="0") | ||
503 | + * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功") | ||
504 | + * @ApiReturn ({ | ||
505 | + 'code':'1', | ||
506 | + 'msg':'返回成功', | ||
507 | + }) | ||
508 | + */ | ||
509 | + public function Lianxi() | ||
510 | + { | ||
511 | + $title = Db::name('lianxi')->where('id', 1)->value('title'); | ||
512 | + $this->success('成功', $title); | ||
513 | + } | ||
521 | } | 514 | } |
-
请 注册 或 登录 后发表评论