|
|
@ -9,6 +9,7 @@ use App\Service\OpenPlatform; |
|
|
use EasyWeChat\Factory; |
|
|
use EasyWeChat\Factory; |
|
|
use Illuminate\Support\Facades\Cache; |
|
|
use Illuminate\Support\Facades\Cache; |
|
|
use Illuminate\Support\Facades\DB; |
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 仅用于测试 |
|
|
* 仅用于测试 |
|
|
@ -19,41 +20,7 @@ class TestController |
|
|
{ |
|
|
{ |
|
|
public function index() |
|
|
public function index() |
|
|
{ |
|
|
{ |
|
|
$appid = 'wx5bd5789ad8f89524'; |
|
|
|
|
|
$message = json_decode('{"ToUserName":"gh_f4ab40774bed","FromUserName":"o4seR5d-TVCImgh2aE6UtrQn6LIM","CreateTime":"1631670431","MsgType":"event","Event":"weapp_audit_success","SuccTime":"1631670431"}', true); |
|
|
|
|
|
DB::table('mini_program_events') |
|
|
|
|
|
->insert([ |
|
|
|
|
|
'type' => 1, |
|
|
|
|
|
'response' => json_encode($message), |
|
|
|
|
|
'event' => $message['MsgType'] ?? '', |
|
|
|
|
|
'created_at' => now() |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
$openPlatform = new OpenPlatform(); |
|
|
|
|
|
$refreshToken = $openPlatform->refreshToken($appid); |
|
|
|
|
|
|
|
|
|
|
|
//审核结果通知
|
|
|
|
|
|
if (isset($message['MsgType'], $message['Event']) && $message['MsgType'] == 'event') { |
|
|
|
|
|
$auditArr = [ |
|
|
|
|
|
'weapp_audit_success' => 0, //成功
|
|
|
|
|
|
'weapp_audit_fail' => 1, //拒绝
|
|
|
|
|
|
'weapp_audit_delay' => 4, //审核延后
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
//如果审核成功则发布
|
|
|
|
|
|
if ($message['Event'] == 'weapp_audit_success') { |
|
|
|
|
|
$code = $openPlatform->code($appid, $refreshToken); |
|
|
|
|
|
$res = $code->release(); |
|
|
|
|
|
dump($res); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$log = MiniProgramUploadLog::query() |
|
|
|
|
|
->where('appid', $appid) |
|
|
|
|
|
->orderBy('id', 'desc') |
|
|
|
|
|
->first(); |
|
|
|
|
|
$log->is_success = $auditArr[$message['Event']] ?? -1; |
|
|
|
|
|
$log->save(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Log::debug(json_encode(['a', 'b', 'c', 'd'])); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|