@@ -3,6 +3,8 @@ | |||
namespace SRVX\Api\Controllers; | |||
use SRVX\Model\SelfSupportForSchoolInfo; | |||
use SRVX\Model\SelfSupportForSchoolOrd; | |||
use SRVX\Model\UserIdentity; | |||
use SRVX\Traits\BasisFun; | |||
class AliCallBackController extends \Phalcon\Mvc\Controller | |||
@@ -65,30 +67,73 @@ class AliCallBackController extends \Phalcon\Mvc\Controller | |||
$this->logger(["info" => $selfSupportForSchoolInfo], 'aliEcoCommonCallBack', true); | |||
if (empty($selfSupportForSchoolInfo)) { | |||
$response = [ | |||
"code" => "40000", | |||
"msg" => "Business Failed", | |||
"code" => "40000", | |||
"msg" => "Business Failed", | |||
"sub_code" => "20000", | |||
"sub_msg" => "not found records", | |||
"sub_msg" => "not found records", | |||
]; | |||
} else { | |||
$response = [ | |||
"code" => "10000", | |||
"msg" => "Success", | |||
"code" => "10000", | |||
"msg" => "Success", | |||
"face_group_key" => $selfSupportForSchoolInfo->group_key, | |||
]; | |||
} | |||
break; | |||
case "alipay.planet.ecocampus.spi.trade.pay.detail": | |||
//SPI::交易通知 | |||
$this->logger(["alipay.planet.ecocampus.spi.trade.pay.detail" => $params], 'aliEcoCommonCallBack', true); | |||
$this->logger($params, 'alipay.planet.ecocampus.spi.trade.pay.detail', true); | |||
$biz_content = json_decode($params["biz_content"], true); | |||
//获取用户身份信息 | |||
$userIdentityId = $biz_content["buyer_info"]["roster_code"] ?? 0; //身份id | |||
$selfSupportForSchoolInfo = UserIdentity::findFirst("id = '{$userIdentityId}'"); | |||
if (empty($selfSupportForSchoolInfo)) { | |||
$response = [ | |||
"code" => "40000", | |||
"msg" => "Business Failed", | |||
"sub_code" => "20000", | |||
"sub_msg" => "not found user identity", | |||
]; | |||
} else { | |||
//新增`自营-学校-订单表`数据 | |||
$model = new SelfSupportForSchoolOrd(); | |||
$model->enterprise_id = $selfSupportForSchoolInfo->enterprise_id; | |||
$model->uid = $selfSupportForSchoolInfo->uid; | |||
$model->user_identity_id = $userIdentityId; | |||
$model->out_order_no = $biz_content["out_order_no"] ?? ""; | |||
$model->trade_no = $biz_content["trade_no"] ?? ""; | |||
$model->consumer = $biz_content["consumer"] ?? ""; | |||
$model->buyer_id = $biz_content["buyer_id"] ?? ""; | |||
$model->seller_id = $biz_content["seller_id"] ?? ""; | |||
$model->device_sn = $biz_content["device_sn"] ?? ""; | |||
$model->school_name = $biz_content["buyer_info"]["school_name"] ?? ""; | |||
$model->school_code = $biz_content["buyer_info"]["school_code"] ?? ""; | |||
$model->store_business_scenario = $biz_content["store_business_scenario"] ?? ""; | |||
$model->store_name = $biz_content["store_name"] ?? ""; | |||
$model->cp_store_id = $biz_content["cp_store_id"] ?? ""; | |||
$model->merchant_name = $biz_content["merchant_name"] ?? ""; | |||
$model->cp_merchant_id = $biz_content["cp_merchant_id"] ?? ""; | |||
$model->trade_amount = $biz_content["trade_amount"] ?? ""; | |||
$model->face_time = $biz_content["face_time"] ?? ""; | |||
$model->order_status = ($biz_content["order_status"] == "ORDER_SUCCESS") ? 1 : 0; //支付状态 | |||
$model->debt_business_code = $biz_content["debt_business_code"] ?? ""; | |||
$model->debt_business_msg = $biz_content["debt_business_msg"] ?? ""; | |||
$model->create_at = date("Y-m-d H:i:s"); | |||
$model->update_at = date("Y-m-d H:i:s"); | |||
$model->save(); | |||
$response = [ | |||
"code" => "10000", | |||
"msg" => "Success", | |||
]; | |||
} | |||
break; | |||
default: | |||
$response = [ | |||
"code" => "40000", | |||
"msg" => "Business Failed", | |||
"code" => "40000", | |||
"msg" => "Business Failed", | |||
"sub_code" => "20000", | |||
"sub_msg" => "未匹配到相关接口服务", | |||
"sub_msg" => "未匹配到相关接口服务", | |||
]; | |||
} | |||
@@ -99,9 +144,9 @@ class AliCallBackController extends \Phalcon\Mvc\Controller | |||
//用 接入准备 > 3.配置应用公私钥 中生成的私钥,对第4步的加密字符串进行加签,放到 sign 参数里。 | |||
// $sign1 = $this->RSA2($responseSecretText, $privateKey);//加签 | |||
$sign1 = $this->RSA2($contentToSign, $privateKey);//加签 | |||
$sign1 = $this->RSA2($contentToSign, $privateKey);//加签 | |||
$result = [ | |||
"sign" => $sign1, | |||
"sign" => $sign1, | |||
"response" => $response | |||
]; | |||
@@ -44,6 +44,17 @@ class PayController extends ControllerBase | |||
$app_auth_token = $args["app_auth_token"] ?? ""; | |||
$result = (new AlipayService($config))->alipayTradeCreateRequest($op_app_id, $subject, $out_trade_no, $total_amount, $buyer_id, $app_auth_token); | |||
$this->logger(["config" => $config, "args" => [ | |||
"op_app_id" => $op_app_id, | |||
"buyer_id" => $buyer_id, | |||
"total_amount" => $total_amount, | |||
"out_trade_no" => $out_trade_no, | |||
"subject" => $subject, | |||
"app_auth_token" => $app_auth_token, | |||
], "resp" => $result | |||
], 'tradeCreate', true); | |||
if (!$result["status"]) { | |||
$this->api(["statusCode" => 500, "code" => $result["data"]["code"] * 1, "msg" => $result["msg"] ?? $result["sub_msg"]]); | |||
} | |||
@@ -60,10 +71,10 @@ class PayController extends ControllerBase | |||
$config["pay_ali_private_key"] = $args["config"]["pay_ali_private_key"] ?? "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCSGJ9ob4kmGy6y4YeynjKJc/LSg02EXjLErPZSfVrAOy69FTRfBDbazlxpfl6YCAxDdT5ZcspB5kS2XYOY4dmqqPmF4VywmcjmZM8IxZFl1p7YC8BOlP6JrzDPwVl3hn4z3Em1byj8ANLY/AxAaW9W43FSIX+cSfdJThTlxGcbHZFM3kqu++hgFc/E+ar1nB0garqh03ESjatO4b6tuHM57ou7M+fXsoIf3gaL1IDZpeAoRh5sLCBLIbLz55tF0DcOaFsK7NUImnabJDRtrM1IN0lDZkQYAzL+JFsAq+ncRJm60Vd1jq/pXML/cFVHQQgdnjUd2u2NJTSMiCKCftmdAgMBAAECggEARzt+LduEEXJbeJiCI1MC7QX9tSqUFyAevMpgZ6P7JZM1nLfECzfwzwqjAES/Nn1mDVYTCmXvu+XcRtadnWMxUAaHcwGIwgqZa8xnLa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+EuRxrwrP1EBcL5z6Cern9c9Zzs8BPUacU+Q5e8c87W"; | |||
$config["pay_ali_public_key"] = $args["config"]["pay_ali_public_key"] ?? "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzEC7+3O/Ej/gkXug6EgcCM3LjWzz11RR6ESo0KshGg3ODgM8DfdKDHD5b1T6VbcRGFobXQBqVtW008ocUnSOZzE67a73l6mKT3FbmhRsbrgwcUuOHEJUZaLFxPibJgFl7fkOjBcIiz+Wc+9VDTt8O4YxIZhAL6L6ppXcrVrCkOaiIiuHGyp7FjQ+5s3Lk3NLSO3TfXw1WEX2F+IHnw32ZN/FlC8rF8HVlgM0w/PZJ9RuadoLqn5H6z/iqrurbtxscnx0Qbdt8CBzREabJnWxHjxO936AXu9njIPvsXkTfaJJIXxRGGb0b8peSiCljwi8UEODe8mjl2c/LzLel6RuLQIDAQAB"; | |||
$out_trade_no = $args["out_trade_no"] ?? ""; | |||
$trade_no = $args["trade_no"] ?? ""; | |||
$app_auth_token = $args["app_auth_token"] ?? ""; | |||
$result = (new AlipayService($config))->tradeCommonQueryPay($out_trade_no, $trade_no, $app_auth_token); | |||
$out_trade_no = $args["out_trade_no"] ?? ""; | |||
$trade_no = $args["trade_no"] ?? ""; | |||
$app_auth_token = $args["app_auth_token"] ?? ""; | |||
$result = (new AlipayService($config))->tradeCommonQueryPay($out_trade_no, $trade_no, $app_auth_token); | |||
if (!$result["status"]) { | |||
$this->api(["statusCode" => 500, "code" => $result["data"]["code"] * 1, "msg" => $result["msg"] ?? $result["sub_msg"]]); | |||
} | |||
@@ -81,7 +92,7 @@ class PayController extends ControllerBase | |||
public function tradeRefundAction() | |||
{ | |||
if ($this->request->isPost()) { | |||
$args = $this->request->getJsonRawBody(true); | |||
$args = $this->request->getJsonRawBody(true); | |||
$config["pay_ali_app_id"] = $args["config"]["pay_ali_app_id"] ?? "2021004101651996"; | |||
$config["pay_ali_private_key"] = $args["config"]["pay_ali_private_key"] ?? "MI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LqyM+rjUd/38QKBgQCNu2fsVQHDOsEMB/qakK3YlSb0q61iAjzeAjKYcXV9BHJ6ERTfeN3Z+9asSjs1TqzZSAtoQQ1EiCaFS4P9dNCTpYttS+52gy+VlJhNjCT0RHfxlGkpb+4OA4vHkbKpvTUAHjjXnMW1ZwC5CugSAchdTXTeV1im4Yms4DqJqacwoQKBgQCocPd7An8qTDIBZMOC4oT29+TYvUO+yMkAHLmx1h4QkLCkWegB4g5QkKkAGPWp3hshAj/KA0cXthFXVUG/SGZ2K6eB+nbon1N+9cDETdM4QXzN5gE/mUlupIxqRU1ouI27YYPbJSQNTrC7OkwNzfnpe/gshEj/gr5eHHvd4UrvMQKBgD2Toow7sfpV0R9rhO8aJ9njlbH15LqUK/AotK3E7zr73Uv5j/BIKS4dVC7T56L2khEUbM/y8+Rig6CdyFf3A4i4GKfbp56Sap/Haa9OP6jfep6VW7Aa1AJxPvIPgPZ2U+EuRxrwrP1EBcL5z6Cern9c9Zzs8BPUacU+Q5e8c87W"; | |||
$config["pay_ali_public_key"] = $args["config"]["pay_ali_public_key"] ?? "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzEC7+3O/Ej/gkXug6EgcCM3LjWzz11RR6ESo0KshGg3ODgM8DfdKDHD5b1T6VbcRGFobXQBqVtW008ocUnSOZzE67a73l6mKT3FbmhRsbrgwcUuOHEJUZaLFxPibJgFl7fkOjBcIiz+Wc+9VDTt8O4YxIZhAL6L6ppXcrVrCkOaiIiuHGyp7FjQ+5s3Lk3NLSO3TfXw1WEX2F+IHnw32ZN/FlC8rF8HVlgM0w/PZJ9RuadoLqn5H6z/iqrurbtxscnx0Qbdt8CBzREabJnWxHjxO936AXu9njIPvsXkTfaJJIXxRGGb0b8peSiCljwi8UEODe8mjl2c/LzLel6RuLQIDAQAB"; | |||
@@ -0,0 +1,183 @@ | |||
<?php | |||
namespace SRVX\Model; | |||
class SelfSupportForSchoolOrd extends BaseModel | |||
{ | |||
/** | |||
* | |||
* @var integer | |||
*/ | |||
public $id; | |||
/** | |||
* | |||
* @var integer | |||
*/ | |||
public $enterprise_id; | |||
/** | |||
* | |||
* @var integer | |||
*/ | |||
public $uid; | |||
/** | |||
* | |||
* @var integer | |||
*/ | |||
public $user_identity_id; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $out_order_no; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $trade_no; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $consumer; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $buyer_id; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $seller_id; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $device_sn; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $school_name; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $school_code; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $store_business_scenario; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $store_name; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $cp_store_id; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $merchant_name; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $cp_merchant_id; | |||
/** | |||
* | |||
* @var double | |||
*/ | |||
public $trade_amount; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $face_time; | |||
/** | |||
* | |||
* @var integer | |||
*/ | |||
public $order_status; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $debt_business_code; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $debt_business_msg; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $create_at; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $update_at; | |||
/** | |||
* Initialize method for model. | |||
*/ | |||
public function initialize() | |||
{ | |||
$this->setSchema("smart_canteen"); | |||
$this->setSource("self_support_for_school_ord"); | |||
} | |||
/** | |||
* Allows to query a set of records that match the specified conditions | |||
* | |||
* @param mixed $parameters | |||
* @return SelfSupportForSchoolOrd[]|SelfSupportForSchoolOrd|\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 SelfSupportForSchoolOrd|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null | |||
*/ | |||
public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface | |||
{ | |||
return parent::findFirst($parameters); | |||
} | |||
} |
@@ -0,0 +1,105 @@ | |||
<?php | |||
namespace SRVX\Model; | |||
class UserIdentity extends BaseModel | |||
{ | |||
/** | |||
* | |||
* @var integer | |||
*/ | |||
public $id; | |||
/** | |||
* | |||
* @var integer | |||
*/ | |||
public $uid; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $name; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $id_no; | |||
/** | |||
* | |||
* @var integer | |||
*/ | |||
public $kind; | |||
/** | |||
* | |||
* @var integer | |||
*/ | |||
public $identity; | |||
/** | |||
* | |||
* @var integer | |||
*/ | |||
public $enterprise_id; | |||
/** | |||
* | |||
* @var integer | |||
*/ | |||
public $state; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $memo; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $create_at; | |||
/** | |||
* | |||
* @var string | |||
*/ | |||
public $update_at; | |||
/** | |||
* Initialize method for model. | |||
*/ | |||
public function initialize() | |||
{ | |||
$this->setSchema("smart_canteen"); | |||
$this->setSource("user_identity"); | |||
} | |||
/** | |||
* Allows to query a set of records that match the specified conditions | |||
* | |||
* @param mixed $parameters | |||
* @return UserIdentity[]|UserIdentity|\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 UserIdentity|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null | |||
*/ | |||
public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface | |||
{ | |||
return parent::findFirst($parameters); | |||
} | |||
} |