Browse Source

查研观向5.2

xingzai 3 years ago
parent
commit
0fcece2b91

+ 22 - 0
controllers/activity.go

@@ -586,6 +586,12 @@ func (this *ActivityCoAntroller) Detail() {
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		return
 	}
+	detailConfig, err := models.GetConfigByCode("free_trial_card")
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
+		return
+	}
 
 	//获取FICC销售信息 如果是FICC的客户类型,则默认他申请过
 	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
@@ -626,6 +632,12 @@ func (this *ActivityCoAntroller) Detail() {
 					}
 				}
 			}
+
+			if detailConfig.ConfigValue == "1" {
+				if hasPermission == 3 {
+					resp.IsShow = true
+				}
+			}
 			resp.HasPermission = hasPermission
 			resp.OperationMode = "Apply"
 			resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
@@ -738,6 +750,11 @@ func (this *ActivityCoAntroller) Detail() {
 						}
 					}
 				}
+				if detailConfig.ConfigValue == "1" {
+					if hasPermission == 3 {
+						resp.IsShow = true
+					}
+				}
 				resp.HasPermission = hasPermission
 				resp.OperationMode = "Apply"
 				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
@@ -816,6 +833,11 @@ func (this *ActivityCoAntroller) Detail() {
 		resp.Detail = activityInfo
 	}
 	resp.HasPermission = hasPermission
+	if detailConfig.ConfigValue == "1" {
+		if hasPermission == 3 {
+			resp.IsShow = true
+		}
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 12 - 0
controllers/article.go

@@ -323,7 +323,19 @@ Loop:
 		detail.HttpUrl = utils.StrategyPlatform + strconv.Itoa(articleId)
 		detail.IsNeedJump = true
 	}
+
 	resp := new(models.ArticleDetailResp)
+	detailConfig, err := models.GetConfigByCode("free_trial_card")
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
+		return
+	}
+	if detailConfig.ConfigValue == "1" {
+		if hasPermission == 5 {
+			resp.IsShow = true
+		}
+	}
 	resp.HasPermission = hasPermission
 	resp.HaveResearch = haveResearch
 	resp.HasFree = hasFree

+ 94 - 124
controllers/user.go

@@ -898,40 +898,6 @@ func (this *UserController) AddCountryCcode() {
 	br.Msg = "新增成功"
 }
 
-//// @Title 是否需要填写外呼手机号
-//// @Description 获取是否需要填写外呼手机号接口
-//// @Success 200 {object} models.CountryCode
-//// @router /countryCcode/isNeedAddOutbound [get]
-//func (this *UserController) OutboundMobile() {
-//	br := new(models.BaseResponse).Init()
-//	defer func() {
-//		this.Data["json"] = br
-//		this.ServeJSON()
-//	}()
-//	user := this.User
-//	uid := user.UserId
-//	if user == nil {
-//		br.Msg = "请登录"
-//		br.ErrMsg = "请登录,用户信息为空"
-//		br.Ret = 408
-//		return
-//	}
-//	if uid == 0 {
-//		br.Msg = "请登录"
-//		br.ErrMsg = "请登录,用户信息为空"
-//		br.Ret = 408
-//		return
-//	}
-//	resp := new(models.OutboundMobile)
-//	if user.OutboundMobile == "" && user.CountryCode == "" {
-//		resp.IsNeedAddOutboundMobile = true
-//	}
-//	br.Ret = 200
-//	br.Success = true
-//	br.Msg = "获取成功"
-//	br.Data = resp
-//}
-
 // @Title 用户修改外呼手机号以及区号
 // @Description 用户修改外呼手机号以及区号接口
 // @Param	request	body models.OutboundMobileItem true "type json string"
@@ -1014,96 +980,6 @@ func (this *UserController) AddOutboundMobile() {
 	br.Msg = "操作成功"
 }
 
