Browse Source

Merge remote-tracking branch 'origin/master'

one_orenge
DengBiao 8 months ago
parent
commit
681959e447
1 changed files with 13 additions and 2 deletions
  1. +13
    -2
      consume/zhios_order_total_second.go

+ 13
- 2
consume/zhios_order_total_second.go View File

@@ -119,25 +119,36 @@ func handleZhiosOrderTotalSecond(msg []byte) error {
Date: utils.StrToInt(now), Date: utils.StrToInt(now),
Uid: v.Uid, Uid: v.Uid,
} }
_, err := sess.Insert(&userStatistics)
has, err := sess.Insert(&userStatistics)
if err != nil { if err != nil {
sess.Rollback() sess.Rollback()
return err return err
} }
if has == 0 {
sess.Rollback()
return errors.New("失败")
}
} }
isupdate := 0
if ordData.State == 4 && ordData.IsTotal == 1 { if ordData.State == 4 && ordData.IsTotal == 1 {
isupdate = 1
isTotal = 2 isTotal = 2
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4) userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4)
} }
if ordData.State != 4 && ordData.IsTotal == 0 { if ordData.State != 4 && ordData.IsTotal == 0 {
isupdate = 1
isTotal = 1 isTotal = 1
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 4) userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 4)
} }
_, err := sess.Where("id=?", userStatistics.Id).Cols("amount").Update(&userStatistics)
update, err := sess.Where("id=?", userStatistics.Id).Cols("amount").Update(&userStatistics)
if err != nil { if err != nil {
sess.Rollback() sess.Rollback()
return err return err
} }
if update == 0 && isupdate == 1 {
sess.Rollback()
return errors.New("失败")
}
} }
} }
} else { } else {


Loading…
Cancel
Save