浏览代码

feature(订单管理系统):
1、跟进记录增加日期及跟进类型的筛选。

2、当月签约金额的抓取合同签约时间和合同金额的数据

3、销售区域授权没有香港地区问题修复。

4、打卡跳转客户/经销商的列表,打卡可以关联到具体客户或者经销商名单。

5、公海客户查询条件调整:客户名称、省份、市、跟进时间(改为时间段)。

6、储备客户查询条件调整:所属销售、跟进时间(改为时间段)。

7、跟进记录查询条件优化:跟进时间、跟进类型(电话、拜访、邮件)、跟进对象、跟进人

销售功能是客户查看自己所负责的项目历史全部跟进记录。增加跟进时间、跟进方式的筛选方式。

3】公海客户按照所在省、所在市查询
4】储备客户增加所属销售、所在省、所在市查询类型
5.新增数据指标

niezch 2 年之前
父节点
当前提交
43ccae3878

+ 5 - 1
opms_parent/app/model/cust/cust_customer.go

@@ -23,9 +23,13 @@ type CustCustomerSearchReq struct {
 	CustIndustry string `json:"custIndustry"`
 	CustLevel    string `json:"custLevel"`
 	TargetType   string `json:"targetType,omitempty"`
-	FollowUpDate string `json:"followUpDate,omitempty"`
+	//FollowUpDate string `json:"followUpDate,omitempty"`
 	Remark       string `json:"remark"`
 	IsRemovePage bool   `json:"isRemovePage,omitempty"` //是否去掉分页
+	CustProvince string `json:"custProvince"`           // 所在省
+	CustCity     string `json:"custCity"`               // 所在市
+	CreateOn     string `json:"createOn"`
+	SalesName    string `json:"salesName"` // 所属于销售
 	request.PageReq
 }
 

+ 26 - 0
opms_parent/app/model/plat/plat_followup.go

@@ -8,6 +8,7 @@ import (
 	"dashoo.cn/micro/app/model/plat/internal"
 	"dashoo.cn/opms_libary/request"
 	"github.com/gogf/gf/os/gtime"
+	"time"
 )
 
 // PlatFollowup is the golang structure for table plat_followup.
