胡轶钦 6 lat temu
rodzic
commit
e7b318dedd

+ 9
- 0
controllers/coupon/coupon.go Wyświetl plik

@@ -280,3 +280,12 @@ func (c *CouponController) GetCustomerCouponByCustomerAndSale() {
280 280
 	}
281 281
 	c.ResponseJSON(Coupons)
282 282
 }
283
+
284
+func (c *CouponController) GetSysCouponByCase() {
285
+	caseId := c.GetString(":caseId")
286
+	coupon, err := c.serv.GetSysCouponByCase(caseId)
287
+	if err != nil {
288
+		c.ResponseError(err)
289
+	}
290
+	c.ResponseJSON(coupon)
291
+}

+ 0
- 3
controllers/flashbuy/flashbuy.go Wyświetl plik

@@ -7,8 +7,6 @@ import (
7 7
 	"spaceofcheng/services/models/model"
8 8
 	"spaceofcheng/services/service/flashbuy"
9 9
 	"spaceofcheng/services/utils"
10
-
11
-	"github.com/astaxie/beego"
12 10
 )
13 11
 
14 12
 // CaseController 信息
@@ -31,7 +29,6 @@ func (c *FlashBuyController) GetFlashBuyList() {
31 29
 	}
32 30
 	flashBuyName := c.GetString("flashbuyname")
33 31
 	flashBuyStatus := c.GetString("flashbuystatus")
34
-	beego.Error(flashBuyStatus)
35 32
 	page, _ := c.GetInt("page")
36 33
 	pageSize, _ := c.GetInt("pagesize")
37 34
 	list, err := c.dao.GetFlashBuyList(caseIDs, flashBuyName, flashBuyStatus, page, pageSize)

+ 2
- 0
controllers/marketing/marketing.go Wyświetl plik

