Browse Source

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

zjxpcyc 6 years ago
parent
commit
42a9c52b71
3 changed files with 9 additions and 10 deletions
  1. 0
    1
      conf/app.conf
  2. 2
    2
      models/coupon/coupon.go
  3. 7
    7
      models/luckdraw/luckdraw.go

+ 0
- 1
conf/app.conf View File

12
 followText = 您正在使用悦琦设备进行体检~
12
 followText = 您正在使用悦琦设备进行体检~
13
 resultURL = http://spaceofcheng.ycjcjy.com/wechat/bodyCheck.html
13
 resultURL = http://spaceofcheng.ycjcjy.com/wechat/bodyCheck.html
14
 
14
 
15
-clientShareURL = http://spaceofcheng.ycjcjy.com/wechat/user.html
16
 defaultShareUserID = 1
15
 defaultShareUserID = 1
17
 
16
 
18
 [cros]
17
 [cros]

+ 2
- 2
models/coupon/coupon.go View File

313
 // GetCaseUsableCoupon 获取案场可用优惠券信息
313
 // GetCaseUsableCoupon 获取案场可用优惠券信息
314
 func (m *CouponDAO) GetCaseUsableCoupon(caseid, userid string, page, pageSize int) ([]CaseCouponDetail, error) {
314
 func (m *CouponDAO) GetCaseUsableCoupon(caseid, userid string, page, pageSize int) ([]CaseCouponDetail, error) {
315
 	var Coupons []CaseCouponDetail
315
 	var Coupons []CaseCouponDetail
316
-	sql := `select * from ta_coupon where case_id=? and status=? and DATE_FORMAT(end_date, '%Y-%m-%d')>=DATE_FORMAT(NOW(), '%Y-%m-%d') and send_type=? order by create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
316
+	sql := `select * from ta_coupon where case_id=? and status=? and (DATE_FORMAT(end_date, '%Y-%m-%d')>=DATE_FORMAT(NOW(), '%Y-%m-%d') or valid_days>0) and send_type=? order by create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
317
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&Coupons)
317
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&Coupons)
318
 	for inx, coupon := range Coupons {
318
 	for inx, coupon := range Coupons {
319
 		if userid != "" {
319
 		if userid != "" {
342
 // GetCaseUsableCouponCount 获取案场可用优惠券数量
342
 // GetCaseUsableCouponCount 获取案场可用优惠券数量
343
 func (m *CouponDAO) GetCaseUsableCouponCount(caseid, userid string) (int, error) {
343
 func (m *CouponDAO) GetCaseUsableCouponCount(caseid, userid string) (int, error) {
344
 	var Coupons []CaseCouponDetail
344
 	var Coupons []CaseCouponDetail
345
-	sql := `select * from ta_coupon where case_id=? and status=? and DATE_FORMAT(end_date, '%Y-%m-%d')>=DATE_FORMAT(NOW(), '%Y-%m-%d') and send_type=?`
345
+	sql := `select * from ta_coupon where case_id=? and status=? and (DATE_FORMAT(end_date, '%Y-%m-%d')>=DATE_FORMAT(NOW(), '%Y-%m-%d') or valid_days>0) and send_type=?`
346
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&Coupons)
346
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&Coupons)
347
 
347
 
348
 	return len(Coupons), err
348
 	return len(Coupons), err

+ 7
- 7
models/luckdraw/luckdraw.go View File

318
 			var d = model.TaPrizeDetail{
318
 			var d = model.TaPrizeDetail{
319
 				Id:      utils.GetGUID(),
319
 				Id:      utils.GetGUID(),
320
 				PrizeId: prize.Id,
320
 				PrizeId: prize.Id,
321
-				Url:     beego.AppConfig.String("clientShareURL") + url,
321
+				Url:     url,
322
 				Status:  models.STATUS_NORMAL,
322
 				Status:  models.STATUS_NORMAL,
323
 			}
323
 			}
324
 			details = append(details, d)
324
 			details = append(details, d)
431
 			if err != nil {
431
 			if err != nil {
432
 				return nil, nil, nil, errors.New("获取信息失败!")
432
 				return nil, nil, nil, errors.New("获取信息失败!")
433
 			}
433
 			}
434
-			if sysuser != nil {
434
+			if sysuser != nil && sysuser.UserId != "" {
435
 				return nil, nil, nil, errors.New("内部人员不允许进行抽奖!")
435
 				return nil, nil, nil, errors.New("内部人员不允许进行抽奖!")
436
 			}
436
 			}
437
 		}
437
 		}
618
 // GetPrizeDefaultByUser 获取默认用户
618
 // GetPrizeDefaultByUser 获取默认用户
619
 func (m *LuckDrawDao) GetPrizeDefaultByUser(id string, customer *model.TaCustomer) (*PrizeWithDefault, error) {
619
 func (m *LuckDrawDao) GetPrizeDefaultByUser(id string, customer *model.TaCustomer) (*PrizeWithDefault, error) {
620
 	var prize = PrizeWithDefault{}
620
 	var prize = PrizeWithDefault{}
621
-	sql := `select a.default_id,b.* from ta_prize_default a inner join ta_prize_default b on a.prize_id=b.id where a.luckdraw_id=? and a.tel=? and is_receive=?`
622
-	_, err := m.db.Sql(sql, id, customer.Phone, models.BOOL_FALSE).Get(prize)
621
+	sql := `select a.default_id,b.* from ta_prize_default a inner join ta_luckdraw_prize b on a.prize_id=b.id where a.luckdraw_id=? and a.tel=? and a.is_receive=?`
622
+	_, err := m.db.Sql(sql, id, customer.Phone, models.BOOL_FALSE).Get(&prize)
623
 	return &prize, err
623
 	return &prize, err
624
 }
624
 }
625
 
625
 
636
 		"receive_date",
636
 		"receive_date",
637
 		"is_receive",
637
 		"is_receive",
638
 	}
638
 	}
