ecs/platform/wechat/define.go
2025-06-04 18:17:39 +08:00

110 lines
4.4 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package wechat
const (
appId = "wx057a904618b19710"
appSecret = "9972a1b287261bebbaf9276127228133"
offerId = "1450125439"
appKey = "pn0LmWFP9LJlC2La27h6WyAeq3Wo0ePe" // 现网 appKey = "ZBgXETlv4Nrn230EBMYksDFEw33y8fWy" // 沙箱
apiEnv = 0 // 现网 apiEnv = 1 // 沙箱
apiUri = "https://api.weixin.qq.com"
apiCode2Session = "/sns/jscode2session"
apiGetAccessToken = "/cgi-bin/token"
apiGetStableAccessToken = "/cgi-bin/stable_token"
apiGetBalance = "/wxa/game_1/getbalance" //获取余额
apiPay = "/wxa/game_1/pay" //支付扣款
apiCancelPay = "/wxa/game_1/cancelpay" //取消支付
apiPresent = "/wxa/game_1/present" //赠送余额
syncSignKey = "246e4fabfaeacc8f2a2faa325ba0142c"
syncUri = "https://pay.77hd.com"
syncAccessToken = "/api/ios/v1/receive_cp_push_minigame_accesstoken/470526540514463744/470534187137503232"
)
func AppId() string {
return appId
}
func SyncSignKey() string {
return syncSignKey
}
type MsgWechatApiAck struct {
ErrCode uint32 `json:"errcode"` // 错误码
ErrMsg string `json:"errmsg"` // 错误信息
}
type MsgCode2SessionAck struct {
MsgWechatApiAck
OpenId string `json:"openid"` // 用户唯一标识
UnionId string `json:"unionid"` // 用户在开放平台的唯一标识符,若当前小程序已绑定到微信开放平台账号下会返回,详见 UnionID 机制说明。
SessionKey string `json:"session_key"` // 会话密钥
}
type MsgGetAccessTokenReq struct {
GrantType string `json:"grant_type"`
Appid string `json:"appid"`
Secret string `json:"secret"`
ForceRefresh bool `json:"force_refresh,omitempty"`
}
type MsgGetAccessTokenAck struct {
MsgWechatApiAck
AccessToken string `json:"access_token"` // 获取到的凭证
ExpiresIn int64 `json:"expires_in"` // 凭证有效时间单位秒。目前是7200秒之内的值。
}
type MsgVirtualPayReq struct {
OpenId string `json:"openid"` // 用户唯一标识符
OfferId string `json:"offer_id"` // 支付应用ID(OfferId)
Ts int64 `json:"ts"` // 当前UNIX时间戳
ZoneId string `json:"zone_id"` // 已发布的分区ID
Env int32 `json:"env"` // 环境配置, 0现网环境(也叫正式环境), 1沙箱环境
UserIp string `json:"user_ip,omitempty"` // 用户外网ip
}
type MsgGetBalanceReq struct {
MsgVirtualPayReq
}
type MsgGetBalanceAck struct {
MsgWechatApiAck
Balance int32 `json:"balance"` // 游戏币总余额,包括现金充值和赠送部分。
PresentBalance int32 `json:"present_balance"` // 赠送账户的游戏币余额
SumSave int64 `json:"sum_save"` // 累计现金充值获得的游戏币数量
SumPresent int64 `json:"sum_present"` // 累计赠送的游戏币数量
SumBalance int64 `json:"sum_balance"` // 累计获得的游戏币数量,包括现金充值和赠送
SumCost int64 `json:"sum_cost"` // 累计总消耗(即扣除)游戏币数量
FirstSave bool `json:"first_save"` // 是否满足首充活动标记
}
type MsgPayReq struct {
MsgVirtualPayReq
Amount uint32 `json:"amount"` // 金额(分)
BillNo string `json:"bill_no"` // 扣除游戏币订单号
PayItem string `json:"payitem,omitempty"` // 道具信息
Remark string `json:"remark,omitempty"` // 备注
}
type MsgPayAck struct {
MsgWechatApiAck
BillNo string `json:"bill_no"` // 扣除游戏币订单号
Balance int32 `json:"balance"` // 游戏币总余额,包括现金充值和赠送部分。
UsedPresentAmount int32 `json:"used_present_amount"` // 赠送账户的游戏币余额原1.0的gen_balance
}
type MsgCancelPayReq struct {
MsgVirtualPayReq
Amount uint32 `json:"amount"` // 金额(分)
PayBillNo string `json:"pay_bill_no"` // 扣除游戏币订单号
BillNo string `json:"bill_no"` // 扣除游戏币订单号
}
type MsgCancelPayAck struct {
MsgWechatApiAck
BillNo string `json:"bill_no"` // 扣除游戏币订单号
}
type MsgSyncAccessTokenAck struct {
Code int32 `json:"code"`
Msg string `json:"msg"`
}