Browse Source

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

胡轶钦 6 years ago
parent
commit
e38917f19b
6 changed files with 54 additions and 22 deletions
  1. 2
    1
      conf/db.conf
  2. 19
    0
      controllers/flashbuy/flashbuy.go
  3. 1
    1
      models/models.go
  4. 1
    1
      routers/wechat.go
  5. 11
    0
      service/flashbuy/flashbuy.go
  6. 20
    19
      service/user.go

+ 2
- 1
conf/db.conf View File

6
 
6
 
7
 ; 数据库地址,可以使用IP
7
 ; 数据库地址,可以使用IP
8
 ; db_addr      = 47.101.36.130
8
 ; db_addr      = 47.101.36.130
9
-db_addr        = 192.168.0.122
9
+# db_addr        = 192.168.0.122
10
+db_addr = localhost
10
 # db_addr      = rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com
11
 # db_addr      = rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com
11
 
12
 
12
 ; 端口
13
 ; 端口

+ 19
- 0
controllers/flashbuy/flashbuy.go View File

69
 
69
 
70
 }
70
 }
71
 
71
 
72
+// GetFlashBuyById 获取抢购详情
72
 func (c *FlashBuyController) GetFlashBuyById() {
73
 func (c *FlashBuyController) GetFlashBuyById() {
73
 	flashBuyId := c.GetString(":flashBuyId")
74
 	flashBuyId := c.GetString(":flashBuyId")
74
 	flashBuy, err := c.dao.GetFlashBuyById(flashBuyId)
75
 	flashBuy, err := c.dao.GetFlashBuyById(flashBuyId)
75
 	if err != nil {
76
 	if err != nil {
76
 		c.ResponseError(err)
77
 		c.ResponseError(err)
77
 	}
78
 	}
79
+
78
 	c.ResponseJSON(flashBuy)
80
 	c.ResponseJSON(flashBuy)
79
 }
81
 }
80
 
82
 
83
+// GetWechatFlashBuyById
84
+func (c *FlashBuyController) GetWechatFlashBuyById() {
85
+	flashBuyId := c.GetString(":flashBuyId")
86
+	flashBuy, err := c.dao.GetFlashBuyById(flashBuyId)
87
+	if err != nil {
88
+		c.ResponseError(err)
89
+	}
90
+	userinfo, err := c.dao.GetFlashByUser(flashBuyId)
91
+	if err != nil {
92
+		c.ResponseError(err)
93
+	}
94
+	c.ResponseJSON(map[string]interface{}{
95
+		"flashBuy": flashBuy,
96
+		"userInfo": userinfo,
97
+	})
98
+}
99
+
81
 func (c *FlashBuyController) GetCustomerFlashBuyId() {
100
 func (c *FlashBuyController) GetCustomerFlashBuyId() {
82
 	flashBuyId := c.GetString(":customerFlashBuyId")
101
 	flashBuyId := c.GetString(":customerFlashBuyId")
83
 	flashBuy, err := c.dao.GetCustomerFlashBuyId(flashBuyId)
102
 	flashBuy, err := c.dao.GetCustomerFlashBuyId(flashBuyId)

+ 1
- 1
models/models.go View File

22
 	dns := getMySQLDNS()
22
 	dns := getMySQLDNS()
23
 
23
 
24
 	engine, err := xorm.NewEngine(dbType, dns)
24
 	engine, err := xorm.NewEngine(dbType, dns)
25
-	engine.ShowSQL()
25
+	// engine.ShowSQL()
26
 
26
 
27
 	if err != nil {
27
 	if err != nil {
28
 		panic(err)
28
 		panic(err)

+ 1
- 1
routers/wechat.go View File

97
 		beego.NSRouter("/user/luckdraw/record/:id", &luckdraw.LuckDrawController{}, "get:GetRecordByID"),
97
 		beego.NSRouter("/user/luckdraw/record/:id", &luckdraw.LuckDrawController{}, "get:GetRecordByID"),
98
 
98
 
99
 		// 抢购
99
 		// 抢购
100
-		beego.NSRouter("/flashbuy/flash/:flashBuyId", &flashbuy.FlashBuyController{}, "get:GetFlashBuyById"),
100
+		beego.NSRouter("/flashbuy/flash/:flashBuyId", &flashbuy.FlashBuyController{}, "get:GetWechatFlashBuyById"),
101
 		beego.NSRouter("/flashbuy/customer", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyByCustomerId"),
101
 		beego.NSRouter("/flashbuy/customer", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyByCustomerId"),
102
 		beego.NSRouter("/flashbuy/customerFlash/:customerFlashBuyId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyId"),
102
 		beego.NSRouter("/flashbuy/customerFlash/:customerFlashBuyId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyId"),
103
 		beego.NSRouter("/flashbuy/:id", &flashbuy.FlashBuyController{}, "post:FlashBuy"),
103
 		beego.NSRouter("/flashbuy/:id", &flashbuy.FlashBuyController{}, "post:FlashBuy"),

+ 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

+ 20
- 19
service/user.go View File

117
 		beego.Error(err)
117
 		beego.Error(err)
118
 		return nil, err
118
 		return nil, err
119
 	}
119
 	}
120
-	userinfo.Pwd = ""
121
-	usertype, err := s.dao.GetUserType(userid)
122
-	if err != nil {
123
-		beego.Error(err)
124
-		return nil, err
125
-	}
126
-	userinfo.UserType = usertype
120
+	if userinfo != nil {
121
+		userinfo.Pwd = ""
122
+		usertype, err := s.dao.GetUserType(userid)
123
+		if err != nil {
124
+			beego.Error(err)
125
+			return nil, err
126
+		}
127
+		userinfo.UserType = usertype
127
 
128
 
128
-	usertag, err := s.dao.GetUserTag(userid)
129
-	if err != nil {
130
-		beego.Error(err)
131
-		return nil, err
132
-	}
133
-	userinfo.UserTag = usertag
129
+		usertag, err := s.dao.GetUserTag(userid)
130
+		if err != nil {
131
+			beego.Error(err)
132
+			return nil, err
133
+		}
134
+		userinfo.UserTag = usertag
134
 
135
 
135
-	usercase, err := s.dao.GetUserCase(userid)
136
-	if err != nil {
137
-		beego.Error(err)
138
-		return nil, err
136
+		usercase, err := s.dao.GetUserCase(userid)
137
+		if err != nil {
138
+			beego.Error(err)
139
+			return nil, err
140
+		}
141
+		userinfo.UserCase = usercase
139
 	}
142
 	}
140
-	userinfo.UserCase = usercase
141
-
142
 	// userrole, err := s.dao.GetUserRole(userid)
143
 	// userrole, err := s.dao.GetUserRole(userid)
143
 	// if err != nil {
144
 	// if err != nil {
144
 	// 	return nil, err
145
 	// 	return nil, err