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