ignoreactionlogic.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. query := map[string]interface{}{
  29. "position_id": req.PositionId,
  30. "itype": req.Source,
  31. "relate_id": util.DecodeId(req.RelateId),
  32. }
  33. info := T.CrmMysql.FindOne("connection_status", query, "id", "")
  34. if info != nil && len(*info) > 0 {
  35. update := map[string]interface{}{
  36. "is_ignore": req.Action,
  37. }
  38. if req.Action == "1" {
  39. update["is_handle"] = 0
  40. }
  41. b := T.CrmMysql.Update("connection_status", query, update)
  42. if !b {
  43. resp.Error_code = -1
  44. resp.Error_msg = "状态更新失败"
  45. } else {
  46. resp.Error_msg = "更新成功"
  47. }
  48. } else {
  49. if req.Action == "1" {
  50. save := map[string]interface{}{
  51. "position_id": req.PositionId,
  52. "ent_id": req.EntId,
  53. "ent_dept_id": req.EntDeptId,
  54. "ent_user_id": req.EntUserId,
  55. "relate_id": req.RelateId,
  56. "itype": req.Source,
  57. "is_handle": 1,
  58. "is_ignore": req.Action,
  59. "create_time": time.Now().Format(date.Date_Full_Layout),
  60. "update_time": time.Now().Format(date.Date_Full_Layout),
  61. }
  62. i := T.CrmMysql.Insert("connection_status", save)
  63. if i <= 0 {
  64. resp.Error_code = -1
  65. resp.Error_msg = "插入失败"
  66. } else {
  67. resp.Data = i
  68. resp.Error_msg = "更新成功"
  69. }
  70. } else {
  71. resp.Error_code = -1
  72. resp.Error_msg = "未查询到收录信息"
  73. }
  74. }
  75. return
  76. }