Forráskód Böngészése

新增:报价与获取报价接口

shizhongqi 11 hónapja
szülő
commit
135200f63e

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

@@ -169,4 +169,31 @@ class ChatController extends BaseController
         $c = ChatService::getUnReadMsgCount($this->shopId, 'message');
         util::success(['msg_count'=>$c]);
     }
+
+    // 给暂无价格商品报价
+    public function actionsCreateQuotedPrice()
+    {
+        $post = Yii::$app->request->post();
+        $key = $post['key'];
+        $price = floatval($post['price']);
+        $keyArr = explode('-', $key);
+        $shopId = intval($keyArr[0]);
+        if($this->shopId != $shopId){
+            util::error(-1, '校验失败,并不是你的客户');
+        }
+
+        $goodsId = $keyArr[2];
+        $goods = GoodsClass::getById($goodsId, fasle, 'id, priceType');
+        if ($goods['priceType'] != 0) {
+            util::error(-1, '此商品无需走报价');
+        }
+
+        $val = Yii::$app->redis->executeCommand('GET', [$key]);
+        if (!empty($saveAuthCode)) { // 修改报价
+            Yii::info('修改报价:' . $key . ' -- 旧价:' . $val . ', 新价:' . $price);
+        }
+
+        Yii::$app->redis->executeCommand('SETEX', [$key, 864000, $price]);
+        util::success(['oldPice'=>$val, 'newPrice'=>$price]);
+    }
 }

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

@@ -135,4 +135,21 @@ class ChatController extends BaseController
         $c = ChatService::getUnReadMsgCount(intval($this->userId), 'message');
         util::success(['msg_count'=>$c]);
     }
+
+    //用 redis key 获取商品报价
+    public function actionGetQuotedPrice()
+    {
+        $key = Yii::$app->request->post('key');
+        $keyArr = explode('-', $key);
+        $userId = intval($keyArr[1]);
+        if ($userId != $this->userId) {
+            util::error(-1, '校验失败');
+        }
+
+        $val = Yii::$app->redis->executeCommand('GET', [$key]);
+        if (empty($val)) {
+            util::success(['price'=>-1]);
+        }
+        util::success(['price'=>$val]);
+    }
 }