Example #1
0
 public function search($params)
 {
     $query = MGh::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['create_time' => SORT_DESC]], 'pagination' => ['pageSize' => 20]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->addCondition($query, 'gh_id', true);
     return $dataProvider;
 }
Example #2
0
 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;
 }