GS2-Lottery Transaction Actions

Specification of verify/consume/acquire transaction actions

Acquire Action

Gs2Lottery:DrawByUserId

Execute a lottery by specifying a User ID

Performs a lottery draw for the specified user based on the lottery model configuration. The lottery supports two methods: Prize Table mode (using predefined probability tables) and Script mode (using a GS2-Script to determine prizes). In box lottery mode, drawn prizes are removed from the box and cannot be drawn again. If the box is empty, an Empty error is returned. The drawn prizes are issued as a transaction.

Supports quantity specification: YES

Whether the action is reversible: NO

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
lotteryName string
~ 128 chars Lottery Model name
Lottery Model-specific name. Specified using alphanumeric characters, hyphen (-), underscore (_), and period (.).
userId string
~ 128 chars User ID
Specify #{userId} to substitute the currently logged-in user’s ID.
count int
1 ~ 1000 Number of draws
config List<Config> [] 0 ~ 1000 items Configuration values applied to transaction placeholders
timeOffsetToken string ~ 1024 chars Time offset token
{
    "action": "Gs2Lottery:DrawByUserId",
    "request": {
        "namespaceName": "[string]Namespace name",
        "lotteryName": "[string]Lottery Model name",
        "userId": "[string]User ID",
        "count": "[int]Number of draws",
        "config": [
            {
                "key": "[string]Name",
                "value": "[string]Value"
            }
        ],
        "timeOffsetToken": "[string]Time offset token"
    }
}
action: Gs2Lottery:DrawByUserId
request:
  namespaceName: "[string]Namespace name"
  lotteryName: "[string]Lottery Model name"
  userId: "[string]User ID"
  count: "[int]Number of draws"
  config: 
    - key: "[string]Name"
      value: "[string]Value"
  timeOffsetToken: "[string]Time offset token"
transaction.service("lottery").acquire.draw_by_user_id({
    namespaceName="[string]Namespace name",
    lotteryName="[string]Lottery Model name",
    userId="[string]User ID",
    count="[int]Number of draws",
    config={
        {
            key="[string]Name",
            value="[string]Value"
        }
    },
    timeOffsetToken="[string]Time offset token",
})

Gs2Lottery:ResetBoxByUserId

Reset box with specified user ID

Resets the specified user’s box to its initial state, returning all drawn prizes back into the box.

Supports quantity specification: NO

Whether the action is reversible: NO

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
prizeTableName string
~ 128 chars Prize Table name
userId string
~ 128 chars User ID
Specify #{userId} to substitute the currently logged-in user’s ID.
timeOffsetToken string ~ 1024 chars Time offset token
{
    "action": "Gs2Lottery:ResetBoxByUserId",
    "request": {
        "namespaceName": "[string]Namespace name",
        "prizeTableName": "[string]Prize Table name",
        "userId": "[string]User ID",
        "timeOffsetToken": "[string]Time offset token"
    }
}
action: Gs2Lottery:ResetBoxByUserId
request:
  namespaceName: "[string]Namespace name"
  prizeTableName: "[string]Prize Table name"
  userId: "[string]User ID"
  timeOffsetToken: "[string]Time offset token"
transaction.service("lottery").acquire.reset_box_by_user_id({
    namespaceName="[string]Namespace name",
    prizeTableName="[string]Prize Table name",
    userId="[string]User ID",
    timeOffsetToken="[string]Time offset token",
})