|
@@ -8,6 +8,7 @@ import (
|
|
|
"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,13 +16,16 @@ 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"
|
|
|
"hongze/hongze_yb/services/alarm_msg"
|
|
|
"hongze/hongze_yb/services/user"
|
|
|
+ "hongze/hongze_yb/services/wx_app"
|
|
|
"hongze/hongze_yb/utils"
|
|
|
"io/ioutil"
|
|
|
+ "net/url"
|
|
|
"os"
|
|
|
"path"
|
|
|
"strconv"
|
|
@@ -503,4 +507,136 @@ 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) {
|
|
|
+ userId, _ := strconv.Atoi(c.Query("UserId"))
|
|
|
+ bannerId, _ := strconv.Atoi(c.Query("BannerId"))
|
|
|
+ remark := c.Query("Remark")
|
|
|
+ wxUserInfo, err := wx_user.GetByUserId(userId)
|
|
|
+ if err != nil {
|
|
|
+ response.Ok(err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ companyInfo, tmpErr := company.GetByCompanyId(wxUserInfo.CompanyID)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ if tmpErr == utils.ErrNoRow {
|
|
|
+ response.Fail(err.Error(), c)
|
|
|
+ err = errors.New("找不到该客户")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.Fail(err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ companyName := companyInfo.CompanyName
|
|
|
+
|
|
|
+ companyNameCode := url.QueryEscape(companyName) // 进行URL编码
|
|
|
+ remarkCode := url.QueryEscape(remark) // 进行URL编码
|
|
|
+ url := "pages-report/signUpPage/signUpPage?RealName=%s&CompanyName=%s&Mobile=%s&BannerId=%d&Title=%s"
|
|
|
+ url = fmt.Sprintf(url, wxUserInfo.RealName, companyNameCode, wxUserInfo.Mobile, bannerId, remarkCode)
|
|
|
+
|
|
|
+ picByte, err := wx_app.GetSunCodeV2(url)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 生成图片
|
|
|
+ localPath := "./static/img"
|
|
|
+ fileName := utils.GetRandStringNoSpecialChar(28) + ".png"
|
|
|
+ fpath := fmt.Sprint(localPath, "/", fileName)
|
|
|
+ f, err := os.Create(fpath)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if _, err = f.Write(picByte); err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ f.Close()
|
|
|
+ os.Remove(fpath)
|
|
|
+ }()
|
|
|
+ //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, fpath)
|
|
|
+ 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
|
|
|
+ //}
|
|
|
+ count, err := yb_research_signup_statistics.GetSignUpCountByMobileAndBannerId(customMobile, bannerId)
|
|
|
+ if err != nil {
|
|
|
+ response.FailData("查询失败", "查询失败,Err:"+err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if count > 0 {
|
|
|
+ response.FailData("该手机号已报名!", "该手机号已报名", 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)
|
|
|
+}
|