| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace openend\controllers;
- use common\services\xhUserAssetService;
- use common\services\xhUserService;
- use common\services\xhUserAlipayService;
- use common\services\xhMerchantExtendService;
- use common\services\xhActiveOrderService;
- use common\components\util;
- use Yii;
- use yii\web\Controller;
- use linslin\yii2\curl;
- use common\services\xhOrderService;
- use common\components\weixinUtil;
- use common\components\configDict;
- use common\services\xhMerchantService;
- use common\services\xhPayToolService;
- class NoticeController extends PublicController{
- public $cateogryList;
- public $enableCsrfValidation = false;
- /**
- * 微信支付异步回调
- */
- public function actionApplyWeixinCallback()
- {
- $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;//流水类型
- if(isset($capitalType) == false){
- Yii::warning('capitalType empty,orderId:'.$orderId);
- util::end();
- }
- $return = xhPayToolService::weixinPay($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>';
- }
- }
|