ignoreactionlogic.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. }
  43. } else {
  44. if req.Action == 1 {
  45. save := map[string]interface{}{
  46. "position_id": req.PositionId,
  47. "ent_id": req.EntId,
  48. "ent_dept_id": req.EntDeptId,
  49. "ent_user id": req.EntUserId,
  50. "relate_id": req.RelateId,
  51. "itype": req.Source,
  52. "is_handle": 1,
  53. "is_ignore": req.Action,
  54. "create_time": time.Now().Format(date.Date_Full_Layout),
  55. "update_time": time.Now().Format(date.Date_Full_Layout),
  56. }
  57. i := T.CrmMysql.Insert("connection_status", save)
  58. if i <= 0 {
  59. resp.Error_code = -1
  60. resp.Error_msg = "更新失败"
  61. }
  62. } else {
  63. resp.Error_code = -1
  64. resp.Error_msg = "更新失败"
  65. }
  66. }
  67. return
  68. }