unicom.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package unicom
  2. import (
  3. "fmt"
  4. "strconv"
  5. "strings"
  6. "time"
  7. "go-common/app/job/main/app-wall/model"
  8. xtime "go-common/library/time"
  9. )
  10. type UserBind struct {
  11. Usermob string `json:"usermob,omitempty"`
  12. Phone int `json:"phone"`
  13. Mid int64 `json:"mid"`
  14. State int `json:"state,omitempty"`
  15. Integral int `json:"integral"`
  16. Flow int `json:"flow"`
  17. Monthly time.Time `json:"monthly"`
  18. }
  19. // type
  20. type ClickMsg struct {
  21. Plat int8
  22. AID int64
  23. MID int64
  24. Lv int8
  25. BvID string
  26. CTime int64
  27. STime int64
  28. IP string
  29. KafkaBs []byte
  30. EpID int64
  31. SeasonType int
  32. UserAgent string
  33. }
  34. type Unicom struct {
  35. Usermob string `json:"-"`
  36. Spid int `json:"spid"`
  37. TypeInt int `json:"type"`
  38. Ordertime xtime.Time `json:"ordertime"`
  39. Endtime xtime.Time `json:"endtime,omitempty"`
  40. }
  41. type UnicomUserFlow struct {
  42. Phone int `json:"phone"`
  43. Mid int64 `json:"mid"`
  44. Integral int `json:"integral"`
  45. Flow int `json:"flow"`
  46. Outorderid string `json:"outorderid"`
  47. Orderid string `json:"orderid"`
  48. Desc string `json:"desc"`
  49. }
  50. type UnicomIP struct {
  51. Ipbegin int `json:"-"`
  52. Ipend int `json:"-"`
  53. IPStartUint uint32 `json:"-"`
  54. IPEndUint uint32 `json:"-"`
  55. }
  56. type UserPackLog struct {
  57. Phone int `json:"-"`
  58. Usermob string `json:"-"`
  59. Mid int64 `json:"-"`
  60. RequestNo string `json:"-"`
  61. Type int `json:"-"`
  62. Desc string `json:"-"`
  63. Integral int `json:"-"`
  64. }
  65. type UserIntegralLog struct {
  66. Phone int `json:"-"`
  67. Mid int64 `json:"-"`
  68. UnicomDesc string `json:"-"`
  69. Type int `json:"-"`
  70. Integral int `json:"-"`
  71. Flow int `json:"-"`
  72. Desc string `json:"-"`
  73. }
  74. func (u *UnicomIP) UnicomIPStrToint(ipstart, ipend string) {
  75. u.Ipbegin = ipToInt(ipstart)
  76. u.Ipend = ipToInt(ipend)
  77. }
  78. // ipToint
  79. func ipToInt(ipString string) (ipInt int) {
  80. tmp := strings.Split(ipString, ".")
  81. if len(tmp) < 4 {
  82. return
  83. }
  84. var ipStr string
  85. for _, tip := range tmp {
  86. var (
  87. ipLen = len(tip)
  88. last int
  89. ip1 string
  90. )
  91. if ipLen < 3 {
  92. last = 3 - ipLen
  93. switch last {
  94. case 1:
  95. ip1 = "0" + tip
  96. case 2:
  97. ip1 = "00" + tip
  98. case 3:
  99. ip1 = "000"
  100. }
  101. } else {
  102. ip1 = tip
  103. }
  104. ipStr = ipStr + ip1
  105. }
  106. ipInt, _ = strconv.Atoi(ipStr)
  107. return
  108. }
  109. func (u *UnicomIP) UnicomIPChange() {
  110. u.IPStartUint = u.unicomIPTOUint(u.Ipbegin)
  111. u.IPEndUint = u.unicomIPTOUint(u.Ipend)
  112. }
  113. func (u *UnicomIP) unicomIPTOUint(ip int) (ipUnit uint32) {
  114. var (
  115. ip1, ip2, ip3, ip4 int
  116. ipStr string
  117. )
  118. var _initIP = "%d.%d.%d.%d"
  119. ip1 = ip / 1000000000
  120. ip2 = (ip / 1000000) % 1000
  121. ip3 = (ip / 1000) % 1000
  122. ip4 = ip % 1000
  123. ipStr = fmt.Sprintf(_initIP, ip1, ip2, ip3, ip4)
  124. ipUnit = model.InetAtoN(ipStr)
  125. return
  126. }