wangfei 6 years ago
parent
commit
7a0c5fe905

+ 7
- 1
controllers/customer/customer.go View File

32
 	page, _ := c.GetInt("page")
32
 	page, _ := c.GetInt("page")
33
 	pageSize, _ := c.GetInt("pagesize")
33
 	pageSize, _ := c.GetInt("pagesize")
34
 
34
 
35
-	custList, total, err := c.serv.GetCustWithWXList(phone, username, recommendname, begindate, enddate, page, pageSize)
35
+	caseids := c.GetString("caseid")
36
+	if caseids == "" {
37
+		cases := c.Context.Get("cases").([]model.SysUserCase)
38
+		caseids = c.GetCaseIDs(cases)
39
+	}
40
+
41
+	custList, total, err := c.serv.GetCustWithWXList(phone, username, recommendname, begindate, enddate, caseids, page, pageSize)
36
 	if err != nil {
42
 	if err != nil {
37
 		utils.LogError("获取客户列表失败: " + err.Error())
43
 		utils.LogError("获取客户列表失败: " + err.Error())
38
 		c.ResponseError(
44
 		c.ResponseError(

+ 111
- 0
log/common.log View File

10
 2018/09/19 14:00:13 [E] 获取人员信息失败: 获取人员信息失败
10
 2018/09/19 14:00:13 [E] 获取人员信息失败: 获取人员信息失败
11
 2018/09/19 14:00:18 [E] 获取发送卡信息失败: Error 1054: Unknown column 'serial_code' in 'field list'
11
 2018/09/19 14:00:18 [E] 获取发送卡信息失败: Error 1054: Unknown column 'serial_code' in 'field list'
12
 2018/09/19 14:00:18 [E] 获取人员信息失败: 获取人员信息失败
12
 2018/09/19 14:00:18 [E] 获取人员信息失败: 获取人员信息失败
13
+2018/09/19 15:43:34 [E] 用户没有设置默认案场
14
+2018/09/19 15:43:34 [E] 用户没有设置默认案场
15
+2018/09/19 15:43:36 [E] 用户没有设置默认案场
16
+2018/09/19 15:43:36 [E] 用户没有设置默认案场
17
+2018/09/19 15:43:41 [E] 用户没有设置默认案场
18
+2018/09/19 15:43:42 [E] 用户没有设置默认案场
19
+2018/09/19 15:43:45 [E] 用户没有设置默认案场
20
+2018/09/19 15:43:45 [E] 用户没有设置默认案场
21
+2018/09/19 15:43:45 [E] 用户没有设置默认案场
22
+2018/09/19 15:43:48 [E] 用户没有设置默认案场
23
+2018/09/19 15:43:48 [E] 用户没有设置默认案场
24
+2018/09/19 15:46:57 [E] 用户没有设置默认案场
25
+2018/09/19 15:46:57 [E] 用户没有设置默认案场
26
+2018/09/19 15:46:58 [E] 用户没有设置默认案场
27
+2018/09/19 15:46:58 [E] 用户没有设置默认案场
28
+2018/09/19 15:47:00 [E] 用户没有设置默认案场
29
+2018/09/19 15:47:00 [E] 用户没有设置默认案场
30
+2018/09/19 15:47:01 [E] 用户没有设置默认案场
31
+2018/09/19 15:47:06 [E] 用户没有设置默认案场
32
+2018/09/19 15:47:06 [E] 用户没有设置默认案场
33
+2018/09/19 15:47:10 [E] 用户没有设置默认案场
34
+2018/09/19 15:47:10 [E] 用户没有设置默认案场
35
+2018/09/19 15:47:11 [E] 用户没有设置默认案场
36
+2018/09/19 15:47:11 [E] 用户没有设置默认案场
37
+2018/09/19 15:47:14 [E] 用户没有设置默认案场
38
+2018/09/19 15:47:14 [E] 用户没有设置默认案场
39
+2018/09/19 15:47:15 [E] 用户没有设置默认案场
40
+2018/09/19 15:47:15 [E] 用户没有设置默认案场
41
+2018/09/19 15:47:19 [E] 用户没有设置默认案场
42
+2018/09/19 15:47:19 [E] 用户没有设置默认案场
43
+2018/09/19 15:48:07 [E] 用户没有设置默认案场
44
+2018/09/19 15:48:07 [E] 用户没有设置默认案场
45
+2018/09/19 15:48:14 [E] 用户没有设置默认案场
46
+2018/09/19 15:48:14 [E] 用户没有设置默认案场
47
+2018/09/19 15:48:14 [E] 用户没有设置默认案场
48
+2018/09/19 15:49:00 [E] 用户没有设置默认案场
49
+2018/09/19 15:49:04 [E] 用户没有设置默认案场
50
+2018/09/19 15:49:05 [E] 用户没有设置默认案场
51
+2018/09/19 15:49:43 [E] 用户没有设置默认案场
52
+2018/09/19 15:49:46 [E] 用户没有设置默认案场
53
+2018/09/19 15:49:47 [E] 用户没有设置默认案场
54
+2018/09/19 15:50:07 [E] 用户没有设置默认案场
55
+2018/09/19 15:50:08 [E] 用户没有设置默认案场
56
+2018/09/19 15:50:08 [E] 用户没有设置默认案场
57
+2018/09/19 15:50:15 [E] 用户没有设置默认案场
58
+2018/09/19 15:50:15 [E] 用户没有设置默认案场
59
+2018/09/19 15:50:27 [E] 用户没有设置默认案场
60
+2018/09/19 15:50:27 [E] 用户没有设置默认案场
61
+2018/09/19 15:50:48 [E] 用户没有设置默认案场
62
+2018/09/19 15:50:48 [E] 用户没有设置默认案场
63
+2018/09/19 15:50:50 [E] 用户没有设置默认案场
64
+2018/09/19 15:50:51 [E] 用户没有设置默认案场
65
+2018/09/19 15:50:51 [E] 用户没有设置默认案场
66
+2018/09/19 15:50:51 [E] 用户没有设置默认案场
67
+2018/09/19 15:50:53 [E] 用户没有设置默认案场
68
+2018/09/19 15:50:53 [E] 用户没有设置默认案场
69
+2018/09/19 15:51:05 [E] 用户没有设置默认案场
70
+2018/09/19 15:51:06 [E] 用户没有设置默认案场
71
+2018/09/19 15:51:07 [E] 用户没有设置默认案场
72
+2018/09/19 15:51:07 [E] 用户没有设置默认案场
73
+2018/09/19 15:51:08 [E] 用户没有设置默认案场
74
+2018/09/19 15:51:08 [E] 用户没有设置默认案场
75
+2018/09/19 15:51:12 [E] 用户没有设置默认案场
76
+2018/09/19 15:51:12 [E] 用户没有设置默认案场
77
+2018/09/19 15:51:15 [E] 用户没有设置默认案场
78
+2018/09/19 15:51:15 [E] 用户没有设置默认案场
79
+2018/09/19 15:51:42 [E] 用户没有设置默认案场
80
+2018/09/19 15:51:42 [E] 用户没有设置默认案场
81
+2018/09/19 15:53:40 [E] 用户没有设置默认案场
82
+2018/09/19 15:53:45 [E] 用户没有设置默认案场
83
+2018/09/19 15:53:45 [E] 用户没有设置默认案场
84
+2018/09/19 15:54:56 [E] 用户没有设置默认案场
85
+2018/09/19 15:55:15 [E] 用户没有设置默认案场
86
+2018/09/19 15:55:15 [E] 用户没有设置默认案场
87
+2018/09/19 16:00:01 [E] 用户没有设置默认案场
88
+2018/09/19 16:00:01 [E] 用户没有设置默认案场
89
+2018/09/19 16:00:01 [E] 获取客户列表失败: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '== '' or t.recommend_case is null)
90
+		 ORDER BY
91
+			t.create_date DESC
92
+	) as virtu' at line 19
93
+2018/09/19 16:00:51 [E] 用户没有设置默认案场
94
+2018/09/19 16:00:51 [E] 用户没有设置默认案场
95
+2018/09/19 16:01:04 [E] 用户没有设置默认案场
96
+2018/09/19 16:01:04 [E] 用户没有设置默认案场
97
+2018/09/19 16:07:17 [E] 获取用户基本信息失败: 没有查询到 ID (OPENID) 对应的用户
98
+2018/09/19 16:09:54 [E] 用户没有设置默认案场
99
+2018/09/19 16:09:54 [E] 用户没有设置默认案场
100
+2018/09/19 16:09:59 [E] 用户没有设置默认案场
101
+2018/09/19 16:10:01 [E] 用户没有设置默认案场
102
+2018/09/19 16:10:01 [E] 用户没有设置默认案场
103
+2018/09/19 16:10:06 [E] 用户没有设置默认案场
104
+2018/09/19 16:10:09 [E] 用户没有设置默认案场
105
+2018/09/19 16:10:09 [E] 用户没有设置默认案场
106
+2018/09/19 16:10:25 [E] 用户没有设置默认案场
107
+2018/09/19 16:10:26 [E] 用户没有设置默认案场
108
+2018/09/19 16:10:26 [E] 用户没有设置默认案场
109
+2018/09/19 16:10:28 [E] 用户没有设置默认案场
110
+2018/09/19 16:10:29 [E] 用户没有设置默认案场
111
+2018/09/19 16:10:30 [E] 用户没有设置默认案场
112
+2018/09/19 16:10:31 [E] 用户没有设置默认案场
113
+2018/09/19 16:10:31 [E] 用户没有设置默认案场
114
+2018/09/19 16:10:32 [E] 用户没有设置默认案场
115
+2018/09/19 16:10:33 [E] 用户没有设置默认案场
116
+2018/09/19 16:10:33 [E] 用户没有设置默认案场
117
+2018/09/19 16:10:33 [E] 用户没有设置默认案场
118
+2018/09/19 16:10:35 [E] 用户没有设置默认案场
119
+2018/09/19 16:10:36 [E] 用户没有设置默认案场
120
+2018/09/19 16:10:36 [E] 用户没有设置默认案场
121
+2018/09/19 16:10:37 [E] 用户没有设置默认案场
122
+2018/09/19 16:10:38 [E] 用户没有设置默认案场
123
+2018/09/19 16:10:38 [E] 用户没有设置默认案场

+ 2
- 2
models/card/card.go View File

229
 // GetCaseUsableCard 获取案场可用卡信息
229
 // GetCaseUsableCard 获取案场可用卡信息
230
 func (m *CardDAO) GetCaseUsableCard(caseid, userid string, page, pageSize int) ([]CaseUsableCard, error) {
230
 func (m *CardDAO) GetCaseUsableCard(caseid, userid string, page, pageSize int) ([]CaseUsableCard, error) {
231
 	var cards []CaseUsableCard
231
 	var cards []CaseUsableCard
232
-	sql := `select * from ta_coupon_card where case_id=? and status=? and end_date>now() and send_type=? order by create_date limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
232
+	sql := `select * from ta_coupon_card 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 limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
233
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&cards)
233
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&cards)
234
 	for inx, card := range cards {
234
 	for inx, card := range cards {
235
 		if userid != "" {
235
 		if userid != "" {
251
 // GetCaseUsableCardCount 获取案场可用卡数量
251
 // GetCaseUsableCardCount 获取案场可用卡数量
252
 func (m *CardDAO) GetCaseUsableCardCount(caseid, userid string) (int, error) {
252
 func (m *CardDAO) GetCaseUsableCardCount(caseid, userid string) (int, error) {
253
 	var Coupons []CaseUsableCard
253
 	var Coupons []CaseUsableCard
254
-	sql := `select * from ta_coupon_card where case_id=? and status=? and end_date>now() and send_type=?`
254
+	sql := `select * from ta_coupon_card where case_id=? and status=? and DATE_FORMAT(end_date, '%Y-%m-%d')>=DATE_FORMAT(NOW(), '%Y-%m-%d') and send_type=?`
255
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&Coupons)
255
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&Coupons)
256
 	return len(Coupons), err
256
 	return len(Coupons), err
257
 }
257
 }

+ 2
- 2
models/coupon/coupon.go View File

291
 // GetCaseUsableCoupon 获取案场可用优惠券信息
291
 // GetCaseUsableCoupon 获取案场可用优惠券信息
292
 func (m *CouponDAO) GetCaseUsableCoupon(caseid, userid string, page, pageSize int) ([]CaseCouponDetail, error) {
292
 func (m *CouponDAO) GetCaseUsableCoupon(caseid, userid string, page, pageSize int) ([]CaseCouponDetail, error) {
293
 	var Coupons []CaseCouponDetail
293
 	var Coupons []CaseCouponDetail
294
-	sql := `select * from ta_coupon where case_id=? and status=? and end_date>now() and send_type=? order by create_date limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
294
+	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 limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
295
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&Coupons)
295
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&Coupons)
296
 	for inx, coupon := range Coupons {
296
 	for inx, coupon := range Coupons {
297
 		if userid != "" {
297
 		if userid != "" {
320
 // GetCaseUsableCouponCount 获取案场可用优惠券数量
320
 // GetCaseUsableCouponCount 获取案场可用优惠券数量
321
 func (m *CouponDAO) GetCaseUsableCouponCount(caseid, userid string) (int, error) {
321
 func (m *CouponDAO) GetCaseUsableCouponCount(caseid, userid string) (int, error) {
322
 	var Coupons []CaseCouponDetail
322
 	var Coupons []CaseCouponDetail
323
-	sql := `select * from ta_coupon where case_id=? and status=? and end_date>now() and send_type=?`
323
+	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=?`
324
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&Coupons)
324
 	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL, models.GIVE_TYPE_CASE).Find(&Coupons)
325
 
325
 
326
 	return len(Coupons), err
326
 	return len(Coupons), err

+ 5
- 2
models/customer/customer.go View File

5
 	"spaceofcheng/services/models"
5
 	"spaceofcheng/services/models"
6
 	"spaceofcheng/services/models/model"
6
 	"spaceofcheng/services/models/model"
7
 	"spaceofcheng/services/utils"
7
 	"spaceofcheng/services/utils"
8
+	"strings"
8
 	"time"
9
 	"time"
9
 
10
 
10
 	"github.com/yl10/kit/guid"
11
 	"github.com/yl10/kit/guid"
27
 }
28
 }
28
 
29
 
29
 // CustWithWXList 客户列表
30
 // CustWithWXList 客户列表
30
-func (m *CustomerDAO) CustWithWXList(phone, username, recommendname, begindate, enddate string, page ...int) ([]CustWithWX, int64, error) {
31
+func (m *CustomerDAO) CustWithWXList(phone, username, recommendname, begindate, enddate, caseids string, page ...int) ([]CustWithWX, int64, error) {
31
 	org := m.ctx.Get("org").(model.SysOrg)
32
 	org := m.ctx.Get("org").(model.SysOrg)
32
 
33
 
33
 	if phone == "" {
34
 	if phone == "" {
82
 			AND t.customer_name like ?
83
 			AND t.customer_name like ?
83
 			AND t.recommend_name like ?
84
 			AND t.recommend_name like ?
84
 		AND t.status > ?
85
 		AND t.status > ?
85
-		AND t.org_id = '` + org.OrgId + `'`
86
+		AND t.org_id = '` + org.OrgId + `'
87
+		AND (t.recommend_case in ('` + strings.Replace(caseids, ",", "','", -1) + `') or t.recommend_case = '' or t.recommend_case is null)
88
+		`
86
 
89
 
87
 	if begindate != "" {
90
 	if begindate != "" {
88
 		query = query + ` AND t.create_date>'` + begindate + `'`
91
 		query = query + ` AND t.create_date>'` + begindate + `'`

+ 1
- 1
models/sys.go View File

180
 
180
 
181
 			if _, err := DBEngine.Cols("status").
181
 			if _, err := DBEngine.Cols("status").
182
 				Where("token=?", token).
182
 				Where("token=?", token).
183
-				Or("batch_no in ('" + strings.Join(batchNo, "','") + "'").
183
+				Or("batch_no in ('" + strings.Join(batchNo, "','") + "')").
184
 				Update(&tk); err != nil {
184
 				Update(&tk); err != nil {
185
 				return err
185
 				return err
186
 			}
186
 			}

+ 2
- 2
service/customer/customer.go View File

41
 }
41
 }
42
 
42
 
43
 // GetCustWithWXList 获取客户列表
43
 // GetCustWithWXList 获取客户列表
44
-func (s *CustomerServ) GetCustWithWXList(phone, username, recommendname, begindate, enddate string, page ...int) ([]customer.CustWithWX, int64, error) {
45
-	return s.dao.CustWithWXList(phone, username, recommendname, begindate, enddate, page...)
44
+func (s *CustomerServ) GetCustWithWXList(phone, username, recommendname, begindate, enddate, caseids string, page ...int) ([]customer.CustWithWX, int64, error) {
45
+	return s.dao.CustWithWXList(phone, username, recommendname, begindate, enddate, caseids, page...)
46
 }
46
 }
47
 
47
 
48
 // GetCustWithWXByID 获取客户列表
48
 // GetCustWithWXByID 获取客户列表