Pārlūkot izejas kodu

更新

one_orenge
huangjiajun pirms 8 mēnešiem
vecāks
revīzija
61e513e7af
3 mainītis faili ar 51 papildinājumiem un 4 dzēšanām
  1. +8
    -0
      app/db/model/user_day_amount.go
  2. +7
    -4
      app/db/model/user_month_amount.go
  3. +36
    -0
      consume/zhios_order_total_second.go

+ 8
- 0
app/db/model/user_day_amount.go Parādīt failu

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

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

+ 7
- 4
app/db/model/user_month_amount.go Parādīt failu

@@ -1,8 +1,11 @@
package model

type UserMonthAmount struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
Date int `json:"date" xorm:"comment('202301') INT(11)"`
Amount string `json:"amount" xorm:"default 0.000000 DECIMAL(30,6)"`
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
Date int `json:"date" xorm:"comment('202301') INT(11)"`
Amount string `json:"amount" xorm:"default 0.000000 DECIMAL(30,6)"`
PlatformAmount string `json:"platform_amount" xorm:"default 0.000000 DECIMAL(30,6)"`
ConfirmAmount string `json:"confirm_amount" xorm:"default 0.000000 DECIMAL(30,6)"`
SettleAmount string `json:"settle_amount" xorm:"default 0.000000 DECIMAL(30,6)"`
}

+ 36
- 0
consume/zhios_order_total_second.go Parādīt failu

@@ -95,6 +95,7 @@ func handleZhiosOrderTotalSecond(msg []byte) error {
}

now := time.Unix(int64(ordData.CreateAt), 0).Format("200601")
nowDay := time.Unix(int64(ordData.CreateAt), 0).Format("20060102")
isTotal := ordData.IsTotal
if ordData.OrderFormType >= 0 {
if ordData.IsTotal == 1 && ordData.State != 4 {
@@ -149,6 +150,41 @@ 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(now),
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 {


Notiek ielāde…
Atcelt
Saglabāt