|
@@ -59,20 +59,20 @@ func (m *StatisticsDAO) CardCouponStatistics(caseids, ctype, name string, page,
|
59
|
59
|
INNER JOIN sys_case b ON a.case_id = b.case_id
|
60
|
60
|
where b.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
|
61
|
61
|
|
62
|
|
- gymcardsql := `SELECT
|
63
|
|
- b.case_name,
|
64
|
|
- b.case_id,
|
65
|
|
- a.gym_card_name,
|
66
|
|
- '健身卡' AS type_name,
|
67
|
|
- a.send_type,
|
68
|
|
- a.price,
|
69
|
|
- a.sent_count,
|
70
|
|
- a.used_count,
|
71
|
|
- a.create_date
|
72
|
|
- FROM
|
73
|
|
- ta_gym_card a
|
74
|
|
- INNER JOIN sys_case b ON a.case_id = b.case_id
|
75
|
|
- where b.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
|
|
62
|
+ // gymcardsql := `SELECT
|
|
63
|
+ // b.case_name,
|
|
64
|
+ // b.case_id,
|
|
65
|
+ // a.gym_card_name,
|
|
66
|
+ // '健身卡' AS type_name,
|
|
67
|
+ // a.send_type,
|
|
68
|
+ // a.price,
|
|
69
|
+ // a.sent_count,
|
|
70
|
+ // a.used_count,
|
|
71
|
+ // a.create_date
|
|
72
|
+ // FROM
|
|
73
|
+ // ta_gym_card a
|
|
74
|
+ // INNER JOIN sys_case b ON a.case_id = b.case_id
|
|
75
|
+ // where b.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
|
76
|
76
|
|
77
|
77
|
sql := ""
|
78
|
78
|
if ctype != "" {
|
|
@@ -86,18 +86,18 @@ func (m *StatisticsDAO) CardCouponStatistics(caseids, ctype, name string, page,
|
86
|
86
|
case "coursecoupon":
|
87
|
87
|
sql = "select * from (" + couponsql + " and a.coupon_type='course') tab"
|
88
|
88
|
break
|
89
|
|
- case "gym":
|
90
|
|
- sql = "select * from (" + gymcardsql + ") tab"
|
91
|
|
- break
|
|
89
|
+ // case "gym":
|
|
90
|
+ // sql = "select * from (" + gymcardsql + ") tab"
|
|
91
|
+ // break
|
92
|
92
|
default:
|
93
|
93
|
return nil, errors.New("类型不正确")
|
94
|
94
|
}
|
95
|
95
|
} else {
|
96
|
|
- sql = "select * from (" + cardsql + " union " + couponsql + " union " + gymcardsql + ") tab"
|
|
96
|
+ sql = "select * from (" + cardsql + " union " + couponsql + ") tab"
|
97
|
97
|
}
|
98
|
98
|
|
99
|
99
|
if name != "" {
|
100
|
|
- sql = sql + ` and c_name like '%` + name + `%'`
|
|
100
|
+ sql = sql + ` where c_name like '%` + name + `%'`
|
101
|
101
|
}
|
102
|
102
|
sql = sql + ` order by create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
|
103
|
103
|
err := m.db.Sql(sql).Find(&cardCoupons)
|
|
@@ -144,20 +144,20 @@ func (m *StatisticsDAO) CardCouponStatisticsCount(caseids, ctype, name string) (
|
144
|
144
|
INNER JOIN sys_case b ON a.case_id = b.case_id
|
145
|
145
|
where b.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
|
146
|
146
|
|
147
|
|
- gymcardsql := `SELECT
|
148
|
|
- b.case_name,
|
149
|
|
- b.case_id,
|
150
|
|
- a.gym_card_name,
|
151
|
|
- '健身卡' AS type_name,
|
152
|
|
- a.send_type,
|
153
|
|
- a.price,
|
154
|
|
- a.sent_count,
|
155
|
|
- a.used_count,
|
156
|
|
- a.create_date
|
157
|
|
- FROM
|
158
|
|
- ta_gym_card a
|
159
|
|
- INNER JOIN sys_case b ON a.case_id = b.case_id
|
160
|
|
- where b.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
|
|
147
|
+ // gymcardsql := `SELECT
|
|
148
|
+ // b.case_name,
|
|
149
|
+ // b.case_id,
|
|
150
|
+ // a.gym_card_name,
|
|
151
|
+ // '健身卡' AS type_name,
|
|
152
|
+ // a.send_type,
|
|
153
|
+ // a.price,
|
|
154
|
+ // a.sent_count,
|
|
155
|
+ // a.used_count,
|
|
156
|
+ // a.create_date
|
|
157
|
+ // FROM
|
|
158
|
+ // ta_gym_card a
|
|
159
|
+ // INNER JOIN sys_case b ON a.case_id = b.case_id
|
|
160
|
+ // where b.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
|
161
|
161
|
|
162
|
162
|
sql := ""
|
163
|
163
|
if ctype != "" {
|
|
@@ -171,18 +171,368 @@ func (m *StatisticsDAO) CardCouponStatisticsCount(caseids, ctype, name string) (
|
171
|
171
|
case "coursecoupon":
|
172
|
172
|
sql = "select * from (" + couponsql + " and a.coupon_type='course') tab"
|
173
|
173
|
break
|
174
|
|
- case "gym":
|
175
|
|
- sql = "select * from (" + gymcardsql + ") tab"
|
176
|
|
- break
|
|
174
|
+ // case "gym":
|
|
175
|
+ // sql = "select * from (" + gymcardsql + ") tab"
|
|
176
|
+ // break
|
177
|
177
|
default:
|
178
|
178
|
return 0, errors.New("类型不正确")
|
179
|
179
|
}
|
180
|
180
|
} else {
|
181
|
|
- sql = "select * from (" + cardsql + " union " + couponsql + " union " + gymcardsql + ") tab"
|
|
181
|
+ sql = "select * from (" + cardsql + " union " + couponsql + ") tab"
|
|
182
|
+ }
|
|
183
|
+
|
|
184
|
+ if name != "" {
|
|
185
|
+ sql = sql + ` where c_name like '%` + name + `%'`
|
|
186
|
+ }
|
|
187
|
+ err := m.db.Sql(sql).Find(&cardCoupons)
|
|
188
|
+ return len(cardCoupons), err
|
|
189
|
+}
|
|
190
|
+
|
|
191
|
+// CardCouponUsedStatistics 卡券使用情况
|
|
192
|
+type CardCouponUsedStatistics struct {
|
|
193
|
+ CaseId string
|
|
194
|
+ CaseName string
|
|
195
|
+ CardCouponName string
|
|
196
|
+ TargetName string
|
|
197
|
+ ReceivingType string
|
|
198
|
+ Name string
|
|
199
|
+ CustomerName string
|
|
200
|
+ Phone string
|
|
201
|
+ SalesId string
|
|
202
|
+ SalesName string
|
|
203
|
+ StartDate time.Time
|
|
204
|
+ EndDate time.Time
|
|
205
|
+ ReceiveDate time.Time
|
|
206
|
+ UsedDate time.Time
|
|
207
|
+ VerifyStatus string
|
|
208
|
+}
|
|
209
|
+
|
|
210
|
+// CardCouponUsedStatistics 获取卡券使用情况统计
|
|
211
|
+func (m *StatisticsDAO) CardCouponUsedStatistics(caseids, tel, name, receivetype, begindate, enddate, status string, page, pageSize int) ([]CardCouponUsedStatistics, error) {
|
|
212
|
+ var cardCoupons []CardCouponUsedStatistics
|
|
213
|
+ cardsql := `SELECT
|
|
214
|
+ d.case_name,
|
|
215
|
+ d.case_id,
|
|
216
|
+ a.customer_card_name as card_coupon_name,
|
|
217
|
+ b.target_name,
|
|
218
|
+ a.receiving_type,
|
|
219
|
+ c.name,
|
|
220
|
+ c.customer_name,
|
|
221
|
+ c.phone,
|
|
222
|
+ a.sales_id,
|
|
223
|
+ a.sales_name,
|
|
224
|
+ a.start_date,
|
|
225
|
+ a.end_date,
|
|
226
|
+ a.receive_date,
|
|
227
|
+ a.receive_date as used_date,
|
|
228
|
+ a.verify_status
|
|
229
|
+ FROM
|
|
230
|
+ ta_customer_card a
|
|
231
|
+ INNER JOIN ta_coupon_card_target b ON b.card_id = a.card_id
|
|
232
|
+ INNER JOIN ta_customer c ON a.customer_id = c.customer_id
|
|
233
|
+ INNER JOIN sys_case d ON a.case_id = d.case_id
|
|
234
|
+ WHERE d.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
|
|
235
|
+
|
|
236
|
+ couponsql := `SELECT
|
|
237
|
+ b.case_name,
|
|
238
|
+ b.case_id,
|
|
239
|
+ a.customer_coupon_name as card_coupon_name,
|
|
240
|
+ (
|
|
241
|
+ CASE
|
|
242
|
+ WHEN cp.coupon_type = 'course' THEN
|
|
243
|
+ d.course_name
|
|
244
|
+ ELSE
|
|
245
|
+ c.coupon_name
|
|
246
|
+ END
|
|
247
|
+ ) as target_name,
|
|
248
|
+ a.receiving_type,
|
|
249
|
+ cst.name,
|
|
250
|
+ cst.customer_name,
|
|
251
|
+ cst.phone,
|
|
252
|
+ a.sales_id,
|
|
253
|
+ a.sales_name,
|
|
254
|
+ a.start_date,
|
|
255
|
+ a.end_date,
|
|
256
|
+ a.receive_date,
|
|
257
|
+ (
|
|
258
|
+ CASE
|
|
259
|
+ WHEN cp.coupon_type = 'course' THEN
|
|
260
|
+ d.create_date
|
|
261
|
+ ELSE
|
|
262
|
+ c.create_date
|
|
263
|
+ END
|
|
264
|
+ ) as used_date,
|
|
265
|
+ (
|
|
266
|
+ CASE
|
|
267
|
+ WHEN NOW() > a.end_date THEN
|
|
268
|
+ 'expire'
|
|
269
|
+ WHEN use_date IS NULL THEN
|
|
270
|
+ 'useable'
|
|
271
|
+ ELSE
|
|
272
|
+ 'used'
|
|
273
|
+ END
|
|
274
|
+ ) AS verify_status
|
|
275
|
+ FROM
|
|
276
|
+ ta_customer_coupon a
|
|
277
|
+ INNER JOIN sys_case b ON a.case_id = b.case_id
|
|
278
|
+ INNER JOIN ta_customer cst ON a.customer_id = cst.customer_id
|
|
279
|
+ INNER JOIN ta_coupon cp ON a.coupon_id = cp.coupon_id
|
|
280
|
+ LEFT JOIN ta_goods_orders_coupon c ON a.coupon_id = c.coupon_id
|
|
281
|
+ LEFT JOIN ta_course_orders_coupon d ON a.coupon_id = d.coupon_id
|
|
282
|
+ WHERE b.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
|
|
283
|
+
|
|
284
|
+ sql := "select * from (" + cardsql + " union " + couponsql + ") tab where (1=1)"
|
|
285
|
+
|
|
286
|
+ if name != "" {
|
|
287
|
+ sql = sql + ` and tab.card_coupon_name like '%` + name + `%'`
|
|
288
|
+ }
|
|
289
|
+ if tel != "" {
|
|
290
|
+ sql = sql + ` and tab.phone like '%` + tel + `%'`
|
|
291
|
+ }
|
|
292
|
+ if receivetype != "" {
|
|
293
|
+ sql = sql + ` and tab.receiving_type = '` + receivetype + `'`
|
182
|
294
|
}
|
|
295
|
+ if status != "" {
|
|
296
|
+ sql = sql + ` and tab.verify_status = '` + receivetype + `'`
|
|
297
|
+ }
|
|
298
|
+ if begindate != "" {
|
|
299
|
+ sql = sql + ` and DATE_FORMAT(tab.receive_date, '%Y-%m-%d') >= '` + begindate + `'`
|
|
300
|
+ }
|
|
301
|
+ if enddate != "" {
|
|
302
|
+ sql = sql + ` and DATE_FORMAT(tab.receive_date, '%Y-%m-%d') <= '` + enddate + `'`
|
|
303
|
+ }
|
|
304
|
+ sql = sql + ` order by receive_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
|
|
305
|
+
|
|
306
|
+ err := m.db.Sql(sql).Find(&cardCoupons)
|
|
307
|
+ return cardCoupons, err
|
|
308
|
+}
|
|
309
|
+
|
|
310
|
+// CardCouponUsedCountStatistics 获取卡券使用情况统计
|
|
311
|
+func (m *StatisticsDAO) CardCouponUsedCountStatistics(caseids, tel, name, receivetype, begindate, enddate, status string) (int, error) {
|
|
312
|
+ var cardCoupons []CardCouponUsedStatistics
|
|
313
|
+ cardsql := `SELECT
|
|
314
|
+ d.case_name,
|
|
315
|
+ d.case_id,
|
|
316
|
+ a.customer_card_name as card_coupon_name,
|
|
317
|
+ b.target_name,
|
|
318
|
+ a.receiving_type,
|
|
319
|
+ c.name,
|
|
320
|
+ c.customer_name,
|
|
321
|
+ c.phone,
|
|
322
|
+ a.sales_id,
|
|
323
|
+ a.sales_name,
|
|
324
|
+ a.start_date,
|
|
325
|
+ a.end_date,
|
|
326
|
+ a.receive_date,
|
|
327
|
+ a.receive_date as used_date,
|
|
328
|
+ a.verify_status
|
|
329
|
+ FROM
|
|
330
|
+ ta_customer_card a
|
|
331
|
+ INNER JOIN ta_coupon_card_target b ON b.card_id = a.card_id
|
|
332
|
+ INNER JOIN ta_customer c ON a.customer_id = c.customer_id
|
|
333
|
+ INNER JOIN sys_case d ON a.case_id = d.case_id
|
|
334
|
+ WHERE d.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
|
|
335
|
+
|
|
336
|
+ couponsql := `SELECT
|
|
337
|
+ b.case_name,
|
|
338
|
+ b.case_id,
|
|
339
|
+ a.customer_coupon_name as card_coupon_name,
|
|
340
|
+ (
|
|
341
|
+ CASE
|
|
342
|
+ WHEN cp.coupon_type = 'course' THEN
|
|
343
|
+ d.course_name
|
|
344
|
+ ELSE
|
|
345
|
+ c.coupon_name
|
|
346
|
+ END
|
|
347
|
+ ) as target_name,
|
|
348
|
+ a.receiving_type,
|
|
349
|
+ cst.name,
|
|
350
|
+ cst.customer_name,
|
|
351
|
+ cst.phone,
|
|
352
|
+ a.sales_id,
|
|
353
|
+ a.sales_name,
|
|
354
|
+ a.start_date,
|
|
355
|
+ a.end_date,
|
|
356
|
+ a.receive_date,
|
|
357
|
+ (
|
|
358
|
+ CASE
|
|
359
|
+ WHEN cp.coupon_type = 'course' THEN
|
|
360
|
+ d.create_date
|
|
361
|
+ ELSE
|
|
362
|
+ c.create_date
|
|
363
|
+ END
|
|
364
|
+ ) as used_date,
|
|
365
|
+ (
|
|
366
|
+ CASE
|
|
367
|
+ WHEN NOW() > a.end_date THEN
|
|
368
|
+ 'expire'
|
|
369
|
+ WHEN use_date IS NULL THEN
|
|
370
|
+ 'useable'
|
|
371
|
+ ELSE
|
|
372
|
+ 'used'
|
|
373
|
+ END
|
|
374
|
+ ) AS verify_status
|
|
375
|
+ FROM
|
|
376
|
+ ta_customer_coupon a
|
|
377
|
+ INNER JOIN sys_case b ON a.case_id = b.case_id
|
|
378
|
+ INNER JOIN ta_customer cst ON a.customer_id = cst.customer_id
|
|
379
|
+ INNER JOIN ta_coupon cp ON a.coupon_id = cp.coupon_id
|
|
380
|
+ LEFT JOIN ta_goods_orders_coupon c ON a.coupon_id = c.coupon_id
|
|
381
|
+ LEFT JOIN ta_course_orders_coupon d ON a.coupon_id = d.coupon_id
|
|
382
|
+ WHERE b.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
|
|
383
|
+
|
|
384
|
+ sql := "select * from (" + cardsql + " union " + couponsql + ") tab where (1=1)"
|
|
385
|
+
|
|
386
|
+ if name != "" {
|
|
387
|
+ sql = sql + ` and tab.card_coupon_name like '%` + name + `%'`
|
|
388
|
+ }
|
|
389
|
+ if tel != "" {
|
|
390
|
+ sql = sql + ` and tab.phone like '%` + tel + `%'`
|
|
391
|
+ }
|
|
392
|
+ if receivetype != "" {
|
|
393
|
+ sql = sql + ` and tab.receiving_type = '` + receivetype + `'`
|
|
394
|
+ }
|
|
395
|
+ if status != "" {
|
|
396
|
+ sql = sql + ` and tab.verify_status = '` + receivetype + `'`
|
|
397
|
+ }
|
|
398
|
+ if begindate != "" {
|
|
399
|
+ sql = sql + ` and DATE_FORMAT(tab.receive_date, '%Y-%m-%d') >= '` + begindate + `'`
|
|
400
|
+ }
|
|
401
|
+ if enddate != "" {
|
|
402
|
+ sql = sql + ` and DATE_FORMAT(tab.receive_date, '%Y-%m-%d') <= '` + enddate + `'`
|
|
403
|
+ }
|
|
404
|
+ err := m.db.Sql(sql).Find(&cardCoupons)
|
|
405
|
+ return len(cardCoupons), err
|
|
406
|
+}
|
|
407
|
+
|
|
408
|
+// CardCouponVerifyStatistics 卡券使用情况
|
|
409
|
+type CardCouponVerifyStatistics struct {
|
|
410
|
+ CaseId string
|
|
411
|
+ CaseName string
|
|
412
|
+ CourseName string
|
|
413
|
+ BeginDate time.Time
|
|
414
|
+ EndDate time.Time
|
|
415
|
+ Name string
|
|
416
|
+ CustomerName string
|
|
417
|
+ Phone string
|
|
418
|
+ CreateDate time.Time
|
|
419
|
+ VerifyDate time.Time
|
|
420
|
+ Status string
|
|
421
|
+}
|
|
422
|
+
|
|
423
|
+// CardCouponVerifyStatistics 获取卡券核销情况统计
|
|
424
|
+func (m *StatisticsDAO) CardCouponVerifyStatistics(caseids, tel, name, status string, page, pageSize int) ([]CardCouponVerifyStatistics, error) {
|
|
425
|
+ var cardCoupons []CardCouponVerifyStatistics
|
|
426
|
+ sql := `SELECT
|
|
427
|
+ c.case_id,
|
|
428
|
+ c.case_name,
|
|
429
|
+ e.course_name,
|
|
430
|
+ e.begin_date,
|
|
431
|
+ e.end_date,
|
|
432
|
+ d.name,
|
|
433
|
+ d.customer_name,
|
|
434
|
+ d.phone,
|
|
435
|
+ d.recommend_name,
|
|
436
|
+ a.create_date,
|
|
437
|
+ b.verify_date,
|
|
438
|
+ (
|
|
439
|
+ CASE
|
|
440
|
+ WHEN b.verify_date IS NULL THEN
|
|
441
|
+ 'useable'
|
|
442
|
+ ELSE
|
|
443
|
+ f.verify_status
|
|
444
|
+ END
|
|
445
|
+ ) AS verify_status
|
|
446
|
+ FROM
|
|
447
|
+ ta_customer_course a
|
|
448
|
+ INNER JOIN (
|
|
449
|
+ SELECT
|
|
450
|
+ customer_course_id,
|
|
451
|
+ min(verify_date) AS verify_date
|
|
452
|
+ FROM
|
|
453
|
+ ta_customer_course_detail
|
|
454
|
+ GROUP BY
|
|
455
|
+ customer_course_id
|
|
456
|
+ ) b ON a.customer_course_id = b.customer_course_id
|
|
457
|
+ INNER JOIN sys_case c ON a.case_id = c.case_id
|
|
458
|
+ INNER JOIN ta_customer d ON a.customer_id = d.customer_id
|
|
459
|
+ INNER JOIN ta_course e ON a.course_id = e.course_id
|
|
460
|
+ LEFT JOIN ta_customer_course_detail f ON b.customer_course_id = f.customer_course_id
|
|
461
|
+ AND b.verify_date = f.verify_date
|
|
462
|
+ WHERE c.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
|
|
463
|
+
|
|
464
|
+ if name != "" {
|
|
465
|
+ sql = sql + ` and e.course_name like '%` + name + `%'`
|
|
466
|
+ }
|
|
467
|
+ if tel != "" {
|
|
468
|
+ sql = sql + ` and d.phone like '%` + tel + `%'`
|
|
469
|
+ }
|
|
470
|
+ if status != "" {
|
|
471
|
+ if status == "useable" {
|
|
472
|
+ sql = sql + ` and b.verify_date is null`
|
|
473
|
+ } else {
|
|
474
|
+ sql = sql + ` and f.verify_status ='` + status + `'`
|
|
475
|
+ }
|
|
476
|
+ }
|
|
477
|
+ sql = sql + ` order by a.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
|
|
478
|
+
|
|
479
|
+ err := m.db.Sql(sql).Find(&cardCoupons)
|
|
480
|
+ return cardCoupons, err
|
|
481
|
+}
|
|
482
|
+
|
|
483
|
+// CardCouponVerifyStatisticsCount 获取卡券核销情况数量统计
|
|
484
|
+func (m *StatisticsDAO) CardCouponVerifyStatisticsCount(caseids, tel, name, status string) (int, error) {
|
|
485
|
+ var cardCoupons []CardCouponVerifyStatistics
|
|
486
|
+ sql := `SELECT
|
|
487
|
+ c.case_id,
|
|
488
|
+ c.case_name,
|
|
489
|
+ e.course_name,
|
|
490
|
+ e.begin_date,
|
|
491
|
+ e.end_date,
|
|
492
|
+ d.name,
|
|
493
|
+ d.customer_name,
|
|
494
|
+ d.phone,
|
|
495
|
+ d.recommend_name,
|
|
496
|
+ a.create_date,
|
|
497
|
+ b.verify_date,
|
|
498
|
+ (
|
|
499
|
+ CASE
|
|
500
|
+ WHEN b.verify_date IS NULL THEN
|
|
501
|
+ 'useable'
|
|
502
|
+ ELSE
|
|
503
|
+ f.verify_status
|
|
504
|
+ END
|
|
505
|
+ ) AS verify_status
|
|
506
|
+ FROM
|
|
507
|
+ ta_customer_course a
|
|
508
|
+ INNER JOIN (
|
|
509
|
+ SELECT
|
|
510
|
+ customer_course_id,
|
|
511
|
+ min(verify_date) AS verify_date
|
|
512
|
+ FROM
|
|
513
|
+ ta_customer_course_detail
|
|
514
|
+ GROUP BY
|
|
515
|
+ customer_course_id
|
|
516
|
+ ) b ON a.customer_course_id = b.customer_course_id
|
|
517
|
+ INNER JOIN sys_case c ON a.case_id = c.case_id
|
|
518
|
+ INNER JOIN ta_customer d ON a.customer_id = d.customer_id
|
|
519
|
+ INNER JOIN ta_course e ON a.course_id = e.course_id
|
|
520
|
+ LEFT JOIN ta_customer_course_detail f ON b.customer_course_id = f.customer_course_id
|
|
521
|
+ AND b.verify_date = f.verify_date
|
|
522
|
+ WHERE c.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `')`
|
183
|
523
|
|
184
|
524
|
if name != "" {
|
185
|
|
- sql = sql + ` and c_name like '%` + name + `%'`
|
|
525
|
+ sql = sql + ` and e.course_name like '%` + name + `%'`
|
|
526
|
+ }
|
|
527
|
+ if tel != "" {
|
|
528
|
+ sql = sql + ` and d.phone like '%` + tel + `%'`
|
|
529
|
+ }
|
|
530
|
+ if status != "" {
|
|
531
|
+ if status == "useable" {
|
|
532
|
+ sql = sql + ` and b.verify_date is null`
|
|
533
|
+ } else {
|
|
534
|
+ sql = sql + ` and f.verify_status ='` + status + `'`
|
|
535
|
+ }
|
186
|
536
|
}
|
187
|
537
|
err := m.db.Sql(sql).Find(&cardCoupons)
|
188
|
538
|
return len(cardCoupons), err
|