|
|
@@ -333,15 +333,10 @@ func getFollowUpRecord(ctx context.Context, dataType string, params *map[string]
|
|
|
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
|
|
|
@@ -374,9 +369,7 @@ func getFollowUpRecord(ctx context.Context, dataType string, params *map[string]
|
|
|
stats = append(stats, stat)
|
|
|
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
return stats, nil
|
|
|
|
|
|
}
|
|
|
@@ -428,33 +421,21 @@ func transferWeekday(day time.Weekday) string {
|
|
|
|
|
|
// 判断时间是当年的第几周
|
|
|
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)
|
|
|
}
|
|
|
@@ -465,98 +446,53 @@ func WeekByDates(now time.Time) int {
|
|
|
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
|
|
|
-
|
|
|
}
|
|
|
|
|
|
type BusCount struct {
|
|
|
@@ -728,13 +664,13 @@ func (s *HomeService) getProductLineSignedAndBackAmount(productLine []string) (i
|
|
|
return nil, err
|
|
|
}
|
|
|
//当月签约合同金额(维度:月)
|
|
|
- monthContractAmount, err := commonDao.WhereGTE(contractDao.C.CreatedTime, monthStart).WhereLTE(contractDao.C.CreatedTime, monthEnd).
|
|
|
+ monthContractAmount, err := commonDao.WhereGTE(contractDao.C.ContractStartTime, monthStart).WhereLTE(contractDao.C.ContractStartTime, monthEnd).
|
|
|
Fields("product_line, SUM(contract_amount) as contract_amount").All()
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
//当月回款金额(维度:月)
|
|
|
- monthCollectedAmount, err := commonDao.WhereGTE(contractDao.C.CreatedTime, monthStart).WhereLTE(contractDao.C.CreatedTime, monthEnd).
|
|
|
+ monthCollectedAmount, err := commonDao.WhereGTE(contractDao.C.ContractStartTime, monthStart).WhereLTE(contractDao.C.ContractStartTime, monthEnd).
|
|
|
Fields("product_line, SUM(collected_amount) as collected_amount").All()
|
|
|
if err != nil {
|
|
|
return nil, err
|