Browse Source

2.1.0改bug

胡轶钦 6 years ago
parent
commit
e7b318dedd

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

280
 	}
280
 	}
281
 	c.ResponseJSON(Coupons)
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 View File

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

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

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

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

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

+ 14
- 0
models/coupon/coupon.go View File

586
 	_, err := m.db.Insert(&couponChannel)
586
 	_, err := m.db.Insert(&couponChannel)
587
 	return err
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 View File

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

+ 3
- 2
routers/common.go View File

269
 		beego.NSRouter("/coupon/:id", &coupon.CouponController{}, "put:UpdateCoupon"),
269
 		beego.NSRouter("/coupon/:id", &coupon.CouponController{}, "put:UpdateCoupon"),
270
 		beego.NSRouter("/coupon/:id/to/:users", &coupon.CouponController{}, "post:GiveCoupon"),
270
 		beego.NSRouter("/coupon/:id/to/:users", &coupon.CouponController{}, "post:GiveCoupon"),
271
 		beego.NSRouter("/coupon/type/:type", &coupon.CouponController{}, "get:GetCouponBySendType"),
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
 		beego.NSRouter("/case/signin", &cases.SigninController{}, "get:GetSigninWhere"),
275
 		beego.NSRouter("/case/signin", &cases.SigninController{}, "get:GetSigninWhere"),
280
 		beego.NSRouter("/card/:id", &card.CardController{}, "get:GetCardByIDForAdmin"),
281
 		beego.NSRouter("/card/:id", &card.CardController{}, "get:GetCardByIDForAdmin"),
281
 		beego.NSRouter("/card/:id", &card.CardController{}, "put:UpdateCard"),
282
 		beego.NSRouter("/card/:id", &card.CardController{}, "put:UpdateCard"),
282
 		beego.NSRouter("/card/:id/to/:users", &card.CardController{}, "post:GiveCard"),
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
 		beego.NSRouter("/record", &card.RecordController{}, "get:GetRecordList"),
286
 		beego.NSRouter("/record", &card.RecordController{}, "get:GetRecordList"),
286
 
287
 
329
 		beego.NSRouter("/flashbuy/:flashBuyId", &flashbuy.FlashBuyController{}, "get:GetFlashBuyById"),
330
 		beego.NSRouter("/flashbuy/:flashBuyId", &flashbuy.FlashBuyController{}, "get:GetFlashBuyById"),
330
 		beego.NSRouter("/flashbuy", &flashbuy.FlashBuyController{}, "post:SaveFlashBuy"),
331
 		beego.NSRouter("/flashbuy", &flashbuy.FlashBuyController{}, "post:SaveFlashBuy"),
331
 		beego.NSRouter("/flashbuy/edit", &flashbuy.FlashBuyController{}, "put:SaveFlashBuy"),
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
 		beego.NSRouter("/flashbuy/:flashBuyId/:flashBuyStatus", &flashbuy.FlashBuyController{}, "put:UpdateFlashBuy"),
334
 		beego.NSRouter("/flashbuy/:flashBuyId/:flashBuyStatus", &flashbuy.FlashBuyController{}, "put:UpdateFlashBuy"),
334
 		beego.NSRouter("/flashbuy/:qrcode", &flashbuy.FlashBuyController{}, "get:VerifyCustomerFlashBuyList"),
335
 		beego.NSRouter("/flashbuy/:qrcode", &flashbuy.FlashBuyController{}, "get:VerifyCustomerFlashBuyList"),
335
 		beego.NSRouter("/flashbuy/:customerFlashBuyId", &flashbuy.FlashBuyController{}, "put:Verify"),
336
 		beego.NSRouter("/flashbuy/:customerFlashBuyId", &flashbuy.FlashBuyController{}, "put:Verify"),

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

691
 		"page":     page,
691
 		"page":     page,
692
 	}, nil
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 View File

62
 func (s *FlashBuyServ) SaveFlashBuy(flashbuy model.TaFlashBuy) (*model.TaFlashBuy, error) {
62
 func (s *FlashBuyServ) SaveFlashBuy(flashbuy model.TaFlashBuy) (*model.TaFlashBuy, error) {
63
 	var newFlashBuy *model.TaFlashBuy
63
 	var newFlashBuy *model.TaFlashBuy
64
 	var err error
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
 	if flashbuy.FlashBuyId == "" {
77
 	if flashbuy.FlashBuyId == "" {
66
 		org := s.ctx.Get("org").(model.SysOrg)
78
 		org := s.ctx.Get("org").(model.SysOrg)
67
 		flashbuy.OrgId = org.OrgId
79
 		flashbuy.OrgId = org.OrgId

+ 7
- 6
service/marketing/marketing.go View File

109
 	var newInfo *model.SysActivity
109
 	var newInfo *model.SysActivity
110
 	var newWoke *model.SysActivityAction
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
 	newInfo, err = s.dao.AddMarketing(activity)
121
 	newInfo, err = s.dao.AddMarketing(activity)
121
 	if err != nil {
122
 	if err != nil {
122
 		return nil, nil, err
123
 		return nil, nil, err