This commit is contained in:
yangduo 2025-01-26 12:02:16 +08:00
parent dd6ac9c8bb
commit f03228764d

View File

@ -146,13 +146,14 @@ func (this *GiftCodeApi) List(c *gin.Context) {
} }
func (this *GiftCodeApi) DownloadFile(c *gin.Context) { func (this *GiftCodeApi) DownloadFile(c *gin.Context) {
gameid := q5.SafeToInt32(c.DefaultQuery("gameid", ""))
batchid := q5.SafeToInt32(c.DefaultQuery("batchid", "")) batchid := q5.SafeToInt32(c.DefaultQuery("batchid", ""))
if batchid < 1 { if gameid < 1 || batchid < 1 {
f5.RspErr2(c, 1, "batchid error") f5.RspErr2(c, 1, "gameid or batchid error")
return return
} }
sql := fmt.Sprintf("SELECT * FROM t_activation_code WHERE 1=1 AND batch_id = %d", batchid) sql := fmt.Sprintf("SELECT * FROM t_gift_code WHERE 1=1 AND gameid = %d AND batch_id = %d", gameid, batchid)
f5.GetGoStyleDb().RawQuery( f5.GetGoStyleDb().RawQuery(
constant.ACCOUNT_DB, constant.ACCOUNT_DB,
sql, sql,
@ -163,15 +164,8 @@ func (this *GiftCodeApi) DownloadFile(c *gin.Context) {
return return
} }
data := []struct { data := []*system.GiftCode{}
BatchId int32 `json:"batch_id"` f5.UnmarshalModelList(ds, &data)
Code string `json:"activation_code"`
}{}
for ds.Next() {
p := q5.NewSliceElement(&data)
p.BatchId = q5.SafeToInt32(ds.GetByName("batch_id"))
p.Code = ds.GetByName("activation_code")
}
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"code": 0, "code": 0,