更改ERP、订单状态接口替换成pcpayNotify
Showing
8 changed files
with
47 additions
and
69 deletions
@@ -220,21 +220,29 @@ class PayData | @@ -220,21 +220,29 @@ class PayData | ||
220 | } | 220 | } |
221 | 221 | ||
222 | /** | 222 | /** |
223 | - * 更新订单状态-未付款更新已付款状态 | ||
224 | - * @param type int $orderCode 订单号 | ||
225 | - * @param type int $paymentCode 支付方式 | ||
226 | - * @param type int $totalFee 金额 | 223 | + * 支付成功后--更新订单状态 |
224 | + * @param type string $orderCode 订单号 | ||
225 | + * @param type int $payment 支付方式 | ||
226 | + * @param type double $amount 金额(单位:元) | ||
227 | + * @param type string $bankName 银行名称 | ||
228 | + * @param type string $bankCode 银行代码 | ||
229 | + * @param type string $tradeNo 交易流水号 | ||
230 | + * @param type string $bankBillNo 银行流水号 | ||
227 | * @return type [] | 231 | * @return type [] |
228 | */ | 232 | */ |
229 | - public static function pcpayNotify($orderCode, $paymentCode, $totalFee) | 233 | + public static function pcpayNotify($orderCode, $payment, $amount, $bankName = '', $bankCode = '', $tradeNo = '', $bankBillNo = '') |
230 | { | 234 | { |
231 | $param = Yohobuy::param(); | 235 | $param = Yohobuy::param(); |
232 | $param['client_type'] = 'web'; | 236 | $param['client_type'] = 'web'; |
233 | $param['private_key'] = Yohobuy::$privateKeyList['web']; | 237 | $param['private_key'] = Yohobuy::$privateKeyList['web']; |
234 | $param['method'] = 'web.SpaceOrders.pcpayNotify'; | 238 | $param['method'] = 'web.SpaceOrders.pcpayNotify'; |
235 | - $param['orderCode'] = $orderCode; | ||
236 | - $param['paymentCode'] = $paymentCode; | ||
237 | - $param['totalFee'] = $totalFee; | 239 | + $param['order_code'] = $orderCode; |
240 | + $param['payment'] = $payment; | ||
241 | + $param['bank_name'] = $bankName; | ||
242 | + $param['bank_code'] = $bankCode; | ||
243 | + $param['amount'] = $amount; | ||
244 | + $param['trade_no'] = $tradeNo; | ||
245 | + $param['bank_bill_no'] = $bankBillNo; | ||
238 | 246 | ||
239 | $param['client_secret'] = Sign::getSign($param); | 247 | $param['client_secret'] = Sign::getSign($param); |
240 | 248 |
@@ -177,13 +177,12 @@ class Service extends PayAbstract | @@ -177,13 +177,12 @@ class Service extends PayAbstract | ||
177 | ksort($arrResponse); | 177 | ksort($arrResponse); |
178 | reset($arrResponse); | 178 | reset($arrResponse); |
179 | $sign = ''; | 179 | $sign = ''; |
180 | - foreach ($arrResponse AS $key=>$val) | ||
181 | - { | ||
182 | - if ($key != 'sign' && $key != 'sign_type' && $key != 'code') | ||
183 | - { | ||
184 | - $sign .= "$key=$val&"; | ||
185 | - } | ||
186 | - } | 180 | + foreach ($arrResponse AS $key => $val) { |
181 | + if ($key === 'sign' || $key === 'sign_type' || $key === 'code' || $val === '') { | ||
182 | + continue; | ||
183 | + } | ||
184 | + $sign .= "$key=$val&"; | ||
185 | + } | ||
187 | $sign = substr($sign, 0, -1) . $this->config->alipay_key; | 186 | $sign = substr($sign, 0, -1) . $this->config->alipay_key; |
188 | 187 | ||
189 | return md5($sign) != $arrResponse['sign'] ? false : true; | 188 | return md5($sign) != $arrResponse['sign'] ? false : true; |
@@ -203,9 +203,10 @@ class Service extends PayAbstract | @@ -203,9 +203,10 @@ class Service extends PayAbstract | ||
203 | reset($arrResponse); | 203 | reset($arrResponse); |
204 | $sign = ''; | 204 | $sign = ''; |
205 | foreach ($arrResponse AS $key => $val) { | 205 | foreach ($arrResponse AS $key => $val) { |
206 | - if ($key != 'sign' && $key != 'sign_type' && $key != 'code') { | ||
207 | - $sign .= "$key=$val&"; | 206 | + if ($key === 'sign' || $key === 'sign_type' || $key === 'code' || $val === '') { |
207 | + continue; | ||
208 | } | 208 | } |
209 | + $sign .= "$key=$val&"; | ||
209 | } | 210 | } |
210 | $sign = substr($sign, 0, -1) . $this->config->alipay_key; | 211 | $sign = substr($sign, 0, -1) . $this->config->alipay_key; |
211 | 212 |
@@ -167,19 +167,18 @@ class Service extends PayAbstract | @@ -167,19 +167,18 @@ class Service extends PayAbstract | ||
167 | */ | 167 | */ |
168 | protected function checkResponse(array $arrResponse) | 168 | protected function checkResponse(array $arrResponse) |
169 | { | 169 | { |
170 | - ksort($arrResponse); | ||
171 | - reset($arrResponse); | ||
172 | - $sign = ''; | ||
173 | - foreach ($arrResponse AS $key=>$val) | ||
174 | - { | ||
175 | - if ($key != 'sign' && $key != 'sign_type' && $key != 'code') | ||
176 | - { | 170 | + ksort($arrResponse); |
171 | + reset($arrResponse); | ||
172 | + $sign = ''; | ||
173 | + foreach ($arrResponse AS $key => $val) { | ||
174 | + if ($key === 'sign' || $key === 'sign_type' || $key === 'code' || $val === '') { | ||
175 | + continue; | ||
176 | + } | ||
177 | $sign .= "$key=$val&"; | 177 | $sign .= "$key=$val&"; |
178 | } | 178 | } |
179 | - } | ||
180 | - $sign = substr($sign, 0, -1) . $this->config->alipay_key; | 179 | + $sign = substr($sign, 0, -1) . $this->config->alipay_key; |
181 | 180 | ||
182 | - return md5($sign) != $arrResponse['sign'] ? false : true; | 181 | + return md5($sign) != $arrResponse['sign'] ? false : true; |
183 | 182 | ||
184 | } | 183 | } |
185 | } | 184 | } |
@@ -54,15 +54,6 @@ class PayNotifyCallBack extends WxPayNotify | @@ -54,15 +54,6 @@ class PayNotifyCallBack extends WxPayNotify | ||
54 | $tradeNo = $result['out_trade_no']; | 54 | $tradeNo = $result['out_trade_no']; |
55 | $bankBillNo = $result['bank_type']; | 55 | $bankBillNo = $result['bank_type']; |
56 | 56 | ||
57 | - $this->log->LogInfo('===[' . $orderCode . ']==='); | ||
58 | - | ||
59 | - $this->log->LogInfo('==[' . $orderCode . ']=开始调用ERP提交订单状态接口,接口方法为web.SpaceOrders.submitOrderStatus==='); | ||
60 | - $this->log->LogInfo('==[' . $orderCode . ']=请求参数为orderCode=' . $orderCode . '==='); | ||
61 | - // ERP提交订单状态 | ||
62 | - $erpReturn = PayData::submitOrderStatus($orderCode, $payment, $bankName, $bankCode, $amount, $orderCode, $tradeNo, $bankBillNo); | ||
63 | - $this->log->LogInfo('==[' . $orderCode . ']=结束调用ERP提交订单状态接口,返回结果为==='); | ||
64 | - $this->log->LogInfo(var_export($erpReturn, true)); | ||
65 | - | ||
66 | $this->log->LogInfo('==[' . $orderCode . ']=开始调用获取订单详情方式接口,接口方法为app.SpaceOrders.detail==='); | 57 | $this->log->LogInfo('==[' . $orderCode . ']=开始调用获取订单详情方式接口,接口方法为app.SpaceOrders.detail==='); |
67 | $orderInfo = OrderData::getOrderDetail('', $orderCode); | 58 | $orderInfo = OrderData::getOrderDetail('', $orderCode); |
68 | $this->log->LogInfo('==[' . $orderCode . ']=结束调用获取订单详情方式接口,返回结果为==='); | 59 | $this->log->LogInfo('==[' . $orderCode . ']=结束调用获取订单详情方式接口,返回结果为==='); |
@@ -72,12 +63,9 @@ class PayNotifyCallBack extends WxPayNotify | @@ -72,12 +63,9 @@ class PayNotifyCallBack extends WxPayNotify | ||
72 | $this->log->LogInfo('==[' . $orderCode . ']=微信支付状态同步中未获取到订单详情信息==='); | 63 | $this->log->LogInfo('==[' . $orderCode . ']=微信支付状态同步中未获取到订单详情信息==='); |
73 | return false; | 64 | return false; |
74 | } | 65 | } |
75 | - | ||
76 | - $this->log->LogInfo('==[' . $orderCode . ']=开始调用更新订单状态接口,接口方法为web.SpaceOrders.updatePaymentStatus==='); | ||
77 | - $this->log->LogInfo('==[' . $orderCode . ']=请求参数为orderId=' . $orderInfo['data']['order_id'] . 'uid=' . $this->_uid . '==='); | ||
78 | - // 更新订单的状态 | ||
79 | - $updateOrderStatus = PayData::updateOrderStatus($orderInfo['data']['order_id'], $this->_uid, $payment, 'Y', $bankCode); | ||
80 | - $this->log->LogInfo('==[' . $orderCode . ']=结束调用更新订单状态接口,返回结果为==='); | 66 | + |
67 | + //更新订单状态 | ||
68 | + $updateOrderStatus = PayData::pcpayNotify($orderCode, $payment, $amount, $bankName, $bankCode, $tradeNo, $bankBillNo); | ||
81 | $this->log->LogInfo(var_export($updateOrderStatus, true)); | 69 | $this->log->LogInfo(var_export($updateOrderStatus, true)); |
82 | $this->log->LogInfo('==[' . $orderCode . ']=微信扫码订单支付成功==='); | 70 | $this->log->LogInfo('==[' . $orderCode . ']=微信扫码订单支付成功==='); |
83 | 71 |
@@ -152,20 +152,10 @@ class PayModel | @@ -152,20 +152,10 @@ class PayModel | ||
152 | $log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL); | 152 | $log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL); |
153 | $log->LogInfo('===[' . $orderCode . ']==='); | 153 | $log->LogInfo('===[' . $orderCode . ']==='); |
154 | 154 | ||
155 | - // ERP提交订单状态 | ||
156 | - $log->LogInfo('===开始调用ERP提交订单状态接口,接口方法为web.SpaceOrders.submitOrderStatus==='); | ||
157 | - $log->LogInfo('===请求参数为orderCode=' . $orderCode . '==='); | ||
158 | - $erpReturn = PayData::submitOrderStatus($orderCode, 0, '', '', 0, '', '', ''); | ||
159 | - $log->LogInfo('===结束调用ERP提交订单状态接口,返回结果为==='); | ||
160 | - $log->LogInfo(var_export($erpReturn, true)); | ||
161 | - | ||
162 | - // 更新订单的状态 | ||
163 | - $log->LogInfo('===开始调用更新订单状态接口,接口方法为web.SpaceOrders.updatePaymentStatus==='); | ||
164 | - $log->LogInfo('===请求参数为orderId=' . $order['order_id'] . 'uid=' . $uid . '==='); | ||
165 | - $updateOrderStatus = PayData::updateOrderStatus($order['order_id'], $uid, 0, 'Y', ''); | ||
166 | - $log->LogInfo('===结束调用更新订单状态接口,返回结果为==='); | 155 | + //无需付款-更新订单状态 |
156 | + $updateOrderStatus = PayData::pcpayNotify($orderCode, 0, 0); | ||
157 | + $log->LogInfo('===无需付款---结束调用更新订单状态接口,返回结果为==='); | ||
167 | $log->LogInfo(var_export($updateOrderStatus, true)); | 158 | $log->LogInfo(var_export($updateOrderStatus, true)); |
168 | - | ||
169 | $result['notNeedPay'] = true; | 159 | $result['notNeedPay'] = true; |
170 | break; | 160 | break; |
171 | } | 161 | } |
@@ -580,18 +570,8 @@ class PayModel | @@ -580,18 +570,8 @@ class PayModel | ||
580 | // 初始化日志 | 570 | // 初始化日志 |
581 | $log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL); | 571 | $log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL); |
582 | $log->LogInfo('===[' . $orderCode . ']==='); | 572 | $log->LogInfo('===[' . $orderCode . ']==='); |
583 | - | ||
584 | - $log->LogInfo('==[' . $orderCode . ']=开始调用ERP提交订单状态接口,接口方法为web.SpaceOrders.submitOrderStatus==='); | ||
585 | - $log->LogInfo('==[' . $orderCode . ']=请求参数为orderCode=' . $orderCode . '==='); | ||
586 | - // ERP提交订单状态 | ||
587 | - $erpReturn = PayData::submitOrderStatus($orderCode, $payment, $bankName, $bankCode, $amount, $payOrderCode, $tradeNo, $bankBillNo); | ||
588 | - $log->LogInfo('==[' . $orderCode . ']=结束调用ERP提交订单状态接口,返回结果为==='); | ||
589 | - $log->LogInfo(var_export($erpReturn, true)); | ||
590 | - | ||
591 | - $log->LogInfo('==[' . $orderCode . ']=开始调用更新订单状态接口,接口方法为web.SpaceOrders.updatePaymentStatus==='); | ||
592 | - $log->LogInfo('==[' . $orderCode . ']=请求参数为orderId=' . $orderData['order_id'] . 'uid=' . $uid . '==='); | ||
593 | - // 更新订单的状态 | ||
594 | - $updateOrderStatus = PayData::updateOrderStatus($orderData['order_id'], $uid, $payment, 'Y', $bankCode); | 573 | + //更新订单状态 |
574 | + $updateOrderStatus = PayData::pcpayNotify($orderCode, $payment, $amount, $bankName, $bankCode, $tradeNo, $bankBillNo); | ||
595 | $log->LogInfo('==[' . $orderCode . ']=结束调用更新订单状态接口,返回结果为==='); | 575 | $log->LogInfo('==[' . $orderCode . ']=结束调用更新订单状态接口,返回结果为==='); |
596 | $log->LogInfo(var_export($updateOrderStatus, true)); | 576 | $log->LogInfo(var_export($updateOrderStatus, true)); |
597 | $log->LogInfo('==[' . $orderCode . ']=订单支付成功,请等待发货==='); | 577 | $log->LogInfo('==[' . $orderCode . ']=订单支付成功,请等待发货==='); |
@@ -223,7 +223,10 @@ class NoticeController extends WebAction | @@ -223,7 +223,10 @@ class NoticeController extends WebAction | ||
223 | $payment = PayModel::getPaymentById(1); | 223 | $payment = PayModel::getPaymentById(1); |
224 | $payService = PayFactory::factory($payment); | 224 | $payService = PayFactory::factory($payment); |
225 | $rspParams = $payService->parseResponse($_GET); //财付通是以get方式回复的。 | 225 | $rspParams = $payService->parseResponse($_GET); //财付通是以get方式回复的。 |
226 | - $this->payResultProc($rspParams, 1); | 226 | + |
227 | + $dealResult = $this->payResultProc($rspParams, 1); | ||
228 | + $dealResult['payData'] = array('payWay' => '财付通'); | ||
229 | + $this->commonShowResult($dealResult); | ||
227 | } | 230 | } |
228 | 231 | ||
229 | /** | 232 | /** |
@@ -184,7 +184,7 @@ routes.coupons.route.action = Index | @@ -184,7 +184,7 @@ routes.coupons.route.action = Index | ||
184 | 184 | ||
185 | ; 商品支付方式选择 | 185 | ; 商品支付方式选择 |
186 | routes.paytypechoose.type = "rewrite" | 186 | routes.paytypechoose.type = "rewrite" |
187 | -routes.paytypechoose.match = "/shopping/pay" | 187 | +routes.paytypechoose.match = "/shopping/pay$" |
188 | routes.paytypechoose.route.module = Shopping | 188 | routes.paytypechoose.route.module = Shopping |
189 | routes.paytypechoose.route.controller = Pay | 189 | routes.paytypechoose.route.controller = Pay |
190 | routes.paytypechoose.route.action = Index | 190 | routes.paytypechoose.route.action = Index |
-
Please register or login to post a comment