infoc.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package unicom
  2. import (
  3. "strconv"
  4. "time"
  5. "go-common/app/job/main/app-wall/conf"
  6. "go-common/library/log"
  7. binfoc "go-common/library/log/infoc"
  8. )
  9. type infoc struct {
  10. usermob string
  11. phone string
  12. mid string
  13. leve string
  14. integral string
  15. flow string
  16. unicomtype string
  17. now string
  18. }
  19. type packInfoc struct {
  20. usermob string
  21. phone string
  22. mid string
  23. requestNo string
  24. packName string
  25. packIntegral string
  26. packType string
  27. now string
  28. }
  29. // unicomInfoc unicom user infoc
  30. func (s *Service) unicomInfoc(usermob string, phone, leve, integral, flow int, utype string, mid int64, now time.Time) {
  31. select {
  32. case s.logCh[mid%s.c.ChanDBNum] <- infoc{usermob, strconv.Itoa(phone), strconv.FormatInt(mid, 10),
  33. strconv.Itoa(leve), strconv.Itoa(integral), strconv.Itoa(flow), utype, strconv.FormatInt(now.Unix(), 10)}:
  34. default:
  35. log.Warn("unicomInfoc log buffer is full")
  36. }
  37. }
  38. func (s *Service) unicomInfocproc(i int64) {
  39. var (
  40. cliChan = s.logCh[i]
  41. packinf = binfoc.New(conf.Conf.UnicomUserInfoc2)
  42. )
  43. for {
  44. i, ok := <-cliChan
  45. if !ok {
  46. log.Warn("infoc proc exit")
  47. return
  48. }
  49. switch v := i.(type) {
  50. case infoc:
  51. packinf.Info(v.now, "0", v.usermob, v.phone, v.mid, v.leve, v.integral, v.flow, v.unicomtype)
  52. log.Info("unicomInfocproc log mid(%v) phone(%v)", v.mid, v.phone)
  53. }
  54. }
  55. }
  56. // unicomPackInfoc unicom pack infoc
  57. func (s *Service) unicomPackInfoc(usermob, packName, orderNumber string, phone, packIntegral, packType int, mid int64, now time.Time) {
  58. select {
  59. case s.packCh <- packInfoc{usermob, strconv.Itoa(phone), strconv.FormatInt(mid, 10),
  60. orderNumber, packName, strconv.Itoa(packIntegral), strconv.Itoa(packType), strconv.FormatInt(now.Unix(), 10)}:
  61. default:
  62. log.Warn("unicomPackInfoc log buffer is full")
  63. }
  64. }
  65. func (s *Service) unicomPackInfocproc() {
  66. var (
  67. packinf = binfoc.New(conf.Conf.UnicomPackInfoc)
  68. )
  69. for {
  70. i, ok := <-s.packCh
  71. if !ok {
  72. log.Warn("infoc proc exit")
  73. return
  74. }
  75. switch v := i.(type) {
  76. case packInfoc:
  77. packinf.Info(v.now, "0", v.usermob, v.phone, v.mid, v.requestNo, v.packName, v.packIntegral, v.packType)
  78. }
  79. }
  80. }