From 2cee273b56eda53c476026432aba0d02e5802d56 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 24 Oct 2019 10:26:57 +0800 Subject: [PATCH] 1 --- webapp/controller/KefuController.class.php | 45 ++++++++++++---------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/webapp/controller/KefuController.class.php b/webapp/controller/KefuController.class.php index 975affe..4408a1f 100644 --- a/webapp/controller/KefuController.class.php +++ b/webapp/controller/KefuController.class.php @@ -308,6 +308,7 @@ class KefuController { private function processText($msg, $accountid) { + $this->createUser($accountid); $openid = $msg['FromUserName']; $CreateTime = $msg['CreateTime']; //$text = $msg['Content']; @@ -373,26 +374,30 @@ class KefuController { private function processEvent($msg, $accountid) { if ($msg['Event'] == 'user_enter_tempsession') { - $conn = $this->getMysql($accountid); - $ret = $conn->execScript('INSERT INTO accounts(accountid, channel, gameid, openid, awardtime, activetime) ' . - 'SELECT :accountid, :channel, :gameid, :openid, :awardtime, :activetime ' . - 'FROM DUAL ' . - 'WHERE NOT EXISTS(SELECT accountid FROM accounts WHERE accountid=:accountid);', - array( - ':accountid' => $accountid, - ':channel' => WEIXIN_CHANNEL, - ':gameid' => phpcommon\extractGameId($accountid), - ':openid' => $msg['FromUserName'], - ':awardtime' => 0, - ':activetime' => 0 - )); - if ($ret) { - $this->sendKefuMsg($accountid, array( - "touser" => $msg['FromUserName'], - "msgtype" => "text", - //"text" => array("content" => "您好,有什么能帮助你? \n ") - )); - } + $this->createUser($accountid); + } + } + + private function createUser($accountid) { + $conn = $this->getMysql($accountid); + $ret = $conn->execScript('INSERT INTO accounts(accountid, channel, gameid, openid, awardtime, activetime) ' . + 'SELECT :accountid, :channel, :gameid, :openid, :awardtime, :activetime ' . + 'FROM DUAL ' . + 'WHERE NOT EXISTS(SELECT accountid FROM accounts WHERE accountid=:accountid);', + array( + ':accountid' => $accountid, + ':channel' => WEIXIN_CHANNEL, + ':gameid' => phpcommon\extractGameId($accountid), + ':openid' => $msg['FromUserName'], + ':awardtime' => 0, + ':activetime' => 0 + )); + if ($ret) { + $this->sendKefuMsg($accountid, array( + "touser" => $msg['FromUserName'], + "msgtype" => "text", + //"text" => array("content" => "您好,有什么能帮助你? \n ") + )); } }