getdistributorlogic.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "context"
  5. "jyBXSubscribe/rpc/model"
  6. "strings"
  7. "jyBXSubscribe/rpc/internal/svc"
  8. "jyBXSubscribe/rpc/type/bxsubscribe"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type GetDistributorLogic struct {
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. logx.Logger
  15. }
  16. func NewGetDistributorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDistributorLogic {
  17. return &GetDistributorLogic{
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. Logger: logx.WithContext(ctx),
  21. }
  22. }
  23. // 手动分发人员
  24. func (l *GetDistributorLogic) GetDistributor(in *bxsubscribe.GetDistributorReq) (*bxsubscribe.DistributorResp, error) {
  25. // todo: add your logic here and delete this line
  26. da := new(bxsubscribe.DistributorResp)
  27. var (
  28. users []*model.User
  29. )
  30. //搜索分发人员
  31. if in.SelectIds == "1" {
  32. users = model.AllDistributor(common.IntAll(in.EntId), common.IntAll(in.EntUserId))
  33. } else {
  34. //手动分发人员
  35. users = model.Distributor(strings.Split(in.Region, ","), common.IntAll(in.EntId), common.IntAll(in.EntUserId))
  36. }
  37. if len(users) > 0 {
  38. for _, v := range users {
  39. var data bxsubscribe.UserResp
  40. data.Id = common.Int64All(v.Id)
  41. data.Name = v.Name
  42. data.Phone = v.Phone
  43. da.Items = append(da.Items, &data)
  44. }
  45. }
  46. return da, nil
  47. }