Browse Source

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

胡轶钦 6 years ago
parent
commit
992a11725c
5 changed files with 64 additions and 26 deletions
  1. 4
    16
      controllers/luckdraw/luckdraw.go
  2. 48
    0
      log/common.log
  3. 8
    7
      routers/wechat.go
  4. 3
    2
      service/coupon/coupon.go
  5. 1
    1
      service/message/news.go

+ 4
- 16
controllers/luckdraw/luckdraw.go View File

1
 package luckdraw
1
 package luckdraw
2
 
2
 
3
 import (
3
 import (
4
-	"cdkj-check/helper"
5
 	"errors"
4
 	"errors"
6
 	"net/http"
5
 	"net/http"
7
 	"spaceofcheng/services/controllers"
6
 	"spaceofcheng/services/controllers"
8
 	"spaceofcheng/services/models/model"
7
 	"spaceofcheng/services/models/model"
9
 	"spaceofcheng/services/service/luckdraw"
8
 	"spaceofcheng/services/service/luckdraw"
10
 	"spaceofcheng/services/utils"
9
 	"spaceofcheng/services/utils"
11
-	"strconv"
12
 )
10
 )
13
 
11
 
14
 // LuckdrawController 应用
12
 // LuckdrawController 应用
27
 
25
 
28
 // GetUserByCode 根据code获取用户信息
26
 // GetUserByCode 根据code获取用户信息
