wangfei 6 years ago
parent
commit
e89cec7d4f
2 changed files with 22 additions and 3 deletions
  1. 17
    0
      models/customer/account.go
  2. 5
    3
      service/customer/customer.go

+ 17
- 0
models/customer/account.go View File

@@ -124,3 +124,20 @@ func (m *CustomerDAO) GetAccountByCust(id string) (*model.TaCustomerAccount, err
124 124
 
125 125
 	return acc, nil
126 126
 }
127
+
128
+// GetCustomerVipAmount 获取用户vip金额
129
+func (m *CustomerDAO) GetCustomerVipAmount(id string) (string, error) {
130
+	type amount struct {
131
+		Balance string
132
+	}
133
+	sql := `select sum(balance) as balance from ta_customer_vip where customer_id=?`
134
+	var vip = amount{}
135
+	_, err := m.db.Sql(sql, id).Get(&vip)
136
+	if err != nil {
137
+		return "0.00", err
138
+	}
139
+	if vip.Balance == "" {
140
+		vip.Balance = "0.00"
141
+	}
142
+	return vip.Balance, nil
143
+}

+ 5
- 3
service/customer/customer.go View File

@@ -407,9 +407,11 @@ func (s *CustomerServ) GetCustomerInfo() (map[string]interface{}, error) {
407 407
 		utils.LogError("获取用户卡信息失败:", err)
408 408
 		return nil, err
409 409
 	}
410
+	balance, err := s.dao.GetCustomerVipAmount(customer.CustomerId)
410 411
 	return map[string]interface{}{
411
-		"account":   account,
412
-		"cardsnum":  len(card),
413
-		"couponnum": len(coupon),
412
+		"account":    account,
413
+		"cardsnum":   len(card),
414
+		"couponnum":  len(coupon),
415
+		"vipbalance": balance,
414 416
 	}, nil
415 417
 }