|
@@ -44,6 +44,7 @@ type StatisticCompanyMergerController struct {
|
|
|
// @Param IsConfirm query int false "是否确认续约: -1-默认全部; 0-待确认; 1-已确认 ;2-到期合同"
|
|
|
// @Param CompanyAscribeId query int false "归因ID"
|
|
|
// @Param PackageDifference query string false "和上一份合同的区别,枚举值:`增加套餐`,`减少套餐`,`维持套餐`"
|
|
|
+// @Param Operation query string false "新增类型 ,枚举值:`新建`,`领取`"
|
|
|
// @Success 200 {object} response.IncrementalCompanyListResp
|
|
|
// @router /merge_company_list [get]
|
|
|
func (this *StatisticCompanyMergerController) MergeCompanyList() {
|
|
@@ -71,6 +72,7 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
|
|
|
tryOutType := this.GetString("TryOutType")
|
|
|
keyword := this.GetString("Keyword")
|
|
|
packageDifference := this.GetString("PackageDifference")
|
|
|
+ operation := this.GetString("Operation")
|
|
|
|
|
|
startDate := this.GetString("StartDate")
|
|
|
endDate := this.GetString("EndDate")
|
|
@@ -214,19 +216,27 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
|
|
|
|
|
|
//试用客户数
|
|
|
{
|
|
|
+ var operationSql string
|
|
|
+ if operation == "新建" {
|
|
|
+ operationSql = ` "add" `
|
|
|
+ } else if operation == "领取" {
|
|
|
+ operationSql = ` "add","receive" `
|
|
|
+ } else {
|
|
|
+ operationSql = ` "add","receive","apply_receive" `
|
|
|
+ }
|
|
|
condition1 := condition
|
|
|
pars1 := pars
|
|
|
//销售筛选条件
|
|
|
if adminId != "" {
|
|
|
- condition1 += ` AND c.seller_id in (` + adminId + `) `
|
|
|
+ condition1 += ` AND a.sys_user_id in (` + adminId + `) `
|
|
|
} else {
|
|
|
condition1, pars1 = getQueryParams(condition1, pars1, sysUser, "c.")
|
|
|
}
|
|
|
- condition1 += ` AND a.create_time >= ? AND a.create_time <= ? AND a.operation in ("add","receive") AND b.company_id NOT IN ( SELECT company_id FROM company_operation_record WHERE product_id = 2 AND operation ="loss" GROUP BY company_id ) AND c.status = '试用' `
|
|
|
+ condition1 += ` AND a.create_time >= ? AND a.create_time <= ? AND a.operation in (` + operationSql + `) AND b.company_id NOT IN ( SELECT company_id FROM company_operation_record WHERE product_id = 2 AND operation ="loss" GROUP BY company_id ) AND a.sys_user_id IN ( SELECT admin_id FROM admin WHERE role_type_code IN ( 'rai_seller', 'rai_group' , 'rai_admin') ) `
|
|
|
pars1 = append(pars1, startDate, endDate)
|
|
|
|
|
|
- total, err := models.GetIncrementalCompanyCountByOperationRecord(condition1, pars1)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ total, err := models.GetIncrementalCompanyCountByOperationRecordRai(condition1, pars1)
|
|
|
+ if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -235,25 +245,32 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
|
|
|
|
|
|
if dataType == "新增试用" {
|
|
|
//列表数据数量
|
|
|
- total, err := models.GetIncrementalCompanyProductCountByOperationRecord(condition1, pars1)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
+ //total, err := models.GetIncrementalCompanyProductCountByOperationRecord(condition1, pars1)
|
|
|
+ //if err != nil {
|
|
|
+ // br.Msg = "获取失败"
|
|
|
+ // br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+
|
|
|
+ //total = trialTotal
|
|
|
|
|
|
//列表页数据
|
|
|
- tmpList, err := models.GetIncrementalCompanyListByOperationRecord(condition1, pars1, startSize, pageSize)
|
|
|
+ tmpList, err := models.GetIncrementalCompanyListByOperationRecordRai(condition1, pars1, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
for _, v := range tmpList {
|
|
|
- v.SellerName = v.SellerNameInit
|
|
|
+ v.SellerName = v.SysRealName
|
|
|
+ if v.Operation == "add" {
|
|
|
+ v.Operation = "新建"
|
|
|
+ } else if v.Operation == "receive" || v.Operation == "apply_receive" {
|
|
|
+ v.Operation = "领取"
|
|
|
+ }
|
|
|
}
|
|
|
list = tmpList
|
|
|
- dataTotal = total
|
|
|
+ dataTotal = trialTotal
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -534,7 +551,11 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
|
|
|
//fmt.Println()
|
|
|
//导出excel
|
|
|
if isExport {
|
|
|
- MergeCompanyListListExport(this, dataType, resp, br)
|
|
|
+ if dataType == "新增试用" {
|
|
|
+ MergeCompanyListListTrialExport(this, dataType, resp, br)
|
|
|
+ } else {
|
|
|
+ MergeCompanyListListExport(this, dataType, resp, br)
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
br.Ret = 200
|
|
@@ -719,6 +740,97 @@ func MergeCompanyListListExport(this *StatisticCompanyMergerController, dataType
|
|
|
br.Msg = "导出成功"
|
|
|
}
|
|
|
|
|
|
+// MergeCompanyListListTrialExport 导出增量客户新增试用模块数据报表excel
|
|
|
+func MergeCompanyListListTrialExport(this *StatisticCompanyMergerController, dataType string, resp response.IncrementalCompanyListResp, br *models.BaseResponse) {
|
|
|
+ dir, err := os.Executable()
|
|
|
+ exPath := filepath.Dir(dir)
|
|
|
+ downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
|
|
|
+ xlsxFile := xlsx.NewFile()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "生成文件失败"
|
|
|
+ br.ErrMsg = "生成文件失败"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ style := xlsx.NewStyle()
|
|
|
+ alignment := xlsx.Alignment{
|
|
|
+ Horizontal: "center",
|
|
|
+ Vertical: "center",
|
|
|
+ WrapText: true,
|
|
|
+ }
|
|
|
+
|
|
|
+ style.Alignment = alignment
|
|
|
+ style.ApplyAlignment = true
|
|
|
+
|
|
|
+ sheel, err := xlsxFile.AddSheet("新增试用客户数据")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "新增Sheet失败"
|
|
|
+ br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sheel.SetColWidth(0, 0, 30)
|
|
|
+ sheel.SetColWidth(1, 1, 15)
|
|
|
+ sheel.SetColWidth(2, 2, 15)
|
|
|
+ sheel.SetColWidth(3, 3, 18)
|
|
|
+ sheel.SetColWidth(4, 4, 40)
|
|
|
+ sheel.SetColWidth(5, 5, 18)
|
|
|
+
|
|
|
+ //统计数据
|
|
|
+ statisticRow := sheel.AddRow()
|
|
|
+
|
|
|
+ cell1 := statisticRow.AddCell()
|
|
|
+ cell1.SetStyle(style)
|
|
|
+ cell1.SetValue("客户名称")
|
|
|
+
|
|
|
+ cell2 := statisticRow.AddCell()
|
|
|
+ cell2.SetStyle(style)
|
|
|
+ cell2.SetValue("所属销售")
|
|
|
+
|
|
|
+ cell3 := statisticRow.AddCell()
|
|
|
+ cell3.SetStyle(style)
|
|
|
+ cell3.SetValue("新增类型")
|
|
|
+
|
|
|
+ cell4 := statisticRow.AddCell()
|
|
|
+ cell4.SetStyle(style)
|
|
|
+ cell4.SetValue("新增时间")
|
|
|
+ //表头
|
|
|
+
|
|
|
+ for _, v := range resp.List {
|
|
|
+ dataRow := sheel.AddRow()
|
|
|
+ dataRow.SetHeight(20)
|
|
|
+
|
|
|
+ cellDataName := dataRow.AddCell()
|
|
|
+ cellDataName.SetStyle(style)
|
|
|
+ cellDataName.SetValue(v.CompanyName)
|
|
|
+
|
|
|
+ cellDataSellerName := dataRow.AddCell()
|
|
|
+ cellDataSellerName.SetStyle(style)
|
|
|
+ cellDataSellerName.SetValue(v.SellerName)
|
|
|
+
|
|
|
+ cellDataOperation := dataRow.AddCell()
|
|
|
+ cellDataOperation.SetStyle(style)
|
|
|
+ cellDataOperation.SetValue(v.Operation)
|
|
|
+
|
|
|
+ cellDataTime := dataRow.AddCell()
|
|
|
+ cellDataTime.SetStyle(style)
|
|
|
+ cellDataTime.SetValue(v.CreateTime)
|
|
|
+ }
|
|
|
+ err = xlsxFile.Save(downLoadnFilePath)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "保存文件失败"
|
|
|
+ br.ErrMsg = "保存文件失败"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
|
|
|
+ downloadFileName := "新增试用客户数据_" + randStr + ".xlsx"
|
|
|
+ this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
|
|
|
+ defer func() {
|
|
|
+ os.Remove(downLoadnFilePath)
|
|
|
+ }()
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "导出成功"
|
|
|
+}
|
|
|
+
|
|
|
// @Title 上一份合同详情
|
|
|
// @Description 上一份合同详情接口
|
|
|
// @Param CompanyContractId query int true "合同ID"
|