Browse Source

actionReplaceClientId 接口更新

shizhongqi 9 months ago
parent
commit
d1aebcab3c

+ 16 - 9
app-ghs/controllers/AdminController.php

@@ -14,6 +14,7 @@ use common\components\util;
 use Yii;
 use yii\helpers\Json;
 use bizHd\user\classes\UserClass;
+use bizGhs\device\classes\GhsDeviceClass;
 
 class AdminController extends BaseController
 {
@@ -105,15 +106,21 @@ class AdminController extends BaseController
         $this->admin->clientId = $id;
         $this->admin->save();
 
-        $device = [
-            'clientId' => $id,
-            'mainId' => $this->mainId,
-            'shopId' => $this->shopId,
-            'adminId' => $this->adminId,
-            'loginTime' => date('Y-m-d H:i:s'),
-            'status' => 1
-        ];
-        \bizGhs\device\classes\GhsDeviceClass::add($device);
+        $ghsDevice = GhsDeviceClass::getByCondition(['clientId'=>$id], true);
+        if ($ghsDevice == null){
+            $device = [
+                'clientId' => $id,
+                'mainId' => $this->mainId,
+                'shopId' => $this->shopId,
+                'adminId' => $this->adminId,
+                'loginTime' => date('Y-m-d H:i:s'),
+                'status' => 1
+            ];
+            GhsDeviceClass::add($device);
+        } else {
+            $ghsDevice->loginTime = date('Y-m-d H:i:s');
+            $ghsDevice->save();
+        }
 
         util::complete();
     }

+ 3 - 2
app-ghs/controllers/TestController.php

@@ -1381,11 +1381,11 @@ class TestController extends BaseController
 
     public function actionPush()
     {
-       $push = new \common\components\push('ghs', \common\components\push::MSG_TYPE_ORDER);
+        $push = new \common\components\push('ghs', \common\components\push::MSG_TYPE_ORDER);
 
         $cids = [
             '5badab3ce8d531aa00f0ff5ddf6f37d8', // OPPO
-            '95a9f195f9ebdae801a8ac0a5693befc', // 小米 - 线上
+            '335cea1f91394178d1b302f2e240c0ad', // 小米 - 线上
             '08fd2c3c72a5da46d2274aaa05c321e3', //
             '9a5f7a63e290bf28f35d0691484e0721', // 华为
             '2278477ef2fe50fed89bc27dd4b9bde2', // VIVO
@@ -1403,6 +1403,7 @@ class TestController extends BaseController
         $rs = $push->pushByCloud($cids, $title, $content, $payload);
         Yii::info(json_encode($rs));
 
+        // clientId 后接状态:successed_online / successed_offline
         echo json_encode($rs);
     }
 }

+ 17 - 9
app-hd/controllers/AdminController.php

@@ -15,6 +15,7 @@ use common\components\util;
 use Yii;
 use yii\helpers\Json;
 use bizHd\user\classes\UserClass;
+use \bizHd\device\classes\HdDeviceClass;
 
 class AdminController extends BaseController
 {
@@ -439,15 +440,22 @@ class AdminController extends BaseController
         if (empty($clientId)) {
             util::success(['returnStatus' => 'FAILURE']);
         }
-        $device = [
-            'clientId' => $clientId,
-            'mainId' => $this->mainId,
-            'shopId' => $this->shopId,
-            'adminId' => $this->adminId,
-            'loginTime' => date('Y-m-d H:i:s'),
-            'status' => 1
-        ];
-        \bizHd\device\classes\HdDeviceClass::add($device);
+
+        $hdDevice = HdDeviceClass::getByCondition(['clientId'=>$clientId], true);
+        if ($hdDevice == null) {
+            $device = [
+                'clientId' => $clientId,
+                'mainId' => $this->mainId,
+                'shopId' => $this->shopId,
+                'adminId' => $this->adminId,
+                'loginTime' => date('Y-m-d H:i:s'),
+                'status' => 1
+            ];
+            HdDeviceClass::add($device);
+        } else {
+            $hdDevice->loginTime = date("Y-m-d H:i:s");
+            $hdDevice->save();
+        }
 
         noticeUtil::push("保存花店零售客户端ID:" . $clientId, '15280215347');
         util::complete();

+ 28 - 0
app-hd/controllers/TestController.php

@@ -38,4 +38,32 @@ class TestController extends BaseController
 //            util::fail('操作失败');
 //        }
     }
+
+    public function actionPush()
+    {
+        $push = new \common\components\push('hd', \common\components\push::MSG_TYPE_ORDER);
+
+        $cids = [
+            '', // OPPO
+            '', // 小米 - 线上
+            '', //
+            '', // 华为
+            '', // VIVO
+            '', // VIVO 线上
+            '', // 荣耀
+            '', // Apple XS - 我的(线下)
+            '', // Apple XS Max - 测试机(线上)
+        ];
+        $title = '新订单';
+        $content = '您有新的订单,请查看 order_id: ' . random_int(100000, 999999);
+        $payload = [
+            "page" => "pagesClient/member/detail",
+            "params" => ["id" => 682]
+        ];
+        $rs = $push->pushByCloud($cids, $title, $content, $payload);
+        Yii::info(json_encode($rs));
+
+        // clientId 后接状态:successed_online / successed_offline
+        echo json_encode($rs);
+    }
 }