附近小店
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

49 rader
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. }*/