Exemple #1
0
 /**
  * Gui nhung tin nhan cua status = 0
  * Use: php yii sendsms/daily
  */
 public function actionDaily()
 {
     $stats = [];
     $limit = 100;
     for ($i = 0; $i < 10000; $i++) {
         $model = Sms::find()->where(['status' => 0])->limit($limit)->all();
         if ($model) {
             foreach ($model as $sms) {
                 $sendSms = new \app\modules\sms\helpers\SmsBrandname();
                 $sendSms->model = $sms;
                 $sended = $sendSms->sent();
                 if (property_exists($sended, 'status')) {
                     $stats[$sended->status] = ArrayHelper::getValue($stats, $sended->status, 0) + 1;
                 }
             }
         } else {
             break;
         }
     }
     echo "Thong ke gui sms:\n";
     foreach ($stats as $status => $value) {
         echo $status . ': ' . $value . "\n";
     }
 }
 /**
  * Convert du lieu sms theo dung dinh dang
  * Use: php yii smsstats/convert
  */
 public function actionConvert()
 {
     $count = 0;
     $limit = 500;
     for ($i = 0; $i <= 20; $i++) {
         $models = Sms::find()->orderBy('create_time')->limit($limit)->offset($i * $limit)->all();
         foreach ($models as $model) {
             $count++;
             echo $count . ':';
             $model->status = (string) $model->status;
             $model->status = (int) $model->status;
             //            $model->_id = uniqid();
             if ($model->type == '1') {
                 $model->type == 'CSKH';
             }
             if ($model->campaign === 'LTS') {
                 $model->campaign = 'LHTS';
             }
             $newModel = new Sms();
             $newModel->phone = $model->phone;
             $newModel->message = $model->message;
             $newModel->type = $model->type;
             $newModel->campaign = $model->campaign;
             $newModel->status = $model->status;
             $newModel->checknum = $model->checknum;
             $newModel->create_time = $model->create_time;
             $newModel->save();
             echo ' - Tao model moi';
             $model->delete();
             echo ' - Xoa model cu';
             echo "\n";
         }
     }
 }