瀏覽代碼

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

胡轶钦 6 年之前
父節點
當前提交
4ca90ea303
共有 7 個檔案被更改,包括 134 行新增1 行删除
  1. 8
    0
      log/common.log
  2. 41
    0
      models/card/card.go
  3. 41
    0
      models/coupon/coupon.go
  4. 1
    0
      models/coupon/types.go
  5. 21
    0
      service/card/card.go
  6. 21
    0
      service/coupon/coupon.go
  7. 1
    1
      service/course/course.go

+ 8
- 0
log/common.log 查看文件

271
 2018/09/19 17:42:09 [E] 用户没有设置默认案场
271
 2018/09/19 17:42:09 [E] 用户没有设置默认案场
272
 2018/09/19 17:42:09 [E] 用户没有设置默认案场
272
 2018/09/19 17:42:09 [E] 用户没有设置默认案场
273
 2018/09/19 17:51:33 [E] 获取用户基本信息失败: 没有查询到 ID (OPENID) 对应的用户
273
 2018/09/19 17:51:33 [E] 获取用户基本信息失败: 没有查询到 ID (OPENID) 对应的用户
274
+2018/09/19 18:58:01 [E] 获取发送卡信息失败: Error 1054: Unknown column 'serial_code' in 'field list'
275
+2018/09/19 18:58:01 [E] 获取人员信息失败: 获取人员信息失败
276
+2018/09/19 19:00:04 [E] 获取发送卡信息失败: Error 1054: Unknown column 'price' in 'field list'
277
+2018/09/19 19:00:04 [E] 获取人员信息失败: 获取人员信息失败
278
+2018/09/19 19:00:37 [E] 获取发送券信息失败: Error 1054: Unknown column 'serial_code' in 'field list'
279
+2018/09/19 19:00:37 [E] 获取人员信息失败: 获取人员信息失败
280
+2018/09/19 19:06:05 [E] 获取发送券信息失败: Error 1054: Unknown column 'price' in 'field list'
281
+2018/09/19 19:06:05 [E] 获取人员信息失败: 获取人员信息失败

+ 41
- 0
models/card/card.go 查看文件

34
 	Images             []model.TaExperienceCardImage
34
 	Images             []model.TaExperienceCardImage
35
 	Targets            []model.TaCouponCardTarget
35
 	Targets            []model.TaCouponCardTarget
36
 	Share              *model.TaExperienceCardShare
36
 	Share              *model.TaExperienceCardShare
37
+	ChannelId          string
37
 }
38
 }
38
 
39
 
39
 // GetCardList 获取卡列表
40
 // GetCardList 获取卡列表
83
 		return nil, err
84
 		return nil, err
84
 	}
85
 	}
85
 	card[0].Share = share
86
 	card[0].Share = share
87
+	channel, err := m.GetCardChannel(cardid)
88
+	if err != nil {
89
+		return nil, err
90
+	}
91
+	if channel != nil {
92
+		card[0].ChannelId = channel.ChannelId
93
+	}
86
 	return &card[0], err
94
 	return &card[0], err
87
 }
95
 }
88
 
96
 
414
 	}
422
 	}
415
 	return cards, nil
423
 	return cards, nil
416
 }
424
 }
