xingzai 1 rok pred
rodič
commit
0d2c0cafc9

+ 62 - 34
controllers/yidong.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"hongze/hongze_open_api/models/request/yidong"
+	"hongze/hongze_open_api/models/tables/company_product"
 	cygxActivity "hongze/hongze_open_api/models/tables/cygx_activity"
 	"hongze/hongze_open_api/services/alarm_msg"
 	servicesYidong "hongze/hongze_open_api/services/yidong"
@@ -52,8 +53,6 @@ func (c *YiDongController) ActivityExamine() {
 	//校验 签名
 
 	signStr := servicesYidong.GetSign(activityIdYiDong, timeInt)
-	fmt.Println("____")
-	fmt.Println(signStr)
 	ownSign := req.Sign
 	if ownSign != signStr {
 		c.FailWithMessage("签名错误!")
@@ -264,38 +263,6 @@ func (c *YiDongController) ActivityExamine() {
 	c.OkWithMessage("操作成功")
 }
 
-func init2342() {
-	//allow 59.46.229.165;
-	//allow 123.185.222.0/24;
-	//allow 123.185.223.0/24;
-	//allow 59.36.22.17;
-	//allow 120.86.187.82;
-	//202.105.122.162
-
-	//	@张怀民 您好,不好意思,刚才发错了,我们这边生产IP是个地址池,
-	//生产:
-	//	49.4.0.0/16
-	//	119.3.0.0/16
-	//	117.78.0.0/16
-	//	43.254.0.0/16
-	//allow 59.36.22.17;
-	//allow 120.86.187.82;
-	//测试:
-	//	121.36.45.174
-	//	麻烦帮忙配置一下白名单
-
-	var ipstr string
-	var ipstrs string
-	ipstr = "43.254.0.0."
-
-	for i := 0; i <= 16; i++ {
-		fmt.Println(i)
-		ipstrs += ipstr + strconv.Itoa(i) + ","
-		//ipstr += ipstr + strconv.Itoa(i)
-	}
-	fmt.Println(ipstrs)
-}
-
 // YiDongController
 // @Title 易董提交报名时,获取用户信息接口
 // @Description 易董提交报名时,获取用户信息接口
@@ -374,3 +341,64 @@ func (c *YiDongController) UserSignup() {
 	}
 	c.OkDetailed(userInfo, "获取成功")
 }
+
+// YiDongController
+// @Title 校验用户是否有对应权限
+// @Description 校验用户是否有对应权限接口
+// @Param	request	body yidong.ActivityExamineReq true "type json string"
+// @Success 200 创建成功
+// @router /activity/user/check [post]
+func (c *YiDongController) UserCheck() {
+	var req yidong.ActivitySignUpReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		c.FailWithMessage("参数解析异常")
+		return
+	}
+	activityIdYiDong := req.ActivityId
+	timeInt := req.Time
+	appid := req.Appid
+	mobile := req.Mobile
+	timeUnix := time.Now().Unix() //当前格林威治时间,int64类型
+	timestamp := int64(timeInt)
+	if math.Abs(float64(timeUnix-timestamp)) > 600 {
+		c.FailWithMessage("当前时间异常,请调整设备时间与北京时间一致:" + strconv.Itoa(timeInt))
+		return
+	}
+	//校验 APPID 与ip白名单
+	ip := c.Ctx.Input.IP()
+	err = servicesYidong.CheckAppidAndIp(appid, ip)
+	if err != nil {
+		c.FailWithMessage(err.Error())
+		return
+	}
+	signStr := servicesYidong.GetSign(activityIdYiDong, timeInt)
+	ownSign := req.Sign
+	if ownSign != signStr {
+		c.FailWithMessage("签名错误!")
+		return
+	}
+	_, err = cygxActivity.GetAddActivityInfoById(activityIdYiDong)
+	if err != nil {
+		c.FailWithMessage("会议id异常:" + activityIdYiDong)
+		return
+	}
+	var dateTxt = []byte(mobile)
+	resultDe := utils.DesBase64Decrypt(dateTxt)
+	deMobile := string(resultDe)
+	if deMobile == "" {
+		go alarm_msg.SendAlarmMsg("加密手机号解密失败:"+mobile, 3)
+		c.FailWithMessage("加密手机号解密失败:" + mobile)
+		return
+	}
+	resp := new(yidong.CheckHaspermissionResp)
+	total, err := company_product.CheckUserAaiPerssionByMobile(deMobile)
+	if err != nil {
+		c.FailWithMessage("校验失败!" + err.Error())
+		return
+	}
+	if total > 0 {
+		resp.Haspermission = true
+	}
+	c.OkDetailed(resp, "获取成功")
+}

+ 5 - 0
models/request/yidong/yidong.go

@@ -23,3 +23,8 @@ type ActivitySignUpReq struct {
 	Appid      string `description:"开放平台给分配的appid" json:"appid"`
 	Sign       string `description:"签名" json:"sign"`
 }
+
+// CheckHaspermissionResp 用户是否有权益报名权限
+type CheckHaspermissionResp struct {
+	Haspermission bool `description:"是否有权限" json:"haspermission"`
+}

