|
|
@@ -14,6 +14,8 @@ use GatewayClient\Gateway;
|
|
|
|
|
|
class ChatController extends BaseController
|
|
|
{
|
|
|
+ public $guestAccess = ['message-server-call'];
|
|
|
+
|
|
|
//聊天 ssh 2019.12.28
|
|
|
public function actionIndex()
|
|
|
{
|
|
|
@@ -169,4 +171,52 @@ class ChatController extends BaseController
|
|
|
$c = ChatService::getUnReadMsgCount($this->shopId, 'message');
|
|
|
util::success(['msg_count'=>$c]);
|
|
|
}
|
|
|
+
|
|
|
+ // 给暂无价格商品报价
|
|
|
+ public function actionCreateQuotedPrice()
|
|
|
+ {
|
|
|
+ $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, false, '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]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // message_server 远程调用专用方法,可用于:1.@商家--客户发了商品消息 2.有未读消息的通知(可以额外添加触发条件)3.哦哦
|
|
|
+ public function actionMessageServerCall()
|
|
|
+ {
|
|
|
+ Yii::info('message_server 远程调用');
|
|
|
+
|
|
|
+ $callbackData = Yii::$app->request->post();
|
|
|
+ if (empty($callbackData)) {
|
|
|
+ $postStr = file_get_contents('php://input');
|
|
|
+ // 处理转义字符,将JSON字符串正确解析为数组
|
|
|
+ //$postStr = stripslashes($postStr);
|
|
|
+ $callbackData = json_decode($postStr, true);
|
|
|
+
|
|
|
+ if (empty($callbackData)) {
|
|
|
+ util::fail('回调请求的数据为空');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Yii::info(json_encode($callbackData));
|
|
|
+ return $this->asJson(['return_code' => 0, 'return_msg' => 'OK']); // 成功状态的返回数据
|
|
|
+ }
|
|
|
}
|