本文整理汇总了PHP中common\models\Order::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::findOne方法的具体用法?PHP Order::findOne怎么用?PHP Order::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\Order
的用法示例。
在下文中一共展示了Order::findOne方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findModel
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: actionShip
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: actionSuccesspay
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: NotifyProcess
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: actionTimeout
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: actionWebhooks
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;
}
示例9: actionCancel
public function actionCancel($id)
{
$order = Order::findOne($id);
$order->status = -1;
$order->update();
return $this->redirect('orders');
}
示例10: actionTimeout
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' => []];
}
}