activity_signup.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package services
  2. import (
  3. "errors"
  4. "hongze/hongze_cygx/models"
  5. "hongze/hongze_cygx/utils"
  6. )
  7. // GetActivitySignupResp 处理用户的报名方式
  8. func GetActivitySignupResp(activityIdS []int, user *models.WxUserItem) (mapItem map[int]int, err error) {
  9. var condition string
  10. var pars []interface{}
  11. lenActivityId := len(activityIdS)
  12. if lenActivityId == 0 || user.Mobile == "" {
  13. return
  14. }
  15. condition = ` AND do_fail_type = 0 AND activity_id IN (` + utils.GetOrmInReplace(lenActivityId) + `) AND mobile = ?`
  16. pars = append(pars, activityIdS, user.Mobile)
  17. listSignup, e := models.GetActivitySignupList(condition, pars)
  18. if e != nil {
  19. err = errors.New("GetResourceDataList, Err: " + e.Error())
  20. return
  21. }
  22. mapItem = make(map[int]int, 0)
  23. for _, v := range listSignup {
  24. mapItem[v.ActivityId] = v.SignupType
  25. }
  26. return
  27. }
  28. // CheckActivitySignUpLimit 校验报名限制
  29. func CheckActivitySignUpLimit(user *models.WxUserItem, activityInfo *models.ActivityDetail) (signupStatus, popupMsg string, failType int, err error) {
  30. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  31. signupStatus = "Success"
  32. activityId := activityInfo.ActivityId
  33. //弘则下面的用户不做单机构两人限制、不受报名总人数限制
  34. if user.CompanyId != utils.HZ_COMPANY_ID {
  35. totaSignupPeopleNum, e := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
  36. if e != nil {
  37. err = errors.New("GetActivitySignupSuccessByUserCountNoHz, Err: " + e.Error())
  38. return
  39. }
  40. if totaSignupPeopleNum >= activityInfo.LimitPeopleNum {
  41. signupStatus = "FullStarffed"
  42. popupMsg = "此活动报名人数已满,请留意下期活动"
  43. failType = 1
  44. return
  45. }
  46. totalSignupCompany, e := models.GetActivitySignupCompanyCount(activityId, user.CompanyId)
  47. if e != nil {
  48. err = errors.New("GetActivitySignupCompanyCount, Err: " + e.Error())
  49. return
  50. }
  51. if totalSignupCompany >= 2 {
  52. signupStatus = "TwoPeople"
  53. popupMsg = "单机构最多2人报名同一活动,您所在机构报名人数已满"
  54. failType = 2
  55. return
  56. }
  57. }
  58. //totalRestrict, e := models.GetUserRestrictCount(user.Mobile)
  59. //if e != nil {
  60. // err = errors.New("GetUserRestrictCount, Err: " + e.Error())
  61. // return
  62. //}
  63. //if totalRestrict >= 1 {
  64. // signupStatus = "BreakPromise"
  65. // popupMsg = "由于爽约次数过多,您暂时被限制报名资格,请联系对口销售"
  66. // failType = 3
  67. // return
  68. //}
  69. return
  70. }