|
|
|
@ -12,12 +12,6 @@ use think\facade\Db; |
|
|
|
|
|
|
|
|
|
class Wxserver extends BaseController |
|
|
|
|
{ |
|
|
|
|
public function index() |
|
|
|
|
{ |
|
|
|
|
$obj = new \app\common\library\wxserver\Server(); |
|
|
|
|
$data = $obj->getAuditStatus('wxe3ed157849bd07b5', 428711396); |
|
|
|
|
return $this->renderSuccess($data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function verifyTicket() |
|
|
|
|
{ |
|
|
|
@ -44,21 +38,24 @@ class Wxserver extends BaseController |
|
|
|
|
echo 'success'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function callback() |
|
|
|
|
public function callback($appid) |
|
|
|
|
{ |
|
|
|
|
$time = date('Y-m-d H:i:s'); |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => '推送开始', 'created_at' => $time]); |
|
|
|
|
$query = $this->request->query(); |
|
|
|
|
$obj = new \app\common\library\wxserver\Server(); |
|
|
|
|
$signature = $this->request->get('signature'); |
|
|
|
|
$timestamp = $this->request->get('timestamp'); |
|
|
|
|
$nonce = $this->request->get('nonce'); |
|
|
|
|
if ($signature && $timestamp && $nonce) { |
|
|
|
|
if ($obj->checkSignature($signature, $timestamp, $nonce)) { |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => '签名正确', 'created_at' => $time]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$xmlData = file_get_contents("php://input"); |
|
|
|
|
if ($query) { |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => $query, 'created_at' => $time]); |
|
|
|
|
$arr = explode('/', $query); |
|
|
|
|
$appid = end($arr); |
|
|
|
|
if ($xmlData && $appid) { |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => $xmlData, 'created_at' => $time]); |
|
|
|
|
$obj = new \app\common\library\wxserver\Server(); |
|
|
|
|
$data = $obj->decryptXml($xmlData); |
|
|
|
|
if (!empty($data['MsgType']) && $data['MsgType'] == 'event' && !empty($data['Event'])) { |
|
|
|
|
if ($xmlData) { |
|
|
|
|
$data = $obj->decryptXml($xmlData); |
|
|
|
|
if (!empty($data['MsgType'])) { |
|
|
|
|
if ($data['MsgType'] == 'event' && !empty($data['Event'])) { |
|
|
|
|
$up = []; |
|
|
|
|
if ($data['Event'] == 'weapp_audit_success') { |
|
|
|
|
$up['audit_status'] = 2; |
|
|
|
@ -70,13 +67,32 @@ class Wxserver extends BaseController |
|
|
|
|
if (!empty($data['Reason'])) { |
|
|
|
|
$up['audit_reason'] = $data['Reason']; |
|
|
|
|
} |
|
|
|
|
if ($up) { |
|
|
|
|
if ($up && $appid) { |
|
|
|
|
$model = new WxserverAccount(); |
|
|
|
|
$model->update($up, ['appid' => $appid]); |
|
|
|
|
} |
|
|
|
|
} elseif ($data['MsgType'] == 'text') { |
|
|
|
|
echo $this->responseText($data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
echo 'success'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function responseText($data): string |
|
|
|
|
{ |
|
|
|
|
$template = "<xml> |
|
|
|
|
<ToUserName><![CDATA[%s]]></ToUserName> |
|
|
|
|
<FromUserName><![CDATA[%s]]></FromUserName> |
|
|
|
|
<CreateTime>%s</CreateTime> |
|
|
|
|
<MsgType><![CDATA[%s]]></MsgType> |
|
|
|
|
<Content><![CDATA[%s]]></Content> |
|
|
|
|
</xml>"; |
|
|
|
|
$fromUser = $data['ToUserName']; |
|
|
|
|
$toUser = $data['FromUserName']; |
|
|
|
|
$content = !empty($data['Content']) ? $data['Content'] : '收到你的信息了'; |
|
|
|
|
$time = time(); |
|
|
|
|
$msgType = 'text'; |
|
|
|
|
return sprintf($template, $toUser, $fromUser, $time, $msgType, $content); |
|
|
|
|
} |
|
|
|
|
} |