| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace shop\controllers;
- use Yii;
- use common\components\util;
- use common\services\xhPayToolService;
- class NoticeController extends PublicController
- {
-
- public $categoryList;
-
- //微信支付异步回调
- public function actionWxCallback()
- {
- $postStr = file_get_contents('php://input');//接收微信服务器返回的xml消息体
- if (empty($postStr)) {
- util::end();
- }
- $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
- if ($postObj->return_code != 'SUCCESS') {
- Yii::warning('return_code error:' . $postObj->return_code);
- util::end();
- }
- $orderId = $postObj->out_trade_no;
- $total_fee = $postObj->total_fee;
- $totalFee = $total_fee / 100;
- $attach = $postObj->attach;
- //接收流水类型、代金劵
- parse_str($attach);
- $couponId = isset($couponId) ? $couponId : 0;
- //流水类型
- $capitalType = isset($capitalType) ? $capitalType : null;
- $wxPayType = isset($wxPayType) ? $wxPayType : 0;
- if (isset($capitalType) == false) {
- Yii::warning('capitalType empty,orderId:' . $orderId);
- util::end();
- }
- $callbackParams = ['wxPayType' => $wxPayType];
- $return = xhPayToolService::weixinPay($callbackParams, $orderId, $totalFee, $capitalType, $couponId);//支付回调流程
- if ($return['code'] == 'A0002') {
- Yii::warning('callback exec and failed,capitalType:' . $capitalType . ' orderId:' . $orderId);
- util::end();
- }
- echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
- }
-
- }
|