Browse Source

no message

xingzai 2 years ago
parent
commit
3dbe422a5e

+ 154 - 0
controllers/activity_special.go

@@ -0,0 +1,154 @@
+package controllers
+
+import (
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
+	"hongze/hongze_cygx/utils"
+	"strings"
+)
+
+//专项调研活动
+type ActivitySpecialCoAntroller struct {
+	BaseAuthController
+}
+
+// @Title 专项产业调研列表
+// @Description 获取专项产业调研列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.GetCygxActivitySpecialDetailListResp
+// @router /list [get]
+func (this *ActivitySpecialCoAntroller) SpecialList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	//uid := user.UserId
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	userType, permissionStr, err := services.GetUserType(user.CompanyId)
+	fmt.Println(permissionStr)
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	var condition string
+	var pars []interface{}
+	//活动可见限制
+	slicePer := strings.Split(permissionStr, ",")
+	var permissionSqlStr string
+	for _, v := range slicePer {
+		if userType == 1 {
+			if !strings.Contains(v, "研选") {
+				permissionSqlStr += "'" + v + "',"
+			}
+		} else {
+			permissionSqlStr += "'" + v + "',"
+		}
+	}
+	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
+
+	condition, err = services.HandleActivityLabelSpecialPermission(user)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	total, err := models.GetActivitySpecialCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	//list, errList := models.GetCygxActivitySpecialDetailList(condition, pars, uid, startSize, pageSize)
+	//if errList != nil {
+	//	br.Msg = "获取失败"
+	//	br.ErrMsg = "获取失败,Err:" + errList.Error()
+	//	return
+	//}
+
+	list, errList := services.GetActivityLabelSpecialConfirmList(user, startSize, pageSize, 0)
+	if errList != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + errList.Error()
+		return
+	}
+
+	detail, err := models.GetConfigByCode("city_img_url")
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
+		return
+	}
+	detailChart, err := models.GetConfigByCode("chart_img_url")
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
+		return
+	}
+
+	addressList := strings.Split(detail.ConfigValue, "{|}")
+	mapAddress := make(map[string]string)
+	chartList := strings.Split(detailChart.ConfigValue, "{|}")
+	mapChart := make(map[string]string)
+	var cityName string
+	var chartName string
+	var imgUrl string
+	var imgUrlChart string
+	for _, v := range addressList {
+		vslice := strings.Split(v, "_")
+		cityName = vslice[0]
+		imgUrl = vslice[len(vslice)-1]
+		mapAddress[cityName] = imgUrl
+	}
+	for _, v := range chartList {
+		vslice := strings.Split(v, "_")
+		chartName = vslice[0]
+		imgUrlChart = vslice[len(vslice)-1]
+		mapChart[chartName] = imgUrlChart
+	}
+	for k, v := range list {
+		//list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
+		if mapChart[v.ChartPermissionName] != "" {
+			list[k].ImgUrl = mapChart[v.ChartPermissionName]
+		}
+		list[k].ActivityTypeName = "专项调研"
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.GetCygxActivitySpecialDetailListResp)
+	count, err := models.GetCygxUserFollowSpecial(user.UserId)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+		return
+	}
+	if count == 1 && user.UserId > 0 {
+		resp.IsFollow = true
+	}
+	if user.Mobile != "" {
+		resp.IsBindingMobile = true
+	}
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+
+}

+ 1 - 0
controllers/report.go

