示例#1
0
 public function actionUpdateTopup()
 {
     $result = \Yii::$app->request->post();
     foreach ($result as $key => $value) {
         Yii::$app->db->createCommand('Update toppupBank set code=:code , used=1 where order_product_id=:key')->bindValue(':code', $value)->bindValue(':key', $key)->execute();
         $codeBank = CodeBank::find()->where(['code' => $value])->one();
         // Get Topup id
         $orderProduct = OrderProduct::findOne($key);
         // Get topup maxCallOut
         $tp = Topup::findOne($orderProduct->objectId);
         $codeBank->updateCounters(['maxCallout' => $tp->maxCallOut]);
     }
     return 1;
 }
示例#2
0
 /**
  * Finds the Topup model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Topup the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Topup::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }