Browse Source

客户管理

wangxingcheng 3 years ago
parent
commit
605cd29dd2
1 changed files with 10 additions and 6 deletions
  1. 10 6
      opms_parent/app/service/cust/cust_customer.go

+ 10 - 6
opms_parent/app/service/cust/cust_customer.go

@@ -104,7 +104,7 @@ func (c *customerService) Create(req *model.AddCustCustomerReq) (err error) {
 //客户列表列表
 func (c *customerService) GetList(req *model.CustCustomerSearchReq) (total int, customerList []*model.CustList, err error) {
 
-	Model := c.Dao.M.As("c").LeftJoin("cust_customer_contact ct", "c.id=ct.cust_id").Where("c.is_public ", 20) //非公海客户
+	Model := c.Dao.M.As("c").LeftJoin("cust_customer_contact ct", "c.id=ct.cust_id").Where("c.is_public =?", 20) //非公海客户
 	//客户名称
 	if req.CustName != "" {
 		Model = Model.Where("c.cust_name ", req.CustName)
@@ -156,7 +156,7 @@ func (c *customerService) DistriCustomer(req *model.DistriCustomer) error {
 		err = gerror.New("该数据不存在")
 		return err
 	}
-	err = c.Customer(req.Ids, req.SalesId, 2)
+	err = c.UpdateCustomer(req.Ids, req.SalesId, 2)
 	if err != nil {
 		err = gerror.New("可配客户失败")
 		return err
@@ -186,7 +186,11 @@ func (c *customerService) UpdateBytransfer(req *model.CustSalesReq) (entityInfo
 		err = gerror.New("该数据不存在")
 		return
 	}
-	c.Customer(req.Ids, req.SalesIds, 1)
+	err = c.UpdateCustomer(req.Ids, req.SalesIds, 1)
+	if err != nil {
+		err = gerror.New("转移客户失败")
+		return
+	}
 	belongModel := c.BelongDao.M
 	maps := []map[string]interface{}{}
 	date_time := gtime.Now()
@@ -217,7 +221,8 @@ func (c *customerService) UpdateBytransfer(req *model.CustSalesReq) (entityInfo
 	return
 }
 
-func (c *customerService) Customer(ids []int64, salesId int64, behavior int8) error {
+//变更客户所属关系
+func (c *customerService) UpdateCustomer(ids []int64, salesId int64, behavior int8) error {
 	custModel := c.Dao.M
 	custCustomerData := new(model.CustCustomer)
 	custCustomerData.SalesId = int(salesId)
@@ -244,9 +249,8 @@ func (c *customerService) Customer(ids []int64, salesId int64, behavior int8) er
 		WherePri(cust.CustCustomer.Columns.Id+" in (?)", ids).Update(custCustomerData)
 	if err != nil {
 		g.Log().Error(err)
-		err = gerror.New("转移客户变更失败")
+		err = gerror.New("变更失败")
 		return err
 	}
-
 	return nil
 }