@@ -43,10 +43,12 @@ func (c *MarketingController) SaveMarketing() {
43 43
 	activityType := c.GetString("activityType")
44 44
 	activeType := c.GetString("activeType")
45 45
 	resourceDesc := c.GetString("resourceDesc") // 活动描述
46
+	caseId := c.GetString("CaseId")
46 47
 
47 48
 	// 赋值
48 49
 	marketing.ActivityName = activityName
49 50
 	marketing.ActivityType = activityType
51
+	marketing.CaseId = caseId
50 52
 
51 53
 	newInfo, _, err := c.serv.SaveMarketing(marketing, activeType, resourceDesc)
52 54
 	if err != nil {

+ 1
- 1
models/card/card.go Wyświetl plik

@@ -538,7 +538,7 @@ FROM
538 538
 WHERE
539 539
 	send_type = '` + models.GIVE_TYPE_SYSTEM + `'
540 540
 	and case_id = '` + caseid + `'
541
-	and  a.status > ` + strconv.Itoa(models.STATUS_DEL)
541
+	and  status > ` + strconv.Itoa(models.STATUS_DEL)
542 542
 	err := m.db.Sql(sql).Find(&card)
543 543
 	return card, err
544 544
 

+ 14
- 0
models/coupon/coupon.go Wyświetl plik

@@ -586,3 +586,17 @@ func (m *CouponDAO) SaveCouponChannel(channelid, couponid string) error {
586 586
 	_, err := m.db.Insert(&couponChannel)
587 587
 	return err
588 588
 }
589
+
590
+func (m *CouponDAO) GetSysCouponByCase(caseid string) ([]model.TaCoupon, error) {
591
+	var coupon []model.TaCoupon
592
+	sql := `SELECT
593
+	* 
594
+FROM
595
+	ta_coupon 
596
+WHERE
597
+	send_type = '` + models.GIVE_TYPE_SYSTEM + `'
598
+	and case_id = '` + caseid + `'
599
+	and status > ` + strconv.Itoa(models.STATUS_DEL)
600
+	err := m.db.Sql(sql).Find(&coupon)
601
+	return coupon, err
602
+}

+ 4
- 7
models/flashbuy/flashbuy.go Wyświetl plik

@@ -8,8 +8,6 @@ import (
8 8
 	"strings"
9 9
 	"time"
10 10
 
11
-	"github.com/astaxie/beego"
12
-
13 11
 	"github.com/go-xorm/xorm"
14 12
 )
15 13
 
@@ -57,13 +55,12 @@ FROM
57 55
 	Where a.status > ` + strconv.Itoa(models.STATUS_DEL) + `
58 56
 	and a.case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')`
59 57
 	if flashBuyName != "" {
60
-		sql += ` and a.flash_buy_name = '` + flashBuyName + `' `
58
+		sql += ` and a.flash_buy_name like '%` + flashBuyName + `%'`
61 59
 	}
62 60
 	if flashBuyStatus != "" {
63 61
 		sql += ` and a.flash_buy_status ='` + flashBuyStatus + `'`
64 62
 	}
65 63
 	sql += ` order by a.start_date desc limit ` + strconv.Itoa(page-1) + `, ` + strconv.Itoa(pageSize)
66
-	beego.Error(sql)
67 64
 	err := m.db.Sql(sql).Find(&flashBuy)
68 65
 	return flashBuy, err
69 66
 }
@@ -77,7 +74,7 @@ FROM
77 74
 	Where a.status > ` + strconv.Itoa(models.STATUS_DEL) + `
78 75
 	and a.case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')`
79 76
 	if flashBuyName != "" {
80
-		sql += ` and a.flash_buy_name = '` + flashBuyName + `' `
77
+		sql += ` and a.flash_buy_name like '%` + flashBuyName + `%'`
81 78
 	}
82 79
 	if flashBuyStatus != "" {
83 80
 		sql += ` and a.flash_buy_status ='` + flashBuyStatus + `'`
@@ -166,7 +163,7 @@ WHERE
166 163
 	a.flash_buy_id = '` + flashBuyId + `' 
167 164
 	and a.status >` + strconv.Itoa(models.STATUS_DEL)
168 165
 	if phone != "" {
169
-		sql += ` and b.phone = '` + phone + `'`
166
+		sql += ` and b.phone like '%` + phone + `%'`
170 167
 	}
171 168
 	sql += ` order by a.create_date desc  limit ` + strconv.Itoa(page-1) + `, ` + strconv.Itoa(pageSize)
172 169
 	err := m.db.Sql(sql).Find(&customerFlashBuy)
@@ -188,7 +185,7 @@ WHERE
188 185
 	a.flash_buy_id = '` + flashBuyId + `' 
189 186
 	and a.status >` + strconv.Itoa(models.STATUS_DEL)
190 187
 	if phone != "" {
191
-		sql += ` and b.phone = '` + phone + `'`
188
+		sql += ` and b.phone like '%` + phone + `%'`
192 189
 	}
193 190
 	err := m.db.Sql(sql).Find(&customerFlashBuy)
194 191
 	return len(customerFlashBuy), err

+ 3
- 2
routers/common.go Wyświetl plik

@@ -269,6 +269,7 @@ func getCommonRoutes(prefix string) beego.LinkNamespace {
269 269
 		beego.NSRouter("/coupon/:id", &coupon.CouponController{}, "put:UpdateCoupon"),
270 270
 		beego.NSRouter("/coupon/:id/to/:users", &coupon.CouponController{}, "post:GiveCoupon"),
271 271
 		beego.NSRouter("/coupon/type/:type", &coupon.CouponController{}, "get:GetCouponBySendType"),
272
+		beego.NSRouter("/coupon/sys/:caseId", &coupon.CouponController{}, "get:GetSysCouponByCase"),
272 273
 
273 274
 		// 签到
274 275
 		beego.NSRouter("/case/signin", &cases.SigninController{}, "get:GetSigninWhere"),
@@ -280,7 +281,7 @@ func getCommonRoutes(prefix string) beego.LinkNamespace {
280 281
 		beego.NSRouter("/card/:id", &card.CardController{}, "get:GetCardByIDForAdmin"),
281 282
 		beego.NSRouter("/card/:id", &card.CardController{}, "put:UpdateCard"),
282 283
 		beego.NSRouter("/card/:id/to/:users", &card.CardController{}, "post:GiveCard"),
283
-		beego.NSRouter("/card/:caseId", &card.CardController{}, "get:GetSysCardList"),
284
+		beego.NSRouter("/card/sys/:caseId", &card.CardController{}, "get:GetSysCardList"),
284 285
 		// 赠送记录
285 286
 		beego.NSRouter("/record", &card.RecordController{}, "get:GetRecordList"),
286 287
 
@@ -329,7 +330,7 @@ func getCommonRoutes(prefix string) beego.LinkNamespace {
329 330
 		beego.NSRouter("/flashbuy/:flashBuyId", &flashbuy.FlashBuyController{}, "get:GetFlashBuyById"),
330 331
 		beego.NSRouter("/flashbuy", &flashbuy.FlashBuyController{}, "post:SaveFlashBuy"),
331 332
 		beego.NSRouter("/flashbuy/edit", &flashbuy.FlashBuyController{}, "put:SaveFlashBuy"),
332
-		beego.NSRouter("/flashbuy/:channelId", &flashbuy.FlashBuyController{}, "delete:DeleteFlashBuy"),
333
+		beego.NSRouter("/flashbuy/:flashBuyId", &flashbuy.FlashBuyController{}, "delete:DeleteFlashBuy"),
333 334
 		beego.NSRouter("/flashbuy/:flashBuyId/:flashBuyStatus", &flashbuy.FlashBuyController{}, "put:UpdateFlashBuy"),
334 335
 		beego.NSRouter("/flashbuy/:qrcode", &flashbuy.FlashBuyController{}, "get:VerifyCustomerFlashBuyList"),
335 336
 		beego.NSRouter("/flashbuy/:customerFlashBuyId", &flashbuy.FlashBuyController{}, "put:Verify"),

+ 9
- 0
service/coupon/coupon.go Wyświetl plik

@@ -691,3 +691,12 @@ func (s *CouponServ) GetCustomerCouponByCustomerAndSale(customerid string, page,
691 691
 		"page":     page,
692 692
 	}, nil
693 693
 }
694
+
695
+func (s *CouponServ) GetSysCouponByCase(caseid string) ([]model.TaCoupon, error) {
696
+	coupon, err := s.dao.GetSysCouponByCase(caseid)
697
+	if err != nil {
698
+		utils.LogError("获取系统赠送券失败: " + err.Error())
699
+		return nil, errors.New("获取系统赠送券失败")
700
+	}
701
+	return coupon, nil
702
+}

+ 12
- 0
service/flashbuy/flashbuy.go Wyświetl plik

@@ -62,6 +62,18 @@ func (s *FlashBuyServ) GetFlashBuyById(flashBuyId string) (*model.TaFlashBuy, er
62 62
 func (s *FlashBuyServ) SaveFlashBuy(flashbuy model.TaFlashBuy) (*model.TaFlashBuy, error) {
63 63
 	var newFlashBuy *model.TaFlashBuy
64 64
 	var err error
65
+	if flashbuy.CaseId == "" {
66
+		return nil, utils.LogError("请选择所属案场!")
67
+	}
68
+	if flashbuy.FlashBuyName == "" {
69
+		return nil, utils.LogError("请输入活动标题!")
70
+	}
71
+	if flashbuy.FlashBuyInfo == "" {
72
+		return nil, utils.LogError("请输入活动描述!")
73
+	}
74
+	if flashbuy.ModelId == "" {
75
+		return nil, utils.LogError("请选择活动模板!")
76
+	}
65 77
 	if flashbuy.FlashBuyId == "" {
66 78
 		org := s.ctx.Get("org").(model.SysOrg)
67 79
 		flashbuy.OrgId = org.OrgId

+ 7
- 6
service/marketing/marketing.go Wyświetl plik

@@ -109,14 +109,15 @@ func (s *MarketingServ) SaveMarketing(activity model.SysActivity, activeType, re
109 109
 	var newInfo *model.SysActivity
110 110
 	var newWoke *model.SysActivityAction
111 111
 
112
-	user := s.ctx.Get("user").(model.SysUser)
112
+	// user := s.ctx.Get("user").(model.SysUser)
113 113
 
114
-	caseinfo, err := s.userdao.GetUserBelongCase(user.UserId)
115
-	if err != nil {
116
-		return nil, nil, err
117
-	}
118
-	activity.CaseId = caseinfo.CaseId
114
+	// caseinfo, err := s.userdao.GetUserBelongCase(user.UserId)
115
+	// if err != nil {
116
+	// 	return nil, nil, err
117
+	// }
118
+	// activity.CaseId = caseinfo.CaseId
119 119
 	// 存储 营销活动
120
+	var err error
120 121
 	newInfo, err = s.dao.AddMarketing(activity)
121 122
 	if err != nil {
122 123
 		return nil, nil, err