wangfei 6 gadus atpakaļ
vecāks
revīzija
2beb031a0e

+ 17
- 1
controllers/card/card.go Parādīt failu

@@ -180,5 +180,21 @@ func (c *CardController) GetCardWithCustomer() {
180 180
 
181 181
 // GetCardByCustomer 获取我的卡信息
182 182
 func (c *CardController) GetCardByCustomer() {
183
-	c.ResponseJSON("OK")
183
+	cards, err := c.serv.GetCardByCustomer()
184
+	if err != nil {
185
+		c.ResponseError(err)
186
+	}
187
+
188
+	c.ResponseJSON(cards)
189
+}
190
+
191
+// GetCustomerCardByID 获取我的卡详情
192
+func (c *CardController) GetCustomerCardByID() {
193
+	id := c.GetString(":id")
194
+	card, err := c.serv.GetCustomerCardByID(id)
195
+	if err != nil {
196
+		c.ResponseError(err)
197
+	}
198
+
199
+	c.ResponseJSON(card)
184 200
 }

+ 11
- 0
controllers/coupon/coupon.go Parādīt failu

@@ -199,3 +199,14 @@ func (c *CouponController) GetCouponByCustomer() {
199 199
 
200 200
 	c.ResponseJSON(coupons)
201 201
 }
202
+
203
+// GetCustomerCouponByID 获取我的优惠券详情
204
+func (c *CouponController) GetCustomerCouponByID() {
205
+	id := c.GetString(":id")
206
+	coupon, err := c.serv.GetCustomerCouponByID(id)
207
+	if err != nil {
208
+		c.ResponseError(err)
209
+	}
210
+
211
+	c.ResponseJSON(coupon)
212
+}

+ 10
- 0
models/card/card.go Parādīt failu

@@ -302,3 +302,13 @@ func (m *CardDAO) GetCardByCustomer(orgid, customerid string) ([]model.TaCustome
302 302
 	err := m.db.Where("status>?", models.STATUS_DEL).And("customer_id=?", customerid).And("org_id=?", orgid).Find(&cards)
303 303
 	return cards, err
304 304
 }
305
+
306
+// GetCustomerCardByID 获取我的体验卡详情
307
+func (m *CardDAO) GetCustomerCardByID(id string) (*model.TaCustomerCard, error) {
308
+	if id == "" {
309
+		return nil, errors.New("无优惠券信息")
310
+	}
311
+	var customerCard = new(model.TaCustomerCard)
312
+	_, err := m.db.Where("customer_card_id=?", id).Get(customerCard)
313
+	return customerCard, err
314
+}

+ 1
- 1
models/coupon/coupon.go Parādīt failu

@@ -382,7 +382,7 @@ func (m *CouponDAO) GetCouponByCustomer(orgid, customerid string) ([]CustomerCou
382 382
 	return coupons, err
383 383
 }
384 384
 
385
-// GetCustomerCouponByID 获取我的优惠券想想
385
+// GetCustomerCouponByID 获取我的优惠券详情
386 386
 func (m *CouponDAO) GetCustomerCouponByID(id string) (*model.TaCustomerCoupon, error) {
387 387
 	if id == "" {
388 388
 		return nil, errors.New("无优惠券信息")

+ 2
- 0
routers/wechat.go Parādīt failu

@@ -21,6 +21,8 @@ func getWechatRoutes() beego.LinkNamespace {
21 21
 		beego.NSRouter("/customer/user", &user.UserController{}, "get:GetUserCustomer"),
22 22
 		beego.NSRouter("/customer/coupon", &coupon.CouponController{}, "get:GetCouponByCustomer"),
23 23
 		beego.NSRouter("/customer/card", &card.CardController{}, "get:GetCardByCustomer"),
24
+		beego.NSRouter("/customer/coupon/:id", &coupon.CouponController{}, "get:GetCustomerCouponByID"),
25
+		beego.NSRouter("/customer/card/:id", &card.CardController{}, "get:GetCustomerCardByID"),
24 26
 
25 27
 		// 下单
26 28
 		beego.NSRouter("/order/goods", &goods.GoodsController{}, "post:PostOrder"),

+ 14
- 4
service/card/card.go Parādīt failu

@@ -275,20 +275,20 @@ func (s *CardServ) GetCardByIDWithCheck(cardID string) (*card.CardInfo, error) {
275 275
 	return card, nil
276 276
 }
277 277
 
278
-// GetCardWithCustomer 获取优惠券明细
278
+// GetCardWithCustomer 获取体验卡明细
279 279
 func (s *CardServ) GetCardWithCustomer(cardid string) (*card.CaseUsableCard, error) {
280 280
 	if cardid == "" {
281 281
 		return nil, errors.New("没有卡信息!")
282 282
 	}
283 283
 	cardDetail, err := s.dao.GetCardDetail(cardid)
284 284
 	if err != nil {
285
-		utils.LogError("获取优惠券失败: " + err.Error())
286
-		return nil, errors.New("获取优惠券失败")
285
+		utils.LogError("获取体验卡失败: " + err.Error())
286
+		return nil, errors.New("获取体验卡失败")
287 287
 	}
288 288
 	return cardDetail, nil
289 289
 }
290 290
 
291
-// GetCardByCustomer 获取我的优惠券
291
+// GetCardByCustomer 获取我的体验卡
292 292
 func (s *CardServ) GetCardByCustomer() ([]model.TaCustomerCard, error) {
293 293
 	org := s.ctx.Get("org").(model.SysOrg)
294 294
 	customer := s.ctx.Get("customer").(model.TaCustomer)
@@ -299,3 +299,13 @@ func (s *CardServ) GetCardByCustomer() ([]model.TaCustomerCard, error) {
299 299
 	}
300 300
 	return cards, nil
301 301
 }
302
+
303
+// GetCustomerCardByID 获取我的体验卡详情
304
+func (s *CardServ) GetCustomerCardByID(id string) (*model.TaCustomerCard, error) {
305
+	card, err := s.dao.GetCustomerCardByID(id)
306
+	if err != nil {
307
+		utils.LogError("获取体验卡失败: " + err.Error())
308
+		return nil, errors.New("获取体验卡失败")
309
+	}
310
+	return card, nil
311
+}

+ 10
- 0
service/coupon/coupon.go Parādīt failu

@@ -393,3 +393,13 @@ func (s *CouponServ) GetCouponByCustomer() ([]coupon.CustomerCoupon, error) {
393 393
 	}
394 394
 	return coupons, nil
395 395
 }
396
+
397
+// GetCustomerCouponByID 获取我的优惠券详情
398
+func (s *CouponServ) GetCustomerCouponByID(id string) (*model.TaCustomerCoupon, error) {
399
+	coupon, err := s.dao.GetCustomerCouponByID(id)
400
+	if err != nil {
401
+		utils.LogError("获取优惠券失败: " + err.Error())
402
+		return nil, errors.New("获取优惠券失败")
403
+	}
404
+	return coupon, nil
405
+}

+ 2
- 0
service/course/course.go Parādīt failu

@@ -148,6 +148,8 @@ func (s *CourseServ) SaveCourse(course model.TaCourse, tagids string) (*model.Ta
148 148
 		return nil, utils.LogError("请选择课程标签!")
149 149
 	}
150 150
 	if course.CourseId == "" {
151
+		org := s.ctx.Get("org").(model.SysOrg)
152
+		course.OrgId = org.OrgId
151 153
 		newInfo, err = s.dao.AddCourse(course)
152 154
 		if err != nil {
153 155
 			utils.LogError("保存课程信息失败: " + err.Error())