public function payNotifyUrl()
 {
     $xml = $this->getXmlArray();
     $wxPayHelper = new WxPayHelper();
     //获得openid
     $openid = $xml['openid'];
     //$order = $_GET; //获取订单信息
     //获取shop_id
     $shop_id = $_GET['shop_id'];
     //第三方商户订单号
     $out_trade_no = $_GET['out_trade_no'];
     //订单号
     $trade_no = $_GET['transaction_id'];
     //订单状态 0为成功
     $trade_status = $_GET['trade_state'];
     //订单总金额,单位为分
     $total_fee = $_GET['total_fee'];
     $notify_id = $_GET['notify_id'];
     $appsignature = $_GET['appsignature'];
     //验证是否是从微信服务器返回的
     $is_weixin = $this->verifyNotify($_GET, $_GET['sign']);
     if ($is_weixin) {
         //实例化model
         $main = D('main');
         //商城订单状态处理
         //第三方订单号格式:  来源+订单ID+客户ID+用户ID;
         $order = explode('_', $out_trade_no);
         $source = $order[0];
         $order_id = $order[1];
         $custom_id = $order[2];
         $user_id = $order[3];
         //判断通知是否已经处理过,处理过直接返回success
         //是否支付成功
         if ($trade_status == '0') {
             //获取access_token
             $access_token = $wxPayHelper->access_token();
             //订单修改为已支付的状态
             $order_data = array('id' => $order_id, 'u_id' => $user_id, 'data' => array('status' => 6));
             $main->edit_order_status($order_data);
             //****************添加交易记录   组合参数*************
             //查询用户名和电话
             $user_info = M(C('DB_WECHAT_NAME') . '.wxh_member_baseinfo')->where('is_del = 0 and id = ' . $user_id)->field('name, phone')->find();
             //查询订单提交时间
             $add_time = M(C('DB_WECHAT_NAME') . '.wxh_order')->where('is_del = 0  and id = ' . $order_id . ' and user_id = ' . $user_id)->getField('add_time');
             $param_zero = array('user_id' => $user_id, 'order_id' => $order_id, 'source' => $source, 'source_id' => $shop_id, 'custom_id' => $custom_id, 'name' => $user_info['name'], 'tel' => $user_info['phone'], 'order_price' => round($total_fee / 100, 2), 'order_time' => $add_time, 'pay_method' => 2, 'pay_time' => time(), 'pay_status' => $trade_status, 'pay_number' => $trade_no, 'notify_id' => $notify_id);
             //添加交易记录   先验证验证是否已经添加
             $is_record = $main->verify_record($order_id);
             if ($is_record) {
                 $main->add_record($param_zero);
             }
             $wxPayHelper = new WxPayHelper($custom_id);
             //发货,调用发货接口
             $res = $wxPayHelper->delivernotify($openid, $trade_no, $out_trade_no);
             //if($res["errmsg"]=='ok'){
             //返回发货通知消息,ok为发货成功
             ///记录到日志中
             //}
             //业务处理完后以字符串形式返回微信系统结果
             echo 'success';
             //不要更改或删除
         } else {
             //失败,微信系统通过补单机制再次通知
             echo 'fail';
             //不要更改或删除
         }
     } else {
         echo "不是微信回调";
     }
     //记录日志
     $fp = fopen('api.txt', 'w+');
     fwrite($fp, "\n_______delivernotify_______");
     fwrite($fp, var_export($res, true));
     fwrite($fp, "\n _______GET________");
     fwrite($fp, var_export($_GET, true));
     fwrite($fp, "\n ________postObj________");
     fwrite($fp, var_export($xml, true));
     fwrite($fp, 'NowTime:  ' . date("Y-m-d H:i:s") . "\n");
     fclose($fp);
 }