附近小店
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

49 行
1.1 KiB

  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "xorm.io/xorm"
  6. )
  7. func GetUserVirtualAmountOne(session *xorm.Session, uid int, coinId int) (*model.UserVirtualAmount, error) {
  8. var m model.UserVirtualAmount
  9. isExist, err := session.Table("user_virtual_amount").Where("uid = ? AND coin_id = ?", uid, coinId).Get(&m)
  10. if err != nil {
  11. return nil, err
  12. }
  13. if !isExist {
  14. return nil, nil
  15. }
  16. return &m, nil
  17. }
  18. func GetUserVirtualAmountOneEg(eg *xorm.Engine, uid int, coinId int) (*model.UserVirtualAmount, error) {
  19. var m model.UserVirtualAmount
  20. isExist, err := eg.Table("user_virtual_amount").Where("uid = ? AND coin_id = ?", uid, coinId).Get(&m)
  21. if err != nil {
  22. return nil, err
  23. }
  24. if !isExist {
  25. return nil, nil
  26. }
  27. return &m, nil
  28. }
  29. func GetUserVirtualAmountSum(eg *xorm.Engine, uid int) (string, error) {
  30. var m model.UserVirtualAmount
  31. sum, err := eg.Table("user_virtual_amount").Where("uid = ? ", uid).Sum(&m, "amount")
  32. if err != nil {
  33. return "0", err
  34. }
  35. return utils.Float64ToStr(sum), nil
  36. }
  37. /*func UserVirtualAmountUpdateWithSession(session *xorm.Session, m *model.UserVirtualAmount) bool {
  38. }*/