1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\controller\api;
- use app\Request;
- use app\services\pay\PayNotifyServices;
- use qiniu\services\huifu\HuiFuService;
- use qiniu\utils\Hook;
- use think\Response;
- class Huifu
- {
-
- public function notify(Request $request, string $type)
- {
- if (cache('hj_' . md5($request->getContent()))) return 'lock';
- cache('hj_' . md5($request->getContent()), 30);
- return HuiFuService::notify(function ($notify) use ($request) {
- if (isset($notify->out_trade_no)) {
- if (isset($notify->attach) && $notify->attach) {
- if (($count = strpos($notify->out_trade_no, '_')) !== false) {
- $notify->trade_no = $notify->out_trans_id;
- $notify->req_seq_id = $notify->out_trade_no;
- $notify->out_trade_no = substr($notify->out_trade_no, $count + 1);
- }
- cache('hj_' . md5($request->getContent()), null);
- return (new Hook(PayNotifyServices::class, 'huifu'))->listen($notify->attach, $notify->out_trade_no, $notify->trade_no, $notify->req_seq_id);
- }
- return false;
- }
- return false;
- });
- }
-
- public function refund(Request $request, string $type)
- {
- @file_put_contents('hjverify.txt', $type . PHP_EOL, FILE_APPEND);
- @file_put_contents('hjverify.txt', $request->getContent() . PHP_EOL, FILE_APPEND);
- @file_put_contents('hjverify.txt', json_encode(input()) . PHP_EOL, FILE_APPEND);
- @file_put_contents('hjverify.txt', json_encode(input()) . PHP_EOL, FILE_APPEND);
- }
- }
|