public function NotifyProcess($data, &$msg)
 {
     // Log::DEBUG("call back:" . json_encode($data));
     $notfiyOutput = array();
     if (!array_key_exists("transaction_id", $data)) {
         $msg = "输入参数不正确";
         return false;
     }
     //查询订单,判断订单真实性
     if (!($result = $this->Queryorder($data["transaction_id"]))) {
         $msg = "订单查询失败";
         return false;
     }
     // TODO:: 更新订单信息失败的处理
     try {
         if (isset($result['out_trade_no']) && $result['out_trade_no']) {
             $order_sn = $result['out_trade_no'];
             $order = new Order();
             $transaction_id = isset($result['transaction_id']) ? $result['transaction_id'] : '';
             $turnover = isset($result['total_fee']) ? $result['total_fee'] : 0;
             $relt = $order->setOrderPaySucc($order_sn, $transaction_id);
             if ($relt) {
                 if ($relt['transaction_id'] && $transaction_id && $relt['transaction_id'] != $transaction_id) {
                     $paymentConflict = new PaymentConflict();
                     if (!$paymentConflict->existsTransactionId($transaction_id)) {
                         $payRecord = ['rel_id' => $order->getOrderId(), 'order_sn' => $order_sn, 'pay_type' => PaymentConflict::WX_PAYMENT, 'transaction_id' => $transaction_id, 'turnover' => $turnover / 100, 'create_time' => time(), 'update_time' => time(), 'pay_status' => Order::ORDER_PAID_STATUS];
                         // TODO:: 记录新增失败处理
                         $paymentConflict->addConflictRecord($payRecord);
                     }
                 }
                 return true;
             }
         }
         return false;
     } catch (Exception $ex) {
         return false;
     }
 }
 /**
  * 获取订单列表信息
  */
 public function actionList()
 {
     $this->layout = 'main';
     //判断用户是否登录
     if (!UserBaseInfo::isLogin()) {
         return $this->redirect(Url::toRoute('user/login'));
     }
     //从session或cookie中获取open_id
     $openId = UserBaseInfo::getOpenId();
     $data['open_id'] = $openId;
     $data['status'] = Order::ORDER_USABLE_STATUS;
     $params = Yii::$app->request->get();
     $startTime = false;
     $endTime = false;
     $time = Yii::$app->util->loadConfig('user-order-time', '/platform_i/config/');
     if ($params) {
         if (isset($params['startTime']) && isset($params['endTime'])) {
             $data['startTime'] = strtotime($params['startTime'] . ' 00:00:00');
             $data['endTime'] = strtotime($params['endTime'] . ' 23:59:59');
             $checkTime = $this->checkTime($params['startTime'], $params['endTime']);
             if ($checkTime['startTime'] && $checkTime['endTime']) {
                 $data['startTime'] = strtotime($checkTime['startTime'] . ' 00:00:00');
                 $data['endTime'] = strtotime($checkTime['endTime'] . '23:59:59');
                 $params['startTime'] = $checkTime['startTime'];
                 $params['endTime'] = $checkTime['endTime'];
             }
             if ($data['startTime'] > $data['endTime']) {
                 $tmpParam = $params['startTime'];
                 $params['startTime'] = $params['endTime'];
                 $params['endTime'] = $tmpParam;
                 $tmpData = $data['startTime'];
                 $data['startTime'] = $data['endTime'];
                 $data['endTime'] = $tmpData;
             }
             $timeInterval = $params['startTime'] . '_' . $params['endTime'];
             foreach ($time as $key => &$value) {
                 if ($timeInterval == $value['timeInterval']) {
                     $value['class'] = true;
                 }
             }
         } else {
             if (isset($params['timeRange'])) {
                 if (in_array($params['timeRange'], array_keys($time))) {
                     $time[$params['timeRange']]['class'] = true;
                 } else {
                     $time[1]['class'] = true;
                 }
             } else {
                 //默认为今天
                 $time[1]['class'] = true;
                 $params['timeRange'] = 1;
             }
             $data['endTime'] = strtotime(date('Y-m-d 23:59:59'));
             $data['startTime'] = $this->getTime($params['timeRange']);
         }
         if (isset($params['payStatus'])) {
             if ($params['payStatus'] != 0 && $params['payStatus'] != 1 && $params['payStatus'] != 5) {
                 unset($params['payStatus']);
             } else {
                 $data['pay_status'] = $params['payStatus'];
             }
         }
     } else {
         $params['timeRange'] = 1;
         $data['endTime'] = strtotime(date('Y-m-d 23:59:59'));
         $data['startTime'] = $this->getTime($params['timeRange']);
         $time[1]['class'] = true;
     }
     $result = Order::getData($data, $startTime, $endTime);
     $pages = new Pagination(['totalCount' => $result->count(), 'pageSize' => '10']);
     $result = $result->offset($pages->offset)->limit($pages->limit)->asArray()->all();
     //从缓存中取出应用配置信息
     $appConfig = AppConfig::getConfigUrl();
     if (is_array($appConfig)) {
         foreach ($result as $key => &$value) {
             $value['config_urls'] = $appConfig[$value['app_id']];
         }
     }
     return $this->render('list', ['result' => $result, 'pages' => $pages, 'time' => $time]);
 }
 /**
  * 轮询检查支付结果
  *
  * @return json
  */
 public function actionPollPayRes()
 {
     $util = Yii::$app->util;
     $request = Yii::$app->getRequest();
     $session = Yii::$app->getSession();
     $cookie = $request->cookies->getValue('open_id');
     $openId = $session[UserBaseInfo::SESSION_KEY_USER]['open_id'] ?: $cookie;
     if (!$request->getIsAjax()) {
         return $util->formatResData(1301, 'illegal_request', ['msg' => '非法请求']);
     }
     $post = $request->post();
     if (!isset($post['out_trade_no']) || !$post['out_trade_no']) {
         return $util->formatResData(1302, 'Loss_order_information', ['msg' => '订单信息丢失']);
     }
     /*
     if (!isset($post['pay_method']) || !$post['pay_method']) {
         return $util->formatResData(1303, 'Paymethods_not_exist', ['msg' => '支付方式不存在']);
     }
     */
     $order = Order::getByOrderSn($post['out_trade_no']);
     if (!$order || $order['open_id'] != $openId || $order['status'] == Order::ORDER_DELETE_STATUS) {
         return $util->formatResData(1305, 'Jurisdiction_not_enough', ['msg' => '权限不够']);
     }
     switch ($order['pay_status']) {
         case '1':
             $appUncookie = ['msg' => '支付成功', 'ret' => $order];
             return $util->formatResData(0, 'success', $appUncookie);
             break;
         case '0':
             $appUncookie = ['msg' => '未支付', 'ret' => $order];
             return $util->formatResData(1001, 'notyay', $appUncookie);
         case '2':
             $appUncookie = ['msg' => '转入退款', 'ret' => $order];
             return $util->formatResData(1004, 'refund', $appUncookie);
         case '4' || '3':
             $appUncookie = ['msg' => '已关闭', 'ret' => $order];
             return $util->formatResData(1005, 'closed', $appUncookie);
     }
 }