Quellcode durchsuchen

update: 获取商品报价接口

shizhongqi vor 11 Monaten
Ursprung
Commit
07d9b7936b
2 geänderte Dateien mit 18 neuen und 1 gelöschten Zeilen
  1. 17 0
      app-hd/controllers/ChatController.php
  2. 1 1
      app-mall/controllers/GoodsController.php

+ 17 - 0
app-hd/controllers/ChatController.php

@@ -199,6 +199,23 @@ class ChatController extends BaseController
         util::success(['oldPice'=>$val, 'newPrice'=>$price]);
     }
 
+    //用 redis key 获取商品报价
+    public function actionGetQuotedPrice()
+    {
+        $key = Yii::$app->request->post('key');
+        $keyArr = explode('-', $key);
+        $shopId = intval($keyArr[0]);
+        if ($shopId != $this->shopId) {
+            util::error(-1, '校验失败');
+        }
+
+        $val = Yii::$app->redis->executeCommand('GET', [$key]);
+        if (empty($val)) {
+            util::success(['price'=>-1]);
+        }
+        util::success(['price'=>$val]);
+    }
+
     // message_server 远程调用专用方法,可用于:1.@商家--客户发了商品消息  2.有未读消息的通知(可以额外添加触发条件)3.哦哦
     public function actionMessageServerCall()
     {

+ 1 - 1
app-mall/controllers/GoodsController.php

@@ -29,7 +29,7 @@ class GoodsController extends BaseController
         $key = $this->shopId . '-' . $this->userId . '-' . $id;
         $val = Yii::$app->redis->executeCommand('GET', [$key]);
         if (floatval($val) > 0) {
-            $info['price'] = $val;
+            $info['price'] = floatval($val);
             $info['priceType'] = 2;
         }