Commit 1202b8c2 authored by wwccw0591's avatar wwccw0591

pc

parent 49c4b5c5
......@@ -2,7 +2,9 @@
namespace Alipay\aop;
require_once 'AopEncrypt.php';
require_once 'SignData.php';
$libaryUrl=\Bootstrap::getUrlIniConfig('libary');
require_once ($libaryUrl.'/Alipay/lotusphp_runtime/Logger/LtLogger.php');
class AopClient {
//应用ID
public $appId;
......@@ -230,14 +232,12 @@ class AopClient {
$reponse = curl_exec($ch);
if (curl_errno($ch)) {
throw new Exception(curl_error($ch), 0);
throw new \Exception(curl_error($ch), 0);
} else {
$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (200 !== $httpStatusCode) {
throw new Exception($reponse, $httpStatusCode);
throw new \Exception($reponse, $httpStatusCode);
}
}
......@@ -253,7 +253,7 @@ class AopClient {
protected function logCommunicationError($apiName, $requestUrl, $errorCode, $responseTxt) {
$localIp = isset ($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : "CLI";
$logger = new LtLogger;
$logger = new \LtLogger();
$logger->conf["log_file"] = rtrim(AOP_SDK_WORK_DIR, '\\/') . '/' . "logs/aop_comm_err_" . $this->appId . "_" . date("Y-m-d") . ".log";
$logger->conf["separator"] = "^_^";
$logData = array(
......@@ -464,7 +464,7 @@ class AopClient {
$sysParams["notify_url"] = $request->getNotifyUrl();
$sysParams["charset"] = $this->postCharset;
$sysParams["app_auth_token"] = $appInfoAuthtoken;
//获取业务参数
$apiParams = $request->getApiParas();
......@@ -475,17 +475,17 @@ class AopClient {
if ($this->checkEmpty($apiParams['biz_content'])) {
throw new Exception(" api request Fail! The reason : encrypt request is not supperted!");
throw new \Exception(" api request Fail! The reason : encrypt request is not supperted!");
}
if ($this->checkEmpty($this->encryptKey) || $this->checkEmpty($this->encryptType)) {
throw new Exception(" encryptType and encryptKey must not null! ");
throw new \Exception(" encryptType and encryptKey must not null! ");
}
if ("AES" != $this->encryptType) {
throw new Exception("加密类型只支持AES");
throw new \Exception("加密类型只支持AES");
}
// 执行加密
......@@ -510,7 +510,7 @@ class AopClient {
//发起HTTP请求
try {
$resp = $this->curl($requestUrl, $apiParams);
} catch (Exception $e) {
} catch (\Exception $e) {
$this->logCommunicationError($sysParams["method"], $requestUrl, "HTTP_ERROR_" . $e->getCode(), $e->getMessage());
return false;
......@@ -1014,7 +1014,7 @@ class AopClient {
* @param $signData
* @param $resp
* @param $respObject
* @throws Exception
* @throws \Exception
*/
public function checkResponseSign($request, $signData, $resp, $respObject) {
......@@ -1023,7 +1023,7 @@ class AopClient {
if ($signData == null || $this->checkEmpty($signData->sign) || $this->checkEmpty($signData->signSourceData)) {
throw new Exception(" check sign Fail! The reason : signData is Empty");
throw new \Exception(" check sign Fail! The reason : signData is Empty");
}
......@@ -1045,12 +1045,12 @@ class AopClient {
$checkResult = $this->verify($signData->signSourceData, $signData->sign, $this->alipayPublicKey, $this->signType);
if (!$checkResult) {
throw new Exception("check sign Fail! [sign=" . $signData->sign . ", signSourceData=" . $signData->signSourceData . "]");
throw new \Exception("check sign Fail! [sign=" . $signData->sign . ", signSourceData=" . $signData->signSourceData . "]");
}
} else {
throw new Exception("check sign Fail! [sign=" . $signData->sign . ", signSourceData=" . $signData->signSourceData . "]");
throw new \Exception("check sign Fail! [sign=" . $signData->sign . ", signSourceData=" . $signData->signSourceData . "]");
}
}
......
<?php
namespace Alipay\aop;
/**
* Created by PhpStorm.
* User: jiehua
......
......@@ -207,12 +207,21 @@ class Push
public function sendTcpMessage()
{
$push = \Yaf\Registry::get('config')->get('push');
$conf = \Yaf\Registry::get('config')->get('redis.database.params');
if ($push['open']) {
if(!empty($this->data)){
$redis=new \Redis();
$redis->connect($conf['host'], $conf['port']);
if(!empty($conf['password'])){
$redis->auth($conf['password']);
}
$message['data'] = $this->data;
$message['uid'] = !empty($this->uid)?$this->uid:ApiConst::zero;
// $message['data']=array_slice($message['data'],2,14);
$message = json_encode($message);
$key=md5($message);
$redis->set($key,$message);
$message=$key;
$message = $message . "\r\n";
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!@socket_connect($socket, $push['host'], $push['port'])) {
......@@ -239,6 +248,7 @@ class Push
return true;
}
unset($this->data);
unset($redis);
}
} else {
$this->errorCode = CodeConfigModel::pushIsNotOpen;
......
......@@ -62,7 +62,7 @@ class Alipay {
}
public function refund($order){
$refundAmount = round($order['refundAmount']/\Our\ApiConst::hundred,\Our\ApiConst::two);
if(APP_ENV == 'develop'||APP_ENV == 'test'||APP_ENV == 'pre'){
if(APP_ENV == 'develop'||APP_ENV == 'test'||APP_ENV == 'pre' || APP_ENV=='ccwdevelop'){
$refundAmount = 0.01;
}
$aop = new \Alipay\aop\AopClient();
......@@ -77,7 +77,7 @@ class Alipay {
$outRequestNo=$this->getRandomString(ApiConst::nine);
// require_once BASE_ROOT_PATH.'/core/payment/alipay/aop/request/AlipayTradeRefundRequest.php';
// //require_once 'aop/request/AlipayTradeRefundRequest.php';
$request = new \Alipay\aop\request\AlipayTradeAppPayRequest();
$request = new \Alipay\aop\request\AlipayTradeRefundRequest();
$request->setBizContent("{" .
"\"out_trade_no\":\"{$order['outTradeNo']}\"," .
"\"refund_amount\":{$refundAmount}," .
......
......@@ -68,15 +68,15 @@ class WxPay extends \Payment\TencentPay
{
$total_fee = intval($param['totalFee']);
$refund_fee = intval($param['refundFee']);
if (APP_ENV == 'develop' || APP_ENV == 'test' || APP_ENV == 'pre') {
if(APP_ENV == 'develop'||APP_ENV == 'test'||APP_ENV == 'pre' || APP_ENV=='ccwdevelop'){
$this->parameters['total_fee'] = 1;
$this->parameters['refund_fee'] = 1;
} else {
$this->parameters['total_fee'] = $total_fee;
$this->parameters['refund_fee'] = $refund_fee;
}
$this->parameters['out_refund_no'] = $param['refund_order_no'];
$this->parameters['out_trade_no'] = $param['out_trade_no'];
$this->parameters['out_refund_no'] = $param['refundOrderNo'];
$this->parameters['out_trade_no'] = $param['outTradeNo'];
$this->parameters['op_user_id'] = $this->mch_id;
$this->parameters['nonce_str'] = $this->createNoncestr(32);
$this->parameters['appid'] = \Our\PayConst::wxPayAppId;
......
......@@ -188,20 +188,30 @@ $tcp_server->on('connect', function($serv, $fd) use($conf){
*/
$tcp_server->on('receive', function($serv, $fd, $from_id, $data) use($conf) {
// echo $data;
$data = json_decode($data, true);
if(empty($data['data']) && !isset($data['data'])){
//$data = json_decode($data, true);
// if(empty($data['data']) && !isset($data['data'])){
// $serv->send($fd, responseJson(1,"fail", ['method' => 'receive', 'error_code' => 1, 'status' => 0]));
// $serv->close($fd);
// return;
// }
if(empty($data) && !isset($data)){
$serv->send($fd, responseJson(1,"fail", ['method' => 'receive', 'error_code' => 1, 'status' => 0]));
$serv->close($fd);
return;
}
$s = json_encode($data['data']);
echo $s;
// $s = json_encode($data['data']);
echo $data;
// 推送 存入redis、最后入库(MySQL)
$redis=new Redis();
$redis->connect($conf['host'], $conf['port']);
if(!empty($conf['password'])){
$redis->auth($conf['password']);
}
$key=trim($data,"\r\n");
$data=$redis->get($key);
$redis->delete($key);
$data=json_decode($data,true);
if(true) {
$serv->send($fd, responseJson(1,"success", ['method' => 'receive', 'error_code' => 0, 'status' => 1]));
$serv->close($fd);
......@@ -234,6 +244,7 @@ $tcp_server->on('receive', function($serv, $fd, $from_id, $data) use($conf) {
} else {
$serv->send($fd, responseJson(1,'fromMsg',"fail", ['method' => 'receive', 'error_code' => 110,'status' => 0]));
}
unset($redis);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment