execute(); if($res == true) { echo 'success'; return ExitCode::OK; } } catch (\Exception $e) { echo '定时任务统计资产' . $e->getMessage(); $this->stderr('Error: ' . ExitCode::getReason(ExitCode::UNSPECIFIED_ERROR)); return ExitCode::UNSPECIFIED_ERROR; } } /** * 生成统计缓存任务 * * @param string type [global|user|goods|region] */ public function actionCacheStatistics(string $type, int $mall_id) { if (empty($type) || empty($mall_id)) return; $mall = Mall::find()->select('name')->where(['id' => $mall_id, 'is_delete' => 0, 'is_recycle' => 0, 'is_disable' => 0])->one(); if (empty($mall)) { echo 'id=' . $mall_id . '商城不存在'; $this->stderr('Error: ' . ExitCode::getReason(ExitCode::UNSPECIFIED_ERROR)); return ExitCode::UNSPECIFIED_ERROR; } try { switch ($type) { case 'global': $model = GlobalStatistics::class; break; case 'user': $model = UserStatistics::class; break; case 'goods': $model = GoodsStatistics::class; break; case 'region': $model = RegionStatistics::class; break; } $model::resetCache($mall_id); echo 'success'; return ExitCode::OK; } catch (\Exception $e) { echo '生成' . $type . '缓存失败' . $e->getMessage(); $this->stderr('Error: ' . ExitCode::getReason(ExitCode::UNSPECIFIED_ERROR)); return ExitCode::UNSPECIFIED_ERROR; } } /** * 团队数据每日统计 * @Author: lun * @DateTime: 2021/11/26 0026 9:16 * @Copyright: copyright (c) 2021 广东七件事集团 * @return int */ public function actionUserTeamStatistics() { try { $mall_list = Mall::getEnableMallList(true); if(!empty($mall_list)){ foreach ($mall_list as $mall){ $logic = new UserTeamStatisticsLogic(); $res = $logic->execute($mall['id']); if($res == false) { $this->stderr('Error: ' . ExitCode::getReason(ExitCode::UNSPECIFIED_ERROR)); return ExitCode::UNSPECIFIED_ERROR; } } } echo 'success'; return ExitCode::OK; } catch (\Exception $e) { echo '定时任务团队数据每日统计' . $e->getMessage(); $this->stderr('Error: ' . ExitCode::getReason(ExitCode::UNSPECIFIED_ERROR)); return ExitCode::UNSPECIFIED_ERROR; } } }