/** * Creates a new MUserAccount model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new MUserAccount(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
public static function addRecommendFanAmount($date_start, $date_end) { U::W(__METHOD__ . " BEGIN from {$date_start}, {$date_end}"); // $tableName = MSceneDay::tableName(); $ghs = MGh::find()->all(); foreach ($ghs as $gh) { if ($gh->gh_id !== MGh::GH_XIANGYANGUNICOM) { continue; } foreach ($gh->staffs as $staff) { if ($staff->scene_id != 0 && ($staff->cat == MStaff::SCENE_CAT_OUT || $staff->cat == MStaff::SCENE_CAT_FAN) && !empty($staff->openid)) { $real_score = MAccessLog::getRealScoreByRange($gh->gh_id, $staff->scene_id, $date_start, $date_end); if ($real_score > 0) { //$amount = intval($real_score) * 100; //$amount = intval($real_score/3) * 500; $amount = intval($real_score) * 500; if ($amount > 0) { $model = new MUserAccount(); $model->gh_id = $staff->gh_id; $model->openid = $staff->openid; $model->scene_id = $staff->scene_id; $model->cat = MUserAccount::CAT_DEBIT_FAN; $model->amount = $amount; $model->memo = '推荐有礼'; $model->save(false); // U::W("SAVE OK, scene_id={$staff->scene_id}, openid={$staff->openid}, amount={$model->amount}"); } } else { // U::W("scene_id={$staff->scene_id}, openid={$staff->openid}, realscore={$real_score}, "); } } else { // U::W("scene_id={$staff->scene_id}, openid={$staff->openid}"); } } } U::W(__METHOD__ . " END"); return; }