425
+
426
+// GetCardChannel 获取卡对应渠道
427
+func (m *CardDAO) GetCardChannel(cardid string) (*model.TaCardCouponChannel, error) {
428
+	var channels []model.TaCardCouponChannel
429
+	err := m.db.Where("card_coupon_type=?", models.COURSE_COUPON_CARD).And("card_coupon_id=?", cardid).And("status=?", models.STATUS_NORMAL).Find(&channels)
430
+	if err != nil {
431
+		return nil, err
432
+	}
433
+	if len(channels) > 0 {
434
+		return &channels[0], nil
435
+	}
436
+	return nil, nil
437
+}
438
+
439
+// DelCardChannel 删除卡对应渠道
440
+func (m *CardDAO) DelCardChannel(cardid string) error {
441
+	sql := `delete from ta_card_coupon_channel where card_coupon_id=? and card_coupon_type=?`
442
+	_, err := m.db.Exec(sql, cardid, models.COURSE_COUPON_CARD)
443
+	return err
444
+}
445
+
446
+// SaveCardChannel 保存卡对应渠道
447
+func (m *CardDAO) SaveCardChannel(channelid, cardid string) error {
448
+	var cardChannel = model.TaCardCouponChannel{
449
+		CardCouponChannelId: utils.GetGUID(),
450
+		CardCouponId:        cardid,
451
+		ChannelId:           channelid,
452
+		CardCouponType:      models.COURSE_COUPON_CARD,
453
+		Status:              models.STATUS_NORMAL,
454
+	}
455
+	_, err := m.db.Insert(&cardChannel)
456
+	return err
457
+}

+ 41
- 0
models/coupon/coupon.go 查看文件

86
 	cp.Rules = rules
86
 	cp.Rules = rules
87
 	cp.Share = share
87
 	cp.Share = share
88
 
88
 
89
+	channel, err := m.GetCouponChannel(id)
90
+	if err != nil {
91
+		return nil, err
92
+	}
93
+	if channel != nil {
94
+		cp.ChannelId = channel.ChannelId
95
+	}
96
+
89
 	return cp, nil
97
 	return cp, nil
90
 }
98
 }
91
 
99
 
519
 	err := m.db.Sql(sql, models.STATUS_DEL, customerid, orgid).Find(&coupons)
527
 	err := m.db.Sql(sql, models.STATUS_DEL, customerid, orgid).Find(&coupons)
520
 	return coupons, err
528
 	return coupons, err
521
 }
529
 }
530
+
531
+// GetCouponChannel 获取优惠券对应渠道
532
+func (m *CouponDAO) GetCouponChannel(couponid string) (*model.TaCardCouponChannel, error) {
533
+	var channels []model.TaCardCouponChannel
534
+	err := m.db.Where("card_coupon_type=?", models.COURSE_COUPON_COUPON).And("card_coupon_id=?", couponid).And("status=?", models.STATUS_NORMAL).Find(&channels)
535
+	if err != nil {
536
+		return nil, err
537
+	}
538
+	if len(channels) > 0 {
539
+		return &channels[0], nil
540
+	}
541
+	return nil, nil
542
+}
543
+
544
+// DelCouponChannel 删除优惠券对应渠道
545
+func (m *CouponDAO) DelCouponChannel(couponid string) error {
546
+	sql := `delete from ta_card_coupon_channel where card_coupon_id=? and card_coupon_type=?`
547
+	_, err := m.db.Exec(sql, couponid, models.COURSE_COUPON_COUPON)
548
+	return err
549
+}
550
+
551
+// SaveCouponChannel 保存优惠券对应渠道
552
+func (m *CouponDAO) SaveCouponChannel(channelid, couponid string) error {
553
+	var couponChannel = model.TaCardCouponChannel{
554
+		CardCouponChannelId: utils.GetGUID(),
555
+		CardCouponId:        couponid,
556
+		ChannelId:           channelid,
557
+		CardCouponType:      models.COURSE_COUPON_COUPON,
558
+		Status:              models.STATUS_NORMAL,
559
+	}
560
+	_, err := m.db.Insert(&couponChannel)
561
+	return err
562
+}

+ 1
- 0
models/coupon/types.go 查看文件

17
 	Targets        []model.TaCouponTarget
17
 	Targets        []model.TaCouponTarget
18
 	Images         []model.TaCouponImage
18
 	Images         []model.TaCouponImage
19
 	Rules          []model.TaCouponRule
19
 	Rules          []model.TaCouponRule
20
+	ChannelId      string
20
 }
21
 }
21
 
22
 
22
 // CaseUsableCoupon 案场可用优惠券信息
23
 // CaseUsableCoupon 案场可用优惠券信息

