예제 #1
0
 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
0
 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
0
 /**
  * 完成超过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
0
 /**
  * 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
0
 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
0
 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]);
 }
 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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;
 }
예제 #16
0
 public function search($params)
 {
     $query = Order::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => 20]]);
     // load the seach form data and validate
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->_addDigitalFilter($query, 'real_fee');
     $dateBegin = strtotime($this->date);
     $dateEnd = $dateBegin + 86400;
     // adjust the query by adding the filters
     $query->andFilterWhere(['like', 'order_sn', $this->order_sn])->andFilterWhere(['school_id' => $this->school_id])->andFilterWhere(['store_id' => $this->store_id])->andFilterWhere(['user_id' => $this->user_id])->andFilterWhere(['payment' => $this->payment])->andFilterWhere(['status' => $this->status])->andFilterWhere(['>=', 'created_at', $this->date ? $dateBegin : null])->andFilterWhere(['<', 'created_at', $this->date ? $dateEnd : null]);
     return $dataProvider;
 }
예제 #17
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Order::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['order_id' => $this->order_id, 'user_id' => $this->user_id, 'date_time' => $this->date_time]);
     return $dataProvider;
 }
예제 #18
0
 public function actionIndex()
 {
     if (Yii::$app->request->get('status')) {
         $status = Yii::$app->request->get('status');
         if (strpos($status, ',')) {
             $status = explode(',', $status);
         }
         $query = Order::find()->where(['user_id' => Yii::$app->user->id, 'status' => $status]);
     } elseif (Yii::$app->request->get('sn')) {
         $query = Order::find()->where(['sn' => Yii::$app->request->get('sn')]);
     } else {
         $query = Order::find()->where(['and', 'user_id=' . Yii::$app->user->id, 'status > ' . Order::STATUS_DELETED]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => Yii::$app->params['defaultPageSizeOrder']], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     return $this->render('index', ['orders' => $dataProvider->getModels(), 'pagination' => $dataProvider->pagination]);
 }
예제 #19
0
 /**
  * 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 any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['order_id' => $this->order_id]);
     // $query->andFilterWhere(['like', 'store_name', $this->store_name])
     //     ->andFilterWhere(['like', 'store_desc', $this->store_desc])
     //     ->andFilterWhere(['like', 'store_picture', $this->store_picture]);
     return $dataProvider;
 }
예제 #20
0
 public function actionView($id)
 {
     $model = User::findOne($id);
     if (!$model) {
         throw new NotFoundHttpException('未找到该用户');
     }
     $last15days = [];
     $numDataOrder = [];
     $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', ['user_id' => $id], ['>=', 'created_at', $timestrap], ['<=', 'created_at', $timestrapEnd]];
         array_unshift($last15days, date('m/d', $timestrap));
         array_unshift($numDataOrder, Order::find()->where($where)->count('id'));
     }
     return $this->render('view', ['model' => $model, 'last15days' => $last15days, 'numDataOrder' => $numDataOrder]);
 }
예제 #21
0
 /**
  * Lists all Order models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Order::find()->orderBy('id DESC'), 'pagination' => ['pageSize' => 10]]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
예제 #22
0
                        <i class="fa fa-envelope-o"></i>
                        <span class="label label-success"><?php 
    echo Order::count();
    ?>
</span>
                    </a>
                    <ul class="dropdown-menu">
                        <li class="header">У вас <?php 
    echo Order::count();
    ?>
 заявок</li>
                        <li>
                            <!-- inner menu: contains the actual data -->
                            <ul class="menu">
                               <?php 
    echo ListView::widget(['dataProvider' => $provider = new ActiveDataProvider(['query' => Order::find()->where(['is_new' => 0]), 'sort' => ['defaultOrder' => ['is_new' => SORT_ASC, 'id' => SORT_DESC]]]), 'itemOptions' => ['class' => 'item'], 'itemView' => function ($model, $key, $index, $widget) {
        return $this->render('_order', ['model' => $model]);
    }, 'layout' => "{items}"]);
    ?>
                            </ul>
                        </li>
                        <li class="footer"><a href="#">Все сообщения</a></li>
                    </ul>
                </li>
                <?php 
}
?>
                 <?php 
'
                <li class="dropdown notifications-menu">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
예제 #23
0
 /**
  * Lists all Post models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Order::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
예제 #24
0
 /**
  * @return array
  */
 public function actionDeleteOrder()
 {
     $result = 0;
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $id = Yii::$app->request->post('id');
     if ($id) {
         $order = Order::find()->where(['id' => $id])->one();
         $result = $order->delete();
     }
     return ['success' => $result];
 }
