ignoreactionlogic.go 1.9 KB

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