PhoneController.php 919 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace console\controllers;
  3. use common\models\LwtPhoneMessageList;
  4. use common\util\PhoneMessage;
  5. use yii\console\Controller;
  6. class PhoneController extends Controller
  7. {
  8. public function actionSend()
  9. {
  10. $resultList = [];
  11. $idList = [];
  12. $LwtPhoneMessageList = LwtPhoneMessageList::find()->where(["is_send" => 0])->all();
  13. foreach ($LwtPhoneMessageList as $LwtPhoneMessage) {
  14. /** @var LwtPhoneMessageList $LwtPhoneMessage */
  15. foreach (PhoneMessage::$phoneList as $phone) {
  16. $resultList[] = PhoneMessage::sendNoticeMsg($phone, $LwtPhoneMessage->company_name, $LwtPhoneMessage->code);
  17. }
  18. $idList[] = $LwtPhoneMessage->id;
  19. }
  20. if ($idList != []) {
  21. LwtPhoneMessageList::updateAll(["is_send" => 1, "update_time" => time()], ["id" => $idList]);
  22. }
  23. var_dump($resultList);
  24. }
  25. }