瀏覽代碼

更新

one_orenge
huangjiajun 8 月之前
父節點
當前提交
05c4ed77ef
共有 1 個檔案被更改,包括 31 行新增0 行删除
  1. +31
    -0
      consume/zhios_order_settle_total.go

+ 31
- 0
consume/zhios_order_settle_total.go 查看文件

@@ -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…
取消
儲存