CustomController.php 749 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace console\controllers;
  3. use biz\ghs\classes\GhsClass;
  4. use bizGhs\custom\classes\CustomClass;
  5. use yii\console\Controller;
  6. use Yii;
  7. class CustomController extends Controller
  8. {
  9. //黑名单设置 ./yii custom/black
  10. public function actionBlack()
  11. {
  12. $list = CustomClass::getAllByCondition(['black' => 2], null, '*', null, true);
  13. if (!empty($list)) {
  14. foreach ($list as $c) {
  15. $ghsId = $c->ghsId ?? 0;
  16. $ghs = GhsClass::getById($ghsId, true);
  17. if (!empty($ghs)) {
  18. $ghs->black = 2;
  19. $ghs->save();
  20. echo $ghs->name . " id:{$ghs->id} 已经黑了\n";
  21. }
  22. }
  23. }
  24. }
  25. }