Browse Source

权限提示文案修改

xingzai 2 years ago
parent
commit
0ae4606aae

+ 2 - 2
controllers/activity.go

@@ -3732,13 +3732,13 @@ func (this *ActivityCoAntroller) SpecialSignupAdd() {
 			resp.Status = 2
 		}
 	} else {
-		hasPermission, sellerName, sellerMobile, err := services.GetUserHasPermission(user)
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 			return
 		}
-		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+		resp.PopupMsg = popupMsg
 		resp.HasPermission = hasPermission
 		resp.SellerName = sellerName
 		resp.SellerMobile = sellerMobile

+ 30 - 38
controllers/activity_special.go

@@ -146,13 +146,13 @@ func (this *ActivitySpecialCoAntroller) SpecialDetail() {
 		resp.Detail = activityInfo
 		resp.Detail = activityInfo
 	} else {
-		hasPermission, sellerName, sellerMobile, err := services.GetUserHasPermission(user)
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 			return
 		}
-		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+		resp.PopupMsg = popupMsg
 		resp.HasPermission = hasPermission
 		resp.SellerName = sellerName
 		resp.SellerMobile = sellerMobile
@@ -257,44 +257,28 @@ func (this *ActivitySpecialCoAntroller) SpecialTripAdd() {
 					return
 				}
 				//SignupStatus  int    `description:"返回状态:1:成功 、2 :人数已满 、3:调研次数已用完、 4:超时"`
-
-				////给所属销售发送消息
-				//if sellerItem.Mobile != "" {
-				//	openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
-				//	if openIpItem != nil && openIpItem.OpenId != "" {
-				//		if sellerItem != nil {
-				//			go services.SendSpecialTemplateMsg(user.RealName+"【"+user.CompanyName+"】", time.Now().Format(utils.FormatDateTime), user.Mobile, activityInfo.ResearchTheme, "sale", openIpItem)
-				//		}
-				//	}
-				//}
-
-				// 给芳姐发消息
-				//cnf, _ := models.GetConfigByCode("tpl_msg")
-				//if cnf != nil {
-				//	openIpItem, _ := models.GetUserRecordByMobile(4, cnf.ConfigValue)
-				//	if openIpItem != nil && openIpItem.OpenId != "" {
-				//		actList, _ := models.GetActivityListSpecialAll(activityId)
-				//		if len(actList) == 5 {
-				//			var companyName string
-				//			for _, v := range actList {
-				//				companyName += "【" + v.CompanyName + "】"
-				//			}
-				//			go services.SendSpecialTemplateMsg(companyName, "", "", activityInfo.ResearchTheme, "", openIpItem)
-				//		}
-				//	}
-				//}
-				////用户专项调研操作行为,模板消息推送
-				//go services.SpecialActivityUserRemind(user, activityInfo, 1)
+			} else {
+				updateParams := make(map[string]interface{})
+				updateParams["IsValid"] = 1
+				updateParams["CreateTime"] = time.Now()
+				updateParams["IsCancel"] = 0
+				whereParam := map[string]interface{}{"user_id": user.UserId, "activity_id": activityId}
+				err = models.UpdateByExpr(models.CygxActivitySpecialTrip{}, whereParam, updateParams)
+				if err != nil {
+					br.Msg = "报名失败,"
+					br.ErrMsg = "二次报名,更改报名是否有效状态失败,Err:" + err.Error()
+					return
+				}
 			}
 		}
 	} else {
-		hasPermission, sellerName, sellerMobile, err := services.GetUserHasPermission(user)
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 			return
 		}
-		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+		resp.PopupMsg = popupMsg
 		resp.HasPermission = hasPermission
 		resp.SellerName = sellerName
 		resp.SellerMobile = sellerMobile
@@ -344,13 +328,21 @@ func (this *ActivitySpecialCoAntroller) Tripcancel() {
 		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
 		return
 	}
-	err = models.CancelActivitySpecialTrip(uid, activityInfo)
-	if err != nil {
-		br.Msg = "操作失败"
-		br.ErrMsg = "CancelActivitySpecialTrip,Err:" + err.Error()
-		return
+	resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
+	//48小时之内的取消也扣除一次参会记录
+	var isValid int
+	if time.Now().Add(+time.Hour * 48).After(resultTime) {
+		isValid = 1
+	}
+	if isValid == 0 {
+		err = models.CancelActivitySpecialTripIsValid(isValid, activityInfo.ActivityId, uid)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "CancelActivitySpecialTrip,Err:" + err.Error()
+			return
+		}
 	}
 	br.Ret = 200
 	br.Success = true
-	br.Msg = "会议提醒已取消"
+	br.Msg = "已取消"
 }

+ 2 - 2
models/activity.go

@@ -851,7 +851,7 @@ FROM
 	cygx_activity_special AS a 
 WHERE
 	activity_id = ?
-	AND publish_status = 1`
+	AND publish_status = 1 	AND is_offline = 0  `
 	err = o.Raw(sql, uid, ActivityId).QueryRow(&item)
 	return
 }