예제 #25
0
 /**
  * Displays a single CouponType model.
  * @param integer $id
  * @return mixed
  */
 public function actionSend($id)
 {
     //if(!Yii::$app->user->can('viewYourAuth')) throw new ForbiddenHttpException(Yii::t('app', 'No Auth'));
     if (Yii::$app->request->post()) {
         if (isset(Yii::$app->request->post('CouponType')['users'])) {
             $strUser = Yii::$app->request->post('CouponType')['users'];
             $arrayUser = explode(',', $strUser);
             foreach ($arrayUser as $user) {
                 $user = User::find()->where(['username' => $user])->one();
                 $userId = isset($user) ? $user->id : null;
                 $couponType = CouponType::findOne($id);
                 if ($userId) {
                     $coupon = new Coupon();
                     $coupon->user_id = $userId;
                     $coupon->coupon_type_id = $id;
                     $coupon->money = $couponType->money;
                     $coupon->min_amount = $couponType->min_amount;
                     $coupon->started_at = $couponType->started_at;
                     $coupon->ended_at = $couponType->ended_at;
                     $coupon->user_id = $userId;
                     $coupon->save();
                 }
             }
         } elseif (isset(Yii::$app->request->post('CouponType')['numbers']) && Yii::$app->request->post('CouponType')['numbers'] > 0) {
             for ($i = 0; $i < Yii::$app->request->post('CouponType')['numbers']; $i++) {
                 $couponType = CouponType::findOne($id);
                 $coupon = new Coupon();
                 $coupon->coupon_type_id = $id;
                 $coupon->money = $couponType->money;
                 $coupon->min_amount = $couponType->min_amount;
                 $coupon->started_at = $couponType->started_at;
                 $coupon->ended_at = $couponType->ended_at;
                 $coupon->sn = Yii::$app->security->generateRandomString(8);
                 $coupon->save();
             }
         }
         return $this->redirect(['coupon/index']);
     } else {
         $model = $this->findModel($id);
         if ($model->type == CouponType::COUPON_TYPE_AMOUNT) {
             $arrayUserId = ArrayHelper::map(Order::find()->where('amount > :amount', [':amount' => $model->min_goods_amount])->all(), 'user_id', 'user_id');
             $arrayUserName = ArrayHelper::map(User::find()->where(['id' => $arrayUserId])->all(), 'id', 'username');
             $model->users = implode(',', $arrayUserName);
         }
         return $this->render('sendForm', ['model' => $model]);
     }
 }
예제 #26
0
<?php

/**
 * Created by PhpStorm.
 * User: victor
 * Date: 13/12/15
 * Time: 14:41
 */
use common\models\Order;
use yii\data\ActiveDataProvider;
use yii\grid\GridView;
use yii\helpers\Html;
?>

<?php 
echo Html::csrfMetaTags();
?>

    <h1>Orders</h1>
<?php 
echo GridView::widget(['dataProvider' => new ActiveDataProvider(['query' => Order::find()]), 'columns' => ['firstname', 'lastname', 'email', 'phone', 'delivery_address', 'good_id', 'goods_count', 'total_price']]);
예제 #27
0
 public function actionDelete($order)
 {
     $model = Order::find()->where(['and', ['order_sn' => $order], ['user_id' => Yii::$app->user->id], ['<>', 'status', Order::STATUS_DELETED]])->one();
     if ($model) {
         if ($model->discard()) {
             Yii::$app->session->setFlash('success', '已成功删除一个订单');
         } else {
             Yii::$app->session->setFlash('danger', '删除失败!');
             if (Yii::$app->request->referrer) {
                 return $this->redirect(Yii::$app->request->referrer);
             }
         }
     }
     return $this->redirect(['index']);
 }
 public function actionOrders()
 {
     $dataProvider = new ActiveDataProvider(['query' => Order::find()->where('member_id = :mid', [':mid' => Yii::$app->user->identity->id])->orderBy('id DESC'), 'pagination' => ['pageSize' => 10]]);
     return $this->render('orders', ['dataProvider' => $dataProvider]);
 }
예제 #29
0
 public function count()
 {
     return Order::find()->where(['is_new' => 0])->count();
 }
예제 #30
0
<?php

use backend\assets\AppAsset;
use common\models\Order;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
/* @var $this \yii\web\View */
/* @var $content string */
AppAsset::register($this);
$newOrders = Order::find()->where(['status' => Order::STATUS_NEW])->count();
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php 
echo Yii::$app->language;
?>
">
<head>
    <meta charset="<?php 
echo Yii::$app->charset;
?>
">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php 
echo Html::csrfMetaTags();
?>
    <title><?php 
echo Html::encode($this->title);
?>