This commit is contained in:
aozhiwei 2019-07-04 11:32:18 +08:00
parent 5578d5dc4a
commit 684248cdb4

View File

@ -105,7 +105,6 @@ class KefuController {
$gameid = $_REQUEST['gameid']; $gameid = $_REQUEST['gameid'];
$config_name = "../config/game$gameid/weixin/config.php"; $config_name = "../config/game$gameid/weixin/config.php";
require $config_name; require $config_name;
if (isset($_REQUEST['echostr'])) { if (isset($_REQUEST['echostr'])) {
if ($this->checkSignature()) { if ($this->checkSignature()) {
echo $_REQUEST['echostr']; echo $_REQUEST['echostr'];
@ -125,6 +124,7 @@ class KefuController {
$msg_str); $msg_str);
if ($errcode == 0) { if ($errcode == 0) {
$msg = json_decode($msg_str, true); $msg = json_decode($msg_str, true);
//error_log(json_encode($msg));
$accountid = phpcommon\createAccountId(WEIXIN_CHANNEL, $_REQUEST['gameid'], $msg['FromUserName']); $accountid = phpcommon\createAccountId(WEIXIN_CHANNEL, $_REQUEST['gameid'], $msg['FromUserName']);
switch ($msg['MsgType']) { switch ($msg['MsgType']) {
case 'event': case 'event':
@ -145,6 +145,12 @@ class KefuController {
die('not implement'); die('not implement');
break; break;
} }
case 'miniprogrampage':
{
// 小程序消息
$this->processText($msg, $accountid);
break;
}
} }
} else { } else {
#error_log($errcode . "\n"); #error_log($errcode . "\n");
@ -238,8 +244,14 @@ class KefuController {
{ {
$openid = $msg['FromUserName']; $openid = $msg['FromUserName'];
$CreateTime = $msg['CreateTime']; $CreateTime = $msg['CreateTime'];
$text = $msg['Content']; //$text = $msg['Content'];
$text = '';
$gameid = phpcommon\extractGameId($accountid); $gameid = phpcommon\extractGameId($accountid);
if (strcmp($msg['MsgType'], 'miniprogrampage') == 0) {
$text = 1;
} else {
$text = $msg['Content'];
}
$awardConfig = $this->getAwardConfig($gameid, $text); $awardConfig = $this->getAwardConfig($gameid, $text);
if (!isset($awardConfig)) { if (!isset($awardConfig)) {
$this->sendKefuMsg($accountid, array ( $this->sendKefuMsg($accountid, array (
@ -272,8 +284,8 @@ class KefuController {
)); ));
return; return;
} }
if ($this->sendAwardMail($accountid, $awardConfig)) { if ($this->sendAwardMail($accountid, $awardConfig)) {
error_log(json_encode($awardConfig));
$ret = $conn->execScript("UPDATE accounts SET " . $ret = $conn->execScript("UPDATE accounts SET " .
' awardtime=:awardtime ' . ' awardtime=:awardtime ' .
'WHERE accountid=:accountid; ', 'WHERE accountid=:accountid; ',