Kaynağa Gözat

更新

one_orenge
huangjiajun 7 ay önce
ebeveyn
işleme
c7f6be7ebc
3 değiştirilmiş dosya ile 96 ekleme ve 1 silme
  1. +7
    -0
      app/db/model/user_wait_amount.go
  2. +16
    -0
      consume/zhios_order_settle_total.go
  3. +73
    -1
      consume/zhios_order_total_second.go

+ 7
- 0
app/db/model/user_wait_amount.go Dosyayı Görüntüle

@@ -0,0 +1,7 @@
package model

type UserWaitAmount struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
Amount string `json:"amount" xorm:"default 0.000000 DECIMAL(30,6)"`
}

+ 16
- 0
consume/zhios_order_settle_total.go Dosyayı Görüntüle

@@ -118,6 +118,22 @@ func handleZhiosOrderSettleTotal(msg []byte) error {
if err != nil {
return err
}
var userStatistics1 model.UserWaitAmount
sess.Where("uid=? ", v.Uid).Get(&userStatistics1)
if userStatistics1.Id == 0 {
continue
}
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 {
sess.Rollback()
return errors.New("失败")
}

}
}
sess.Commit()


+ 73
- 1
consume/zhios_order_total_second.go Dosyayı Görüntüle

@@ -150,7 +150,7 @@ func handleZhiosOrderTotalSecond(msg []byte) error {
sess.Rollback()
return errors.New("失败")
}
if v.CreateAt > 1711084223 {
if v.CreateAt > 1711086661 {
var userStatistics1 model.UserDayAmount
sess.Where("uid=? and date=?", v.Uid, nowDay).Get(&userStatistics1)
if userStatistics1.Id == 0 {
@@ -187,6 +187,42 @@ func handleZhiosOrderTotalSecond(msg []byte) error {
return errors.New("失败")
}
}
if v.CreateAt > 1711093286 {
var userStatistics1 model.UserWaitAmount
sess.Where("uid=? ", v.Uid).Get(&userStatistics1)
if userStatistics1.Id == 0 {
userStatistics1 = model.UserWaitAmount{
Uid: v.Uid,
}
has, err := sess.Insert(&userStatistics1)
if err != nil {
sess.Rollback()
return err
}
if has == 0 {
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 {
@@ -235,6 +271,42 @@ func handleZhiosOrderTotalSecond(msg []byte) error {
sess.Rollback()
return err
}
if ordData.CreateAt > 1711092953 {
var userStatistics1 model.UserWaitAmount
sess.Where("uid=? ", v.Uid).Get(&userStatistics1)
if userStatistics1.Id == 0 {
userStatistics1 = model.UserWaitAmount{
Uid: v.Uid,
}
has, err := sess.Insert(&userStatistics1)
if err != nil {
sess.Rollback()
return err
}
if has == 0 {
sess.Rollback()
return errors.New("失败")
}
}
if ordData.State == 4 && (ordData.IsTotal == 1 || ordData.IsTotal == 3) {
isTotal = 2
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-utils.StrToFloat64(v.AfterAmount), 4)
}
if ordData.State != 4 && (ordData.IsTotal == 0) {
isTotal = 3
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+utils.StrToFloat64(v.AfterAmount), 4)
}
if ordData.State != 4 && (ordData.IsTotal == 1) {
isTotal = 3
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-utils.StrToFloat64(v.Amount), 4)
}
_, err := sess.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics)
if err != nil {
sess.Rollback()
return err
}
}

}
}
}


Yükleniyor…
İptal
Kaydet