public function run($accountId) { parent::run($accountId); //create default template $where = ['accountId' => $accountId, 'name' => MessageTemplate::STAFF_TITLE]; $result = MessageTemplate::findOne($where); if (empty($result)) { MessageTemplate::createStaffTemplate($accountId); } else { $this->deleteMutiStaff($accountId); } }
/** * create staff template */ public function actionCreateStaff() { //get the info of account $accountInfos = Account::findAll(['enabledMods' => ['$all' => ['product']]]); if ($accountInfos) { foreach ($accountInfos as $accountInfo) { $result = self::checkTemplateNotExists($accountInfo['_id'], MessageTemplate::STAFF_TITLE); if ($result) { MessageTemplate::createStaffTemplate($accountInfo['_id']); } } } echo 'create staff template successfully' . PHP_EOL; }
/** * do something after creating account * @param Account $account */ public static function afterCreateAccount($account) { $options = Yii::$app->params['sensitive_options']; foreach ($options as $name => $options) { SensitiveOperation::initOptions($name, $options, $account->_id); } MessageTemplate::createStaffTemplate($account->_id); }