+ 21
- 0
service/card/card.go 查看文件

122
 		return errors.New("保存卡关联内容失败")
122
 		return errors.New("保存卡关联内容失败")
123
 	}
123
 	}
124
 
124
 
125
+	// 保存渠道
126
+	if cd.ChannelId != "" {
127
+		if err := s.dao.SaveCardChannel(cd.ChannelId, cd.CardId); err != nil {
128
+			utils.LogError("保存对应渠道失败: " + err.Error())
129
+			return errors.New("保存对应渠道失败")
130
+		}
131
+	}
132
+
125
 	return nil
133
 	return nil
126
 }
134
 }
127
 
135
 
158
 		return errors.New("更新卡分享失败")
166
 		return errors.New("更新卡分享失败")
159
 	}
167
 	}
160
 
168
 
169
+	// 删除渠道
170
+	if err := s.dao.DelCardChannel(cd.CardId); err != nil {
171
+		utils.LogError("删除对应渠道信息失败: " + err.Error())
172
+		return errors.New("删除对应渠道信息失败")
173
+	}
174
+
175
+	// 保存渠道
176
+	if cd.ChannelId != "" {
177
+		if err := s.dao.SaveCardChannel(cd.ChannelId, cd.CardId); err != nil {
178
+			utils.LogError("保存对应渠道失败: " + err.Error())
179
+			return errors.New("保存对应渠道失败")
180
+		}
181
+	}
161
 	// 关联内容 规则 不允许更新
182
 	// 关联内容 规则 不允许更新
162
 	return nil
183
 	return nil
163
 }
184
 }

+ 21
- 0
service/coupon/coupon.go 查看文件

124
 		return errors.New("保存优惠券规则失败")
124
 		return errors.New("保存优惠券规则失败")
125
 	}
125
 	}
126
 
126
 
127
+	// 保存渠道
128
+	if cp.ChannelId != "" {
129
+		if err := s.dao.SaveCouponChannel(cp.ChannelId, cp.CouponId); err != nil {
130
+			utils.LogError("保存对应渠道失败: " + err.Error())
131
+			return errors.New("保存对应渠道失败")
132
+		}
133
+	}
134
+
127
 	return nil
135
 	return nil
128
 }
136
 }
129
 
137
 
183
 		return errors.New("保存优惠券规则失败")
191
 		return errors.New("保存优惠券规则失败")
184
 	}
192
 	}
185
 
193
 
194
+	// 删除渠道
195
+	if err := s.dao.DelCouponChannel(cp.CouponId); err != nil {
196
+		utils.LogError("删除对应渠道信息失败: " + err.Error())
197
+		return errors.New("删除对应渠道信息失败")
198
+	}
199
+
200
+	// 保存渠道
201
+	if cp.ChannelId != "" {
202
+		if err := s.dao.SaveCouponChannel(cp.ChannelId, cp.CouponId); err != nil {
203
+			utils.LogError("保存对应渠道失败: " + err.Error())
204
+			return errors.New("保存对应渠道失败")
205
+		}
206
+	}
186
 	return nil
207
 	return nil
187
 }
208
 }
188
 
209
 

+ 1
- 1
service/course/course.go 查看文件

141
 	if course.BeginDate.IsZero() || course.EndDate.IsZero() {
141
 	if course.BeginDate.IsZero() || course.EndDate.IsZero() {
142
 		return nil, utils.LogError("课程时间不允许为空!")
142
 		return nil, utils.LogError("课程时间不允许为空!")
143
 	}
143
 	}
144
-	if !course.EndDate.After(course.BeginDate) {
144
+	if !course.EndDate.After(course.BeginDate) && course.EndDate != course.BeginDate {
145
 		return nil, utils.LogError("截止时间必须大于开始时间!")
145
 		return nil, utils.LogError("截止时间必须大于开始时间!")
146
 	}
146
 	}
147
 	if tagids == "" {
147
 	if tagids == "" {