Browse Source

bug修改

wangfei 6 years ago
parent
commit
da4f482eae
3 changed files with 26 additions and 5 deletions
  1. 11
    3
      models/coupon/coupon.go
  2. 14
    1
      models/coupon/types.go
  3. 1
    1
      service/coupon/coupon.go

+ 11
- 3
models/coupon/coupon.go View File

@@ -344,8 +344,8 @@ func (m *CouponDAO) GetCustomerCouponByCouponAndUser(couponid, userid string) ([
344 344
 }
345 345
 
346 346
 // GetCouponDetail 获取优惠券详情
347
-func (m *CouponDAO) GetCouponDetail(couponid string) (*CaseCouponDetail, error) {
348
-	var coupon = new(CaseCouponDetail)
347
+func (m *CouponDAO) GetCouponDetail(couponid string) (*CaseCouponDetailWithRealName, error) {
348
+	var coupon = new(CaseCouponDetailWithRealName)
349 349
 	sql := `select * from ta_coupon where coupon_id=? and status>?`
350 350
 	_, err := m.db.Sql(sql, couponid, models.STATUS_DEL).Get(coupon)
351 351
 	if err != nil {
@@ -354,7 +354,7 @@ func (m *CouponDAO) GetCouponDetail(couponid string) (*CaseCouponDetail, error)
354 354
 	if coupon == nil || coupon.CouponId == "" {
355 355
 		return nil, errors.New("无优惠券信息")
356 356
 	}
357
-	cCoupons, err := m.GetCustomerCouponByCoupon(couponid)
357
+	cCoupons, err := m.GetCustomerCouponByCouponWithRealName(couponid)
358 358
 	if err != nil {
359 359
 		return nil, err
360 360
 	}
@@ -369,6 +369,14 @@ func (m *CouponDAO) GetCustomerCouponByCoupon(couponid string) ([]model.TaCustom
369 369
 	return customerCoupons, err
370 370
 }
371 371
 
372
+// GetCustomerCouponByCouponWithRealName 根据优惠券与用户获取领取的用户信息
373
+func (m *CouponDAO) GetCustomerCouponByCouponWithRealName(couponid string) ([]CustomerCouponWithSales, error) {
374
+	var customerCoupons []CustomerCouponWithSales
375
+	sql := `select a.*,b.real_name from ta_customer_coupon a inner join sys_user b on a.sales_id = b.user_id where a.coupon_id=? and a.status>?`
376
+	err := m.db.Sql(sql, couponid, models.STATUS_DEL).Find(&customerCoupons)
377
+	return customerCoupons, err
378
+}
379
+
372 380
 // GetCustomerCouponByUser 根据用户获取领取的用户信息
373 381
 func (m *CouponDAO) GetCustomerCouponByUser(caseid, userid string) ([]model.TaCustomerCoupon, error) {
374 382
 	var customerCoupons []model.TaCustomerCoupon

+ 14
- 1
models/coupon/types.go View File

@@ -20,13 +20,26 @@ type CouponInfo struct {
20 20
 	ChannelId      string
21 21
 }
22 22
 
23
-// CaseUsableCoupon 案场可用优惠券信息
23
+// CaseCouponDetail 案场可用优惠券信息
24 24
 type CaseCouponDetail struct {
25 25
 	model.TaCoupon `xorm:"extends"`
26 26
 	CustomerCoupon []model.TaCustomerCoupon
27 27
 	Share          *model.TaCouponShare
28 28
 }
29 29
 
30
+// CaseCouponDetailWithRealName
31
+type CaseCouponDetailWithRealName struct {
32
+	model.TaCoupon `xorm:"extends"`
33
+	CustomerCoupon []CustomerCouponWithSales
34
+	Share          *model.TaCouponShare
35
+}
36
+
37
+// CustomerCouponWithSalesName
38
+type CustomerCouponWithSales struct {
39
+	model.TaCustomerCoupon `xorm:"extends"`
40
+	RealName               string
41
+}
42
+
30 43
 // CustomerCoupon 用户优惠券
31 44
 type CustomerCoupon struct {
32 45
 	model.TaCustomerCoupon `xorm:"extends"`

+ 1
- 1
service/coupon/coupon.go View File

@@ -402,7 +402,7 @@ func (s *CouponServ) GetCouponBySendType(sendtype string) ([]model.TaCoupon, err
402 402
 }
403 403
 
404 404
 // GetCouponWithCustomer 获取优惠券明细
405
-func (s *CouponServ) GetCouponWithCustomer(couponid string) (*coupon.CaseCouponDetail, error) {
405
+func (s *CouponServ) GetCouponWithCustomer(couponid string) (*coupon.CaseCouponDetailWithRealName, error) {
406 406
 	if couponid == "" {
407 407
 		return nil, errors.New("没有券信息!")
408 408
 	}