فهرست منبع

Merge branch 'mfyx_2.0' of http://8.136.199.33:3000/cxzhang/hongze_mfyx into debug

xingzai 1 سال پیش
والد
کامیت
4a12a2f3fc
2فایلهای تغییر یافته به همراه26 افزوده شده و 2 حذف شده
  1. 18 2
      controllers/user.go
  2. 8 0
      models/order/order_user_card.go

+ 18 - 2
controllers/user.go

@@ -407,8 +407,24 @@ func (this *UserController) Detail() {
 	if detail.Headimgurl == "" {
 		detail.Headimgurl = utils.DefaultHeadimgurl
 	}
-	detail.UserCardType = 1                                                           //权益卡类型
-	detail.UserCardEndDate = time.Now().AddDate(0, 0, 1).Format(utils.FormatDateTime) //  结束时间
+
+	if user.Mobile != "" {
+		userCard, err := order.GetCygxOrderUserCardDetailByMobile(user.Mobile)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		if userCard != nil {
+			if userCard.CardType == "日卡" {
+				detail.UserCardType = 1 //权益卡类型
+				detail.UserCardEndDate = userCard.EndDate.Format(utils.FormatDateTime)
+			} else {
+				detail.UserCardType = 2
+				detail.UserCardEndDate = userCard.EndDate.Format(utils.FormatDate)
+			}
+		}
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 8 - 0
models/order/order_user_card.go

@@ -146,6 +146,14 @@ func GetCygxOrderUserCardDetailByOrderCode(orderCode string) (item *CygxOrderUse
 	return
 }
 
+// 根据手机号获取用户持卡详情
+func GetCygxOrderUserCardDetailByMobile(mobile string) (item *CygxOrderUserCard, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_order_user_card WHERE mobile = ? `
+	err = o.Raw(sql, mobile).QueryRow(&item)
+	return
+}
+
 // 获取数量
 func GetCygxOrderUserCardCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrm()