Просмотр исходного кода

Merge branch 'dev' of http://git.ycjcjy.com/SpaceOfCheng/services into dev

wangfei 6 лет назад
Родитель
Сommit
8c7b03863c
5 измененных файлов: 22 добавлений и 13 удалений
  1. 1
    1
      conf/log.conf
  2. 1
    1
      controllers/luckdrawlist/luckdrawlist.go
  3. 2
    2
      routers/common.go
  4. 14
    9
      service/sys.go
  5. 4
    0
      utils/wechat.go

+ 1
- 1
conf/log.conf Просмотреть файл

1
 [common]
1
 [common]
2
-filename="E:\\GoProject\\src\\spaceofcheng\\services\\log\\common.log"
2
+filename="E:\\GoProjects\\src\\spaceofcheng\\services\\log\\common.log"
3
 # log level "emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"
3
 # log level "emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"
4
 level="debug"
4
 level="debug"

+ 1
- 1
controllers/luckdrawlist/luckdrawlist.go Просмотреть файл

83
 func (c *LuckdrawlistController) VerifyLuckdraw() {
83
 func (c *LuckdrawlistController) VerifyLuckdraw() {
84
 	sysUser := c.Context.Get("user").(model.SysUser)
84
 	sysUser := c.Context.Get("user").(model.SysUser)
85
 	userId := sysUser.UserId
85
 	userId := sysUser.UserId
86
-	luckdrawId := c.GetString("luckdrawId")
86
+	luckdrawId := c.GetString(":luckdrawId")
87
 	if luckdrawId == "" {
87
 	if luckdrawId == "" {
88
 		c.ResponseError(errors.New("无效二维码"))
88
 		c.ResponseError(errors.New("无效二维码"))
89
 	}
89
 	}

+ 2
- 2
routers/common.go Просмотреть файл

190
 		//luckdrawlist 抽奖
190
 		//luckdrawlist 抽奖
191
 		beego.NSRouter("luckdrawlist", &luckdrawlist.LuckdrawlistController{}, "get:GetLuckdrawList"),
191
 		beego.NSRouter("luckdrawlist", &luckdrawlist.LuckdrawlistController{}, "get:GetLuckdrawList"),
192
 		beego.NSRouter("luckdrawlist/share", &luckdrawlist.LuckdrawlistController{}, "get:GetLuckShareList"),
192
 		beego.NSRouter("luckdrawlist/share", &luckdrawlist.LuckdrawlistController{}, "get:GetLuckShareList"),
193
-		beego.NSRouter("luckdrawlist/:luckdrawId", &luckdrawlist.LuckdrawlistController{}, "get:GetVerifyList"),
194
-		beego.NSRouter("luckdrawlist/:luckdrawId", &luckdrawlist.LuckdrawlistController{}, "put:VerifyLuckdraw"),
193
+		beego.NSRouter("luckdrawlist/verify/:luckdrawId", &luckdrawlist.LuckdrawlistController{}, "get:GetVerifyList"),
194
+		beego.NSRouter("luckdrawlist/verify/:luckdrawId", &luckdrawlist.LuckdrawlistController{}, "put:VerifyLuckdraw"),
195
 
195
 
196
 		// bodychecklist 体检列表
196
 		// bodychecklist 体检列表
197
 		beego.NSRouter("bodychecklist", &bodychecklist.BodychecklistController{}, "get:GetBodyCheckList"),
197
 		beego.NSRouter("bodychecklist", &bodychecklist.BodychecklistController{}, "get:GetBodyCheckList"),

+ 14
- 9
service/sys.go Просмотреть файл

177
 		// 获取 token
177
 		// 获取 token
178
 		token, err := s.getToken(gctx)
178
 		token, err := s.getToken(gctx)
179
 		if err != nil {
179
 		if err != nil {
180
-			// token 报错一律视为需要重新登录
181
-			return map[string]interface{}{
182
-				"code":  http.StatusUnauthorized,
183
-				"error": err,
184
-				"message": map[string]interface{}{
185
-					"appid": utils.GetWxAppID(s.org.OrgId),
186
-				},
180
+			tokenStr := s.ctx.Get("token").(string)
181
+			if tokenStr != "" {
182
+				// token 报错一律视为需要重新登录
183
+				return map[string]interface{}{
184
+					"code":  http.StatusUnauthorized,
185
+					"error": err,
186
+					"message": map[string]interface{}{
187
+						"appid": utils.GetWxAppID(s.org.OrgId),
188
+					},
189
+				}
187
 			}
190
 			}
188
 		}
191
 		}
189
 
192
 
190
 		// 未登录 或 未验证
193
 		// 未登录 或 未验证
191
-		if token.ID == "" {
194
+		if token == nil || token.ID == "" {
192
 			if code == "" {
195
 			if code == "" {
193
 				return map[string]interface{}{
196
 				return map[string]interface{}{
194
 					"code":  http.StatusUnauthorized,
197
 					"code":  http.StatusUnauthorized,
216
 				}
219
 				}
217
 			}
220
 			}
218
 
221
 
222
+			utils.LogError("获取到微信人员: ", wxUser)
223
+
219
 			openID = wxUser.OpenID
224
 			openID = wxUser.OpenID
220
 		} else {
225
 		} else {
221
 			openID = token.ID
226
 			openID = token.ID
242
 	// 如果尚无人员映射信息, 代表人员初次使用本系统
247
 	// 如果尚无人员映射信息, 代表人员初次使用本系统
243
 	if userMapping == nil {
248
 	if userMapping == nil {
244
 		// 如果没有微信用户信息, 代表产生了未知异常
249
 		// 如果没有微信用户信息, 代表产生了未知异常
245
-		if wxUser == nil || wxUser.UnionID == "" {
250
+		if wxUser == nil || wxUser.OpenID == "" {
246
 			return map[string]interface{}{
251
 			return map[string]interface{}{
247
 				"code":  http.StatusInternalServerError,
252
 				"code":  http.StatusInternalServerError,
248
 				"error": errors.New("系统异常, 请清空缓存后重试"),
253
 				"error": errors.New("系统异常, 请清空缓存后重试"),

+ 4
- 0
utils/wechat.go Просмотреть файл

87
 		user.Sex = data["sex"].(float64)
87
 		user.Sex = data["sex"].(float64)
88
 	}
88
 	}
89
 
89
 
90
+	if data["nickname"] != nil {
91
+		user.NickName = data["nickname"].(string)
92
+	}
93
+
90
 	if data["province"] != nil {
94
 	if data["province"] != nil {
91
 		user.Province = data["province"].(string)
95
 		user.Province = data["province"].(string)
92
 	}
96
 	}