@@ -997,7 +997,7 @@ func GetActivitySpecialSearcheList(condition string, pars []interface{}, conditi
 		FROM
 			cygx_activity_special AS art
 		WHERE
-			1 = 1`
+			1 = 1 `
 	if conditionSpecil != "" {
 		sql += conditionSpecil
 	}

+ 10 - 0
models/activity_special_trip.go

@@ -21,6 +21,8 @@ type CygxActivitySpecialTrip struct {
 	Source         int       `description:"来源,1小程序,2后台添加"`
 	OutboundMobile string    `description:"外呼手机号"`
 	CountryCode    string    `description:"手机国家区号"`
+	IsCancel       string    `description:"是否取消,1是,0否"`
+	IsValid        string    `description:"参会报名是否有效 1:是,0"`
 }
 
 type CygxActivitySpecialTripResp struct {
@@ -91,3 +93,11 @@ func CancelActivitySpecialTrip(uid int, item *CygxActivitySpecialDetail) (err er
 	_, err = o.Raw(sql, uid, item.ActivityId).Exec()
 	return
 }
+
+//CancelActivitySpecialTripIsValid  处理活动报名是否有效
+func CancelActivitySpecialTripIsValid(isValid, activityId, userId int) (err error) {
+	sql := ` UPDATE cygx_activity_special_trip SET  is_valid= ?,is_cancel = 1  WHERE activity_id = ? AND  user_id = ? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, isValid, activityId, userId).Exec()
+	return
+}

+ 9 - 5
services/activity_special.go

@@ -242,7 +242,7 @@ func GetActivitySpecialPrepareList(user *models.WxUserItem, startSize, pageSize
 
 /*
 确定行程的查询  GetActivityLabelSpecialConfirmList
-state 进行状态 1:未开始,2:进行中,3:已结束 不传默认查询全部items []*CygxActivitySpecialDetail
+state 进行状态 1:未开始,2:进行中,3:已结束,4:未开始、进行中 不传默认查询全部items []*CygxActivitySpecialDetail
 */
 func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, pageSize, state int, keywords string) (list []*models.CygxActivitySpecialDetail, totalConfirm int, err error) {
 	//var condition string
@@ -267,7 +267,7 @@ func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, page
 		}
 	}
 	var pars []interface{}
-	condition += ` AND art.days >0  `
+	condition += ` AND art.days >0  AND art.publish_status =1   AND art.is_offline = 0  `
 	if state == 1 {
 		condition += ` AND art.activity_time > ? `
 		pars = append(pars, time.Now())
@@ -282,6 +282,10 @@ func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, page
 		condition += ` AND art.activity_time_end < ? `
 		pars = append(pars, time.Now())
 	}
+	if state == 4 {
+		condition += ` AND art.activity_time_end > ? `
+		pars = append(pars, time.Now())
+	}
 	if keywords != "" {
 		keywords = "%" + keywords + "%"
 		condition += ` AND art.research_theme LIKE ? `
@@ -357,7 +361,7 @@ func GetSpecialTripUserMap(activityIds []int, userId int) (mapUserId map[int]int
 
 //GetActivitySpecialList 获取专项调研列表
 func GetActivitySpecialList(user *models.WxUserItem, currentIndex, pageSize int, keywords string) (list []*models.CygxActivitySpecialDetail, total int, err error) {
-	listConfirm, totalConfirm, e := GetActivityLabelSpecialConfirmList(user, (currentIndex-1)*pageSize, pageSize, 0, keywords)
+	listConfirm, totalConfirm, e := GetActivityLabelSpecialConfirmList(user, (currentIndex-1)*pageSize, pageSize, 4, keywords)
 	if e != nil {
 		err = errors.New("GetActivityLabelSpecialConfirmList, Err: " + e.Error())
 		return
@@ -481,8 +485,8 @@ func GetActivitySpecialSearcheList(user *models.WxUserItem, condition string, st
 	var pars, parsSpecil []interface{}
 	if keywords != "" {
 		keywords = "%" + keywords + "%"
-		conditionSpecil += ` AND art.research_theme LIKE ?`
-		parsSpecil = append(parsSpecil, keywords)
+		conditionSpecil += ` AND (art.research_theme LIKE ? OR art.label LIKE ?  ) `
+		parsSpecil = append(parsSpecil, keywords, keywords)
 	}
 	list, totalSearche, e := models.GetActivitySpecialSearcheList(condition, pars, conditionSpecil, parsSpecil, startSize, pageSize)
 	if e != nil {

+ 1 - 1
services/activity_special_trip.go

@@ -30,7 +30,7 @@ func SpecialTripPopupMsg(activityInfo *models.CygxActivitySpecialDetail, user *m
 	var condition string
 	var pars []interface{}
 
-	condition += ` AND activity_id =  ? `
+	condition += ` AND activity_id =  ? AND  is_cancel = 0 `
 	pars = append(pars, activityInfo.ActivityId)
 
 	tripTota, e := models.GetActivitySpecialTripCountByActivityId(condition, pars)

+ 2 - 2
services/company_permission.go

@@ -31,7 +31,7 @@ func GetCompanyPermissionUpgrade(companyId int) (permissionStr string, err error
 }
 
 //获取用户对应的权限申请状态
-func GetUserHasPermission(user *models.WxUserItem) (hasPermission int, sellerName, sellerMobile string, err error) {
+func GetUserHasPermission(user *models.WxUserItem) (hasPermission int, sellerName, sellerMobile, popupMsg string, err error) {
 	//HasPermission     int    `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请,5:有IFCC、无权益"`
 	uid := user.UserId
 	applyCount, e := models.GetApplyRecordCount(uid)
@@ -72,6 +72,6 @@ func GetUserHasPermission(user *models.WxUserItem) (hasPermission int, sellerNam
 			}
 		}
 	}
-	fmt.Println(hasPermission)
+	popupMsg = "需要升级行业套餐权限才可参与此活动,请联系对口销售"
 	return
 }