jh-admin/addon/aliapp/event/AliAuditResult.php

121 lines
4.2 KiB
PHP

<?php
/**
* SAAS应用系统 --- 十年开发经验汇集巨献!
* ==========================================================
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
* ----------------------------------------------------------
* 官方网址: https://www.zoomtk.com
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
* 任何企业和个人未经允许对程序代码以任何形式任何目的再发布传播。
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
* ==========================================================
*/
namespace addon\aliapp\event;
use addon\aliapp\model\MinCode;
use think\facade\Db;
use think\facade\Log;
class AliAuditResult
{
// 支付宝小程序审核结果通知处理
public function handle($param = [])
{
$msgMethod = $param['msg_method'] ?? '';
if ($msgMethod && $this->rsaCheck($param)) {
Log::write('支付宝小程序通知:' . $msgMethod . json_encode($param));
$biz_content = json_decode($param['biz_content'], true);
$param['biz_content'] = $biz_content;
$res = event('AliGatewayNotify', $param, true);
switch ($msgMethod) {
case 'alipay.open.mini.version.audit.rejected'; //审核被拒绝
$this->auditResultHandle($biz_content);
break;
case 'alipay.open.mini.version.audit.passed'; //审核通过
$this->passed($biz_content);
break;
case 'alipay.open.mini.merchant.confirmed'; //小程序创建
$this->confirmed($biz_content);
break;
case 'alipay.open.search.keyword.changed'; //小程序关键词审核进度消息通知
echo 'success';
break;
case 'alipay.open.mini.version.baseaudit.passed'; //小程序审核不可营销通知
echo 'success';
break;
default :
if ($res) {
if (is_string($res)) echo $res;
if (is_array($res)) echo json_encode($res);
} else {
echo 'success';
}
}
}
}
/**
* Common: 支付宝小程序审核结果处理 —— 驳回处理
* Author: wu-hui
* Time: 2023/01/06 14:52
* @param $param
* @throws \think\db\exception\DbException
*/
public function auditResultHandle($bizContent)
{
$siteIds = Db::name('uni_account')->where('appid', $bizContent['mini_app_id'])->column('site_id');
Db::name('applet_release')
->whereIn('site_id', $siteIds)
->where('version', $bizContent['mini_app_version'])
->update(['version_status' => 'AUDIT_REJECT', 'audit_reason' => $bizContent['audit_reason']]);
echo 'success';
}
/***
* 小程序创建
* @param $param
*/
public function confirmed($bizContent)
{
$business_code = $bizContent['out_order_no'];
$where = [
'app_type' => 'aliapp',
'business_code' => $business_code,
];
$info = Db::name('applet_reg')->where($where)->value('ag_site_id');
if ($info) {
$data = [
'original_id' => $bizContent['pid'],
'appid' => $bizContent['min_app_id'] ?? '',
'status' => $bizContent['status'],
'reg_fee' => model('website')->getValue(['site_id' => $info], 'appreg_rate'),
];
Db::name('applet_reg')->where($where)->update($data);
}
echo 'success';
}
/***
* 小程序审核通过
* @param $param
*/
public function passed($bizContent)
{
event('AlipayAuditPassed', $bizContent);//审核通过
echo 'success';
}
/***
* 验证签名
* @param $param
* @return bool
*/
public function rsaCheck($param)
{
$payModel = new MinCode();
$res = $payModel->verifySgin($param);
return $res;
}
}