deal.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package service
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/app/interface/main/videoup/model/archive"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. )
  9. func (s *Service) dealElec(c context.Context, openElec int8, aid, mid int64, ip string) (err error) {
  10. show, err := s.elec.ArcShow(c, mid, aid, ip)
  11. if err != nil {
  12. log.Error("s.elec.ArcShow(%d, %d, %d, %d) error(%v)", mid, aid, openElec, show, err)
  13. return
  14. }
  15. if show != (openElec == 1) {
  16. s.elec.ArcUpdate(c, mid, aid, openElec, ip)
  17. }
  18. return
  19. }
  20. func (s *Service) dealOrder(c context.Context, mid, aid, orderID int64, ip string) (err error) {
  21. if orderID == 0 {
  22. return
  23. }
  24. if err = s.order.BindOrder(c, mid, aid, orderID, ip); err != nil {
  25. log.Error("s.order.ExecuteOrder mid(%d) aid(%d) orderId(%d) error(%v)", mid, aid, orderID, err)
  26. err = ecode.VideoupOrderAPIErr
  27. }
  28. return
  29. }
  30. func (s *Service) dealTag(c context.Context, mid, aid int64, srcTag, descTag, ip string, typeID int16) (err error) {
  31. if srcTag != descTag {
  32. typeName := ""
  33. if tp, ok := s.typeCache[typeID]; ok && tp != nil {
  34. typeName = tp.Name
  35. if tp, ok = s.typeCache[tp.PID]; ok && tp != nil {
  36. typeName = fmt.Sprintf("%s,%s", typeName, tp.Name)
  37. }
  38. }
  39. if err = s.tag.UpBind(c, mid, aid, descTag, typeName, ip); err != nil {
  40. log.Error("s.tag.UpBind(%d, %d, %s, %s,%s) error(%d)", mid, aid, srcTag, descTag, typeName, err)
  41. return
  42. }
  43. }
  44. return
  45. }
  46. func (s *Service) dealWaterMark(c context.Context, mid int64, wm *archive.Watermark, ip string) (err error) {
  47. if wm != nil {
  48. if err = s.creative.SetWatermark(c, mid, wm.State, wm.Ty, wm.Pos, ip); err != nil {
  49. log.Error("s.creative.SetWatermark(%d,%+v,%+v) error(%d)", mid, wm, err)
  50. return
  51. }
  52. }
  53. return
  54. }
  55. func (s *Service) freshFavs(c context.Context, mid int64, ap *archive.ArcParam, ip string) (err error) {
  56. if err = s.arc.FreshFavTypes(c, mid, int(ap.TypeID)); err != nil {
  57. log.Error("s.arc.FreshFavTypes(%d,%+v,%+v) error(%d)", mid, ap, err)
  58. return
  59. }
  60. return
  61. }
  62. func (s *Service) uploadVideoEditInfo(c context.Context, ap *archive.ArcParam, aid, mid int64, ip string) (err error) {
  63. ap.EmptyVideoEditInfo()
  64. editors := make([]*archive.Editor, 0)
  65. for _, v := range ap.Videos {
  66. if v.Editor != nil && v.Cid > 0 {
  67. v.Editor.UpFrom = ap.UpFrom
  68. v.Editor.CID = v.Cid
  69. editors = append(editors, v.Editor)
  70. }
  71. }
  72. if len(editors) > 0 {
  73. if err = s.creative.UploadMaterial(c, editors, aid, mid, ip); err != nil {
  74. log.Error("s.creative.UploadMaterial (%+v,%d,%d,%s) error(%+v)", editors, aid, mid, ip, err)
  75. return
  76. }
  77. }
  78. return
  79. }
  80. func (s *Service) lotteryBind(c context.Context, lotteryID, aid, mid int64, ip string) (err error) {
  81. ck, _ := s.dynamic.UserCheck(c, mid, ip)
  82. if lotteryID > 0 && (ck == 1) {
  83. if err = s.dynamic.LotteryBind(c, lotteryID, aid, mid, ip); err != nil {
  84. log.Error("s.dynamic.LotteryBind (%+v,%d,%d,%s) error(%d)", lotteryID, aid, mid, ip, err)
  85. return
  86. }
  87. }
  88. return
  89. }
  90. func (s *Service) addFollowing(c context.Context, mid int64, fids []int64, upfrom int8, ip string) (err error) {
  91. if len(fids) > 0 {
  92. var src int
  93. if upfrom == archive.UpFromAPPAndroid {
  94. src = 173
  95. } else if upfrom == archive.UpFromAPPiOS || upfrom == archive.UpFromIpad {
  96. src = 183
  97. } else {
  98. src = 173
  99. }
  100. for _, fid := range fids {
  101. s.acc.AddFollowing(context.Background(), mid, fid, src, ip)
  102. }
  103. }
  104. return
  105. }