zwxi 10 months ago
parent
commit
1cfa23aa93

+ 98 - 0
controller/public.go

@@ -5,9 +5,11 @@ import (
 	"errors"
 	"fmt"
 	"github.com/gin-gonic/gin"
+	"github.com/skip2/go-qrcode"
 	"hongze/hongze_yb/controller/response"
 	"hongze/hongze_yb/global"
 	"hongze/hongze_yb/logic"
+	userLogic "hongze/hongze_yb/logic/user"
 	"hongze/hongze_yb/models/request"
 	respond "hongze/hongze_yb/models/response"
 	"hongze/hongze_yb/models/tables/banner"
@@ -15,6 +17,7 @@ import (
 	"hongze/hongze_yb/models/tables/company"
 	"hongze/hongze_yb/models/tables/wx_user"
 	"hongze/hongze_yb/models/tables/yb_config"
+	"hongze/hongze_yb/models/tables/yb_research_signup_statistics"
 	"hongze/hongze_yb/models/tables/yb_resource"
 	"hongze/hongze_yb/models/tables/yb_suncode_pars"
 	"hongze/hongze_yb/services"
@@ -503,4 +506,99 @@ func BannerHistoryList(c *gin.Context) {
 	resp.Paging = respond.GetPaging(page, limit, int(total))
 	resp.List = list
 	response.OkData("获取成功", resp, c)
+}
+
+// BannerGetQRCode banner历史图列表
+// @Tags 公共模块
+// @Summary  banner图列表
+// @Description banner图列表
+// @Security ApiKeyAuth
+// @securityDefinitions.basic BasicAuth
+// @Accept  json
+// @Product json
+// @Success 200 {string} string 获取验证码成功
+// @Failure 400 {string} string 请输入邮箱地址
+// @Router /banner/get_qrcode [get]
+func BannerGetQRCode(c *gin.Context) {
+	inviteCode := c.Query("InviteCode")
+	userInfo := user.GetInfoByClaims(c)
+	userDetail, err, errMsg := userLogic.GetUserInfo(userInfo)
+	if err != nil {
+		if errMsg != "" {
+			errMsg = "获取失败"
+		}
+		response.Fail(errMsg, c)
+		return
+	}
+	randStr := utils.GetRandStringNoSpecialChar(28)
+	filePath :=  "./static/" + randStr + ".png"
+	fileName :=  randStr + ".png"
+	url := "pages-report/signUpPage/signUpPage&RealName?%s&CompanyName?%s&Mobile?%sBannerId?%s&InviteCode?%s"
+	url = fmt.Sprintf(url, userDetail.RealName, userDetail.CompanyName, userDetail.Mobile, inviteCode)
+
+	err = qrcode.WriteFile(url, qrcode.Medium, 256, filePath)
+	if err != nil {
+		response.FailData("生成二维码失败", "生成二维码失败,Err:"+err.Error(), c)
+	}
+
+	defer func() {
+		os.Remove(filePath)
+	}()
+
+	//上传到阿里云
+	resourceUrl, err := services.UploadAliyun(fileName, filePath)
+	if err != nil {
+		response.FailData("文件上传失败", "文件上传失败,Err:"+err.Error(), c)
+		return
+	}
+	response.OkData("获取成功", resourceUrl, c)
+}
+
+
+// ResearchSignUp 报名
+// @Tags 公共模块
+// @Summary  banner图列表
+// @Description banner图列表
+// @Security ApiKeyAuth
+// @securityDefinitions.basic BasicAuth
+// @Accept  json
+// @Product json
+// @Success 200 {string} string 获取验证码成功
+// @Failure 400 {string} string 请输入邮箱地址
+// @Router /banner/signup [get]
+func ResearchSignUp(c *gin.Context) {
+	//inviteCode := c.Query("InviteCode")
+	realName := c.Query("RealName")
+	companyName := c.Query("CompanyName")
+	mobile := c.Query("Mobile")
+	bannerId,_ := strconv.Atoi(c.Query("BannerId"))
+	customName := c.Query("CustomName")
+	customMobile := c.Query("CustomMobile")
+	customCompanyName := c.Query("CustomCompanyName")
+	//userInfo := user.GetInfoByClaims(c)
+	//userDetail, err, errMsg := userLogic.GetUserInfo(userInfo)
+	//if err != nil {
+	//	if errMsg != "" {
+	//		errMsg = "获取失败"
+	//	}
+	//	response.Fail(errMsg, c)
+	//	return
+	//}
+	ob := &yb_research_signup_statistics.YbResearchSignupStatistics{
+		Mobile:                       mobile,
+		CustomCompanyName:            customCompanyName,
+		CompanyName:                  companyName,
+		BannerId:                     bannerId,
+		CustomName:                   customName,
+		RealName:                     realName,
+		CustomMobile:                 customMobile,
+		CreateTime:                   time.Now(),
+	}
+	err := ob.Create()
+	if err != nil {
+		response.FailData("报名失败", "报名失败,Err:"+err.Error(), c)
+		return
+	}
+
+	response.Ok("报名成功", c)
 }

+ 2 - 1
go.mod

@@ -1,6 +1,6 @@
 module hongze/hongze_yb
 
-go 1.19
+go 1.21.7
 
 require (
 	github.com/PuerkitoBio/goquery v1.8.0
@@ -18,6 +18,7 @@ require (
 	github.com/rdlucklib/rdluck_tools v1.0.3
 	github.com/shopspring/decimal v1.3.1
 	github.com/silenceper/wechat/v2 v2.1.4
+	github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
 	github.com/spf13/viper v1.14.0
 	github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a
 	github.com/swaggo/gin-swagger v1.5.3

+ 6 - 0
go.sum

@@ -104,7 +104,9 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
 github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
 github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
 github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
+github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
 github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
+github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
 github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
 github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
@@ -214,6 +216,7 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
 github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
+github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
 github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
@@ -383,6 +386,8 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
 github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
 github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
+github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
+github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
 github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
 github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw=
@@ -409,6 +414,7 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
 github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
 github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
+github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
 github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs=
 github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
 github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a h1:kAe4YSu0O0UFn1DowNo2MY5p6xzqtJ/wQ7LZynSvGaY=

+ 23 - 0
models/tables/yb_research_signup_statistics/entity.go

@@ -0,0 +1,23 @@
+package yb_research_signup_statistics
+
+import "time"
+
+// YbResearchSignupStatistics 调研报名统计结构体
+type YbResearchSignupStatistics struct {
+	YbResearchSignupStatisticsId int     `json:"yb_research_signup_statistics_id"` // 自动生成的主键ID
+	UserId                       int     `json:"user_id"`                            // 分享人ID
+	RealName                     string  `json:"real_name"`                         // 分享人姓名
+	Mobile                       string  `json:"mobile"`                            // 分享人手机号
+	CompanyName                  string  `json:"company_name"`                      // 公司名称
+	BannerId                     int     `json:"banner_id"`                          // 活动ID
+	CreateTime                   time.Time `json:"create_time"`                     // 创建时间
+	Amount                       float64 `json:"amount"`                            // 付款金额
+	CustomName                   string  `json:"custom_name"`                       // 报名人姓名
+	CustomMobile                 string  `json:"custom_mobile"`                      // 报名人手机号
+	CustomCompanyName            string  `json:"custom_company_name"`               // 报名人公司名称
+}
+
+
+func (m *YbResearchSignupStatistics) TableName() string {
+	return "yb_research_signup_statistics"
+}

+ 9 - 0
models/tables/yb_research_signup_statistics/model.go

@@ -0,0 +1,9 @@
+package yb_research_signup_statistics
+
+import "hongze/hongze_yb/global"
+
+func (m *YbResearchSignupStatistics) Create() (err error) {
+	err = global.DEFAULT_MYSQL.Create(m).Error
+	return
+}
+

+ 2 - 0
routers/public.go

@@ -31,6 +31,8 @@ func initPublic(r *gin.Engine) {
 		rGroup.POST("/banner/mark", controller.BannerMark)
 		rGroup.GET("/banner/list", controller.BannerList)
 		rGroup.GET("/banner_history/list", controller.BannerHistoryList)
+		rGroup.GET("/banner/get_qrcode", controller.BannerGetQRCode)
+		rGroup.GET("/banner/signup", controller.ResearchSignUp)
 	}
 
 	rGroup2 := r.Group("api/public")

+ 16 - 0
services/qr_code.go

@@ -0,0 +1,16 @@
+package services
+
+import (
+	"fmt"
+	"github.com/skip2/go-qrcode"
+	"log"
+)
+
+func GetQRCode() {
+	err := qrcode.WriteFile("https://www.baidu.com", qrcode.Medium, 256, "./static/qrcode.png")
+	if err != nil {
+		log.Fatal(err)
+	}
+	log.Println("二维码生成成功")
+	fmt.Println("ok")
+}