-// @Title  白名单同步
-// @Description 获取是否需要填写区号接口
-// @Param   Keypd   query   string  false       "搜索主题 多个用 , 隔开 (空为活动主题,非空为更多主题)"
-// @Success 200 {object} models.CountryCode
-// @router /whiteUser [get]
-func (this *UserController) WhiteUser() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-	user := this.User
-	uid := user.UserId
-	if user == nil {
-		br.Msg = "请登录"
-		br.ErrMsg = "请登录,用户信息为空"
-		br.Ret = 408
-		return
-	}
-	if uid == 0 {
-		br.Msg = "请登录"
-		br.ErrMsg = "请登录,用户信息为空"
-		br.Ret = 408
-		return
-	}
-	keypd := this.GetString("Keypd")
-
-	if keypd != "888wqrerqesdfdsfsdwdsfasdqwerqwer" {
-		br.Msg = "密码错误"
-		return
-	}
-	item := new(models.WxUserWhite)
-	fmt.Println(item)
-	var fieldStr string
-	var condition string
-	fieldStr = ` u.mobile,u.country_code,u.real_name,c.company_name,u.company_id,cp.seller_name,u.created_time,cp.status,`
-	condition = `  AND cp.status IN ( '正式', '试用' ) AND u.mobile != ''  `
-	list1, err := models.GetFormalUserWhiteList(fieldStr, condition)
-	if err != nil {
-		br.Msg = "获取失败,Err:" + err.Error()
-		return
-	}
-	fieldStr = ` u.outbound_mobile as mobile,u.outbound_country_code as country_code,u.real_name,c.company_name,u.company_id,u.created_time,cp.status,`
-	condition = ` AND u.mobile != u.outbound_mobile AND cp.status IN ( '正式', '试用' ) AND u.outbound_mobile != ''  `
-	list2, err := models.GetFormalUserWhiteList(fieldStr, condition)
-	if err != nil {
-		br.Msg = "获取失败,Err:" + err.Error()
-		return
-	}
-	fmt.Println(len(list1))
-	for k, v := range list1 {
-		item.Mobile = v.Mobile
-		item.CountryCode = v.CountryCode
-		item.CompanyName = v.CompanyName
-		item.PermissionName = v.Permission
-		item.CreatedTime = time.Now()
-		item.UserCreatedTime = v.CreatedTime
-		item.RealName = v.RealName
-		item.SellerName = v.SellerName
-		item.Status = v.Status
-		_, err := models.AddWxUserWhite(item)
-		if err != nil {
-			br.Msg = "获取失败,Err:" + err.Error()
-			return
-		}
-		fmt.Println(k)
-	}
-	item = new(models.WxUserWhite)
-	fmt.Println(len(list2))
-	for _, v := range list2 {
-		item.OutboundMobile = v.Mobile
-		item.OutboundCountryCode = v.CountryCode
-		item.CreatedTime = time.Now()
-		item.CompanyName = v.CompanyName
-		item.PermissionName = v.Permission
-		item.UserCreatedTime = v.CreatedTime
-		item.RealName = v.RealName
-		item.SellerName = v.SellerName
-		item.Status = v.Status
-		_, err := models.AddWxUserWhite(item)
-		if err != nil {
-			br.Msg = "获取失败,Err:" + err.Error()
-			return
-		}
-	}
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-}
-
 // @Title 获取我的提问
 // @Description 获取我的提问列表
 // @Success 200 {object} models.CygxAskListResp
@@ -1148,3 +1024,97 @@ func (this *UserController) AskList() {
 	br.Success = true
 	br.Data = resp
 }
+
+// @Title 是否展示免费试用按钮
+// @Description 获取是否展示免费试用按钮接口
+// @Param	request	body models.IsShow true "type json string"
+// @Success 200
+// @router /isShow/freeButton [get]
+func (this *UserController) IsShow() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	var resp models.IsShow
+	detail, err := models.GetConfigByCode("free_trial_card")
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
+		return
+	}
+	companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+		return
+	}
+	count, err := models.CountCygxUserFreeeButton(user.UserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+		return
+	}
+	if companyDetail != nil {
+		if detail.ConfigValue == "1" && (companyDetail.Status == "正式" || companyDetail.Status == "试用" || companyDetail.Status == "永续") && count == 0 {
+			resp.IsShow = true
+		}
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}
+
+// @Title 隐藏当天的按钮
+// @Description 隐藏当天的按钮接口
+// @Success 200
+// @router /freeButton/update [post]
+func (this *UserController) FreeButtonUpdate() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	count, err := models.CountCygxUserFreeeButtonByUser(user.UserId)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+		return
+	}
+	if count == 0 {
+		item := new(models.CygxUserFreeeButton)
+		item.UserId = user.UserId
+		item.CompanyId = user.CompanyId
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		item.EffectiveTime = time.Now().Format(utils.FormatDate)
+		_, err := models.AddCygxUserFreeeButton(item)
+		if err != nil {
+			br.Msg = "操作失败!"
+			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+			return
+		}
+	} else {
+		err := models.UpdateCygxUserFreeeButton(user.UserId)
+		if err != nil {
+			br.Msg = "操作失败!"
+			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+			return
+		}
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功!"
+}

