浏览代码

add test case

zjxpcyc 6 年前
父节点
当前提交
75e9dd5b5b

+ 1
- 1
conf/db.conf 查看文件

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

+ 9
- 0
controllers/customerremark/customerremark.go 查看文件

@@ -55,6 +55,15 @@ func (c *CustomerRemarkController) AddRemark() {
55 55
 	c.ResponseJSON(newRemark)
56 56
 }
57 57
 
58
+func (c *CustomerRemarkController) IsExist() {
59
+	recommendCode := c.GetString(":recommendCode")
60
+	num, err := c.dao.IsExist(recommendCode)
61
+	if err != nil {
62
+		c.ResponseError(err)
63
+	}
64
+	c.ResponseJSON(num)
65
+}
66
+
58 67
 func (c *CustomerRemarkController) SearchCustomer() {
59 68
 	salesId := c.GetString(":salesId")
60 69
 	customerInfo := c.GetString(":customerInfo")

+ 8
- 0
controllers/flashbuy/flashbuy.go 查看文件

@@ -136,3 +136,11 @@ func (c *FlashBuyController) FlashBuy() {
136 136
 	}
137 137
 	c.ResponseJSON("恭喜您!抢购成功!")
138 138
 }
139
+
140
+func (c *FlashBuyController) GetFlashModelList() {
141
+	model, err := c.dao.GetFlashModelList()
142
+	if err != nil {
143
+		c.ResponseError(err)
144
+	}
145
+	c.ResponseJSON(model)
146
+}

+ 21
- 4
controllers/luckdraw/luckdraw.go 查看文件

@@ -11,8 +11,6 @@ import (
11 11
 	"spaceofcheng/services/models/model"
12 12
 	"spaceofcheng/services/service/luckdraw"
13 13
 	"spaceofcheng/services/utils"
14
-
15
-	"github.com/astaxie/beego"
16 14
 )
17 15
 
18 16
 // LuckdrawController 应用
@@ -104,7 +102,6 @@ func (c *LuckDrawController) SaveLuckDraw() {
104 102
 		utils.LogError("抽奖数据转换失败: " + err.Error())
105 103
 		c.ResponseError(err)
106 104
 	}
107
-	beego.Error(info)
108 105
 	newinfo, err := c.serv.SaveLuckDraw(&info)
