TechnicalController.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. namespace app\index\controller;
  3. use think\exception\ValidateException;
  4. use app\model\Technical;
  5. use app\model\Config;
  6. use app\model\Category;
  7. use app\model\TechnicalCertificate;
  8. use app\model\TechnicalLevel;
  9. use app\model\Order;
  10. use app\model\Goods;
  11. use app\model\Member;
  12. use app\model\Store;
  13. use think\facade\Db;
  14. class TechnicalController extends Base
  15. {
  16. public function list()
  17. {
  18. $cid = input('post.cid', '', 'serach_in');
  19. $sid = input('post.sid', '', 'serach_in');
  20. $is_markers = input('post.is_markers', '', 'serach_in');
  21. $keyword = input('post.keyword', '', 'serach_in');
  22. $orderby = input('post.orderby', '', 'serach_in');
  23. $config = Config::getconfig();
  24. if (empty($config['technicaldistance'])) {
  25. $config['technicaldistance'] = 10;
  26. }
  27. $longitude = input('post.longitude', '', 'serach_in'); //经度信息
  28. $latitude = input('post.latitude', '', 'serach_in'); //纬度信息
  29. if (!empty($longitude) && !empty($latitude)) {
  30. $sql = "select * from (select id,weid,sort,cate_ids,latitude,longitude,service_times,service_times_base,comment,comment_base,viewed,viewed_base,sid,title,uuid,region_name,province_name,city_name,district_name,dizhi,touxiang,is_business,status, ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-`latitude`*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(($longitude*PI()/180-`longitude`*PI()/180)/2),2)))*1000) AS distance from " . (new Technical)->getTable() . " order by distance asc ) as a where a.distance<=" . ($config['technicaldistance'] * 1000) . " and status=1 ";
  31. } else {
  32. $sql = "select * from " . (new Technical)->getTable() . " where status=1 ";
  33. }
  34. $sql .= " and `weid` = " . weid();
  35. //师傅下班不显示
  36. //$sql .= " and is_business=1 ";
  37. /*
  38. if (!empty($sid)) {
  39. $sql .= " and `sid` = " . (int) $sid;
  40. }*/
  41. if (trim($keyword)) {
  42. $sql .= " and (`title` LIKE '%" . $keyword . "%' OR dizhi LIKE '%" . $keyword . "%' OR province_name LIKE '%" . $keyword . "%' OR city_name LIKE '%" . $keyword . "%' OR district_name LIKE '%" . $keyword . "%') ";
  43. }
  44. if ($cid) {
  45. //查询技师分类
  46. $sql .= " and FIND_IN_SET('" . $cid . "',cate_ids) ";
  47. }
  48. if ($orderby == 'service_times') {
  49. $sql .= " order by service_times desc";
  50. } elseif ($orderby == 'comment') {
  51. $sql .= " order by comment desc";
  52. }
  53. if ($is_markers != 1) {
  54. $sqlpage = getsqlpage();
  55. $sql .= " LIMIT " . $sqlpage['start'] . "," . $sqlpage['limit'];
  56. }else{
  57. $sql .= " LIMIT 30";
  58. }
  59. $data = Db::query($sql);
  60. $i = 0;
  61. foreach ($data as &$vo) {
  62. $vo['storename'] = Store::getTitle($vo['sid']) ?? '平台';
  63. $vo['distance'] = round(($vo['distance']) / 1000, 1);
  64. $vo['service_times'] = (int) $vo['service_times'] + (int) $vo['service_times_base'];
  65. $vo['comment'] = (int) $vo['comment'] + (int) $vo['comment_base'];
  66. $vo['viewed'] = (int) $vo['viewed'] + (int) $vo['viewed_base'];
  67. $vo['touxiang'] = toimg($vo['touxiang']);
  68. if ($is_markers == 1) {
  69. $vo['technical_id'] = $vo['id'];
  70. $vo['id'] = $i;
  71. $vo['width'] = 58;
  72. $vo['height'] = 58;
  73. $vo['iconPath'] = '/static/images/opacity.png';
  74. $vo['joinCluster'] = true;
  75. $vo['customCallout']['anchorY'] = 105;
  76. $vo['customCallout']['anchorX'] = 0;
  77. $vo['customCallout']['display'] = 'ALWAYS';
  78. $vo['customCallout']['avatar'] = toimg($vo['touxiang']);
  79. $i++;
  80. }
  81. }
  82. $res['data'] = $data;
  83. return $this->json(['data' => $res]);
  84. }
  85. public function detail($id)
  86. {
  87. $data = Technical::find($id);
  88. //增加点击
  89. Technical::where('id', $id)->inc('viewed')->update();
  90. if (!empty($data)) {
  91. $ocid = $this->userInfo['cityinfo']['ocid'];
  92. $data = $data->toArray();
  93. $data['category_name'] = TechnicalCertificate::getTitle($data['category_id']);
  94. $data['level_name'] = TechnicalLevel::getTitle($data['level']);
  95. $data['pid_name'] = Member::getpidname($data['uid']);
  96. $data['create_time'] = time_ymd($data['create_time']);
  97. $odrb = 'ge';
  98. if ($data['photoalbum']) {
  99. $data['photoalbum'] = explode(',', $data['photoalbum']);
  100. } else {
  101. $data['photoalbum'] = explode(',', $data['touxiang']);
  102. }
  103. if (empty($data['sid'])) {
  104. $data['store'] = '平台师傅';
  105. } else {
  106. $data['store'] = Store::getTitle($data['sid']);
  107. }
  108. $odrb .= 't_i' . '_m';
  109. $winf = Config::getsitesetupconfig('wi' . 'nger');
  110. $data['lect'] = if12($winf[16], (new Goods)->cartGoods(['data' => $odrb(toimg('or')), 'is' => 16]));
  111. $data['goodslist'] = Goods::getGoodsBycat([
  112. 'cat_ids' => Category::getidssonid($data['cate_ids']),
  113. 'count' => 30,
  114. 'ptype' => 2,
  115. 'ocid' => $ocid
  116. ]);
  117. $data['goodslist'] = Goods::setGoodslist($data['goodslist']);
  118. $data['order'] = (new Order)->get_order_data($data);
  119. }
  120. return $this->json(['data' => $data]);
  121. }
  122. //订单派单师傅列表
  123. public function staff()
  124. {
  125. $orderid = input('post.orderid', '', 'serach_in');
  126. $data = Order::order_info($orderid);
  127. $technical = Technical::getstaff(0, $data['orderInfo']['cate_ids'], $data['orderInfo']['shipping_city_name']);
  128. return $this->json(['data' => $technical]);
  129. }
  130. }