抽奖&发奖

微服务应用,提供独立的抽奖服务和发奖服务

  • 框架:jm-root
  • 数据库:redis, mysql

抽奖流程:

  1. 工作台编辑或者新增活动配置的时候,由工作调用接口,将gift_config同步到redis中
  2. 由PHP抽奖入口出发抽奖服务
  3. 抽奖服务根据redis中的gift_config配置进行抽奖流程并将抽奖结果返回给PHP

抽奖接口

  • url: http://localhost:3000/awards
  • type: POST
  • post_data:
          {
              "game_id": 77430,
              "user_id": 1,
              "type": 5,
              "send_type": "auto",
              "rank": 1,
              "score": 10,
              "share_times": 1
          }
    
  • response_data:
          {
              "get": {
                  "gift_id": "192239",
                  "num": 0,
                  "gift_type": "1",
                  "game_id": 77430,
                  "user_id": 1,
                  "type": 5
                  "index": 0
              },
              "send": {
                  "code": 0,
                  "msg": "is send!"
              }
          }
    

发奖接口

  • url: http://localhost:3001/awards/send
  • type: POST
  • post_data:
          {
              game_id: 77430,
              user_id: 1,
              gift_id: -1,
              type: 5,
              send_type: 'auto',
              rank: 1,
              score: 10
          }
    
  • response_data:
              {
                  "code": 0,
                  "msg": "is send!"
              }
    

获取发送失败奖品的列表

  • url: http://localhost:3001/awards/fails?game_id=77430&user_id=1
  • type: GET
  • query_params:
              game_id: 游戏ID
              user_id: 玩家ID
    
  • response_data:
              {
                  "code": 0,
                  "msg": [
                      {
                          "create_time": "2017-07-27 17:42:02",
                          "type": 5,
                          "is_mysql": "no",   // 用来标记是否已经插入custom_game_gift到mysql数据库,no表示没有插入即发送失败
                          "gift_id": -1
                      },
                      {
                          "create_time": "2017-07-28 09:48:11",
                          "type": 5,
                          "is_mysql": "no",
                          "gift_id": -1
                      }
                  ]
              }
    

获取抽奖记录的信息

  • url: http://localhost:3000/conditions/enjoy?game_id=77430&user_id=1
  • type: GET
  • query_params:
              game_id: 游戏ID
              user_id: 玩家ID
    
  • response_data:
              [
                  {
                      "create_time": "2017-07-26 10:24:21",
                      "type": 5,
                      "is_mysql": "yes",
                      "gift_id": "192239",
                      "gift_type": "1",
                      "mysql_id": 47000
                  },
                  {
                      "create_time": "2017-07-26 10:24:24",
                      "type": 5,
                      "is_mysql": "yes",
                      "gift_id": "192239",
                      "gift_type": "1",
                      "mysql_id": 47001
                  }
              ]
    

results matching ""

    No results matching ""