|
@@ -544,6 +544,15 @@ func (s *CouponServ) ReceiveCoupon(id, saleid, serialcode string) error {
|
544
|
544
|
return errors.New("log-error-该优惠券已被领取!")
|
545
|
545
|
}
|
546
|
546
|
|
|
547
|
+ // 计算卡券有效期
|
|
548
|
+ startDate := coupon.StartDate
|
|
549
|
+ endDate := coupon.EndDate
|
|
550
|
+ if coupon.ValidDays > 0 {
|
|
551
|
+ startDate = time.Now().Local()
|
|
552
|
+ hs := int64(coupon.ValidDays * 24)
|
|
553
|
+ endDate = time.Now().Local().Add(time.Hour * time.Duration(hs))
|
|
554
|
+ }
|
|
555
|
+
|
547
|
556
|
// 领取
|
548
|
557
|
var customerCoupon = model.TaCustomerCoupon{
|
549
|
558
|
CouponId: coupon.CouponId,
|
|
@@ -551,8 +560,8 @@ func (s *CouponServ) ReceiveCoupon(id, saleid, serialcode string) error {
|
551
|
560
|
CustomerId: customer.CustomerId,
|
552
|
561
|
SalesId: saler.UserId,
|
553
|
562
|
SalesName: saler.UserName,
|
554
|
|
- StartDate: coupon.StartDate,
|
555
|
|
- EndDate: coupon.EndDate,
|
|
563
|
+ StartDate: startDate,
|
|
564
|
+ EndDate: endDate,
|
556
|
565
|
CaseId: coupon.CaseId,
|
557
|
566
|
OrgId: coupon.OrgId,
|
558
|
567
|
SerialCode: serialcode,
|
|
@@ -611,13 +620,22 @@ func (s *CouponServ) ChannelReceiveCoupon(id string) error {
|
611
|
620
|
return errors.New("log-error-您已领取过该优惠券!")
|
612
|
621
|
}
|
613
|
622
|
|
|
623
|
+ // 计算卡券有效期
|
|
624
|
+ startDate := coupon.StartDate
|
|
625
|
+ endDate := coupon.EndDate
|
|
626
|
+ if coupon.ValidDays > 0 {
|
|
627
|
+ startDate = time.Now().Local()
|
|
628
|
+ hs := int64(coupon.ValidDays * 24)
|
|
629
|
+ endDate = time.Now().Local().Add(time.Hour * time.Duration(hs))
|
|
630
|
+ }
|
|
631
|
+
|
614
|
632
|
// 领取
|
615
|
633
|
var customerCoupon = model.TaCustomerCoupon{
|
616
|
634
|
CouponId: coupon.CouponId,
|
617
|
635
|
CustomerCouponName: coupon.CouponName,
|
618
|
636
|
CustomerId: customer.CustomerId,
|
619
|
|
- StartDate: coupon.StartDate,
|
620
|
|
- EndDate: coupon.EndDate,
|
|
637
|
+ StartDate: startDate,
|
|
638
|
+ EndDate: endDate,
|
621
|
639
|
CaseId: coupon.CaseId,
|
622
|
640
|
OrgId: coupon.OrgId,
|
623
|
641
|
ReceivingType: models.RECEIVEING_TYPE_CHANNEL,
|