@@ -17,6 +18,9 @@ type PlatFollowup internal.PlatFollowup
 
 // 查询
 type SearchPlatFollowupReq struct {
+	Sell            string `json:"sell"`
+	FollowType      string `json:"followType"`
+	CreateOn        string `json:"createOn"`
 	CustId          string `json:"custId"`
 	CustName        string `json:"custName"`
 	TargetType      string `son:"targetType"`
@@ -61,3 +65,25 @@ type FollowupInfoResp struct {
 	FollowDay    string          `json:"followDay"`    // 跟进记录的当天日期
 	FollowupList []*FollowupInfo `json:"followupList"` // 跟进记录
 }
+
+// 跟进记录数据
+type Followlist struct {
+	FollowType string `json:"followType"`
+	Num        string `json:"num"`
+}
+
+// 跟进记录统计
+type Statistics struct {
+	Phone    int    `json:"phone"`    //电话
+	Mail     int    `json:"mail"`     //邮件
+	PayVisit int    `json:"payvisit"` //拜访
+	Total    int    `json:"total"`    //总计
+	Week     string `json:"week"`     //总计
+}
+type WeekDate struct {
+	WeekTh string
+
+	StartTime time.Time
+
+	EndTime time.Time
+}

+ 22 - 2
opms_parent/app/service/cust/cust_customer.go

@@ -100,8 +100,28 @@ func (s *CustomerService) GetList(req *model.CustCustomerSearchReq) (total int,
 		Model = Model.Where(s.Dao.C.CustLevel, req.CustLevel)
 	}
 	//
-	if req.FollowUpDate != "" {
-		Model = Model.Where(s.Dao.C.FollowUpDate+" like ? ", req.FollowUpDate+"%")
+	//if req.FollowUpDate != "" {
+	//	Model = Model.Where(s.Dao.C.FollowUpDate+" like ? ", req.FollowUpDate+"%")
+	//}
+	//省份
+	if req.CustProvince != "" {
+		Model = Model.Where(s.Dao.C.CustProvince, req.CustProvince)
+	}
+	//市
+	if req.CustCity != "" {
+		Model = Model.Where(s.Dao.C.CustCity, req.CustCity)
+	}
+	//所属销售
+	if req.SalesName != "" {
+		Model = Model.Where(s.Dao.C.SalesName+" like ?", "%"+req.SalesName+"%")
+	}
+	if req.CreateOn != "" {
+		dates := strings.Split(req.CreateOn, ",")
+		if len(dates) == 2 {
+			begin := dates[0]
+			end := dates[1]
+			Model = Model.Where(s.Dao.C.FollowUpDate+" >=? AND "+s.Dao.C.FollowUpDate+"<=?", begin, end)
+		}
 	}
 
 	if req.IsRemovePage {

+ 11 - 5
opms_parent/app/service/home/home.go

@@ -112,6 +112,12 @@ func (s *HomeService) getReportData(id int64, params *map[string]interface{}) (i
 	case 20007:
 		// 报表数据   季度回款指标
 		return getQuarterGoalReportData(s.ContextService.Ctx, "20", params)
+	case 20008:
+		//报表数据 现场打卡频次
+		return getClockfrequency(s.ContextService.Ctx, "20", params)
+	case 20009:
+		//表格数据 跟进记录频次
+		return getFollowUpRecord(s.ContextService.Ctx, "20", params)
 	default:
 		return nil, nil
 	}
@@ -153,26 +159,26 @@ func (s *HomeService) getNumStatisticsData(id int64, params *map[string]interfac
 		return gconv.String(count), err
 
 	case 10006: //当月新增合同数量(维度:月)
-		count, err := contractDao.DataScope(s.Ctx, "incharge_id").WhereGTE(contractDao.C.CreatedTime, monthStart).WhereLTE(contractDao.C.CreatedTime, monthEnd).CountColumn("id")
+		count, err := contractDao.DataScope(s.Ctx, "incharge_id").WhereGTE(contractDao.C.ContractStartTime, monthStart).WhereLTE(contractDao.C.CreatedTime, monthEnd).CountColumn("id")
 		return gconv.String(count), err
 
 	case 10007: //当月签约合同金额(维度:月)
-		count, err := contractDao.DataScope(s.Ctx, "incharge_id").WhereGTE(contractDao.C.CreatedTime, monthStart).WhereLTE(contractDao.C.CreatedTime, monthEnd).
+		count, err := contractDao.DataScope(s.Ctx, "incharge_id").WhereGTE(contractDao.C.ContractStartTime, monthStart).WhereLTE(contractDao.C.CreatedTime, monthEnd).
 			Sum(contractDao.C.ContractAmount)
 		return gconv.String(count), err
 
 	case 10008: //当月回款金额(维度:月)
-		count, err := contractDao.DataScope(s.Ctx, "incharge_id").WhereGTE(contractDao.C.CreatedTime, monthStart).WhereLTE(contractDao.C.CreatedTime, monthEnd).
+		count, err := contractDao.DataScope(s.Ctx, "incharge_id").WhereGTE(contractDao.C.ContractStartTime, monthStart).WhereLTE(contractDao.C.CreatedTime, monthEnd).
 			Sum(contractDao.C.CollectedAmount)
 		return gconv.String(count), err
 
 	case 10009: //当年的签约金额(维度:年)
-		count, err := contractDao.DataScope(s.Ctx, "incharge_id").WhereGTE(contractDao.C.CreatedTime, yearStart).WhereLTE(contractDao.C.CreatedTime, yearEnd).
+		count, err := contractDao.DataScope(s.Ctx, "incharge_id").WhereGTE(contractDao.C.ContractStartTime, yearStart).WhereLTE(contractDao.C.CreatedTime, yearEnd).
 			Sum(contractDao.C.ContractAmount)
 		return gconv.String(count), err
 
 	case 10010: //当年的回款金额(维度:年)
-		count, err := contractDao.DataScope(s.Ctx, "incharge_id").WhereGTE(contractDao.C.CreatedTime, yearStart).WhereLTE(contractDao.C.CreatedTime, yearEnd).
+		count, err := contractDao.DataScope(s.Ctx, "incharge_id").WhereGTE(contractDao.C.ContractStartTime, yearStart).WhereLTE(contractDao.C.CreatedTime, yearEnd).
 			Sum(contractDao.C.CollectedAmount)
 		return gconv.String(count), err
 

+ 269 - 5
opms_parent/app/service/home/report.go

@@ -2,16 +2,19 @@ package home
 
 import (
 	"context"
-	"database/sql"
-	"fmt"
-
 	"dashoo.cn/micro/app/model/home"
+	"dashoo.cn/micro/app/model/plat"
 	"dashoo.cn/micro/app/service"
 	contractService "dashoo.cn/micro/app/service/contract"
+	platService "dashoo.cn/micro/app/service/plat"
 	"dashoo.cn/opms_libary/micro_srv"
+	"database/sql"
+	"fmt"
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/util/gconv"
+	"math"
+	"time"
 )
 
 // getPersonalContractReportData 获取个人数据
@@ -147,7 +150,7 @@ func getCompanyContractReportData(ctx context.Context, dataType string, params *
 	// 统计合同值
 	contractModel := srv.Dao.DB.Model("ctr_contract").Group("ctr_contract.incharge_id").Order("ctr_contract.incharge_id ASC")
 	if dataType != "COLLECTION" {
-		contracts, err := contractModel.Where(dateWhere1).Fields("ctr_contract.incharge_id, ctr_contract.incharge_name, SUM(ctr_contract.contract_amount) contract_amount").FindAll()
+		contracts, err := contractModel.Where(dateWhere1).Fields("ctr_contract.incharge_id, ctr_contract.incharge_name, count(ctr_contract.contract_amount) contract_amount").FindAll()
 		if err != nil && err != sql.ErrNoRows {
 			return nil, err
 		}
@@ -264,6 +267,115 @@ func getQuarterGoalReportData(ctx context.Context, dataType string, params *map[
 	return &reportData, nil
 }
 
+//客户现场打卡频次
+func getClockfrequency(ctx context.Context, dataType string, params *map[string]interface{}) (*home.ReportData, error) {
+	var reportData home.ReportData
+	realMap := make(map[int]gdb.Record, 0)
+	dateWhere1 := "" // 查询条件
+	date := gtime.Now()
+	nowTime := gtime.Datetime()
+	if params != nil && (*params)["date"] != nil {
+		date = gconv.GTime((*params)["date"])
+	}
+
+	if params != nil && (*params)["searchType"] != nil {
+		searchType := gconv.String((*params)["searchType"])
+		if searchType == "month" {
+			dateWhere1 = fmt.Sprintf("plat_punch_records.punch_time LIKE '%v'", date.Format("Y-m")+"-%")
+		} else if searchType == "week" {
+			weekday := transferWeekday(date.Weekday())
+			fmt.Println(weekday)
+			beforeTime := gtime.NewFromStr(nowTime).AddDate(0, 0, -gconv.Int(weekday)).String()
+			endTime := gtime.NewFromStr(nowTime).AddDate(0, 0, 7-gconv.Int(weekday)).String()
+			dateWhere1 = fmt.Sprintf("plat_punch_records.punch_time between '%v' and '%v'", beforeTime, endTime)
+		}
+	}
+	srv, err := platService.NewPunchRecordsService(ctx)
+	if err != nil {
+		return nil, err
+	}
+	platpunchrecords, err := srv.Dao.DB.Model("plat_punch_records").Where(dateWhere1).Fields("plat_punch_records.user_nick_name,Count(plat_punch_records.user_nick_name) as punch_sum").Group("plat_punch_records.user_nick_name").FindAll()
+	if err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	// 赋值实际值
+	for index, target := range platpunchrecords {
+		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 {
+			reportData.YDataReal = append(reportData.YDataReal, realData["punch_sum"].Float64())
+		} else {
+			reportData.YDataReal = append(reportData.YDataReal, 0)
+		}
+		if reportData.YDataTarget[index] == 0 {
+			reportData.PercentData = append(reportData.PercentData, 0)
+		} else {
+			reportData.PercentData = append(reportData.PercentData, reportData.YDataReal[index]*100/reportData.YDataTarget[index])
+		}
+	}
+	return &reportData, nil
+}
+
+//销售工程师跟进记录的打卡频次
+func getFollowUpRecord(ctx context.Context, dataType string, params *map[string]interface{}) ([]plat.Statistics, error) {
+	now := time.Now()
+	date := gconv.Int(gtime.Now().Month())
+	if params != nil && (*params)["date"] != nil {
+		date = gconv.Int((*params)["date"])
+	}
+	// 获取本月的第一天
+	firstOfMonth := time.Date(now.Year(), time.Month(date), 1, 0, 0, 0, 0, now.Location())
+	// 获取本月的最后一天
+	lastOfMonth := firstOfMonth.AddDate(0, 1, -1)
+
+	l, _ := time.LoadLocation("Asia/Shanghai")
+
+	startTime, _ := time.ParseInLocation("2006-01-02", firstOfMonth.Format("2006-01-02"), l)
+
+	endTime, _ := time.ParseInLocation("2006-01-02", lastOfMonth.Format("2006-01-02"), l)
+
+	datas := GroupByWeekDate(startTime, endTime)
+
+	var Follows []plat.Followlist
+
+	srv, err := platService.NewFollowupService(ctx)
+	if err != nil {
+		return nil, err
+	}
+
+	var stats []plat.Statistics
+	for _, d := range datas {
+
+		err = srv.Dao.DB.Model("plat_followup").
+			Where("follow_date>=? and follow_date<=?", d.StartTime.Format("2006-01-02"), d.EndTime.Format("2006-01-02")).Fields("count(follow_type)as num ,follow_type").
+			Group("date_format(follow_date,'%v'),follow_type").Scan(&Follows)
+		if err != nil && err != sql.ErrNoRows {
+			return nil, err
+		}
+		if len(Follows) > 0 {
+			var stat plat.Statistics
+			for _, val := range Follows {
+
+				if val.FollowType == "10" {
+					stat.Phone = gconv.Int(val.Num)
+				} else if val.FollowType == "20" {
+					stat.Mail = gconv.Int(val.Num)
+				} else if val.FollowType == "30" {
+					stat.PayVisit = gconv.Int(val.Num)
+				}
+
+			}
+			stat.Total = stat.Phone + stat.Mail + stat.PayVisit
+			stat.Week = d.WeekTh + "周"
+			stats = append(stats, stat)
+
+		}
+
+	}
+
+	return stats, nil
+
+}
 func getQuarterWhere(date *gtime.Time, field string) string {
 	if date.Month() >= 1 && date.Month() <= 3 {
 		return fmt.Sprintf("%v >= '%v' AND %v < '%v'", field, date.Format("Y-")+"01-01 00:00:00", field, date.Format("Y-")+"04-01 00:00:00")
@@ -276,7 +388,6 @@ func getQuarterWhere(date *gtime.Time, field string) string {
 	}
 	return ""
 }
-
 func getQuarterMonthWhere(date *gtime.Time, field string) string {
 	if date.Month() >= 1 && date.Month() <= 3 {
 		return fmt.Sprintf("%v >= %v AND %v < %v", field, 1, field, 4)
@@ -289,3 +400,156 @@ func getQuarterMonthWhere(date *gtime.Time, field string) string {
 	}
 	return ""
 }
+func transferWeekday(day time.Weekday) string {
+	switch day {
+	case time.Monday:
+		return "1"
+	case time.Tuesday:
+		return "2"
+	case time.Wednesday:
+		return "3"
+	case time.Thursday:
+		return "4"
+	case time.Friday:
+		return "5"
+	case time.Saturday:
+		return "6"
+	case time.Sunday:
+		return "7"
+	default:
+		return ""
+	}
+}
+
+//判断时间是当年的第几周
+func WeekByDate(t time.Time) string {
+
+	yearDay := t.YearDay()
+
+	yearFirstDay := t.AddDate(0, 0, -yearDay+1)
+
+	firstDayInWeek := int(yearFirstDay.Weekday())
+
+	//今年第一周有几天
+
+	firstWeekDays := 1
+
+	if firstDayInWeek != 0 {
+
+		firstWeekDays = 7 - firstDayInWeek + 1
+
+	}
+
+	var week int
+	Weeks := WeekByDates(t)
+	if yearDay <= firstWeekDays {
+
+		week = 1
+
+	} else {
+
+		week = (yearDay-firstWeekDays)/7 + 2
+
+	}
+	return fmt.Sprintf("%d", week-gconv.Int(Weeks)+1)
+}
+func WeekByDates(now time.Time) int {
+	l, _ := time.LoadLocation("Asia/Shanghai")
+	// 获取本月的第一天
+	firstOfMonth := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
+	endTime, _ := time.ParseInLocation("2006-01-02", firstOfMonth.Format("2006-01-02"), l)
+	t := endTime
+	yearDay := t.YearDay()
+
+	yearFirstDay := t.AddDate(0, 0, -yearDay+1)
+
+	firstDayInWeek := int(yearFirstDay.Weekday())
+
+	//今年第一周有几天
+
+	firstWeekDays := 1
+
+	if firstDayInWeek != 0 {
+
+		firstWeekDays = 7 - firstDayInWeek + 1
+
+	}
+
+	var week int
+
+	if yearDay <= firstWeekDays {
+
+		week = 1
+
+	} else {
+
+		week = (yearDay-firstWeekDays)/7 + 2
+
+	}
+
+	return week
+
+}
+
+// 将开始时间和结束时间分割为周为单位
+func GroupByWeekDate(startTime, endTime time.Time) []plat.WeekDate {
+
+	weekDate := make([]plat.WeekDate, 0)
+
+	diffDuration := endTime.Sub(startTime)
+
+	days := int(math.Ceil(float64(diffDuration/(time.Hour*24)))) + 1
+
+	currentWeekDate := plat.WeekDate{}
+
+	currentWeekDate.WeekTh = WeekByDate(endTime)
+
+	currentWeekDate.EndTime = endTime
+
+	currentWeekDay := int(endTime.Weekday())
+
+	if currentWeekDay == 0 {
+
+		currentWeekDay = 7
+
+	}
+
+	currentWeekDate.StartTime = endTime.AddDate(0, 0, -currentWeekDay+1)
+
+	nextWeekEndTime := currentWeekDate.StartTime
+
+	weekDate = append(weekDate, currentWeekDate)
+
+	for i := 0; i < (days-currentWeekDay)/7; i++ {
+
+		weekData := plat.WeekDate{}
+
+		weekData.EndTime = nextWeekEndTime
+
+		weekData.StartTime = nextWeekEndTime.AddDate(0, 0, -7)
+
+		weekData.WeekTh = WeekByDate(weekData.StartTime)
+
+		nextWeekEndTime = weekData.StartTime
+
+		weekDate = append(weekDate, weekData)
+
+	}
+
+	if lastDays := (days - currentWeekDay) % 7; lastDays > 0 {
+
+		lastData := plat.WeekDate{}
+
+		lastData.EndTime = nextWeekEndTime
+
+		lastData.StartTime = nextWeekEndTime.AddDate(0, 0, -lastDays)
+
+		lastData.WeekTh = WeekByDate(lastData.StartTime)
+
+		weekDate = append(weekDate, lastData)
+
+	}
+
+	return weekDate
+
+}

+ 158 - 24
opms_parent/app/service/home/report_test.go

@@ -1,32 +1,166 @@
 package home
 
 import (
+	"fmt"
 	"testing"
-
-	"dashoo.cn/micro/app/model/contract"
-	"github.com/gogf/gf/frame/g"
-	"github.com/gogf/gf/os/gtime"
+	"time"
 )
 
 func TestInsertGoal(t *testing.T) {
-	for _, goalType := range []string{"10", "20"} {
-		for _, productLine := range []string{"10", "20", "30", "40", "50", "90"} {
-			for _, quarter := range []int{1, 2, 3, 4} {
-				g.DB().Insert("ctr_contract_goal", contract.CtrContractGoal{
-					GoalType:    goalType,
-					Year:        2023,
-					Quarter:     quarter,
-					ProductLine: productLine,
-					Amount:      float64(quarter) * 100,
-					Remark:      "",
-					CreatedBy:   1000,
-					CreatedName: "大数华创",
-					CreatedTime: gtime.Now(),
-					UpdatedBy:   1000,
-					UpdatedName: "大数华创",
-					UpdatedTime: gtime.Now(),
-				})
-			}
-		}
-	}
+	//now:=
+	now := time.Now()
+	// 获取本月的第一天
+	firstOfMonth := time.Date(now.Year(), 2, 1, 0, 0, 0, 0, now.Location())
+	// 获取本月的最后一天
+	lastOfMonth := firstOfMonth.AddDate(0, 1, -1)
+	fmt.Println("本月的开始日期:", firstOfMonth.Format("2006-01-02"))
+	fmt.Println("本月的结束日期:", lastOfMonth.Format("2006-01-02"))
+
 }
+
+//
+////判断时间是当年的第几周
+////
+//func WeekByDate(t time.Time) string {
+//
+//	yearDay := t.YearDay()
+//
+//	yearFirstDay := t.AddDate(0, 0, -yearDay+1)
+//
+//	firstDayInWeek := int(yearFirstDay.Weekday())
+//
+//	//今年第一周有几天
+//
+//	firstWeekDays := 1
+//
+//	if firstDayInWeek != 0 {
+//
+//		firstWeekDays = 7 - firstDayInWeek + 1
+//
+//	}
+//
+//	var week int
+//	Weeks := WeekByDates()
+//	if yearDay <= firstWeekDays {
+//
+//		week = 1
+//
+//	} else {
+//
+//		week = (yearDay-firstWeekDays)/7 + 2
+//
+//	}
+//
+//	return fmt.Sprintf("%d第%d周", t.Year(), week-gconv.Int(Weeks)+1)
+//
+//}
+//func WeekByDates() int {
+//	l, _ := time.LoadLocation("Asia/Shanghai")
+//	now := time.Now()
+//	// 获取本月的第一天
+//	firstOfMonth := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
+//	endTime, _ := time.ParseInLocation("2006-01-02", firstOfMonth.Format("2006-01-02"), l)
+//	t := endTime
+//	yearDay := t.YearDay()
+//
+//	yearFirstDay := t.AddDate(0, 0, -yearDay+1)
+//
+//	firstDayInWeek := int(yearFirstDay.Weekday())
+//
+//	//今年第一周有几天
+//
+//	firstWeekDays := 1
+//
+//	if firstDayInWeek != 0 {
+//
+//		firstWeekDays = 7 - firstDayInWeek + 1
+//
+//	}
+//
+//	var week int
+//
+//	if yearDay <= firstWeekDays {
+//
+//		week = 1
+//
+//	} else {
+//
+//		week = (yearDay-firstWeekDays)/7 + 2
+//
+//	}
+//
+//	return week
+//
+//}
+//
+//type WeekDate struct {
+//	WeekTh string
+//
+//	StartTime time.Time
+//
+//	EndTime time.Time
+//}
+//
+//// 将开始时间和结束时间分割为周为单位
+//
+//func GroupByWeekDate(startTime, endTime time.Time) []WeekDate {
+//
+//	weekDate := make([]WeekDate, 0)
+//
+//	diffDuration := endTime.Sub(startTime)
+//
+//	days := int(math.Ceil(float64(diffDuration/(time.Hour*24)))) + 1
+//
+//	currentWeekDate := WeekDate{}
+//
+//	currentWeekDate.WeekTh = WeekByDate(endTime)
+//
+//	currentWeekDate.EndTime = endTime
+//
+//	currentWeekDay := int(endTime.Weekday())
+//
+//	if currentWeekDay == 0 {
+//
+//		currentWeekDay = 7
+//
+//	}
+//
+//	currentWeekDate.StartTime = endTime.AddDate(0, 0, -currentWeekDay+1)
+//
+//	nextWeekEndTime := currentWeekDate.StartTime
+//
+//	weekDate = append(weekDate, currentWeekDate)
+//
+//	for i := 0; i < (days-currentWeekDay)/7; i++ {
+//
+//		weekData := WeekDate{}
+//
+//		weekData.EndTime = nextWeekEndTime
+//
+//		weekData.StartTime = nextWeekEndTime.AddDate(0, 0, -7)
+//
+//		weekData.WeekTh = WeekByDate(weekData.StartTime)
+//
+//		nextWeekEndTime = weekData.StartTime
+//
+//		weekDate = append(weekDate, weekData)
+//
+//	}
+//
+//	if lastDays := (days - currentWeekDay) % 7; lastDays > 0 {
+//
+//		lastData := WeekDate{}
+//
+//		lastData.EndTime = nextWeekEndTime
+//
+//		lastData.StartTime = nextWeekEndTime.AddDate(0, 0, -lastDays)
+//
+//		lastData.WeekTh = WeekByDate(lastData.StartTime)
+//
+//		weekDate = append(weekDate, lastData)
+//
+//	}
+//
+//	return weekDate
+//
+//}

+ 20 - 7
opms_parent/app/service/plat/plat_followup.go

@@ -7,7 +7,6 @@ import (
 	"dashoo.cn/opms_libary/myerrors"
 	"database/sql"
 	"github.com/gogf/gf/frame/g"
-	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/util/gconv"
 	"strconv"
 	"strings"
@@ -180,18 +179,32 @@ func (s *followupService) GetListByDay(req *model.SearchPlatFollowupReq) (total
 		followupModel = followupModel.Where("created_by", s.GetCxtUserId())
 	}
 	// 日期条件
-	if req.DaysBeforeToday > 0 { // 获取前N天的跟进记录
-		now := gtime.Now()
-		begin := now.AddDate(0, 0, -req.DaysBeforeToday).Format("Y-m-d 00:00:00")
-		followupModel = followupModel.Where("follow_date>=?", begin)
-	}
+	//if req.DaysBeforeToday > 0 { // 获取前N天的跟进记录
+	//	now := gtime.Now()
+	//	begin := now.AddDate(0, 0, -req.DaysBeforeToday).Format("Y-m-d 00:00:00")
+	//	followupModel = followupModel.Where("follow_date>=?", begin)
+	//}
 	// 获取日期区间范围内的记录
 	if req.BeginTime != "" && req.EndTime != "" {
 		begin := strings.Split(req.BeginTime, " ")[0] + " 00:00:00"
 		end := strings.Split(req.EndTime, " ")[0] + " 23:59:59"
 		followupModel = followupModel.Where("follow_date>=? AND follow_date<=?", begin, end)
 	}
-
+	if req.FollowType != "" {
+		followupModel = followupModel.Where("follow_type", req.FollowType)
+	}
+	if req.CreateOn != "" {
+		dates := strings.Split(req.CreateOn, ",")
+		if len(dates) == 2 {
+			begin := dates[0]
+			end := dates[1]
+			followupModel = followupModel.Where("follow_date>=? AND follow_date<=?", begin, end)
+		}
+	}
+	//跟进记录销售 添加销售人权限
+	if req.Sell != "" {
+		followupModel = followupModel.Where("created_by", s.CxtUser.Id)
+	}
 	//total, err = followupModel.Count()
 	//if err != nil {
 	//	g.Log().Error(err)