Ver código fonte

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

zjxpcyc 6 anos atrás
pai
commit
42a9c52b71
3 arquivos alterados com 9 adições e 10 exclusões
  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 Ver arquivo

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

+ 2
- 2
models/coupon/coupon.go Ver arquivo

@@ -313,7 +313,7 @@ func (m *CouponDAO) GetCouponBySendType(caseids, sendtype string) ([]model.TaCou
313 313
 // GetCaseUsableCoupon 获取案场可用优惠券信息
314 314
 func (m *CouponDAO) GetCaseUsableCoupon(caseid, userid string, page, pageSize int) ([]CaseCouponDetail, error) {
315 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 317
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&Coupons)
318 318
 	for inx, coupon := range Coupons {
319 319
 		if userid != "" {
@@ -342,7 +342,7 @@ func (m *CouponDAO) GetCouponShareByCouponID(couponid string) (*model.TaCouponSh
342 342
 // GetCaseUsableCouponCount 获取案场可用优惠券数量
343 343
 func (m *CouponDAO) GetCaseUsableCouponCount(caseid, userid string) (int, error) {
344 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 346
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&Coupons)
347 347
 
348 348
 	return len(Coupons), err

+ 7
- 7
models/luckdraw/luckdraw.go Ver arquivo

@@ -318,7 +318,7 @@ func (m *LuckDrawDao) SavePrizeDetail(prize model.TaLuckdrawPrize) error {
318 318
 			var d = model.TaPrizeDetail{
319 319
 				Id:      utils.GetGUID(),
320 320
 				PrizeId: prize.Id,
321
-				Url:     beego.AppConfig.String("clientShareURL") + url,
321
+				Url:     url,
322 322
 				Status:  models.STATUS_NORMAL,
323 323
 			}
324 324
 			details = append(details, d)
@@ -431,7 +431,7 @@ func (m *LuckDrawDao) LuckDraw(id string, user *model.TaCustomer) (*model.TaLuck
431 431
 			if err != nil {
432 432
 				return nil, nil, nil, errors.New("获取信息失败!")
433 433
 			}
434
-			if sysuser != nil {
434
+			if sysuser != nil && sysuser.UserId != "" {
435 435
 				return nil, nil, nil, errors.New("内部人员不允许进行抽奖!")
436 436
 			}
437 437
 		}
@@ -618,8 +618,8 @@ type PrizeWithDefault struct {
618 618
 // GetPrizeDefaultByUser 获取默认用户
619 619
 func (m *LuckDrawDao) GetPrizeDefaultByUser(id string, customer *model.TaCustomer) (*PrizeWithDefault, error) {
620 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 623
 	return &prize, err
624 624
 }
625 625
 
@@ -636,7 +636,7 @@ func (m *LuckDrawDao) UpdatePrizeDefault(id, recordid string) error {
636 636
 		"receive_date",
637 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 640
 	return err
641 641
 }
642 642
 
@@ -797,7 +797,7 @@ func (m *LuckDrawDao) GetPrizeStock(luckdrawid string) ([]model.TaLuckdrawPrize,
797 797
 	a.* from ta_luckdraw_prize a 
798 798
 	left join (select prize_id,count(1) as default_num from ta_prize_default where luckdraw_id) b 
799 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 801
 	// err := m.db.Where("luckdraw_id=?", luckdrawid).And("status=?", models.STATUS_NORMAL).And("(remainder>0 or is_reality=0)").Find(&prizes)
802 802
 	return prizes, err
803 803
 }
@@ -876,7 +876,7 @@ func (m *LuckDrawDao) GetUserRecordByLuckDraw(userid string, luckdrawid string)
876 876
 // GetUserLuckDrawSet 获取用户抽奖设置
877 877
 func (m *LuckDrawDao) GetUserLuckDrawSet(customer model.TaCustomer, luckdrawid string) (*model.TaLuckdrawCustomer, error) {
878 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 880
 	if err != nil {
881 881
 		return nil, err
882 882
 	}