...
|
...
|
@@ -401,7 +401,12 @@ class PayModel |
|
|
$result = array();
|
|
|
|
|
|
do {
|
|
|
// 初始化日志
|
|
|
$log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL);
|
|
|
$log->LogInfo('=====[' . $orderCode . ']===开始生成微信支付二维码========');
|
|
|
|
|
|
if (empty($orderCode)) {
|
|
|
$log->LogInfo('=====[' . $orderCode . ']===微信支付时,订单号为空========');
|
|
|
$result['error'] = true;
|
|
|
$result['message'] = '订单号不能为空';
|
|
|
break;
|
...
|
...
|
@@ -410,6 +415,7 @@ class PayModel |
|
|
/* 判断订单信息是否存在 */
|
|
|
$orderDetail = OrderData::getOrderDetail($uid, $orderCode);
|
|
|
if (!isset($orderDetail['data']) || empty($orderDetail['data'])) {
|
|
|
$log->LogInfo('=====[' . $orderCode . ']===微信支付时,订单信息未查到========');
|
|
|
$result['error'] = true;
|
|
|
$result['message'] = '没有找到该订单';
|
|
|
break;
|
...
|
...
|
@@ -436,6 +442,8 @@ class PayModel |
|
|
$input->SetProduct_id($orderCode);
|
|
|
$notify = new WxPayNativePay();
|
|
|
$payResult = $notify->GetPayUrl($input);
|
|
|
$log->LogInfo('=====[' . $orderCode . ']===微信支付时,微信统一下单的返回结果为:========');
|
|
|
$log->LogInfo(var_export($payResult, true));
|
|
|
|
|
|
$orderData = $orderDetail['data'];
|
|
|
$firstGoods = current($orderData['order_goods']);
|
...
|
...
|
@@ -447,10 +455,12 @@ class PayModel |
|
|
'tellphoneNum' => $orderData['mobile'],
|
|
|
'tradeName' => $firstGoods['product_name'],
|
|
|
'choosePayUrl' => Helpers::url('/shopping/pay', array('order_code' => $orderData['order_code'])),
|
|
|
'qrcodeUrl' => $payResult['code_url']//$reqPars['pay_url'] // 'http://paysdk.weixin.qq.com/example/qrcode.php?data=' . $result['code_url']
|
|
|
'qrcodeUrl' => $payResult['code_url'] // 'http://paysdk.weixin.qq.com/example/qrcode.php?data=' . $result['code_url']
|
|
|
);
|
|
|
|
|
|
} while (false);
|
|
|
$log->LogInfo('=====[' . $orderCode . ']===微信支付时,处理微信支付的结果为:========');
|
|
|
$log->LogInfo(var_export($result, true));
|
|
|
|
|
|
return $result;
|
|
|
}
|
...
|
...
|
@@ -476,22 +486,24 @@ class PayModel |
|
|
|
|
|
// 初始化日志
|
|
|
$log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL);
|
|
|
$log->LogInfo('========[' . $orderCode . ']========');
|
|
|
$log->LogInfo('========开始查询微信扫码支付状态========');
|
|
|
$log->LogInfo('=====[' . $orderCode . ']===开始查询微信扫码支付状态========');
|
|
|
|
|
|
// 组装微信支付的订单号
|
|
|
$tradeNo = 'YOHOBuy_' . $orderCode;
|
|
|
$input = new WxPayOrderQuery();
|
|
|
$input->SetOut_trade_no($tradeNo);
|
|
|
$payResult = WxPayApi::orderQuery($input);
|
|
|
$log->LogInfo(var_export($payResult, true));
|
|
|
|
|
|
if (isset($payResult['trade_state']) && $payResult['trade_state'] === 'SUCCESS') {
|
|
|
$log->LogInfo('========微信扫码支付成功========');
|
|
|
$log->LogInfo('====[' . $orderCode . ']====微信扫码支付成功========');
|
|
|
$result = array(
|
|
|
'code' => '200',
|
|
|
'message' => 'success'
|
|
|
);
|
|
|
}
|
|
|
|
|
|
$log->LogInfo('====[' . $orderCode . ']====微信扫码支付失败========');
|
|
|
} while (false);
|
|
|
|
|
|
return $result;
|
...
|
...
|
@@ -518,13 +530,13 @@ class PayModel |
|
|
$log->LogInfo('========[' . $payResult->orderCode . ']========');
|
|
|
$log->LogInfo(var_export($payResult, true));
|
|
|
|
|
|
$log->LogInfo('===开始调用获取订单详情方式接口,接口方法为app.SpaceOrders.detail===');
|
|
|
$log->LogInfo('==[' . $payResult->orderCode . ']=开始调用获取订单详情方式接口,接口方法为app.SpaceOrders.detail===');
|
|
|
$orderInfo = OrderData::getOrderDetail($uid, $payResult->orderCode);
|
|
|
$log->LogInfo('===结束调用获取订单详情方式接口,返回结果为===');
|
|
|
$log->LogInfo('==[' . $payResult->orderCode . ']=结束调用获取订单详情方式接口,返回结果为===');
|
|
|
$log->LogInfo(var_export($orderInfo, true));
|
|
|
|
|
|
if (!isset($orderInfo['data']) || empty($orderInfo['data'])) {
|
|
|
$log->LogInfo('===订单支付失败,未获取到订单详情信息===');
|
|
|
$log->LogInfo('==[' . $payResult->orderCode . ']=订单支付失败,未获取到订单详情信息===');
|
|
|
break;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -539,9 +551,9 @@ class PayModel |
|
|
// 初始化日志
|
|
|
$log = new PhpLog(self::SEND_MESSAGE_LOG, 'PRC', self::LOG_LEVEL);
|
|
|
$log->LogInfo('===[' . $orderCode . ']===');
|
|
|
$log->LogInfo('===开始调用订单取消时给用户发短信接口,接口方法为app.message.sendMsg===');
|
|
|
$log->LogInfo('==[' . $orderCode . ']=开始调用订单取消时给用户发短信接口,接口方法为app.message.sendMsg===');
|
|
|
$messageReturn = PayData::sendMessage($orderData['mobile'], 'error_sms', '支付成功,但订单已取消,订单号为' . $orderCode);
|
|
|
$log->LogInfo('===结束调用给用户发短信接口,返回结果为===');
|
|
|
$log->LogInfo('==[' . $orderCode . ']=结束调用给用户发短信接口,返回结果为===');
|
|
|
$log->LogInfo(var_export($messageReturn, true));
|
|
|
|
|
|
$result['code'] = 417;
|
...
|
...
|
@@ -552,7 +564,7 @@ class PayModel |
|
|
// 支付金额与订单金额不一致
|
|
|
if (round($amount, 2) != round($payResult->totalFee, 2)) {
|
|
|
$log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL);
|
|
|
$log->LogInfo('===订单支付失败,支付金额与订单金额不一致===');
|
|
|
$log->LogInfo('==[' . $orderCode . ']=订单支付失败,支付金额与订单金额不一致===');
|
|
|
$result['code'] = 415;
|
|
|
$result['message'] = '支付金额与订单金额不一致';
|
|
|
break;
|
...
|
...
|
@@ -569,20 +581,20 @@ class PayModel |
|
|
$log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL);
|
|
|
$log->LogInfo('===[' . $orderCode . ']===');
|
|
|
|
|
|
$log->LogInfo('===开始调用ERP提交订单状态接口,接口方法为web.SpaceOrders.submitOrderStatus===');
|
|
|
$log->LogInfo('===请求参数为orderCode=' . $orderCode . '===');
|
|
|
$log->LogInfo('==[' . $orderCode . ']=开始调用ERP提交订单状态接口,接口方法为web.SpaceOrders.submitOrderStatus===');
|
|
|
$log->LogInfo('==[' . $orderCode . ']=请求参数为orderCode=' . $orderCode . '===');
|
|
|
// ERP提交订单状态
|
|
|
$erpReturn = PayData::submitOrderStatus($orderCode, $payment, $bankName, $bankCode, $amount, $payOrderCode, $tradeNo, $bankBillNo);
|
|
|
$log->LogInfo('===结束调用ERP提交订单状态接口,返回结果为===');
|
|
|
$log->LogInfo('==[' . $orderCode . ']=结束调用ERP提交订单状态接口,返回结果为===');
|
|
|
$log->LogInfo(var_export($erpReturn, true));
|
|
|
|
|
|
$log->LogInfo('===开始调用更新订单状态接口,接口方法为web.SpaceOrders.updatePaymentStatus===');
|
|
|
$log->LogInfo('===请求参数为orderId=' . $orderData['order_id'] . 'uid=' . $uid . '===');
|
|
|
$log->LogInfo('==[' . $orderCode . ']=开始调用更新订单状态接口,接口方法为web.SpaceOrders.updatePaymentStatus===');
|
|
|
$log->LogInfo('==[' . $orderCode . ']=请求参数为orderId=' . $orderData['order_id'] . 'uid=' . $uid . '===');
|
|
|
// 更新订单的状态
|
|
|
$updateOrderStatus = PayData::updateOrderStatus($orderData['order_id'], $uid, $payment, 'Y', $bankCode);
|
|
|
$log->LogInfo('===结束调用更新订单状态接口,返回结果为===');
|
|
|
$log->LogInfo('==[' . $orderCode . ']=结束调用更新订单状态接口,返回结果为===');
|
|
|
$log->LogInfo(var_export($updateOrderStatus, true));
|
|
|
$log->LogInfo('===订单支付成功,请等待发货===');
|
|
|
$log->LogInfo('==[' . $orderCode . ']=订单支付成功,请等待发货===');
|
|
|
|
|
|
$result['code'] = 200;
|
|
|
$result['message'] = '支付成功,请等待发货';
|
...
|
...
|
|