胡轶钦 6 лет назад
Родитель
Сommit
683a13fe71

+ 8
- 12
controllers/flashbuy/flashbuy.go Просмотреть файл

@@ -83,6 +83,7 @@ func (c *FlashBuyController) GetFlashBuyById() {
83 83
 // GetWechatFlashBuyById
84 84
 func (c *FlashBuyController) GetWechatFlashBuyById() {
85 85
 	flashBuyId := c.GetString(":flashBuyId")
86
+	cust := c.Context.Get("customer").(model.TaCustomer)
86 87
 	flashBuy, err := c.dao.GetFlashBuyById(flashBuyId)
87 88
 	if err != nil {
88 89
 		c.ResponseError(err)
@@ -91,9 +92,14 @@ func (c *FlashBuyController) GetWechatFlashBuyById() {
91 92
 	if err != nil {
92 93
 		c.ResponseError(err)
93 94
 	}
95
+	flashCustomer, err := c.dao.IsFlashBuyCustomer(cust.CustomerId, flashBuyId)
96
+	if err != nil {
97
+		c.ResponseError(err)
98
+	}
94 99
 	c.ResponseJSON(map[string]interface{}{
95
-		"flashBuy": flashBuy,
96
-		"userInfo": userinfo,
100
+		"flashBuy":      flashBuy,
101
+		"userInfo":      userinfo,
102
+		"flashCustomer": flashCustomer,
97 103
 	})
98 104
 }
99 105
 
@@ -202,16 +208,6 @@ func (c *FlashBuyController) UpdateFlashBuyCustomer() {
202 208
 	c.ResponseJSON("修改成功")
203 209
 }
204 210
 
205
-func (c *FlashBuyController) IsFlashBuyCustomer() {
206
-	cust := c.Context.Get("customer").(model.TaCustomer)
207
-	flashBuyId := c.GetString(":flashBuyId")
208
-	flag, err := c.dao.IsFlashBuyCustomer(cust.CustomerId, flashBuyId)
209
-	if err != nil {
210
-		c.ResponseError(err)
211
-	}
212
-	c.ResponseJSON(flag)
213
-}
214
-
215 211
 func (c *FlashBuyController) IsNewCustomer() {
216 212
 	cust := c.Context.Get("customer").(model.TaCustomer)
217 213
 	if cust.Phone == "" {

+ 3
- 0
models/flashbuy/flashbuy.go Просмотреть файл

@@ -296,6 +296,7 @@ func (m *FlashbuyDAO) GetFlashModelList() ([]model.TdFlashbuyModel, error) {
296 296
 func (m *FlashbuyDAO) AddNewFlashBuyCustomer(customer model.TaFlashBuyCustomer) error {
297 297
 	customer.CreateDate = time.Now()
298 298
 	customer.FlashBuyCustomerId = utils.GetGUID()
299
+	customer.IsAttend = 1
299 300
 	_, err := m.db.Insert(customer)
300 301
 	return err
301 302
 }
@@ -304,9 +305,11 @@ func (m *FlashbuyDAO) UpdateFlashBuyCustomer(customerId, flashBuyId string) erro
304 305
 	var customer = model.TaFlashBuyCustomer{
305 306
 		CustomerId: customerId,
306 307
 		IsNew:      0,
308
+		IsAttend:   0,
307 309
 	}
308 310
 	var cols = []string{
309 311
 		"is_new",
312
+		"si_attend",
310 313
 	}
311 314
 	_, err := m.db.Cols(cols...).Where("customer_id = ?", customer.CustomerId).And("flash_buy_id =?", flashBuyId).Update(customer)
312 315
 	return err

+ 1
- 0
models/model/ta_flash_buy_customer.go Просмотреть файл

@@ -9,5 +9,6 @@ type TaFlashBuyCustomer struct {
9 9
 	FlashBuyId         string    `xorm:"VARCHAR(64)"`
10 10
 	CustomerId         string    `xorm:"VARCHAR(64)"`
11 11
 	IsNew              int       `xorm:"TINYINT(1)"`
12
+	IsAttend           int       `xorm:"TINYINT(1)"`
12 13
 	CreateDate         time.Time `xorm:"DATETIME"`
13 14
 }

+ 3
- 6
service/flashbuy/flashbuy.go Просмотреть файл

@@ -352,14 +352,11 @@ func (s *FlashBuyServ) UpdateFlashBuyCustomer(customerId, flashBuyId string) err
352 352
 	return nil
353 353
 }
354 354
 
355
-func (s *FlashBuyServ) IsFlashBuyCustomer(customerId, flashBuyId string) (bool, error) {
355
+func (s *FlashBuyServ) IsFlashBuyCustomer(customerId, flashBuyId string) (*model.TaFlashBuyCustomer, error) {
356 356
 	flashBuyCustomer, err := s.dao.IsFlashBuyCustomer(customerId, flashBuyId)
357 357
 	if err != nil {
358 358
 		utils.LogError("判断是否参与失败: " + err.Error())
359
-		return false, errors.New("判断是否参与失败")
359
+		return nil, errors.New("判断是否参与失败")
360 360
 	}
361
-	if flashBuyCustomer != nil || flashBuyCustomer.IsNew == 0 {
362
-		return false, errors.New("客户已参与本次抢购")
363
-	}
364
-	return true, nil
361
+	return flashBuyCustomer, nil
365 362
 }