+ 1 - 0
models/activity.go

@@ -108,6 +108,7 @@ type CygxActivityResp struct {
 	SellerMobile      string `description:"销售电话"`
 	SellerName        string `description:"销售姓名"`
 	Detail            *ActivityDetail
+	IsShow            bool `description:"是否展示"`
 }
 
 //通过纪要ID获取活动详情

+ 1 - 0
models/article.go

@@ -224,6 +224,7 @@ type ArticleDetailResp struct {
 	HasFree       int    `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
 	HaveResearch  bool   `description:"是否有研选权限"`
 	Mobile        string `description:"用户手机号"`
+	IsShow        bool   `description:"是否展示"`
 }
 
 type ArticleDetailHtgjResp struct {

+ 1 - 0
models/db.go

@@ -95,6 +95,7 @@ func init() {
 		new(UserSellerRelation),
 		new(CygxShanghaiCompanyLog),
 		new(CygxShanghaiErrLog),
+		new(CygxUserFreeeButton),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 45 - 0
models/user_freee_button.go

@@ -0,0 +1,45 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxUserFreeeButton struct {
+	Id            int       `orm:"column(id);pk"`
+	UserId        int       `description:"用户id"`
+	CompanyId     int       `description:"公司id"`
+	CreateTime    time.Time `description:"创建时间"`
+	ModifyTime    time.Time `description:"修改时间"`
+	EffectiveTime string    `description:"有效隐藏时间"`
+}
+
+//添加历史信息
+func AddCygxUserFreeeButton(item *CygxUserFreeeButton) (lastId int64, err error) {
+	o := orm.NewOrm()
+	item.ModifyTime = time.Now()
+	lastId, err = o.Insert(item)
+	return
+}
+
+//更新当天隐藏时间
+func UpdateCygxUserFreeeButton(userId int) (err error) {
+	o := orm.NewOrm()
+	msql := ` UPDATE cygx_user_freee_button SET effective_time = NOW() ,modify_time = NOW() WHERE user_id = ? `
+	_, err = o.Raw(msql, userId).Exec()
+	return
+}
+
+func CountCygxUserFreeeButton(userId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS count FROM cygx_user_freee_button WHERE user_id = ? AND  effective_time = date_format(now(),'%Y-%m-%d')`
+	err = o.Raw(sql, userId).QueryRow(&count)
+	return
+}
+
+func CountCygxUserFreeeButtonByUser(userId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS count FROM cygx_user_freee_button WHERE user_id = ? `
+	err = o.Raw(sql, userId).QueryRow(&count)
+	return
+}

+ 15 - 6
routers/commentsRouter_controllers.go

@@ -754,6 +754,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
+        beego.ControllerComments{
+            Method: "FreeButtonUpdate",
+            Router: "/freeButton/update",
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
         beego.ControllerComments{
             Method: "InterviewApplyList",
@@ -765,18 +774,18 @@ func init() {
 
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
         beego.ControllerComments{
-            Method: "Login",
-            Router: "/login",
-            AllowHTTPMethods: []string{"post"},
+            Method: "IsShow",
+            Router: "/isShow/freeButton",
+            AllowHTTPMethods: []string{"get"},
             MethodParams: param.Make(),
             Filters: nil,
             Params: nil})
 
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
         beego.ControllerComments{
-            Method: "WhiteUser",
-            Router: "/whiteUser",
-            AllowHTTPMethods: []string{"get"},
+            Method: "Login",
+            Router: "/login",
+            AllowHTTPMethods: []string{"post"},
             MethodParams: param.Make(),
             Filters: nil,
             Params: nil})