wangfei 6 years ago
parent
commit
3fb01126e7
2 changed files with 12 additions and 10 deletions
  1. 1
    10
      controllers/flashbuy/flashbuy.go
  2. 11
    0
      service/flashbuy/flashbuy.go

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

8
 	"spaceofcheng/services/models/model"
8
 	"spaceofcheng/services/models/model"
9
 	"spaceofcheng/services/service/flashbuy"
9
 	"spaceofcheng/services/service/flashbuy"
10
 	"spaceofcheng/services/utils"
10
 	"spaceofcheng/services/utils"
11
-
12
-	"github.com/astaxie/beego"
13
 )
11
 )
14
 
12
 
15
 // CaseController 信息
13
 // CaseController 信息
77
 	if err != nil {
75
 	if err != nil {
78
 		c.ResponseError(err)
76
 		c.ResponseError(err)
79
 	}
77
 	}
80
-	userRaw := c.Context.Get("customer")
81
-	if userRaw == nil {
82
-		c.ResponseError(errors.New("系统内部错误"), http.StatusInternalServerError)
83
-	}
84
-
85
-	user := userRaw.(model.TaCustomer)
86
-	userinfo, err := c.dao.GetCustomerFlashBuyId(flashBuyId, user.CustomerId)
78
+	userinfo, err := c.dao.GetFlashByUser(flashBuyId)
87
 	if err != nil {
79
 	if err != nil {
88
 		c.ResponseError(err)
80
 		c.ResponseError(err)
89
 	}
81
 	}
90
-	beego.Error(userinfo)
91
 	c.ResponseJSON(map[string]interface{}{
82
 	c.ResponseJSON(map[string]interface{}{
92
 		"flashBuy": flashBuy,
83
 		"flashBuy": flashBuy,
93
 		"userInfo": userinfo,
84
 		"userInfo": userinfo,

+ 11
- 0
service/flashbuy/flashbuy.go View File

62
 	}
62
 	}
63
 	return flashbuy, nil
63
 	return flashbuy, nil
64
 }
64
 }
65
+
66
+// GetFlashByUser 获取用户的抢购信息
67
+func (s *FlashBuyServ) GetFlashByUser(id string) ([]model.TaCustomerFlashBuy, error) {
68
+	cst := s.ctx.Get("customer")
69
+	if cst == nil {
70
+		return nil, errors.New("系统内部错误")
71
+	}
72
+	flashbuys, err := s.dao.GetCustomerFlashBuy(id, cst.(model.TaCustomer).CustomerId)
73
+	return flashbuys, err
74
+}
75
+
65
 func (s *FlashBuyServ) SaveFlashBuy(flashbuy model.TaFlashBuy) (*model.TaFlashBuy, error) {
76
 func (s *FlashBuyServ) SaveFlashBuy(flashbuy model.TaFlashBuy) (*model.TaFlashBuy, error) {
66
 	var newFlashBuy *model.TaFlashBuy
77
 	var newFlashBuy *model.TaFlashBuy
67
 	var err error
78
 	var err error