瀏覽代碼

更新

one_orenge
huangjiajun 8 月之前
父節點
當前提交
080b78a600
共有 1 個檔案被更改,包括 29 行新增27 行删除
  1. +29
    -27
      consume/zhios_order_total_second.go

+ 29
- 27
consume/zhios_order_total_second.go 查看文件

@@ -150,41 +150,43 @@ func handleZhiosOrderTotalSecond(msg []byte) error {
sess.Rollback()
return errors.New("失败")
}
var userStatistics1 model.UserDayAmount
sess.Where("uid=? and date=?", v.Uid, nowDay).Get(&userStatistics1)
if userStatistics1.Id == 0 {
userStatistics1 = model.UserDayAmount{
Date: utils.StrToInt(nowDay),
Uid: v.Uid,
if v.CreateAt > 1711084223 {
var userStatistics1 model.UserDayAmount
sess.Where("uid=? and date=?", v.Uid, nowDay).Get(&userStatistics1)
if userStatistics1.Id == 0 {
userStatistics1 = model.UserDayAmount{
Date: utils.StrToInt(nowDay),
Uid: v.Uid,
}
has, err := sess.Insert(&userStatistics1)
if err != nil {
sess.Rollback()
return err
}
if has == 0 {
sess.Rollback()
return errors.New("失败")
}
}
has, err := sess.Insert(&userStatistics1)
if err != nil {
isupdate1 := 0
if ordData.State == 4 && ordData.IsTotal == 1 {
isupdate1 = 1
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4)
}
if ordData.State != 4 && ordData.IsTotal == 0 {
isupdate1 = 1
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 4)
}
update1, err1 := sess.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1)
if err1 != nil {
sess.Rollback()
return err
}
if has == 0 {
if update1 == 0 && isupdate1 == 1 {
sess.Rollback()
return errors.New("失败")
}
}
isupdate1 := 0
if ordData.State == 4 && ordData.IsTotal == 1 {
isupdate1 = 1
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4)
}
if ordData.State != 4 && ordData.IsTotal == 0 {
isupdate1 = 1
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 4)
}
update1, err1 := sess.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1)
if err1 != nil {
sess.Rollback()
return err
}
if update1 == 0 && isupdate1 == 1 {
sess.Rollback()
return errors.New("失败")
}
}
}
} else {


Loading…
取消
儲存