1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package services
- import (
- "errors"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/utils"
- )
- // GetActivitySignupResp 处理用户的报名方式
- func GetActivitySignupResp(activityIdS []int, user *models.WxUserItem) (mapItem map[int]int, err error) {
- var condition string
- var pars []interface{}
- lenActivityId := len(activityIdS)
- if lenActivityId == 0 || user.Mobile == "" {
- return
- }
- condition = ` AND do_fail_type = 0 AND activity_id IN (` + utils.GetOrmInReplace(lenActivityId) + `) AND mobile = ?`
- pars = append(pars, activityIdS, user.Mobile)
- listSignup, e := models.GetActivitySignupList(condition, pars)
- if e != nil {
- err = errors.New("GetResourceDataList, Err: " + e.Error())
- return
- }
- mapItem = make(map[int]int, 0)
- for _, v := range listSignup {
- mapItem[v.ActivityId] = v.SignupType
- }
- return
- }
- // CheckActivitySignUpLimit 校验报名限制
- func CheckActivitySignUpLimit(user *models.WxUserItem, activityInfo *models.ActivityDetail) (signupStatus, popupMsg string, failType int, err error) {
- //判断优先级:总人数限制→单机构2人限制→爽约3次限制
- signupStatus = "Success"
- activityId := activityInfo.ActivityId
- //弘则下面的用户不做单机构两人限制、不受报名总人数限制
- if user.CompanyId != utils.HZ_COMPANY_ID {
- totaSignupPeopleNum, e := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
- if e != nil {
- err = errors.New("GetActivitySignupSuccessByUserCountNoHz, Err: " + e.Error())
- return
- }
- if totaSignupPeopleNum >= activityInfo.LimitPeopleNum {
- signupStatus = "FullStarffed"
- popupMsg = "此活动报名人数已满,请留意下期活动"
- failType = 1
- return
- }
- totalSignupCompany, e := models.GetActivitySignupCompanyCount(activityId, user.CompanyId)
- if e != nil {
- err = errors.New("GetActivitySignupCompanyCount, Err: " + e.Error())
- return
- }
- if totalSignupCompany >= 2 {
- signupStatus = "TwoPeople"
- popupMsg = "单机构最多2人报名同一活动,您所在机构报名人数已满"
- failType = 2
- return
- }
- }
- //totalRestrict, e := models.GetUserRestrictCount(user.Mobile)
- //if e != nil {
- // err = errors.New("GetUserRestrictCount, Err: " + e.Error())
- // return
- //}
- //if totalRestrict >= 1 {
- // signupStatus = "BreakPromise"
- // popupMsg = "由于爽约次数过多,您暂时被限制报名资格,请联系对口销售"
- // failType = 3
- // return
- //}
- return
- }
|