feat: 初始化雄戈商城服务端代码与Webhook自动部署配置
这个提交包含在:
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
namespace addons\shopro_huifu\controller;
|
||||
|
||||
|
||||
|
||||
use addons\shopro_huifu\library\HuifuNotifyHandler;
|
||||
|
||||
use addons\shopro_huifu\library\HuifuNotifyParser;
|
||||
|
||||
use addons\shopro_huifu\library\HuifuQueryService;
|
||||
|
||||
use think\addons\Controller;
|
||||
|
||||
use think\Log;
|
||||
|
||||
|
||||
|
||||
class Pay extends Controller
|
||||
|
||||
{
|
||||
|
||||
protected $noNeedLogin = ['notify', 'notifyrefund'];
|
||||
|
||||
protected $noNeedRight = ['*'];
|
||||
|
||||
|
||||
|
||||
public function notify()
|
||||
|
||||
{
|
||||
|
||||
$raw = HuifuNotifyParser::parse($this->request);
|
||||
|
||||
Log::write('[shopro_huifu] notify hit(legacy): req_seq_id=' . $this->peekReqSeqId($raw));
|
||||
@file_put_contents(RUNTIME_PATH . 'log/huifu_notify_hit.log', date('c') . ' legacy ' . $this->peekReqSeqId($raw) . "\n", FILE_APPEND);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
|
||||
$handler = new HuifuNotifyHandler();
|
||||
|
||||
$ack = $handler->handlePayNotify($raw);
|
||||
|
||||
http_response_code($ack['httpCode']);
|
||||
|
||||
echo $ack['body'];
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
Log::write('[shopro_huifu] notify error: ' . $e->getMessage());
|
||||
|
||||
http_response_code(500);
|
||||
|
||||
echo '';
|
||||
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function notifyrefund()
|
||||
|
||||
{
|
||||
|
||||
http_response_code(200);
|
||||
|
||||
echo 'OK';
|
||||
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function peekReqSeqId(array $raw)
|
||||
|
||||
{
|
||||
|
||||
$respData = $raw['resp_data'] ?? '';
|
||||
|
||||
if (is_string($respData) && $respData !== '') {
|
||||
|
||||
$data = json_decode($respData, true);
|
||||
|
||||
if (is_array($data) && !empty($data['req_seq_id'])) {
|
||||
|
||||
return (string) $data['req_seq_id'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return '-';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户