Browse Source

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

zjxpcyc 6 years ago
parent
commit
2ed76be81f

+ 9
- 0
controllers/card/card.go View File

@@ -266,3 +266,12 @@ func (c *CardController) GetCustomerCardByCustomerAndSale() {
266 266
 	}
267 267
 	c.ResponseJSON(cards)
268 268
 }
269
+
270
+func (c *CardController) GetSysCardList() {
271
+	caseid := c.GetString(":caseId")
272
+	cards, err := c.serv.GetSysCardList(caseid)
273
+	if err != nil {
274
+		c.ResponseError(err)
275
+	}
276
+	c.ResponseJSON(cards)
277
+}

+ 25
- 3
controllers/flashbuy/flashbuy.go View File

@@ -35,9 +35,20 @@ func (c *FlashBuyController) GetFlashBuyList() {
35 35
 	c.ResponseJSON(list)
36 36
 }
37 37
 
38
+func (c *FlashBuyController) GetCustomerFlashBuyByCustomerId() {
39
+	customerId := c.GetString(":customerId")
40
+	page, _ := c.GetInt("page")
41
+	pageSize, _ := c.GetInt("pagesize")
42
+	list, err := c.dao.GetCustomerFlashBuyByCustomerId(customerId, page, pageSize)
43
+	if err != nil {
44
+		c.ResponseError(err)
45
+	}
46
+	c.ResponseJSON(list)
47
+}
48
+
38 49
 func (c *FlashBuyController) GetCustomerFlashBuyList() {
39 50
 	flashBuyId := c.GetString(":flashBuyId")
40
-	phone := c.GetString(":phone")
51
+	phone := c.GetString("phone")
41 52
 	page, _ := c.GetInt("page")
42 53
 	pageSize, _ := c.GetInt("pagesize")
43 54
 	list, err := c.dao.GetCustomerFlashBuyById(flashBuyId, phone, page, pageSize)
@@ -57,6 +68,15 @@ func (c *FlashBuyController) GetFlashBuyById() {
57 68
 	c.ResponseJSON(flashBuy)
58 69
 }
59 70
 
71
+func (c *FlashBuyController) GetCustomerFlashBuyId() {
72
+	flashBuyId := c.GetString(":customerFlashBuyId")
73
+	flashBuy, err := c.dao.GetCustomerFlashBuyId(flashBuyId)
74
+	if err != nil {
75
+		c.ResponseError(err)
76
+	}
77
+	c.ResponseJSON(flashBuy)
78
+}
79
+
60 80
 func (c *FlashBuyController) SaveFlashBuy() {
61 81
 	flashbuy := model.TaFlashBuy{}
62 82
 	if err := c.ParseForm(&flashbuy); err != nil {
@@ -80,7 +100,7 @@ func (c *FlashBuyController) DeleteFlashBuy() {
80 100
 
81 101
 func (c *FlashBuyController) UpdateFlashBuy() {
82 102
 	flashBuyId := c.GetString(":flashBuyId")
83
-	flashBuyStatus := c.GetString("flashBuyStatus")
103
+	flashBuyStatus := c.GetString(":flashBuyStatus")
84 104
 	err := c.dao.UpdateFlashBuy(flashBuyId, flashBuyStatus)
85 105
 	if err != nil {
86 106
 		c.ResponseError(err)
@@ -90,7 +110,9 @@ func (c *FlashBuyController) UpdateFlashBuy() {
90 110
 
91 111
 func (c *FlashBuyController) VerifyCustomerFlashBuyList() {
92 112
 	qrcode := c.GetString(":qrcode")
93
-	customerFlashBuy, err := c.dao.VerifyCustomerFlashBuyList(qrcode)
113
+	cases := c.Context.Get("cases").([]model.SysUserCase)
114
+	caseids := c.GetCaseIDs(cases)
115
+	customerFlashBuy, err := c.dao.VerifyCustomerFlashBuyList(qrcode, caseids)
94 116
 	if err != nil {
95 117
 		c.ResponseError(err)
96 118
 	}

+ 10
- 0
controllers/marketing/marketing.go View File

@@ -116,3 +116,13 @@ func (c *MarketingController) SetMarketingDisable() {
116 116
 	}
117 117
 	c.ResponseJSON("操作成功!")
118 118
 }
119
+
120
+func (c *MarketingController) GetUserCases() {
121
+	cases := c.Context.Get("cases").([]model.SysUserCase)
122
+	caseIDs := c.GetCaseIDs(cases)
123
+	sysCase, err := c.serv.GetUserCases(caseIDs)
124
+	if err != nil {
125
+		c.ResponseError(err)
126
+	}
127
+	c.ResponseJSON(sysCase)
128
+}

+ 15
- 0
models/card/card.go View File

@@ -528,3 +528,18 @@ func (m *CardDAO) SaveCardChannel(channelid, cardid string) error {
528 528
 	_, err := m.db.Insert(&cardChannel)
529 529
 	return err
530 530
 }
531
+
532
+func (m *CardDAO) GetSysCardList(caseid string) ([]model.TaCouponCard, error) {
533
+	var card []model.TaCouponCard
534
+	sql := `SELECT
535
+	* 
536
+FROM
537
+	ta_coupon_card 
538
+WHERE
539
+	send_type = '` + models.GIVE_TYPE_SYSTEM + `'
540
+	and case_id = '` + caseid + `'
541
+	and  a.status > ` + strconv.Itoa(models.STATUS_DEL)
542
+	err := m.db.Sql(sql).Find(&card)
543
+	return card, err
544
+
545
+}

+ 1
- 1
models/customerremark/customerremark.go View File

@@ -55,7 +55,7 @@ WHERE
55 55
 }
56 56
 
57 57
 func (m *CustomerRemarkDAO) AddRemark(remark model.TaSaleCustomerRemark) (*model.TaSaleCustomerRemark, error) {
58
-	remark.SaleCustomerRemarkId = utils.GetGUID()
58
+	remark.SalesCustomerRemarkId = utils.GetGUID()
59 59
 	remark.CreateDate = time.Now()
60 60
 	remark.Status = models.STATUS_NORMAL
61 61
 	_, err := m.db.Insert(remark)

+ 50
- 2
models/flashbuy/flashbuy.go View File

@@ -35,6 +35,14 @@ type CustomerFlashBuy struct {
35 35
 	CustomerName             string
36 36
 	Phone                    string
37 37
 }
38
+type CustomerFlashResult struct {
39
+	model.TaCustomerFlashBuy `xorm:"extends"`
40
+	FlashBuyName             string
41
+}
42
+type CustomerFlashDetail struct {
43
+	model.TaCustomerFlashBuy `xorm:"extends"`
44
+	CustomerQrcode           string
45
+}
38 46
 
39 47
 func (m *FlashbuyDAO) GetFlashBuyList(caseid, flashBuyName, flashBuyStatus string, page, pageSize int) ([]FlashBuy, error) {
40 48
 	var flashBuy []FlashBuy
@@ -183,7 +191,7 @@ WHERE
183 191
 	return len(customerFlashBuy), err
184 192
 }
185 193
 
186
-func (m *FlashbuyDAO) GetCustomerFlashBuyByQr(customerFlashBuyId string) (*CustomerFlashBuy, error) {
194
+func (m *FlashbuyDAO) GetCustomerFlashBuyByQr(customerFlashBuyId, caseId string) (*CustomerFlashBuy, error) {
187 195
 	var customerFlashBuy []CustomerFlashBuy
188 196
 	sql := `SELECT
189 197
 	a.*,
@@ -195,7 +203,7 @@ FROM
195 203
 	INNER JOIN ta_customer b ON a.customer_id = b.customer_id
196 204
 	INNER JOIN sys_case c ON a.case_id = c.case_id 
197 205
 WHERE
198
-	a.customer_flash_buy_id ='` + customerFlashBuyId + `'`
206
+	a.customer_flash_buy_id ='` + customerFlashBuyId + `' and a.case_id = '` + caseId + `'`
199 207
 	sql += ` and a.validate_start <= now() and a.validate_end >= now()`
200 208
 	err := m.db.Sql(sql).Find(&customerFlashBuy)
201 209
 	if len(customerFlashBuy) > 0 {
@@ -204,6 +212,46 @@ WHERE
204 212
 	return nil, nil
205 213
 }
206 214
 
215
+func (m *FlashbuyDAO) GetCustomerFlashBuyByCustomerId(customerId string, page, pageSize int) ([]CustomerFlashResult, error) {
216
+	var customerResult []CustomerFlashResult
217
+	sql := `select a.*,b.flash_buy_name
218
+	 from ta_customer_flash_buy a 
219
+	 inner join ta_flash_buy b 
220
+	 on a.flash_buy_id = b.flash_buy_id
221
+	 where a.customer_id = '` + customerId + `'`
222
+	sql += ` order by a.validate_start desc  limit ` + strconv.Itoa(page-1) + `, ` + strconv.Itoa(pageSize)
223
+	err := m.db.Sql(sql).Find(&customerResult)
224
+	return customerResult, err
225
+
226
+}
227
+
228
+func (m *FlashbuyDAO) GetCustomerFlashBuyByCustomerIdCount(customerId string) (int, error) {
229
+	var customerResult []CustomerFlashResult
230
+	sql := `select a.*,b.flash_buy_name
231
+	 from ta_customer_flash_buy a 
232
+	 inner join ta_flash_buy b 
233
+	 on a.flash_buy_id = b.flash_buy_id
234
+	 where a.customer_id = '` + customerId + `'`
235
+	err := m.db.Sql(sql).Find(&customerResult)
236
+	return len(customerResult), err
237
+
238
+}
239
+
240
+func (m *FlashbuyDAO) GetCustomerFlashBuyId(customerFlashBuyId string) (*CustomerFlashDetail, error) {
241
+	var customerDetail CustomerFlashDetail
242
+	sql := `SELECT
243
+	a.*,
244
+	b.customer_qrcode 
245
+FROM
246
+	ta_customer_flash_buy a
247
+	INNER JOIN ta_customer_course_qrcode b ON a.customer_flash_buy_id = b.customer_course_id
248
+	WHERE a.customer_flash_buy_id = '` + customerFlashBuyId + `'`
249
+	err := m.db.Sql(sql).Find(&customerDetail)
250
+	return &customerDetail, err
251
+
252
+}
253
+
254
+// Update
207 255
 // GetCustomerFlashBuy 获取用户抢购信息
208 256
 func (m *FlashbuyDAO) GetCustomerFlashBuy(id, customerid string) ([]model.TaCustomerFlashBuy, error) {
209 257
 	var buys []model.TaCustomerFlashBuy

+ 2
- 0
models/luckdrawlist/luckdrawlist.go View File

@@ -102,6 +102,8 @@ FROM
102 102
 WHERE
103 103
 	 DATE_FORMAT( e.verification_start, '%Y-%m-%d' ) <= DATE_FORMAT( NOW( ), '%Y-%m-%d' )
104 104
 	 AND DATE_FORMAT( e.verification_end, '%Y-%m-%d' ) >= DATE_FORMAT( NOW( ), '%Y-%m-%d' )
105
+	 AND DATE_FORMAT( a.verification_start, '%Y-%m-%d' ) <= DATE_FORMAT( NOW( ), '%Y-%m-%d' )
106
+	 AND DATE_FORMAT( a.verification_end, '%Y-%m-%d' ) >= DATE_FORMAT( NOW( ), '%Y-%m-%d' )
105 107
 	 AND a.id = '` + luckdrawId + `'
106 108
 	 and b.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
107 109
 	err := m.db.Sql(sql).Find(&luckdraw)

+ 11
- 0
models/marketing/marketing.go View File

@@ -136,3 +136,14 @@ func (m *MarketingDAO) UpdateMarketing(activity model.SysActivity) error {
136 136
 	_, err := m.db.Cols(cols...).Where("action_id=?", activity.ActivityId).Update(activity)
137 137
 	return err
138 138
 }
139
+
140
+func (m *MarketingDAO) GetUserCases(caseid string) ([]model.SysCase, error) {
141
+	var cases []model.SysCase
142
+	sql := `SELECT
143
+	* 
144
+FROM
145
+	sys_case 
146
+WHERE case_id in ('` + strings.Replace(caseid, ",", "','", -1) + `')`
147
+	err := m.db.Sql(sql).Find(&cases)
148
+	return cases, err
149
+}

+ 6
- 6
models/model/ta_sale_customer_remark.go View File

@@ -5,10 +5,10 @@ import (
5 5
 )
6 6
 
7 7
 type TaSaleCustomerRemark struct {
8
-	SalesCustomerRemark string    `xorm:"not null VARCHAR(64)"`
9
-	SaleCustomerId      string    `xorm:"VARCHAR(64)"`
10
-	RemarkTitle         string    `xorm:"VARCHAR(256)"`
11
-	Remark              string    `xorm:"TEXT"`
12
-	CreateDate          time.Time `xorm:"DATETIME"`
13
-	Status              int       `xorm:"SMALLINT(6)"`
8
+	SalesCustomerRemarkId string    `xorm:"not null VARCHAR(64)"`
9
+	SaleCustomerId        string    `xorm:"VARCHAR(64)"`
10
+	RemarkTitle           string    `xorm:"VARCHAR(256)"`
11
+	Remark                string    `xorm:"TEXT"`
12
+	CreateDate            time.Time `xorm:"DATETIME"`
13
+	Status                int       `xorm:"SMALLINT(6)"`
14 14
 }

+ 2
- 0
routers/common.go View File

@@ -277,6 +277,7 @@ func getCommonRoutes(prefix string) beego.LinkNamespace {
277 277
 		beego.NSRouter("/card/:id", &card.CardController{}, "get:GetCardByIDForAdmin"),
278 278
 		beego.NSRouter("/card/:id", &card.CardController{}, "put:UpdateCard"),
279 279
 		beego.NSRouter("/card/:id/to/:users", &card.CardController{}, "post:GiveCard"),
280
+		beego.NSRouter("/card/:caseId", &card.CardController{}, "get:GetSysCardList"),
280 281
 		// 赠送记录
281 282
 		beego.NSRouter("/record", &card.RecordController{}, "get:GetRecordList"),
282 283
 
@@ -298,6 +299,7 @@ func getCommonRoutes(prefix string) beego.LinkNamespace {
298 299
 		beego.NSRouter("/marketing/normal/:activityId", &marketing.MarketingController{}, "put:SetMarketingNormal"),
299 300
 		beego.NSRouter("/marketing/disable/:activityId", &marketing.MarketingController{}, "put:SetMarketingDisable"),
300 301
 		beego.NSRouter("/marketing/:activityId", &marketing.MarketingController{}, "delete:DelMarketing"),
302
+		beego.NSRouter("/marketing/case", &marketing.MarketingController{}, "get:GetUserCases"),
301 303
 
302 304
 		// websocket
303 305
 		beego.NSRouter("/websocket/:grps/:id", &controllers.BaseController{}, "get:Ws"),

+ 10
- 0
routers/wechat.go View File

@@ -7,6 +7,7 @@ import (
7 7
 	"spaceofcheng/services/controllers/coupon"
8 8
 	"spaceofcheng/services/controllers/course"
9 9
 	"spaceofcheng/services/controllers/customer"
10
+	"spaceofcheng/services/controllers/customerremark"
10 11
 	"spaceofcheng/services/controllers/flashbuy"
11 12
 	"spaceofcheng/services/controllers/goods"
12 13
 	"spaceofcheng/services/controllers/gymcard"
@@ -94,6 +95,15 @@ func getWechatRoutes(prefix string) beego.LinkNamespace {
94 95
 		beego.NSRouter("/user/luckdraw/record/:id", &luckdraw.LuckDrawController{}, "get:GetRecordByID"),
95 96
 
96 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"),
97 101
 		beego.NSRouter("/flashbuy/:id", &flashbuy.FlashBuyController{}, "post:FlashBuy"),
102
+
103
+		// 客户备注
104
+		beego.NSRouter("/customerremark/record/:salesId/:customerId", &customerremark.CustomerRemarkController{}, "get:GetCustomerReceiveRecord"),
105
+		beego.NSRouter("/customerremark/:salesId/:customerId", &customerremark.CustomerRemarkController{}, "get:GetCustomerRemarkList"),
106
+		beego.NSRouter("/customerremark/:salesId/:customerInfo", &customerremark.CustomerRemarkController{}, "get:SearchCustomer"),
107
+		beego.NSRouter("/customerremark", &customerremark.CustomerRemarkController{}, "post:AddRemark"),
98 108
 	)
99 109
 }

+ 9
- 0
service/card/card.go View File

@@ -392,6 +392,15 @@ func (s *CardServ) GetCustomerCardByID(id string) (*card.CustomerCardWithShare,
392 392
 	return card, nil
393 393
 }
394 394
 
395
+func (s *CardServ) GetSysCardList(caseid string) ([]model.TaCouponCard, error) {
396
+	cards, err := s.dao.GetSysCardList(caseid)
397
+	if err != nil {
398
+		utils.LogError("获取体验卡失败: " + err.Error())
399
+		return nil, errors.New("获取体验卡失败")
400
+	}
401
+	return cards, nil
402
+}
403
+
395 404
 // GetCaseUsableCard 获取案场可用卡
396 405
 func (s *CardServ) GetCaseUsableCard(page, pageSize int) (map[string]interface{}, error) {
397 406
 

+ 1
- 0
service/events/constant.go View File

@@ -13,4 +13,5 @@ const (
13 13
 
14 14
 	// 送券
15 15
 	ActGiveCoupon = "giveCoupon"
16
+	ActGiveCard   = "giveCard"
16 17
 )

+ 2
- 0
service/events/events.go View File

@@ -19,6 +19,8 @@ var EvtActions = map[string]tinyevent.Action{
19 19
 
20 20
 	// 赠送卡券
21 21
 	ActGiveCoupon: giveCoupon,
22
+
23
+	ActGiveCard: giveCard,
22 24
 }
23 25
 
24 26
 // ListenAllEvent 监听所有事件

+ 83
- 0
service/events/giveCard.go View File

@@ -0,0 +1,83 @@
1
+package events
2
+
3
+import (
4
+	"encoding/json"
5
+	"errors"
6
+	"spaceofcheng/services/models"
7
+	"spaceofcheng/services/models/model"
8
+	"spaceofcheng/services/service/card"
9
+	"spaceofcheng/services/utils"
10
+
11
+	"github.com/zjxpcyc/tinyevent"
12
+)
13
+
14
+var giveCard = func(e tinyevent.Event) error {
15
+	utils.LogInfo("开始卡券赠送操作...")
16
+
17
+	ctx := NewContext()
18
+	defer DestroyContext(ctx, false)
19
+
20
+	if e.Payload == nil {
21
+		utils.LogError("注册送券失败, 没有用户信息")
22
+		return errors.New("注册送券失败, 没有用户信息")
23
+	}
24
+	cust := e.Payload.(model.TaCustomer)
25
+	caseID := cust.RecommendCase
26
+	orgID := cust.OrgId
27
+
28
+	utils.LogInfo("被赠送人: " + cust.CustomerId)
29
+	query := `
30
+		SELECT
31
+			t.*
32
+		FROM
33
+			sys_activity_action t
34
+		JOIN sys_activity s ON t.activity_id = s.activity_id
35
+		WHERE
36
+		t.active_type = 'giveCard'
37
+		AND	s.org_id = ?
38
+		AND s.case_id = ?
39
+		AND s.status = ?
40
+		AND s.activity_type = ?
41
+	`
42
+
43
+	var acts []model.SysActivityAction
44
+	if err := models.DBEngine.SQL(query, orgID, caseID, models.STATUS_NORMAL, e.Name).Find(&acts); err != nil {
45
+		utils.LogError("检查营销活动失败: " + err.Error())
46
+		return errors.New("检查营销活动失败")
47
+	}
48
+
49
+	fromUser := model.SysUser{
50
+		UserId:   "SYSTEM",
51
+		UserName: "system",
52
+	}
53
+	cpServ := card.NewCardServ(ctx)
54
+	for _, act := range acts {
55
+		switch act.ActiveType {
56
+		case ActGiveCoupon:
57
+			res := make(map[string]interface{})
58
+			if err := json.Unmarshal([]byte(act.ResourceDesc), &res); err != nil {
59
+				utils.LogError("解析优惠券赠送规则失败: " + err.Error())
60
+				continue
61
+			}
62
+
63
+			cpID, has := res["giftValue"]
64
+			if !has {
65
+				continue
66
+			}
67
+
68
+			cp, err := cpServ.GetCardByID(cpID.(string))
69
+			if err != nil {
70
+				utils.LogError("获取优惠券失败: " + err.Error())
71
+				continue
72
+			}
73
+
74
+			if err := cpServ.GiveCardTo(&fromUser, &cust, cp); err != nil {
75
+				utils.LogError("送券失败: " + err.Error())
76
+				continue
77
+			}
78
+		default:
79
+			utils.LogError("暂不支持的赠送类型")
80
+		}
81
+	}
82
+	return nil
83
+}

+ 2
- 1
service/events/giveCoupon.go View File

@@ -37,7 +37,8 @@ var giveCoupon = func(e tinyevent.Event) error {
37 37
 			sys_activity_action t
38 38
 		JOIN sys_activity s ON t.activity_id = s.activity_id
39 39
 		WHERE
40
-			s.org_id = ?
40
+		t.active_type = 'giveCoupon'
41
+		AND	s.org_id = ?
41 42
 		AND s.case_id = ?
42 43
 		AND s.status = ?
43 44
 		AND s.activity_type = ?

+ 33
- 2
service/flashbuy/flashbuy.go View File

@@ -114,7 +114,7 @@ func (s *FlashBuyServ) GetCustomerFlashBuyById(flashBuyId, phone string, page, p
114 114
 	}, nil
115 115
 }
116 116
 
117
-func (s *FlashBuyServ) VerifyCustomerFlashBuyList(qrcode string) (*flashbuy.CustomerFlashBuy, error) {
117
+func (s *FlashBuyServ) VerifyCustomerFlashBuyList(qrcode, caseId string) (*flashbuy.CustomerFlashBuy, error) {
118 118
 	var err error
119 119
 	var customerFlashBuyId string
120 120
 	var customerVerify *flashbuy.CustomerFlashBuy
@@ -123,7 +123,7 @@ func (s *FlashBuyServ) VerifyCustomerFlashBuyList(qrcode string) (*flashbuy.Cust
123 123
 		utils.LogError("获取核销列表失败: " + err.Error())
124 124
 		return nil, errors.New("获取核销列表失败")
125 125
 	}
126
-	customerVerify, err = s.dao.GetCustomerFlashBuyByQr(customerFlashBuyId)
126
+	customerVerify, err = s.dao.GetCustomerFlashBuyByQr(customerFlashBuyId, caseId)
127 127
 	if err != nil {
128 128
 		utils.LogError("获取核销列表失败: " + err.Error())
129 129
 		return nil, errors.New("获取核销列表失败")
@@ -141,6 +141,37 @@ func (s *FlashBuyServ) Verify(customerFlashBuyId string) error {
141 141
 	return nil
142 142
 }
143 143
 
144
+func (s *FlashBuyServ) GetCustomerFlashBuyByCustomerId(customerId string, page, pageSize int) (map[string]interface{}, error) {
145
+	if pageSize == 0 {
146
+		pageSize = service.PAGENUM
147
+	}
148
+	flashbuys, err := s.dao.GetCustomerFlashBuyByCustomerId(customerId, page, pageSize)
149
+	if err != nil {
150
+		utils.LogError("获取抢购活动列表失败: " + err.Error())
151
+		return nil, errors.New("获取抢购活动列表失败")
152
+	}
153
+	total, err := s.dao.GetCustomerFlashBuyByCustomerIdCount(customerId)
154
+	if err != nil {
155
+		utils.LogError("获取抢购活动列表失败: " + err.Error())
156
+		return nil, errors.New("获取抢购活动列表失败")
157
+	}
158
+	return map[string]interface{}{
159
+		"list":     flashbuys,
160
+		"pageSize": pageSize,
161
+		"pagenum":  total,
162
+		"page":     page,
163
+	}, nil
164
+}
165
+
166
+func (s *FlashBuyServ) GetCustomerFlashBuyId(customerFlashBuyId string) (*flashbuy.CustomerFlashDetail, error) {
167
+	flashbuy, err := s.dao.GetCustomerFlashBuyId(customerFlashBuyId)
168
+	if err != nil {
169
+		utils.LogError("获取抢购活动信息失败: " + err.Error())
170
+		return nil, errors.New("获取抢购活动信息失败")
171
+	}
172
+	return flashbuy, nil
173
+}
174
+
144 175
 // FlashBuy 抢购
145 176
 func (s *FlashBuyServ) FlashBuy(id string) error {
146 177
 	flashbuy, err := s.dao.GetFlashBuyById(id)

+ 18
- 0
service/marketing/marketing.go View File

@@ -4,6 +4,7 @@ import (
4 4
 	"encoding/json"
5 5
 	"errors"
6 6
 	"spaceofcheng/services/models"
7
+	"spaceofcheng/services/models/card"
7 8
 	"spaceofcheng/services/models/coupon"
8 9
 	"spaceofcheng/services/models/marketing"
9 10
 	"spaceofcheng/services/models/model"
@@ -22,6 +23,7 @@ type MarketingServ struct {
22 23
 	wdao      *marketing.WorkDAO
23 24
 	userdao   *system.UserDAO
24 25
 	couponDAO *coupon.CouponDAO
26
+	cardDAO   *card.CardDAO
25 27
 }
26 28
 
27 29
 // NewMarketingServ 初始化
@@ -32,6 +34,7 @@ func NewMarketingServ(ctx *utils.Context) *MarketingServ {
32 34
 		wdao:      marketing.NewWorkDAO(ctx),
33 35
 		userdao:   system.NewUserDAO(ctx),
34 36
 		couponDAO: coupon.NewCouponDAO(ctx),
37
+		cardDAO:   card.NewCardDAO(ctx),
35 38
 	}
36 39
 }
37 40
 
@@ -96,6 +99,12 @@ func (s *MarketingServ) SaveMarketing(activity model.SysActivity, activeType, re
96 99
 		// 	return nil, nil, errors.New("赠送数量不能大于卡券总数的数量")
97 100
 		// }
98 101
 	}
102
+	if activeType == events.ActGiveCard {
103
+		cardID := res["giftValue"].(string)
104
+		if cardID == "" {
105
+			return nil, nil, errors.New("未指定赠送券内容")
106
+		}
107
+	}
99 108
 
100 109
 	var newInfo *model.SysActivity
101 110
 	var newWoke *model.SysActivityAction
@@ -225,3 +234,12 @@ func (s *MarketingServ) UpdateMarketing(activity model.SysActivity) error {
225 234
 	err := s.dao.UpdateMarketing(activity)
226 235
 	return err
227 236
 }
237
+
238
+func (s *MarketingServ) GetUserCases(caseId string) ([]model.SysCase, error) {
239
+	cases, err := s.dao.GetUserCases(caseId)
240
+	if err != nil {
241
+		utils.LogError("获取用户案场失败: " + err.Error())
242
+		return nil, errors.New("获取用户案场失败")
243
+	}
244
+	return cases, nil
245
+}