@@ -1219,6 +1219,7 @@ func (this *ReportController) IsShow() {
 	resp.IsShowChart = true
 	resp.IsShowResearch = true
 	resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
+	resp.ActivitySpecialExplain = utils.ACTIVITY_SPECIAL_EXPLAIN
 	resp.YanXuan_Explain = true
 	resp.IsShowFreeButton = IsShowFreeButton
 	mobile := user.Mobile

+ 1 - 0
models/activity.go

@@ -747,6 +747,7 @@ type CygxActivitySpecialDetail struct {
 	IndustrialSubjectName string `description:"标的名称(相关公司)"`
 	Scale                 string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
 	CustomerTypeIds       string `description:"活动可见的客户类型,多个ID用 , 隔开"`
+	IsTrip                int    `description:"是否报名 1是 ,0 否"`
 }
 
 type GetCygxActivitySpecialDetailListResp struct {

+ 31 - 0
models/activity_special_trip.go

@@ -0,0 +1,31 @@
+package models
+
+import (
+	//"hongze/hongze_admin/models"
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type CygxActivitySpecialTripResp struct {
+	Id             int    `description:"ID"`
+	UserId         int    `description:"用户id"`
+	ActivityId     int    `description:"活动ID"`
+	CreateTime     string `description:"创建时间"`
+	Mobile         string `description:"手机号"`
+	Email          string `description:"邮箱号"`
+	CompanyId      int    `description:"公司ID"`
+	CompanyName    string `description:"公司名称"`
+	RealName       string `description:"用户实际名称"`
+	SellerName     string `description:"所属销售"`
+	OutboundMobile string `description:"外呼手机号"`
+	CountryCode    string `description:"手机国家区号"`
+}
+
+func GetCygxActivitySpecialTripList(condition string, pars []interface{}) (item []*CygxActivitySpecialTripResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+			FROM
+			cygx_activity_special_trip  
+			WHERE 1 = 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+	return
+}

+ 9 - 8
models/report.go

@@ -226,14 +226,15 @@ func GetWhichDepartmentCount(condition string) (count int, err error) {
 }
 
 type IsShow struct {
-	IsShow           bool      `description:"绝密内参按钮是否展示"`
-	IsShowFreeButton bool      `description:"免费送月卡按钮是否展示"`
-	IsShowResearch   bool      `description:"研选是否展示限免"`
-	IsShowChart      bool      `description:"图表是否展示限免"`
-	IsShowList       bool      `description:"榜单是否展示"`
-	LinkWxExplain    string    `description:"关注微信公众号链接说明地址"`
-	YanXuan_Explain  bool      `description:"研选说明"`
-	SearchTxtList    SearchTxt `description:"搜索栏回显内容说明"`
+	IsShow                 bool      `description:"绝密内参按钮是否展示"`
+	IsShowFreeButton       bool      `description:"免费送月卡按钮是否展示"`
+	IsShowResearch         bool      `description:"研选是否展示限免"`
+	IsShowChart            bool      `description:"图表是否展示限免"`
+	IsShowList             bool      `description:"榜单是否展示"`
+	LinkWxExplain          string    `description:"关注微信公众号链接说明地址"`
+	YanXuan_Explain        bool      `description:"研选说明"`
+	ActivitySpecialExplain string    `description:"专项调研活动"`
+	SearchTxtList          SearchTxt `description:"搜索栏回显内容说明"`
 }
 
 type SearchTxt struct {

+ 9 - 0
routers/commentsRouter.go

@@ -223,6 +223,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"],
+        beego.ControllerComments{
+            Method: "SpecialList",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:AdviceController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:AdviceController"],
         beego.ControllerComments{
             Method: "ApplyApprove",

+ 5 - 0
routers/router.go

@@ -124,6 +124,11 @@ func init() {
 				&controllers.MicroRoadShowController{},
 			),
 		),
+		web.NSNamespace("/activity_special",
+			web.NSInclude(
+				&controllers.ActivitySpecialCoAntroller{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 64 - 0
services/activity_special.go

@@ -2,10 +2,12 @@ package services
 
 import (
 	"context"
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -106,3 +108,65 @@ func GetActivityLabelSpecialList(userType, isPower int, chartPermissionIds, scal
 	item = itemList
 	return
 }
+
+//HandleActivityLabelSpecialPermission 处理专项产业调研的查询权限sql
+func HandleActivityLabelSpecialPermission(user *models.WxUserItem) (condition string, err error) {
+	userType, permissionStr, err := GetUserType(user.CompanyId)
+	if err != nil {
+		return
+	}
+	slicePer := strings.Split(permissionStr, ",")
+	var permissionSqlStr string
+	for _, v := range slicePer {
+		if userType == 1 {
+			if !strings.Contains(v, "研选") {
+				permissionSqlStr += "'" + v + "',"
+			}
+		} else {
+			permissionSqlStr += "'" + v + "',"
+		}
+	}
+	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
+	condition = ` AND art.publish_status = 1  AND art.label != ''  AND art.is_offline = 0  `
+	condition += ` AND art.chart_permission_name  IN (` + permissionSqlStr + `) `
+	condition += ` AND  art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
+	return
+}
+
+/*
+确定行程的查询  GetActivityLabelSpecialConfirmList
+state 进行状态 1:未开始,2:进行中,3:已结束 不传默认查询全部items []*CygxActivitySpecialDetail
+*/
+func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, pageSize, state int) (list []*models.CygxActivitySpecialDetail, err error) {
+	//var condition string
+	condition, e := HandleActivityLabelSpecialPermission(user)
+	if e != nil {
+		err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
+		return
+	}
+	var pars []interface{}
+	condition += ` AND art.days >0  `
+	if state == 1 {
+		condition += ` AND art.activity_time < ? `
+		pars = append(pars, time.Now())
+	}
+	if state == 2 {
+		condition += ` AND art.activity_time < ? `
+		pars = append(pars, time.Now())
+		condition += ` AND art.activity_time_end > ? `
+		pars = append(pars, time.Now())
+	}
+	if state == 1 {
+		condition += ` AND art.activity_time_end < ? `
+		pars = append(pars, time.Now())
+	}
+	list, e = models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, startSize, pageSize)
+	if e != nil {
+		err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
+		return
+	}
+
+	return
+}

+ 1 - 0
utils/constants.go

@@ -89,6 +89,7 @@ const (
 	ZHI_ZAO_NAME                     string = "智造"
 	ZHI_ZAO_ID                       int    = 19
 	LINK_WX_EXPLAIN                         = "https://mp.weixin.qq.com/s?__biz=Mzg2OTYzODk0Nw==&mid=2247483662&idx=1&sn=3752df99025189b9d77fe658bfc0edbd&chksm=ce98b742f9ef3e54b49986e647dd951a3aad74f323174b252174e0938c264c0562c8ec455106#rd" //用户阅读数据
+	ACTIVITY_SPECIAL_EXPLAIN                = "预报名专项调研行程持续更新中,满10家即开团,欢迎点击感兴趣预报名"                                                                                                                                                                //用户阅读数据
 	HZ_COMPANY_ID                    int    = 16                                                                                                                                                                                                 // 弘则公司的ID
 	HONG_GUAN_NAME                   string = "宏观"
 	HONG_GUAN_ID                     int    = 1