ignoreactionlogic.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/date"
  4. "app.yhyue.com/moapp/jypkg/ent/util"
  5. T "bp.jydev.jianyu360.cn/CRM/application/api/common"
  6. "context"
  7. "fmt"
  8. "time"
  9. "bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
  10. "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type IgnoreActionLogic struct {
  14. logx.Logger
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. }
  18. func NewIgnoreActionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *IgnoreActionLogic {
  19. return &IgnoreActionLogic{
  20. Logger: logx.WithContext(ctx),
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. }
  24. }
  25. func (l *IgnoreActionLogic) IgnoreAction(req *types.IgnoreReq) (resp *types.Reply, err error) {
  26. logx.Info(fmt.Sprintf("%+v", req))
  27. resp = &types.Reply{}
  28. rid := ""
  29. if req.Source == "2" {
  30. rid = util.DecodeId(req.RelateId)
  31. } else {
  32. rid = req.RelateId
  33. }
  34. query := map[string]interface{}{
  35. "position_id": req.PositionId,
  36. "itype": req.Source,
  37. "relate_id": rid,
  38. }
  39. info := T.CrmMysql.FindOne("connection_status", query, "id", "")
  40. if info != nil && len(*info) > 0 {
  41. update := map[string]interface{}{
  42. "is_ignore": req.Action,
  43. }
  44. if req.Action == "1" {
  45. update["is_handle"] = 0
  46. }
  47. b := T.CrmMysql.Update("connection_status", query, update)
  48. if !b {
  49. resp.Error_code = -1
  50. resp.Error_msg = "状态更新失败"
  51. } else {
  52. resp.Error_msg = "更新成功"
  53. }
  54. } else {
  55. if req.Action == "1" {
  56. save := map[string]interface{}{
  57. "position_id": req.PositionId,
  58. "ent_id": req.EntId,
  59. "ent_dept_id": req.EntDeptId,
  60. "ent_user_id": req.EntUserId,
  61. "relate_id": rid,
  62. "itype": req.Source,
  63. "is_handle": 1,
  64. "is_ignore": req.Action,
  65. "create_time": time.Now().Format(date.Date_Full_Layout),
  66. "update_time": time.Now().Format(date.Date_Full_Layout),
  67. }
  68. i := T.CrmMysql.Insert("connection_status", save)
  69. if i <= 0 {
  70. resp.Error_code = -1
  71. resp.Error_msg = "插入失败"
  72. } else {
  73. resp.Data = i
  74. resp.Error_msg = "更新成功"
  75. }
  76. } else {
  77. resp.Error_code = -1
  78. resp.Error_msg = "未查询到收录信息"
  79. }
  80. }
  81. return
  82. }