Browse Source

feature(400资讯): 去掉经销商,添加客户、项目、状态字段

likai 1 year ago
parent
commit
97b990f11f

+ 3 - 0
opms_parent/app/dao/cust/internal/product_consult_record.go

@@ -53,6 +53,7 @@ type productConsultRecordColumns struct {
 	CustName        string // 客户名称
 	NboId           string // 关联项目
 	NboName         string // 项目名称
+	State           string // 状态:10(其他)未跟进;20已跟进
 	Remark          string // 备注
 	CreatedBy       string // 创建者
 	CreatedName     string // 创建人
@@ -92,6 +93,7 @@ var (
 			CustName:        "cust_name",
 			NboId:           "nbo_id",
 			NboName:         "nbo_name",
+			State:           "state",
 			Remark:          "remark",
 			CreatedBy:       "created_by",
 			CreatedName:     "created_name",
@@ -133,6 +135,7 @@ func NewProductConsultRecordDao(tenant string) ProductConsultRecordDao {
 			CustName:        "cust_name",
 			NboId:           "nbo_id",
 			NboName:         "nbo_name",
+			State:           "state",
 			Remark:          "remark",
 			CreatedBy:       "created_by",
 			CreatedName:     "created_name",

+ 13 - 0
opms_parent/app/handler/cust/product_consult_record.go

@@ -72,6 +72,19 @@ func (c *ProductConsultRecordHandler) Update(ctx context.Context, req *model.Pro
 	return nil
 }
 
+func (c *ProductConsultRecordHandler) FollowUp(ctx context.Context, req *model.FollowUpReq, rsp *comm_def.CommonMsg) error {
+	g.Log().Infof("ProductConsultRecordHandler.Update request %#v ", *req)
+	s, err := service.NewProductConsultRecordService(ctx)
+	if err != nil {
+		return err
+	}
+	err = s.FollowUp(ctx, req)
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
 func (c *ProductConsultRecordHandler) Delete(ctx context.Context, req *model.IdsReq, rsp *comm_def.CommonMsg) error {
 	g.Log().Infof("ProductConsultRecordHandler.Delete request %#v ", *req)
 	s, err := service.NewProductConsultRecordService(ctx)

+ 1 - 0
opms_parent/app/model/cust/internal/product_consult_record.go

@@ -32,6 +32,7 @@ type ProductConsultRecord struct {
 	CustName        string      `orm:"cust_name"        json:"custName"`        // 客户名称
 	NboId           int         `orm:"nbo_id"           json:"nboId"`           // 关联项目
 	NboName         string      `orm:"nbo_name"         json:"nboName"`         // 项目名称
+	State           string      `orm:"state"            json:"state"`           // 状态:10(其他)未跟进;20已跟进
 	Remark          string      `orm:"remark"           json:"remark"`          // 备注
 	CreatedBy       int         `orm:"created_by"       json:"createdBy"`       // 创建者
 	CreatedName     string      `orm:"created_name"     json:"createdName"`     // 创建人

+ 45 - 31
opms_parent/app/model/cust/product_consult_record.go

@@ -17,47 +17,61 @@ type ProductConsultRecord internal.ProductConsultRecord
 type ProductConsultRecordListReq struct {
 	request.PageReq
 	Name         string `json:"name"`         // 联系人
+	State        string `json:"state"`        // 状态
 	InchargeName string `json:"inchargeName"` // 对接人(销售工程师)
 	Unit         string `json:"unit"`         // 单位名称
 }
 
 type ProductConsultRecordAddReq struct {
-	Code         string      `json:"code"`                              // 序号
+	Code         string      `json:"code"`                                     // 序号
 	ConsultTime  *gtime.Time `json:"consultTime"  v:"required#请输入日期时间"` // 日期时间
-	ProvinceId   int         `json:"provinceId"`                        // 所在省ID
-	Province     string      `json:"province"`                          // 所在省
-	CityId       int         `json:"cityId"`                            // 所在市ID
-	City         string      `json:"city"`                              // 所在市
+	ProvinceId   int         `json:"provinceId"`                               // 所在省ID
+	Province     string      `json:"province"`                                 // 所在省
+	CityId       int         `json:"cityId"`                                   // 所在市ID
+	City         string      `json:"city"`                                     // 所在市
 	Unit         string      `json:"unit" v:"required#请输入单位名称"`         // 单位名称
-	Name         string      `json:"name" v:"required#请输入联系人"`          // 联系人
+	Name         string      `json:"name" v:"required#请输入联系人"`           // 联系人
 	Contact      string      `json:"contact" v:"required#请输入联系方式"`      // 联系方式
 	Product      string      `json:"product" v:"required#请输入咨询产品"`      // 咨询产品
-	InchargeId   int         `json:"inchargeId" v:"required#请输入对接人"`    // 对接人ID
-	InchargeName string      `json:"inchargeName"`                      // 对接人(销售工程师)
-	Content      string      `json:"content" v:"required#请输入400电话内容"`   // 内容
+	InchargeId   int         `json:"inchargeId" v:"required#请输入对接人"`     // 对接人ID
+	InchargeName string      `json:"inchargeName"`                             // 对接人(销售工程师)
+	Remark       string      `json:"remark"`                                   // 备注
 }
 
 type ProductConsultRecordUpdateReq struct {
-	Id              int         `json:"id" v:"required#请输入Id"`
-	ConsultTime     *gtime.Time `json:"consultTime"`     // 日期时间
-	ProvinceId      int         `json:"provinceId"`      // 所在省ID
-	Province        string      `json:"province"`        // 所在省
-	CityId          int         `json:"cityId"`          // 所在市ID
-	City            string      `json:"city"`            // 所在市
-	Unit            string      `json:"unit"`            // 单位名称
-	Name            string      `json:"name"`            // 联系人
-	Contact         string      `json:"contact"`         // 联系方式
-	Product         string      `json:"product"`         // 咨询产品
-	InchargeId      int         `json:"inchargeId"`      // 对接人ID
-	InchargeName    string      `json:"inchargeName"`    // 对接人(销售工程师)
-	Content         string      `json:"content"`         // 内容
-	Progress        string      `json:"progress"`        // 进展
-	NextPlan        string      `json:"nextPlan"`        // 下一步计划
-	DistributorId   int         `json:"distributorId"`   // 经销商ID
-	DistributorName string      `json:"distributorName"` // 经销商
-	CustId          int         `json:"custId"`          // 关联客户
-	CustName        string      `json:"custName"`        // 客户名称
-	NboId           int         `json:"nboId"`           // 关联项目
-	NboName         string      `json:"nboName"`         // 项目名称
-	Remark          string      `json:"remark"`          // 备注
+	Id           int         `json:"id" v:"required#请输入Id"`
+	ConsultTime  *gtime.Time `json:"consultTime"`  // 日期时间
+	ProvinceId   int         `json:"provinceId"`   // 所在省ID
+	Province     string      `json:"province"`     // 所在省
+	CityId       int         `json:"cityId"`       // 所在市ID
+	City         string      `json:"city"`         // 所在市
+	Unit         string      `json:"unit"`         // 单位名称
+	Name         string      `json:"name"`         // 联系人
+	Contact      string      `json:"contact"`      // 联系方式
+	Product      string      `json:"product"`      // 咨询产品
+	InchargeId   int         `json:"inchargeId"`   // 对接人ID
+	InchargeName string      `json:"inchargeName"` // 对接人(销售工程师)
+	Content      string      `json:"content"`      // 内容
+	//Progress        string      `json:"progress"`        // 进展
+	//NextPlan        string      `json:"nextPlan"`        // 下一步计划
+	//DistributorId   int         `json:"distributorId"`   // 经销商ID
+	//DistributorName string      `json:"distributorName"` // 经销商
+	//CustId          int         `json:"custId"`          // 关联客户
+	//CustName        string      `json:"custName"`        // 客户名称
+	//NboId           int         `json:"nboId"`           // 关联项目
+	//NboName         string      `json:"nboName"`         // 项目名称
+	Remark string `json:"remark"` // 备注
+}
+
+type FollowUpReq struct {
+	Id              int    `json:"id" v:"required#请输入Id"`
+	Content         string `json:"content"`         // 内容
+	Progress        string `json:"progress"`        // 进展
+	NextPlan        string `json:"nextPlan"`        // 下一步计划
+	DistributorId   int    `json:"distributorId"`   // 经销商ID
+	DistributorName string `json:"distributorName"` // 经销商
+	CustId          int    `json:"custId"`          // 关联客户
+	CustName        string `json:"custName"`        // 客户名称
+	NboId           int    `json:"nboId"`           // 关联项目
+	NboName         string `json:"nboName"`         // 项目名称
 }

+ 71 - 70
opms_parent/app/service/cust/product_consult_record.go

@@ -58,6 +58,9 @@ func (s ProductConsultRecordService) List(ctx context.Context, req *model.Produc
 		likestr := fmt.Sprintf("%%%s%%", req.Name)
 		dao = dao.Where("name like ?", likestr)
 	}
+	if req.State != "" {
+		dao = dao.Where("state = ?", req.State)
+	}
 	if req.InchargeName != "" {
 		likestr := fmt.Sprintf("%%%s%%", req.InchargeName)
 		dao = dao.Where("incharge_name like ?", likestr)
@@ -92,7 +95,7 @@ func (s ProductConsultRecordService) List(ctx context.Context, req *model.Produc
 	return total, ents, err
 }
 
-func (s *ProductConsultRecordService) consultCode() (string, error) {
+func (s ProductConsultRecordService) consultCode() (string, error) {
 	sequence, err := service.Sequence(s.Dao.DB, "consult_code")
 	if err != nil {
 		return "", err
@@ -133,8 +136,8 @@ func (s ProductConsultRecordService) Add(ctx context.Context, req *model.Product
 		Product:      req.Product,
 		InchargeId:   req.InchargeId,
 		InchargeName: req.InchargeName,
-		Content:      req.Content,
-		Remark:       "",
+		State:        "10",
+		Remark:       req.Remark,
 		CreatedBy:    int(s.userInfo.Id),
 		CreatedName:  s.userInfo.NickName,
 		CreatedTime:  gtime.Now(),
@@ -165,78 +168,76 @@ func (s ProductConsultRecordService) Update(ctx context.Context, req *model.Prod
 	dao := &s.Dao.ProductConsultRecordDao
 	toupdate := map[string]interface{}{}
 
-	if req.ConsultTime != nil {
-		toupdate["consult_time"] = req.ConsultTime
-	}
-	if req.ProvinceId != 0 {
-		toupdate["province_id"] = req.ProvinceId
-	}
-	if req.Province != "" {
-		toupdate["province"] = req.Province
-	}
-	if req.CityId != 0 {
-		toupdate["city_id"] = req.CityId
-	}
-	if req.City != "" {
-		toupdate["city"] = req.City
-	}
-	if req.Unit != "" {
-		toupdate["unit"] = req.Unit
-	}
-	if req.Name != "" {
-		toupdate["name"] = req.Name
-	}
-	if req.Contact != "" {
-		toupdate["contact"] = req.Contact
-	}
-	if req.Product != "" {
-		toupdate["product"] = req.Product
-	}
-	if req.InchargeId != 0 {
-		toupdate["incharge_id"] = req.InchargeId
-	}
-	if req.InchargeName != "" {
-		toupdate["incharge_name"] = req.InchargeName
-	}
-	if req.Content != "" {
-		toupdate["content"] = req.Content
-	}
-	if req.Progress != "" {
-		toupdate["progress"] = req.Progress
-	}
-	if req.NextPlan != "" {
-		toupdate["next_plan"] = req.NextPlan
-	}
-	if req.DistributorId != 0 {
-		toupdate["distributor_id"] = req.DistributorId
-	}
-	if req.DistributorName != "" {
-		toupdate["distributor_name"] = req.DistributorName
-	}
-	if req.CustId != 0 {
-		toupdate["cust_id"] = req.CustId
-	}
-	if req.CustName != "" {
-		toupdate["cust_name"] = req.CustName
+	toupdate["consult_time"] = req.ConsultTime
+	toupdate["province_id"] = req.ProvinceId
+	toupdate["province"] = req.Province
+	toupdate["city_id"] = req.CityId
+	toupdate["city"] = req.City
+	toupdate["unit"] = req.Unit
+	toupdate["name"] = req.Name
+	toupdate["contact"] = req.Contact
+	toupdate["product"] = req.Product
+	toupdate["incharge_id"] = req.InchargeId
+	toupdate["incharge_name"] = req.InchargeName
+	//toupdate["content"] = req.Content
+	//toupdate["progress"] = req.Progress
+	//toupdate["next_plan"] = req.NextPlan
+	//toupdate["distributor_id"] = req.DistributorId
+	//toupdate["distributor_name"] = req.DistributorName
+	//toupdate["cust_id"] = req.CustId
+	//toupdate["cust_name"] = req.CustName
+	//toupdate["nbo_id"] = req.NboId
+	//toupdate["nbo_name"] = req.NboName
+	toupdate["remark"] = req.Remark
+
+	toupdate["updated_by"] = int(s.userInfo.Id)
+	toupdate["updated_name"] = s.userInfo.NickName
+	toupdate["updated_time"] = gtime.Now()
+	_, err = dao.Where("Id", req.Id).Data(toupdate).Update()
+	if err != nil {
+		return err
 	}
-	if req.NboId != 0 {
-		toupdate["nbo_id"] = req.NboId
+
+	return nil
+}
+
+func (s ProductConsultRecordService) FollowUp(ctx context.Context, req *model.FollowUpReq) error {
+	validErr := gvalid.CheckStruct(ctx, req, nil)
+	if validErr != nil {
+		return myerrors.TipsError(validErr.Current().Error())
 	}
-	if req.NboName != "" {
-		toupdate["nbo_name"] = req.NboName
+
+	ent, err := s.Dao.Where("id = ?", req.Id).One()
+	if err != nil {
+		return err
 	}
-	if req.Remark != "" {
-		toupdate["remark"] = req.Remark
+	if ent == nil {
+		return myerrors.TipsError(fmt.Sprintf("记录不存在: %d", req.Id))
 	}
-	if len(toupdate) != 0 {
-		toupdate["updated_by"] = int(s.userInfo.Id)
-		toupdate["updated_name"] = s.userInfo.NickName
-		toupdate["updated_time"] = gtime.Now()
-		_, err = dao.Where("Id", req.Id).Data(toupdate).Update()
-		if err != nil {
-			return err
-		}
+
+	dao := &s.Dao.ProductConsultRecordDao
+	toupdate := map[string]interface{}{}
+
+	toupdate["content"] = req.Content
+	toupdate["progress"] = req.Progress
+	toupdate["next_plan"] = req.NextPlan
+	//toupdate["distributor_id"] = req.DistributorId
+	//toupdate["distributor_name"] = req.DistributorName
+	toupdate["cust_id"] = req.CustId
+	toupdate["cust_name"] = req.CustName
+	toupdate["nbo_id"] = req.NboId
+	toupdate["nbo_name"] = req.NboName
+	toupdate["state"] = "20"
+
+	toupdate["updated_by"] = int(s.userInfo.Id)
+	toupdate["updated_name"] = s.userInfo.NickName
+	toupdate["updated_time"] = gtime.Now()
+
+	_, err = dao.Where("Id", req.Id).Data(toupdate).Update()
+	if err != nil {
+		return err
 	}
+
 	return nil
 }