GoodsStatisticsController.php 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace addons\BusinessCard\console\controllers;
  3. use addons\BusinessCard\common\logic\Statistics;
  4. use yii\console\Controller;
  5. use yii\console\ExitCode;
  6. class GoodsStatisticsController extends Controller
  7. {
  8. /**
  9. * 自动监听名片商品浏览和访问统计
  10. *
  11. */
  12. // 0 */1 * * * *
  13. public function actionUpdateGoodsStatistics()
  14. {
  15. try {
  16. echo ' 自动监听名片商品浏览和访问统计任务开始执行 ... ' . PHP_EOL;
  17. // 获取当前系统所有可用的 mall_id
  18. Statistics::goodsStatistics();
  19. echo ' 自动监听名片商品浏览和访问统计任务执行完毕 ... ' . PHP_EOL;
  20. return ExitCode::OK;
  21. } catch (\Exception $e) {
  22. $errmsg = ' 自动监听名片商品浏览和访问统计任务执行出错, errmsg => ' . $e->getMessage() . ', file: ' . $e->getFile() . ', line: ' . $e->getLine();
  23. echo $errmsg . PHP_EOL;
  24. \Yii::error($errmsg);
  25. \Yii::getLogger()->flush(true);
  26. return false;
  27. }
  28. }
  29. }