Exemplo n.º 1
0
 private function deleteMutiStaff($accountId)
 {
     $where = ['accountId' => $accountId, 'name' => MessageTemplate::STAFF_TITLE, 'mobile' => ['message' => MessageTemplate::STAFF_MOBILE_MESSAGE]];
     $number = MessageTemplate::count($where);
     if ($number >= 2) {
         $template = MessageTemplate::findOne($where);
         MessageTemplate::deleteAll(['_id' => $template->_id]);
     }
 }
 /**
  * delete muti staff
  */
 public function actionDeleteStaff()
 {
     $accountInfos = Account::findAll(['enabledMods' => ['$all' => ['product']]]);
     if ($accountInfos) {
         foreach ($accountInfos as $accountInfo) {
             $where = ['accountId' => $accountInfo['_id'], 'name' => MessageTemplate::STAFF_TITLE, 'mobile' => ['message' => MessageTemplate::STAFF_MOBILE_MESSAGE]];
             $number = MessageTemplate::count($where);
             if ($number >= 2) {
                 $template = MessageTemplate::findOne($where);
                 if (MessageTemplate::deleteAll(['_id' => $template->_id])) {
                     echo 'delete :' . $template->_id . PHP_EOL;
                 }
             }
         }
     }
     echo 'delete staff template successfully' . PHP_EOL;
 }