639
-	_, err := m.db.Cols(cols...).Where("id=?", prizeDefault.DefaultId).Update(prizeDefault)
639
+	_, err := m.db.Cols(cols...).Where("default_id=?", prizeDefault.DefaultId).Update(prizeDefault)
640
 	return err
640
 	return err
641
 }
641
 }
642
 
642
 
797
 	a.* from ta_luckdraw_prize a 
797
 	a.* from ta_luckdraw_prize a 
798
 	left join (select prize_id,count(1) as default_num from ta_prize_default where luckdraw_id) b 
798
 	left join (select prize_id,count(1) as default_num from ta_prize_default where luckdraw_id) b 
799
 	on a.id=b.prize_id where a.luckdraw_id=? and a.status=? and (a.remainder-(case when b.default_num is null then 0 else b.default_num end)>0 or is_reality=0)`
799
 	on a.id=b.prize_id where a.luckdraw_id=? and a.status=? and (a.remainder-(case when b.default_num is null then 0 else b.default_num end)>0 or is_reality=0)`
800
-	err := m.db.Sql(sql).Find(&prizes)
800
+	err := m.db.Sql(sql, luckdrawid, models.STATUS_NORMAL).Find(&prizes)
801
 	// err := m.db.Where("luckdraw_id=?", luckdrawid).And("status=?", models.STATUS_NORMAL).And("(remainder>0 or is_reality=0)").Find(&prizes)
801
 	// err := m.db.Where("luckdraw_id=?", luckdrawid).And("status=?", models.STATUS_NORMAL).And("(remainder>0 or is_reality=0)").Find(&prizes)
802
 	return prizes, err
802
 	return prizes, err
803
 }
803
 }
876
 // GetUserLuckDrawSet 获取用户抽奖设置
876
 // GetUserLuckDrawSet 获取用户抽奖设置
877
 func (m *LuckDrawDao) GetUserLuckDrawSet(customer model.TaCustomer, luckdrawid string) (*model.TaLuckdrawCustomer, error) {
877
 func (m *LuckDrawDao) GetUserLuckDrawSet(customer model.TaCustomer, luckdrawid string) (*model.TaLuckdrawCustomer, error) {
878
 	var cstluckdraw = model.TaLuckdrawCustomer{}
878
 	var cstluckdraw = model.TaLuckdrawCustomer{}
879
-	_, err := m.db.Where("customer_id=?").And("luckdraw_id=?", luckdrawid).Get(&cstluckdraw)
879
+	_, err := m.db.Where("customer_id=?", customer.CustomerId).And("luckdraw_id=?", luckdrawid).Get(&cstluckdraw)
880
 	if err != nil {
880
 	if err != nil {
881
 		return nil, err
881
 		return nil, err
882
 	}
882
 	}