Commit 1202b8c2 authored by wwccw0591's avatar wwccw0591

pc

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