Authored by 周少峰

Merge branch 'temp' of git.dev.yoho.cn:web/yohobuy into temp

... ... @@ -6,6 +6,8 @@ use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Reqparams;
use WebPlugin\Pay\Rspparams;
use WebPlugin\Pay\Signature;
use WebPlugin\Pay\weixin\lib\WxPayApi;
use WebPlugin\Pay\weixin\lib\WxPayOrderQuery;
class Service extends PayAbstract
{
... ... @@ -74,25 +76,33 @@ class Service extends PayAbstract
return array('pay_url' => $payUrl);
}
public function parseResponse(array $arrResponse) {
public function parseResponse(array $data) {
/* 返回示例
* http://www.yohobuy.com/pay/notice/wechatqrcodereturn?ordercode=93465435
*/
// 组装微信支付的订单号
$tradeNo = 'YOHOBuy_' . $data['orderCode'];
$input = new WxPayOrderQuery();
$input->SetOut_trade_no($tradeNo);
$result = WxPayApi::orderQuery($input);
$rsp = new Rspparams();
if($arrResponse['payResult'] == 200){
// 支付成功
if(isset($result['trade_state']) && $result['trade_state'] === 'SUCCESS'){
$rsp->payResult = 200;
$rsp->bankName = "WX";
$rsp->orderCode = $arrResponse['order_code'];
$rsp->payTime = $arrResponse["arrive_time"];
$rsp->totalFee = $arrResponse["amount"];
$rsp->orderCode = $data['orderCode'];
$rsp->payTime = $result["time_end"];
$rsp->totalFee = $result["total_fee"] / 100;
$rsp->resultMsg = '支付成功';
//添加支付订单号和交易号
$rsp->payOrderCode = $arrResponse["order_code"];
$rsp->tradeNo = "";
$rsp->bankBillNo = "";
$rsp->payOrderCode = $data["orderCode"];
$rsp->tradeNo = $result["out_trade_no"];
$rsp->bankBillNo = $result['bank_type'];
}else{
$rsp->payResult = -1;
}
return $rsp;
}
... ...
... ... @@ -4,6 +4,7 @@ namespace WebPlugin\Pay\weixin;
use WebPlugin\Pay\weixin\lib\WxPayApi;
use WebPlugin\Pay\weixin\lib\WxPayNotify;
use WebPlugin\Pay\weixin\lib\WxPayOrderQuery;
class PayNotifyCallBack extends WxPayNotify
{
... ...
... ... @@ -31,7 +31,7 @@ class WxPayConfig
const APPSECRET = 'ce21ae4a3f93852279175a167e54509b';
//=======【异步通知url设置】===================================
//异步通知url,商户根据实际开发过程设定
const NOTIFY_URL = 'http://www.yohobuy.com/pay/notice/wechatqrcodereturn';
const NOTIFY_URL = 'http://www.yohobuy.com/pay/notice/wechatqrcodenotify';
//=======【证书路径设置】=====================================
/**
* TODO:设置商户证书路径
... ...
... ... @@ -80,7 +80,7 @@ class WxPayNotify extends WxPayNotifyReply
{
//如果需要签名
if ($needSign == true &&
$this->GetReturn_code($return_code) == "SUCCESS") {
$this->GetReturn_code() == "SUCCESS") {
$this->SetSign();
}
WxpayApi::replyNotify($this->ToXml());
... ...
... ... @@ -9,8 +9,10 @@ use WebPlugin\Pay\Banks;
use WebPlugin\Pay\PayFactory;
use WebPlugin\Pay\Reqparams;
use WebPlugin\Pay\Rspparams;
use WebPlugin\Pay\weixin\lib\WxPayApi;
use WebPlugin\Pay\weixin\lib\WxPayConfig;
use WebPlugin\Pay\weixin\lib\WxPayNativePay;
use WebPlugin\Pay\weixin\lib\WxPayOrderQuery;
use WebPlugin\Pay\weixin\lib\WxPayUnifiedOrder;
/**
... ... @@ -342,10 +344,9 @@ class PayModel
*
* @param int $uid 用户ID
* @param string $orderCode 订单号
* @param int $paymentCode 支付方式ID
* @return array
*/
public static function weixinQrcode($uid, $orderCode, $paymentCode)
public static function weixinQrcode($uid, $orderCode)
{
$result = array();
... ... @@ -404,46 +405,6 @@ class PayModel
return $result;
}
/**
* 处理支付结果数据
*
* @param int $uid 用户ID
* @param string $orderCode 订单号
* @return array
*/
public static function getPayDetail($uid, $orderCode)
{
$result = array(
'code' => 500,
'message' => '支付失败'
);
do {
$orderInfo = OrderData::getOrderDetail($uid, $orderCode);
if (!isset($orderInfo['data']['payment_status']) || $orderInfo['data']['payment_status'] !== 'Y') {
break;
}
$result['code'] = 200;
$result['message'] = '支付成功,请等待发货';
$orderData = $orderInfo['data'];
$result['data'] = array(
'pay' => $orderData['payment_amount'],
'orderNum' => $orderData['order_code'],
'checkOrderUrl' => Helpers::url('/home/orders/detail', array('order_code' => $orderData['order_code'])),
'payMode' => ($orderData['payment_type'] == 1 ? '在线支付' : '货到付款'),
'currency' => $orderData['yoho_give_coin'],
'yohoCoinUrl' => Helpers::url('/help', array('category_id' => 87)),
'vipSum' => $orderData['order_code'],
'returnGoodsUrl' => Helpers::url('/help', array('category_id' => 121)),
'vipUrl' => Helpers::url('/help', array('category_id' => 91)),
'returnHomeUrl' => Helpers::url('/')
);
} while (false);
return $result;
}
/**
* 检查微信扫码支付结果
*
... ... @@ -463,12 +424,13 @@ class PayModel
break;
}
$orderInfo = OrderData::getOrderDetail($uid, $orderCode);
if (!isset($orderInfo['data']) || empty($orderInfo['data'])) {
break;
}
// 组装微信支付的订单号
$tradeNo = 'YOHOBuy_' . $orderCode;
$input = new WxPayOrderQuery();
$input->SetOut_trade_no($tradeNo);
$payResult = WxPayApi::orderQuery($input);
if ($orderInfo['data']['payment_status'] === 'Y') {
if (isset($payResult['trade_state']) && $payResult['trade_state'] === 'SUCCESS') {
$result = array(
'code' => '200',
'message' => 'success'
... ...
... ... @@ -2,9 +2,9 @@
use Action\WebAction;
use Shopping\PayModel;
use WebPlugin\Helpers;
use WebPlugin\Pay\PayFactory;
use WebPlugin\Pay\Rspparams;
use WebPlugin\Pay\weixin\PayNotifyCallBack;
/**
* 支付Notice
... ... @@ -237,24 +237,34 @@ class NoticeController extends WebAction
}
/**
* 微信扫码支付返回返回
* 微信扫码支付结果商户通知地址
*/
public function wechatqrcodenotifyAction()
{
$notify = new PayNotifyCallBack();
$notify->handle(false);
}
/**
* 微信扫码支付返回
*/
public function wechatqrcodereturnAction()
{
//判断是否登录
$uid = $this->auditJumpLogin();
$dealResult = array(
'code' => 500,
'message' => '支付失败'
);
do {
$orderCode = isset($_GET['order_code']) ? $_GET['order_code'] : 0;
if (empty($orderCode)) {
$dealResult = array(
'code' => 500,
'message' => '支付失败'
);
break;
}
$dealResult = PayModel::getPayDetail($uid, $orderCode);
$payment = PayModel::getPaymentById(21);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse(array('orderCode' => $orderCode));
$dealResult = $this->payResultProc($res, 21);
$dealResult['payData'] = array('payWay' => '微信扫码支付');
} while (false);
... ... @@ -266,23 +276,11 @@ class NoticeController extends WebAction
*/
public function unionpaywebreturnAction()
{
//判断是否登录
$uid = $this->auditJumpLogin();
do {
$orderCode = isset($_GET['order_code']) ? $_GET['order_code'] : 0;
if (empty($orderCode)) {
$dealResult = array(
'code' => 500,
'message' => '支付失败'
);
break;
}
$dealResult = PayModel::getPayDetail($uid, $orderCode);
$dealResult['payData'] = array('payWay' => '银联在线支付');
} while (false);
$payment = PayModel::getPaymentById(25);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_REQUEST);
$dealResult = $this->payResultProc($res, 25);
$dealResult['payData'] = array('payWay' => '银联在线支付');
$this->commonShowResult($dealResult);
}
... ...
... ... @@ -19,8 +19,7 @@ class WechatqrcodeController extends WebAction
}
$orderCode = $this->get('order_code', $this->get('ordercode'));
$paymentCode = $this->get('payment_code');
$data = PayModel::weixinQrcode($uid, $orderCode, $paymentCode);
$data = PayModel::weixinQrcode($uid, $orderCode);
if (isset($data['error'])) {
$this->helpJsRedirect($data['message']);
}
... ...