完成sendMsg重构

This commit is contained in:
aozhiwei 2019-01-27 19:31:25 +08:00
parent 70217c5b3d
commit 27a50bfdbe

View File

@ -279,7 +279,7 @@ class KefuController {
} }
} }
private function sendMsg($data, $accountid) private function sendMsg($accountid, $data)
{ {
$postarray = json_encode($data, JSON_UNESCAPED_UNICODE); $postarray = json_encode($data, JSON_UNESCAPED_UNICODE);
//POST发送https请求客服接口api //POST发送https请求客服接口api
@ -311,8 +311,7 @@ class KefuController {
"msgtype" => "miniprogrampage", "msgtype" => "miniprogrampage",
"miniprogrampage" => $miniprogrampateInfo "miniprogrampage" => $miniprogrampateInfo
); );
#error_log('sendmsg11111:' . json_encode($data)); $this->sendMsg($userInfo['accountid'], $data);
$this->sendMsg($data, $userInfo['accountid']);
} }
} }
@ -350,32 +349,26 @@ class KefuController {
$save_ret = $this->saveAwardTimeToDB($accountid, $time); $save_ret = $this->saveAwardTimeToDB($accountid, $time);
if ($save_ret) { if ($save_ret) {
#error_log('save_ret:' . $save_ret); #error_log('save_ret:' . $save_ret);
$content = '奖励领取成功,请查收邮件!'; $this->sendMsg($accountid, array (
$data = array (
"touser" => $openid, "touser" => $openid,
"msgtype" => "text", "msgtype" => "text",
"text" => array ("content" => $content) "text" => array ("content" => '奖励领取成功,请查收邮件!')
); ));
$this->sendMsg($data, $accountid);
} }
} }
} else { } else {
$content = "一天内只能领取一次奖励!\n请明天再来!"; $this->sendMsg($accountid, array (
$data = array (
"touser" => $openid, "touser" => $openid,
"msgtype" => "text", "msgtype" => "text",
"text" => array ("content" => $content) "text" => array ("content" => "一天内只能领取一次奖励!\n请明天再来!")
); ));
$this->sendMsg($data, $accountid);
} }
} else { } else {
$content = '回复指定文字领取奖励!'; $this->sendMsg($accountid, array (
$data = array (
"touser" => $openid, "touser" => $openid,
"msgtype" => "text", "msgtype" => "text",
"text" => array ("content" => $content) "text" => array ("content" => '回复指定文字领取奖励!')
); ));
$this->sendMsg($data, $accountid);
} }
} }
@ -404,13 +397,11 @@ class KefuController {
':openid' => $openid, ':openid' => $openid,
':awardtime' => 0 ':awardtime' => 0
)); ));
$content = "您好,有什么能帮助你? \n回复指定文字领取奖励。 "; $this->sendMsg($accountid, array(
$data = array (
"touser" => $openid, "touser" => $openid,
"msgtype" => "text", "msgtype" => "text",
"text" => array ("content" => $content) "text" => array ("content" => "您好,有什么能帮助你? \n回复指定文字领取奖励。 ")
); ));
$this->sendMsg($data, $accountid);
} }
} }