|
@@ -6357,3 +6357,89 @@ func (this *StatisticReportController) UnusualRenewCompanyStatistics() {
|
|
|
br.Msg = "获取成功"
|
|
|
br.Data = companyRenewRecordResp
|
|
|
}
|
|
|
+
|
|
|
+// UnusualRenewCompanyList
|
|
|
+// @Title 获取未续约的公司合同列表
|
|
|
+// @Description 合同套餐列表
|
|
|
+// @Param ProductId query int false "套餐类型: 1-FICC(默认); 2-权益"
|
|
|
+// @Param StartDate query string true "开始日期,格式:2022-04"
|
|
|
+// @Param EndDate query string true "结束日期,格式:2022-04"
|
|
|
+// @Success 200 {object} company.GetUnusualRenewListGroupMonthResp
|
|
|
+// @router /report/unusual_renew_company/chart [get]
|
|
|
+func (this *StatisticReportController) UnusualRenewCompanyList() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 起始日期
|
|
|
+ // 截止日期
|
|
|
+ productId, _ := this.GetInt("ProductId", 1)
|
|
|
+ startDate := this.GetString("StartDate")
|
|
|
+ endDate := this.GetString("EndDate")
|
|
|
+
|
|
|
+ if startDate == `` || endDate == `` {
|
|
|
+ br.Msg = "开始日期或结束日期不能为空"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ allList := make([]*company.GetUnusualRenewListGroupMonth, 0)
|
|
|
+ resp := new(company.GetUnusualRenewListGroupMonthResp)
|
|
|
+ resp.List = allList
|
|
|
+ newStartDate := startDate + "-01"
|
|
|
+ newEndDate := endDate + "-01"
|
|
|
+
|
|
|
+ startDateTimer, _ := time.ParseInLocation(utils.FormatDate, newStartDate, time.Local)
|
|
|
+ endDateTimer, _ := time.ParseInLocation(utils.FormatDate, newEndDate, time.Local)
|
|
|
+ endDateTimer = endDateTimer.AddDate(0, 1, 0).Add(-1 * time.Second) //本月最后一天
|
|
|
+
|
|
|
+ // 按月分组
|
|
|
+ monthMap := make(map[string]int)
|
|
|
+ monthList := make([]string, 0)
|
|
|
+ tmpDate, _ := time.ParseInLocation(utils.FormatYearMonthDate, startDate, time.Local)
|
|
|
+ tmpEndDate, _ := time.ParseInLocation(utils.FormatYearMonthDate, endDate, time.Local)
|
|
|
+ for tmpDate.Before(tmpEndDate) || tmpDate == tmpEndDate {
|
|
|
+ monthMap[tmpDate.Format(utils.FormatYearMonthDate)] = 0
|
|
|
+ monthList = append(monthList, tmpDate.Format(utils.FormatYearMonthDate))
|
|
|
+ tmpDate = tmpDate.AddDate(0, 1, 0)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ list, err := company.GetUnusualRenewList(startDateTimer, endDateTimer, productId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "数据异常"
|
|
|
+ br.ErrMsg = "数据异常,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(list) > 0 {
|
|
|
+ for _, v := range list {
|
|
|
+ t := v.ModifyTime.Format(utils.FormatYearMonthDate)
|
|
|
+ if num, ok := monthMap[t]; ok {
|
|
|
+ monthMap[t] = num + 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range monthList {
|
|
|
+ n, _ := monthMap[v]
|
|
|
+ tmp := &company.GetUnusualRenewListGroupMonth{
|
|
|
+ Date: v,
|
|
|
+ CompanyNum: n,
|
|
|
+ }
|
|
|
+ allList = append(allList, tmp)
|
|
|
+ }
|
|
|
+ resp = &company.GetUnusualRenewListGroupMonthResp{
|
|
|
+ List: allList,
|
|
|
+ }
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|