|
|
@@ -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
|
|
|
}
|
|
|
|