Commit de2222b7 authored by zhz's avatar zhz

Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into master_dev

parents b5aec359 9777a7a3
......@@ -57,7 +57,28 @@ class Common
return isset($httpStatusCodes[$num]) ? $httpStatusCodes[$num] : '';
}
public static function isSerialized( $data ) {
$data = trim( $data );
if ( 'N;' == $data )
return true;
if ( !preg_match( '/^([adObis]):/', $data, $badions ) )
return false;
switch ( $badions[1] ) {
case 'a' :
case 'O' :
case 's' :
if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) )
return true;
break;
case 'b' :
case 'i' :
case 'd' :
if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) )
return true;
break;
}
return false;
}
/**
* 获取客户端IP
*
......
......@@ -210,7 +210,8 @@ class Push
if ($push['open']) {
if(!empty($this->data)){
$message['data'] = $this->data;
$message['uid'] = $this->uid;
$message['uid'] = !empty($this->uid)?$this->uid:ApiConst::zero;
// $message['data']=array_slice($message['data'],2,14);
$message = json_encode($message);
$message = $message . "\r\n";
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
......
......@@ -8,12 +8,14 @@ namespace Payment;
* Description:
*/
class WxPay extends \Payment\TencentPay{
class WxPay extends \Payment\TencentPay
{
private $refundUrl="https://api.mch.weixin.qq.com/secapi/pay/refund";
public function __construct()
{
$this->appid = \Our\PayConst::wxPayAppId;
$this->notify_url = \Our\NameConst::httpPrefix.$_SERVER['SERVER_NAME'].\Our\PayConst::wxAppNotifyUrl;
$this->notify_url = \Our\NameConst::httpPrefix . $_SERVER['SERVER_NAME'] . \Our\PayConst::wxAppNotifyUrl;
$this->mch_id = \Our\PayConst::wxPayMchId;
$this->key = \Our\PayConst::wxPayKey;
$this->sslcert_path = \Our\PayConst::wxSslcertPath;
......@@ -22,12 +24,13 @@ class WxPay extends \Payment\TencentPay{
$this->tradeType = \Our\PayConst::wxAppTradeType;
}
public function doPay($orderInfo){
public function doPay($orderInfo)
{
$this->setRequestParams($orderInfo);
$wxAppParameters = $this->getParameters();
$returnData = array(
'credential'=>array(\Our\NameConst::wxAppChannel=>$wxAppParameters),
'app_id'=>$this->appid
'credential' => array(\Our\NameConst::wxAppChannel => $wxAppParameters),
'app_id' => $this->appid
);
return $returnData;
}
......@@ -48,6 +51,45 @@ class WxPay extends \Payment\TencentPay{
return $wxApiObj;
}
/**
* 作用:产生随机字符串,不长于32位
*/
private function createNoncestr($length = 32)
{
$chars = "abcdefghijklmnopqrstuvwxyz0123456789";
$str = "";
for ($i = 0; $i < $length; $i++) {
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
}
return $str;
}
public function refund($param)
{
$total_fee = intval($param['totalFee']);
$refund_fee = intval($param['refundFee']);
if (APP_ENV == 'develop' || APP_ENV == 'test' || APP_ENV == 'pre') {
$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['op_user_id'] = $this->mch_id;
$this->parameters['nonce_str'] = $this->createNoncestr(32);
$this->parameters['appid'] = \Our\PayConst::wxPayAppId;
$this->parameters['mch_id'] = \Our\PayConst::wxPayMchId;
$xml = $this->createXml();
$response = $this->postXmlSSLCurl($xml, $this->refundUrl, 6);
$values = $this->xmlToArray($response);
if ($values['return_code'] != 'SUCCESS') {
return $values;
}
$this->checkSign($values);
return $values;
}
/**
* 类实例
......
......@@ -45,7 +45,7 @@ class OrderModel extends \DAO\AbstractModel
public function getOrderDetailField()
{
return 'order_id as orderId,coupon_id as couponId,refund_amount as refundAmount,order_sn as orderSn,store_name as storeName,add_time as addTime,store_id as storeId,goods_amount as goodsAmount,shipping_fee as shippingFee,order_amount as orderAmount,shipping_type as shippingType,payment_type as paymentType,order_state as orderState,shipping_fee as shippingFee,refund_state as refundState,order_type as orderType,is_receive_payment as isReceivePayment,payment_time as paymentTime,finnshed_time as finnshedTime,need_shipping_fee as needShippingFee,payment_code as paymentCode,buyer_id as buyerId,buyer_name as buyerName,refund_condition as refundCondition';
return 'order_id as orderId,coupon_id as couponId,refund_amount as refundAmount,order_sn as orderSn,pay_sn as paySn,store_name as storeName,add_time as addTime,store_id as storeId,goods_amount as goodsAmount,shipping_fee as shippingFee,order_amount as orderAmount,shipping_type as shippingType,payment_type as paymentType,order_state as orderState,shipping_fee as shippingFee,refund_state as refundState,order_type as orderType,is_receive_payment as isReceivePayment,payment_time as paymentTime,finnshed_time as finnshedTime,need_shipping_fee as needShippingFee,payment_code as paymentCode,buyer_id as buyerId,buyer_name as buyerName,refund_condition as refundCondition';
}
public function getOrderShippingField()
......
......@@ -162,7 +162,8 @@ abstract class BaseCli
protected function _getBaseFileName($path)
{
return dirname(__FILE__).DS.$path.DS.'locks';
$locksPath=\Our\Common::getConfig('out.locks');
return $locksPath.DS.$path.DS.'locks';
}
......
......@@ -56,12 +56,12 @@ class cliOrderClose extends basecli
echo "*** Debug mode ***\n";
}
// Step: 02 检查是否已有相同CLI在运行中
$lockDir=$this->_getBaseFileName('orderClose');
$lockDir=$this->_getBaseFileName('order');
if(!$this->mkdirs($lockDir)){
echo '****create dir fail ****';
exit;
}
$this->lockFileName = $lockDir .'.locks';
$this->lockFileName = $lockDir .DS.'close.locks';
if( file_exists( $this->lockFileName ) )
{
$stat = stat($this->lockFileName);
......@@ -76,7 +76,9 @@ class cliOrderClose extends basecli
}
}
$this->bDoUnLock = true;
if(APP_ENV =='pre' || APP_ENV=='product'){
file_put_contents($this->lockFileName ,"running" ); // CLI 独占锁
}
$this->autoCloseOrder();
echo '定单关闭消息发送成功'."\r\n";
......
......@@ -187,8 +187,14 @@ $tcp_server->on('connect', function($serv, $fd) use($conf){
* 4. 按照用户类型(channel)推送
*/
$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'])) return;
var_dump($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;
}
$s = json_encode($data['data']);
echo $s;
// 推送 存入redis、最后入库(MySQL)
......
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