Browse Source

2.1.0 bug fix

胡轶钦 6 years ago
parent
commit
6e9a7fd907

+ 8
- 1
controllers/flashbuy/flashbuy.go View File

@@ -3,6 +3,7 @@ package flashbuy
3 3
 import (
4 4
 	"encoding/json"
5 5
 	"errors"
6
+	"net/http"
6 7
 	"spaceofcheng/services/controllers"
7 8
 	"spaceofcheng/services/models/model"
8 9
 	"spaceofcheng/services/service/flashbuy"
@@ -39,7 +40,13 @@ func (c *FlashBuyController) GetFlashBuyList() {
39 40
 }
40 41
 
41 42
 func (c *FlashBuyController) GetCustomerFlashBuyByCustomerId() {
42
-	customerId := c.GetString(":customerId")
43
+	userRaw := c.Context.Get("customer")
44
+	if userRaw == nil {
45
+		c.ResponseError(errors.New("系统内部错误"), http.StatusInternalServerError)
46
+	}
47
+
48
+	user := userRaw.(model.TaCustomer)
49
+	customerId := user.CustomerId
43 50
 	page, _ := c.GetInt("page")
44 51
 	pageSize, _ := c.GetInt("pagesize")
45 52
 	list, err := c.dao.GetCustomerFlashBuyByCustomerId(customerId, page, pageSize)

+ 9
- 0
controllers/user/user.go View File

@@ -314,3 +314,12 @@ func (c *UserController) GetCaseUserByID() {
314 314
 	}
315 315
 	c.ResponseJSON(userdetail)
316 316
 }
317
+
318
+func (c *UserController) GetMyRecommendCode() {
319
+	user := c.Context.Get("user").(model.SysUser)
320
+	if user.UserId == "" {
321
+		utils.LogError("获取人员推荐码失败")
322
+		c.ResponseError(errors.New("获取人员推荐码失败"))
323
+	}
324
+	c.ResponseJSON(user.RecommendCode)
325
+}

+ 6
- 3
models/flashbuy/flashbuy.go View File

@@ -45,6 +45,7 @@ type CustomerFlashResult struct {
45 45
 type CustomerFlashDetail struct {
46 46
 	model.TaCustomerFlashBuy `xorm:"extends"`
47 47
 	CustomerQrcode           string
48
+	CaseName                 string
48 49
 }
49 50
 
50 51
 func (m *FlashbuyDAO) GetFlashBuyList(caseid, flashBuyName, flashBuyStatus string, page, pageSize int) ([]FlashBuy, error) {
@@ -251,16 +252,18 @@ func (m *FlashbuyDAO) GetCustomerFlashBuyByCustomerIdCount(customerId string) (i
251 252
 }
252 253
 
253 254
 func (m *FlashbuyDAO) GetCustomerFlashBuyId(customerFlashBuyId string) (*CustomerFlashDetail, error) {
254
-	var customerDetail CustomerFlashDetail
255
+	var customerDetail []CustomerFlashDetail
255 256
 	sql := `SELECT
256 257
 	a.*,
257
-	b.customer_qrcode 
258
+	b.customer_qrcode,
259
+	c.case_name
258 260
 FROM
259 261
 	ta_customer_flash_buy a
260 262
 	INNER JOIN ta_customer_course_qrcode b ON a.customer_flash_buy_id = b.customer_course_id
263
+	INNER JOIN sys_case c ON a.case_id = c.case_id
261 264
 	WHERE a.customer_flash_buy_id = '` + customerFlashBuyId + `'`
262 265
 	err := m.db.Sql(sql).Find(&customerDetail)
263
-	return &customerDetail, err
266
+	return &customerDetail[0], err
264 267
 
265 268
 }
266 269
 

+ 2
- 1
routers/wechat.go View File

@@ -62,6 +62,7 @@ func getWechatRoutes(prefix string) beego.LinkNamespace {
62 62
 		// 用户
63 63
 		beego.NSRouter("/user/:type", &user.UserController{}, "get:GetCaseUserByType"),
64 64
 		beego.NSRouter("/user/detail/:id", &user.UserController{}, "get:GetCaseUserByID"),
65
+		beego.NSRouter("/user/code", &user.UserController{}, "get:GetMyRecommendCode"),
65 66
 
66 67
 		// 优惠券
67 68
 		beego.NSRouter("/coupon", &coupon.CouponController{}, "get:GetCaseUsableCoupon"),
@@ -97,7 +98,7 @@ func getWechatRoutes(prefix string) beego.LinkNamespace {
97 98
 
98 99
 		// 抢购
99 100
 		beego.NSRouter("/flashbuy/flash/:flashBuyId", &flashbuy.FlashBuyController{}, "get:GetFlashBuyById"),
100
-		beego.NSRouter("/flashbuy/customer/:customerId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyByCustomerId"),
101
+		beego.NSRouter("/flashbuy/customer", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyByCustomerId"),
101 102
 		beego.NSRouter("/flashbuy/customerFlash/:customerFlashBuyId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyId"),
102 103
 		beego.NSRouter("/flashbuy/:id", &flashbuy.FlashBuyController{}, "post:FlashBuy"),
103 104
 

+ 0
- 1
service/user.go View File

@@ -181,7 +181,6 @@ func (s *UserServ) SaveUser(user system.SysUserForm) (*model.SysUser, error) {
181 181
 			flag = false
182 182
 			break
183 183
 		}
184
-
185 184
 	}
186 185
 	if flag {
187 186
 		return nil, errors.New("生成推荐码失败!请重新点击保存。")