adjust
This commit is contained in:
parent
408e33cd24
commit
f689ab2111
@ -27,7 +27,7 @@ func (gca *GiftCodeApi) GenCode(c *gin.Context) {
|
|||||||
gameid := q5.SafeToInt32(c.DefaultQuery("gameid", "1"))
|
gameid := q5.SafeToInt32(c.DefaultQuery("gameid", "1"))
|
||||||
typeid := q5.SafeToInt32(c.DefaultQuery("type", ""))
|
typeid := q5.SafeToInt32(c.DefaultQuery("type", ""))
|
||||||
gifttype := new(system.GiftType)
|
gifttype := new(system.GiftType)
|
||||||
db := f5.GetApp().GetOrmDb(constant.ACCOUNT_DB).Table("t_gift_type").Take(gifttype, "gameid = ? AND gift_type = ?", gameid, typeid)
|
db := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table("t_gift_type").Take(gifttype, "gameid = ? AND gift_type = ?", gameid, typeid)
|
||||||
if db.Error != nil {
|
if db.Error != nil {
|
||||||
if !f5.IsOrmErrRecordNotFound(db.Error) {
|
if !f5.IsOrmErrRecordNotFound(db.Error) {
|
||||||
f5.RspErr2(c, 1, db.Error.Error())
|
f5.RspErr2(c, 1, db.Error.Error())
|
||||||
@ -38,7 +38,7 @@ func (gca *GiftCodeApi) GenCode(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
db = f5.GetApp().GetOrmDb(constant.ACCOUNT_DB).Table("t_gift_code").Where("gameid = ?", gameid).Select("max(batch_id)")
|
db = f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table("t_gift_code").Where("gameid = ?", gameid).Select("max(batch_id)")
|
||||||
err := db.Error
|
err := db.Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !f5.IsOrmErrRecordNotFound(err) {
|
if !f5.IsOrmErrRecordNotFound(err) {
|
||||||
@ -108,7 +108,7 @@ func (gca *GiftCodeApi) GenCode(c *gin.Context) {
|
|||||||
batchcodeinfo = append(batchcodeinfo, p)
|
batchcodeinfo = append(batchcodeinfo, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = f5.GetApp().GetOrmDb(constant.ACCOUNT_DB).Table("t_gift_code").Create(batchcodeinfo).Error
|
err = f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table("t_gift_code").Create(batchcodeinfo).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
f5.RspErr2(c, 1, err.Error())
|
f5.RspErr2(c, 1, err.Error())
|
||||||
return
|
return
|
||||||
@ -135,7 +135,7 @@ func (gca *GiftCodeApi) List(c *gin.Context) {
|
|||||||
params := []string{}
|
params := []string{}
|
||||||
result := []*system.GiftCode{}
|
result := []*system.GiftCode{}
|
||||||
f5.GetGoStyleDb().PageQuery(
|
f5.GetGoStyleDb().PageQuery(
|
||||||
constant.ACCOUNT_DB,
|
constant.ADMIN_DB,
|
||||||
q5.ToInt32(req.PageDto.PageSize),
|
q5.ToInt32(req.PageDto.PageSize),
|
||||||
q5.ToInt32(req.PageDto.Page),
|
q5.ToInt32(req.PageDto.Page),
|
||||||
sql,
|
sql,
|
||||||
@ -171,7 +171,7 @@ func (gca *GiftCodeApi) DownloadFile(c *gin.Context) {
|
|||||||
|
|
||||||
sql := fmt.Sprintf("SELECT * FROM t_gift_code WHERE 1=1 AND gameid = %d AND batch_id = %d", gameid, 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.ADMIN_DB,
|
||||||
sql,
|
sql,
|
||||||
[]string{},
|
[]string{},
|
||||||
func(err error, ds *f5.DataSet) {
|
func(err error, ds *f5.DataSet) {
|
||||||
@ -204,7 +204,7 @@ func (gca *GiftCodeApi) ListType(c *gin.Context) {
|
|||||||
params := []string{}
|
params := []string{}
|
||||||
result := []*system.GiftType{}
|
result := []*system.GiftType{}
|
||||||
f5.GetGoStyleDb().PageQuery(
|
f5.GetGoStyleDb().PageQuery(
|
||||||
constant.ACCOUNT_DB,
|
constant.ADMIN_DB,
|
||||||
q5.ToInt32(req.PageDto.PageSize),
|
q5.ToInt32(req.PageDto.PageSize),
|
||||||
q5.ToInt32(req.PageDto.Page),
|
q5.ToInt32(req.PageDto.Page),
|
||||||
sql,
|
sql,
|
||||||
@ -242,7 +242,7 @@ func (gca *GiftCodeApi) AddType(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var maxtype int32 = 0
|
var maxtype int32 = 0
|
||||||
db := f5.GetApp().GetOrmDb(constant.ACCOUNT_DB).Table("t_gift_type").Where("gameid = ?", req.GameId).Select("max(gift_type)")
|
db := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table("t_gift_type").Where("gameid = ?", req.GameId).Select("max(gift_type)")
|
||||||
err := db.Error
|
err := db.Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !f5.IsOrmErrRecordNotFound(err) {
|
if !f5.IsOrmErrRecordNotFound(err) {
|
||||||
@ -274,7 +274,7 @@ func (gca *GiftCodeApi) AddType(c *gin.Context) {
|
|||||||
p.CreateTime = nowsecs
|
p.CreateTime = nowsecs
|
||||||
p.ModifyTime = nowsecs
|
p.ModifyTime = nowsecs
|
||||||
|
|
||||||
err = f5.GetApp().GetOrmDb(constant.ACCOUNT_DB).Table(p.TableName()).Create(p).Error
|
err = f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table(p.TableName()).Create(p).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
f5.RspErr2(c, 1, err.Error())
|
f5.RspErr2(c, 1, err.Error())
|
||||||
return
|
return
|
||||||
@ -303,7 +303,7 @@ func (gca *GiftCodeApi) QueryCode(c *gin.Context) {
|
|||||||
Type int32 `json:"type"`
|
Type int32 `json:"type"`
|
||||||
}{}
|
}{}
|
||||||
codeinfo := new(system.GiftCode)
|
codeinfo := new(system.GiftCode)
|
||||||
db := f5.GetApp().GetOrmDb(constant.ACCOUNT_DB).Table(codeinfo.TableName()).Take(codeinfo, "gameid = ? AND gift_code = ?", req.GameId, req.Code)
|
db := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table(codeinfo.TableName()).Take(codeinfo, "gameid = ? AND gift_code = ?", req.GameId, req.Code)
|
||||||
err := db.Error
|
err := db.Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !f5.IsOrmErrRecordNotFound(err) {
|
if !f5.IsOrmErrRecordNotFound(err) {
|
||||||
@ -353,7 +353,7 @@ func (gca *GiftCodeApi) UseCode(c *gin.Context) {
|
|||||||
Type int32 `json:"type"`
|
Type int32 `json:"type"`
|
||||||
}{}
|
}{}
|
||||||
codeinfo := new(system.GiftCode)
|
codeinfo := new(system.GiftCode)
|
||||||
db := f5.GetApp().GetOrmDb(constant.ACCOUNT_DB).Table(codeinfo.TableName()).Take(codeinfo, "gameid = ? AND gift_code = ?", req.GameId, req.Code)
|
db := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table(codeinfo.TableName()).Take(codeinfo, "gameid = ? AND gift_code = ?", req.GameId, req.Code)
|
||||||
err := db.Error
|
err := db.Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !f5.IsOrmErrRecordNotFound(err) {
|
if !f5.IsOrmErrRecordNotFound(err) {
|
||||||
@ -373,7 +373,7 @@ func (gca *GiftCodeApi) UseCode(c *gin.Context) {
|
|||||||
|
|
||||||
if rspObj.CodeStatus == 0 && codeinfo.Limit > 0 {
|
if rspObj.CodeStatus == 0 && codeinfo.Limit > 0 {
|
||||||
codeinfo.Count++
|
codeinfo.Count++
|
||||||
err := f5.GetApp().GetOrmDb(constant.ACCOUNT_DB).Table(codeinfo.TableName()).Where("gameid = ?", req.GameId).Where("gift_code = ?", req.Code).UpdateColumn("count", codeinfo.Count).Error
|
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table(codeinfo.TableName()).Where("gameid = ?", req.GameId).Where("gift_code = ?", req.Code).UpdateColumn("count", codeinfo.Count).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
f5.GetSysLog().Error("update gift code error:%s, %s", req.AccountId, req.Code)
|
f5.GetSysLog().Error("update gift code error:%s, %s", req.AccountId, req.Code)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user