|
@@ -1,138 +1,127 @@
|
|
|
package services
|
|
|
|
|
|
-import (
|
|
|
- "errors"
|
|
|
- "fmt"
|
|
|
- "hongze/hz_crm_api/models/company"
|
|
|
- "hongze/hz_crm_api/services/alarm_msg"
|
|
|
- "hongze/hz_crm_api/utils"
|
|
|
- "strconv"
|
|
|
- "strings"
|
|
|
- "time"
|
|
|
-)
|
|
|
-
|
|
|
//func init() {
|
|
|
// InitCompanyContractMerge()
|
|
|
// //GetCompanyContractPermissionNameMapById(map[int]string{6513: "182,183", 6663: "435,542"})
|
|
|
//}
|
|
|
|
|
|
// 初始化合并合同之后的数据脚本
|
|
|
-func InitCompanyContractMerge() {
|
|
|
-
|
|
|
- var condition string
|
|
|
- var pars []interface{}
|
|
|
- condition = " AND status = 1 AND product_id = 2 ORDER BY company_contract_id ASC "
|
|
|
- companyContractList, err := company.GetCompanyContractList(condition, pars)
|
|
|
-
|
|
|
- if err != nil {
|
|
|
- fmt.Println(err)
|
|
|
- return
|
|
|
- }
|
|
|
- mapCompanyContractItems := make(map[int][]*company.CompanyContractResp)
|
|
|
- for _, v := range companyContractList {
|
|
|
- //fmt.Println(v)
|
|
|
- mapCompanyContractItems[v.CompanyId] = append(mapCompanyContractItems[v.CompanyId], v)
|
|
|
- }
|
|
|
-
|
|
|
- mapCompanyMoney := make(map[int]float64)
|
|
|
- var items []*company.CompanyContractMergeResp
|
|
|
- for _, ContractItems := range mapCompanyContractItems {
|
|
|
- item := new(company.CompanyContractMergeResp)
|
|
|
- for k, v := range ContractItems {
|
|
|
- item = new(company.CompanyContractMergeResp)
|
|
|
- item.ContractType = v.ContractType
|
|
|
- item.ProductId = v.ProductId
|
|
|
- item.ProductName = v.ProductName
|
|
|
- item.CompanyId = v.CompanyId
|
|
|
- item.CompanyProductId = v.CompanyProductId
|
|
|
- item.StartDate = v.StartDate
|
|
|
- item.EndDate = v.EndDate
|
|
|
- item.Money = v.Money
|
|
|
- item.CompanyContractIdGroup += strconv.Itoa(v.CompanyContractId) + ","
|
|
|
- if k == 0 {
|
|
|
- items = append(items, item)
|
|
|
- mapCompanyMoney[v.CompanyId] = item.Money
|
|
|
- } else {
|
|
|
- if v.CompanyId != items[len(items)-1].CompanyId {
|
|
|
- items = append(items, item)
|
|
|
- } else {
|
|
|
- //续约的合同开始时间是否<上一次合同记录的结束时间 且间隔>6个月(180)天,那么就对两个合同进行合并
|
|
|
- if item.StartDate.AddDate(0, 0, +180).Before(items[len(items)-1].EndDate) && item.StartDate.Before(items[len(items)-1].EndDate) {
|
|
|
- items[len(items)-1].Money += v.Money
|
|
|
- items[len(items)-1].EndDate = v.EndDate
|
|
|
- items[len(items)-1].CompanyContractIdGroup += strconv.Itoa(v.CompanyContractId) + ","
|
|
|
- } else {
|
|
|
- if item.ContractType == "续约合同" {
|
|
|
- if item.Money > mapCompanyMoney[v.CompanyId] {
|
|
|
- item.PackageDifference = "增加套餐"
|
|
|
- }
|
|
|
- if item.Money == mapCompanyMoney[v.CompanyId] {
|
|
|
- item.PackageDifference = "维持套餐"
|
|
|
- }
|
|
|
- if item.Money < mapCompanyMoney[v.CompanyId] {
|
|
|
- item.PackageDifference = "减少套餐"
|
|
|
- }
|
|
|
- }
|
|
|
- items = append(items, item)
|
|
|
- mapCompanyMoney[v.CompanyId] = item.Money
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- var contractMergeitems []*company.CompanyContractMerge
|
|
|
-
|
|
|
- var companyIds []int
|
|
|
- mapcompanyIds := make(map[int]bool)
|
|
|
- for _, v := range items {
|
|
|
- item := new(company.CompanyContractMerge)
|
|
|
- item.ContractType = v.ContractType
|
|
|
- item.ProductId = v.ProductId
|
|
|
- item.ProductName = v.ProductName
|
|
|
- item.CompanyId = v.CompanyId
|
|
|
- item.CompanyProductId = v.CompanyProductId
|
|
|
- item.StartDate = v.StartDate.Format(utils.FormatDate)
|
|
|
- item.EndDate = v.EndDate.Format(utils.FormatDate)
|
|
|
- item.Money = v.Money
|
|
|
- item.PackageDifference = v.PackageDifference
|
|
|
- item.CompanyContractIdGroup = strings.TrimRight(v.CompanyContractIdGroup, ",")
|
|
|
- item.CreateTime = time.Now()
|
|
|
- item.ModifyTime = time.Now()
|
|
|
- contractMergeitems = append(contractMergeitems, item)
|
|
|
-
|
|
|
- if !mapcompanyIds[v.CompanyId] {
|
|
|
- companyIds = append(companyIds, v.CompanyId)
|
|
|
- mapcompanyIds[v.CompanyId] = true
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- err = company.MultiAddCompanyContractMerge(contractMergeitems)
|
|
|
- if err != nil {
|
|
|
- fmt.Println(err)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- for _, v := range companyIds {
|
|
|
- var condition string
|
|
|
- var pars []interface{}
|
|
|
-
|
|
|
- fmt.Println(v)
|
|
|
- condition = " AND company_id = ? ORDER BY start_date DESC LIMIT 1 "
|
|
|
- pars = append(pars, v)
|
|
|
- contractMergeInfo, err := company.GetCompanyContractMergeDetail(condition, pars)
|
|
|
- if err != nil {
|
|
|
- fmt.Println(err)
|
|
|
- return
|
|
|
- }
|
|
|
- err = company.UpdateCompanyContractMergeIsBestNewto1(contractMergeInfo.CompanyContractMergeId)
|
|
|
- if err != nil {
|
|
|
- fmt.Println(err)
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+//func InitCompanyContractMerge() {
|
|
|
+//
|
|
|
+// var condition string
|
|
|
+// var pars []interface{}
|
|
|
+// condition = " AND status = 1 AND product_id = 2 ORDER BY company_contract_id ASC "
|
|
|
+// companyContractList, err := company.GetCompanyContractList(condition, pars)
|
|
|
+//
|
|
|
+// if err != nil {
|
|
|
+// fmt.Println(err)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// mapCompanyContractItems := make(map[int][]*company.CompanyContractResp)
|
|
|
+// for _, v := range companyContractList {
|
|
|
+// //fmt.Println(v)
|
|
|
+// mapCompanyContractItems[v.CompanyId] = append(mapCompanyContractItems[v.CompanyId], v)
|
|
|
+// }
|
|
|
+//
|
|
|
+// mapCompanyMoney := make(map[int]float64)
|
|
|
+// var items []*company.CompanyContractMergeResp
|
|
|
+// for _, ContractItems := range mapCompanyContractItems {
|
|
|
+// item := new(company.CompanyContractMergeResp)
|
|
|
+// for k, v := range ContractItems {
|
|
|
+// item = new(company.CompanyContractMergeResp)
|
|
|
+// item.ContractType = v.ContractType
|
|
|
+// item.ProductId = v.ProductId
|
|
|
+// item.ProductName = v.ProductName
|
|
|
+// item.CompanyId = v.CompanyId
|
|
|
+// item.CompanyProductId = v.CompanyProductId
|
|
|
+// item.StartDate = v.StartDate
|
|
|
+// item.EndDate = v.EndDate
|
|
|
+// item.Money = v.Money
|
|
|
+// item.CompanyContractIdGroup += strconv.Itoa(v.CompanyContractId) + ","
|
|
|
+// if k == 0 {
|
|
|
+// items = append(items, item)
|
|
|
+// mapCompanyMoney[v.CompanyId] = item.Money
|
|
|
+// } else {
|
|
|
+// if v.CompanyId != items[len(items)-1].CompanyId {
|
|
|
+// items = append(items, item)
|
|
|
+// } else {
|
|
|
+// //续约的合同开始时间是否<上一次合同记录的结束时间 且间隔>6个月(180)天,那么就对两个合同进行合并
|
|
|
+// if item.StartDate.AddDate(0, 0, +180).Before(items[len(items)-1].EndDate) && item.StartDate.Before(items[len(items)-1].EndDate) {
|
|
|
+// items[len(items)-1].Money += v.Money
|
|
|
+// items[len(items)-1].EndDate = v.EndDate
|
|
|
+// items[len(items)-1].CompanyContractIdGroup += strconv.Itoa(v.CompanyContractId) + ","
|
|
|
+// } else {
|
|
|
+// if item.ContractType == "续约合同" {
|
|
|
+// if item.Money > mapCompanyMoney[v.CompanyId] {
|
|
|
+// item.PackageDifference = "增加套餐"
|
|
|
+// }
|
|
|
+// if item.Money == mapCompanyMoney[v.CompanyId] {
|
|
|
+// item.PackageDifference = "维持套餐"
|
|
|
+// }
|
|
|
+// if item.Money < mapCompanyMoney[v.CompanyId] {
|
|
|
+// item.PackageDifference = "减少套餐"
|
|
|
+// }
|
|
|
+// }
|
|
|
+// items = append(items, item)
|
|
|
+// mapCompanyMoney[v.CompanyId] = item.Money
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// var contractMergeitems []*company.CompanyContractMerge
|
|
|
+//
|
|
|
+// var companyIds []int
|
|
|
+// mapcompanyIds := make(map[int]bool)
|
|
|
+// for _, v := range items {
|
|
|
+// item := new(company.CompanyContractMerge)
|
|
|
+// item.ContractType = v.ContractType
|
|
|
+// item.ProductId = v.ProductId
|
|
|
+// item.ProductName = v.ProductName
|
|
|
+// item.CompanyId = v.CompanyId
|
|
|
+// item.CompanyProductId = v.CompanyProductId
|
|
|
+// item.StartDate = v.StartDate.Format(utils.FormatDate)
|
|
|
+// item.EndDate = v.EndDate.Format(utils.FormatDate)
|
|
|
+// item.Money = v.Money
|
|
|
+// item.PackageDifference = v.PackageDifference
|
|
|
+// item.CompanyContractIdGroup = strings.TrimRight(v.CompanyContractIdGroup, ",")
|
|
|
+// item.CreateTime = time.Now()
|
|
|
+// item.ModifyTime = time.Now()
|
|
|
+// contractMergeitems = append(contractMergeitems, item)
|
|
|
+//
|
|
|
+// if !mapcompanyIds[v.CompanyId] {
|
|
|
+// companyIds = append(companyIds, v.CompanyId)
|
|
|
+// mapcompanyIds[v.CompanyId] = true
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// err = company.MultiAddCompanyContractMerge(contractMergeitems)
|
|
|
+// if err != nil {
|
|
|
+// fmt.Println(err)
|
|
|
+// return
|
|
|
+// }
|
|
|
+//
|
|
|
+// for _, v := range companyIds {
|
|
|
+// var condition string
|
|
|
+// var pars []interface{}
|
|
|
+//
|
|
|
+// fmt.Println(v)
|
|
|
+// condition = " AND company_id = ? ORDER BY start_date DESC LIMIT 1 "
|
|
|
+// pars = append(pars, v)
|
|
|
+// contractMergeInfo, err := company.GetCompanyContractMergeDetail(condition, pars)
|
|
|
+// if err != nil {
|
|
|
+// fmt.Println(err)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// err = company.UpdateCompanyContractMergeIsBestNewto1(contractMergeInfo.CompanyContractMergeId)
|
|
|
+// if err != nil {
|
|
|
+// fmt.Println(err)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+//}
|
|
|
|
|
|
//// GetCompanyContractPermissionNameMapById 获取合并之后的合同所对应的权限种类名称
|
|
|
//func GetCompanyContractPermissionNameMapBymapCompamy(mapCompamy map[int]string) (mapContractResp map[int]string, err error) {
|
|
@@ -281,129 +270,129 @@ func InitCompanyContractMerge() {
|
|
|
//}
|
|
|
|
|
|
// AddCompanyContractMergeByCompanyContractId 通过合同ID对合同进行合并
|
|
|
-func AddCompanyContractMergeByCompanyContractId(companyContractId int) {
|
|
|
- var err error
|
|
|
- defer func() {
|
|
|
- if err != nil {
|
|
|
- fmt.Println(err)
|
|
|
- go alarm_msg.SendAlarmMsg("通过合同ID对合同进行合并,失败"+err.Error()+fmt.Sprint("companyContractId", companyContractId), 2)
|
|
|
- }
|
|
|
- }()
|
|
|
- contractInfo, e := company.GetCompanyContractDetailByCompanyContractId(companyContractId)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("GetCompanyContractDetailByCompanyContractId, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- var condition string
|
|
|
- var pars []interface{}
|
|
|
-
|
|
|
- condition = " AND company_id = ? ORDER BY start_date DESC LIMIT 1 "
|
|
|
- pars = append(pars, contractInfo.CompanyId)
|
|
|
- contractMergeInfo, e := company.GetCompanyContractMergeDetail(condition, pars)
|
|
|
- if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetCompanyContractMergeDetail, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- //fmt.Println(contractMergeInfo)
|
|
|
- e = company.UpdateCompanyContractMergeIsBestNew(0, contractInfo.CompanyId)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("UpdateCompanyContractMergeIsBestNew, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- //fmt.Println(contractInfo)
|
|
|
- item := new(company.CompanyContractMerge)
|
|
|
- item.ContractType = contractInfo.ContractType
|
|
|
- item.ProductId = contractInfo.ProductId
|
|
|
- item.ProductName = contractInfo.ProductName
|
|
|
- item.CompanyId = contractInfo.CompanyId
|
|
|
- item.CompanyProductId = contractInfo.CompanyProductId
|
|
|
- item.IsBestNew = 1
|
|
|
- item.CreateTime = time.Now()
|
|
|
- item.ModifyTime = time.Now()
|
|
|
- //如果不存在就是新的数据
|
|
|
- if contractMergeInfo == nil {
|
|
|
- item.StartDate = contractInfo.StartDate
|
|
|
- item.EndDate = contractInfo.EndDate
|
|
|
- item.Money = contractInfo.Money
|
|
|
- item.CompanyContractIdGroup = strconv.Itoa(companyContractId)
|
|
|
- e = company.AddCompanyContractMerge(item)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("AddCompanyContractMerge, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- } else {
|
|
|
- newStartDate := utils.StrDateToDate(contractInfo.StartDate)
|
|
|
- //newEndDate := utils.StrDateToDate(contractInfo.EndDate)
|
|
|
- oldEndDate := utils.StrDateToDate(contractMergeInfo.EndDate)
|
|
|
-
|
|
|
- //续约的合同开始时间是否<上一次合同记录的结束时间 且间隔>6个月(180)天,那么就对两个合同进行合并
|
|
|
- if newStartDate.AddDate(0, 0, +180).Before(oldEndDate) && newStartDate.Before(oldEndDate) {
|
|
|
- item.Money = contractInfo.Money + contractMergeInfo.Money
|
|
|
- item.EndDate = contractInfo.EndDate
|
|
|
- item.CompanyContractIdGroup = contractMergeInfo.CompanyContractIdGroup + "," + strconv.Itoa(companyContractId)
|
|
|
- //如果是续约合同就对比跟上一份合并之后的合同的差距
|
|
|
- if item.ContractType == "续约合同" {
|
|
|
- pars = make([]interface{}, 0)
|
|
|
- condition = " AND company_id = ? AND company_contract_merge_id != ? ORDER BY start_date DESC LIMIT 1 "
|
|
|
- pars = append(pars, contractMergeInfo.CompanyId, contractMergeInfo.CompanyContractMergeId)
|
|
|
- detailPrevious, e := company.GetCompanyContractMergeDetail(condition, pars)
|
|
|
- if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetCompanyContractMergeDetail-Update, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- if detailPrevious == nil {
|
|
|
- item.PackageDifference = ""
|
|
|
- } else {
|
|
|
- if item.Money > detailPrevious.Money {
|
|
|
- item.PackageDifference = "增加套餐"
|
|
|
- }
|
|
|
- if item.Money == detailPrevious.Money {
|
|
|
- item.PackageDifference = "维持套餐"
|
|
|
- }
|
|
|
- if item.Money < detailPrevious.Money {
|
|
|
- item.PackageDifference = "减少套餐"
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- item.CompanyContractMergeId = contractMergeInfo.CompanyContractMergeId
|
|
|
- e = company.UpdateCompanyContractMerge(item)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("AddCompanyContractMerge, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- } else {
|
|
|
- item.StartDate = contractInfo.StartDate
|
|
|
- item.EndDate = contractInfo.EndDate
|
|
|
- item.Money = contractInfo.Money
|
|
|
- item.CompanyContractIdGroup = strconv.Itoa(companyContractId)
|
|
|
- //如果是续约合同就对比跟上一份合并之后的合同的差距
|
|
|
- if item.ContractType == "续约合同" {
|
|
|
- //pars = make([]interface{}, 0)
|
|
|
- //condition = " AND company_id = ? AND company_contract_merge_id != ? ORDER BY start_date DESC LIMIT 1 "
|
|
|
- //pars = append(pars, contractMergeInfo.CompanyId, contractMergeInfo.CompanyContractMergeId)
|
|
|
- //detailPrevious, e := company.GetCompanyContractMergeDetail(condition, pars)
|
|
|
- //if e != nil {
|
|
|
- // err = errors.New("GetCompanyContractMergeDetail——add, Err: " + e.Error())
|
|
|
- // return
|
|
|
- //}
|
|
|
- if item.Money > contractMergeInfo.Money {
|
|
|
- item.PackageDifference = "增加套餐"
|
|
|
- }
|
|
|
- if item.Money == contractMergeInfo.Money {
|
|
|
- item.PackageDifference = "维持套餐"
|
|
|
- }
|
|
|
- if item.Money < contractMergeInfo.Money {
|
|
|
- item.PackageDifference = "减少套餐"
|
|
|
- }
|
|
|
- }
|
|
|
- e = company.AddCompanyContractMerge(item)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("AddCompanyContractMerge, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return
|
|
|
-}
|
|
|
+//func AddCompanyContractMergeByCompanyContractId(companyContractId int) {
|
|
|
+// var err error
|
|
|
+// defer func() {
|
|
|
+// if err != nil {
|
|
|
+// fmt.Println(err)
|
|
|
+// go alarm_msg.SendAlarmMsg("通过合同ID对合同进行合并,失败"+err.Error()+fmt.Sprint("companyContractId", companyContractId), 2)
|
|
|
+// }
|
|
|
+// }()
|
|
|
+// contractInfo, e := company.GetCompanyContractDetailByCompanyContractId(companyContractId)
|
|
|
+// if e != nil {
|
|
|
+// err = errors.New("GetCompanyContractDetailByCompanyContractId, Err: " + e.Error())
|
|
|
+// return
|
|
|
+// }
|
|
|
+//
|
|
|
+// var condition string
|
|
|
+// var pars []interface{}
|
|
|
+//
|
|
|
+// condition = " AND company_id = ? ORDER BY start_date DESC LIMIT 1 "
|
|
|
+// pars = append(pars, contractInfo.CompanyId)
|
|
|
+// contractMergeInfo, e := company.GetCompanyContractMergeDetail(condition, pars)
|
|
|
+// if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+// err = errors.New("GetCompanyContractMergeDetail, Err: " + e.Error())
|
|
|
+// return
|
|
|
+// }
|
|
|
+// //fmt.Println(contractMergeInfo)
|
|
|
+// e = company.UpdateCompanyContractMergeIsBestNew(0, contractInfo.CompanyId)
|
|
|
+// if e != nil {
|
|
|
+// err = errors.New("UpdateCompanyContractMergeIsBestNew, Err: " + e.Error())
|
|
|
+// return
|
|
|
+// }
|
|
|
+// //fmt.Println(contractInfo)
|
|
|
+// item := new(company.CompanyContractMerge)
|
|
|
+// item.ContractType = contractInfo.ContractType
|
|
|
+// item.ProductId = contractInfo.ProductId
|
|
|
+// item.ProductName = contractInfo.ProductName
|
|
|
+// item.CompanyId = contractInfo.CompanyId
|
|
|
+// item.CompanyProductId = contractInfo.CompanyProductId
|
|
|
+// item.IsBestNew = 1
|
|
|
+// item.CreateTime = time.Now()
|
|
|
+// item.ModifyTime = time.Now()
|
|
|
+// //如果不存在就是新的数据
|
|
|
+// if contractMergeInfo == nil {
|
|
|
+// item.StartDate = contractInfo.StartDate
|
|
|
+// item.EndDate = contractInfo.EndDate
|
|
|
+// item.Money = contractInfo.Money
|
|
|
+// item.CompanyContractIdGroup = strconv.Itoa(companyContractId)
|
|
|
+// e = company.AddCompanyContractMerge(item)
|
|
|
+// if e != nil {
|
|
|
+// err = errors.New("AddCompanyContractMerge, Err: " + e.Error())
|
|
|
+// return
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// newStartDate := utils.StrDateToDate(contractInfo.StartDate)
|
|
|
+// //newEndDate := utils.StrDateToDate(contractInfo.EndDate)
|
|
|
+// oldEndDate := utils.StrDateToDate(contractMergeInfo.EndDate)
|
|
|
+//
|
|
|
+// //续约的合同开始时间是否<上一次合同记录的结束时间 且间隔>6个月(180)天,那么就对两个合同进行合并
|
|
|
+// if newStartDate.AddDate(0, 0, +180).Before(oldEndDate) && newStartDate.Before(oldEndDate) {
|
|
|
+// item.Money = contractInfo.Money + contractMergeInfo.Money
|
|
|
+// item.EndDate = contractInfo.EndDate
|
|
|
+// item.CompanyContractIdGroup = contractMergeInfo.CompanyContractIdGroup + "," + strconv.Itoa(companyContractId)
|
|
|
+// //如果是续约合同就对比跟上一份合并之后的合同的差距
|
|
|
+// if item.ContractType == "续约合同" {
|
|
|
+// pars = make([]interface{}, 0)
|
|
|
+// condition = " AND company_id = ? AND company_contract_merge_id != ? ORDER BY start_date DESC LIMIT 1 "
|
|
|
+// pars = append(pars, contractMergeInfo.CompanyId, contractMergeInfo.CompanyContractMergeId)
|
|
|
+// detailPrevious, e := company.GetCompanyContractMergeDetail(condition, pars)
|
|
|
+// if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+// err = errors.New("GetCompanyContractMergeDetail-Update, Err: " + e.Error())
|
|
|
+// return
|
|
|
+// }
|
|
|
+// if detailPrevious == nil {
|
|
|
+// item.PackageDifference = ""
|
|
|
+// } else {
|
|
|
+// if item.Money > detailPrevious.Money {
|
|
|
+// item.PackageDifference = "增加套餐"
|
|
|
+// }
|
|
|
+// if item.Money == detailPrevious.Money {
|
|
|
+// item.PackageDifference = "维持套餐"
|
|
|
+// }
|
|
|
+// if item.Money < detailPrevious.Money {
|
|
|
+// item.PackageDifference = "减少套餐"
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// item.CompanyContractMergeId = contractMergeInfo.CompanyContractMergeId
|
|
|
+// e = company.UpdateCompanyContractMerge(item)
|
|
|
+// if e != nil {
|
|
|
+// err = errors.New("AddCompanyContractMerge, Err: " + e.Error())
|
|
|
+// return
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// item.StartDate = contractInfo.StartDate
|
|
|
+// item.EndDate = contractInfo.EndDate
|
|
|
+// item.Money = contractInfo.Money
|
|
|
+// item.CompanyContractIdGroup = strconv.Itoa(companyContractId)
|
|
|
+// //如果是续约合同就对比跟上一份合并之后的合同的差距
|
|
|
+// if item.ContractType == "续约合同" {
|
|
|
+// //pars = make([]interface{}, 0)
|
|
|
+// //condition = " AND company_id = ? AND company_contract_merge_id != ? ORDER BY start_date DESC LIMIT 1 "
|
|
|
+// //pars = append(pars, contractMergeInfo.CompanyId, contractMergeInfo.CompanyContractMergeId)
|
|
|
+// //detailPrevious, e := company.GetCompanyContractMergeDetail(condition, pars)
|
|
|
+// //if e != nil {
|
|
|
+// // err = errors.New("GetCompanyContractMergeDetail——add, Err: " + e.Error())
|
|
|
+// // return
|
|
|
+// //}
|
|
|
+// if item.Money > contractMergeInfo.Money {
|
|
|
+// item.PackageDifference = "增加套餐"
|
|
|
+// }
|
|
|
+// if item.Money == contractMergeInfo.Money {
|
|
|
+// item.PackageDifference = "维持套餐"
|
|
|
+// }
|
|
|
+// if item.Money < contractMergeInfo.Money {
|
|
|
+// item.PackageDifference = "减少套餐"
|
|
|
+// }
|
|
|
+// }
|
|
|
+// e = company.AddCompanyContractMerge(item)
|
|
|
+// if e != nil {
|
|
|
+// err = errors.New("AddCompanyContractMerge, Err: " + e.Error())
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// return
|
|
|
+//}
|