cust_customer_belong.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package cust
  2. import (
  3. "context"
  4. "github.com/gogf/gf/frame/g"
  5. "github.com/gogf/gf/util/gconv"
  6. "dashoo.cn/micro/app/dao/cust"
  7. model "dashoo.cn/micro/app/model/cust"
  8. "dashoo.cn/micro/app/service"
  9. )
  10. type CustomerbelongService struct {
  11. *service.ContextService
  12. Dao *cust.CustCustomerBelongDao
  13. }
  14. func NewCustomerBelongService(ctx context.Context) (svc *CustomerbelongService, err error) {
  15. svc = new(CustomerbelongService)
  16. if svc.ContextService, err = svc.Init(ctx); err != nil {
  17. return nil, err
  18. }
  19. svc.Dao = cust.NewCustCustomerBelongDao(svc.Tenant)
  20. return svc, nil
  21. }
  22. //GetList 获取客户归属信息
  23. func (s *CustomerbelongService) GetList(req *model.ReqCustomerBelongReq) (total int, Info []*model.CustomerBelongInfo, err error) {
  24. err = s.Dao.Where("cust_id = ", req.CustId).Scan(&Info)
  25. if err != nil {
  26. g.Log().Error(err)
  27. return
  28. }
  29. total, err = s.Dao.Count()
  30. if err != nil {
  31. g.Log().Error(err)
  32. return
  33. }
  34. return
  35. }
  36. //Create 插入归属销售
  37. func (s *CustomerbelongService) Create(req *model.CustomerBelongAddSeq) (err error) {
  38. cusTomerBelong := new(model.CustCustomerBelong)
  39. if err = gconv.Struct(req, cusTomerBelong); err != nil {
  40. g.Log().Error(err)
  41. return
  42. }
  43. service.SetCreatedInfo(cusTomerBelong, s.GetCxtUserId(), s.GetCxtUserName())
  44. _, err = s.Dao.Insert(cusTomerBelong)
  45. if err != nil {
  46. g.Log().Error(err)
  47. return
  48. }
  49. return nil
  50. }