Browse Source

update

master
DengBiao 1 year ago
parent
commit
7011bb2371
2 changed files with 236 additions and 27 deletions
  1. +107
    -27
      src/applet/app/controllers/CallBackController.php
  2. +129
    -0
      src/common/Model/CentralKitchenForSchoolPackageOrd.php

+ 107
- 27
src/applet/app/controllers/CallBackController.php View File

@@ -14,15 +14,83 @@ class CallBackController extends \Phalcon\Mvc\Controller


use BasisFun; 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(); $args = $this->request->get();
$this->logger($args, 'alipayCommonCallBack', true); $this->logger($args, 'alipayCommonCallBack', true);
if ($this->request->isPost()) { 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); $this->logger($_POST, 'alipayCommonCallBack_post', true);

} }
echo "success"; echo "success";
die(); die();
@@ -35,42 +103,54 @@ class CallBackController extends \Phalcon\Mvc\Controller
{ {
if ($this->request->isPost()) { if ($this->request->isPost()) {
try { try {
$verify_result = (new EasyAlipayService())->verifyNotify($_POST);
logger(json_encode([ logger(json_encode([
"msg" => "异步回调", "msg" => "异步回调",
"data" => $_POST, "data" => $_POST,
"res" => $verify_result
], 320), 'common_alipay_sync_notify', true); ], 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([ logger(json_encode([
"msg" => "异步回调失败-訂單未查到",
"msg" => "异步回调驗證失败",
"data" => $_POST, "data" => $_POST,
], 320), 'common_alipay_sync_notify_not_find', true);
], 320), 'alipay_sync_notify_verify_fail', true);
//验证失败 //验证失败
echo "fail"; echo "fail";
die(); 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) { } catch (\Exception $e) {
logger(json_encode([ logger(json_encode([
"msg" => "异步回调處理异常", "msg" => "异步回调處理异常",


+ 129
- 0
src/common/Model/CentralKitchenForSchoolPackageOrd.php View File

@@ -0,0 +1,129 @@
<?php

namespace SRVX\Model;

class CentralKitchenForSchoolPackageOrd extends BasicModel
{

/**
*
* @var integer
*/
public $id;

/**
*
* @var integer
*/
public $enterprise_id;

/**
*
* @var integer
*/
public $uid;

/**
*
* @var string
*/
public $user_identity_name;

/**
*
* @var integer
*/
public $user_identity_id;

/**
*
* @var double
*/
public $total_price;

/**
*
* @var integer
*/
public $kind;

/**
*
* @var string
*/
public $out_trade_no;

/**
*
* @var string
*/
public $trade_no;

/**
*
* @var integer
*/
public $state;

/**
*
* @var integer
*/
public $ord_state;

/**
*
* @var string
*/
public $req_content;

/**
*
* @var string
*/
public $with_day_data;

/**
*
* @var string
*/
public $create_at;

/**
*
* @var string
*/
public $update_at;

/**
* Initialize method for model.
*/
public function initialize()
{
parent::initialize();
$this->setSource("central_kitchen_for_school_package_ord");
}

/**
* Allows to query a set of records that match the specified conditions
*
* @param mixed $parameters
* @return CentralKitchenForSchoolPackageOrd[]|CentralKitchenForSchoolPackageOrd|\Phalcon\Mvc\Model\ResultSetInterface
*/
public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInterface
{
return parent::find($parameters);
}

/**
* Allows to query the first record that match the specified conditions
*
* @param mixed $parameters
* @return CentralKitchenForSchoolPackageOrd|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
*/
public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface
{
return parent::findFirst($parameters);
}

}

Loading…
Cancel
Save