ExpressController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace hd\controllers;
  3. use bizHd\express\classes\ExpressClass;
  4. use bizHd\merchant\services\ExpressService;
  5. use bizHd\merchant\services\ShopService;
  6. use bizHd\purchase\classes\PurchaseClass;
  7. use common\components\dict;
  8. use Yii;
  9. use common\components\util;
  10. class ExpressController extends BaseController
  11. {
  12. //获取采购单物流运单的轨迹 ssh 20250705
  13. public function actionGetCgExpressTrack()
  14. {
  15. $get = Yii::$app->request->get();
  16. $id = $get['id'] ?? 0;
  17. $cg = PurchaseClass::getById($id, true);
  18. if (empty($cg)) {
  19. util::fail('没有找到订单');
  20. }
  21. if ($cg->mainId != $this->mainId) {
  22. util::fail('不是你的订单');
  23. }
  24. $bizIdMap = dict::getDict('expressBizIdMap');
  25. if (getenv('YII_ENV') == 'production') {
  26. $bizId = $bizIdMap[$mainId] ?? 0;
  27. if (empty($bizId)) {
  28. util::fail('没有找到月结账号');
  29. }
  30. //暂时只支持顺丰
  31. $deliveryId = 'SF';
  32. } else {
  33. $deliveryId = 'TEST';
  34. $bizId = 'test_biz_id';
  35. }
  36. $params = [
  37. 'deliveryId' => $deliveryId,
  38. ];
  39. $respond = ExpressClass::getTrack($params, $cg);
  40. util::success($respond);
  41. }
  42. //计算客户距离和运费 ssh 2020.5.14
  43. public function actionGetUserDistance()
  44. {
  45. //经度
  46. $lng = Yii::$app->request->get('lng', '');
  47. //纬度
  48. $lat = Yii::$app->request->get('lat', '');
  49. if (empty($lng) || empty($lat)) {
  50. util::fail('经度或纬度不能为空');
  51. }
  52. $shopId = ShopService::getDefaultShopId($this->sj);
  53. $respond = ExpressService::getUserDistance($lng, $lat, $shopId, $this->sjExtend);
  54. util::success($respond);
  55. }
  56. // 获取字典中的 hasMap
  57. public function actionGetHasMap()
  58. {
  59. util::success(['hasMap' => dict::getDict('hasMap')]);
  60. }
  61. }