parttimeuseraddlogic.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package part_time_user
  2. import (
  3. "context"
  4. "git.i2edu.net/i2/go-zero/core/stores/sqlx"
  5. "git.i2edu.net/i2/i2-bill-api/model"
  6. "time"
  7. "git.i2edu.net/i2/i2-bill-api/internal/svc"
  8. "git.i2edu.net/i2/i2-bill-api/internal/types"
  9. "git.i2edu.net/i2/go-zero/core/logx"
  10. )
  11. type PartTimeUserAddLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewPartTimeUserAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) PartTimeUserAddLogic {
  17. return PartTimeUserAddLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *PartTimeUserAddLogic) PartTimeUserAdd(req types.PartTimeUserAddRequest) (*types.Response, error) {
  24. // todo: add your logic here and delete this line
  25. userId := l.svcCtx.GetUserIdByJwt(l.ctx)
  26. var bean = new(model.I2billMktPartTimeUser)
  27. err := l.svcCtx.SqlConn.QueryRow(bean, "select * from i2bill_mkt_part_time_user where user_id = ? and del_flag = 0", userId)
  28. if err != nil && err != sqlx.ErrNotFound {
  29. return &types.Response{Code: 500, Msg: err.Error(), Data: nil}, nil
  30. }
  31. if bean.Id != 0 {
  32. if bean.CheckState == 54 {
  33. return &types.Response{Code: 500, Msg: "你的申请兼职人员的个人信息已提交,请等待审核!", Data: nil}, nil
  34. }
  35. if bean.CheckState == 58 {
  36. return &types.Response{Code: 500, Msg: "你的申请兼职人员的个人信息不通过原因:" + bean.CheckDesc, Data: nil}, nil
  37. }
  38. if bean.CheckState == 57 {
  39. return &types.Response{Code: 500, Msg: "你已经是兼职人员:", Data: nil}, nil
  40. }
  41. }
  42. bean = &model.I2billMktPartTimeUser{
  43. CreateTime: time.Now(),
  44. LastUpdateTime: time.Now(),
  45. DelFlag: 0,
  46. MkId: req.MkId,
  47. CreateBy: 1,
  48. CheckState: 54,
  49. CheckDesc: "",
  50. CityId: req.CityId,
  51. IponeNumber: "",
  52. Sex: req.Sex,
  53. Target: 0,
  54. UserId: userId,
  55. LastUpdateBy: 0,
  56. Name: req.Name,
  57. }
  58. res, err := model.NewI2billMktPartTimeUserModel(l.svcCtx.SqlConn).Insert(*bean)
  59. if err != nil {
  60. return &types.Response{Code: 500, Msg: err.Error(), Data: nil}, nil
  61. }
  62. id, _ := res.LastInsertId()
  63. return &types.Response{Code: 200, Msg: "", Data: id}, nil
  64. }