|
@@ -10,6 +10,8 @@ import (
|
10
|
10
|
"strings"
|
11
|
11
|
"time"
|
12
|
12
|
|
|
13
|
+ "github.com/astaxie/beego"
|
|
14
|
+
|
13
|
15
|
"github.com/go-xorm/xorm"
|
14
|
16
|
"github.com/yl10/kit/guid"
|
15
|
17
|
)
|
|
@@ -108,7 +110,7 @@ func (m *CardDAO) AddCard(card *model.TaCouponCard) error {
|
108
|
110
|
return nil
|
109
|
111
|
}
|
110
|
112
|
|
111
|
|
-// UpdateCard 更新优惠券
|
|
113
|
+// UpdateCard 更新体验卡
|
112
|
114
|
func (m *CardDAO) UpdateCard(card *model.TaCouponCard, cols []string) error {
|
113
|
115
|
if card.CardId == "" {
|
114
|
116
|
return errors.New("无卡信息")
|
|
@@ -222,6 +224,7 @@ type CaseUsableCard struct {
|
222
|
224
|
func (m *CardDAO) GetCaseUsableCard(caseid, userid string, page, pageSize int) ([]CaseUsableCard, error) {
|
223
|
225
|
var cards []CaseUsableCard
|
224
|
226
|
sql := `select * from ta_coupon_card where case_id=? and status=? and end_date>now() order by create_date limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
|
|
227
|
+ beego.Error(sql)
|
225
|
228
|
err := m.db.Sql(sql, caseid, models.STATUS_NORMAL).Find(&cards)
|
226
|
229
|
if userid != "" {
|
227
|
230
|
for inx, card := range cards {
|
|
@@ -240,7 +243,6 @@ func (m *CardDAO) GetCaseUsableCardCount(caseid, userid string) (int, error) {
|
240
|
243
|
var Coupons []CaseUsableCard
|
241
|
244
|
sql := `select * from ta_coupon_card where case_id=? and status=? and end_date>now()`
|
242
|
245
|
err := m.db.Sql(sql, caseid, models.STATUS_NORMAL).Find(&Coupons)
|
243
|
|
-
|
244
|
246
|
return len(Coupons), err
|
245
|
247
|
}
|
246
|
248
|
|
|
@@ -284,7 +286,7 @@ func (m *CardDAO) GetCustomerCardByUser(caseid, userid string) ([]model.TaCustom
|
284
|
286
|
return customerCards, err
|
285
|
287
|
}
|
286
|
288
|
|
287
|
|
-// GetCardWithCustomer 获取优惠券明细
|
|
289
|
+// GetCardWithCustomer 获取体验卡明细
|
288
|
290
|
func (m *CardDAO) GetCardWithCustomer(cardid string) (*CaseUsableCard, error) {
|
289
|
291
|
var card = new(CaseUsableCard)
|
290
|
292
|
sql := `select * from ta_card where coupin_id=?`
|
|
@@ -293,7 +295,7 @@ func (m *CardDAO) GetCardWithCustomer(cardid string) (*CaseUsableCard, error) {
|
293
|
295
|
return nil, err
|
294
|
296
|
}
|
295
|
297
|
if card == nil || card.CardId == "" {
|
296
|
|
- return nil, errors.New("无优惠券信息")
|
|
298
|
+ return nil, errors.New("无体验卡信息")
|
297
|
299
|
}
|
298
|
300
|
var customerCopons []model.TaCustomerCard
|
299
|
301
|
sql = `select * from ta_customer_card where card_id = ? and status>?`
|
|
@@ -333,7 +335,7 @@ func (m *CardDAO) GetCardByCustomer(orgid, customerid string) ([]CustomerCardWit
|
333
|
335
|
// GetCustomerCardByID 获取我的体验卡详情
|
334
|
336
|
func (m *CardDAO) GetCustomerCardByID(id string) (*CustomerCardWithShare, error) {
|
335
|
337
|
if id == "" {
|
336
|
|
- return nil, errors.New("无优惠券信息")
|
|
338
|
+ return nil, errors.New("无体验卡信息")
|
337
|
339
|
}
|
338
|
340
|
var customerCard = new(CustomerCardWithShare)
|
339
|
341
|
sql := `select * from ta_customer_card where status>? and customer_card_id=?`
|