Kaynağa Gözat

feature(*): 400资讯页面调整,去掉客户、是否创建项目字段,新增跟进沟通情况字段,并调整关联项目的逻辑

likai 1 yıl önce
ebeveyn
işleme
15572834e6

+ 96 - 93
opms_parent/app/dao/cust/internal/product_consult_record.go

@@ -31,37 +31,38 @@ type ProductConsultRecordDao struct {
 
 // ProductConsultRecordColumns defines and stores column names for table product_consult_record.
 type productConsultRecordColumns struct {
-	Id              string // 主键
-	Code            string // 序号
-	ConsultTime     string // 日期时间
-	ProvinceId      string // 所在省ID
-	Province        string // 所在省
-	CityId          string // 所在市ID
-	City            string // 所在市
-	Unit            string // 单位名称
-	Name            string // 联系人
-	Contact         string // 联系方式
-	Product         string // 咨询产品
-	InchargeId      string // 对接人ID
-	InchargeName    string // 对接人(销售工程师)
-	Content         string // 内容
-	Progress        string // 进展
-	NextPlan        string // 下一步计划
-	DistributorId   string // 经销商ID
-	DistributorName string // 经销商
-	CustId          string // 关联客户
-	CustName        string // 客户名称
-	NboId           string // 关联项目
-	NboName         string // 项目名称
-	State           string // 状态:10(其他)未跟进;20已跟进
-	Remark          string // 备注
-	CreatedBy       string // 创建者
-	CreatedName     string // 创建人
-	CreatedTime     string // 创建时间
-	UpdatedBy       string // 更新者
-	UpdatedName     string // 更新人
-	UpdatedTime     string // 更新时间
-	DeletedTime     string // 删除时间
+	Id                    string // 主键
+	Code                  string // 序号
+	ConsultTime           string // 日期时间
+	ProvinceId            string // 所在省ID
+	Province              string // 所在省
+	CityId                string // 所在市ID
+	City                  string // 所在市
+	Unit                  string // 单位名称
+	Name                  string // 联系人
+	Contact               string // 联系方式
+	Product               string // 咨询产品
+	InchargeId            string // 对接人ID
+	InchargeName          string // 对接人(销售工程师)
+	Content               string // 内容
+	Progress              string // 进展
+	NextPlan              string // 下一步计划
+	DistributorId         string // 经销商ID
+	DistributorName       string // 经销商
+	CustId                string // 关联客户
+	CustName              string // 客户名称
+	NboId                 string // 关联项目
+	NboName               string // 项目名称
+	State                 string // 状态:10(其他)未跟进;20已跟进
+	FollowCommunicateCase string // 10、信息有效,可继续跟进,转C类订单;20、信息有效,可转为储备用户;30、信息无效,不再跟进。
+	Remark                string // 备注
+	CreatedBy             string // 创建者
+	CreatedName           string // 创建人
+	CreatedTime           string // 创建时间
+	UpdatedBy             string // 更新者
+	UpdatedName           string // 更新人
+	UpdatedTime           string // 更新时间
+	DeletedTime           string // 删除时间
 }
 
 var (
@@ -71,37 +72,38 @@ var (
 		DB:    g.DB("default"),
 		Table: "product_consult_record",
 		C: productConsultRecordColumns{
-			Id:              "id",
-			Code:            "code",
-			ConsultTime:     "consult_time",
-			ProvinceId:      "province_id",
-			Province:        "province",
-			CityId:          "city_id",
-			City:            "city",
-			Unit:            "unit",
-			Name:            "name",
-			Contact:         "contact",
-			Product:         "product",
-			InchargeId:      "incharge_id",
-			InchargeName:    "incharge_name",
-			Content:         "content",
-			Progress:        "progress",
-			NextPlan:        "next_plan",
-			DistributorId:   "distributor_id",
-			DistributorName: "distributor_name",
-			CustId:          "cust_id",
-			CustName:        "cust_name",
-			NboId:           "nbo_id",
-			NboName:         "nbo_name",
-			State:           "state",
-			Remark:          "remark",
-			CreatedBy:       "created_by",
-			CreatedName:     "created_name",
-			CreatedTime:     "created_time",
-			UpdatedBy:       "updated_by",
-			UpdatedName:     "updated_name",
-			UpdatedTime:     "updated_time",
-			DeletedTime:     "deleted_time",
+			Id:                    "id",
+			Code:                  "code",
+			ConsultTime:           "consult_time",
+			ProvinceId:            "province_id",
+			Province:              "province",
+			CityId:                "city_id",
+			City:                  "city",
+			Unit:                  "unit",
+			Name:                  "name",
+			Contact:               "contact",
+			Product:               "product",
+			InchargeId:            "incharge_id",
+			InchargeName:          "incharge_name",
+			Content:               "content",
+			Progress:              "progress",
+			NextPlan:              "next_plan",
+			DistributorId:         "distributor_id",
+			DistributorName:       "distributor_name",
+			CustId:                "cust_id",
+			CustName:              "cust_name",
+			NboId:                 "nbo_id",
+			NboName:               "nbo_name",
+			State:                 "state",
+			FollowCommunicateCase: "follow_communicate_case",
+			Remark:                "remark",
+			CreatedBy:             "created_by",
+			CreatedName:           "created_name",
+			CreatedTime:           "created_time",
+			UpdatedBy:             "updated_by",
+			UpdatedName:           "updated_name",
+			UpdatedTime:           "updated_time",
+			DeletedTime:           "deleted_time",
 		},
 	}
 )
@@ -113,37 +115,38 @@ func NewProductConsultRecordDao(tenant string) ProductConsultRecordDao {
 		DB:    g.DB(tenant),
 		Table: "product_consult_record",
 		C: productConsultRecordColumns{
-			Id:              "id",
-			Code:            "code",
-			ConsultTime:     "consult_time",
-			ProvinceId:      "province_id",
-			Province:        "province",
-			CityId:          "city_id",
-			City:            "city",
-			Unit:            "unit",
-			Name:            "name",
-			Contact:         "contact",
-			Product:         "product",
-			InchargeId:      "incharge_id",
-			InchargeName:    "incharge_name",
-			Content:         "content",
-			Progress:        "progress",
-			NextPlan:        "next_plan",
-			DistributorId:   "distributor_id",
-			DistributorName: "distributor_name",
-			CustId:          "cust_id",
-			CustName:        "cust_name",
-			NboId:           "nbo_id",
-			NboName:         "nbo_name",
-			State:           "state",
-			Remark:          "remark",
-			CreatedBy:       "created_by",
-			CreatedName:     "created_name",
-			CreatedTime:     "created_time",
-			UpdatedBy:       "updated_by",
-			UpdatedName:     "updated_name",
-			UpdatedTime:     "updated_time",
-			DeletedTime:     "deleted_time",
+			Id:                    "id",
+			Code:                  "code",
+			ConsultTime:           "consult_time",
+			ProvinceId:            "province_id",
+			Province:              "province",
+			CityId:                "city_id",
+			City:                  "city",
+			Unit:                  "unit",
+			Name:                  "name",
+			Contact:               "contact",
+			Product:               "product",
+			InchargeId:            "incharge_id",
+			InchargeName:          "incharge_name",
+			Content:               "content",
+			Progress:              "progress",
+			NextPlan:              "next_plan",
+			DistributorId:         "distributor_id",
+			DistributorName:       "distributor_name",
+			CustId:                "cust_id",
+			CustName:              "cust_name",
+			NboId:                 "nbo_id",
+			NboName:               "nbo_name",
+			State:                 "state",
+			FollowCommunicateCase: "follow_communicate_case",
+			Remark:                "remark",
+			CreatedBy:             "created_by",
+			CreatedName:           "created_name",
+			CreatedTime:           "created_time",
+			UpdatedBy:             "updated_by",
+			UpdatedName:           "updated_name",
+			UpdatedTime:           "updated_time",
+			DeletedTime:           "deleted_time",
 		},
 	}
 	return dao

+ 32 - 31
opms_parent/app/model/cust/internal/product_consult_record.go

@@ -10,35 +10,36 @@ import (
 
 // ProductConsultRecord is the golang structure for table product_consult_record.
 type ProductConsultRecord struct {
-	Id              int         `orm:"id,primary"       json:"id"`              // 主键
-	Code            string      `orm:"code"             json:"code"`            // 序号
-	ConsultTime     *gtime.Time `orm:"consult_time"     json:"consultTime"`     // 日期时间
-	ProvinceId      int         `orm:"province_id"      json:"provinceId"`      // 所在省ID
-	Province        string      `orm:"province"         json:"province"`        // 所在省
-	CityId          int         `orm:"city_id"          json:"cityId"`          // 所在市ID
-	City            string      `orm:"city"             json:"city"`            // 所在市
-	Unit            string      `orm:"unit"             json:"unit"`            // 单位名称
-	Name            string      `orm:"name"             json:"name"`            // 联系人
-	Contact         string      `orm:"contact"          json:"contact"`         // 联系方式
-	Product         string      `orm:"product"          json:"product"`         // 咨询产品
-	InchargeId      int         `orm:"incharge_id"      json:"inchargeId"`      // 对接人ID
-	InchargeName    string      `orm:"incharge_name"    json:"inchargeName"`    // 对接人(销售工程师)
-	Content         string      `orm:"content"          json:"content"`         // 内容
-	Progress        string      `orm:"progress"         json:"progress"`        // 进展
-	NextPlan        string      `orm:"next_plan"        json:"nextPlan"`        // 下一步计划
-	DistributorId   int         `orm:"distributor_id"   json:"distributorId"`   // 经销商ID
-	DistributorName string      `orm:"distributor_name" json:"distributorName"` // 经销商
-	CustId          int         `orm:"cust_id"          json:"custId"`          // 关联客户
-	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"`     // 创建人
-	CreatedTime     *gtime.Time `orm:"created_time"     json:"createdTime"`     // 创建时间
-	UpdatedBy       int         `orm:"updated_by"       json:"updatedBy"`       // 更新者
-	UpdatedName     string      `orm:"updated_name"     json:"updatedName"`     // 更新人
-	UpdatedTime     *gtime.Time `orm:"updated_time"     json:"updatedTime"`     // 更新时间
-	DeletedTime     *gtime.Time `orm:"deleted_time"     json:"deletedTime"`     // 删除时间
+	Id                    int         `orm:"id,primary"              json:"id"`                    // 主键
+	Code                  string      `orm:"code"                    json:"code"`                  // 序号
+	ConsultTime           *gtime.Time `orm:"consult_time"            json:"consultTime"`           // 日期时间
+	ProvinceId            int         `orm:"province_id"             json:"provinceId"`            // 所在省ID
+	Province              string      `orm:"province"                json:"province"`              // 所在省
+	CityId                int         `orm:"city_id"                 json:"cityId"`                // 所在市ID
+	City                  string      `orm:"city"                    json:"city"`                  // 所在市
+	Unit                  string      `orm:"unit"                    json:"unit"`                  // 单位名称
+	Name                  string      `orm:"name"                    json:"name"`                  // 联系人
+	Contact               string      `orm:"contact"                 json:"contact"`               // 联系方式
+	Product               string      `orm:"product"                 json:"product"`               // 咨询产品
+	InchargeId            int         `orm:"incharge_id"             json:"inchargeId"`            // 对接人ID
+	InchargeName          string      `orm:"incharge_name"           json:"inchargeName"`          // 对接人(销售工程师)
+	Content               string      `orm:"content"                 json:"content"`               // 内容
+	Progress              string      `orm:"progress"                json:"progress"`              // 进展
+	NextPlan              string      `orm:"next_plan"               json:"nextPlan"`              // 下一步计划
+	DistributorId         int         `orm:"distributor_id"          json:"distributorId"`         // 经销商ID
+	DistributorName       string      `orm:"distributor_name"        json:"distributorName"`       // 经销商
+	CustId                int         `orm:"cust_id"                 json:"custId"`                // 关联客户
+	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已跟进
+	FollowCommunicateCase string      `orm:"follow_communicate_case" json:"followCommunicateCase"` // 10、信息有效,可继续跟进,转C类订单;20、信息有效,可转为储备用户;30、信息无效,不再跟进。
+	Remark                string      `orm:"remark"                  json:"remark"`                // 备注
+	CreatedBy             int         `orm:"created_by"              json:"createdBy"`             // 创建者
+	CreatedName           string      `orm:"created_name"            json:"createdName"`           // 创建人
+	CreatedTime           *gtime.Time `orm:"created_time"            json:"createdTime"`           // 创建时间
+	UpdatedBy             int         `orm:"updated_by"              json:"updatedBy"`             // 更新者
+	UpdatedName           string      `orm:"updated_name"            json:"updatedName"`           // 更新人
+	UpdatedTime           *gtime.Time `orm:"updated_time"            json:"updatedTime"`           // 更新时间
+	DeletedTime           *gtime.Time `orm:"deleted_time"            json:"deletedTime"`           // 删除时间
 }

+ 14 - 13
opms_parent/app/model/cust/product_consult_record.go

@@ -23,19 +23,19 @@ type ProductConsultRecordListReq struct {
 }
 
 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"`                             // 对接人(销售工程师)
-	Remark       string      `json:"remark"`                                   // 备注
+	InchargeId   int         `json:"inchargeId" v:"required#请输入对接人"`    // 对接人ID
+	InchargeName string      `json:"inchargeName"`                      // 对接人(销售工程师)
+	Remark       string      `json:"remark"`                            // 备注
 }
 
 type ProductConsultRecordUpdateReq struct {
@@ -70,8 +70,9 @@ type FollowUpReq struct {
 	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"`         // 项目名称
+	//CustId                int    `json:"custId"`                // 关联客户
+	//CustName              string `json:"custName"`              // 客户名称
+	NboId                 int    `json:"nboId"`                 // 关联项目
+	NboName               string `json:"nboName"`               // 项目名称
+	FollowCommunicateCase string `json:"followCommunicateCase"` // 10、信息有效,可继续跟进,转C类订单;20、信息有效,可转为储备用户;30、信息无效,不再跟进。
 }

+ 3 - 2
opms_parent/app/service/cust/product_consult_record.go

@@ -223,11 +223,12 @@ func (s ProductConsultRecordService) FollowUp(ctx context.Context, req *model.Fo
 	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["cust_id"] = req.CustId
+	//toupdate["cust_name"] = req.CustName
 	toupdate["nbo_id"] = req.NboId
 	toupdate["nbo_name"] = req.NboName
 	toupdate["state"] = "20"
+	toupdate["follow_communicate_case"] = req.FollowCommunicateCase
 
 	toupdate["updated_by"] = int(s.userInfo.Id)
 	toupdate["updated_name"] = s.userInfo.NickName

+ 42 - 13
opms_parent/app/service/home/report.go

@@ -175,8 +175,22 @@ func getCompanyContractReportData(ctx context.Context, dataType string, params *
 		}
 	}
 
+	// 过滤掉已删除的销售
+	normalUserMap := make(map[int]bool)
+	normalUsers, err := srv.Dao.DB.Model("sys_user").Where("status='10'").FindAll()
+	if err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	for _, user := range normalUsers {
+		normalUserMap[user["id"].Int()] = true
+	}
+
 	// 统计目标值和实际值
 	for index, target := range targets {
+		// 过滤掉已删除的销售
+		if !normalUserMap[target["sale_user_id"].Int()] {
+			continue
+		}
 		reportData.XData = append(reportData.XData, target["sale_user_name"].String())
 		reportData.YDataTarget = append(reportData.YDataTarget, target[targetField].Float64())
 		if realData, ok := realMap[target["sale_user_id"].Int()]; ok {
@@ -226,19 +240,19 @@ func getQuarterGoalReportData(ctx context.Context, dataType string, params *map[
 	}
 
 	got := map[string]float64{}
-	ctrdao := srv.Dao.Where("year(created_time) = ?", year)
+	ctrdao := srv.Dao.As("a").InnerJoin("sys_user b", "a.incharge_id=b.id").Where("b.status='10'").Where("year(a.created_time) = ?", year)
 	if quarter != 0 {
 		if quarter == 1 {
-			ctrdao = ctrdao.Where("month(created_time) in (1,2,3)")
+			ctrdao = ctrdao.Where("month(a.created_time) in (1,2,3)")
 		}
 		if quarter == 2 {
-			ctrdao = ctrdao.Where("month(created_time) in (4,5,6)")
+			ctrdao = ctrdao.Where("month(a.created_time) in (4,5,6)")
 		}
 		if quarter == 3 {
-			ctrdao = ctrdao.Where("month(created_time) in (7,8,9)")
+			ctrdao = ctrdao.Where("month(a.created_time) in (7,8,9)")
 		}
 		if quarter == 4 {
-			ctrdao = ctrdao.Where("month(created_time) in (10,11,12)")
+			ctrdao = ctrdao.Where("month(a.created_time) in (10,11,12)")
 		}
 	}
 	ctrent, err := ctrdao.All()
@@ -305,8 +319,23 @@ func getClockfrequency(ctx context.Context, dataType string, params *map[string]
 	if err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
+
+	// 过滤掉已删除的销售
+	normalUserMap := make(map[int]bool)
+	normalUsers, err := srv.Dao.DB.Model("sys_user").Where("status='10'").FindAll()
+	if err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	for _, user := range normalUsers {
+		normalUserMap[user["id"].Int()] = true
+	}
+
 	// 赋值实际值
 	for index, target := range platpunchrecords {
+		// 过滤掉已删除的销售
+		if !normalUserMap[target["user_id"].Int()] {
+			continue
+		}
 		reportData.XData = append(reportData.XData, target["user_nick_name"].String())
 		reportData.YDataTarget = append(reportData.YDataTarget, target["punch_sum"].Float64())
 		if realData, ok := realMap[target["punch_sum"].Int()]; ok {
@@ -637,9 +666,9 @@ func (s *HomeService) getNewAndConvertBusiness(productLine []string, params *map
 // 报表数据   三大产品线,AB类项目出货金额
 func (s *HomeService) getShipmentAmount(productLine, nboType []string) (interface{}, error) {
 	businessDao := projDao.NewProjBusinessDao(s.Tenant)
-	data, err := businessDao.Fields("product_line, nbo_type, SUM(est_trans_price) as est_trans_price").
-		WhereIn("product_line", productLine).WhereIn("nbo_type", nboType).
-		Group("product_line, nbo_type").Order("product_line ASC, nbo_type ASC").DataScope(s.Ctx, "sale_id").All()
+	data, err := businessDao.As("a").InnerJoin("sys_user b", "a.sale_id=b.id").Fields("a.product_line, a.nbo_type, SUM(a.est_trans_price) as est_trans_price").Where("b.status='10'").
+		WhereIn("a.product_line", productLine).WhereIn("a.nbo_type", nboType).
+		Group("a.product_line, a.nbo_type").Order("a.product_line ASC, a.nbo_type ASC").DataScope(s.Ctx, "a.sale_id").All()
 	if err != nil {
 		return nil, err
 	}
@@ -665,28 +694,28 @@ func (s *HomeService) getProductLineSignedAndBackAmount(productLine []string) (i
 	monthEnd := currentTime.EndOfMonth()
 
 	contractDao := contDao.NewCtrContractDao(s.Tenant)
-	commonDao := contractDao.DataScope(s.Ctx, "incharge_id").WhereIn(contractDao.C.ProductLine, productLine).
+	commonDao := contractDao.As("a").InnerJoin("sys_user b", "a.incharge_id=b.id").DataScope(s.Ctx, "incharge_id").WhereIn(contractDao.C.ProductLine, productLine).Where("b.status='10'").
 		Group(contractDao.C.ProductLine).OrderAsc(contractDao.C.ProductLine)
 
 	//累计签约合同金额 contract_amount
-	allContractAmount, err := commonDao.Fields("product_line, SUM(contract_amount) as contract_amount").All()
+	allContractAmount, err := commonDao.Fields("a.product_line, SUM(a.contract_amount) as contract_amount").All()
 	if err != nil {
 		return nil, err
 	}
 	//累计回款金额 collected_amount
-	allCollectedAmount, err := commonDao.Fields("product_line, SUM(collected_amount) as collected_amount").All()
+	allCollectedAmount, err := commonDao.Fields("a.product_line, SUM(a.collected_amount) as collected_amount").All()
 	if err != nil {
 		return nil, err
 	}
 	//当月签约合同金额(维度:月)
 	monthContractAmount, err := commonDao.WhereGTE(contractDao.C.ContractStartTime, monthStart).WhereLTE(contractDao.C.ContractStartTime, monthEnd).
-		Fields("product_line, SUM(contract_amount) as contract_amount").All()
+		Fields("a.product_line, SUM(a.contract_amount) as contract_amount").All()
 	if err != nil {
 		return nil, err
 	}
 	//当月回款金额(维度:月)
 	monthCollectedAmount, err := commonDao.WhereGTE(contractDao.C.ContractStartTime, monthStart).WhereLTE(contractDao.C.ContractStartTime, monthEnd).
-		Fields("product_line, SUM(collected_amount) as collected_amount").All()
+		Fields("a.product_line, SUM(a.collected_amount) as collected_amount").All()
 	if err != nil {
 		return nil, err
 	}