109 106
 	if err != nil {
110 107
 		c.ResponseError(err)
@@ -122,6 +119,26 @@ func (c *LuckDrawController) DelLuckDraw() {
122 119
 	c.ResponseJSON("操作成功!")
123 120
 }
124 121
 
122
+// OpenLuckDraw 抽奖启用
123
+func (c *LuckDrawController) OpenLuckDraw() {
124
+	luckdrawid := c.GetString(":luckdrawid")
125
+	err := c.serv.OpenLuckDraw(luckdrawid)
126
+	if err != nil {
127
+		c.ResponseError(err)
128
+	}
129
+	c.ResponseJSON("操作成功!")
130
+}
131
+
132
+// StopLuckDraw 抽奖启用
133
+func (c *LuckDrawController) StopLuckDraw() {
134
+	luckdrawid := c.GetString(":luckdrawid")
135
+	err := c.serv.StopLuckDraw(luckdrawid)
136
+	if err != nil {
137
+		c.ResponseError(err)
138
+	}
139
+	c.ResponseJSON("操作成功!")
140
+}
141
+
125 142
 // GetUserByCode 根据code获取用户信息
126 143
 func (c *LuckDrawController) GetUserByCode() {
127 144
 	userRaw := c.Context.Get("customer")
@@ -131,7 +148,7 @@ func (c *LuckDrawController) GetUserByCode() {
131 148
 
132 149
 	user := userRaw.(model.TaCustomer)
133 150
 	luckdrawid := c.GetString(":id")
134
-	record, err := c.serv.GetUserLuckDrawByLuckDraw(user.CustomerId, luckdrawid)
151
+	record, err := c.serv.GetUserLuckDrawByLuckDraw(user, luckdrawid)
135 152
 	if err != nil {
136 153
 		utils.LogError("获取用户抽奖信息失败: " + err.Error())
137 154
 		c.ResponseError(errors.New("获取用户抽奖信息失败"))

+ 8
- 0
models/constant.go 查看文件

@@ -205,6 +205,7 @@ const (
205 205
 	NUMTYPE_REPART    = "repeat"
206 206
 	NUMTYPE_NOTREPART = "no_repeat"
207 207
 )
208
+
208 209
 const (
209 210
 	FLASH_BUY_ACTIVE   = "active"
210 211
 	FLASH_BUY_INACTIVE = "inactive"
@@ -226,3 +227,10 @@ const (
226 227
 	ActGiveCoupon = "giveCoupon"
227 228
 	ActGiveCard   = "giveCard"
228 229
 )
230
+
231
+// 抽奖次数间隔
232
+const (
233
+	INTERVAL_DAY   = "day"
234
+	INTERVAL_WEEK  = "week"
235
+	INTERVAL_MONTH = "month"
236
+)

+ 1
- 1
models/customer/customer.go 查看文件

@@ -282,7 +282,7 @@ func (m *CustomerDAO) GetSalesByRecommendCode(recommendCode string) (*model.SysU
282 282
 
283 283
 func (m *CustomerDAO) GetSalesCaseById(userId string) (*model.SysUserCase, error) {
284 284
 	userCase := new(model.SysUserCase)
285
-	if _, err := m.db.Where("user_id = ?", userId).Get(&userCase); err != nil {
285
+	if _, err := m.db.Where("user_id = ?", userId).Get(userCase); err != nil {
286 286
 		return nil, err
287 287
 	}
288 288
 	return userCase, nil

+ 8
- 0
models/customerremark/customerremark.go 查看文件

@@ -128,3 +128,11 @@ FROM
128 128
 	return len(customerReceive), err
129 129
 
130 130
 }
131
+
132
+func (m *CustomerRemarkDAO) IsExist(recommendCode string) (int, error) {
133
+	var user []model.SysUser
134
+	sql := `select * from sys_user where recommend_code = '` + recommendCode + `' 
135
+	and status > ` + strconv.Itoa(models.STATUS_DEL)
136
+	err := m.db.Sql(sql).Find(&user)
137
+	return len(user), err
138
+}

+ 7
- 0
models/flashbuy/flashbuy.go 查看文件

@@ -275,3 +275,10 @@ func (m *FlashbuyDAO) SaveCustomerFlashBuy(cstFlashBuy model.TaCustomerFlashBuy)
275 275
 	_, err := m.db.Insert(cstFlashBuy)
276 276
 	return &cstFlashBuy, err
277 277
 }
278
+
279
+func (m *FlashbuyDAO) GetFlashModelList() ([]model.TdFlashbuyModel, error) {
280
+	var model []model.TdFlashbuyModel
281
+	sql := `select * from td_flashbuy_model`
282
+	err := m.db.Sql(sql).Find(&model)
283
+	return model, err
284
+}

+ 92
- 33
models/luckdraw/luckdraw.go 查看文件

@@ -97,7 +97,7 @@ func (m *LuckDrawDao) GetLuckDrawRecordCount(id, tel string) (int, error) {
97 97
 		sql = sql + ` and b.phone=` + tel
98 98
 	}
99 99
 
100
-	err := m.db.Sql(sql).Find(&records)
100
+	err := m.db.Sql(sql, id).Find(&records)
101 101
 	return len(records), err
102 102
 }
103 103
 
@@ -110,7 +110,7 @@ func (m *LuckDrawDao) GetLuckDrawRecord(id, tel string, page, pageSize int) ([]R
110 110
 	}
111 111
 	sql = sql + ` ORDER BY a.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
112 112
 
113
-	err := m.db.Sql(sql).Find(&records)
113
+	err := m.db.Sql(sql, id).Find(&records)
114 114
 	return records, err
115 115
 }
116 116
 
@@ -329,7 +329,6 @@ func (m *LuckDrawDao) SavePrizeDetail(prize model.TaLuckdrawPrize) error {
329 329
 		var card model.TaCouponCard
330 330
 		_, err := m.db.Where("card_id=?", prize.CouponCardId).Get(&card)
331 331
 		if err != nil {
332
-			beego.Error(err)
333 332
 			return err
334 333
 		}
335 334
 		if card.UsedCount > 0 {
@@ -362,6 +361,19 @@ func (m *LuckDrawDao) UpdateLuckDraw(luckdraw model.TaLuckdraw, cols []string) e
362 361
 	return err
363 362
 }
364 363
 
364
+// UpdatePrizeDesc 更新奖品描述
365
+func (m *LuckDrawDao) UpdatePrizeDesc(prizes []PrizeWithDefaults) error {
366
+	for _, prize := range prizes {
367
+		_, err := m.db.Cols([]string{
368
+			"prize_desc",
369
+		}...).Where("id=?", prize.Id).Update(prize.TaLuckdrawPrize)
370
+		if err != nil {
371
+			return err
372
+		}
373
+	}
374
+	return nil
375
+}
376
+
365 377
 // GetLuckDraw 获取抽奖信息
366 378
 func (m *LuckDrawDao) GetLuckDraw(id string) (*LuckDraw, error) {
367 379
 	if id == "" {
@@ -388,13 +400,13 @@ func (m *LuckDrawDao) GetLuckDraw(id string) (*LuckDraw, error) {
388 400
 }
389 401
 
390 402
 // AddCustomerLuckDraw 保存用户抽奖配置信息
391
-func (m *LuckDrawDao) AddCustomerLuckDraw(custLuckDraw *model.TaLuckdrawCustomer) (*model.TaLuckdrawCustomer, error) {
403
+func (m *LuckDrawDao) AddCustomerLuckDraw(custLuckDraw model.TaLuckdrawCustomer) (*model.TaLuckdrawCustomer, error) {
392 404
 	custLuckDraw.LuckdrawCustomerId = utils.GetGUID()
393 405
 	custLuckDraw.CreateDate = time.Now()
394 406
 	custLuckDraw.ShareNum = 0
395
-	custLuckDraw.SurplusNum = 0
407
+	custLuckDraw.ShareSurplusNum = 0
396 408
 	_, err := m.db.Insert(custLuckDraw)
397
-	return custLuckDraw, err
409
+	return &custLuckDraw, err
398 410
 }
399 411
 
400 412
 // LuckDraw 抽奖
@@ -441,33 +453,18 @@ func (m *LuckDrawDao) LuckDraw(id string, user *model.TaCustomer) (*model.TaLuck
441 453
 	// 抽奖次数判断
442 454
 	if cstluckdrawSet.SurplusNum <= 0 {
443 455
 		return nil, nil, nil, errors.New("您的抽奖次数已用完!")
456
+	} else {
457
+		// 抽奖次数库存修改
458
+		err := m.UpdateCstLuckdrawSurplus(cstluckdrawSet)
459
+		if err != nil {
460
+			return nil, nil, nil, errors.New("操作失败,请刷新后重试!")
461
+		}
462
+		// 更新参与人数
463
+		err = m.UpdateLuckDrawJoinedNum(id)
464
+		if err != nil {
465
+			return nil, nil, nil, errors.New("操作失败,请刷新后重试!")
466
+		}
444 467
 	}
445
-	// 	userluckdraws, err := m.GetUserRecordByLuckDraw(user.CustomerId, id)
446
-	// 	if err != nil {
447
-	// 		utils.LogError("获取用户抽奖信息失败:", err)
448
-	// 		return nil, nil, nil, errors.New("获取用户抽奖信息失败!")
449
-	// 	}
450
-
451
-	// 	if len(userluckdraws) >= luckdraw.LuckdrawNum {
452
-	// 		return nil, nil, nil, errors.New("您的抽奖次数已用完!")
453
-	// 	}
454
-
455
-	// 判断人数是否已超过限制
456
-	// if luckdraw.JoinNum > 0 {
457
-	// 	usernum, err := m.GetLuckDrawCustomerNum(luckdraw.Id)
458
-	// 	if err != nil {
459
-	// 		utils.LogError("获取抽奖人员信息失败:", err)
460
-	// 		return nil, nil, nil, errors.New("获取抽奖人员信息失败!")
461
-	// 	}
462
-	// 	if luckdraw.JoinNum <= usernum {
463
-	// 		err = m.UpdateLuckDrawEndDate(luckdraw.Id)
464
-	// 		if err != nil {
465
-	// 			utils.LogError("操作失败,请刷新后重试:", err)
466
-	// 			return nil, nil, nil, errors.New("操作失败,请刷新后重试!")
467
-	// 		}
468
-	// 		return nil, nil, nil, errors.New("活动已结束!")
469
-	// 	}
470
-	// }
471 468
 
472 469
 	// 判断是否内置用户
473 470
 	defaultPrize, err := m.GetPrizeDefaultByUser(id, user)
@@ -581,6 +578,37 @@ func (m *LuckDrawDao) LuckDraw(id string, user *model.TaCustomer) (*model.TaLuck
581 578
 	return prize, &detail, record, err
582 579
 }
583 580
 
581
+// UpdateCstLuckdrawSurplus 更新用户抽奖剩余次数
582
+func (m *LuckDrawDao) UpdateCstLuckdrawSurplus(cstLuckDraw *model.TaLuckdrawCustomer) error {
583
+	sql := `update ta_luckdraw_customer set share_surplus_num = (case when surplus_num > share_surplus_num then share_surplus_num else share_surplus_num - 1 end),
584
+	surplus_num = surplus_num - 1 where luckdraw_customer_id = ? and surplus_num>0`
585
+	res, err := m.db.Exec(sql, cstLuckDraw.LuckdrawCustomerId)
586
+	if err != nil {
587
+		return err
588
+	}
589
+	len, _ := res.RowsAffected()
590
+	if len < 1 {
591
+		return errors.New("您没有剩余次数!")
592
+	}
593
+	return nil
594
+}
595
+
596
+// UpdateLuckDrawJoinedNum 更新抽奖参与人数
597
+func (m *LuckDrawDao) UpdateLuckDrawJoinedNum(id string) error {
598
+	var records []model.TaLuckdrawRecord
599
+	sql := `select DISTINCT user_id from ta_luckdraw_record where luckdraw_id=?`
600
+	err := m.db.Sql(sql, id).Find(&records)
601
+	if err != nil {
602
+		return err
603
+	}
604
+	if len(records) > 0 {
605
+		sql = `update ta_luckdraw set joined_num=? where id=?`
606
+		_, err = m.db.Exec(sql, len(records), id)
607
+		return err
608
+	}
609
+	return nil
610
+}
611
+
584 612
 // PrizeWithDefault 默认奖品
585 613
 type PrizeWithDefault struct {
586 614
 	DefaultId             string
@@ -845,6 +873,37 @@ func (m *LuckDrawDao) GetUserRecordByLuckDraw(userid string, luckdrawid string)
845 873
 	return records, err
846 874
 }
847 875
 
876
+// GetUserLuckDrawSet 获取用户抽奖设置
877
+func (m *LuckDrawDao) GetUserLuckDrawSet(customer model.TaCustomer, luckdrawid string) (*model.TaLuckdrawCustomer, error) {
878
+	var cstluckdraw = model.TaLuckdrawCustomer{}
879
+	_, err := m.db.Where("customer_id=?").And("luckdraw_id=?", luckdrawid).Get(&cstluckdraw)
880
+	if err != nil {
881
+		return nil, err
882
+	}
883
+	if cstluckdraw.CustomerId != "" {
884
+		return &cstluckdraw, nil
885
+	}
886
+	// 插入
887
+	luckdraw, err := m.GetLuckDrawByID(luckdrawid)
888
+	if err != nil {
889
+		return nil, err
890
+	}
891
+	surplusNum := luckdraw.LuckdrawNum
892
+	isnew := 0
893
+	if customer.Phone == "" {
894
+		isnew = 1
895
+	}
896
+	if luckdraw.JoinType == models.JOINTYPE_NEWUSER && isnew != 1 {
897
+		surplusNum = 0
898
+	}
899
+	cstluckdraw.CustomerId = customer.CustomerId
900
+	cstluckdraw.IsNew = isnew
901
+	cstluckdraw.LuckdrawId = luckdrawid
902
+	cstluckdraw.SurplusNum = surplusNum
903
+	newinfo, err := m.AddCustomerLuckDraw(cstluckdraw)
904
+	return newinfo, err
905
+}
906
+
848 907
 // GetUserLuckDrawByLuckDraw 获取用户的抽奖信息
849 908
 func (m *LuckDrawDao) GetUserLuckDrawByLuckDraw(userid string, luckdrawid string) (*model.TaLuckdrawRecord, error) {
850 909
 	var records []model.TaLuckdrawRecord
@@ -942,7 +1001,7 @@ func (m *LuckDrawDao) GetLuckDrawShareData(from, to, luckID, caseID string) ([]m
942 1001
 // UpdateShareNum 分享增加抽奖次数
943 1002
 func (m *LuckDrawDao) UpdateShareNum(luckdraw *LuckDraw, from string) error {
944 1003
 	num := strconv.Itoa(luckdraw.ShareAddNum)
945
-	sql := `update ta_luckdraw_customer set share_num=share_num+` + num + `,surplus_num = surplus_num+` + num + ` where luckdraw_id=? and customer_id=?`
1004
+	sql := `update ta_luckdraw_customer set share_num=share_num+` + num + `,share_surplus_num = share_surplus_num +` + num + ` ,surplus_num = surplus_num+` + num + ` where luckdraw_id=? and customer_id=?`
946 1005
 	_, err := m.db.Exec(sql, luckdraw.Id, from)
947 1006
 	return err
948 1007
 }

+ 1
- 0
models/model/ta_luckdraw_customer.go 查看文件

@@ -10,6 +10,7 @@ type TaLuckdrawCustomer struct {
10 10
 	CustomerId         string    `xorm:"VARCHAR(64)"`
11 11
 	IsNew              int       `xorm:"TINYINT(1)"`
12 12
 	ShareNum           int       `xorm:"INT(11)"`
13
+	ShareSurplusNum    int       `xorm:"INT(11)"`
13 14
 	SurplusNum         int       `xorm:"INT(11)"`
14 15
 	CreateDate         time.Time `xorm:"DATETIME"`
15 16
 }

+ 6
- 2
routers/common.go 查看文件

@@ -204,8 +204,11 @@ func getCommonRoutes(prefix string) beego.LinkNamespace {
204 204
 		beego.NSRouter("luckdraw/:luckdrawid", &luckdraw.LuckDrawController{}, "put:SaveLuckDraw"),
205 205
 		beego.NSRouter("luckdraw/:luckdrawid", &luckdraw.LuckDrawController{}, "delete:DelLuckDraw"),
206 206
 
207
-		beego.NSRouter("luckdraw/records/:luckdrawid", &luckdraw.LuckDrawController{}, "delete:GetLuckDrawRecordList"),
208
-		beego.NSRouter("luckdraw/share/:luckdrawid", &luckdraw.LuckDrawController{}, "delete:GetLuckDrawShareList"),
207
+		beego.NSRouter("luckdraw/:luckdrawid/open", &luckdraw.LuckDrawController{}, "put:OpenLuckDraw"),
208
+		beego.NSRouter("luckdraw/:luckdrawid/stop", &luckdraw.LuckDrawController{}, "put:StopLuckDraw"),
209
+
210
+		beego.NSRouter("luckdraw/records/:luckdrawid", &luckdraw.LuckDrawController{}, "get:GetLuckDrawRecordList"),
211
+		beego.NSRouter("luckdraw/share/:luckdrawid", &luckdraw.LuckDrawController{}, "get:GetLuckDrawShareList"),
209 212
 
210 213
 		// bodychecklist 体检列表
211 214
 		beego.NSRouter("bodychecklist", &bodychecklist.BodychecklistController{}, "get:GetBodyCheckList"),
@@ -330,5 +333,6 @@ func getCommonRoutes(prefix string) beego.LinkNamespace {
330 333
 		beego.NSRouter("/flashbuy/:flashBuyId/:flashBuyStatus", &flashbuy.FlashBuyController{}, "put:UpdateFlashBuy"),
331 334
 		beego.NSRouter("/flashbuy/:qrcode", &flashbuy.FlashBuyController{}, "get:VerifyCustomerFlashBuyList"),
332 335
 		beego.NSRouter("/flashbuy/:customerFlashBuyId", &flashbuy.FlashBuyController{}, "put:Verify"),
336
+		beego.NSRouter("/flashbuy/model", &flashbuy.FlashBuyController{}, "get:GetFlashModelList"),
333 337
 	)
334 338
 }

+ 3
- 0
routers/guest.go 查看文件

@@ -6,6 +6,7 @@ import (
6 6
 	"spaceofcheng/services/controllers/cases"
7 7
 	"spaceofcheng/services/controllers/course"
8 8
 	"spaceofcheng/services/controllers/customer"
9
+	"spaceofcheng/services/controllers/customerremark"
9 10
 	"spaceofcheng/services/controllers/goods"
10 11
 	"spaceofcheng/services/controllers/message"
11 12
 	"spaceofcheng/services/controllers/user"
@@ -66,5 +67,7 @@ func getGuestRoutes(prefix string) beego.LinkNamespace {
66 67
 		beego.NSRouter("/case/checkin", &cases.SigninController{}, "post:AddSignin"),
67 68
 		beego.NSRouter("/wechat", &controllers.WechatController{}, "get,post:WechatInfo"),
68 69
 		// beego.NSRouter("/wechat", &controllers.WechatController{}, "post:WxReceive"),
70
+
71
+		beego.NSRouter("/customerremark/:recommendCode", &customerremark.CustomerRemarkController{}, "get:IsExist"),
69 72
 	)
70 73
 }

+ 4
- 4
routers/wechat.go 查看文件

@@ -95,15 +95,15 @@ func getWechatRoutes(prefix string) beego.LinkNamespace {
95 95
 		beego.NSRouter("/user/luckdraw/record/:id", &luckdraw.LuckDrawController{}, "get:GetRecordByID"),
96 96
 
97 97
 		// 抢购
98
-		beego.NSRouter("/flashbuy/:flashBuyId", &flashbuy.FlashBuyController{}, "get:GetFlashBuyById"),
99
-		beego.NSRouter("/flashbuy/:customerId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyByCustomerId"),
100
-		beego.NSRouter("/flashbuy/:customerFlashBuyId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyId"),
98
+		beego.NSRouter("/flashbuy/flash/:flashBuyId", &flashbuy.FlashBuyController{}, "get:GetFlashBuyById"),
99
+		beego.NSRouter("/flashbuy/customer/:customerId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyByCustomerId"),
100
+		beego.NSRouter("/flashbuy/customerFlash/:customerFlashBuyId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyId"),
101 101
 		beego.NSRouter("/flashbuy/:id", &flashbuy.FlashBuyController{}, "post:FlashBuy"),
102 102
 
103 103
 		// 客户备注
104 104
 		beego.NSRouter("/customerremark/record/:salesId/:customerId", &customerremark.CustomerRemarkController{}, "get:GetCustomerReceiveRecord"),
105 105
 		beego.NSRouter("/customerremark/:salesId/:customerId", &customerremark.CustomerRemarkController{}, "get:GetCustomerRemarkList"),
106
-		beego.NSRouter("/customerremark/:salesId/:customerInfo", &customerremark.CustomerRemarkController{}, "get:SearchCustomer"),
106
+		beego.NSRouter("/customerremark/search/:salesId/:customerInfo", &customerremark.CustomerRemarkController{}, "get:SearchCustomer"),
107 107
 		beego.NSRouter("/customerremark", &customerremark.CustomerRemarkController{}, "post:AddRemark"),
108 108
 	)
109 109
 }

+ 8
- 0
service/customerremark/customerremark.go 查看文件

@@ -80,3 +80,11 @@ func (s *CustomerRemarkServ) SearchCustomer(customerInfo, salesId string) (*mode
80 80
 	}
81 81
 	return &customer, nil
82 82
 }
83
+func (s *CustomerRemarkServ) IsExist(recommendCode string) (int, error) {
84
+	num, err := s.dao.IsExist(recommendCode)
85
+	if err != nil {
86
+		utils.LogError("获取推荐人失败: " + err.Error())
87
+		return 0, errors.New("获取推荐人失败")
88
+	}
89
+	return num, nil
90
+}

+ 1
- 1
service/events/giveCard.go 查看文件

@@ -56,7 +56,7 @@ var giveCard = func(e tinyevent.Event) error {
56 56
 		case ActGiveCoupon:
57 57
 			res := make(map[string]interface{})
58 58
 			if err := json.Unmarshal([]byte(act.ResourceDesc), &res); err != nil {
59
-				utils.LogError("解析优惠券赠送规则失败: " + err.Error())
59
+				utils.LogError("解析体验卡赠送规则失败: " + err.Error())
60 60
 				continue
61 61
 			}
62 62
 

+ 9
- 0
service/flashbuy/flashbuy.go 查看文件

@@ -251,3 +251,12 @@ func (s *FlashBuyServ) FlashBuy(id string) error {
251 251
 
252 252
 	return nil
253 253
 }
254
+
255
+func (s *FlashBuyServ) GetFlashModelList() ([]model.TdFlashbuyModel, error) {
256
+	model, err := s.dao.GetFlashModelList()
257
+	if err != nil {
258
+		utils.LogError("获取抢购活动模板失败: " + err.Error())
259
+		return nil, errors.New("获取抢购活动模板失败")
260
+	}
261
+	return model, nil
262
+}

+ 15
- 2
service/luckdraw/luckdraw.go 查看文件

@@ -166,6 +166,12 @@ func (s *LuckdrawServ) SaveLuckDraw(luckdraw *luckdraw.LuckDrawInfo) (*model.TaL
166 166
 				utils.LogError("更新抽奖信息失败: " + err.Error())
167 167
 				return nil, errors.New("更新抽奖信息失败")
168 168
 			}
169
+
170
+			err = s.dao.UpdatePrizeDesc(luckdraw.Prizes)
171
+			if err != nil {
172
+				utils.LogError("更新抽奖信息失败: " + err.Error())
173
+				return nil, errors.New("更新抽奖信息失败")
174
+			}
169 175
 			return &luckdraw.TaLuckdraw, nil
170 176
 		}
171 177
 		var cols = []string{
@@ -460,8 +466,15 @@ func (s *LuckdrawServ) GetUserRecordByLuckDraw(userid string, luckdrawid string)
460 466
 	return record, nil
461 467
 }
462 468
 
463
-func (s *LuckdrawServ) GetUserLuckDrawByLuckDraw(userid string, luckdrawid string) (*model.TaLuckdrawRecord, error) {
464
-	record, err := s.dao.GetUserLuckDrawByLuckDraw(userid, luckdrawid)
469
+// GetUserLuckDrawByLuckDraw 获取用户抽奖信息
470
+func (s *LuckdrawServ) GetUserLuckDrawByLuckDraw(user model.TaCustomer, luckdrawid string) (*model.TaLuckdrawRecord, error) {
471
+	// 获取用户抽奖设置信息
472
+	_, err := s.dao.GetUserLuckDrawSet(user, luckdrawid)
473
+	if err != nil {
474
+		utils.LogError("获取用户抽奖设置失败: " + err.Error())
475
+		return nil, errors.New("获取用户抽奖设置失败")
476
+	}
477
+	record, err := s.dao.GetUserLuckDrawByLuckDraw(user.CustomerId, luckdrawid)
465 478
 	if err != nil {
466 479
 		utils.LogError("获取用户的抽奖信息失败: " + err.Error())
467 480
 		return nil, errors.New("获取用户的抽奖信息失败")