/** * Finds the CustomerSeller model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CustomerSeller the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { $model = Kiwi::getCustomerSeller(); if (($model = $model::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionIntegral() { $dataProvider = new ActiveDataProvider(['query' => Kiwi::getDealLog()->find()->innerJoinWith('customerSales')->where(['customer_sales.user_id' => \Yii::$app->user->id])]); /** @var \yincart\customer\models\Customer $customer */ $customer = \Yii::$app->user->identity; $customerSellers = Kiwi::getCustomerSeller()->find()->where(['referrer' => $customer->username])->all(); $sellerIds = ArrayHelper::getColumn($customerSellers, 'customer_id'); $referrerProvider = new ActiveDataProvider(['query' => Kiwi::getDealLog()->find()->innerJoinWith('customerSales')->where(['customer_sales.user_id' => $sellerIds])]); return $this->render('integral', ['dataProvider' => $dataProvider, 'referrerProvider' => $referrerProvider]); }
/** * 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]); }
/** * update seller's reference number * @author Cangzhou.Wu(wucangzhou@gmail.com) * @throws \yii\db\Exception */ public function updateReferenceNo() { $referrer = $this->referrer; $customer = Kiwi::getCustomer()->findOne(['username' => $referrer]); $seller = Kiwi::getCustomerSeller()->findOne(['customer_id' => $customer->id]); $seller->reference_no = $seller->reference_no + 1; if (!$seller->save()) { throw new Exception('update ReferenceNo fail', $seller->getErrors()); } }
echo $user->username; ?> </span> 卖出 <?php echo $dealLogModel->order_id; ?> 单</li> <?php } } ?> </ul> </div> <div class="tab-pane fade" id="dropdown"> <ul class="list-unstyled contact-details"> <?php $topSellers = Kiwi::getCustomerSeller()->find()->orderBy(['integral' => SORT_DESC])->limit(7)->all(); foreach ($topSellers as $topSeller) { ?> <li style="padding: 10px 30px; border-bottom: dashed 1px #8c8b8b; line-height: 24px">销售: <?php echo $topSeller->user->username; ?> ; 销量: <?php echo $topSeller->getSelesCount(); ?> </li> <?php } ?> </ul> </div> <div class="tab-pane fade" id="category">