/**
  * Finds the CustomerSales model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CustomerSales the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $model = Kiwi::getCustomerSales();
     if (($model = $model::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * user center customerSales index
  * @author Cangzhou.Wu(wucangzhou@gmail.com)
  * @return string|\yii\web\Response
  */
 public function actionIndex()
 {
     //make a request for bing a seller
     $model = Kiwi::getCustomerSeller()->find()->where(['customer_id' => Yii::$app->user->id])->one() ?: Kiwi::getCustomerSeller();
     if (!$model->isNewRecord && $model->status == 1) {
         // show CustomerSales data
         $dataProvider = new ActiveDataProvider(['query' => Kiwi::getCustomerSales()->find()->where(['user_id' => Yii::$app->user->id])]);
         return $this->render('index', ['dataProvider' => $dataProvider, 'model' => $model]);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         //            return $this->redirect(['index']);
     }
     return $this->render('form', ['model' => $model]);
 }
Example #3
0
 public function getMonthSelesCount()
 {
     $sales = Kiwi::getCustomerSales()->find()->where(['user_id' => $this->customer_id])->all();
     $saleKeys = ArrayHelper::getColumn($sales, 'key');
     return Kiwi::getDealLog()->find()->innerJoinWith(['orderItem', 'order'])->where(['key' => $saleKeys])->andWhere('order.create_at > ' . strtotime('- 1 month'))->count('order_item.qty');
 }
Example #4
0
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="profile">
                <ul class="list-unstyled contact-details">
                    <?php 
$month = date('m');
$year = date('Y');
$last_month = date('m') - 1;
if ($month == 1) {
    $last_month = 12;
    $year = $year - 1;
}
$start = mktime(0, 0, 0, $last_month, 0, $year);
$end = mktime(0, 0, 0, $month, 0, $year);
$dealLogModels = Kiwi::getDealLog()->find()->select('key,count(*) as order_id')->where(['between', 'created_at', $start, $end])->groupBy('user_id')->orderBy('order_id desc')->limit(7)->all();
foreach ($dealLogModels as $dealLogModel) {
    $seller = Kiwi::getCustomerSales()->find()->where(['key' => $dealLogModel->key])->one();
    if ($seller) {
        $user = $seller->user;
        ?>
                            <li><span><?php 
        echo $user->username;
        ?>
</span> 卖出 <?php 
        echo $dealLogModel->order_id;
        ?>
 单</li>
                    <?php 
    }
}
?>
                </ul>
Example #5
0
">
                    加入购物车
                    <i class="fa fa-shopping-cart"></i>
                </button>
                <?php 
}
?>
<!--                <button type="button" class="btn btn-cart buy-now" data-url="--><?php 
//= Url::to(['order/create']);
?>
<!--">-->
<!--                    立即购买-->
<!--                    <i class="fa fa-crosshairs"></i>-->
<!--                </button>-->
                <?php 
$isApply = Kiwi::getCustomerSales()->find()->where(['item_id' => $item->item_id, 'user_id' => Yii::$app->user->id])->exists();
?>
                <button type="button" class="btn btn-cart request-sales" data-url="<?php 
echo Url::to(['customerSales/create']);
?>
" style="<?php 
echo $isApply ? 'background-color: #333' : '';
?>
">
                    <?php 
if ($isApply) {
    echo '已申请销售';
} else {
    echo '申请销售';
}
?>