29
 func (c *LuckDrawController) GetUserByCode() {
27
 func (c *LuckDrawController) GetUserByCode() {
30
-	custID := 0
31
-	encodeUser, _ := c.GetInt("from")
32
-	if encodeUser != 0 {
33
-		encodeUser = helper.IntXOR(encodeUser, 97)
34
-		enStr := strconv.Itoa(encodeUser)
35
-		enStr = enStr[:len(enStr)-3]
36
-
37
-		custID, _ = strconv.Atoi(enStr)
38
-	}
39
-
40
 	userRaw := c.Context.Get("customer")
28
 	userRaw := c.Context.Get("customer")
41
 	if userRaw == nil {
29
 	if userRaw == nil {
42
 		c.ResponseError(errors.New("系统内部错误"), http.StatusInternalServerError)
30
 		c.ResponseError(errors.New("系统内部错误"), http.StatusInternalServerError)
43
 	}
31
 	}
44
 
32
 
45
 	user := userRaw.(model.TaCustomer)
33
 	user := userRaw.(model.TaCustomer)
46
-	luckdrawid, _ := c.GetInt("luckdrawid")
34
+	luckdrawid := c.GetString(":id")
47
 	record, err := c.dao.GetUserLuckDrawByLuckDraw(user.Id, luckdrawid)
35
 	record, err := c.dao.GetUserLuckDrawByLuckDraw(user.Id, luckdrawid)
48
 	if err != nil {
36
 	if err != nil {
49
 		utils.LogError("获取用户抽奖信息失败: " + err.Error())
37
 		utils.LogError("获取用户抽奖信息失败: " + err.Error())
67
 
55
 
68
 // GetLuckDraw 获取抽奖信息
56
 // GetLuckDraw 获取抽奖信息
69
 func (c *LuckDrawController) GetLuckDraw() {
57
 func (c *LuckDrawController) GetLuckDraw() {
70
-	id, _ := c.GetInt(":id")
58
+	id := c.GetString(":id")
71
 	luckdraw, err := c.dao.GetLuckDraw(id)
59
 	luckdraw, err := c.dao.GetLuckDraw(id)
72
 	if err != nil {
60
 	if err != nil {
73
 		utils.LogError("获取抽奖信息失败: " + err.Error())
61
 		utils.LogError("获取抽奖信息失败: " + err.Error())
78
 
66
 
79
 // LuckDraw 抽奖
67
 // LuckDraw 抽奖
80
 func (c *LuckDrawController) LuckDraw() {
68
 func (c *LuckDrawController) LuckDraw() {
81
-	id, _ := c.GetInt(":id")
69
+	id := c.GetString(":id")
82
 	userRaw := c.Context.Get("customer")
70
 	userRaw := c.Context.Get("customer")
83
 	if userRaw == nil {
71
 	if userRaw == nil {
84
 		c.ResponseError(errors.New("系统内部错误"), http.StatusInternalServerError)
72
 		c.ResponseError(errors.New("系统内部错误"), http.StatusInternalServerError)
120
 
108
 
121
 // GetRecordByID 根据ID获取中奖记录信息
109
 // GetRecordByID 根据ID获取中奖记录信息
122
 func (c *LuckDrawController) GetRecordByID() {
110
 func (c *LuckDrawController) GetRecordByID() {
123
-	id, _ := c.GetInt(":id")
111
+	id := c.GetString(":id")
124
 	record, err := c.dao.GetRecordByID(id)
112
 	record, err := c.dao.GetRecordByID(id)
125
 	if err != nil {
113
 	if err != nil {
126
 		utils.LogError("获取中奖记录失败: " + err.Error())
114
 		utils.LogError("获取中奖记录失败: " + err.Error())

+ 48
- 0
log/common.log View File

142
 2018/09/21 03:22:13 [E] 用户没有设置默认案场
142
 2018/09/21 03:22:13 [E] 用户没有设置默认案场
143
 2018/09/21 03:22:13 [E] 用户没有设置默认案场
143
 2018/09/21 03:22:13 [E] 用户没有设置默认案场
144
 2018/09/21 03:22:16 [E] 用户没有设置默认案场
144
 2018/09/21 03:22:16 [E] 用户没有设置默认案场
145
+2018/09/25 09:32:27 [E] 用户没有设置默认案场
146
+2018/09/25 09:32:27 [E] 用户没有设置默认案场
147
+2018/09/25 09:32:27 [E] 统计会员总数失败: Error 1370: execute command denied to user 'spaceofcheng'@'localhost' for routine 'cdkj.fun_total_customer'
148
+2018/09/25 09:32:28 [E] 用户没有设置默认案场
149
+2018/09/25 09:59:43 [E] 用户没有设置默认案场
150
+2018/09/25 09:59:43 [E] 用户没有设置默认案场
151
+2018/09/25 09:59:43 [E] 统计会员总数失败: Error 1370: execute command denied to user 'spaceofcheng'@'localhost' for routine 'cdkj.fun_total_customer'
152
+2018/09/25 09:59:43 [E] 用户没有设置默认案场
153
+2018/09/25 10:00:36 [E] 用户没有设置默认案场
154
+2018/09/25 10:00:53 [E] 用户没有设置默认案场
155
+2018/09/25 10:00:53 [E] 用户没有设置默认案场
156
+2018/09/25 10:01:04 [E] 用户没有设置默认案场
157
+2018/09/25 10:01:12 [E] 用户没有设置默认案场
158
+2018/09/25 10:01:34 [E] 用户没有设置默认案场
159
+2018/09/25 10:01:36 [E] 用户没有设置默认案场
160
+2018/09/25 10:01:37 [E] 用户没有设置默认案场
161
+2018/09/25 10:01:38 [E] 用户没有设置默认案场
162
+2018/09/25 10:01:39 [E] 用户没有设置默认案场
163
+2018/09/25 10:01:40 [E] 用户没有设置默认案场
164
+2018/09/25 10:01:41 [E] 用户没有设置默认案场
165
+2018/09/25 10:02:06 [E] 用户没有设置默认案场
166
+2018/09/25 10:02:07 [E] 用户没有设置默认案场
167
+2018/09/25 10:33:31 [E] 用户没有设置默认案场
168
+2018/09/25 10:33:31 [E] 用户没有设置默认案场
169
+2018/09/25 10:34:18 [E] 用户没有设置默认案场
170
+2018/09/25 10:34:18 [E] 用户没有设置默认案场
171
+2018/09/25 10:34:18 [E] 用户没有设置默认案场
172
+2018/09/25 10:34:19 [E] 用户没有设置默认案场
173
+2018/09/25 10:34:20 [E] 用户没有设置默认案场
174
+2018/09/25 10:34:26 [E] 用户没有设置默认案场
175
+2018/09/25 10:34:34 [E] 用户没有设置默认案场
176
+2018/09/25 10:36:05 [E] 用户没有设置默认案场
177
+2018/09/25 10:36:06 [E] 用户没有设置默认案场
178
+2018/09/25 10:36:12 [E] 用户没有设置默认案场
179
+2018/09/25 10:37:32 [E] 用户没有设置默认案场
180
+2018/09/25 10:37:33 [E] 用户没有设置默认案场
181
+2018/09/25 10:37:34 [E] 用户没有设置默认案场
182
+2018/09/25 10:37:36 [E] 用户没有设置默认案场
183
+2018/09/25 10:39:44 [E] 用户没有设置默认案场
184
+2018/09/25 10:39:45 [E] 用户没有设置默认案场
185
+2018/09/25 10:39:46 [E] 用户没有设置默认案场
186
+2018/09/25 10:49:52 [E] 用户没有设置默认案场
187
+2018/09/25 10:49:56 [E] 用户没有设置默认案场
188
+2018/09/25 10:50:04 [E] 用户没有设置默认案场
189
+2018/09/25 10:52:56 [E] 用户没有设置默认案场
190
+2018/09/25 10:52:58 [E] 用户没有设置默认案场
191
+2018/09/25 10:53:02 [E] 用户没有设置默认案场
192
+2018/09/25 11:03:32 [E] 用户没有设置默认案场

+ 8
- 7
routers/wechat.go View File

1
 package routers
1
 package routers
2
 
2
 
3
 import (
3
 import (
4
+	"cdkj-check/controllers/luckdraw"
4
 	"spaceofcheng/services/controllers/bodycheck"
5
 	"spaceofcheng/services/controllers/bodycheck"
5
 	"spaceofcheng/services/controllers/card"
6
 	"spaceofcheng/services/controllers/card"
6
 	"spaceofcheng/services/controllers/cases"
7
 	"spaceofcheng/services/controllers/cases"
82
 		beego.NSRouter("/case/conf/:caseid", &cases.CaseController{}, "get:GetCaseConf"),
83
 		beego.NSRouter("/case/conf/:caseid", &cases.CaseController{}, "get:GetCaseConf"),
83
 
84
 
84
 		// 抽奖
85
 		// 抽奖
85
-		// beego.NSRouter("/user", &luckdraw.LuckDrawController{}, "get:GetUserByCode"),
86
-		// beego.NSRouter("/luckdraw/:id", &luckdraw.LuckDrawController{}, "get:GetLuckDraw"),
87
-		// beego.NSRouter("/luckdraw/:id", &luckdraw.LuckDrawController{}, "post:LuckDraw"),
88
-		// beego.NSRouter("/luckdraw/:id/share", &luckdraw.LuckDrawController{}, "post:SaveShareRecord"),
89
-		// beego.NSRouter("/record", &luckdraw.LuckDrawController{}, "get:GetRecordByLuckDraw"),
90
-		// beego.NSRouter("/user/record", &luckdraw.LuckDrawController{}, "get:GetUserLuckDraw"),
91
-		// beego.NSRouter("/user/record/:id", &luckdraw.LuckDrawController{}, "get:GetRecordByID"),
86
+		beego.NSRouter("/luckdraw/user/:id", &luckdraw.LuckDrawController{}, "get:GetUserByCode"),
87
+		beego.NSRouter("/luckdraw/:id", &luckdraw.LuckDrawController{}, "get:GetLuckDraw"),
88
+		beego.NSRouter("/luckdraw/:id", &luckdraw.LuckDrawController{}, "post:LuckDraw"),
89
+		beego.NSRouter("/luckdraw/:id/share", &luckdraw.LuckDrawController{}, "post:SaveShareRecord"),
90
+		beego.NSRouter("/luckdraw/record", &luckdraw.LuckDrawController{}, "get:GetRecordByLuckDraw"),
91
+		beego.NSRouter("/user/luckdraw/record", &luckdraw.LuckDrawController{}, "get:GetUserLuckDraw"),
92
+		beego.NSRouter("/user/luckdraw/record/:id", &luckdraw.LuckDrawController{}, "get:GetRecordByID"),
92
 	)
93
 	)
93
 }
94
 }

+ 3
- 2
service/coupon/coupon.go View File

515
 	if coupon.TotalCount <= coupon.SentCount && coupon.IsOver == 0 {
515
 	if coupon.TotalCount <= coupon.SentCount && coupon.IsOver == 0 {
516
 		return errors.New("log-error-优惠券已领完!")
516
 		return errors.New("log-error-优惠券已领完!")
517
 	}
517
 	}
518
-	if coupon.EndDate.Before(time.Now()) {
518
+	if coupon.ValidDays <= 0 && coupon.EndDate.Before(time.Now()) {
519
 		return errors.New("log-error-优惠券已过期")
519
 		return errors.New("log-error-优惠券已过期")
520
 	}
520
 	}
521
 
521
 
606
 	if coupon.TotalCount <= coupon.SentCount && coupon.IsOver == 0 {
606
 	if coupon.TotalCount <= coupon.SentCount && coupon.IsOver == 0 {
607
 		return errors.New("log-error-优惠券已领完!")
607
 		return errors.New("log-error-优惠券已领完!")
608
 	}
608
 	}
609
-	if coupon.EndDate.Before(time.Now()) {
609
+
610
+	if coupon.ValidDays <= 0 && coupon.EndDate.Before(time.Now()) {
610
 		return errors.New("log-error-优惠券已过期")
611
 		return errors.New("log-error-优惠券已过期")
611
 	}
612
 	}
612
 
613
 

+ 1
- 1
service/message/news.go View File

37
 
37
 
38
 // GetNewsByLocation 根据位置id获取咨询信息
38
 // GetNewsByLocation 根据位置id获取咨询信息
39
 func (s *MessageServ) GetNewsByLocation(locationid, orgid string) ([]model.TaCmsNews, error) {
39
 func (s *MessageServ) GetNewsByLocation(locationid, orgid string) ([]model.TaCmsNews, error) {
40
-	news, err := s.dao.GetNewsByLocation(locationid, orgid)
40
+	news, err := s.dao.GetNewsByLocationShow(locationid, orgid)
41
 	if err != nil {
41
 	if err != nil {
42
 		utils.LogError("获取列表失败: " + err.Error())
42
 		utils.LogError("获取列表失败: " + err.Error())
43
 		return nil, errors.New("获取列表失败")
43
 		return nil, errors.New("获取列表失败")