예제 #1
0
 /**
  * Finds the Post model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Post the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Order::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #2
0
 /**
  * Creates a form model given a order id.
  *
  * @param  string                          $id
  * @param  array                           $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if waybill sn is empty or not valid
  */
 public function __construct($id, $config = [])
 {
     if (empty($id) || !is_numeric($id)) {
         throw new InvalidParamException('参数错误!');
     }
     $this->_order = Order::findOne(['id' => $id, 'store_id' => Yii::$app->user->identity->store_id]);
     if (!$this->_order) {
         throw new InvalidParamException('您没有该订单!');
     }
     parent::__construct($config);
 }
예제 #3
0
 /**
  * Creates a form model given a order id.
  *
  * @param  string                          $id
  * @param  array                           $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if waybill sn is empty or not valid
  */
 public function __construct($id, $config = [])
 {
     if (empty($id) || !is_numeric($id)) {
         throw new InvalidParamException('参数错误!');
     }
     $this->_order = Order::findOne($id);
     if (!$this->_order) {
         throw new InvalidParamException('未找到该订单!');
     }
     parent::__construct($config);
 }
예제 #4
0
 public function actionShip($id)
 {
     $model = Order::findOne(['id' => $id, 'store_id' => Yii::$app->user->identity->store_id]);
     if (!$model) {
         throw new NotFoundHttpException('未找到该订单!');
     }
     if ($model->ship()) {
         Yii::$app->session->setFlash('success', '设置配送成功!');
     } else {
         Yii::$app->session->setFlash('danger', '配送请求失败!');
     }
     return $this->redirect(['view', 'id' => $id]);
 }
예제 #5
0
 public function actionSuccesspay()
 {
     //      vd(['get' => Yii::$app->request->getQueryParams() ,
     //          'post' => Yii::$app->request->getBodyParams()],1);
     $r = new Request();
     //Yii::info(\yii\helpers\Json::encode($requestData), 'apiRequest');
     \Yii::info('[DEBUG_ME]' . print_r(['get' => $r->getQueryParams(), 'post' => $r->getBodyParams()], true), 'appDebug');
     if ($r->post('action')) {
         vd(['get' => $r->getQueryParams(), 'post' => $r->getBodyParams()], 1);
     }
     $order = Order::findOne($r->post('orderNumber'));
     if ($order) {
     } else {
         vd($order);
     }
     $project = $order->project;
     return $this->render('successpay', ['project' => $project]);
 }
예제 #6
0
 public function NotifyProcess($data, &$msg)
 {
     if (!array_key_exists("transaction_id", $data)) {
         $msg = "输入参数不正确";
         return false;
     }
     //查询订单,判断订单真实性
     //if(!$this->Queryorder($data["transaction_id"])){
     //    $msg = "订单查询失败";
     //    return false;
     //}
     $model = Order::findOne(['order_sn' => $data['out_trade_no'], 'status' => [Order::STATUS_UNPAID, Order::STATUS_CANCELLED]]);
     if ($model) {
         if ($model->pay()) {
             Yii::info("订单支付成功!订单号:{$model->order_sn}");
             return true;
         } else {
             Yii::error("订单支付失败!订单号:{$model->order_sn}");
         }
     }
     return false;
 }
예제 #7
0
 public function actionTimeout($order)
 {
     $model = Order::findOne(['user_id' => Yii::$app->user->id, 'order_sn' => $order, 'status' => Order::STATUS_UNPAID]);
     if ($model && $model->cancel('支付超时。')) {
         Yii::$app->session->setFlash('warning', '订单取消,支付超时!');
     }
     return $this->redirect(['/order/detail', 'order' => $order]);
 }
예제 #8
0
 public function actionWebhooks()
 {
     Yii::$app->response->format = Response::FORMAT_RAW;
     $data = file_get_contents("php://input");
     $signature = Yii::$app->request->headers->get('x-pingplusplus-signature');
     $pubKey = file_get_contents(Yii::getAlias(Yii::$app->params['pingpp.publicKeyPath']));
     // Verify signature
     $result = openssl_verify($data, base64_decode($signature), $pubKey, 'sha256');
     if ($result !== 1) {
         Yii::$app->response->statusCode = 403;
         return;
     }
     $event = json_decode($data);
     if (!isset($event->type)) {
         Yii::$app->response->statusCode = 400;
         return;
     }
     switch ($event->type) {
         case "charge.succeeded":
             $charge = $event->data->object;
             $model = Order::findOne(['order_sn' => $charge->order_no]);
             if ($model) {
                 if ($charge->paid && $model->pay()) {
                     $this->_sendMsg($model);
                     Yii::info("订单支付成功!订单号:{$charge->order_no}");
                     return;
                 } else {
                     Yii::error("订单支付失败!订单号:{$charge->order_no}");
                 }
             }
             break;
         default:
             break;
     }
     Yii::$app->response->statusCode = 400;
     return;
 }
 public function actionCancel($id)
 {
     $order = Order::findOne($id);
     $order->status = -1;
     $order->update();
     return $this->redirect('orders');
 }
예제 #10
0
 public function actionTimeout($id)
 {
     $model = Order::findOne(['user_id' => Yii::$app->user->id, 'id' => $id, 'status' => Order::STATUS_UNPAID]);
     if ($model && $model->cancel('支付超时。')) {
         return ['status' => 'success', 'data' => ['status' => $model->status, 'statusMsg' => $model->statusMsg]];
     } else {
         return ['status' => 'fail', 'data' => []];
     }
 }