EventProc.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace loyalsoft;
  3. include_once './EventProc/NormalEventProc.php';
  4. /**
  5. * 事件模块.
  6. * @version
  7. * 1.0.0 Created at 2017-8-28. by --gwang
  8. * @author gwang (mail@wanggangzero.cn)
  9. * @copyright ? 2017-8-28, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  10. */
  11. class EventProc {
  12. public static function procMain($req) {
  13. switch ($req->cmd) {
  14. case CmdCode::cmd_event_GetNotifications: # 7201 拉取角标通知列表
  15. return self::GetCornerSignNotifications($req);
  16. default:
  17. return Resp::err(ErrCode::cmd_err);
  18. }
  19. }
  20. //put your code here
  21. /**
  22. * [7201] 拉取角标通知
  23. * @param req $req
  24. */
  25. static function GetCornerSignNotifications($req) {
  26. // 这里直接返回, 将来开发对应的触发逻辑, 给数组中添加相应的值
  27. $arr = array_values(array_unique($req->userInfo->game->privateState->cornerSignNotifications)); # 返回值去重
  28. $req->userInfo->game->privateState->cornerSignNotifications = []; # 清理记录
  29. UserProc::updateUserInfo();
  30. return Resp::ok(array("notifications" => $arr)); # 返回
  31. }
  32. static function Init() {
  33. Event::register('onpay', array(new UserProfile(req()->userInfo->game->profile), "OnPay"));
  34. }
  35. /**
  36. * 收到请求
  37. */
  38. static function OnRequest() {
  39. }
  40. /**
  41. * 处理完毕准备返回
  42. */
  43. static function AfterResponse() {
  44. }
  45. /**
  46. * 当天第一次登录
  47. */
  48. static function OnNewDay() {
  49. }
  50. /**
  51. * 当周第一次登录(周一)
  52. */
  53. static function OnNewWeek() {
  54. }
  55. }