shish 1 anno fa
parent
commit
3d74998baa

+ 3 - 6
app-ghs/controllers/ExpressController.php

@@ -5,6 +5,7 @@ namespace ghs\controllers;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\express\classes\ExpressClass;
 use bizGhs\order\classes\OrderClass;
+use common\components\dict;
 use common\components\imgUtil;
 use common\components\util;
 use Yii;
@@ -28,6 +29,7 @@ class ExpressController extends BaseController
         if (empty($fhWlNo)) {
             util::fail('没有找到物流单');
         }
+        $bizIdMap = dict::getDict('expressBizIdMap');
         if (getenv('YII_ENV') == 'production') {
             $bizId = $bizIdMap[$mainId] ?? 0;
             if (empty($bizId)) {
@@ -95,12 +97,7 @@ class ExpressController extends BaseController
             util::fail('没有找到客户');
         }
         //要先去后台绑定,这里填写才有用,mainId对应月结账号
-        $bizIdMap = [
-            //长春花路鲜花,
-            '36707' => '4212960899',
-            //龙岩花掌柜
-            '50' => '5925274162',
-        ];
+        $bizIdMap = dict::getDict('expressBizIdMap');
         $mainId = $this->mainId;
 
         if (getenv('YII_ENV') == 'production') {

+ 48 - 14
app-hd/controllers/ExpressController.php

@@ -2,8 +2,11 @@
 
 namespace hd\controllers;
 
+use bizHd\express\classes\ExpressClass;
 use bizHd\merchant\services\ExpressService;
 use bizHd\merchant\services\ShopService;
+use bizHd\purchase\classes\PurchaseClass;
+use common\components\dict;
 use Yii;
 use yii\web\Controller;
 use common\components\util;
@@ -11,19 +14,50 @@ use common\components\util;
 class ExpressController extends BaseController
 {
 
-	//计算客户距离和运费 ssh 2020.5.14
-	public function actionGetUserDistance()
-	{
-		//经度
-		$lng = Yii::$app->request->get('lng', '');
-		//纬度
-		$lat = Yii::$app->request->get('lat', '');
-		if (empty($lng) || empty($lat)) {
-			util::fail('经度或纬度不能为空');
-		}
-		$shopId = ShopService::getDefaultShopId($this->sj);
-		$respond = ExpressService::getUserDistance($lng, $lat, $shopId, $this->sjExtend);
-		util::success($respond);
-	}
+    //获取采购单物流运单的轨迹 ssh 20250705
+    public function actionGetCgExpressTrack()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $cg = PurchaseClass::getById($id, true);
+        if (empty($cg)) {
+            util::fail('没有找到订单');
+        }
+        if ($cg->mainId != $this->mainId) {
+            util::fail('不是你的订单');
+        }
+        $bizIdMap = dict::getDict('expressBizIdMap');
+        if (getenv('YII_ENV') == 'production') {
+            $bizId = $bizIdMap[$mainId] ?? 0;
+            if (empty($bizId)) {
+                util::fail('没有找到月结账号');
+            }
+            //暂时只支持顺丰
+            $deliveryId = 'SF';
+        } else {
+            $deliveryId = 'TEST';
+            $bizId = 'test_biz_id';
+        }
+        $params = [
+            'deliveryId' => $deliveryId,
+            'bizId' => $bizId,
+        ];
+        ExpressClass::getTrack($params);
+    }
+
+    //计算客户距离和运费 ssh 2020.5.14
+    public function actionGetUserDistance()
+    {
+        //经度
+        $lng = Yii::$app->request->get('lng', '');
+        //纬度
+        $lat = Yii::$app->request->get('lat', '');
+        if (empty($lng) || empty($lat)) {
+            util::fail('经度或纬度不能为空');
+        }
+        $shopId = ShopService::getDefaultShopId($this->sj);
+        $respond = ExpressService::getUserDistance($lng, $lat, $shopId, $this->sjExtend);
+        util::success($respond);
+    }
 
 }

+ 29 - 0
biz-hd/express/classes/ExpressClass.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace bizHd\express\classes;
+
+use bizHd\wx\classes\WxOpenClass;
+use common\components\dict;
+use common\components\expressUtil;
+use common\components\util;
+use Yii;
+use bizHd\base\classes\BaseClass;
+
+class ExpressClass extends BaseClass
+{
+
+    public static $baseFile = '\bizHd\express\models\Express';
+
+    public static function getTrack($params)
+    {
+        $merchant = WxOpenClass::getGhsWxInfo();
+        $ptStyle = dict::getDict('ptStyle', 'ghs');
+        $data = [
+            'delivery_id' => 0,
+            'waybill_id' => 0,
+        ];
+        $ret = expressUtil::getPath($merchant, $data, $ptStyle);
+        print_r($ret);
+    }
+
+}

+ 13 - 0
biz-hd/express/models/Express.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizHd\express\models;
+use bizHd\base\models\Base;
+
+class Express extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhExpress';
+    }
+
+}

+ 7 - 0
common/components/dict.php

@@ -8,6 +8,13 @@ class dict
 {
 
     public static $data = [
+        //mainId对应物流月结账号
+        'expressBizIdMap' => [
+            //长春花路鲜花,
+            '36707' => '4212960899',
+            //龙岩花掌柜
+            '50' => '5925274162',
+        ],
         //花材售后原因
         'itemRefundOption' => [
             0 => ['id' => 0, 'name' => '未选'],