|
|
@@ -14,15 +14,83 @@ class CallBackController extends \Phalcon\Mvc\Controller |
|
|
|
|
|
|
|
use BasisFun; |
|
|
|
|
|
|
|
public function alipayGatewayAction() |
|
|
|
{ |
|
|
|
$args = $this->request->get(); |
|
|
|
} |
|
|
|
|
|
|
|
//加密方法 |
|
|
|
function encrypt($input, $key, $iv) |
|
|
|
{ |
|
|
|
|
|
|
|
$data = @base64_encode(openssl_encrypt($input, 'AES-256-CBC', base64_decode($key), OPENSSL_RAW_DATA, $iv)); |
|
|
|
return $data; |
|
|
|
} |
|
|
|
|
|
|
|
//解密 |
|
|
|
function decrypt($input, $key, $iv) |
|
|
|
{ |
|
|
|
return openssl_decrypt(base64_decode($input), 'AES-256-CBC', base64_decode($key), OPENSSL_RAW_DATA, $iv); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function RSA2($data, $pikey) |
|
|
|
{ |
|
|
|
$res = "-----BEGIN RSA PRIVATE KEY-----\n" . wordwrap($pikey, 64, "\n", true) . "\n-----END RSA PRIVATE KEY-----"; |
|
|
|
// 请注意密钥 是不是有带 -----BEGIN RSA PRIVATE KEY----- -----END RSA PRIVATE KEY----- |
|
|
|
$piKey = openssl_pkey_get_private($res); |
|
|
|
|
|
|
|
if ($piKey) { |
|
|
|
$res = openssl_get_privatekey($res); |
|
|
|
openssl_sign($data, $sign, $res, 'SHA256'); |
|
|
|
$sign = base64_encode($sign); |
|
|
|
openssl_free_key($piKey); |
|
|
|
return $sign; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 支付宝 - 公共网关回调 |
|
|
|
*/ |
|
|
|
public function cloudpayAliPayCallBackAction() |
|
|
|
public function alipayCommonCallBackAction() |
|
|
|
{ |
|
|
|
$args = $this->request->get(); |
|
|
|
$this->logger($args, 'alipayCommonCallBack', true); |
|
|
|
if ($this->request->isPost()) { |
|
|
|
switch ($_POST["msg_method"] ?? ""){ |
|
|
|
case "alipay.commerce.educate.service.status.changed" : |
|
|
|
$biz_content = json_decode($_POST["biz_content"], true); |
|
|
|
$selfSupportForSchoolInfo = SelfSupportForUserFaceInfo::findFirst("user_id = '{$biz_content["user_id"]}' and school_std_code = '{$biz_content["school_std_code"]}'"); |
|
|
|
if (!empty($selfSupportForSchoolInfo)) { |
|
|
|
if ($biz_content["service_name"] == "SCHOOL_FACE_PASS_OPEN") { |
|
|
|
//一脸通行开通 |
|
|
|
$selfSupportForSchoolInfo->school_face_pass_status = "OPEN"; |
|
|
|
} |
|
|
|
if ($biz_content["service_name"] == "SCHOOL_FACE_PASS_CLOSE") { |
|
|
|
//一脸通行关闭 |
|
|
|
$selfSupportForSchoolInfo->school_face_pass_status = "CLOSE"; |
|
|
|
} |
|
|
|
if ($biz_content["service_name"] == "SCHOOL_FACE_PAYMENT_OPEN") { |
|
|
|
//校园刷脸支付开通 |
|
|
|
$selfSupportForSchoolInfo->school_face_payment_status = "OPEN"; |
|
|
|
} |
|
|
|
if ($biz_content["service_name"] == "SCHOOL_FACE_PAYMENT_CLOSE") { |
|
|
|
//校园刷脸支付关闭 |
|
|
|
$selfSupportForSchoolInfo->school_face_payment_status = "CLOSE"; |
|
|
|
} |
|
|
|
$selfSupportForSchoolInfo->save(); |
|
|
|
//TODO::通知行业云 alipay.planet.ecocampus.api.roster.signUpInfo(签约信息同步) |
|
|
|
// (new AliEcoService())->alipayPlanetEcocampusApiRosterSignUpInfo( |
|
|
|
// $selfSupportForSchoolInfo->user_id, $selfSupportForSchoolInfo->parent_user_id, |
|
|
|
// $selfSupportForSchoolInfo->parent_logon_id, $selfSupportForSchoolInfo->user_identity_id, |
|
|
|
// $selfSupportForSchoolInfo->user_identity_id, $selfSupportForSchoolInfo->school_code, |
|
|
|
// $args["school_name"], $args["face_open_status"], $args["scan_face_pay_status"] |
|
|
|
// ); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
$this->logger($_POST, 'alipayCommonCallBack_post', true); |
|
|
|
|
|
|
|
} |
|
|
|
echo "success"; |
|
|
|
die(); |
|
|
@@ -35,42 +103,54 @@ class CallBackController extends \Phalcon\Mvc\Controller |
|
|
|
{ |
|
|
|
if ($this->request->isPost()) { |
|
|
|
try { |
|
|
|
$verify_result = (new EasyAlipayService())->verifyNotify($_POST); |
|
|
|
logger(json_encode([ |
|
|
|
"msg" => "异步回调", |
|
|
|
"data" => $_POST, |
|
|
|
"res" => $verify_result |
|
|
|
], 320), 'common_alipay_sync_notify', true); |
|
|
|
$self_order_sn = $_POST['out_trade_no']; //商家业务订单号 |
|
|
|
$trade_no = $_POST['trade_no']; //支付宝交易号 |
|
|
|
$trade_status = $_POST['trade_status']; //交易状态 |
|
|
|
|
|
|
|
//判断该笔订单是否在 |
|
|
|
$model = UserMerchantOrder::findFirst("self_trade_no = '{$self_order_sn}'"); |
|
|
|
if (!$model) { |
|
|
|
//未查到訂單 |
|
|
|
if ($verify_result) {//验证成功 |
|
|
|
$self_order_sn = $_POST['out_trade_no']; //商家业务订单号 |
|
|
|
$trade_no = $_POST['trade_no']; //支付宝交易号 |
|
|
|
$trade_status = $_POST['trade_status']; //交易状态 |
|
|
|
|
|
|
|
//判断该笔订单是否在 |
|
|
|
$model = UserMerchantOrder::findFirst("self_trade_no = '{$self_order_sn}'"); |
|
|
|
if (!$model) { |
|
|
|
//未查到訂單 |
|
|
|
logger(json_encode([ |
|
|
|
"msg" => "异步回调失败-訂單未查到", |
|
|
|
"data" => $_POST, |
|
|
|
], 320), 'common_alipay_sync_notify_not_find', true); |
|
|
|
//验证失败 |
|
|
|
echo "fail"; |
|
|
|
die(); |
|
|
|
} |
|
|
|
//商户网站中已经做过处理 |
|
|
|
if ($model->status != IPay::PAY_STATE_FOR_WAIT) { |
|
|
|
logger(json_encode([ |
|
|
|
"msg" => "异步回调已处理", |
|
|
|
"data" => $_POST, |
|
|
|
], 320), 'alipay_sync_notify_already', true); |
|
|
|
echo "success"; |
|
|
|
die(); |
|
|
|
} |
|
|
|
|
|
|
|
$model->return_data = json_encode($_POST); |
|
|
|
$model->trade_no = $trade_no; |
|
|
|
$model->updated_at = date("Y-m-d H:i:s"); |
|
|
|
|
|
|
|
echo "success"; |
|
|
|
die(); |
|
|
|
} else { |
|
|
|
logger(json_encode([ |
|
|
|
"msg" => "异步回调失败-訂單未查到", |
|
|
|
"msg" => "异步回调驗證失败", |
|
|
|
"data" => $_POST, |
|
|
|
], 320), 'common_alipay_sync_notify_not_find', true); |
|
|
|
], 320), 'alipay_sync_notify_verify_fail', true); |
|
|
|
//验证失败 |
|
|
|
echo "fail"; |
|
|
|
die(); |
|
|
|
} |
|
|
|
//商户网站中已经做过处理 |
|
|
|
if ($model->status != IPay::PAY_STATE_FOR_WAIT) { |
|
|
|
logger(json_encode([ |
|
|
|
"msg" => "异步回调已处理", |
|
|
|
"data" => $_POST, |
|
|
|
], 320), 'alipay_sync_notify_already', true); |
|
|
|
echo "success"; |
|
|
|
die(); |
|
|
|
} |
|
|
|
|
|
|
|
$model->return_data = json_encode($_POST); |
|
|
|
$model->trade_no = $trade_no; |
|
|
|
$model->updated_at = date("Y-m-d H:i:s"); |
|
|
|
|
|
|
|
echo "success"; |
|
|
|
die(); |
|
|
|
} catch (\Exception $e) { |
|
|
|
logger(json_encode([ |
|
|
|
"msg" => "异步回调處理异常", |
|
|
|