ExpressController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace mall\controllers;
  3. use bizMall\order\classes\OrderClass;
  4. use common\components\dict;
  5. use Yii;
  6. use common\components\util;
  7. class ExpressController extends BaseController
  8. {
  9. //计算距离和运费【另外还有个地方要同步修改,关键词calc_freight_distance】 ssh 20221003
  10. public function actionGetUserDistance()
  11. {
  12. $get = Yii::$app->request->get();
  13. $lng = $get['lng'] ?? '';
  14. $lat = $get['lat'] ?? '';
  15. //花束重量默认1.5
  16. $weight = 1.5;
  17. if (empty($lng) || empty($lat)) {
  18. util::fail('请填写收花地址吧');
  19. }
  20. $shop = $this->shop;
  21. $shopLong = $shop->long ?? '';
  22. $shopLat = $shop->lat ?? '';
  23. if (empty($shopLong) || empty($shopLat)) {
  24. util::fail('门店地址有问题');
  25. }
  26. $respond = OrderClass::getDistanceFee($lat, $lng, $shopLat, $shopLong, $weight);
  27. $distance = $respond['distance'] ?? 0;
  28. $showDistance = $respond['showDistance'] ?? 0;
  29. $fee = $respond['fee'] ?? 0;
  30. util::success(['distance' => $distance, 'showDistance' => $showDistance, 'fee' => $fee]);
  31. }
  32. // 获取字典中的 hasMap
  33. public function actionGetHasMap()
  34. {
  35. // 补充店铺信息
  36. $shop = [];
  37. $intraCityRet = \biz\shop\classes\ShopClass::hasIntraCity($this->shop);
  38. $shop['openIntraCity'] = $intraCityRet['openIntraCity'];
  39. $shop['hcFreeKm'] = $intraCityRet['hcFreeKm'];
  40. $shop['hcMap'] = $intraCityRet['hcMap'];
  41. $shop['hsFreeKm'] = $intraCityRet['hsFreeKm'];
  42. $shop['hsAddFee'] = $intraCityRet['hsAddFee'];
  43. util::success(['hasMap' => dict::getDict('hasMap'), 'shop'=>$shop]);
  44. }
  45. }