UserLabelController.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * 会员标签 定时任务
  4. */
  5. namespace console\controllers;
  6. use common\enums\StatusEnum;
  7. use common\enums\UserLabelEnum;
  8. use common\logic\common\Label;
  9. use common\models\mall\Mall;
  10. use common\models\user\User;
  11. use common\models\user\UserLabel;
  12. use common\models\user\UserLabelRelationship;
  13. use yii\console\Controller;
  14. use yii\console\ExitCode;
  15. use yii\helpers\Json;
  16. use common\traits\ErrorTrait;
  17. use Yii;
  18. class UserLabelController extends Controller
  19. {
  20. use ErrorTrait;
  21. public function actionHandleLabel()
  22. {
  23. try {
  24. // 获取有效的商城
  25. $mall_list = Mall::getEnableMallList(true);
  26. if(!empty($mall_list)) {
  27. foreach ($mall_list as $mall) {
  28. $mall_id = $mall['id'];// 商城id
  29. $res = Label::Handle($mall_id);
  30. if ($res == false) throw new \Exception($this->getError());
  31. }
  32. }
  33. echo '操作成功';
  34. return ExitCode::OK;
  35. } catch (\Exception $e) {
  36. echo $e->getMessage();
  37. $this->stderr('Error: ' . ExitCode::getReason(ExitCode::UNSPECIFIED_ERROR));
  38. return ExitCode::UNSPECIFIED_ERROR;
  39. }
  40. }
  41. }