|
@@ -33,6 +33,10 @@ type UserListInfo struct {
|
33
|
33
|
model.SysUser `xorm:"extends"`
|
34
|
34
|
UserTypeNames string
|
35
|
35
|
}
|
|
36
|
+type CustomerInfo struct {
|
|
37
|
+ model.TaCustomer `xorm:"extends"`
|
|
38
|
+ Remark string
|
|
39
|
+}
|
36
|
40
|
|
37
|
41
|
// GetUserList 用户列表
|
38
|
42
|
func (m *UserDAO) GetUserList(username, typeid, caseids string, page int, pageSize int) ([]UserListInfo, error) {
|
|
@@ -404,11 +408,12 @@ func (m *UserDAO) UpdateCustomerHeadImg(customerid, username, imgurl string) err
|
404
|
408
|
}
|
405
|
409
|
|
406
|
410
|
// GetUserCustomer 获取我的推荐客户
|
407
|
|
-func (m *UserDAO) GetUserCustomer(userid, isrecommend, key string, page int, pageSize int) ([]model.TaCustomer, error) {
|
408
|
|
- var customers []model.TaCustomer
|
409
|
|
- sql := `select * from ta_customer where (recommend_id='` + userid + `'`
|
|
411
|
+func (m *UserDAO) GetUserCustomer(userid, isrecommend, key string, page int, pageSize int) ([]CustomerInfo, error) {
|
|
412
|
+ var customers []CustomerInfo
|
|
413
|
+ sql := `select a.*,
|
|
414
|
+ ( SELECT remark FROM ta_sale_customer_remark b WHERE a.customer_id = b.customer_id ORDER BY b.create_date DESC LIMIT 1 ) AS remark from ta_customer a where (a.recommend_id='` + userid + `'`
|
410
|
415
|
if isrecommend == "" || isrecommend == "false" {
|
411
|
|
- sql += ` or customer_id in (
|
|
416
|
+ sql += ` or a.customer_id in (
|
412
|
417
|
select customer_id from ta_customer_coupon where sales_id='` + userid + `'
|
413
|
418
|
union
|
414
|
419
|
select customer_id from ta_customer_card where sales_id='` + userid + `'
|
|
@@ -416,10 +421,10 @@ func (m *UserDAO) GetUserCustomer(userid, isrecommend, key string, page int, pag
|
416
|
421
|
}
|
417
|
422
|
sql += ")"
|
418
|
423
|
if key != "" {
|
419
|
|
- sql += ` and (customer_name like '%` + key + `%' or phone like '%` + key + `%' or name like '%` + key + `%')`
|
|
424
|
+ sql += ` and (a.customer_name like '%` + key + `%' or a.phone like '%` + key + `%' or a.name like '%` + key + `%')`
|
420
|
425
|
}
|
421
|
426
|
offset := (page - 1) * pageSize
|
422
|
|
- sql += ` order by create_date desc LIMIT ` + strconv.Itoa(pageSize) + ` OFFSET ` + strconv.Itoa(offset)
|
|
427
|
+ sql += ` order by a.create_date desc LIMIT ` + strconv.Itoa(pageSize) + ` OFFSET ` + strconv.Itoa(offset)
|
423
|
428
|
err := m.db.Sql(sql).Find(&customers)
|
424
|
429
|
return customers, err
|
425
|
430
|
}
|