|
@@ -193,7 +193,7 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
|
|
|
parsAscribeRai = append(parsAscribeRai, companyIds)
|
|
|
}
|
|
|
|
|
|
- condition += ` AND c.product_id = ? `
|
|
|
+ condition += ` AND c.product_id = ? AND a.status = 1 `
|
|
|
pars = append(pars, 2)
|
|
|
|
|
|
var list []*models.IncrementalList
|
|
@@ -209,7 +209,7 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
|
|
|
{
|
|
|
condition1 := condition
|
|
|
pars1 := pars
|
|
|
- condition1 += ` AND a.start_date >= ? AND a.start_date <= ? `
|
|
|
+ condition1 += ` AND a.start_date >= ? AND a.start_date <= ? `
|
|
|
pars1 = append(pars1, startDate, endDate)
|
|
|
condition1 += ` AND a.contract_type = ? `
|
|
|
pars1 = append(pars1, "新签合同")
|
|
@@ -243,7 +243,6 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
|
|
|
|
|
|
//续约客户数
|
|
|
{
|
|
|
-
|
|
|
condition1 := condition
|
|
|
pars1 := pars
|
|
|
condition1 += ` AND a.start_date >= ? AND a.start_date <= ? `
|
|
@@ -386,7 +385,7 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
|
|
|
return
|
|
|
}
|
|
|
//列表页数据
|
|
|
- tmpList, err := models.GetIncrementalCompanyListByOperationRecord(condition1, pars1, startSize, pageSize)
|
|
|
+ tmpList, err := models.GetIncrementalCompanyMergeList(condition1, pars1, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
@@ -420,10 +419,10 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
|
|
|
if listLen == 0 {
|
|
|
list = make([]*models.IncrementalList, 0)
|
|
|
}
|
|
|
- mapCompamy := make(map[int]string)
|
|
|
+ var companyContractIds []int
|
|
|
for i := 0; i < listLen; i++ {
|
|
|
item := list[i]
|
|
|
- mapCompamy[item.CompanyId] = item.CompanyContractIdGroup
|
|
|
+ companyContractIds = append(companyContractIds, item.CompanyContractId)
|
|
|
//新增试用不需要计算剩余日期
|
|
|
if dataType != "新增试用" {
|
|
|
//剩余可用天数
|
|
@@ -437,14 +436,14 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
|
|
|
|
|
|
if dataType == "新签客户" || dataType == "续约客户" {
|
|
|
//合并合同所对应的权限
|
|
|
- mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapBymapCompamy(mapCompamy)
|
|
|
+ mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(companyContractIds)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
for _, v := range list {
|
|
|
- v.PermissionName = mappermissionName[v.CompanyId]
|
|
|
+ v.PermissionName = mappermissionName[v.CompanyContractId]
|
|
|
}
|
|
|
}
|
|
|
page := paging.GetPaging(currentIndex, pageSize, dataTotal)
|
|
@@ -683,7 +682,7 @@ func MergeCompanyListListExport(this *StatisticCompanyMergerController, dataType
|
|
|
|
|
|
// @Title 上一份合同详情
|
|
|
// @Description 上一份合同详情接口
|
|
|
-// @Param ComPanyId query int true "公司ID"
|
|
|
+// @Param CompanyContractId query int true "合同ID"
|
|
|
// @Success Ret=200 {object} company.GetCompanyContractMergeDetailResp
|
|
|
// @router /merge_company_previous/detail [get]
|
|
|
func (this *StatisticCompanyMergerController) CompanyPreviousDetail() {
|
|
@@ -700,22 +699,33 @@ func (this *StatisticCompanyMergerController) CompanyPreviousDetail() {
|
|
|
return
|
|
|
}
|
|
|
resp := new(company.GetCompanyContractDetailResp)
|
|
|
- comPanyId, _ := this.GetInt("ComPanyId")
|
|
|
- if comPanyId < 1 {
|
|
|
- br.Msg = "请输入公司ID"
|
|
|
+ companyContractId, _ := this.GetInt("CompanyContractId")
|
|
|
+ if companyContractId < 1 {
|
|
|
+ br.Msg = "请输入合同ID"
|
|
|
return
|
|
|
}
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
//获取最新的一条到期的合同信息
|
|
|
- condition = " AND company_id = ? AND end_date < ? ORDER BY start_date DESC LIMIT 1 "
|
|
|
- pars = append(pars, comPanyId, time.Now())
|
|
|
+
|
|
|
+ condition = " AND company_contract_id = ? "
|
|
|
+ pars = append(pars, companyContractId)
|
|
|
detail, err := company.GetCompanyContracDetail(condition, pars)
|
|
|
if err != nil {
|
|
|
br.Msg = "详情不存在"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ //获取前一份合同的信息
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = " AND company_id = ? AND company_contract_id < ? AND status = 1 AND product_id = 2 ORDER BY company_contract_id DESC LIMIT 1 "
|
|
|
+ pars = append(pars, detail.CompanyId, companyContractId)
|
|
|
+ detailPrevious, err := company.GetCompanyContracDetail(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "详情不存在"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
//合并合同所对应的权限
|
|
|
mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById([]int{detail.CompanyContractId})
|
|
|
if err != nil {
|
|
@@ -723,8 +733,8 @@ func (this *StatisticCompanyMergerController) CompanyPreviousDetail() {
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- detail.PermissionName = mappermissionName[detail.CompanyContractId]
|
|
|
- resp.Detail = detail
|
|
|
+ detailPrevious.PermissionName = mappermissionName[detail.CompanyContractId]
|
|
|
+ resp.Detail = detailPrevious
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|