本文整理汇总了PHP中common\models\Order::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::find方法的具体用法?PHP Order::find怎么用?PHP Order::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\Order
的用法示例。
在下文中一共展示了Order::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex()
{
$dataProvider = new ActiveDataProvider(['query' => Order::find()->limit(10)->where(['status' => Order::STATUS_NEW])]);
$productModel = new Product(['scenario' => 'create']);
$productModel->date = date('Y-m-d H:i');
return $this->render('index', ['dataProvider' => $dataProvider, 'categoryModel' => new Category(), 'productModel' => $productModel]);
}
示例2: actionIndex
public function actionIndex()
{
$last15days = [];
$last6Month = [];
$numDataOrder = [];
// 订单生成数据
$numDataVolume = [];
// 营业额数据
$numDataCompleted = [];
// 订单完成数据
$numDataVolumeMonth = [];
// 每月营业额
$today = strtotime("00:00:00");
$todayEnd = strtotime("23:59:59");
for ($i = 0; $i < 15; $i++) {
$timestrap = strtotime('-' . $i . ' days', $today);
$timestrapEnd = strtotime('-' . $i . ' days', $todayEnd);
$where = ['and', ['store_id' => Yii::$app->user->identity->store_id], ['>=', 'created_at', $timestrap], ['<=', 'created_at', $timestrapEnd]];
array_unshift($last15days, date('m/d', $timestrap));
array_unshift($numDataOrder, Order::find()->where($where)->count());
$data = OrderVolume::find()->select(['sum(volume) AS volume', 'count(*) AS count'])->where($where)->asArray()->one();
array_unshift($numDataVolume, $data['volume']);
array_unshift($numDataCompleted, $data['count']);
}
for ($i = 0; $i < 6; $i++) {
$timestrap = strtotime("first day of -{$i} month", $today);
$timestrapEnd = strtotime("last day of -{$i} month", $todayEnd);
$where = ['and', ['store_id' => Yii::$app->user->identity->store_id], ['>=', 'created_at', $timestrap], ['<=', 'created_at', $timestrapEnd]];
array_unshift($last6Month, date('Y/m', $timestrap));
array_unshift($numDataVolumeMonth, OrderVolume::find()->where($where)->sum('volume'));
}
$data2 = OrderVolume::find()->select(['sum(volume) AS volume', 'count(*) AS count'])->where(['store_id' => Yii::$app->user->identity->store_id])->asArray()->one();
return $this->render('index', ['model' => Yii::$app->user->identity->store, 'last15days' => $last15days, 'last6Month' => $last6Month, 'numDataOrder' => $numDataOrder, 'numDataVolume' => $numDataVolume, 'numDataCompleted' => $numDataCompleted, 'numDataVolumeMonth' => $numDataVolumeMonth, 'countOrder' => Order::getCountByStoreId(Yii::$app->user->identity->store_id), 'countCompleted' => $data2['count'], 'sumVolume' => $data2['volume']]);
}
示例3: actionComplete
/**
* 完成超过2小时未收货的订单,每小时执行一次
*
* @return string
*/
public function actionComplete()
{
$transaction = Yii::$app->db->beginTransaction();
try {
$twelveHoursAgo = time() - 3600 * 2;
$orders = Order::find()->where(['and', ['status' => Order::STATUS_SHIPPED], ['<=', 'created_at', $twelveHoursAgo]])->all();
$count1 = 0;
$count2 = 0;
foreach ($orders as $key => $order) {
if ($order->complete()) {
$count1++;
} else {
$count2++;
}
unset($orders[$key]);
}
$transaction->commit();
echo "{$count1} of orders affected by the execution, {$count2} fails.\n";
return static::EXIT_CODE_NORMAL;
} catch (\Exception $e) {
$transaction->rollBack();
echo $e->getMessage();
return static::EXIT_CODE_ERROR;
}
}
示例4: __construct
/**
* Creates a form model given an 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 order id is not valid
*/
public function __construct($id, $config = [])
{
$this->_order = Order::find()->where(['and', ['id' => $id], ['user_id' => Yii::$app->user->id], ['<>', 'status', Order::STATUS_DELETED]])->one();
if (!$this->_order) {
throw new InvalidParamException('您没有该订单!');
}
parent::__construct($config);
}
示例5: actionSelect
public function actionSelect($id, $hallid)
{
$res = Order::find()->select('session_id')->where(['session_id' => $id])->one();
if (!empty($res)) {
\Yii::$app->db->createCommand("UPDATE `order` SET `seats`=:status WHERE `session_id`=:id")->bindValue(':id', $id)->bindValue(':status', $hallid)->execute();
} else {
\Yii::$app->db->createCommand()->insert('order', ['session_id' => $id, 'seats' => $hallid])->execute();
}
}
示例6: actionIndex
public function actionIndex()
{
$orders = Order::find()->where(['user_id' => Yii::$app->user->id])->limit(2)->all();
$productIds = ArrayHelper::map(Favorite::find()->where(['user_id' => Yii::$app->user->id])->orderBy(['id' => SORT_DESC])->asArray()->all(), 'product_id', 'product_id');
if (count($productIds)) {
$favorites = Product::find()->where(['id' => $productIds])->limit(5)->all();
}
$coupons = Coupon::find()->where(['and', 'user_id = ' . Yii::$app->user->id, 'used_at = 0', 'ended_at >= ' . time()])->all();
return $this->render('index', ['orders' => $orders, 'favorites' => isset($favorites) ? $favorites : null, 'coupons' => $coupons]);
}
示例7: search
public function search($params)
{
$query = Order::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'summ' => $this->summ, 'status_index' => $this->status_index, 'created_datetime' => $this->created_datetime, 'finished_datetime' => $this->finished_datetime]);
return $dataProvider;
}
示例8: __construct
/**
* Creates a form model given an order sn.
*
* @param string $orderSn
* @param array $config name-value pairs that will be used to initialize the object properties
* @throws \yii\base\InvalidParamException if order sn is empty or not valid
*/
public function __construct($orderSn, $config = [])
{
if (empty($orderSn) || !is_string($orderSn)) {
throw new InvalidParamException('订单号错误!');
}
$this->_order = Order::find()->where(['and', ['order_sn' => $orderSn], ['user_id' => Yii::$app->user->id], ['<>', 'status', Order::STATUS_DELETED]])->one();
if (!$this->_order) {
throw new InvalidParamException('您没有该订单!');
}
parent::__construct($config);
}
示例9: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Order::find()->orderBy('id DESC');
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
$query->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'notes', $this->notes])->andFilterWhere(['like', 'status', $this->status]);
return $dataProvider;
}
示例10: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Order::find();
$query->orderBy(['created_at' => SORT_DESC]);
$dataProvider = new ActiveDataProvider(['query' => $query]);
if ($this->load($params) && !$this->validate()) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'country' => $this->country, 'province' => $this->province, 'city' => $this->city, 'district' => $this->district, 'payment_method' => $this->payment_method, 'payment_status' => $this->payment_status, 'payment_id' => $this->payment_id, 'payment_fee' => $this->payment_fee, 'shipment_status' => $this->shipment_status, 'shipment_id' => $this->shipment_id, 'shipment_fee' => $this->shipment_fee, 'amount' => $this->amount, 'tax' => $this->tax, 'status' => $this->status, 'paid_at' => $this->paid_at, 'shipped_at' => $this->shipped_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
$query->andFilterWhere(['like', 'sn', $this->sn])->andFilterWhere(['like', 'consignee', $this->consignee])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'zipcode', $this->zipcode])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'mobile', $this->mobile])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'remark', $this->remark])->andFilterWhere(['like', 'payment_name', $this->payment_name])->andFilterWhere(['like', 'shipment_name', $this->shipment_name])->andFilterWhere(['like', 'invoice', $this->invoice]);
return $dataProvider;
}
示例11: actionMy
public function actionMy()
{
if (\Yii::$app->user->isGuest) {
throw new NotFoundHttpException();
} else {
$query = Order::find()->where(['and', ['user_id' => \Yii::$app->user->getId()], ['not', ['closed_at' => null]]]);
$pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
$orders = $query->with('project')->orderBy('closed_at DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
// vd($orders);
return $this->render('my', ['orders' => $orders, 'pagination' => $pagination]);
}
}
示例12: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Order::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'goods_id' => $this->goods_id, 'user_id' => $this->user_id, 'active' => $this->active, 'datetime' => $this->datetime]);
return $dataProvider;
}
示例13: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Order::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'orderId' => $this->orderId, 'totalPrice' => $this->totalPrice, 'dateTime' => $this->dateTime]);
$query->andFilterWhere(['like', 'firstName', $this->firstName])->andFilterWhere(['like', 'lastName', $this->lastName])->andFilterWhere(['like', 'package', $this->package]);
return $dataProvider;
}
示例14: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Order::find()->orderBy('status');
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'total_cost' => $this->total_cost, 'date' => $this->date]);
$query->andFilterWhere(['like', 'data', $this->data])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'message', $this->message]);
return $dataProvider;
}
示例15: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Order::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'price' => $this->price, 'datetime' => $this->datetime]);
$query->andFilterWhere(['like', 'fio', $this->fio])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'email', $this->email]);
return $dataProvider;
}