コード例 #1
0
 /**
  * Handle the dma.friends.reward.redeemed event
  * @param Reward $reward
  * The reward model that has just been redeemed
  * @param User $user
  * The user that redeemed the reward
  */
 public function onRewardRedeemed($reward, $user)
 {
     $data = ['reward' => $reward, 'user' => $user];
     // Send an email to the user that redeemed the reward
     if ($reward->enable_email) {
         Mail::send($reward->email_template, $data, function ($message) use($reward, $user) {
             $message->to($user->email, $user->full_name);
         });
     }
     if ($reward->enable_admin_email) {
         Mail::send($reward->admin_email_template, $data, function ($message) use($reward, $user) {
             // If a group is configured email those users
             if (!empty($reward->admin_email_group)) {
                 $group = UserGroup::find($reward->admin_email_group);
                 foreach ($group->users as $user) {
                     $message->to($user->email, $user->first_name . ' ' . $user->last_name);
                 }
             }
             // If an individual email is configured email that person
             if (!empty($reward->admin_email_address)) {
                 $message->to($reward->admin_email_address, 'Anonymous');
             }
         });
     }
     // Print the reward if user is at a kiosk
     $location = LocationManager::getLocation();
     if ($location) {
         $printManager = new PrintManager($location, $user);
         $printManager->printCoupon($reward);
     }
 }
コード例 #2
0
 /**
  * 普通用户组成员
  */
 public function actionGroupuser()
 {
     $view = \Yii::$app->view;
     $view->params['moduleName'] = '用户分组';
     $request = \Yii::$app->request;
     $groupId = $request->_get('groupId', '');
     $search = $request->_get('search', '');
     $where = 1;
     if (preg_match('/^1[0-9]{10}$/', $search)) {
         $where .= ' AND userMobile LIKE \'%' . $search . '%\'';
     } elseif (preg_match('/@/', $search)) {
         $where .= ' AND userEmail LIKE \'%' . $search . '%\'';
     } else {
         $where .= ' AND nickName LIKE \'%' . $search . '%\'';
     }
     $userModel = User::find()->where($where);
     $pageSize = \Yii::$app->params['pageSize'];
     $total = $userModel->count();
     $pagination = new Pagination(['defaultPageSize' => $pageSize, 'totalCount' => $total]);
     $data = $userModel->asArray()->offset($pagination->offset)->limit($pagination->limit)->all();
     $groupuser = UserGroup::find()->where('groupId=' . $groupId)->asArray()->All();
     foreach ($data as &$user) {
         foreach ($groupuser as $group) {
             if ($user['userId'] == $group['userId']) {
                 $user['inGroup'] = 1;
             }
         }
     }
     $token = Token::getToken();
     $userId = \Yii::$app->user->id;
     $savegroupuserIdentity = EasyHelpers::dataEncrypt('savegroupuser,' . $userId);
     return $this->render('groupuser', ['data' => $data, 'search' => $search, 'groupId' => $groupId, 'token' => $token, 'pagination' => $pagination, 'savegroupuserIdentity' => $savegroupuserIdentity]);
 }
コード例 #3
0
 /**
  * 组管理(编辑组成员)
  */
 public function actionSavegroupuser()
 {
     $request = \Yii::$app->request;
     $identity = Identity::checkIdentity('savegroupuser', '/app-backend/backend/adminmanage/savegroupuser');
     if (is_array($identity)) {
         return $identity;
     }
     $groupId = $request->_get('groupId', 0);
     $userId = $request->_get('userId', 0);
     if (!$groupId || !$userId) {
         return ['code' => 1, 'msg' => '数据非法', 'data' => []];
     }
     $check = UserGroup::find()->where('groupId=' . $groupId . ' And userId=' . $userId)->one();
     if ($check) {
         $res = UserGroup::deleteAll('groupId=' . $groupId . ' And userId=' . $userId);
     } else {
         $usergroup = new UserGroup();
         $usergroup->userId = $userId;
         $usergroup->groupId = $groupId;
         $res = $usergroup->save();
     }
     if ($res !== false) {
         return ['code' => 0, 'msg' => '操作成功', 'data' => []];
     } else {
         return ['code' => 2, 'msg' => '操作失败,请重试', 'data' => []];
     }
 }