ignoreactionlogic.go 2.0 KB

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