Browse Source

更新

one_orenge
huangjiajun 8 months ago
parent
commit
05c4ed77ef
1 changed files with 31 additions and 0 deletions
  1. +31
    -0
      consume/zhios_order_settle_total.go

+ 31
- 0
consume/zhios_order_settle_total.go View File

@@ -134,6 +134,37 @@ func handleZhiosOrderSettleTotal(msg []byte) error {
return errors.New("失败")
}

var userStatistics2 model.UserMonthAmount
if ordData.SettleAt == 0 {
ordData.SettleAt = int(time.Now().Unix())
}
now := time.Unix(int64(ordData.SettleAt), 0).Format("200601")
sess.Where("uid=? and date=?", v.Uid, now).Get(&userStatistics2)
if userStatistics2.Id == 0 {
userStatistics2 = model.UserMonthAmount{
Date: utils.StrToInt(now),
Uid: v.Uid,
}
has, err := sess.Insert(&userStatistics2)
if err != nil {
sess.Rollback()
return err
}
if has == 0 {
sess.Rollback()
return errors.New("失败")
}
}
userStatistics2.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics2.SettleAmount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 4)
update2, err2 := eg.Where("id=?", userStatistics2.Id).Cols("settle_amount").Update(&userStatistics2)
if err2 != nil {
sess.Rollback()
return err2
}
if update2 == 0 {
sess.Rollback()
return errors.New("失败")
}
}
}
sess.Commit()


Loading…
Cancel
Save