+ 17 - 0
models/tables/company_product/company_product.go

@@ -60,3 +60,20 @@ func GetCompanyProductByCompanyIdAndProductId(companyId, productId int) (item *C
 	err = o.Raw(sql, companyId, productId).QueryRow(&item)
 	return
 }
+
+// CheckUserAaiPerssionByMobile 校验手机号是否有对应的权益权限
+func CheckUserAaiPerssionByMobile(mobile string) (count int, err error) {
+	sql := `SELECT
+			COUNT( 1 ) AS count 
+		FROM
+			wx_user AS u
+			INNER JOIN company_product AS p ON p.company_id = u.company_id 
+		WHERE
+			1 = 1 
+			AND u.mobile = ? 
+			AND p.STATUS IN ( '正式', '试用', '永续' ) 
+			AND p.product_id = 2`
+	o := orm.NewOrm()
+	err = o.Raw(sql, mobile).QueryRow(&count)
+	return
+}

+ 10 - 10
models/tables/cygx_activity/cygx_activity.go

@@ -5,7 +5,7 @@ import (
 	"time"
 )
 
-//活动详情
+// 活动详情
 type CygxActivity struct {
 	ActivityId           int       `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
 	ActivityTypeId       int       `description:"活动类型id"`
@@ -83,7 +83,7 @@ type CygxYidongActivityExamineStatus struct {
 	YidongExamineStatus int       `description:"易董活动报名审核状态0审核中,1:审核通过、2审核不通过"`
 }
 
-//通过纪要ID获取活动详情
+// 通过ID获取活动详情
 func GetAddActivityInfoById(activityIdYiDong string) (item *CygxActivity, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -91,8 +91,8 @@ func GetAddActivityInfoById(activityIdYiDong string) (item *CygxActivity, err er
 		FROM
 			cygx_activity  as a
 		WHERE
-			yidong_activity_id =?`
-	err = o.Raw(sql, activityIdYiDong).QueryRow(&item)
+			yidong_activity_id =? OR yidong_activity_id_by_cygx = ?  LIMIT 1 `
+	err = o.Raw(sql, activityIdYiDong, activityIdYiDong).QueryRow(&item)
 	return
 }
 
@@ -134,7 +134,7 @@ func AddActivitySignupNumMulti(items []*CygxActivitySignup) (err error) {
 	return
 }
 
-//GetActivitySignupListByActivity获取已经报名了的用户列表
+// GetActivitySignupListByActivity获取已经报名了的用户列表
 func GetActivitySignupListByActivity(activityId int) (items []*CygxActivitySignup, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_activity_signup WHERE activity_id = ?`
@@ -188,7 +188,7 @@ type CygxYidongActivitySignupReq struct {
 	Job         string `description:"职务" json:"job"`
 }
 
-//通过纪要ID获取活动详情
+// 通过纪要ID获取活动详情
 func GetAddActivityInfoByMobile(mobile string) (item *CygxYidongActivitySignupReq, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT u.*, c.company_name FROM wx_user AS u
@@ -208,7 +208,7 @@ func AddActivityItemsLogNumMulti(items []*CygxYidongActivityExamineStatus) (err
 	return
 }
 
-//我的日程
+// 我的日程
 type CygxMySchedule struct {
 	Id          int       `orm:"column(id);pk"`
 	ActivityId  int       `description:"活动ID"`
@@ -220,7 +220,7 @@ type CygxMySchedule struct {
 	CompanyName string    `description:"公司名称"`
 }
 
-//GetCygxMyScheduleList 获取我的日程数据
+// GetCygxMyScheduleList 获取我的日程数据
 func GetCygxMyScheduleList(activityId int) (items []*CygxMySchedule, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_my_schedule WHERE activity_id = ?`
@@ -238,7 +238,7 @@ func AddCygxMyScheduleLNumMulti(items []*CygxMySchedule) (err error) {
 	return
 }
 
-//DelCygxMyScheduleList 删除我的日程
+// DelCygxMyScheduleList 删除我的日程
 func DelCygxMyScheduleList(mobile string, activityId int) (err error) {
 	o := orm.NewOrm()
 	sql := ` DELETE  FROM cygx_my_schedule   WHERE mobile IN (` + mobile + `)  AND activity_id=?`
@@ -246,7 +246,7 @@ func DelCygxMyScheduleList(mobile string, activityId int) (err error) {
 	return
 }
 
-//DelCygxcActivitySignup 删除我的报名信息
+// DelCygxcActivitySignup 删除我的报名信息
 func DelCygxcActivitySignup(mobile string, activityId int) (err error) {
 	o := orm.NewOrm()
 	sql := ` DELETE  FROM cygx_activity_signup   WHERE mobile IN (` + mobile + `)  AND activity_id=?`

+ 9 - 0
routers/commentsRouter.go

@@ -178,6 +178,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:YiDongController"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:YiDongController"],
+        beego.ControllerComments{
+            Method: "UserCheck",
+            Router: `/activity/user/check`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:YiDongController"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:YiDongController"],
         beego.ControllerComments{
             Method: "UserSignup",