|
|
@@ -52,7 +52,7 @@ func NewCustomerService(ctx context.Context) (svc *CustomerService, err error) {
|
|
|
return svc, nil
|
|
|
}
|
|
|
|
|
|
-//GetList 客户列表列表
|
|
|
+// GetList 客户列表列表
|
|
|
func (s *CustomerService) GetList(req *model.CustCustomerSearchReq) (total int, customerList []*model.CustList, err error) {
|
|
|
Model := s.Dao.M
|
|
|
if req.TargetType == "" {
|
|
|
@@ -90,7 +90,13 @@ func (s *CustomerService) GetList(req *model.CustCustomerSearchReq) (total int,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- err = Model.Page(req.GetPage()).Order("id desc").Scan(&customerList)
|
|
|
+ if req.IsRemovePage {
|
|
|
+
|
|
|
+ Model = Model
|
|
|
+ } else {
|
|
|
+ Model = Model.Page(req.GetPage())
|
|
|
+ }
|
|
|
+ err = Model.Order("id desc").Scan(&customerList)
|
|
|
if err != nil {
|
|
|
g.Log().Error(err)
|
|
|
return
|
|
|
@@ -98,7 +104,7 @@ func (s *CustomerService) GetList(req *model.CustCustomerSearchReq) (total int,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//Create 创建客户
|
|
|
+// Create 创建客户
|
|
|
func (s *CustomerService) Create(req *model.CustomerAddSeq) (insertId int64, err error) {
|
|
|
cusTomer := new(model.CustCustomer)
|
|
|
count, err := s.Dao.Where(s.Dao.Columns.CustName, req.CustName).Count()
|
|
|
@@ -147,7 +153,7 @@ func (s *CustomerService) Create(req *model.CustomerAddSeq) (insertId int64, err
|
|
|
return insertId, err
|
|
|
}
|
|
|
|
|
|
-//CreateBelong 创建客户归属信息
|
|
|
+// CreateBelong 创建客户归属信息
|
|
|
func (s *CustomerService) CreateBelong(custId int) (insertId int64, err error) {
|
|
|
belong := new(model.CustomerBelongAddSeq)
|
|
|
belong.CustId = custId
|
|
|
@@ -163,7 +169,7 @@ func (s *CustomerService) CreateBelong(custId int) (insertId int64, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//删除客户
|
|
|
+// 删除客户
|
|
|
func (s *CustomerService) DeleteByIds(Ids []int64) (err error) {
|
|
|
customerCount, err := s.Dao.Where(" id in (?)", Ids).Count()
|
|
|
if err != nil {
|
|
|
@@ -196,7 +202,7 @@ func (s *CustomerService) DeleteByIds(Ids []int64) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//UpdateById 修改客户
|
|
|
+// UpdateById 修改客户
|
|
|
func (s *CustomerService) UpdateById(req *model.UpdateCustomer) (err error) {
|
|
|
//判断数据是否存在
|
|
|
count, err := s.Dao.Where("id = ", req.Id).Count()
|
|
|
@@ -233,7 +239,7 @@ func (s *CustomerService) UpdateById(req *model.UpdateCustomer) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//MoveToPubic 移入公海
|
|
|
+// MoveToPubic 移入公海
|
|
|
func (s *CustomerService) MoveToPubic(Ids []int64) (err error) {
|
|
|
count, err := s.Dao.WhereIn(s.Dao.Columns.Id, Ids).Count()
|
|
|
if err != nil {
|
|
|
@@ -264,7 +270,7 @@ func (s *CustomerService) MoveToPubic(Ids []int64) (err error) {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-//AssignCustomer 分配客户
|
|
|
+// AssignCustomer 分配客户
|
|
|
func (s *CustomerService) AssignCustomer(req *model.AssignCustomerReq) (err error) {
|
|
|
data, err := s.Dao.Where("id in (?)", req.Ids).LockShared().All()
|
|
|
if err != nil {
|
|
|
@@ -293,7 +299,7 @@ func (s *CustomerService) AssignCustomer(req *model.AssignCustomerReq) (err erro
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//GetEntityById 客户详情
|
|
|
+// GetEntityById 客户详情
|
|
|
func (s *CustomerService) GetEntityById(Ids []int64) (entityInfo []*model.CustList, err error) {
|
|
|
Model := s.Dao //
|
|
|
err = Model.Where(" id in (?)", Ids).Scan(&entityInfo)
|
|
|
@@ -304,7 +310,7 @@ func (s *CustomerService) GetEntityById(Ids []int64) (entityInfo []*model.CustLi
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//GetCustNameIsExist 获取客户名称
|
|
|
+// GetCustNameIsExist 获取客户名称
|
|
|
func (s *CustomerService) GetCustNameIsExist(name string) (exist bool, err error) {
|
|
|
count, err := s.Dao.Where(cust.CustCustomer.Columns.CustName, name).Count()
|
|
|
if err != nil {
|
|
|
@@ -318,7 +324,7 @@ func (s *CustomerService) GetCustNameIsExist(name string) (exist bool, err error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//CustAbstract 客户摘要
|
|
|
+// CustAbstract 客户摘要
|
|
|
func (s *CustomerService) CustAbstract(Id int64) (followInfo *model.Follow, err error) {
|
|
|
count, err := s.FollowDao.Where(s.FollowDao.Columns.CustId, Id).Count()
|
|
|
if err != nil {
|
|
|
@@ -349,7 +355,7 @@ func (s *CustomerService) CustAbstract(Id int64) (followInfo *model.Follow, err
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//TransCustomer 转移客户
|
|
|
+// TransCustomer 转移客户
|
|
|
func (s *CustomerService) TransCustomer(req *model.AssignCustomerReq) (err error) {
|
|
|
data, err := s.Dao.Fields("sales_id,sales_name,id").Where("id in (?)", req.Ids).All()
|
|
|
if err != nil {
|
|
|
@@ -366,7 +372,7 @@ func (s *CustomerService) TransCustomer(req *model.AssignCustomerReq) (err error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//ChangeCustBelong 变更客户所属关系
|
|
|
+// ChangeCustBelong 变更客户所属关系
|
|
|
func (s *CustomerService) ChangeCustBelong(Ids []int64, salesId int64, salesName string) (err error) {
|
|
|
_, err = s.Dao.Data(g.Map{
|
|
|
"sales_id": salesId,
|
|
|
@@ -384,8 +390,8 @@ func (s *CustomerService) ChangeCustBelong(Ids []int64, salesId int64, salesName
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//OperationLog 客户操作日志
|
|
|
-func (s *CustomerService) OperationLog(ids []int64, req *model.AddCustomerDynameicsReq) (err error) {
|
|
|
+// OperationLog 客户操作日志
|
|
|
+func (s *CustomerService) OperationLog(ctx context.Context, ids []int64, req *model.AddCustomerDynameicsReq) (err error) {
|
|
|
cusDynameics := new(model.CustCustomerDynamics)
|
|
|
if err = gconv.Struct(req, cusDynameics); err != nil {
|
|
|
err = myerrors.NewMsgError(nil, "操作日志验证结构体失败")
|
|
|
@@ -417,7 +423,7 @@ func (s *CustomerService) OperationLog(ids []int64, req *model.AddCustomerDyname
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//GetDynamicsList 客户动态
|
|
|
+// GetDynamicsList 客户动态
|
|
|
func (s *CustomerService) GetDynamicsList(req *model.CustomerDynameicsReq) (total int, result []interface{}, err error) {
|
|
|
total, err = s.DynamicsDao.Where("cust_id = ", req.CustId).Count()
|
|
|
if err != nil {
|
|
|
@@ -447,7 +453,7 @@ func (s *CustomerService) GetDynamicsList(req *model.CustomerDynameicsReq) (tota
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//MergeCustomer 合并客户
|
|
|
+// MergeCustomer 合并客户
|
|
|
func (s *CustomerService) MergeCustomer(req *model.MergecustomerRep) (err error) {
|
|
|
//当前目标客户是否存在
|
|
|
customerCount, err := s.Dao.FindCount(req.Id)
|
|
|
@@ -511,8 +517,8 @@ func (s *CustomerService) Createcontact(Ids []int64, req *model.CustCustomerCont
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//BatchCreatebelong 批量插入客户归属记录表
|
|
|
-func (s *CustomerService) BatchCreatebelong(rep []*model.CustCustomer, req *model.AssignCustomerReq) (err error) {
|
|
|
+// BatchCreatebelong 批量插入客户归属记录表
|
|
|
+func (s *CustomerService) BatchCreatebelong(rep []*model.CustCustomer, req *model.AssignCustomerReq, n ...interface{}) (err error) {
|
|
|
var belongData []*model.CustCustomerBelong
|
|
|
userName := s.GetCxtUserName()
|
|
|
for _, v := range rep {
|
|
|
@@ -538,9 +544,10 @@ func (s *CustomerService) BatchCreatebelong(rep []*model.CustCustomer, req *mode
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//导出数据
|
|
|
+// 导出数据
|
|
|
func (s *CustomerService) Export(req *model.CustCustomerExport) (content *model.CustExport, err error) {
|
|
|
var con model.CustExport
|
|
|
+ req.IsRemovePage = true // 去掉分页标识
|
|
|
total, data, err := s.GetList(&req.CustCustomerSearchReq)
|
|
|
if err != nil {
|
|
|
return
|