122 Commit-ok 9c4a7ff6cd ... d3345e16d5

Szerző SHA1 Üzenet Dátum
  zhangchuanxing d3345e16d5 Merge branch 'master' of http://8.136.199.33:3000/hongze/hz_crm_api into cygx/cygx_13.9 1 napja
  zhangchuanxing 6742d8d818 no message 5 napja
  zhangchuanxing 4efb700fcc no message 5 napja
  zhangchuanxing 11c88b5153 Merge branch 'master' of http://8.136.199.33:3000/hongze/hz_crm_api into crm/crm_16.1 5 napja
  zhangchuanxing 089f1fddda no message 5 napja
  zhangchuanxing e98d9d20f6 Merge branch 'crm/crm_16.1' of http://8.136.199.33:3000/hongze/hz_crm_api 5 napja
  zhangchuanxing f00969365a no message 5 napja
  zhangchuanxing dbc77310ff no message 1 hete
  zhangchuanxing f108d34e69 no message 1 hete
  zhangchuanxing 689793d83c Merge branch 'crm/crm_16.1' of http://8.136.199.33:3000/hongze/hz_crm_api 1 hete
  zhangchuanxing 6997f00cba no message 1 hete
  zhangchuanxing d4d9d27193 no message 1 hete
  zhangchuanxing 808130b4e1 Merge branch 'cygx/cygx_14.1' of http://8.136.199.33:3000/hongze/hz_crm_api 1 hete
  zhangchuanxing f514329e01 no message 1 hete
  zhangchuanxing ca86e34464 no message 1 hete
  zhangchuanxing 42f0ae81f6 no message 1 hete
  zhangchuanxing db424e1536 no message 1 hete
  zhangchuanxing 4cc88a6b9c no message 1 hete
  zhangchuanxing b4cf4e390b no message 2 hete
  zhangchuanxing fc0f8f1ea1 no message 2 hete
  xiziwen 2540df5df1 Merge branch 'small_281' 2 hete
  zhangchuanxing 9e8b05afee no message 2 hete
  zhangchuanxing 9d4bb605b0 no message 2 hete
  zhangchuanxing 8edb0c398d no message 2 hete
  zhangchuanxing 5319837f2c no message 2 hete
  zhangchuanxing 71827d382e no message 2 hete
  zhangchuanxing cb88f7446f no message 2 hete
  zhangchuanxing 3ecfd54a74 no message 2 hete
  zhangchuanxing 42a37110f3 no message 2 hete
  zhangchuanxing a40ba6536c no message 2 hete
  zhangchuanxing d9cd8b427c no message 2 hete
  zhangchuanxing a738b14728 no message 2 hete
  zhangchuanxing 83bd4fab2e no message 2 hete
  zhangchuanxing c3dd9ef54a no message 2 hete
  zhangchuanxing d25d0e5ce9 Merge branch 'master' of http://8.136.199.33:3000/hongze/hz_crm_api into crm/crm_16.1 2 hete
  zhangchuanxing bda22cb259 no message 2 hete
  zhangchuanxing ee7578af19 no message 2 hete
  zhangchuanxing 0c9c5bf94a no message 3 hete
  zhangchuanxing 3200f86412 no message 3 hete
  zhangchuanxing 0ecbbfa728 no message 3 hete
  zhangchuanxing e20087432c no message 3 hete
  zhangchuanxing cc978719f2 Merge branch 'master' of http://8.136.199.33:3000/hongze/hz_crm_api into crm/crm_16.1 3 hete
  xiziwen 1160029950 first 3 hete
  zhangchuanxing 5c4d929b88 Merge branch 'master' of http://8.136.199.33:3000/hongze/hz_crm_api 3 hete
  xiziwen a20d9e9dda Merge branch 'small_299' 3 hete
  zhangchuanxing d650710a6e Merge branch 'crm/crm_16.3' of http://8.136.199.33:3000/hongze/hz_crm_api 3 hete
  zhangchuanxing a66148f42a Merge branch 'crm/crm_16.2.2' of http://8.136.199.33:3000/hongze/hz_crm_api 3 hete
  xiziwen a003994ead fix 3 hete
  Roc 6a41f09013 fix:跨年的报告搜索 3 hete
  Roc d55b956ecd fix:跨年的报告搜索 3 hete
  zhangchuanxing f03c324bb9 no message 3 hete
  zhangchuanxing cbdc2c7f46 no message 4 hete
  zhangchuanxing ea65065a19 no message 4 hete
  zhangchuanxing 80fa7924ec no message 1 hónapja
  zhangchuanxing c566f7a608 no message 1 hónapja
  zhangchuanxing 4d6acc20da no message 1 hónapja
  zhangchuanxing 7dda187133 no message 1 hónapja
  zhangchuanxing 56593450e1 no message 1 hónapja
  xiziwen 075ed39586 fix 1 hónapja
  xiziwen 33d07eed7d fix 1 hónapja
  zhangchuanxing 476788912d Merge branch 'cygx/cygx_need_959' of http://8.136.199.33:3000/hongze/hz_crm_api 1 hónapja
  zhangchuanxing a047b774ab no message 1 hónapja
  zhangchuanxing 2e67698ddf no message 1 hónapja
  zhangchuanxing bc92fa779c no message 1 hónapja
  zhangchuanxing 510c548f50 no message 1 hónapja
  zhangchuanxing 4e22706941 Merge branch 'master' of http://8.136.199.33:3000/hongze/hz_crm_api into crm/crm_16.2.2 1 hónapja
  zhangchuanxing a087db7a17 no message 1 hónapja
  xiziwen facccf22ab 去掉修改原因 1 hónapja
  xiziwen 65aa05e9c4 Merge branch 'small_291' 1 hónapja
  xiziwen b5dadf7e88 三级审批人 1 hónapja
  xyxie 4478e81173 Merge branch 'hotfix/bug6548_matters_edit' of hongze/hz_crm_api into master 1 hónapja
  zhangchuanxing fa04c10a86 no message 1 hónapja
  zhangchuanxing 8f679e1852 no message 1 hónapja
  xiziwen 0c5f7172e8 导出fix 1 hónapja
  xyxie 8de8164a3f ..异常解决 1 hónapja
  zhangchuanxing 97e7d53751 no message 1 hónapja
  xiziwen b0ae84c61d fix 1 hónapja
  xiziwen 1e0301bfff fix 1 hónapja
  xiziwen 3dbd545a08 fix 1 hónapja
  xiziwen 19a3e063d9 fix 导出 1 hónapja
  xiziwen 84a18f6d39 Merge branch 'small_289' 1 hónapja
  xiziwen 028c1f7c82 fix 1 hónapja
  xiziwen 4d33b1bf8f Merge branch 'small_289' 1 hónapja
  xiziwen cfe2d7c956 fix 1 hónapja
  xiziwen e108fb68d2 fix 1 hónapja
  xiziwen cdbe0eb489 fix 1 hónapja
  xiziwen 5509b03d3d fix 1 hónapja
  xiziwen 08c21393bc fix 1 hónapja
  xiziwen 267b80c59f fix 1 hónapja
  xiziwen d9b60d09b0 fix 1 hónapja
  xiziwen 629985df97 first 1 hónapja
  xiziwen 75eba4c761 fix 1 hónapja
  zhangchuanxing c327a4b4e1 Merge branch 'cygx/need_1007' of http://8.136.199.33:3000/hongze/hz_crm_api 1 hónapja
  zhangchuanxing 9c07432821 no message 1 hónapja
  zhangchuanxing 1a0c076584 no message 1 hónapja
  zhangchuanxing 774d444564 no message 1 hónapja
  xiziwen d2765e9fba first 1 hónapja
  zhangchuanxing 8b32eec8fa no message 1 hónapja
  zhangchuanxing be6d37774c no message 1 hónapja
  zhangchuanxing 6401ac3462 no message 1 hónapja
  zhangchuanxing 55b440b787 no message 1 hónapja
  zhangchuanxing 5e89e83bc3 no message 1 hónapja
  zhangchuanxing 5ebdb5dfda no message 1 hónapja
  zhangchuanxing 5b7f6282e5 no message 2 hónapja
  zhangchuanxing 38477afb20 no message 2 hónapja
  zhangchuanxing 232890c52b no message 2 hónapja
  zhangchuanxing e42d56650d no message 2 hónapja
  zhangchuanxing 7dc2c8ac36 no message 2 hónapja
  zhangchuanxing 277cd1f917 no message 2 hónapja
  zhangchuanxing bf4869ec4e no message 2 hónapja
  zhangchuanxing e312a4015b Merge branch 'crm/crm_16.2.1' of http://8.136.199.33:3000/hongze/hz_crm_api 2 hónapja
  zhangchuanxing 55a53a0e9d no message 2 hónapja
  zhangchuanxing cce3b1c969 Merge branch 'crm/crm_16.2.1' of http://8.136.199.33:3000/hongze/hz_crm_api 2 hónapja
  xingzai c318184d5d no message 2 hónapja
  xingzai 6342c3d8aa no message 2 hónapja
  xingzai 63848912d9 no message 2 hónapja
  xingzai 54b15ecc5d no message 2 hónapja
  xingzai 234f7f2bf9 no message 2 hónapja
  xingzai 8554c643e3 Merge branch 'master' of http://8.136.199.33:3000/hongze/hz_crm_api into crm/crm_16.1 2 hónapja
  xingzai 31c6156266 no message 2 hónapja
  xingzai e76b74e4d6 no message 2 hónapja
  xingzai d3389abb11 no message 3 hónapja
55 módosított fájl, 5929 hozzáadás és 471 törlés
  1. 12 0
      controllers/business_trip/business_apply.go
  2. 9 0
      controllers/company.go
  3. 89 63
      controllers/company_apply_v2.go
  4. 1958 1
      controllers/company_seller.go
  5. 4 0
      controllers/company_share.go
  6. 62 2
      controllers/company_user.go
  7. 1 0
      controllers/cygx/activity.go
  8. 150 82
      controllers/cygx/activity_meet.go
  9. 61 0
      controllers/cygx/industrial_subject.go
  10. 1 0
      controllers/cygx/report_article.go
  11. 142 42
      controllers/cygx/report_selection.go
  12. 10 1
      controllers/cygx/user.go
  13. 79 38
      controllers/roadshow/calendar.go
  14. 312 7
      controllers/seal/seal_approval.go
  15. 692 39
      controllers/statistic_company_merge.go
  16. 917 34
      controllers/statistic_report.go
  17. 4 0
      models/business_trip/business_apply.go
  18. 11 0
      models/company/company_approval.go
  19. 150 0
      models/company/company_contract.go
  20. 9 2
      models/company/company_operation_record.go
  21. 33 0
      models/company/company_product.go
  22. 1 0
      models/company/company_user.go
  23. 65 0
      models/company/wx_user_move_log.go
  24. 34 0
      models/cygx/activity.go
  25. 13 8
      models/cygx/activity_attendance_detail.go
  26. 35 0
      models/cygx/activity_signup_detail.go
  27. 1 0
      models/cygx/cygx_user.go
  28. 1 23
      models/cygx/cygx_user_company.go
  29. 1 3
      models/cygx/gushou_time_line_history.go
  30. 1 0
      models/cygx/industrial_subject.go
  31. 12 1
      models/cygx/report_article.go
  32. 1 1
      models/cygx/report_selection.go
  33. 63 51
      models/cygx/report_selection_log.go
  34. 12 10
      models/cygx/report_selection_subject_history.go
  35. 33 0
      models/cygx/report_selection_third_name.go
  36. 3 0
      models/db.go
  37. 9 0
      models/response/statistic_report.go
  38. 35 0
      models/roadshow/rs_calendar_api_log.go
  39. 31 29
      models/seal/request/seal_approval.go
  40. 65 1
      models/seal/seal.go
  41. 4 0
      models/stack_company_statistic.go
  42. 39 6
      models/statistic_report.go
  43. 8 0
      models/system/sys_admin.go
  44. 7 0
      models/system/sys_group.go
  45. 72 0
      routers/commentsRouter.go
  46. 76 0
      services/company.go
  47. 1 0
      services/company_apply/company_approval.go
  48. 129 0
      services/company_contract.go
  49. 28 1
      services/contract/contract.go
  50. 3 0
      services/cygx/acitvity.go
  51. 14 17
      services/cygx/activity_special.go
  52. 369 0
      services/cygx/yidong.go
  53. 36 4
      services/roadshow/calendar.go
  54. 13 5
      services/seal/seal.go
  55. 8 0
      utils/common.go

+ 12 - 0
controllers/business_trip/business_apply.go

@@ -78,6 +78,11 @@ func (this *BusinessTrip) ApplyAdd() {
 		return
 	}
 
+	if req.Itinerary == "" {
+		br.Msg = "请填写行程说明"
+		return
+	}
+
 	startP, _ := time.ParseInLocation(utils.FormatDate, req.ArriveDate, time.Local)
 	endP, _ := time.ParseInLocation(utils.FormatDate, req.ReturnDate, time.Local)
 	nowDate, _ := time.ParseInLocation(utils.FormatDate, time.Now().Format(utils.FormatDate), time.Local)
@@ -188,6 +193,7 @@ func (this *BusinessTrip) ApplyAdd() {
 	item.ApproveName = approveItem.RealName
 	item.CreateTime = time.Now()
 	item.ModifyTime = time.Now()
+	item.Itinerary = req.Itinerary
 	applyId, err := business_trip.AddBusinessApply(item)
 	if err != nil {
 		br.Msg = "申请失败"
@@ -332,6 +338,11 @@ func (this *BusinessTrip) ApplyEdit() {
 		return
 	}
 
+	if req.Itinerary == "" {
+		br.Msg = "请填写行程说明"
+		return
+	}
+
 	startP, _ := time.ParseInLocation(utils.FormatDate, req.ArriveDate, time.Local)
 	endP, _ := time.ParseInLocation(utils.FormatDate, req.ReturnDate, time.Local)
 	nowDate, _ := time.ParseInLocation(utils.FormatDate, time.Now().Format(utils.FormatDate), time.Local)
@@ -459,6 +470,7 @@ func (this *BusinessTrip) ApplyEdit() {
 	updateParams["refuse_reason"] = ""
 	updateParams["create_time"] = time.Now()
 	updateParams["modify_time"] = time.Now()
+	updateParams["itinerary"] = req.Itinerary
 
 	err = business_trip.UpdateBusinessApply(whereParams, updateParams)
 	if err != nil {

+ 9 - 0
controllers/company.go

@@ -2983,6 +2983,9 @@ func (this *CompanyController) Add() {
 	if productId == utils.COMPANY_PRODUCT_RAI_ID && req.Status == utils.COMPANY_STATUS_FOREVER { // 权益的永续客户给一个状态初始化的记录
 		companyProduct.InitStatus = req.Status
 	}
+
+	companyProduct.SellerIdInit = seller.AdminId
+	companyProduct.SellerNameInit = seller.RealName
 	companyProductId, err := company.AddCompanyProduct(companyProduct)
 	if err != nil {
 		br.Msg = "新增失败"
@@ -5119,6 +5122,8 @@ func (this *CompanyController) Receive() {
 		companyProduct.OpenCode = services.GenerateOpenCompanyProductCode(req.CompanyId, productId)
 		companyProduct.TodoStatus = "无任务"
 		companyProduct.TryStage = 1
+		companyProduct.SellerIdInit = seller.AdminId
+		companyProduct.SellerNameInit = seller.RealName
 		_, err = company.AddCompanyProduct(companyProduct)
 		if err != nil {
 			br.Msg = "新增失败"
@@ -5315,6 +5320,10 @@ func (this *CompanyController) MoveSeller() {
 		services.AddCompanyOperationRecord(req.CompanyId, seller.AdminId, sysUser.AdminId, productId, sysUser.AdminId, cp.CompanyName,
 			cp.ProductName, sysUser.RealName, remark, operation, "", sysUser.RealName, "", cp.Status)
 	}
+
+	{
+		services.UpdateCompanyContractSellerMove(req.CompanyId, productId) //益客户移动所属销售之后,更新所关联的销售信息
+	}
 	//变更销售员与联系人关系
 	_ = models.UpdateUserSellerRelationByCompanyId(req.CompanyId, productId, seller.AdminId, seller.RealName)
 

+ 89 - 63
controllers/company_apply_v2.go

@@ -77,6 +77,49 @@ func (this *CompanyApplyController) ApplyServiceUpdate() {
 		br.ErrMsg = "客户类型为:" + req.CompanyType
 		return
 	}
+
+	//添加缓存,避免多次点击提交
+	{
+		deleteCache := true
+		cacheKey := "CACHE_COMPANY_APPLY_" + strconv.Itoa(req.CompanyId) + "_" + strconv.Itoa(productId)
+		defer func() {
+			if deleteCache {
+				utils.Rc.Delete(cacheKey)
+			}
+		}()
+		if !utils.Rc.SetNX(cacheKey, 1, 30*time.Second) {
+			deleteCache = false
+			br.Msg = "系统处理中,请勿重复操作"
+			br.ErrMsg = "系统处理中,请勿重复操作" + sysUser.RealName + ";data:" + string(this.Ctx.Input.RequestBody)
+			return
+		}
+	}
+
+	approveRoleTypeCode := ""
+	if productId == 1 {
+		approveRoleTypeCode = utils.ROLE_TYPE_CODE_FICC_ADMIN
+	} else {
+		approveRoleTypeCode = utils.ROLE_TYPE_CODE_RAI_ADMIN
+	}
+	companyProduct, err := company.GetCompanyProductByCompanyIdAndProductId(req.CompanyId, productId)
+	if err != nil {
+		br.Msg = "获取客户信息失败"
+		br.ErrMsg = "获取客户信息失败"
+		return
+	}
+	if companyProduct.Status != utils.COMPANY_STATUS_FORMAL && companyProduct.Status != utils.COMPANY_STATUS_TRY_OUT {
+		br.Msg = "客户状态为:" + companyProduct.Status + ";不可进行服务更新申请"
+		br.ErrMsg = "客户状态为:" + companyProduct.Status + ";不可进行服务更新申请"
+		return
+	}
+
+	//客户归属判断-当前销售/咨询组共享销售
+	if companyProduct.SellerId != sysUser.AdminId && companyProduct.ShareSellerId != sysUser.AdminId {
+		br.Msg = "客户信息异常"
+		br.ErrMsg = "客户信息异常,不是当前所属销售,客户所属销售:" + companyProduct.SellerName + ";当前销售:" + sysUser.AdminName
+		return
+	}
+
 	mapPermissionIdUpgrade := make(map[int]int, 0)
 	mapPermissionIdExpensive := make(map[int]int, 0)
 	var raicontractType string
@@ -100,7 +143,7 @@ func (this *CompanyApplyController) ApplyServiceUpdate() {
 
 		//权益的新签合同重新定义,如果合同起始时间在新签合同起始日期 1年之内的,仍为新签合同。
 		raicontractType = req.ContractType
-		if raicontractType != "新签合同" {
+		if raicontractType != "新签合同" && companyProduct.Status != utils.COMPANY_STATUS_FOREVER {
 			//startDateTime, _ := time.Parse(utils.FormatDate, req.StartDate)
 			//startDateTime = startDateTime.AddDate(-1, 0, 0)
 			totalLastYear, err := contractService.GetCompanyContractCountRaiByLastYear(req.CompanyId, req.StartDate)
@@ -124,47 +167,6 @@ func (this *CompanyApplyController) ApplyServiceUpdate() {
 		req.PermissionIds = permissionStr
 	}
 
-	//添加缓存,避免多次点击提交
-	{
-		deleteCache := true
-		cacheKey := "CACHE_COMPANY_APPLY_" + strconv.Itoa(req.CompanyId) + "_" + strconv.Itoa(productId)
-		defer func() {
-			if deleteCache {
-				utils.Rc.Delete(cacheKey)
-			}
-		}()
-		if !utils.Rc.SetNX(cacheKey, 1, 30*time.Second) {
-			deleteCache = false
-			br.Msg = "系统处理中,请勿重复操作"
-			br.ErrMsg = "系统处理中,请勿重复操作" + sysUser.RealName + ";data:" + string(this.Ctx.Input.RequestBody)
-			return
-		}
-	}
-
-	approveRoleTypeCode := ""
-	if productId == 1 {
-		approveRoleTypeCode = utils.ROLE_TYPE_CODE_FICC_ADMIN
-	} else {
-		approveRoleTypeCode = utils.ROLE_TYPE_CODE_RAI_ADMIN
-	}
-	companyProduct, err := company.GetCompanyProductByCompanyIdAndProductId(req.CompanyId, productId)
-	if err != nil {
-		br.Msg = "获取客户信息失败"
-		br.ErrMsg = "获取客户信息失败"
-		return
-	}
-	if companyProduct.Status != utils.COMPANY_STATUS_FORMAL && companyProduct.Status != utils.COMPANY_STATUS_TRY_OUT {
-		br.Msg = "客户状态为:" + companyProduct.Status + ";不可进行服务更新申请"
-		br.ErrMsg = "客户状态为:" + companyProduct.Status + ";不可进行服务更新申请"
-		return
-	}
-
-	//客户归属判断-当前销售/咨询组共享销售
-	if companyProduct.SellerId != sysUser.AdminId && companyProduct.ShareSellerId != sysUser.AdminId {
-		br.Msg = "客户信息异常"
-		br.ErrMsg = "客户信息异常,不是当前所属销售,客户所属销售:" + companyProduct.SellerName + ";当前销售:" + sysUser.AdminName
-		return
-	}
 	var approveUserId int
 	var approveUserRealName string
 	applyMethod := 5 //续约服务
@@ -241,6 +243,14 @@ func (this *CompanyApplyController) ApplyServiceUpdate() {
 		contract.ModifyTime = time.Now()
 		contract.PackageType = req.PackageType
 		contract.RaiPackageType = req.RaiPackageType
+		contract.SellerIdInit = companyProduct.SellerId
+		contract.SellerNameInit = companyProduct.SellerName
+		contract.ShareSellerInit = companyProduct.ShareSeller
+		contract.ShareSellerIdInit = companyProduct.ShareSellerId
+		contract.SellerIdLast = companyProduct.SellerId
+		contract.SellerNameLast = companyProduct.SellerName
+		contract.ShareSellerLast = companyProduct.ShareSeller
+		contract.ShareSellerIdLast = companyProduct.ShareSellerId
 		newId, err := company.AddCompanyContract(contract)
 		if err != nil {
 			br.Msg = "新增合同失败"
@@ -616,7 +626,7 @@ func (this *CompanyApplyController) ApplyTurnPositive() {
 		if productId == 2 {
 			//权益的新签合同重新定义,如果合同起始时间在新签合同起始日期 1年之内的,仍为新签合同。
 			raicontractType = contractType
-			if raicontractType != "新签合同" {
+			if raicontractType != "新签合同" && companyProduct.Status != utils.COMPANY_STATUS_FOREVER {
 				//startDateTime, _ := time.Parse(utils.FormatDate, req.StartDate)
 				//startDateTime = startDateTime.AddDate(-1, 0, 0)
 				totalLastYear, err := contractService.GetCompanyContractCountRaiByLastYear(req.CompanyId, req.StartDate)
@@ -693,6 +703,14 @@ func (this *CompanyApplyController) ApplyTurnPositive() {
 		contract.RaiPackageType = req.RaiPackageType
 		contract.CreateTime = time.Now()
 		contract.ModifyTime = time.Now()
+		contract.SellerIdInit = companyProduct.SellerId
+		contract.SellerNameInit = companyProduct.SellerName
+		contract.ShareSellerInit = companyProduct.ShareSeller
+		contract.ShareSellerIdInit = companyProduct.ShareSellerId
+		contract.SellerIdLast = companyProduct.SellerId
+		contract.SellerNameLast = companyProduct.SellerName
+		contract.ShareSellerLast = companyProduct.ShareSeller
+		contract.ShareSellerIdLast = companyProduct.ShareSellerId
 		newId, err := company.AddCompanyContract(contract)
 		if err != nil {
 			br.Msg = "新增合同失败"
@@ -1141,7 +1159,7 @@ func (this *CompanyApplyController) ApplyBySystemContract() {
 	if productId == 2 {
 		//权益的新签合同重新定义,如果合同起始时间在新签合同起始日期 1年之内的,仍为新签合同。
 		raicontractType = contractType
-		if raicontractType != "新签合同" {
+		if raicontractType != "新签合同" && companyProduct.Status != utils.COMPANY_STATUS_FOREVER {
 			//startDateTime := contractDetail.StartDate.AddDate(-1, 0, 0)
 			totalLastYear, err := contractService.GetCompanyContractCountRaiByLastYear(req.CompanyId, contractDetail.StartDate.Format(utils.FormatDate))
 			if err != nil {
@@ -1176,25 +1194,33 @@ func (this *CompanyApplyController) ApplyBySystemContract() {
 		//	return
 		//}
 		companyContract := &company.CompanyContract{
-			CompanyId:        req.CompanyId,
-			ProductId:        contractDetail.ProductId,
-			ContractType:     contractType,
-			RaiContractType:  raicontractType,
-			ProductName:      companyProduct.ProductName,
-			CompanyProductId: companyProduct.CompanyProductId,
-			ContractCode:     contractDetail.ContractCode,
-			StartDate:        contractDetail.StartDate.Format(utils.FormatDate),
-			EndDate:          contractDetail.EndDate.Format(utils.FormatDate),
-			Money:            contractDetail.Price,
-			PayMethod:        contractDetail.PayRemark,
-			PayChannel:       contractDetail.PayChannel,
-			ImgUrl:           contractDetail.CheckBackFileUrl,
-			Status:           0,
-			Source:           "系统合同",
-			PackageType:      packageType,
-			RaiPackageType:   raiPackageType,
-			CreateTime:       time.Now(),
-			ModifyTime:       time.Now(),
+			CompanyId:         req.CompanyId,
+			ProductId:         contractDetail.ProductId,
+			ContractType:      contractType,
+			RaiContractType:   raicontractType,
+			ProductName:       companyProduct.ProductName,
+			CompanyProductId:  companyProduct.CompanyProductId,
+			ContractCode:      contractDetail.ContractCode,
+			StartDate:         contractDetail.StartDate.Format(utils.FormatDate),
+			EndDate:           contractDetail.EndDate.Format(utils.FormatDate),
+			Money:             contractDetail.Price,
+			PayMethod:         contractDetail.PayRemark,
+			PayChannel:        contractDetail.PayChannel,
+			ImgUrl:            contractDetail.CheckBackFileUrl,
+			Status:            0,
+			Source:            "系统合同",
+			PackageType:       packageType,
+			RaiPackageType:    raiPackageType,
+			CreateTime:        time.Now(),
+			ModifyTime:        time.Now(),
+			SellerIdInit:      companyProduct.SellerId,
+			SellerNameInit:    companyProduct.SellerName,
+			ShareSellerInit:   companyProduct.ShareSeller,
+			ShareSellerIdInit: companyProduct.ShareSellerId,
+			SellerIdLast:      companyProduct.SellerId,
+			SellerNameLast:    companyProduct.SellerName,
+			ShareSellerLast:   companyProduct.ShareSeller,
+			ShareSellerIdLast: companyProduct.ShareSellerId,
 		}
 		newId, err := company.AddCompanyContract(companyContract)
 		if err != nil {

+ 1958 - 1
controllers/company_seller.go

@@ -191,7 +191,7 @@ func (this *CompanySellerController) CheckListV2() {
 	getAllUser, _ := this.GetBool("AllUser", false)
 	status, _ := this.GetInt("Status", 0)
 	getAllEnabled, _ := this.GetBool("AllEnabled", false)
-	enabled := 1       //默认只获取正常状态的用户
+	enabled := -1       //默认只获取正常状态的用户
 	if getAllEnabled { //获取所有状态的用户
 		enabled = -1
 	}
@@ -5529,3 +5529,1960 @@ func (this *CompanySellerController) RaiServeSellerList() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// CheckListV2
+// @Title 获取组长/组员下销售(根据部门、分组)-开票到款统计用 有特殊处理
+// @Description 获取组长/组员下销售(根据部门、分组)接口
+// @Param   AllSeller   query   bool  true       "是否获取部门所有的销售信息"
+// @Param   Status   query   int  true       "客户状态 1:流失 0:非流失"
+// @Param   AllEnabled   query   bool  true       "是否获取包含禁用的用户"
+// @Success 200 {object} company.DepartmentGroupSellersResp
+// @router /seller/check/invoice_payment/list [get]
+func (this *CompanySellerController) InvoicePaymentCheckList() {
+	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
+	}
+	roleCodeTypeStr := ``
+	productId := services.GetProductId(sysUser.RoleTypeCode)
+	switch productId {
+	case 1:
+		roleCodeTypeStr = `"` + utils.ROLE_TYPE_CODE_FICC_SELLER + `","` + utils.ROLE_TYPE_CODE_FICC_GROUP + `","` + utils.ROLE_TYPE_CODE_FICC_TEAM + `"`
+	case 2:
+		roleCodeTypeStr = `"` + utils.ROLE_TYPE_CODE_RAI_SELLER + `","` + utils.ROLE_TYPE_CODE_RAI_GROUP + `"`
+	}
+
+	// ficc管理员,不要只查销售
+	if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
+		roleCodeTypeStr = ``
+	} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
+		// 权益管理员,查看所有权益的账号
+		roleCodeTypeStr = `"` + utils.ROLE_TYPE_CODE_RAI_SELLER + `","` + utils.ROLE_TYPE_CODE_RAI_GROUP + `","` + utils.ROLE_TYPE_CODE_RAI_RESEARCHR + `","` + utils.ROLE_TYPE_CODE_RAI_ADMIN + `"`
+	}
+
+	getAllSeller, _ := this.GetBool("AllSeller", false)
+	getAllUser, _ := this.GetBool("AllUser", false)
+	status, _ := this.GetInt("Status", 0)
+	//getAllEnabled, _ := this.GetBool("AllEnabled", false)
+	enabled := -1       //默认只获取正常状态的用户
+	//if getAllEnabled { //获取所有状态的用户
+	//	enabled = -1
+	//}
+	list := make([]company.DepartmentGroupSellers, 0)
+	if getAllUser {
+		departmentList, err := system.GetDepartmentList()
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取部门失败,Err:" + err.Error()
+			return
+		}
+		for _, department := range departmentList {
+			departmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
+			item := company.DepartmentGroupSellers{
+				AdminId: fmt.Sprint("department_", department.DepartmentId),
+				//AdminName string `description:"系统用户名称"`
+				RealName:     department.DepartmentName,
+				ChildrenList: departmentGroupSellerList,
+			}
+
+			groupList, err := system.GetSysGroupByDepartmentId(department.DepartmentId)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取分组失败,Err:" + err.Error()
+				return
+			}
+			for _, group := range groupList {
+				groupSellerList := make([]company.DepartmentGroupSellers, 0)
+				groupItem := company.DepartmentGroupSellers{
+					AdminId: fmt.Sprint("group_", group.DepartmentId),
+					//AdminName string `description:"系统用户名称"`
+					RealName:     group.GroupName,
+					ChildrenList: groupSellerList,
+				}
+				teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
+				if err != nil {
+					br.Msg = "获取小组失败"
+					br.ErrMsg = "获取小组失败,Err:" + err.Error()
+					return
+				}
+				for _, team := range teamList {
+					teamSellerList := make([]company.DepartmentGroupSellers, 0)
+					teamItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint("team_", team.GroupId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     team.GroupName,
+						ChildrenList: teamSellerList,
+					}
+					sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
+					if err != nil {
+						br.Msg = "获取销售失败"
+						br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						return
+					}
+					for _, seller := range sellerList {
+						sellerItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint(seller.AdminId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     seller.RealName,
+							Authority:    seller.Authority,
+							RoleTypeCode: seller.RoleTypeCode,
+						}
+						//fmt.Println("seller.RealName:", seller.RealName)
+						teamSellerList = append(teamSellerList, sellerItem)
+					}
+					teamSellerList = sortDepartmentGroupSellers(teamSellerList)
+					teamItem.ChildrenList = teamSellerList
+					if len(teamSellerList) > 0 {
+						groupSellerList = append(groupSellerList, teamItem)
+					}
+				}
+				//分组为0的销售(直属分组)
+				groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
+				if err != nil {
+					br.Msg = "获取销售失败"
+					br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					return
+				}
+				if len(groupTeamSellerList) > 0 {
+					tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+					for _, seller := range groupTeamSellerList {
+						sellerItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint(seller.AdminId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     seller.RealName,
+							Authority:    seller.Authority,
+							RoleTypeCode: seller.RoleTypeCode,
+						}
+						tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+					}
+					//排个序
+					tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+					groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
+				}
+
+				//groupItem.ChildrenList = groupSellerList
+				//if len(groupSellerList) > 0 {
+				//	list = append(list, item)
+				//}
+
+				//sellerList, err := system.GetGroupSysUserList(group.DepartmentId)
+				//if err != nil {
+				//	br.Msg = "获取销售失败"
+				//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				//	return
+				//}
+				//for _, seller := range sellerList {
+				//	sellerItem := company.DepartmentGroupSellers{
+				//		AdminId: fmt.Sprint(seller.AdminId),
+				//		//AdminName string `description:"系统用户名称"`
+				//		RealName:     seller.RealName,
+				//		Authority:    seller.Authority,
+				//		RoleTypeCode: seller.RoleTypeCode,
+				//	}
+				//	groupSellerList = append(groupSellerList, sellerItem)
+				//}
+				//groupSellerList = sortDepartmentGroupSellers(groupSellerList)
+				groupItem.ChildrenList = groupSellerList
+				if len(groupSellerList) > 0 {
+					departmentGroupSellerList = append(departmentGroupSellerList, groupItem)
+				}
+			}
+
+			//分组为0的销售(直属部门)
+			departmentSellerList, err := system.GetDepartmentGroupSysUserList(department.DepartmentId, 0, roleCodeTypeStr)
+			if err != nil {
+				br.Msg = "获取销售失败"
+				br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				return
+			}
+			if len(departmentSellerList) > 0 {
+				tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+				for _, seller := range departmentSellerList {
+					sellerItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint(seller.AdminId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     seller.RealName,
+						Authority:    seller.Authority,
+						RoleTypeCode: seller.RoleTypeCode,
+					}
+					tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+				}
+				//排个序
+				tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+				departmentGroupSellerList = append(departmentGroupSellerList, tmpDepartmentGroupSellersList...)
+			}
+
+			item.ChildrenList = departmentGroupSellerList
+			if len(departmentGroupSellerList) > 0 {
+				list = append(list, item)
+			}
+		}
+
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = company.DepartmentGroupSellersResp{
+			List: list,
+		}
+
+		return
+	}
+	if getAllSeller == false {
+		//超管看部门、小组、销售
+		if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
+			departmentList, err := system.GetDepartmentList()
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取部门失败,Err:" + err.Error()
+				return
+			}
+			for _, department := range departmentList {
+				departmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
+				item := company.DepartmentGroupSellers{
+					AdminId: fmt.Sprint("department_", department.DepartmentId),
+					//AdminName string `description:"系统用户名称"`
+					RealName:     department.DepartmentName,
+					ChildrenList: departmentGroupSellerList,
+				}
+
+				groupList, err := system.GetSysGroupByDepartmentId(department.DepartmentId)
+				if err != nil {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取分组失败,Err:" + err.Error()
+					return
+				}
+				for _, group := range groupList {
+					groupSellerList := make([]company.DepartmentGroupSellers, 0)
+					groupItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint("group_", group.DepartmentId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     group.GroupName,
+						ChildrenList: groupSellerList,
+					}
+					teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
+					if err != nil {
+						br.Msg = "获取小组失败"
+						br.ErrMsg = "获取小组失败,Err:" + err.Error()
+						return
+					}
+					for _, team := range teamList {
+						teamSellerList := make([]company.DepartmentGroupSellers, 0)
+						teamItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint("team_", team.GroupId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     team.GroupName,
+							ChildrenList: teamSellerList,
+						}
+						sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
+						if err != nil {
+							br.Msg = "获取销售失败"
+							br.ErrMsg = "获取销售失败,Err:" + err.Error()
+							return
+						}
+						for _, seller := range sellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							//fmt.Println("seller.RealName:", seller.RealName)
+							teamSellerList = append(teamSellerList, sellerItem)
+						}
+						teamSellerList = sortDepartmentGroupSellers(teamSellerList)
+						teamItem.ChildrenList = teamSellerList
+						if len(teamSellerList) > 0 {
+							groupSellerList = append(groupSellerList, teamItem)
+						}
+					}
+					//分组为0的销售(直属分组)
+					groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
+					if err != nil {
+						br.Msg = "获取销售失败"
+						br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						return
+					}
+					if len(groupTeamSellerList) > 0 {
+						tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+						for _, seller := range groupTeamSellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+						}
+						//排个序
+						tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+						groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
+					}
+
+					//groupItem.ChildrenList = groupSellerList
+					//if len(groupSellerList) > 0 {
+					//	list = append(list, item)
+					//}
+
+					//sellerList, err := system.GetGroupSysUserList(group.DepartmentId)
+					//if err != nil {
+					//	br.Msg = "获取销售失败"
+					//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					//	return
+					//}
+					//for _, seller := range sellerList {
+					//	sellerItem := company.DepartmentGroupSellers{
+					//		AdminId: fmt.Sprint(seller.AdminId),
+					//		//AdminName string `description:"系统用户名称"`
+					//		RealName:     seller.RealName,
+					//		Authority:    seller.Authority,
+					//		RoleTypeCode: seller.RoleTypeCode,
+					//	}
+					//	groupSellerList = append(groupSellerList, sellerItem)
+					//}
+					//groupSellerList = sortDepartmentGroupSellers(groupSellerList)
+					groupItem.ChildrenList = groupSellerList
+					if len(groupSellerList) > 0 {
+						departmentGroupSellerList = append(departmentGroupSellerList, groupItem)
+					}
+				}
+
+				//分组为0的销售(直属部门)
+				departmentSellerList, err := system.GetDepartmentGroupSysUserList(department.DepartmentId, 0, roleCodeTypeStr)
+				if err != nil {
+					br.Msg = "获取销售失败"
+					br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					return
+				}
+				if len(departmentSellerList) > 0 {
+					tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+					for _, seller := range departmentSellerList {
+						sellerItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint(seller.AdminId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     seller.RealName,
+							Authority:    seller.Authority,
+							RoleTypeCode: seller.RoleTypeCode,
+						}
+						tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+					}
+					//排个序
+					tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+					departmentGroupSellerList = append(departmentGroupSellerList, tmpDepartmentGroupSellersList...)
+				}
+
+				item.ChildrenList = departmentGroupSellerList
+				if len(departmentGroupSellerList) > 0 {
+					list = append(list, item)
+				}
+			}
+		} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_TEAM || sysUser.Authority == 4 {
+			//销售组长看销售
+			if status == 0 {
+				directorId := sysUser.GroupId
+				fmt.Println("directorId:", directorId)
+				groupList, err := system.GetSysGroupByDirectorId(directorId)
+				if err != nil {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取分组失败,Err:" + err.Error()
+					return
+				}
+				for _, group := range groupList {
+					groupSellerList := make([]company.DepartmentGroupSellers, 0)
+					groupItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint("group_", group.DepartmentId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     group.GroupName,
+						ChildrenList: groupSellerList,
+					}
+					teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
+					if err != nil {
+						br.Msg = "获取小组失败"
+						br.ErrMsg = "获取小组失败,Err:" + err.Error()
+						return
+					}
+					for _, team := range teamList {
+						teamSellerList := make([]company.DepartmentGroupSellers, 0)
+						teamItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint("team_", team.GroupId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     team.GroupName,
+							ChildrenList: teamSellerList,
+						}
+						sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
+						if err != nil {
+							br.Msg = "获取销售失败"
+							br.ErrMsg = "获取销售失败,Err:" + err.Error()
+							return
+						}
+						for _, seller := range sellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							//fmt.Println("seller.RealName:", seller.RealName)
+							teamSellerList = append(teamSellerList, sellerItem)
+						}
+						teamSellerList = sortDepartmentGroupSellers(teamSellerList)
+						teamItem.ChildrenList = teamSellerList
+						if len(teamSellerList) > 0 {
+							groupSellerList = append(groupSellerList, teamItem)
+						}
+					}
+					//分组为0的销售(直属分组)
+					groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
+					if err != nil {
+						br.Msg = "获取销售失败"
+						br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						return
+					}
+					if len(groupTeamSellerList) > 0 {
+						tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+						for _, seller := range groupTeamSellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+						}
+						//排个序
+						tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+						groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
+					}
+
+					groupItem.ChildrenList = groupSellerList
+					if len(groupSellerList) > 0 {
+						list = append(list, groupItem)
+					}
+				}
+			} else {
+				departmentStr := `1,2`
+				departmentList, err := system.GetDepartmentListByIds(departmentStr)
+				if err != nil {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取部门失败,Err:" + err.Error()
+					return
+				}
+				for _, department := range departmentList {
+					departmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
+					item := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint("department_", department.DepartmentId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     department.DepartmentName,
+						ChildrenList: departmentGroupSellerList,
+					}
+
+					groupList, err := system.GetSysGroupByDepartmentId(department.DepartmentId)
+					if err != nil {
+						br.Msg = "获取失败"
+						br.ErrMsg = "获取分组失败,Err:" + err.Error()
+						return
+					}
+					for _, group := range groupList {
+						groupSellerList := make([]company.DepartmentGroupSellers, 0)
+						groupItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint("group_", group.DepartmentId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     group.GroupName,
+							ChildrenList: groupSellerList,
+						}
+						teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
+						if err != nil {
+							br.Msg = "获取小组失败"
+							br.ErrMsg = "获取小组失败,Err:" + err.Error()
+							return
+						}
+						for _, team := range teamList {
+							teamSellerList := make([]company.DepartmentGroupSellers, 0)
+							teamItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint("team_", team.GroupId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     team.GroupName,
+								ChildrenList: teamSellerList,
+							}
+							sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
+							if err != nil {
+								br.Msg = "获取销售失败"
+								br.ErrMsg = "获取销售失败,Err:" + err.Error()
+								return
+							}
+							for _, seller := range sellerList {
+								sellerItem := company.DepartmentGroupSellers{
+									AdminId: fmt.Sprint(seller.AdminId),
+									//AdminName string `description:"系统用户名称"`
+									RealName:     seller.RealName,
+									Authority:    seller.Authority,
+									RoleTypeCode: seller.RoleTypeCode,
+								}
+								//fmt.Println("seller.RealName:", seller.RealName)
+								teamSellerList = append(teamSellerList, sellerItem)
+							}
+							teamSellerList = sortDepartmentGroupSellers(teamSellerList)
+							teamItem.ChildrenList = teamSellerList
+							if len(teamSellerList) > 0 {
+								groupSellerList = append(groupSellerList, teamItem)
+							}
+						}
+						//分组为0的人,不光是销售(直属分组)
+						groupTeamSellerList, err := system.GetGroupSysUserList(group.GroupId)
+						if err != nil {
+							br.Msg = "获取销售失败"
+							br.ErrMsg = "获取销售失败,Err:" + err.Error()
+							return
+						}
+						if len(groupTeamSellerList) > 0 {
+							tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+							for _, seller := range groupTeamSellerList {
+								sellerItem := company.DepartmentGroupSellers{
+									AdminId: fmt.Sprint(seller.AdminId),
+									//AdminName string `description:"系统用户名称"`
+									RealName:     seller.RealName,
+									Authority:    seller.Authority,
+									RoleTypeCode: seller.RoleTypeCode,
+								}
+								tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+							}
+							//排个序
+							tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+							groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
+						}
+
+						//groupItem.ChildrenList = groupSellerList
+						//if len(groupSellerList) > 0 {
+						//	list = append(list, item)
+						//}
+
+						//sellerList, err := system.GetGroupSysUserList(group.DepartmentId)
+						//if err != nil {
+						//	br.Msg = "获取销售失败"
+						//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						//	return
+						//}
+						//for _, seller := range sellerList {
+						//	sellerItem := company.DepartmentGroupSellers{
+						//		AdminId: fmt.Sprint(seller.AdminId),
+						//		//AdminName string `description:"系统用户名称"`
+						//		RealName:     seller.RealName,
+						//		Authority:    seller.Authority,
+						//		RoleTypeCode: seller.RoleTypeCode,
+						//	}
+						//	groupSellerList = append(groupSellerList, sellerItem)
+						//}
+						//groupSellerList = sortDepartmentGroupSellers(groupSellerList)
+						groupItem.ChildrenList = groupSellerList
+						if len(groupSellerList) > 0 {
+							departmentGroupSellerList = append(departmentGroupSellerList, groupItem)
+						}
+					}
+
+					//分组为0的人,不光是销售(直属部门)
+					departmentSellerList, err := system.GetDepartmentGroupSysUserList(department.DepartmentId, 0, "")
+					if err != nil {
+						br.Msg = "获取销售失败"
+						br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						return
+					}
+					if len(departmentSellerList) > 0 {
+						tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+						for _, seller := range departmentSellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+						}
+						//排个序
+						tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+						departmentGroupSellerList = append(departmentGroupSellerList, tmpDepartmentGroupSellersList...)
+					}
+
+					item.ChildrenList = departmentGroupSellerList
+					if len(departmentGroupSellerList) > 0 {
+						list = append(list, item)
+					}
+				}
+			}
+		} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_COMPLIANCE || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FINANCE || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN { //合规或财务或ficc管理员
+			departmentStr := `2,5,7` //合规
+			switch sysUser.RoleTypeCode {
+			case utils.ROLE_TYPE_CODE_FINANCE: //财务
+				departmentStr = `2,5,8`
+			case utils.ROLE_TYPE_CODE_FICC_ADMIN: //ficc管理员
+				departmentStr = utils.GetFiccAdminDepartmentIds()
+			}
+			departmentList, err := system.GetDepartmentListByIds(departmentStr)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取部门失败,Err:" + err.Error()
+				return
+			}
+			for _, department := range departmentList {
+				fmt.Println(department)
+				departmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
+				item := company.DepartmentGroupSellers{
+					AdminId: fmt.Sprint("department_", department.DepartmentId),
+					//AdminName string `description:"系统用户名称"`
+					RealName:     department.DepartmentName,
+					ChildrenList: departmentGroupSellerList,
+				}
+
+				groupList, err := system.GetSysGroupByDepartmentId(department.DepartmentId)
+				if err != nil {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取分组失败,Err:" + err.Error()
+					return
+				}
+				for _, group := range groupList {
+					groupSellerList := make([]company.DepartmentGroupSellers, 0)
+					groupItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint("group_", group.DepartmentId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     group.GroupName,
+						ChildrenList: groupSellerList,
+					}
+					teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
+					if err != nil {
+						br.Msg = "获取小组失败"
+						br.ErrMsg = "获取小组失败,Err:" + err.Error()
+						return
+					}
+					for _, team := range teamList {
+						teamSellerList := make([]company.DepartmentGroupSellers, 0)
+						teamItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint("team_", team.GroupId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     team.GroupName,
+							ChildrenList: teamSellerList,
+						}
+						sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
+						if err != nil {
+							br.Msg = "获取销售失败"
+							br.ErrMsg = "获取销售失败,Err:" + err.Error()
+							return
+						}
+						for _, seller := range sellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							//fmt.Println("seller.RealName:", seller.RealName)
+							teamSellerList = append(teamSellerList, sellerItem)
+						}
+						teamSellerList = sortDepartmentGroupSellers(teamSellerList)
+						teamItem.ChildrenList = teamSellerList
+						if len(teamSellerList) > 0 {
+							groupSellerList = append(groupSellerList, teamItem)
+						}
+					}
+					//分组为0的销售(直属分组)
+					groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
+					if err != nil {
+						br.Msg = "获取销售失败"
+						br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						return
+					}
+					if len(groupTeamSellerList) > 0 {
+						tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+						for _, seller := range groupTeamSellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+						}
+						//排个序
+						tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+						groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
+					}
+
+					//groupItem.ChildrenList = groupSellerList
+					//if len(groupSellerList) > 0 {
+					//	list = append(list, item)
+					//}
+
+					//sellerList, err := system.GetGroupSysUserList(group.DepartmentId)
+					//if err != nil {
+					//	br.Msg = "获取销售失败"
+					//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					//	return
+					//}
+					//for _, seller := range sellerList {
+					//	sellerItem := company.DepartmentGroupSellers{
+					//		AdminId: fmt.Sprint(seller.AdminId),
+					//		//AdminName string `description:"系统用户名称"`
+					//		RealName:     seller.RealName,
+					//		Authority:    seller.Authority,
+					//		RoleTypeCode: seller.RoleTypeCode,
+					//	}
+					//	groupSellerList = append(groupSellerList, sellerItem)
+					//}
+					//groupSellerList = sortDepartmentGroupSellers(groupSellerList)
+					groupItem.ChildrenList = groupSellerList
+					if len(groupSellerList) > 0 {
+						departmentGroupSellerList = append(departmentGroupSellerList, groupItem)
+					}
+				}
+
+				//分组为0的销售(直属部门)
+				departmentSellerList, err := system.GetDepartmentGroupSysUserList(department.DepartmentId, 0, roleCodeTypeStr)
+				if err != nil {
+					br.Msg = "获取销售失败"
+					br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					return
+				}
+				if len(departmentSellerList) > 0 {
+					tmpDepartmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
+					for _, seller := range departmentSellerList {
+						sellerItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint(seller.AdminId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     seller.RealName,
+							Authority:    seller.Authority,
+							RoleTypeCode: seller.RoleTypeCode,
+						}
+						tmpDepartmentGroupSellerList = append(tmpDepartmentGroupSellerList, sellerItem)
+					}
+					//排个序
+					tmpDepartmentGroupSellerList = sortDepartmentGroupSellers(tmpDepartmentGroupSellerList)
+					departmentGroupSellerList = append(departmentGroupSellerList, tmpDepartmentGroupSellerList...)
+				}
+
+				item.ChildrenList = departmentGroupSellerList
+				if len(departmentGroupSellerList) > 0 {
+					list = append(list, item)
+				}
+			}
+		} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN || sysUser.Authority == 1 {
+			//部门管理员看小组、销售
+			departmentId := sysUser.DepartmentId
+			switch sysUser.RoleTypeCode {
+			case utils.ROLE_TYPE_CODE_RAI_ADMIN: //权益管理员
+				departmentId = 5
+			case utils.ROLE_TYPE_CODE_FICC_ADMIN: //ficc管理员
+				departmentId = 2
+			}
+			groupList, err := system.GetSysGroupByDepartmentId(departmentId)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取分组失败,Err:" + err.Error()
+				return
+			}
+			for _, group := range groupList {
+				groupSellerList := make([]company.DepartmentGroupSellers, 0)
+				groupItem := company.DepartmentGroupSellers{
+					AdminId: fmt.Sprint("group_", group.DepartmentId),
+					//AdminName string `description:"系统用户名称"`
+					RealName:     group.GroupName,
+					ChildrenList: groupSellerList,
+				}
+				teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
+				if err != nil {
+					br.Msg = "获取小组失败"
+					br.ErrMsg = "获取小组失败,Err:" + err.Error()
+					return
+				}
+				for _, team := range teamList {
+					teamSellerList := make([]company.DepartmentGroupSellers, 0)
+					teamItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint("team_", team.GroupId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     team.GroupName,
+						ChildrenList: teamSellerList,
+					}
+					sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
+					if err != nil {
+						br.Msg = "获取销售失败"
+						br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						return
+					}
+					for _, seller := range sellerList {
+						sellerItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint(seller.AdminId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     seller.RealName,
+							Authority:    seller.Authority,
+							RoleTypeCode: seller.RoleTypeCode,
+						}
+						//fmt.Println("seller.RealName:", seller.RealName)
+						teamSellerList = append(teamSellerList, sellerItem)
+					}
+					teamSellerList = sortDepartmentGroupSellers(teamSellerList)
+					teamItem.ChildrenList = teamSellerList
+					if len(teamSellerList) > 0 {
+						groupSellerList = append(groupSellerList, teamItem)
+					}
+				}
+				//分组为0的销售(直属分组)
+				groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
+				if err != nil {
+					br.Msg = "获取销售失败"
+					br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					return
+				}
+				if len(groupTeamSellerList) > 0 {
+					tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+					for _, seller := range groupTeamSellerList {
+						sellerItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint(seller.AdminId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     seller.RealName,
+							Authority:    seller.Authority,
+							RoleTypeCode: seller.RoleTypeCode,
+						}
+						tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+					}
+					//排个序
+					tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+					groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
+				}
+
+				//groupItem.ChildrenList = groupSellerList
+				//if len(groupSellerList) > 0 {
+				//	list = append(list, item)
+				//}
+
+				//sellerList, err := system.GetGroupSysUserList(group.DepartmentId)
+				//if err != nil {
+				//	br.Msg = "获取销售失败"
+				//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				//	return
+				//}
+				//for _, seller := range sellerList {
+				//	sellerItem := company.DepartmentGroupSellers{
+				//		AdminId: fmt.Sprint(seller.AdminId),
+				//		//AdminName string `description:"系统用户名称"`
+				//		RealName:     seller.RealName,
+				//		Authority:    seller.Authority,
+				//		RoleTypeCode: seller.RoleTypeCode,
+				//	}
+				//	groupSellerList = append(groupSellerList, sellerItem)
+				//}
+				//groupSellerList = sortDepartmentGroupSellers(groupSellerList)
+				groupItem.ChildrenList = groupSellerList
+				if len(groupSellerList) > 0 {
+					list = append(list, groupItem)
+				}
+			}
+
+			//分组为0的销售(直属部门)
+			departmentSellerList, err := system.GetDepartmentGroupSysUserList(departmentId, 0, roleCodeTypeStr)
+			if err != nil {
+				br.Msg = "获取销售失败"
+				br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				return
+			}
+			if len(departmentSellerList) > 0 {
+				tmpDepartmentGroupSeller := make([]company.DepartmentGroupSellers, 0)
+				for _, seller := range departmentSellerList {
+					sellerItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint(seller.AdminId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     seller.RealName,
+						Authority:    seller.Authority,
+						RoleTypeCode: seller.RoleTypeCode,
+					}
+					tmpDepartmentGroupSeller = append(tmpDepartmentGroupSeller, sellerItem)
+				}
+				tmpDepartmentGroupSeller = sortDepartmentGroupSellers(tmpDepartmentGroupSeller)
+				list = append(list, tmpDepartmentGroupSeller...)
+			}
+		} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP || (sysUser.Authority == 2 && sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_FICC_GROUP) {
+			// 权益组长看小组
+			if status == 0 {
+				sellerList, err := system.GetTeamSysUserList(sysUser.GroupId, enabled)
+				if err != nil {
+					br.Msg = "获取销售失败"
+					br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					return
+				}
+				for _, seller := range sellerList {
+					sellerItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint(seller.AdminId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     seller.RealName,
+						Authority:    seller.Authority,
+						RoleTypeCode: seller.RoleTypeCode,
+					}
+					//fmt.Println("seller.RealName:", seller.RealName)
+					list = append(list, sellerItem)
+				}
+				list = sortDepartmentGroupSellers(list)
+
+				//正常来说没有所有人都应该在某个小组下,要不就是小组名为 无 的小组
+				//分组为0的销售(直属分组)
+				//groupTeamSellerList, err := system.GetGrooupsysUserList(sysUser.GroupId, 0, roleCodeTypeStr)
+				//if err != nil {
+				//	br.Msg = "获取销售失败"
+				//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				//	return
+				//}
+				//if len(groupTeamSellerList) > 0 {
+				//	tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+				//	for _, seller := range groupTeamSellerList {
+				//		sellerItem := company.DepartmentGroupSellers{
+				//			AdminId: fmt.Sprint(seller.AdminId),
+				//			//AdminName string `description:"系统用户名称"`
+				//			RealName:     seller.RealName,
+				//			Authority:    seller.Authority,
+				//			RoleTypeCode: seller.RoleTypeCode,
+				//		}
+				//		tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+				//	}
+				//	//排个序
+				//	tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+				//	list = append(list, tmpDepartmentGroupSellersList...)
+				//}
+				//sellerList, err := system.GetDepartmentGroupSysUserList(sysUser.DepartmentId, sysUser.GroupId, roleCodeTypeStr)
+				//if err != nil {
+				//	br.Msg = "获取销售失败"
+				//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				//	return
+				//}
+				//for _, seller := range sellerList {
+				//	sellerItem := company.DepartmentGroupSellers{
+				//		AdminId: fmt.Sprint(seller.AdminId),
+				//		//AdminName string `description:"系统用户名称"`
+				//		RealName:     seller.RealName,
+				//		Authority:    seller.Authority,
+				//		RoleTypeCode: seller.RoleTypeCode,
+				//	}
+				//	list = append(list, sellerItem)
+				//	list = sortDepartmentGroupSellers(list)
+				//}
+			} else {
+				departmentId := 5
+				groupList, err := system.GetSysGroupByDepartmentId(departmentId)
+				if err != nil {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取分组失败,Err:" + err.Error()
+					return
+				}
+				for _, group := range groupList {
+					groupSellerList := make([]company.DepartmentGroupSellers, 0)
+					groupItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint("group_", group.DepartmentId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     group.GroupName,
+						ChildrenList: groupSellerList,
+					}
+					teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
+					if err != nil {
+						br.Msg = "获取小组失败"
+						br.ErrMsg = "获取小组失败,Err:" + err.Error()
+						return
+					}
+					for _, team := range teamList {
+						teamSellerList := make([]company.DepartmentGroupSellers, 0)
+						teamItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint("team_", team.GroupId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     team.GroupName,
+							ChildrenList: teamSellerList,
+						}
+						sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
+						if err != nil {
+							br.Msg = "获取销售失败"
+							br.ErrMsg = "获取销售失败,Err:" + err.Error()
+							return
+						}
+						for _, seller := range sellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							//fmt.Println("seller.RealName:", seller.RealName)
+							teamSellerList = append(teamSellerList, sellerItem)
+						}
+						teamSellerList = sortDepartmentGroupSellers(teamSellerList)
+						teamItem.ChildrenList = teamSellerList
+						if len(teamSellerList) > 0 {
+							groupSellerList = append(groupSellerList, teamItem)
+						}
+					}
+					//分组为0的销售(直属分组)
+					groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
+					if err != nil {
+						br.Msg = "获取销售失败"
+						br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						return
+					}
+					if len(groupTeamSellerList) > 0 {
+						tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+						for _, seller := range groupTeamSellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+						}
+						//排个序
+						tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+						groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
+					}
+
+					//groupItem.ChildrenList = groupSellerList
+					//if len(groupSellerList) > 0 {
+					//	list = append(list, item)
+					//}
+
+					//sellerList, err := system.GetGroupSysUserList(group.DepartmentId)
+					//if err != nil {
+					//	br.Msg = "获取销售失败"
+					//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					//	return
+					//}
+					//for _, seller := range sellerList {
+					//	sellerItem := company.DepartmentGroupSellers{
+					//		AdminId: fmt.Sprint(seller.AdminId),
+					//		//AdminName string `description:"系统用户名称"`
+					//		RealName:     seller.RealName,
+					//		Authority:    seller.Authority,
+					//		RoleTypeCode: seller.RoleTypeCode,
+					//	}
+					//	groupSellerList = append(groupSellerList, sellerItem)
+					//}
+					//groupSellerList = sortDepartmentGroupSellers(groupSellerList)
+					groupItem.ChildrenList = groupSellerList
+					if len(groupSellerList) > 0 {
+						list = append(list, groupItem)
+					}
+				}
+
+				//分组为0的销售(直属部门)
+				departmentSellerList, err := system.GetDepartmentGroupSysUserList(departmentId, 0, roleCodeTypeStr)
+				if err != nil {
+					br.Msg = "获取销售失败"
+					br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					return
+				}
+				if len(departmentSellerList) > 0 {
+					tmpDepartmentGroupSeller := make([]company.DepartmentGroupSellers, 0)
+					for _, seller := range departmentSellerList {
+						sellerItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint(seller.AdminId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     seller.RealName,
+							Authority:    seller.Authority,
+							RoleTypeCode: seller.RoleTypeCode,
+						}
+						tmpDepartmentGroupSeller = append(tmpDepartmentGroupSeller, sellerItem)
+					}
+					tmpDepartmentGroupSeller = sortDepartmentGroupSellers(tmpDepartmentGroupSeller)
+					list = append(list, tmpDepartmentGroupSeller...)
+				}
+			}
+
+		} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP || sysUser.Authority == 2 {
+			// 销售主管看小组
+			if status == 0 {
+				pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
+				if err != nil {
+					br.Msg = "获取失败"
+					br.ErrMsg = "查询父级id异常" + err.Error()
+					return
+				}
+				var realGroupId int
+				if pid != nil && *pid > 0 {
+					//主管角色放在了三级分组下
+					realGroupId = *pid
+				} else {
+					//主管角色放在了二级分组下
+					realGroupId = sysUser.GroupId
+				}
+				groupList, err := system.GetSysGroupByGroupId(realGroupId)
+				if err != nil {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取分组失败,Err:" + err.Error()
+					return
+				}
+				for _, group := range groupList {
+					groupSellerList := make([]company.DepartmentGroupSellers, 0)
+					//groupItem := company.DepartmentGroupSellers{
+					//	AdminId: fmt.Sprint("group_", group.DepartmentId),
+					//	//AdminName string `description:"系统用户名称"`
+					//	RealName:     group.GroupName,
+					//	ChildrenList: groupSellerList,
+					//}
+					teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
+					if err != nil {
+						br.Msg = "获取小组失败"
+						br.ErrMsg = "获取小组失败,Err:" + err.Error()
+						return
+					}
+					for _, team := range teamList {
+						teamSellerList := make([]company.DepartmentGroupSellers, 0)
+						teamItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint("team_", team.GroupId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     team.GroupName,
+							ChildrenList: teamSellerList,
+						}
+						sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
+						if err != nil {
+							br.Msg = "获取销售失败"
+							br.ErrMsg = "获取销售失败,Err:" + err.Error()
+							return
+						}
+						for _, seller := range sellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							//fmt.Println("seller.RealName:", seller.RealName)
+							teamSellerList = append(teamSellerList, sellerItem)
+						}
+						teamSellerList = sortDepartmentGroupSellers(teamSellerList)
+						teamItem.ChildrenList = teamSellerList
+						if len(teamSellerList) > 0 {
+							groupSellerList = append(groupSellerList, teamItem)
+						}
+					}
+					//分组为0的销售(直属分组)
+					groupTeamSellerList, err := system.GetGrooupsysUserList(realGroupId, roleCodeTypeStr, enabled)
+					if err != nil {
+						br.Msg = "获取销售失败"
+						br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						return
+					}
+					if len(groupTeamSellerList) > 0 {
+						tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+						for _, seller := range groupTeamSellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+						}
+						//排个序
+						tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+						groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
+					}
+					list = groupSellerList
+					//groupItem.ChildrenList = groupSellerList
+					//if len(groupSellerList) > 0 {
+					//	list = append(list, item)
+					//}
+
+					//sellerList, err := system.GetGroupSysUserList(group.DepartmentId)
+					//if err != nil {
+					//	br.Msg = "获取销售失败"
+					//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					//	return
+					//}
+					//for _, seller := range sellerList {
+					//	sellerItem := company.DepartmentGroupSellers{
+					//		AdminId: fmt.Sprint(seller.AdminId),
+					//		//AdminName string `description:"系统用户名称"`
+					//		RealName:     seller.RealName,
+					//		Authority:    seller.Authority,
+					//		RoleTypeCode: seller.RoleTypeCode,
+					//	}
+					//	groupSellerList = append(groupSellerList, sellerItem)
+					//}
+					//groupSellerList = sortDepartmentGroupSellers(groupSellerList)
+
+					//groupItem.ChildrenList = groupSellerList
+					//if len(groupSellerList) > 0 {
+					//	list = append(list, groupItem)
+					//}
+
+				}
+
+				//分组为0的销售(直属二级分组)
+				//departmentSellerList, err := system.GetDepartmentGroupSysUserList(2, realGroupId, roleCodeTypeStr)
+				//if err != nil {
+				//	br.Msg = "获取销售失败"
+				//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				//	return
+				//}
+				//if len(departmentSellerList) > 0 {
+				//	tmpDepartmentGroupSeller := make([]company.DepartmentGroupSellers, 0)
+				//	for _, seller := range departmentSellerList {
+				//		sellerItem := company.DepartmentGroupSellers{
+				//			AdminId: fmt.Sprint(seller.AdminId),
+				//			//AdminName string `description:"系统用户名称"`
+				//			RealName:     seller.RealName,
+				//			Authority:    seller.Authority,
+				//			RoleTypeCode: seller.RoleTypeCode,
+				//		}
+				//		tmpDepartmentGroupSeller = append(tmpDepartmentGroupSeller, sellerItem)
+				//	}
+				//	tmpDepartmentGroupSeller = sortDepartmentGroupSellers(tmpDepartmentGroupSeller)
+				//	list = append(list, tmpDepartmentGroupSeller...)
+				//}
+				//pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
+				//if err != nil {
+				//	br.Msg = "获取失败"
+				//	br.ErrMsg = "查询父级id异常" + err.Error()
+				//	return
+				//}
+				//if pid != nil && *pid > 0 {
+				//	//主管角色放在了三级分组下
+				//	//
+				//
+				//
+				//} else {
+				//	//主管角色放在了二级分组下
+				//
+				//}
+				//ids, err := company.GetGroupIdsByParentId(*pid)
+				//if err != nil {
+				//	br.Msg = "获取失败"
+				//	br.ErrMsg = "查询父级id异常" + err.Error()
+				//	return
+				//}
+				//var idSlice []string
+				//var sid string
+				//for _, id := range ids {
+				//	idSlice = append(idSlice, *id)
+				//}
+				//sid = strings.Join(idSlice, ",")
+				//sellerList, err := system.GetTeamSysUserListByIds(sid)
+				//if err != nil {
+				//	br.Msg = "获取销售失败"
+				//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				//	return
+				//}
+				//for _, seller := range sellerList {
+				//	sellerItem := company.DepartmentGroupSellers{
+				//		AdminId: fmt.Sprint(seller.AdminId),
+				//		//AdminName string `description:"系统用户名称"`
+				//		RealName:     seller.RealName,
+				//		Authority:    seller.Authority,
+				//		RoleTypeCode: seller.RoleTypeCode,
+				//	}
+				//	fmt.Println("seller.RealName:", seller.RealName)
+				//	list = append(list, sellerItem)
+				//}
+				//list = sortDepartmentGroupSellers(list)
+				//
+				////分组为0的销售(直属分组)
+				//groupTeamSellerList, err := system.GetGrooupsysUserList(sysUser.GroupId, roleCodeTypeStr)
+				//if err != nil {
+				//	br.Msg = "获取销售失败"
+				//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				//	return
+				//}
+				//if len(groupTeamSellerList) > 0 {
+				//	tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+				//	for _, seller := range groupTeamSellerList {
+				//		sellerItem := company.DepartmentGroupSellers{
+				//			AdminId: fmt.Sprint(seller.AdminId),
+				//			//AdminName string `description:"系统用户名称"`
+				//			RealName:     seller.RealName,
+				//			Authority:    seller.Authority,
+				//			RoleTypeCode: seller.RoleTypeCode,
+				//		}
+				//		tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+				//	}
+				//	//排个序
+				//	tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+				//	list = append(list, tmpDepartmentGroupSellersList...)
+				//}
+				//sellerList, err := system.GetDepartmentGroupSysUserList(sysUser.DepartmentId, sysUser.GroupId, roleCodeTypeStr)
+				//if err != nil {
+				//	br.Msg = "获取销售失败"
+				//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				//	return
+				//}
+				//for _, seller := range sellerList {
+				//	sellerItem := company.DepartmentGroupSellers{
+				//		AdminId: fmt.Sprint(seller.AdminId),
+				//		//AdminName string `description:"系统用户名称"`
+				//		RealName:     seller.RealName,
+				//		Authority:    seller.Authority,
+				//		RoleTypeCode: seller.RoleTypeCode,
+				//	}
+				//	list = append(list, sellerItem)
+				//	list = sortDepartmentGroupSellers(list)
+				//}
+
+				//正常来说没有所有人都应该在某个小组下,要不就是小组名为 无 的小组
+			} else {
+				//var departmentStr string
+				//if utils.RunMode == "release" {
+				//	departmentStr = `1,2`
+				//} else {
+				//	departmentStr = `1,2`
+				//}
+				departmentStr := `1,2`
+				departmentList, err := system.GetDepartmentListByIds(departmentStr)
+				if err != nil {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取部门失败,Err:" + err.Error()
+					return
+				}
+				for _, department := range departmentList {
+					departmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
+					item := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint("department_", department.DepartmentId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     department.DepartmentName,
+						ChildrenList: departmentGroupSellerList,
+					}
+
+					groupList, err := system.GetSysGroupByDepartmentId(department.DepartmentId)
+					if err != nil {
+						br.Msg = "获取失败"
+						br.ErrMsg = "获取分组失败,Err:" + err.Error()
+						return
+					}
+					for _, group := range groupList {
+						groupSellerList := make([]company.DepartmentGroupSellers, 0)
+						groupItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint("group_", group.DepartmentId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     group.GroupName,
+							ChildrenList: groupSellerList,
+						}
+						teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
+						if err != nil {
+							br.Msg = "获取小组失败"
+							br.ErrMsg = "获取小组失败,Err:" + err.Error()
+							return
+						}
+						for _, team := range teamList {
+							teamSellerList := make([]company.DepartmentGroupSellers, 0)
+							teamItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint("team_", team.GroupId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     team.GroupName,
+								ChildrenList: teamSellerList,
+							}
+							sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
+							if err != nil {
+								br.Msg = "获取销售失败"
+								br.ErrMsg = "获取销售失败,Err:" + err.Error()
+								return
+							}
+							for _, seller := range sellerList {
+								sellerItem := company.DepartmentGroupSellers{
+									AdminId: fmt.Sprint(seller.AdminId),
+									//AdminName string `description:"系统用户名称"`
+									RealName:     seller.RealName,
+									Authority:    seller.Authority,
+									RoleTypeCode: seller.RoleTypeCode,
+								}
+								//fmt.Println("seller.RealName:", seller.RealName)
+								teamSellerList = append(teamSellerList, sellerItem)
+							}
+							teamSellerList = sortDepartmentGroupSellers(teamSellerList)
+							teamItem.ChildrenList = teamSellerList
+							if len(teamSellerList) > 0 {
+								groupSellerList = append(groupSellerList, teamItem)
+							}
+						}
+						//分组为0的人,不光是销售(直属分组)
+						groupTeamSellerList, err := system.GetGroupSysUserList(group.GroupId)
+						if err != nil {
+							br.Msg = "获取销售失败"
+							br.ErrMsg = "获取销售失败,Err:" + err.Error()
+							return
+						}
+						if len(groupTeamSellerList) > 0 {
+							tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+							for _, seller := range groupTeamSellerList {
+								sellerItem := company.DepartmentGroupSellers{
+									AdminId: fmt.Sprint(seller.AdminId),
+									//AdminName string `description:"系统用户名称"`
+									RealName:     seller.RealName,
+									Authority:    seller.Authority,
+									RoleTypeCode: seller.RoleTypeCode,
+								}
+								tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+							}
+							//排个序
+							tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+							groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
+						}
+
+						//groupItem.ChildrenList = groupSellerList
+						//if len(groupSellerList) > 0 {
+						//	list = append(list, item)
+						//}
+
+						//sellerList, err := system.GetGroupSysUserList(group.DepartmentId)
+						//if err != nil {
+						//	br.Msg = "获取销售失败"
+						//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						//	return
+						//}
+						//for _, seller := range sellerList {
+						//	sellerItem := company.DepartmentGroupSellers{
+						//		AdminId: fmt.Sprint(seller.AdminId),
+						//		//AdminName string `description:"系统用户名称"`
+						//		RealName:     seller.RealName,
+						//		Authority:    seller.Authority,
+						//		RoleTypeCode: seller.RoleTypeCode,
+						//	}
+						//	groupSellerList = append(groupSellerList, sellerItem)
+						//}
+						//groupSellerList = sortDepartmentGroupSellers(groupSellerList)
+						groupItem.ChildrenList = groupSellerList
+						if len(groupSellerList) > 0 {
+							departmentGroupSellerList = append(departmentGroupSellerList, groupItem)
+						}
+					}
+
+					//分组为0的人,不光是销售(直属部门)
+					departmentSellerList, err := system.GetDepartmentGroupSysUserList(department.DepartmentId, 0, "")
+					if err != nil {
+						br.Msg = "获取销售失败"
+						br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						return
+					}
+					if len(departmentSellerList) > 0 {
+						tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+						for _, seller := range departmentSellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+						}
+						//排个序
+						tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+						departmentGroupSellerList = append(departmentGroupSellerList, tmpDepartmentGroupSellersList...)
+					}
+
+					item.ChildrenList = departmentGroupSellerList
+					if len(departmentGroupSellerList) > 0 {
+						list = append(list, item)
+					}
+				}
+			}
+		} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER && status == 1 {
+			//var departmentStr string
+			//if utils.RunMode == "release" {
+			//	departmentStr = `1,2`
+			//} else {
+			//	departmentStr = `1,2`
+			//}
+			departmentStr := `1,2`
+			departmentList, err := system.GetDepartmentListByIds(departmentStr)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取部门失败,Err:" + err.Error()
+				return
+			}
+			for _, department := range departmentList {
+				departmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
+				item := company.DepartmentGroupSellers{
+					AdminId: fmt.Sprint("department_", department.DepartmentId),
+					//AdminName string `description:"系统用户名称"`
+					RealName:     department.DepartmentName,
+					ChildrenList: departmentGroupSellerList,
+				}
+
+				groupList, err := system.GetSysGroupByDepartmentId(department.DepartmentId)
+				if err != nil {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取分组失败,Err:" + err.Error()
+					return
+				}
+				for _, group := range groupList {
+					groupSellerList := make([]company.DepartmentGroupSellers, 0)
+					groupItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint("group_", group.DepartmentId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     group.GroupName,
+						ChildrenList: groupSellerList,
+					}
+					teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
+					if err != nil {
+						br.Msg = "获取小组失败"
+						br.ErrMsg = "获取小组失败,Err:" + err.Error()
+						return
+					}
+					for _, team := range teamList {
+						teamSellerList := make([]company.DepartmentGroupSellers, 0)
+						teamItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint("team_", team.GroupId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     team.GroupName,
+							ChildrenList: teamSellerList,
+						}
+						sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
+						if err != nil {
+							br.Msg = "获取销售失败"
+							br.ErrMsg = "获取销售失败,Err:" + err.Error()
+							return
+						}
+						for _, seller := range sellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							//fmt.Println("seller.RealName:", seller.RealName)
+							teamSellerList = append(teamSellerList, sellerItem)
+						}
+						teamSellerList = sortDepartmentGroupSellers(teamSellerList)
+						teamItem.ChildrenList = teamSellerList
+						if len(teamSellerList) > 0 {
+							groupSellerList = append(groupSellerList, teamItem)
+						}
+					}
+					//分组为0的人,不光是销售(直属分组)
+					groupTeamSellerList, err := system.GetGroupSysUserList(group.GroupId)
+					if err != nil {
+						br.Msg = "获取销售失败"
+						br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						return
+					}
+					if len(groupTeamSellerList) > 0 {
+						tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+						for _, seller := range groupTeamSellerList {
+							sellerItem := company.DepartmentGroupSellers{
+								AdminId: fmt.Sprint(seller.AdminId),
+								//AdminName string `description:"系统用户名称"`
+								RealName:     seller.RealName,
+								Authority:    seller.Authority,
+								RoleTypeCode: seller.RoleTypeCode,
+							}
+							tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+						}
+						//排个序
+						tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+						groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
+					}
+
+					//groupItem.ChildrenList = groupSellerList
+					//if len(groupSellerList) > 0 {
+					//	list = append(list, item)
+					//}
+
+					//sellerList, err := system.GetGroupSysUserList(group.DepartmentId)
+					//if err != nil {
+					//	br.Msg = "获取销售失败"
+					//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					//	return
+					//}
+					//for _, seller := range sellerList {
+					//	sellerItem := company.DepartmentGroupSellers{
+					//		AdminId: fmt.Sprint(seller.AdminId),
+					//		//AdminName string `description:"系统用户名称"`
+					//		RealName:     seller.RealName,
+					//		Authority:    seller.Authority,
+					//		RoleTypeCode: seller.RoleTypeCode,
+					//	}
+					//	groupSellerList = append(groupSellerList, sellerItem)
+					//}
+					//groupSellerList = sortDepartmentGroupSellers(groupSellerList)
+					groupItem.ChildrenList = groupSellerList
+					if len(groupSellerList) > 0 {
+						departmentGroupSellerList = append(departmentGroupSellerList, groupItem)
+					}
+				}
+
+				//分组为0的人,不光是销售(直属部门)
+				departmentSellerList, err := system.GetDepartmentGroupSysUserList(department.DepartmentId, 0, "")
+				if err != nil {
+					br.Msg = "获取销售失败"
+					br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					return
+				}
+				if len(departmentSellerList) > 0 {
+					tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+					for _, seller := range departmentSellerList {
+						sellerItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint(seller.AdminId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     seller.RealName,
+							Authority:    seller.Authority,
+							RoleTypeCode: seller.RoleTypeCode,
+						}
+						tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+					}
+					//排个序
+					tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+					departmentGroupSellerList = append(departmentGroupSellerList, tmpDepartmentGroupSellersList...)
+				}
+
+				item.ChildrenList = departmentGroupSellerList
+				if len(departmentGroupSellerList) > 0 {
+					list = append(list, item)
+				}
+			}
+		} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER && status == 1 {
+			// 权益销售可以看到权益销售部的所有人
+			departmentId := 5
+			groupList, err := system.GetSysGroupByDepartmentId(departmentId)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取分组失败,Err:" + err.Error()
+				return
+			}
+			for _, group := range groupList {
+				groupSellerList := make([]company.DepartmentGroupSellers, 0)
+				groupItem := company.DepartmentGroupSellers{
+					AdminId: fmt.Sprint("group_", group.DepartmentId),
+					//AdminName string `description:"系统用户名称"`
+					RealName:     group.GroupName,
+					ChildrenList: groupSellerList,
+				}
+				teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
+				if err != nil {
+					br.Msg = "获取小组失败"
+					br.ErrMsg = "获取小组失败,Err:" + err.Error()
+					return
+				}
+				for _, team := range teamList {
+					teamSellerList := make([]company.DepartmentGroupSellers, 0)
+					teamItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint("team_", team.GroupId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     team.GroupName,
+						ChildrenList: teamSellerList,
+					}
+					sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
+					if err != nil {
+						br.Msg = "获取销售失败"
+						br.ErrMsg = "获取销售失败,Err:" + err.Error()
+						return
+					}
+					for _, seller := range sellerList {
+						sellerItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint(seller.AdminId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     seller.RealName,
+							Authority:    seller.Authority,
+							RoleTypeCode: seller.RoleTypeCode,
+						}
+						//fmt.Println("seller.RealName:", seller.RealName)
+						teamSellerList = append(teamSellerList, sellerItem)
+					}
+					teamSellerList = sortDepartmentGroupSellers(teamSellerList)
+					teamItem.ChildrenList = teamSellerList
+					if len(teamSellerList) > 0 {
+						groupSellerList = append(groupSellerList, teamItem)
+					}
+				}
+				//分组为0的销售(直属分组)
+				groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
+				if err != nil {
+					br.Msg = "获取销售失败"
+					br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					return
+				}
+				if len(groupTeamSellerList) > 0 {
+					tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+					for _, seller := range groupTeamSellerList {
+						sellerItem := company.DepartmentGroupSellers{
+							AdminId: fmt.Sprint(seller.AdminId),
+							//AdminName string `description:"系统用户名称"`
+							RealName:     seller.RealName,
+							Authority:    seller.Authority,
+							RoleTypeCode: seller.RoleTypeCode,
+						}
+						tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+					}
+					//排个序
+					tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+					groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
+				}
+
+				//groupItem.ChildrenList = groupSellerList
+				//if len(groupSellerList) > 0 {
+				//	list = append(list, item)
+				//}
+
+				//sellerList, err := system.GetGroupSysUserList(group.DepartmentId)
+				//if err != nil {
+				//	br.Msg = "获取销售失败"
+				//	br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				//	return
+				//}
+				//for _, seller := range sellerList {
+				//	sellerItem := company.DepartmentGroupSellers{
+				//		AdminId: fmt.Sprint(seller.AdminId),
+				//		//AdminName string `description:"系统用户名称"`
+				//		RealName:     seller.RealName,
+				//		Authority:    seller.Authority,
+				//		RoleTypeCode: seller.RoleTypeCode,
+				//	}
+				//	groupSellerList = append(groupSellerList, sellerItem)
+				//}
+				//groupSellerList = sortDepartmentGroupSellers(groupSellerList)
+				groupItem.ChildrenList = groupSellerList
+				if len(groupSellerList) > 0 {
+					list = append(list, groupItem)
+				}
+			}
+
+			//分组为0的销售(直属部门)
+			departmentSellerList, err := system.GetDepartmentGroupSysUserList(departmentId, 0, roleCodeTypeStr)
+			if err != nil {
+				br.Msg = "获取销售失败"
+				br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				return
+			}
+			if len(departmentSellerList) > 0 {
+				tmpDepartmentGroupSeller := make([]company.DepartmentGroupSellers, 0)
+				for _, seller := range departmentSellerList {
+					sellerItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint(seller.AdminId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     seller.RealName,
+						Authority:    seller.Authority,
+						RoleTypeCode: seller.RoleTypeCode,
+					}
+					tmpDepartmentGroupSeller = append(tmpDepartmentGroupSeller, sellerItem)
+				}
+				tmpDepartmentGroupSeller = sortDepartmentGroupSellers(tmpDepartmentGroupSeller)
+				list = append(list, tmpDepartmentGroupSeller...)
+			}
+		} else {
+			//看自己
+			sellerItem := company.DepartmentGroupSellers{
+				AdminId: fmt.Sprint(sysUser.AdminId),
+				//AdminName string `description:"系统用户名称"`
+				RealName: sysUser.RealName,
+			}
+			list = append(list, sellerItem)
+		}
+	} else {
+		departmentId := sysUser.DepartmentId
+		switch productId {
+		case 1:
+			departmentId = 2
+		case 5:
+			departmentId = 5
+		}
+		//查询整个部门的小组、销售
+		groupList, err := system.GetSysGroupByDepartmentId(departmentId)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取分组失败,Err:" + err.Error()
+			return
+		}
+		for _, group := range groupList {
+			groupSellerList := make([]company.DepartmentGroupSellers, 0)
+			groupItem := company.DepartmentGroupSellers{
+				AdminId: fmt.Sprint("group_", group.DepartmentId),
+				//AdminName string `description:"系统用户名称"`
+				RealName:     group.GroupName,
+				ChildrenList: groupSellerList,
+			}
+			teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
+			if err != nil {
+				br.Msg = "获取小组失败"
+				br.ErrMsg = "获取小组失败,Err:" + err.Error()
+				return
+			}
+			for _, team := range teamList {
+				teamSellerList := make([]company.DepartmentGroupSellers, 0)
+				teamItem := company.DepartmentGroupSellers{
+					AdminId: fmt.Sprint("team_", team.GroupId),
+					//AdminName string `description:"系统用户名称"`
+					RealName:     team.GroupName,
+					ChildrenList: teamSellerList,
+				}
+				sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
+				if err != nil {
+					br.Msg = "获取销售失败"
+					br.ErrMsg = "获取销售失败,Err:" + err.Error()
+					return
+				}
+				for _, seller := range sellerList {
+					sellerItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint(seller.AdminId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     seller.RealName,
+						Authority:    seller.Authority,
+						RoleTypeCode: seller.RoleTypeCode,
+					}
+					//fmt.Println("seller.RealName:", seller.RealName)
+					teamSellerList = append(teamSellerList, sellerItem)
+				}
+				teamSellerList = sortDepartmentGroupSellers(teamSellerList)
+				teamItem.ChildrenList = teamSellerList
+				if len(teamSellerList) > 0 {
+					groupSellerList = append(groupSellerList, teamItem)
+				}
+			}
+			//分组为0的销售(直属分组)
+			groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
+			if err != nil {
+				br.Msg = "获取销售失败"
+				br.ErrMsg = "获取销售失败,Err:" + err.Error()
+				return
+			}
+			if len(groupTeamSellerList) > 0 {
+				tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
+				for _, seller := range groupTeamSellerList {
+					sellerItem := company.DepartmentGroupSellers{
+						AdminId: fmt.Sprint(seller.AdminId),
+						//AdminName string `description:"系统用户名称"`
+						RealName:     seller.RealName,
+						Authority:    seller.Authority,
+						RoleTypeCode: seller.RoleTypeCode,
+					}
+					tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
+				}
+				//排个序
+				tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
+				groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
+			}
+
+			groupItem.ChildrenList = groupSellerList
+			if len(groupSellerList) > 0 {
+				list = append(list, groupItem)
+			}
+		}
+
+		//分组为0的销售(直属部门)
+		departmentSellerList, err := system.GetDepartmentGroupSysUserList(departmentId, 0, roleCodeTypeStr)
+		if err != nil {
+			br.Msg = "获取销售失败"
+			br.ErrMsg = "获取销售失败,Err:" + err.Error()
+			return
+		}
+		if len(departmentSellerList) > 0 {
+			tmpDepartmentGroupSeller := make([]company.DepartmentGroupSellers, 0)
+			for _, seller := range departmentSellerList {
+				sellerItem := company.DepartmentGroupSellers{
+					AdminId: fmt.Sprint(seller.AdminId),
+					//AdminName string `description:"系统用户名称"`
+					RealName:     seller.RealName,
+					Authority:    seller.Authority,
+					RoleTypeCode: seller.RoleTypeCode,
+				}
+				tmpDepartmentGroupSeller = append(tmpDepartmentGroupSeller, sellerItem)
+			}
+			//排个序
+			tmpDepartmentGroupSeller = sortDepartmentGroupSellers(tmpDepartmentGroupSeller)
+			list = append(list, tmpDepartmentGroupSeller...)
+		}
+	}
+
+	//// 海外销售部-目前无权限, 均可见
+	//seaDepartment, e := system.GetSysDepartmentByName("海外销售部")
+	//if e != nil && e.Error() != utils.ErrNoRow() {
+	//	br.Msg = "获取失败"
+	//	br.ErrMsg = "获取海外销售部失败, Err: " + e.Error()
+	//	return
+	//}
+	//if e == nil {
+	//	// 获取部门下的销售人员
+	//	seaSellers, e := system.GetDepartmentGroupSysUserList(seaDepartment.DepartmentId, 0, "")
+	//	if e != nil {
+	//		br.Msg = "获取失败"
+	//		br.ErrMsg = "获取海外销售失败, Err: " + e.Error()
+	//		return
+	//	}
+	//	// 获取分组
+	//	seaGroups, e := system.GetSysGroupListByDepartmentId(seaDepartment.DepartmentId)
+	//	if e != nil {
+	//		br.Msg = "获取失败"
+	//		br.ErrMsg = "获取海外销售部分组失败, Err: " + e.Error()
+	//		return
+	//	}
+	//
+	//	var d company.DepartmentGroupSellers
+	//	d.AdminId = fmt.Sprintf("department_%d", seaDepartment.DepartmentId)
+	//	d.RealName = seaDepartment.DepartmentName
+	//	children := make([]company.DepartmentGroupSellers, 0)
+	//	// 无分组
+	//	if len(seaGroups) == 0 {
+	//		for _, s := range seaSellers {
+	//			children = append(children, company.DepartmentGroupSellers{
+	//				AdminId:      strconv.Itoa(s.AdminId),
+	//				RealName:     s.RealName,
+	//				RoleTypeCode: s.RoleTypeCode,
+	//				Authority:    s.Authority,
+	//			})
+	//		}
+	//	}
+	//	// 有分组
+	//	if len(seaGroups) > 0 {
+	//		// 销售map
+	//		sellerMap := make(map[int][]company.DepartmentGroupSellers)
+	//		for _, s := range seaSellers {
+	//			sellerMap[s.GroupId] = append(sellerMap[s.GroupId], company.DepartmentGroupSellers{
+	//				AdminId:      strconv.Itoa(s.AdminId),
+	//				RealName:     s.RealName,
+	//				RoleTypeCode: s.RoleTypeCode,
+	//				Authority:    s.Authority,
+	//			})
+	//		}
+	//		// 小组map
+	//		childrenMap := make(map[int][]company.DepartmentGroupSellers)
+	//		for _, g := range seaGroups {
+	//			if g.ParentId == 0 {
+	//				continue
+	//			}
+	//			childrenMap[g.ParentId] = append(childrenMap[g.ParentId], company.DepartmentGroupSellers{
+	//				AdminId:      fmt.Sprintf("team_%d", g.GroupId),
+	//				RealName:     g.GroupName,
+	//				ChildrenList: sellerMap[g.GroupId],
+	//			})
+	//		}
+	//		// 大组
+	//		for _, g := range seaGroups {
+	//			if g.ParentId > 0 {
+	//				continue
+	//			}
+	//			c := childrenMap[g.GroupId]
+	//			if len(sellerMap[g.GroupId]) > 0 {
+	//				c = append(c, sellerMap[g.GroupId]...)
+	//			}
+	//			children = append(children, company.DepartmentGroupSellers{
+	//				AdminId:      fmt.Sprintf("group_%d", g.GroupId),
+	//				RealName:     g.GroupName,
+	//				ChildrenList: c,
+	//			})
+	//		}
+	//	}
+	//	d.ChildrenList = children
+	//	list = append(list, d)
+	//}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = company.DepartmentGroupSellersResp{
+		List: list,
+	}
+}

+ 4 - 0
controllers/company_share.go

@@ -768,6 +768,10 @@ func (this *CompanyController) MoveShareSeller() {
 		br.ErrMsg = "修改客户信息失败,Err:" + err.Error()
 		return
 	}
+
+	{
+		services.UpdateCompanyContractSellerMove(req.CompanyId, productId) //益客户移动所属销售之后,更新所关联的销售信息
+	}
 	//新增操作记录
 	//{
 	//	remark := "移动到:" + seller.RealName

+ 62 - 2
controllers/company_user.go

@@ -1107,7 +1107,7 @@ func (this *CompanyUserController) List() {
 		for _, v := range ybViewsList {
 			userYbViewsMap[v.UserId] = v.VisitCount
 		}
-
+		userHaveMoveMap := services.GetWxUserHaveMoveMap(mobilesSlice) // 处理用户是否移动过按钮回显
 		for i := 0; i < lenList; i++ {
 			item := list[i]
 			//企业名称
@@ -1261,6 +1261,10 @@ func (this *CompanyUserController) List() {
 			// 分产品阅读统计
 			list[i].YbProductViewTotal = userYbViewsMap[int(item.UserId)]
 			//list[i].LastViewTimeStr = list[i].RaiLastViewTime.Format(utils.FormatDateTime)
+
+			if item.Mobile != "" {
+				list[i].HaveMoveButton = userHaveMoveMap[item.Mobile]
+			}
 		}
 
 		isUserYanXuanButtonShow, err := services.CheckCompanyUserYanXuanButton(sysUser.RoleTypeCode, sysUser.Mobile)
@@ -1317,6 +1321,7 @@ func (this *CompanyUserController) List() {
 					}
 				}
 			}
+
 			for i := 0; i < lenList; i++ {
 				item := list[i]
 				// 分产品阅读统计
@@ -2740,6 +2745,7 @@ func (this *CompanyController) PotentialUserMove() {
 		OpUserName:             sysUser.RealName,
 		CreateTime:             time.Now(),
 	})
+	go services.AddWxUserMoveLog(wxUser, sysUser, req.CompanyId) // 添加用户移动日志记录
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "移动成功"
@@ -2852,6 +2858,8 @@ func (this *CompanyController) UserMove() {
 		CreateTime:             time.Now(),
 	})
 
+	go services.AddWxUserMoveLog(wxUser, sysUser, req.CompanyId) // 添加用户移动日志记录
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "移动成功"
@@ -3297,7 +3305,7 @@ func (this *CompanyUserController) ViewReportList() {
 			secondCondition += `AND create_time <  ?`
 			secondPars = append(secondPars, lastViewTime)
 
-			_, items, err = obj.GetViewReportList(lastViewTimeT.Year(), secondCondition, secondPars, int(total)-pageSize)
+			_, items, err = obj.GetViewReportList(lastViewTimeT.Year()-1, secondCondition, secondPars, pageSize-int(total))
 			if err != nil {
 				br.Msg = "获取失败"
 				br.Msg = "获取失败,Err:" + err.Error()
@@ -6418,3 +6426,55 @@ func (this *CompanyUserController) ListByReport() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// listMoveLog
+// @Title 联系人移动记录列表
+// @Description 联系人移动记录列表接口
+// @Param   Mobile   query   string  true       "手机号"
+// @Success 200 {object} company.CompanyUserListResp
+// @router /user/listMoveLog [get]
+func (this *CompanyUserController) ListMoveLog() {
+	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
+	}
+	mobile := this.GetString("Mobile")
+	if mobile == "" {
+		br.Msg = "手机号不能为空"
+		return
+	}
+	list, err := company.GetWxUserMoveLogListmByMobile(mobile)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	respList := make([]*company.WxUserMoveLogResp, 0)
+	for _, v := range list {
+		item := new(company.WxUserMoveLogResp)
+		item.UserName = v.RealName
+		item.Mobile = v.Mobile
+		item.Email = v.Email
+		item.CompanyId = v.CompanyId
+		item.CompanyName = v.CompanyName
+		item.CompanyIdMove = v.CompanyIdMove
+		item.CompanyNameMove = v.CompanyNameMove
+		item.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
+		respList = append(respList, item)
+	}
+	resp := &company.WxUserMoveLogListResp{
+		List: respList,
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 1 - 0
controllers/cygx/activity.go

@@ -471,6 +471,7 @@ func (this *ActivityCoAntroller) PreserveAndPublish() {
 			item.IsShowHz = isShowHz
 			item.ChartPermissionIdDeputy = charInfo.ChartPermissionId
 			item.ChartPermissionNameDeputy = charInfo.PermissionName
+			item.IsZoom = req.IsZoom
 			if len(labelList) == 1 {
 				item.IsCanAppointmentMinutes = labelList[0].IsCanAppointmentMinutes
 			} else {

+ 150 - 82
controllers/cygx/activity_meet.go

@@ -1610,6 +1610,7 @@ func (this *ActivityMeetCoAntroller) AttendanceDetail() {
 // @Title 线上活动进门财经关联匹配列表
 // @Description 获取线上活动进门财经关联匹配列表接口
 // @Param   KeyWord   query   string  false       "搜索关键词"
+// @Param   ActivityId   query   int  false       "搜索关键词"
 // @Success 200 {object} cygx.RoadshowDataTitleList
 // @router /activityMeet/matchingList [get]
 func (this *ActivityMeetCoAntroller) MatchingList() {
@@ -1629,7 +1630,19 @@ func (this *ActivityMeetCoAntroller) MatchingList() {
 		br.Msg = "请输入搜索内容"
 		return
 	}
-	list, err := cygx.GetRoadshowDataTitleList(keyWord)
+	activityId, _ := this.GetInt("ActivityId")
+
+	detail, err := cygx.GetAddActivityInfoById(activityId)
+	if err != nil {
+		br.Msg = "活动不存在"
+		br.ErrMsg = "活动ID错误,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	dateTime := detail.ActivityTime
+	dateTime = utils.TimeRemoveHms2(dateTime)
+	startTime := dateTime + " 00:00:00'"
+	endTime := dateTime + " 23:59:59'"
+	list, err := cygx.GetRoadshowDataTitleList(startTime, endTime, keyWord)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取信息失败,Err:" + err.Error()
@@ -1648,6 +1661,21 @@ func (this *ActivityMeetCoAntroller) MatchingList() {
 			list[k].RoadshowTitle = activityName
 		}
 	}
+
+	param := new(cygxService.GetYiDongActivityByApiReq)
+	param.MeetingStatus = "2"
+	param.ConveneStartStr = dateTime
+	param.ConveneEndStr = dateTime
+	actList := cygxService.GetYiDongActivityListByApi(param)
+	for _, v := range actList {
+		if strings.Contains(v.Title, keyWord) {
+			item := new(cygx.RoadshowDataTitle)
+			item.RoadshowTitle = v.Title
+			item.ActivityTime = dateTime
+			list = append(list, item)
+		}
+	}
+
 	resplist.List = list
 	br.Ret = 200
 	br.Success = true
@@ -1703,103 +1731,143 @@ func (this *ActivityMeetCoAntroller) MatchingByHand() {
 	}
 	var condition string
 	dateTime := detail.ActivityTime
-	dateTime = utils.TimeRemoveHms(dateTime)
-	condition += ` AND roadshow_begin_time >= ` + "'" + dateTime + " 00:00:00'"
-	condition += ` AND roadshow_begin_time  <= ` + "'" + dateTime + " 23:59:59'"
-	if len(slice) > 0 {
-		keyWord = slice[0]
-	}
-	if keyWord != "" {
-		list, err := cygx.GetRoadshowDataList(keyWord, condition)
-		if err != nil {
-			br.Msg = "手动归类失败"
-			br.ErrMsg = "获取进门财经数据失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
-			return
-		}
-		var roadshowId string
-		for _, v := range list {
-			if v.RoadshowId != "" {
-				roadshowId = v.RoadshowId
+	dateTime = utils.TimeRemoveHms2(dateTime)
+
+	param := new(cygxService.GetYiDongActivityByApiReq)
+	param.MeetingStatus = "2"
+	param.ConveneStartStr = dateTime
+	param.ConveneEndStr = dateTime
+	actList := cygxService.GetYiDongActivityListByApi(param)
+
+	var ismatch bool // 是否匹配
+
+	//优先匹配易董的活动
+	if len(actList) > 0 {
+		for _, v := range actList {
+			var newActivityName string
+			titleSlice := strings.Split(v.Title, "】")
+
+			for _, vt := range titleSlice {
+				newActivityName = strings.Replace(vt, "-", "", -1)
+				newActivityName = strings.Replace(newActivityName, "-", "", -1)
+				newActivityName = strings.Replace(newActivityName, "—", "", -1)
+				newActivityName = strings.Replace(newActivityName, " ", "", -1)
+				newActivityName = strings.Replace(newActivityName, ":", "", -1)
+			}
+			//如果活动时间一致,而且标题还还包含关键词就建立匹配关系
+			if strings.Contains(detail.ActivityNameTask, newActivityName) && detail.ActivityTime == v.Start {
+				err = cygx.UpdateCygxActivityyidongActivityId(v.ID, activityId)
+				if err != nil {
+					br.Msg = "手动归类失败"
+					br.ErrMsg = "建立易董活动匹配关系失败,UpdateCygxActivityyidongActivityId Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+					return
+				}
+				ismatch = true
+				go cygxService.GetYiDongActivityMeeting(v.ID, activityId)
 				break
 			}
+
+		}
+	}
+
+	if !ismatch {
+		condition += ` AND roadshow_begin_time >= ` + "'" + dateTime + " 00:00:00'"
+		condition += ` AND roadshow_begin_time  <= ` + "'" + dateTime + " 23:59:59'"
+		if len(slice) > 0 {
+			keyWord = slice[0]
 		}
-		needAddAttendanc := make([]*cygx.CygxActivityAttendanceDetail, 0)
-		if len(list) > 0 {
-			err = cygx.UpdateActivityRoadshowTitle(activityId, keyWord, roadshowId)
+		if keyWord != "" {
+			list, err := cygx.GetRoadshowDataList(keyWord, condition)
 			if err != nil {
 				br.Msg = "手动归类失败"
-				br.ErrMsg = "关联匹配类型失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+				br.ErrMsg = "获取进门财经数据失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
 				return
 			}
+			var roadshowId string
 			for _, v := range list {
-				if v.UserPhone != "" {
-					item := new(cygx.CygxActivityAttendanceDetail)
-					item.ActivityId = activityId
-					item.RealName = v.UserName
-					item.Mobile = v.UserPhone
-					item.CompanyName = v.Company
-					//item.SellerName = sellerName
-					item.FirstMeetingTime = v.FirstWatchTime
-					item.LastMeetingTime = v.LastWatchTime
-					item.Duration = utils.GetAttendanceDetailSeconds(v.JoinTime)
-					if v.JoinType == 1 {
-						item.MeetingTypeStr = "网络"
-					} else {
-						item.MeetingTypeStr = "电话"
-					}
-					item.MeetingAuthentication = v.AuthInfo
-					if v.DataType == 1 {
-						item.MeetingStatusStr = "直播"
-					} else {
-						item.MeetingStatusStr = "回放"
-					}
-					item.Position = v.Occupation
-					item.UseridEntity = v.UseridEntity
-					item.CrmCompanyMapStatusId = v.CrmCompanyMapStatusId
-					item.CreateTime = time.Now()
-					mobileStr += "'" + v.UserPhone + "'" + ","
-
-					needAddAttendanc = append(needAddAttendanc, item)
+				if v.RoadshowId != "" {
+					roadshowId = v.RoadshowId
+					break
 				}
 			}
-			mobileStr = strings.TrimRight(mobileStr, ",")
-			if mobileStr == "" {
-				mobileStr = "1"
-			}
-			listUser, err := cygx.GetWxUserOutboundMobile(mobileStr)
-			if err != nil {
-				br.Msg = "手动归类失败!"
-				br.ErrMsg = "获取用户列表失败,Err:" + err.Error()
-				return
-			}
-			for _, v := range listUser {
-				userIdArr = append(userIdArr, v.UserId)
-			}
+			needAddAttendanc := make([]*cygx.CygxActivityAttendanceDetail, 0)
+			if len(list) > 0 {
+				err = cygx.UpdateActivityRoadshowTitle(activityId, keyWord, roadshowId)
+				if err != nil {
+					br.Msg = "手动归类失败"
+					br.ErrMsg = "关联匹配类型失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+					return
+				}
+				for _, v := range list {
+					if v.UserPhone != "" {
+						item := new(cygx.CygxActivityAttendanceDetail)
+						item.ActivityId = activityId
+						item.RealName = v.UserName
+						item.Mobile = v.UserPhone
+						item.CompanyName = v.Company
+						//item.SellerName = sellerName
+						item.FirstMeetingTime = v.FirstWatchTime
+						item.LastMeetingTime = v.LastWatchTime
+						item.Duration = utils.GetAttendanceDetailSeconds(v.JoinTime)
+						if v.JoinType == 1 {
+							item.MeetingTypeStr = "网络"
+						} else {
+							item.MeetingTypeStr = "电话"
+						}
+						item.MeetingAuthentication = v.AuthInfo
+						if v.DataType == 1 {
+							item.MeetingStatusStr = "直播"
+						} else {
+							item.MeetingStatusStr = "回放"
+						}
+						item.Position = v.Occupation
+						item.UseridEntity = v.UseridEntity
+						item.CrmCompanyMapStatusId = v.CrmCompanyMapStatusId
+						item.CreateTime = time.Now()
+						mobileStr += "'" + v.UserPhone + "'" + ","
+
+						needAddAttendanc = append(needAddAttendanc, item)
+					}
+				}
+				mobileStr = strings.TrimRight(mobileStr, ",")
+				if mobileStr == "" {
+					mobileStr = "1"
+				}
+				listUser, err := cygx.GetWxUserOutboundMobile(mobileStr)
+				if err != nil {
+					br.Msg = "手动归类失败!"
+					br.ErrMsg = "获取用户列表失败,Err:" + err.Error()
+					return
+				}
+				for _, v := range listUser {
+					userIdArr = append(userIdArr, v.UserId)
+				}
 
-			for k, v := range needAddAttendanc {
-				for _, v2 := range listUser {
-					if v2.OutboundMobile == v.Mobile {
-						needAddAttendanc[k].CompanyId = v2.CompanyId
-						needAddAttendanc[k].SellerName = v2.SellerName
-						needAddAttendanc[k].CompanyName = v2.CompanyName
-						needAddAttendanc[k].IsMeetingStr = 1
+				for k, v := range needAddAttendanc {
+					for _, v2 := range listUser {
+						if v2.OutboundMobile == v.Mobile {
+							needAddAttendanc[k].CompanyId = v2.CompanyId
+							needAddAttendanc[k].SellerName = v2.SellerName
+							needAddAttendanc[k].CompanyName = v2.CompanyName
+							needAddAttendanc[k].IsMeetingStr = 1
+						}
 					}
 				}
-			}
-			err = cygx.AddAttendancDetail(needAddAttendanc, activityId, mobileStr)
-			if err != nil {
+				err = cygx.AddAttendancDetail(needAddAttendanc, activityId, mobileStr)
+				if err != nil {
+					br.Msg = "手动归类失败"
+					br.ErrMsg = "手动归类失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+					return
+				}
+				go cygxService.AddCygxActivityRestrictSignupByAdmin(activityId)
+				go cygx.AddCygxActivityMeetDetailLogOnline(needAddAttendanc, activityId)
+				go cygxService.ActivityUserLabelLogAdd(activityId, userIdArr)                 //添加用户活动到会标签到Redis
+				go cygxService.AddctivitySignupDetailListByHand(needAddAttendanc, activityId) //手动匹配进门财经信息
+			} else {
 				br.Msg = "手动归类失败"
-				br.ErrMsg = "手动归类失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+				br.ErrMsg = "暂未找到匹配数据!"
 				return
 			}
-			go cygxService.AddCygxActivityRestrictSignupByAdmin(activityId)
-			go cygx.AddCygxActivityMeetDetailLogOnline(needAddAttendanc, activityId)
-			go cygxService.ActivityUserLabelLogAdd(activityId, userIdArr)                 //添加用户活动到会标签到Redis
-			go cygxService.AddctivitySignupDetailListByHand(needAddAttendanc, activityId) //手动匹配进门财经信息
-		} else {
-			br.Msg = "手动归类失败"
-			br.ErrMsg = "暂未找到匹配数据!"
-			return
 		}
 	}
 	//添加操作日志记录

+ 61 - 0
controllers/cygx/industrial_subject.go

@@ -628,3 +628,64 @@ func (this *IndustrialSubjectController) CountDetail() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 通过行业获取关联标的列表
+// @Description 通过行业获取关联标的列表接口
+// @Param   KeyWord   query   string  false       "搜索关键词"
+// @Param   ChartPermissionId   query   int  true       "分类ID"
+// @Success Ret=200  {object} cygx.CygxIndustrialSubjectList
+// @router /industrialAndSubject/search [get]
+func (this *IndustrialSubjectController) IndustrialAndSubjectSearch() {
+	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
+	}
+	var condition string
+	keyWord := this.GetString("KeyWord")
+	chartPermissionId, _ := this.GetInt("ChartPermissionId")
+	if keyWord != "" {
+		condition = ` AND s.subject_name LIKE '%` + keyWord + `%'  `
+	}
+	if chartPermissionId > 0 {
+		condition += ` AND m.chart_permission_id = ` + strconv.Itoa(chartPermissionId)
+	}
+	listSubject, err := cygx.GetIndustrialSubjectListNameByChartId(condition)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	condition = ` AND industry_name LIKE '%` + keyWord + `%'  AND  chart_permission_id = ` + strconv.Itoa(chartPermissionId)
+	listIndustrial, err := cygx.GetIndustrialManagement(condition)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	listResp := make([]*cygx.CygxIndustrialSubjectListRep, 0)
+	for _, v := range listIndustrial {
+		item := new(cygx.CygxIndustrialSubjectListRep)
+		item.IndustryName = v.IndustryName
+		item.IndustrialManagementId = v.IndustrialManagementId
+		item.ShowName = v.IndustryName
+		listResp = append(listResp, item)
+	}
+	for _, v := range listSubject {
+		v.ShowName = v.SubjectName
+		listResp = append(listResp, v)
+	}
+	resp := new(cygx.CygxIndustrialSubjectList)
+	resp.List = listResp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 1 - 0
controllers/cygx/report_article.go

@@ -375,6 +375,7 @@ func (this *ReportArticleController) ReportArticleList() {
 			list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
 		} else {
 			list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
+			list[k].ReportId = v.Id
 		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)

+ 142 - 42
controllers/cygx/report_selection.go

@@ -123,6 +123,12 @@ func (this *ReportSelectionController) PreserveAndPublish() {
 		item.IndustrialSubjectId = v.IndustrialSubjectId
 		item.SubjectName = v.IndustrialSubjectName
 		item.IndustrialManagementId = v.IndustrialManagementId
+		item.IndustrialManagementNames = v.IndustrialManagementName
+		if v.IndustrialManagementNames != "" {
+			item.IndustrialManagementNames = v.IndustrialManagementNames
+		}
+		item.ThirdId = v.ThirdId
+		item.ThirdName = v.ThirdName
 		item.OverviewArticleId = v.OverviewArticleId
 		item.IsNew = v.IsNew
 		item.IsShowOverviewArticle = v.IsShowOverviewArticle
@@ -394,23 +400,37 @@ func (this *ReportSelectionController) Detail() {
 			return
 		}
 		for kIndustrial, vIndustrial := range listSon {
+			var industrialNames string
 			//如果报告精选关联的产业被删除了 则做以下处理
-			//if vIndustrial.IndustrialManagementName == "" {
-			industrialNames, err := cygx.GetindustrialManagementNamesBySubjectName(vIndustrial.IndustrialSubjectName, vIndustrial.ChartPermissionId)
-			if err != nil {
-				br.Msg = "获取失败!"
-				br.ErrMsg = "获取删除删除之后的产业失败,Err:" + err.Error() + vIndustrial.IndustrialSubjectId
-				return
+			if vIndustrial.IndustrialSubjectName == "" {
+				industrialNames = vIndustrial.IndustrialManagementNames
+			} else {
+				industrialNames, err = cygx.GetindustrialManagementNamesBySubjectName(vIndustrial.IndustrialSubjectName, vIndustrial.ChartPermissionId)
+				if err != nil {
+					br.Msg = "获取失败!"
+					br.ErrMsg = "获取删除删除之后的产业失败,Err:" + err.Error() + vIndustrial.IndustrialSubjectId
+					return
+				}
 			}
+
 			if vIndustrial.Label != "" {
 				vIndustrial.CompanyLabel = strings.Split(vIndustrial.Label, "{|}")
 			}
 			listSon[kIndustrial].IndustrialManagementName = industrialNames
+			listSon[kIndustrial].IndustrialManagementNames = industrialNames
 			listSon[kIndustrial].OverviewArticleId = articleStockMap[vIndustrial.IndustrialSubjectName]
 			listSon[kIndustrial].OverviewArticleTitle = mapArticle[listSon[kIndustrial].OverviewArticleId]
 			if periods != "" {
 				listSon[kIndustrial].IsNew = 0
 			}
+
+			if vIndustrial.ThirdName != "" {
+				listSon[kIndustrial].ShowName = vIndustrial.ThirdName
+			} else if vIndustrial.SubjectName == "" {
+				listSon[kIndustrial].ShowName = vIndustrial.IndustrialManagementNames
+			} else {
+				listSon[kIndustrial].ShowName = vIndustrial.SubjectName
+			}
 		}
 		list[k].List = listSon
 		list[k].BodyChartSummary = mapChartLog[v.ChartPermissionName]
@@ -654,6 +674,8 @@ func (this *ReportSelectionController) ListPeriods() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
+
+	condition += `	GROUP BY  periods `
 	list, err := cygx.GetReportSelectionListPeriods(condition, pars, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取失败"
@@ -849,41 +871,40 @@ func (this *ReportSelectionController) GetArticle() {
 		br.ErrMsg = "请登录,SysUser Is Empty"
 		return
 	}
-	industrialSubjectId, _ := this.GetInt("IndustrialSubjectId")
-	if industrialSubjectId < 1 {
-		br.Msg = "请输入标的ID"
-		return
-	}
-	detailSubjecj, err := cygx.GetIndustrialSubjectDetailById(industrialSubjectId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-		return
-	}
 	resp := new(cygx.OverviewArticle)
-	if detailSubjecj != nil {
-		var pars []interface{}
-		conditionArticle := `  AND type_name = '综述报告'  AND  stock LIKE ? `
-		subjectName := "%" + detailSubjecj.SubjectName + "%"
-		pars = append(pars, subjectName)
-		articleList, err := cygx.GetCygxArticleList(conditionArticle, pars, 0, 10)
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "GetCygxArticleList,Err:" + err.Error()
+	industrialSubjectId, _ := this.GetInt("IndustrialSubjectId")
+	if industrialSubjectId > 0 {
+		detailSubjecj, err := cygx.GetIndustrialSubjectDetailById(industrialSubjectId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 			return
 		}
-		//一对一精准匹配
-		for _, v := range articleList {
-			sliceSubjects := strings.Split(v.Stock, "/")
-			if len(sliceSubjects) > 0 {
-				for _, vSubject := range sliceSubjects {
-					sliceKuohao := strings.Split(vSubject, "(")           //过滤括号
-					sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
-					subject := sliceXiahuaxian[0]
-					if subject == detailSubjecj.SubjectName {
-						resp.ArticleId = v.ArticleId
-						resp.Title = v.Title
-						continue
+
+		if detailSubjecj != nil {
+			var pars []interface{}
+			conditionArticle := `  AND type_name = '综述报告'  AND  stock LIKE ? `
+			subjectName := "%" + detailSubjecj.SubjectName + "%"
+			pars = append(pars, subjectName)
+			articleList, err := cygx.GetCygxArticleList(conditionArticle, pars, 0, 10)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "GetCygxArticleList,Err:" + err.Error()
+				return
+			}
+			//一对一精准匹配
+			for _, v := range articleList {
+				sliceSubjects := strings.Split(v.Stock, "/")
+				if len(sliceSubjects) > 0 {
+					for _, vSubject := range sliceSubjects {
+						sliceKuohao := strings.Split(vSubject, "(")           //过滤括号
+						sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
+						subject := sliceXiahuaxian[0]
+						if subject == detailSubjecj.SubjectName {
+							resp.ArticleId = v.ArticleId
+							resp.Title = v.Title
+							continue
+						}
 					}
 				}
 			}
@@ -1009,9 +1030,17 @@ func (this *ReportSelectionController) History() {
 		br.ErrMsg = "GetCygxReportSelectionSubjectHistoryList,Err:" + err.Error()
 		return
 	}
-	mapSubjectHistory := make(map[string]int)
+	mapSubjectHistory := make(map[string]int)    // 标的点击数量
+	mapIndustrialHistory := make(map[string]int) // 产业点击数量
+	mapThirdIdHistory := make(map[int]int)       // 三方产业点击数量
 	for _, v := range listSelectionSubjectHistory {
+		if v.ThirdId > 0 {
+			mapThirdIdHistory[v.ThirdId]++
+		}
 		mapSubjectHistory[v.IndustrialSubjectId]++
+		if v.IndustrialSubjectId == "0" && v.IndustrialManagementId > 0 {
+			mapIndustrialHistory[strconv.Itoa(v.IndustrialManagementId)]++
+		}
 	}
 
 	//排序方式修改
@@ -1021,10 +1050,18 @@ func (this *ReportSelectionController) History() {
 		for _, v2 := range listSelectionLog {
 			if v.ChartPermissionName == v2.PermissionName {
 				item := new(cygx.HistoryReportSelectionLogResp)
-				item.SubjectName = v2.SubjectName
-				item.IndustrialSubjectId = v2.IndustrialSubjectId
+				if v2.ThirdId > 0 {
+					item.SubjectName = v2.ThirdName
+					item.Count = mapThirdIdHistory[v2.ThirdId]
+				} else if (v2.IndustrialSubjectId == "" || v2.IndustrialSubjectId == "0") && v2.IndustrialManagementId != "" {
+					item.SubjectName = v2.IndustrialManagementNames
+					item.Count = mapIndustrialHistory[v2.IndustrialManagementId]
+				} else {
+					item.SubjectName = v2.SubjectName
+					item.IndustrialSubjectId = v2.IndustrialSubjectId
+					item.Count = mapSubjectHistory[v2.IndustrialSubjectId]
+				}
 				item.IsNew = v2.IsNew
-				item.Count = mapSubjectHistory[v2.IndustrialSubjectId]
 				resp.Count += item.Count
 				v.List = append(v.List, item)
 			}
@@ -1076,3 +1113,66 @@ func (this *ReportSelectionController) RarryList() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title   添加三方名称
+// @Description   添加三方名称接口
+// @Param	request	body cygx.AddReportSelectionThirdNameReq true "type json string"
+// @Success Ret=200 {object} cygx.AddReportSelectionThirdNameResp
+// @router /reportSelection/add/third_name [post]
+func (this *ReportSelectionController) AddThirdName() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	AdminUser := this.SysUser
+	if AdminUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	var req cygx.AddReportSelectionThirdNameReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	thirdName := req.ThirdName
+	chartPermissionId := req.ChartPermissionId
+	if thirdName == "" {
+		br.Msg = "名称不能为空"
+		return
+	}
+
+	// 品种信息
+	chartPermission, err := models.GetChartPermissionById(chartPermissionId)
+	if err != nil {
+		br.Msg = "品种信息有误"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+
+	item := new(cygx.CygxReportSelectionThirdName)
+	item.ThirdName = thirdName
+	item.ChartPermissionId = chartPermissionId
+	item.ChartPermissionName = chartPermission.ChartPermissionName
+	item.CreateTime = time.Now()
+
+	newId, err := cygx.AddCygxReportSelectionThirdName(item)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + err.Error()
+		return
+	}
+	resp := new(cygx.AddReportSelectionThirdNameResp)
+	resp.ThirdName = thirdName
+	resp.ThirdId = fmt.Sprint(newId)
+	br.Ret = 200
+	br.Data = resp
+	br.Success = true
+	br.Msg = "操作成功"
+	br.IsAddLog = true
+}

+ 10 - 1
controllers/cygx/user.go

@@ -248,6 +248,7 @@ func (this *UserController) List() {
 	var userIds string
 	var userIdArr []int
 	var companyIds []int
+	var mobilesSlice []string
 	if list != nil {
 		for k, v := range list {
 			if v.RegisterTime != "" {
@@ -286,6 +287,10 @@ func (this *UserController) List() {
 				list[k].CompanyInteractionNum = v.CompanyInteractionNumSeller
 			}
 			companyIds = append(companyIds, v.CompanyId)
+
+			if v.Mobile != "" {
+				mobilesSlice = append(mobilesSlice, v.Mobile)
+			}
 		}
 		userIds = strings.TrimRight(userIds, ",")
 		splitList, err := cygx.GetCygxCompanyUserListSplit(userIds)
@@ -310,6 +315,7 @@ func (this *UserController) List() {
 
 		UserRemindListMap := cygxService.GetCygxUserRemindListMap(userIdArr)
 		mapIsUserMaker := cygxService.GetCompanyProductIsUserMakerByCompanyIds(companyIds) //根据公司ID获取近四周之内有决策人互动的客户
+		userHaveMoveMap := services.GetWxUserHaveMoveMap(mobilesSlice)                     // 处理用户是否移动过按钮回显
 		for k, v := range list {
 			for _, vsplit := range splitList {
 				if vsplit.UserId == v.UserId {
@@ -333,6 +339,9 @@ func (this *UserController) List() {
 			}
 			list[k].IsRemind = UserRemindListMap[int(v.UserId)]
 			list[k].IsUserMaker = mapIsUserMaker[v.CompanyId]
+			if v.Mobile != "" {
+				v.HaveMoveButton = userHaveMoveMap[v.Mobile]
+			}
 		}
 		for k := range list {
 			list[k].InteractionNum = list[k].HistoryNum + list[k].CountNum + list[k].IndustryFllowNum + list[k].DepartmentFollowNum + list[k].KeyWordNum + list[k].OnLineNum + list[k].OfficeNum + list[k].ChartNum + list[k].TripNum + list[k].RoadshowVideoNum + list[k].ActivityVideoNum + list[k].ActivityVoiceNum + list[k].YanxuanspecialNum
@@ -851,7 +860,7 @@ func (this *UserController) TableDetail() {
 	} else if source == 5 {
 
 		if classType == 1 {
-			condition += "  AND a.chart_permission_id  = 31 "
+			condition += "  AND a.chart_permission_id  != 31 "
 		} else {
 			condition += "  AND a.chart_permission_id  = 31 "
 		}

+ 79 - 38
controllers/roadshow/calendar.go

@@ -575,54 +575,73 @@ func (this *CalendarController) Edit() {
 
 	calendarWhereParams["rs_calendar_id"] = req.RsCalendarId
 
-	if req.ActivityType != "" {
-		calendarUpdateParams["activity_type"] = req.ActivityType
-	}
+	//if req.ActivityType != "" {
+	calendarUpdateParams["activity_type"] = req.ActivityType
+	//}
 
-	if req.RoadshowType != "" {
-		calendarUpdateParams["roadshow_type"] = req.RoadshowType
-	}
+	//if req.RoadshowType != "" {
+	calendarUpdateParams["roadshow_type"] = req.RoadshowType
+	//	}
 
-	if req.RoadshowPlatform != "" {
-		calendarUpdateParams["roadshow_platform"] = req.RoadshowPlatform
-	}
+	//if req.RoadshowPlatform != "" {
+	calendarUpdateParams["roadshow_platform"] = req.RoadshowPlatform
+	//}
 
-	if req.CompanyId > 0 {
-		calendarUpdateParams["company_id"] = req.CompanyId
-	}
+	//if req.CompanyId > 0 {
+	calendarUpdateParams["company_id"] = req.CompanyId
+	//}
 
-	if req.CompanyName != "" {
-		calendarUpdateParams["company_name"] = req.CompanyName
-	}
+	//if req.CompanyName != "" {
+	calendarUpdateParams["company_name"] = req.CompanyName
+	//}
 
-	if req.ActivityCategory != "" {
-		calendarUpdateParams["activity_category"] = req.ActivityCategory
-	}
+	//if req.ActivityCategory != "" {
+	calendarUpdateParams["activity_category"] = req.ActivityCategory
+	//	}
 
-	if req.Theme != "" {
-		calendarUpdateParams["theme"] = req.Theme
-	}
+	//if req.Theme != "" {
+	calendarUpdateParams["theme"] = req.Theme
+	//}
 
-	if req.CooperationName != "" {
-		calendarUpdateParams["cooperation_name"] = req.CooperationName
-	}
+	//if req.CooperationName != "" {
+	calendarUpdateParams["cooperation_name"] = req.CooperationName
+	//}
 
-	if req.Province != "" {
-		calendarUpdateParams["province"] = req.Province
-	}
+	//if req.Province != "" {
+	calendarUpdateParams["province"] = req.Province
+	//}
 
-	if req.City != "" {
-		calendarUpdateParams["city"] = req.City
-	}
+	//if req.City != "" {
+	calendarUpdateParams["city"] = req.City
+	//	}
 
-	if req.District != "" {
-		calendarUpdateParams["district"] = req.District
-	}
+	//if req.District != "" {
+	calendarUpdateParams["district"] = req.District
+	//}
 
 	calendarUpdateParams["english_company"] = req.EnglishCompany
 
 	calendarUpdateParams["modify_time"] = time.Now()
 	calendarUpdateParams["title"] = getTitle(req.ActivityType, req.RoadshowType, req.ActivityCategory, req.RoadshowPlatform, req.Province, req.City)
+
+	//如果是权益客户,添加销售跟共享销售的信息
+	roleTypeCode := sysUser.RoleTypeCode
+	//如果是权益销售、权益销售组长、权益管理员 添加的路演信息,做销售与共享销售信息关联查看
+	if req.CompanyId > 0 && req.ActivityType == "路演" && (roleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER ||
+		roleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN) {
+		var productItemRai *company.CompanyProduct
+		productItemRai, err = company.GetCompanyProductByCompanyIdAndProductId(req.CompanyId, utils.COMPANY_PRODUCT_RAI_ID)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "客户信息有误"
+			br.ErrMsg = "获取客户信息失败, Err: " + err.Error()
+			return
+		}
+		if productItemRai != nil {
+			calendarUpdateParams["seller_id"] = productItemRai.SellerId
+			calendarUpdateParams["share_seller_id"] = productItemRai.ShareSellerId
+		}
+	}
+
 	err = roadshow.UpdateRsCalendar(calendarWhereParams, calendarUpdateParams)
 	if err != nil {
 		br.Msg = "保存失败!"
@@ -719,6 +738,7 @@ func (this *CalendarController) Edit() {
 			calendar := roadshow.RsCalendar{
 				RsCalendarId: req.RsCalendarId,
 				SysUserId:    this.SysUser.AdminId,
+				CompanyName:  req.CompanyName,
 				Title:        getTitle(req.ActivityType, req.RoadshowType, req.ActivityCategory, req.RoadshowPlatform, req.Province, req.City),
 			}
 			researcher := *rsCalendarResearcherItem
@@ -728,6 +748,7 @@ func (this *CalendarController) Edit() {
 			researcher.EndTime = v.EndTime
 			researcher.StartWeek = v.StartWeek
 			researcher.EndWeek = v.EndWeek
+			roadshowService.DeleteSHCalendar(req.RsCalendarResearcherId) //删除老的
 			go roadshowService.CalendarToSH(calendar, researcher)
 
 			if req.EditType == 2 {
@@ -1457,6 +1478,16 @@ func (this *CalendarController) Accept() {
 		return
 	}
 
+	rsCalendarResearcherItemList, err := roadshow.GetRsCalendarResearcherListById(req.RsCalendarId)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取数据失败!GetRsCalendarResearcherById:" + err.Error()
+		return
+	}
+	for _, v := range rsCalendarResearcherItemList {
+		go roadshowService.CalendarToSH(*rsCalendar, *v)
+	}
+
 	//模板消息通知
 	{
 		if rsCalendar != nil {
@@ -1775,7 +1806,17 @@ func (this *CalendarController) Delete() {
 			br.ErrMsg = "删除失败!UpdateCalendarResearcher:" + err.Error()
 			return
 		}
+
 	}
+	itemApiLog := new(roadshow.RsCalendarApiLog)
+	itemApiLog.CreateTime = time.Now()
+	itemApiLog.Remark = "CRM手动删除"
+	itemApiLog.Url = sysUser.RealName
+	itemApiLog.Body = ""
+	itemApiLog.Result = ""
+	itemApiLog.RsCalendarResearcherId = req.RsCalendarResearcherId
+	itemApiLog.RsCalendarId = req.RsCalendarId
+	go roadshow.AddRsCalendarApiLog(itemApiLog)
 	//`status` int(11) DEFAULT '0' COMMENT '1:待接受,2:已接受,3:已拒绝,4:已删除,5:已撤回,6:已结束',
 	//待接受、已接受的情况,需要同步删除上海那边的日程
 	for _, rsCalendarResearcherItem := range rsCalendarResearcherItemList {
@@ -2098,11 +2139,11 @@ func (this *CalendarController) MattersUpdate() {
 		updateParams["matter_content"] = req.MatterContent
 	}
 	req.EditReason = strings.TrimSpace(req.EditReason)
-	if req.EditReason == "" {
-		br.Msg = "请填写修改原因"
-		return
-	}
-	updateParams["edit_reason"] = req.EditReason
+	//if req.EditReason == "" {
+	//	br.Msg = "请填写修改原因"
+	//	return
+	//}
+	//updateParams["edit_reason"] = req.EditReason
 
 	startDateTime := req.StartDate + " " + req.StartTime
 	endDateTime := req.EndDate + " " + req.EndTime

+ 312 - 7
controllers/seal/seal_approval.go

@@ -2,14 +2,24 @@ package seal
 
 import (
 	"encoding/json"
+	"errors"
+	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"github.com/tealeg/xlsx"
 	"hongze/hz_crm_api/controllers"
 	"hongze/hz_crm_api/models"
+	"hongze/hz_crm_api/models/company"
+	"hongze/hz_crm_api/models/contract"
+	sealModels "hongze/hz_crm_api/models/seal"
 	"hongze/hz_crm_api/models/seal/request"
 	"hongze/hz_crm_api/models/seal/response"
 	"hongze/hz_crm_api/services/seal"
 	"hongze/hz_crm_api/utils"
+	"os"
+	"path/filepath"
+	"strconv"
 	"strings"
+	"time"
 )
 
 // 用印审批管理
@@ -28,6 +38,8 @@ type SealApprovalController struct {
 // @Param   StartTime   	query   string  false	"提交开始时间"
 // @Param   EndTime   		query   string  false	"提交结束时间"
 // @Param   Keyword   		query   string  false	"搜索关键词(客户名称/社会信用码)"
+// @Param   IsExport   		query   bool  	false   "是否导出excel,默认是false"
+// @Param   AffiliatedCompany   query   string  	false   "归属公司"
 // @Success 200 {object} response.SealApprovalListResp
 // @router /getApprovalPageList [get]
 func (this *SealApprovalController) List() {
@@ -55,7 +67,7 @@ func (this *SealApprovalController) List() {
 		currentIndex = 1
 	}
 	startSize = paging.StartIndex(currentIndex, pageSize)
-
+	isExport, _ := this.GetBool("IsExport", false)
 	// 筛选条件
 	condition := ""
 	joinCondition := " AND a.curr_node_id = d.node_id" // contract_approval和contract_approval_record的join条件
@@ -158,6 +170,19 @@ func (this *SealApprovalController) List() {
 		pars = append(pars, keywords, keywords, keywords)
 	}
 
+	// 归属公司
+	affiliatedCompany := this.GetString("AffiliatedCompany")
+	if affiliatedCompany != "" {
+		condition += ` AND c.affiliated_company = ?`
+		pars = append(pars, affiliatedCompany)
+	}
+
+	//导出excel
+	if isExport {
+		ApprovalListExport(this, condition, joinCondition, pars, br)
+		return
+	}
+
 	// 列表
 	listData, listTotal, err := seal.GetSealApprovalPageList(condition, joinCondition, pars, startSize, pageSize, sysUser)
 	if err != nil {
@@ -176,6 +201,242 @@ func (this *SealApprovalController) List() {
 	}
 }
 
+// ApprovalListExport 审批列表导出
+func ApprovalListExport(this *SealApprovalController, condition, joinCondition string, pars []interface{}, br *models.BaseResponse) {
+	list, err := sealModels.GetSealApprovalList(condition, joinCondition, pars)
+	if err != nil {
+		br.Msg = "审批列表获取失败!"
+		br.ErrMsg = "审批列表获取失败!" + err.Error()
+		return
+	}
+	////超级管理员和权益管理员、权益研究员可以下载所有客户,销售组长能下载本组客户,销售只能下载本人名下客户
+	//resp := new(cygx.CanDownload)
+	//adminInfo, errAdmin := system.GetSysUserById(sysUser.AdminId)
+	//if errAdmin != nil {
+	//	br.Msg = "获取失败"
+	//	br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
+	//	return
+	//}
+	//if adminInfo.Role == "admin" || adminInfo.Role == "researcher" {
+	//	resp.IsCanDownload = true
+	//}
+
+	if len(list) > 0 {
+		// 取出所有列表的关联合同id
+		contractIdSlice := make([]string, 0)
+		contractApprovalIdSlice := make([]string, 0)
+		for i := 0; i < len(list); i++ {
+			contractIdSlice = append(contractIdSlice, strconv.Itoa(list[i].ContractId))
+			contractApprovalIdSlice = append(contractApprovalIdSlice, strconv.Itoa(list[i].ContractApprovalId))
+		}
+
+		// 获取所有关联的合同列表
+		selfContractMap := make(map[int]*contract.ContractList)
+		{
+			if len(contractIdSlice) > 0 {
+				contractIdStr := strings.Join(contractIdSlice, ",")
+				contractList, tempErr := contract.GetContractListByContractIds(contractIdStr)
+				if tempErr != nil {
+					err = errors.New(fmt.Sprint("获取合同失败,Err:"+tempErr.Error(), err))
+					return
+				}
+				for i := 0; i < len(contractList); i++ {
+					selfContractMap[contractList[i].ContractId] = contractList[i]
+				}
+			}
+		}
+
+		selfContractApprovalRecordMap := make(map[int][]*contract.ContractApprovalRecord)
+		{
+			if len(contractApprovalIdSlice) > 0 {
+				contractApprovalIdStr := strings.Join(contractApprovalIdSlice, ",")
+				contractApprovalList, tempErr := contract.GetContractApprovalRecordListByContractApprovalIds(contractApprovalIdStr)
+				if tempErr != nil {
+					err = errors.New(fmt.Sprint("获取合同审批记录失败,Err:"+tempErr.Error(), err))
+					return
+				}
+				for i := 0; i < len(contractApprovalList); i++ {
+					selfContractApprovalRecordMap[contractApprovalList[i].ContractApprovalId] = append(selfContractApprovalRecordMap[contractApprovalList[i].ContractApprovalId], contractApprovalList[i])
+				}
+			}
+		}
+
+		for i, v := range list {
+			// 合同编码
+			if selfContract, has := selfContractMap[v.ContractId]; has {
+				list[i].ContractCode = selfContract.ContractCode
+			}
+
+			// 审批人和抄送人
+			if recordList, ok := selfContractApprovalRecordMap[v.ContractApprovalId]; ok {
+				keySort := make([]int, 0)
+				flowNodeMap := make(map[int][]contract.ContractApprovalRecord, 0)
+				for _, approvalRecord := range recordList {
+					if tmpFlowNodeList, ok := flowNodeMap[approvalRecord.NodeId]; ok {
+						flowNodeMap[approvalRecord.NodeId] = append(tmpFlowNodeList, *approvalRecord)
+					} else {
+						tmpFlowNodeList := make([]contract.ContractApprovalRecord, 1)
+						tmpFlowNodeList[0] = *approvalRecord
+						flowNodeMap[approvalRecord.NodeId] = tmpFlowNodeList
+
+						keySort = append(keySort, approvalRecord.NodeId)
+					}
+				}
+				approversList := make([][]string, 0)
+				ccList := make([][]string, 0)
+				for _, key := range keySort {
+					approver := make([]string, 0)
+					cc := make([]string, 0)
+					if node, ok := flowNodeMap[key]; ok {
+						for _, vv := range node {
+							if vv.NodeType == "check" {
+								approver = append(approver, vv.ApproveUserName)
+							} else if vv.NodeType == "cc" {
+								cc = append(cc, vv.ApproveUserName)
+							}
+						}
+						if len(approver) > 0 {
+							approversList = append(approversList, approver)
+						}
+						if len(cc) > 0 {
+							ccList = append(ccList, cc)
+						}
+					}
+				}
+				if len(approversList) > 0 {
+					list[i].FirstLevelApprovers = strings.Join(approversList[0], ",")
+				}
+				if len(ccList) > 0 {
+					list[i].FirstLevelCC = strings.Join(ccList[0], ",")
+				}
+				if len(approversList) > 1 {
+					list[i].SecondLevelApprovers = strings.Join(approversList[1], ",")
+				}
+				if len(ccList) > 1 {
+					list[i].SecondLevelCC = strings.Join(ccList[1], ",")
+				}
+				if len(approversList) > 2 {
+					list[i].ThirdLevelApprovers = strings.Join(approversList[2], ",")
+				}
+				if len(ccList) > 2 {
+					list[i].ThirdLevelCC = strings.Join(ccList[2], ",")
+				}
+			}
+		}
+	}
+	//创建excel
+	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
+
+	sheetName := "审批列表"
+	sheet, err := xlsxFile.AddSheet(sheetName)
+	if err != nil {
+		br.Msg = "新增Sheet失败"
+		br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
+		return
+	}
+	//标头
+	rowTitle := sheet.AddRow()
+	cellA := rowTitle.AddCell()
+	cellA.Value = "归属公司"
+	cellB := rowTitle.AddCell()
+	cellB.Value = "客户名称"
+	cellC := rowTitle.AddCell()
+	cellC.Value = "社会信用码"
+	cellD := rowTitle.AddCell()
+	cellD.Value = "用印用途"
+	cellE := rowTitle.AddCell()
+	cellE.Value = "合同编号"
+	cellF := rowTitle.AddCell()
+	cellF.Value = "合同类型"
+	cellG := rowTitle.AddCell()
+	cellG.Value = "加盖印章"
+	cellH := rowTitle.AddCell()
+	cellH.Value = "所属销售"
+	cellI := rowTitle.AddCell()
+	cellI.Value = "提交时间"
+	cellJ := rowTitle.AddCell()
+	cellJ.Value = "用印状态"
+	cellK := rowTitle.AddCell()
+	cellK.Value = "一级审批人"
+	cellL := rowTitle.AddCell()
+	cellL.Value = "一级抄送人"
+	cellM := rowTitle.AddCell()
+	cellM.Value = "二级审批人"
+	cellN := rowTitle.AddCell()
+	cellN.Value = "二级抄送人"
+	cellO := rowTitle.AddCell()
+	cellO.Value = "三级审批人"
+	cellP := rowTitle.AddCell()
+	cellP.Value = "三级抄送人"
+
+	for _, v := range list {
+		row := sheet.AddRow()
+		cellA := row.AddCell()
+		cellA.Value = v.AffiliatedCompany
+		cellB := row.AddCell()
+		cellB.Value = v.CompanyName
+		cellC := row.AddCell()
+		cellC.Value = v.CreditCode
+		cellD := row.AddCell()
+		cellD.Value = v.Use
+		cellE := row.AddCell()
+		cellE.Value = v.ContractCode
+		cellF := row.AddCell()
+		cellF.Value = v.ContractType
+		cellG := row.AddCell()
+		cellG.Value = v.SealType
+		cellH := row.AddCell()
+		cellH.Value = v.ApplyUserName
+		cellI := row.AddCell()
+		cellI.Value = v.CreateTime.Format(utils.FormatDateTime)
+		cellJ := row.AddCell()
+		cellJ.Value = v.Status
+		cellK := row.AddCell()
+		cellK.Value = v.FirstLevelApprovers
+		cellL := row.AddCell()
+		cellL.Value = v.FirstLevelCC
+		cellM := row.AddCell()
+		cellM.Value = v.SecondLevelApprovers
+		cellN := row.AddCell()
+		cellN.Value = v.SecondLevelCC
+		cellO := row.AddCell()
+		cellO.Value = v.ThirdLevelApprovers
+		cellP := row.AddCell()
+		cellP.Value = v.ThirdLevelCC
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		br.Msg = "保存文件失败"
+		br.ErrMsg = "保存文件失败"
+		return
+	}
+	downloadFileName := "用印审批列表" + time.Now().Format("2006.01.02")+ ".xlsx"
+	this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
+	defer func() {
+		os.Remove(downLoadnFilePath)
+	}()
+	br.Success = true
+	br.Ret = 200
+	br.IsAddLog = true
+}
+
 // 用印申请
 // @Title 用印申请
 // @Description 用印申请
@@ -204,12 +465,13 @@ func (this *SealApprovalController) Apply() {
 		return
 	}
 	reqVerify := utils.Rules{
-		"Use":         {utils.NotEmpty()},
-		"CompanyName": {utils.NotEmpty()},
-		"CreditCode":  {utils.NotEmpty()},
-		"ServiceType": {utils.NotEmpty()},
-		"SealType":    {utils.NotEmpty()},
-		"FileUrls":    {utils.NotEmpty()},
+		"Use":               {utils.NotEmpty()},
+		"CompanyName":       {utils.NotEmpty()},
+		"CreditCode":        {utils.NotEmpty()},
+		"ServiceType":       {utils.NotEmpty()},
+		"SealType":          {utils.NotEmpty()},
+		"FileUrls":          {utils.NotEmpty()},
+		"AffiliatedCompany": {utils.NotEmpty()},
 	}
 
 	err = utils.Verify(req, reqVerify, utils.LANG_CN)
@@ -294,6 +556,11 @@ func (this *SealApprovalController) Edit() {
 		br.ErrMsg = "合同附件不能为空"
 		return
 	}
+	if req.AffiliatedCompany == "" {
+		br.Msg = "归属公司不能为空"
+		br.ErrMsg = "归属公司不能为空"
+		return
+	}
 
 	// 编辑用印
 	err = seal.EditApply(this.SysUser, req)
@@ -370,6 +637,11 @@ func (this *SealApprovalController) VerifierEdit() {
 		br.ErrMsg = "合同附件不能为空"
 		return
 	}
+	if req.AffiliatedCompany == "" {
+		br.Msg = "归属公司不能为空"
+		br.ErrMsg = "归属公司不能为空"
+		return
+	}
 
 	// 审批者编辑
 	err = seal.VerifierEditApply(this.SysUser, req)
@@ -693,3 +965,36 @@ func (this *SealApprovalController) OperationList() {
 		List: list,
 	}
 }
+
+// 关联公司列表
+// @Title 关联公司列表
+// @Description 关联公司列表
+// @Success 200 {object} response.SealApprovalListResp
+// @router /getAffiliatedCompany [get]
+func (this *SealApprovalController) AffiliatedCompanyList() {
+	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
+	}
+	crmConfig, err := company.GetConfigDetailByCode("affiliated_company")
+	if err != nil {
+		br.Msg = "获取配置失败"
+		br.ErrMsg = "获取配置失败"
+		br.IsSendEmail = false
+		return
+	}
+	list := strings.Split(crmConfig.ConfigValue, ",")
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = list
+}

+ 692 - 39
controllers/statistic_company_merge.go

@@ -7,6 +7,7 @@ import (
 	"hongze/hz_crm_api/models"
 	"hongze/hz_crm_api/models/company"
 	"hongze/hz_crm_api/models/response"
+	"hongze/hz_crm_api/models/system"
 	"hongze/hz_crm_api/services"
 	cygxService "hongze/hz_crm_api/services/cygx"
 	"os"
@@ -40,7 +41,7 @@ type StatisticCompanyMergerController struct {
 // @Param   DataType   query   string  false       "报表类型,枚举值:`新增试用`,`新签客户`,`续约客户`,`未续约客户`"
 // @Param   TryOutType   query   string  false       " '试用', '非试用' 非试用即为冻结/流失"
 // @Param   IsExport   query   bool  false       "是否导出excel,默认是false"
-// @Param   IsConfirm   query   int  false       "是否确认续约: -1-默认全部; 0-待确认; 1-已确认"
+// @Param   IsConfirm   query   int  false       "是否确认续约: -1-默认全部; 0-待确认; 1-已确认 ;2-到期合同"
 // @Param   CompanyAscribeId   query   int  false       "归因ID"
 // @Param   PackageDifference   query   string  false       "和上一份合同的区别,枚举值:`增加套餐`,`减少套餐`,`维持套餐`"
 // @Success 200 {object} response.IncrementalCompanyListResp
@@ -108,15 +109,21 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 	var pars []interface{}
 
 	//条件
-	if adminId != "" {
-		condition += ` AND c.seller_id in  (` + adminId + `) `
-		//pars = append(pars, adminId)
-	} else {
-
-		//根据当前角色来获取查询条件
-		condition, pars = getQueryParams(condition, pars, sysUser, "c.")
-
-	}
+	//if adminId != "" {
+	//	//condition += ` AND a.seller_id_init in  (` + adminId + `) `
+	//	//condition += ` AND c.seller_id in  (` + adminId + `) `
+	//	//pars = append(pars, adminId)
+	//} else {
+	//
+	//	//if dataType == "未续约客户" {
+	//	//	//根据当前角色来获取查询条件
+	//	//	condition, pars = getQueryParams(condition, pars, sysUser, "c.")
+	//	//} else {
+	//	//	//根据当前角色来获取查询条件
+	//	//	condition, pars = getQueryParamsInit(condition, pars, sysUser, "c.")
+	//	//}
+	//
+	//}
 	if regionType != "" {
 		condition += ` AND b.region_type = ? `
 		pars = append(pars, regionType)
@@ -160,10 +167,14 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 	if isConfirm != -1 {
 		if isConfirm == 0 {
 			conditionAscribRai += ` AND  a.company_contract_id NOT IN (` + utils.GetOrmInReplace(len(noRenewedcompanyContractIds)) + `)  ` // 待确认
-		} else {
+			parsAscribeRai = append(parsAscribeRai, noRenewedcompanyContractIds)
+		} else if isConfirm == 1 {
 			conditionAscribRai += ` AND  a.company_contract_id IN (` + utils.GetOrmInReplace(len(noRenewedcompanyContractIds)) + `)    ` // 已确认
+			parsAscribeRai = append(parsAscribeRai, noRenewedcompanyContractIds)
+		} else if isConfirm == 2 {
+			conditionAscribRai += ` AND  a.start_date  < ? ` // 已确认
+			parsAscribeRai = append(parsAscribeRai, time.Now().Format(utils.FormatDate))
 		}
-		parsAscribeRai = append(parsAscribeRai, noRenewedcompanyContractIds)
 	}
 	//归因ID CRM 13.9
 	if companyAscribeId > 0 {
@@ -189,7 +200,7 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 		parsAscribeRai = append(parsAscribeRai, noRenewedcompanyContractIds)
 	}
 
-	condition += ` AND c.product_id = ?   AND  a.status = 1 `
+	condition += ` AND c.product_id = ?   `
 	pars = append(pars, 2)
 
 	var list []*models.IncrementalList
@@ -201,14 +212,66 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 	var dataTotal, trialTotal, renewalCompanyTotal int
 	var notRenewalTryOut, notRenewalNotTryOut int
 
+	//试用客户数
+	{
+		condition1 := condition
+		pars1 := pars
+		//销售筛选条件
+		if adminId != "" {
+			condition1 += ` AND c.seller_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 = '试用' `
+		pars1 = append(pars1, startDate, endDate)
+
+		total, err := models.GetIncrementalCompanyCountByOperationRecord(condition1, pars1)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		trialTotal = total
+
+		if dataType == "新增试用" {
+			//列表数据数量
+			total, err := models.GetIncrementalCompanyProductCountByOperationRecord(condition1, pars1)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取失败,Err:" + err.Error()
+				return
+			}
+
+			//列表页数据
+			tmpList, err := models.GetIncrementalCompanyListByOperationRecord(condition1, pars1, startSize, pageSize)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取失败,Err:" + err.Error()
+				return
+			}
+			for _, v := range tmpList {
+				v.SellerName = v.SellerNameInit
+			}
+			list = tmpList
+			dataTotal = total
+		}
+	}
+
 	//新签客户数
 	{
 		condition1 := condition
 		pars1 := pars
-		condition1 += ` AND a.start_date >= ? AND a.start_date <= ?  `
+		//销售筛选条件
+		if adminId != "" {
+			condition1 += ` AND a.seller_id_init in  (` + adminId + `) `
+		} else {
+			condition1, pars1 = getQueryParamsInit(condition1, pars1, sysUser, "c.")
+		}
+		condition1 += ` AND  a.status = 1  AND a.start_date >= ?  AND a.start_date <= ?  `
 		pars1 = append(pars1, startDate, endDate)
-		condition1 += ` AND a.rai_contract_type = ? `
+		condition1 += `  AND a.rai_contract_type = ? `
 		pars1 = append(pars1, "新签合同")
+
 		newCompanyTotal, err = company.GetIncrementalNewCompanyProductMergeCount(condition1, pars1)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取失败"
@@ -241,10 +304,16 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 	{
 		condition1 := condition
 		pars1 := pars
-		condition1 += ` AND a.start_date >= ? AND a.start_date <= ? `
+		condition1 += ` AND  a.status = 1 AND a.start_date >= ? AND a.start_date <= ? `
 		pars1 = append(pars1, startDate, endDate)
 		condition1 += ` AND a.rai_contract_type = ? `
 		pars1 = append(pars1, "续约合同")
+		//销售筛选条件
+		if adminId != "" {
+			condition1 += ` AND a.seller_id_init in  (` + adminId + `) `
+		} else {
+			condition1, pars1 = getQueryParamsInit(condition1, pars1, sysUser, "c.")
+		}
 		////额外条件(续约合同的起始日期包含在所选时间段内且不包含在新签合同存续期内的客户)
 		//pars1 = append(pars1, endDate)
 
@@ -288,12 +357,22 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 		condition1 := condition
 		pars1 := pars
 
-		condition1 += ` AND a.end_date >= ? AND a.end_date  <= ? `
+		condition1 += condition
+		pars1 = append(pars1, pars)
+
+		condition1 += `  AND a.not_renewal_hide = 0  AND a.status = 1 AND a.start_date >= '2020-01-01' AND  a.end_date >= ? AND a.end_date  <= ? `
 		pars1 = append(pars1, startDate, endDate)
 		//condition1 += ` AND a.operation = ? `
 		//pars1 = append(pars1, "try_out")
 		condition1 += ` AND c.status not in ("永续","正式","关闭")  `
 
+		//销售筛选条件
+		if adminId != "" {
+			condition1 += ` AND c.seller_id_last in  (` + adminId + `) `
+		} else {
+			condition1, pars1 = getQueryParamsLast(condition1, pars1, sysUser, "c.")
+		}
+
 		//未续约已确认数量
 		notRenewalCondition := condition1
 		notRenewalPars := pars1
@@ -306,7 +385,6 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 			return
 		}
 		notRenewalCompanyTotal = total
-
 		//未续约待确认数量
 		notRenewalToBeCondition := condition1
 		notRenewalToBePars := pars1
@@ -517,17 +595,23 @@ func MergeCompanyListListExport(this *StatisticCompanyMergerController, dataType
 	cellName.SetStyle(style)
 	cellName.SetValue("客户名称")
 
-	cellProName := titleRow.AddCell()
-	cellProName.SetStyle(style)
-	cellProName.SetValue("客户类型")
+	//cellProName := titleRow.AddCell()
+	//cellProName.SetStyle(style)
+	//cellProName.SetValue("客户类型")
 
 	cellSellerName := titleRow.AddCell()
 	cellSellerName.SetStyle(style)
 	cellSellerName.SetValue("所属销售")
 
-	cellMoney := titleRow.AddCell()
-	cellMoney.SetStyle(style)
-	cellMoney.SetValue("合同金额")
+	if dataType != "新增试用" {
+		cellShareSeller := titleRow.AddCell()
+		cellShareSeller.SetStyle(style)
+		cellShareSeller.SetValue("服务销售")
+
+		cellMoney := titleRow.AddCell()
+		cellMoney.SetStyle(style)
+		cellMoney.SetValue("合同金额")
+	}
 
 	cellTime := titleRow.AddCell()
 	cellTime.SetStyle(style)
@@ -535,11 +619,11 @@ func MergeCompanyListListExport(this *StatisticCompanyMergerController, dataType
 	case "新增试用":
 		cellTime.SetValue("新增时间")
 	case "新签客户":
-		cellTime.SetValue("签约时间")
+		cellTime.SetValue("合同期限")
 	case "续约客户":
-		cellTime.SetValue("续约时间")
+		cellTime.SetValue("合同期限")
 	case "未续约客户":
-		cellTime.SetValue("最近合同到期时间")
+		cellTime.SetValue("合同期限")
 
 		cellAscribeContent := titleRow.AddCell()
 		cellAscribeContent.SetStyle(style)
@@ -549,9 +633,13 @@ func MergeCompanyListListExport(this *StatisticCompanyMergerController, dataType
 		cellContent.SetStyle(style)
 		cellContent.SetValue("详细原因")
 	}
-	cellPermissionName := titleRow.AddCell()
-	cellPermissionName.SetStyle(style)
-	cellPermissionName.SetValue("签约套餐")
+
+	if dataType != "新增试用" {
+		cellPermissionName := titleRow.AddCell()
+		cellPermissionName.SetStyle(style)
+		cellPermissionName.SetValue("签约套餐")
+	}
+
 	for _, v := range resp.List {
 		dataRow := sheel.AddRow()
 		dataRow.SetHeight(20)
@@ -560,18 +648,26 @@ func MergeCompanyListListExport(this *StatisticCompanyMergerController, dataType
 		cellDataName.SetStyle(style)
 		cellDataName.SetValue(v.CompanyName)
 
-		cellDataProName := dataRow.AddCell()
-		cellDataProName.SetStyle(style)
-		cellDataProName.SetValue(v.ProductName)
+		//cellDataProName := dataRow.AddCell()
+		//cellDataProName.SetStyle(style)
+		//cellDataProName.SetValue(v.ProductName)
 
 		cellDataSellerName := dataRow.AddCell()
 		cellDataSellerName.SetStyle(style)
 		cellDataSellerName.SetValue(v.SellerName)
 
+		if dataType != "新增试用" {
+			cellDataShareSeller := dataRow.AddCell()
+			cellDataShareSeller.SetStyle(style)
+			cellDataShareSeller.SetValue(v.ShareSeller)
+
+			cellDataMoney := dataRow.AddCell()
+			cellDataMoney.SetStyle(style)
+			cellDataMoney.SetValue(v.Money)
+		}
+
 		//if dataType == "新签客户" || dataType == "续约客户" {
-		cellDataMoney := dataRow.AddCell()
-		cellDataMoney.SetStyle(style)
-		cellDataMoney.SetValue(v.Money)
+
 		//}
 
 		cellDataTime := dataRow.AddCell()
@@ -580,11 +676,11 @@ func MergeCompanyListListExport(this *StatisticCompanyMergerController, dataType
 		case "新增试用":
 			cellDataTime.SetValue(v.CreateTime)
 		case "新签客户":
-			cellDataTime.SetValue(v.StartDate)
+			cellDataTime.SetValue(fmt.Sprint(v.StartDate, " ~  ", v.EndDate))
 		case "续约客户":
-			cellDataTime.SetValue(v.StartDate)
+			cellDataTime.SetValue(fmt.Sprint(v.StartDate, " ~  ", v.EndDate))
 		case "未续约客户":
-			cellDataTime.SetValue(v.EndDate)
+			cellDataTime.SetValue(fmt.Sprint(v.StartDate, " ~  ", v.EndDate))
 
 			cellAscribeContent := dataRow.AddCell()
 			cellAscribeContent.SetStyle(style)
@@ -1804,6 +1900,395 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListV2()
 	br.Data = resp
 }
 
+// @Title 权益客户未续约率下载
+// @Description 权益客户未续约率下载接口
+// @Param   AdminId   query   string  true       "销售id,多个用英文逗号隔开,空字符串为全部"
+// @Param   StartDate   query   string  false       "开始日期"
+// @Param   EndDate   query   string  false       "结束日期"
+// @Param   ExportType   query   int	  true	       "下载类型 1:下载当前销售的合同明细数据;2:下载所有销售未续约数据列表"
+// @Success 200 {object} response.IncrementalCompanyListResp
+// @router /merge_company/company_contract_percentage/list_export [get]
+func (this *StatisticCompanyMergerController) CompanyContractPercentageListExport() {
+	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
+	}
+
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	exportType, _ := this.GetInt("ExportType")
+	adminId := this.GetString("AdminId")
+	contractDataType := this.GetString("ContractDataType")
+	startDate := this.GetString("StartDate")
+	endDate := this.GetString("EndDate")
+	//initendDate := this.GetString("EndDate")
+	if startDate == "" || endDate == "" {
+		br.Msg = "开始时间或结束时间不能为空"
+		return
+	}
+
+	//判断结束时间是否晚于当前时间,如果晚于当前时间,那么就把当前时间作为截止时间。
+	endDateTime, _ := time.Parse(utils.FormatDate, endDate)
+	if endDateTime.After(time.Now()) {
+		endDate = time.Now().Format(utils.FormatDate)
+	}
+	//fmt.Println("endDate", endDate)
+	if contractDataType == "" {
+		contractDataType = "续约合同"
+	}
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = 10000
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+
+	if exportType == 1 {
+		//条件
+		if adminId != "" {
+			condition += ` AND a.seller_id_init in  (` + adminId + `) `
+		}
+	}
+
+	//权益有效合同
+	condition += ` AND c.product_id = 2   AND  a.status = 1 `
+	condition += ` AND c.status not in ("永续","正式","关闭")  `
+	//var list []*models.IncrementalList
+
+	condition1 := condition
+	pars1 := pars
+	condition1 += ` AND a.end_date >= ? AND a.end_date <= ? `
+	pars1 = append(pars1, startDate, endDate)
+	condition1 += ` AND  a.company_ascribe_id  > 0 AND  a.company_ascribe_id  !=9   ` // 已确认未续约
+
+	//if contractDataType == "续约合同" || contractDataType == "确认不续约合同" {
+	//不续约列表数据
+	listRenewal, err := models.GetIncrementalCompanyMergeListEnd(condition1, pars1, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	conditionEnd1 := condition
+	parsEnd1 := pars
+
+	conditionEnd1 += ` AND a.end_date >= ? AND a.end_date <= ?  AND  a.company_ascribe_id  !=9   `
+	parsEnd1 = append(parsEnd1, startDate, endDate)
+
+	//if contractDataType == "到期合同" {
+	//到期列表数据
+	listEndDate, err := models.GetIncrementalCompanyMergeListEnd(conditionEnd1, parsEnd1, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	var companyContractIds []int
+	for _, v := range listRenewal {
+		companyContractIds = append(companyContractIds, v.CompanyContractId)
+		v.SellerId = v.SellerIdInit
+	}
+	for _, v := range listEndDate {
+		companyContractIds = append(companyContractIds, v.CompanyContractId)
+		v.SellerId = v.SellerIdInit
+	}
+
+	//合同归因标签
+	mapGetCompanyAscribeContent, mapContent := services.GetCompanyContractAscribeContentMap(companyContractIds)
+
+	//合并合同所对应的权限
+	mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(companyContractIds)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range listRenewal {
+		v.PermissionName = mappermissionName[v.CompanyContractId]
+		if mapGetCompanyAscribeContent[v.CompanyContractId] != "" {
+			v.Content = mapContent[v.CompanyContractId]
+			v.AscribeContent = mapGetCompanyAscribeContent[v.CompanyContractId]
+			v.IsShowNoRenewedNote = true
+		}
+	}
+	for _, v := range listEndDate {
+		v.PermissionName = mappermissionName[v.CompanyContractId]
+		if mapGetCompanyAscribeContent[v.CompanyContractId] != "" {
+			v.Content = mapContent[v.CompanyContractId]
+			v.AscribeContent = mapGetCompanyAscribeContent[v.CompanyContractId]
+			v.IsShowNoRenewedNote = true
+		}
+	}
+	//创建excel
+	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
+	if exportType == 1 {
+		for pidIndex := 0; pidIndex <= 1; pidIndex++ {
+			var sheetName string
+			var listDate []*models.IncrementalList
+			if pidIndex == 0 {
+				sheetName = "确认不续约合同"
+				listDate = listRenewal
+			} else {
+				sheetName = "到期合同"
+				listDate = listEndDate
+			}
+			sheet, err := xlsxFile.AddSheet(sheetName)
+			if err != nil {
+				br.Msg = "新增Sheet失败"
+				br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
+				return
+			}
+			//标头
+			rowTitle := sheet.AddRow()
+			cellA := rowTitle.AddCell()
+			cellA.Value = "客户名称"
+			cellB := rowTitle.AddCell()
+			cellB.Value = "客户状态"
+			cellC := rowTitle.AddCell()
+			cellC.Value = "所属销售"
+			cellCSeller := rowTitle.AddCell()
+			cellCSeller.Value = "服务销售"
+			cellD := rowTitle.AddCell()
+			cellD.Value = "合同期限"
+			cellE := rowTitle.AddCell()
+			cellE.Value = "签约套餐"
+			cellF := rowTitle.AddCell()
+			cellF.Value = "合同金额"
+
+			if pidIndex == 0 {
+				cellG := rowTitle.AddCell()
+				cellG.Value = "不续约归因"
+			}
+
+			for _, item := range listDate {
+				row := sheet.AddRow()
+				cellAData := row.AddCell()
+				cellAData.Value = item.CompanyName
+				cellBData := row.AddCell()
+				cellBData.Value = item.ProductStatus
+				cellCData := row.AddCell()
+				cellCData.Value = item.SellerName
+				cellCSellerData := row.AddCell()
+				cellCSellerData.Value = item.ShareSeller
+				cellDData := row.AddCell()
+				cellDData.Value = item.StartDate + "~" + item.EndDate
+				cellEData := row.AddCell()
+				cellEData.Value = item.PermissionName
+				cellFData := row.AddCell()
+				cellFData.Value = fmt.Sprint(item.Money)
+				if pidIndex == 0 {
+					cellGData := row.AddCell()
+					cellGData.Value = item.Content
+				}
+			}
+		}
+		err = xlsxFile.Save(downLoadnFilePath)
+		if err != nil {
+			br.Msg = "保存文件失败"
+			br.ErrMsg = "保存文件失败"
+			return
+		}
+	} else {
+
+		var sheetName string
+		//var listDate []*models.IncrementalList
+		sheetName = "未续约率"
+		sheet, err := xlsxFile.AddSheet(sheetName)
+		if err != nil {
+			br.Msg = "新增Sheet失败"
+			br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
+			return
+		}
+		//标头
+		rowTitle := sheet.AddRow()
+		cellA := rowTitle.AddCell()
+		cellA.Value = "姓名"
+		cellB := rowTitle.AddCell()
+		cellB.Value = "确认不续约合同数"
+		cellC := rowTitle.AddCell()
+		cellC.Value = "确认不续约合同金额"
+		cellD := rowTitle.AddCell()
+		cellD.Value = "到期合同数"
+		cellE := rowTitle.AddCell()
+		cellE.Value = "到期合同金额"
+		cellF := rowTitle.AddCell()
+		cellF.Value = "确认不续约率"
+
+		listRaiSeller, err := system.GetSysuserRaiListNoServer()
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取权益销售信息失败,Err:" + err.Error()
+			return
+		}
+
+		//NoRenewalContractTotal      int    `description:"确认不续约合同数"`
+		//NoRenewalContractMoney      int    `description:"确认不续约合同金额"`
+		//ExpireRenewalContractTotal  int    `description:"到期合同数量"`
+		//ExpireRenewalContractMoney  int    `description:"到期合同总金额"`
+		//NoRenewalContractPercentage string `description:"确认不续约率"`
+		mapNoRenewalContractTotal := make(map[int]int)
+		mapNoRenewalContractMoney := make(map[int]float64)
+		mapExpireRenewalContractTotal := make(map[int]int)
+		mapExpireRenewalContractMoney := make(map[int]float64)
+
+		//mapData := make(map[int]*response.IncrementalCompanyPercentageExportResp)
+		for _, v := range listRenewal {
+			mapNoRenewalContractTotal[v.SellerId]++
+			mapNoRenewalContractMoney[v.SellerId] += v.Money
+		}
+
+		for _, v := range listEndDate {
+			mapExpireRenewalContractTotal[v.SellerId]++
+			mapExpireRenewalContractMoney[v.SellerId] += v.Money
+		}
+
+		for _, item := range listRaiSeller {
+			row := sheet.AddRow()
+			cellAData := row.AddCell()
+			cellAData.Value = item.RealName
+			cellBData := row.AddCell()
+			cellBData.Value = fmt.Sprint(mapNoRenewalContractTotal[item.AdminId])
+			cellCData := row.AddCell()
+			cellCData.Value = utils.SubFloatToString(mapNoRenewalContractMoney[item.AdminId], 2)
+
+			cellEData := row.AddCell()
+			cellEData.Value = fmt.Sprint(mapExpireRenewalContractTotal[item.AdminId])
+			cellFData := row.AddCell()
+			cellFData.Value = utils.SubFloatToString(mapExpireRenewalContractMoney[item.AdminId], 2)
+
+			cellGData := row.AddCell()
+
+			//分子或者分母为零的时候,不做计算
+			if mapNoRenewalContractMoney[item.AdminId] == 0 || mapExpireRenewalContractMoney[item.AdminId] == 0 {
+				cellGData.Value = "0%"
+			} else {
+				cellGData.Value = fmt.Sprint(utils.SubFloatToString(float64(mapNoRenewalContractMoney[item.AdminId])/float64(mapExpireRenewalContractMoney[item.AdminId])*100, 2), "%")
+			}
+		}
+		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"
+// @Success Ret=200 {object} company.GetCompanyContractDetailListResp
+// @router /merge_company_previous/last_year [get]
+func (this *StatisticCompanyMergerController) CompanyPreviousLastYear() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	AdminUser := this.SysUser
+	if AdminUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	resp := new(company.GetCompanyContractDetailListResp)
+	companyContractId, _ := this.GetInt("CompanyContractId")
+	if companyContractId < 1 {
+		br.Msg = "请输入合同ID"
+		return
+	}
+	var condition string
+	var pars []interface{}
+	//获取最新的一条到期的合同信息
+
+	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
+	}
+
+	startDateContrac := detail.StartDate                                            // 合同开始时间
+	startDateYear := utils.StrDateToDate(startDateContrac).AddDate(-1, 0, 0).Year() //所要查询的年份
+	startDate := fmt.Sprint(startDateYear, "-01-01")
+	endDate := fmt.Sprint(startDateYear, "-12-31")
+
+	//获取前一份合同的信息
+	pars = make([]interface{}, 0)
+	condition = " AND company_id = ?   AND status = 1  AND  start_date >= ? AND  start_date <= ? AND product_id = 2  ORDER BY start_date DESC   "
+	pars = append(pars, detail.CompanyId, startDate, endDate)
+	detailPreviousList, err := company.GetCompanyContracList(condition, pars)
+	if err != nil {
+		br.Msg = "详情不存在"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	var companyContractIds []int
+	for _, v := range detailPreviousList {
+		companyContractIds = append(companyContractIds, v.CompanyContractId)
+	}
+	//合并合同所对应的权限
+	mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(companyContractIds)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range detailPreviousList {
+		v.PermissionName = mappermissionName[v.CompanyContractId]
+	}
+	resp.List = detailPreviousList
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
 func init213() {
 	var condition string
 	var pars []interface{}
@@ -1855,3 +2340,171 @@ func init323() {
 		}
 	}
 }
+
+//func init() {
+//	init16_1_06()
+//}
+
+func init16_1_01() {
+	var condition string
+	var pars []interface{}
+
+	condition = "  AND  product_id = 2 "
+	var companyIds []int
+	companyContractList, e := company.GetCompanyContractList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+
+	for _, v := range companyContractList {
+		if utils.InArrayByInt(companyIds, v.CompanyId) {
+			continue
+		}
+		companyIds = append(companyIds, v.CompanyId)
+	}
+
+	condition = "   AND company_id IN (" + (utils.GetOrmInReplace(len(companyIds))) + ") AND product_id = 2  AND share_seller_id > 0  "
+	pars = append(pars, companyIds)
+	listCompanyProduct, e := company.GetCompanyProductList(condition, pars)
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+	for _, v := range listCompanyProduct {
+		fmt.Println(v.ShareSellerId, v.ShareSeller)
+
+		e = company.UpdateCompanyContractTypeinit16_1_01(v.ShareSeller, v.ShareSellerId, v.CompanyId)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+	}
+}
+
+func init16_1_02() {
+	var condition string
+	var pars []interface{}
+
+	condition = "  AND  product_id = 2  AND company_contract_id > 0  "
+
+	CompanyApprovalList, e := company.GetCompanyApprovalList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+
+	for _, v := range CompanyApprovalList {
+		fmt.Println(v.CompanyId, v.CompanyContractId, "__", v.CompanyApprovalId)
+
+		e = company.UpdateCompanyContractTypeinit16_1_02(v.ApplyRealName, v.ApplyUserId, v.CompanyContractId)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+	}
+}
+
+func init16_1_03() {
+	CompanyApprovalList, e := company.GetCompanyOperationRecordListinitcrm16_1()
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+
+	for _, v := range CompanyApprovalList {
+		fmt.Println(v.CompanyId, v.SellerId, "__", v.SysRealName)
+		e = company.UpdateCompanyProductsellerInit(v.SellerId, v.SysRealName, v.CompanyId, 2)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+	}
+}
+
+func init16_1_04() {
+	var condition string
+	var pars []interface{}
+
+	condition = "  AND  product_id = 2  AND  seller_id_init = 0    "
+
+	CompanyApprovalList, e := company.GetCompanyContracList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+
+	for _, v := range CompanyApprovalList {
+		productItem, e := company.GetCompanyProductByCompanyIdAndProductId(v.CompanyId, 2)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			fmt.Println(e)
+			return
+		}
+		if productItem == nil {
+			continue
+		}
+		e = company.UpdateCompanyContractTypeinit16_1_02(productItem.SellerName, productItem.SellerId, v.CompanyContractId)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+	}
+}
+
+//func init16_1_05() {
+//	var condition string
+//	var pars []interface{}
+//
+//	condition = "  AND  product_id = 2    "
+//
+//	listProduct, e := company.GetCompanyProductList(condition, pars)
+//	if e != nil {
+//		fmt.Println(e)
+//		return
+//	}
+//	for _, v := range listProduct {
+//		e = company.UpdateCompanyProductSellerUnexpiredInitinit16_1_05(v.SellerId, v.SellerName, v.CompanyId)
+//		if e != nil {
+//			fmt.Println(e)
+//			return
+//		}
+//	}
+//	fmt.Println("end")
+//}
+
+func init16_1_06() {
+	var condition string
+	var pars []interface{}
+
+	listContractMax, e := company.GetCompanyContracListInit(condition, pars)
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+	maxId := make(map[int]int)
+	for _, v := range listContractMax {
+		maxId[v.MaxCompanyContractId] = v.MaxCompanyContractId
+	}
+
+	listContract, e := company.GetCompanyContracListInit_CRM_16_1(condition, pars)
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+	var updateId []string
+	for _, v := range listContract {
+		if maxId[v.CompanyContractId] > 0 {
+			continue
+		}
+		updateId = append(updateId, strconv.Itoa(v.CompanyContractId))
+	}
+
+	err := company.UpdateCompanyContracthide(updateId)
+	fmt.Println((err))
+	fmt.Println((updateId))
+}
+
+//更新权益销客户后一个正式的销售为当前销售
+//func init(){
+//	SELECT * FROM company_product  WHERE 1= 1  AND  product_id =2   AND  share_seller_id > 0 ;
+//}

+ 917 - 34
controllers/statistic_report.go

@@ -17,6 +17,7 @@ import (
 	"hongze/hz_crm_api/services"
 	"hongze/hz_crm_api/services/alarm_msg"
 	contractService "hongze/hz_crm_api/services/contract"
+	cygxService "hongze/hz_crm_api/services/cygx"
 	fmsService "hongze/hz_crm_api/services/fms"
 	"hongze/hz_crm_api/services/statistic_report"
 	"hongze/hz_crm_api/utils"
@@ -111,6 +112,225 @@ func getQueryParams(condition string, pars []interface{}, sysUser *system.Admin,
 	return
 }
 
+// getQueryParamsInit 获取基础查询信息(最开始关联的销售信息)
+func getQueryParamsInit(condition string, pars []interface{}, sysUser *system.Admin, tableAlias string) (newCondition string, newPars []interface{}) {
+	if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
+		condition += " AND " + tableAlias + "product_id=?"
+		pars = append(pars, 1)
+	} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
+		condition += " AND " + tableAlias + "product_id=?"
+		pars = append(pars, 2)
+	} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FINANCE {
+		//超级管理员账户,不做条件限制
+	} else {
+		//如果不是研究员,那么去找对应的 部门、小组、销售
+		if sysUser.Authority == 0 {
+			//普通用户
+			condition += " AND a.seller_id_init=?"
+			pars = append(pars, sysUser.AdminId)
+		} else if sysUser.Authority == 1 {
+			//部门主管
+			condition += " AND " + tableAlias + "department_id=?"
+			pars = append(pars, sysUser.DepartmentId)
+		} else if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
+			//权益小组负责人
+			condition += " AND " + tableAlias + "group_id=?"
+			pars = append(pars, sysUser.GroupId)
+		} else if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
+			//ficc销售主管
+			pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
+			if err != nil {
+				fmt.Println(err.Error())
+				return
+			}
+			var ids []*string
+			if pid != nil && *pid != 0 {
+				ids, err = company.GetGroupIdsByParentId(*pid)
+				if err != nil {
+					fmt.Println(err.Error())
+				}
+			} else {
+				ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
+				if err != nil {
+					fmt.Println(err.Error())
+				}
+			}
+			var idSlice []string
+			var sid string
+			for _, id := range ids {
+				idSlice = append(idSlice, *id)
+			}
+			//加入父级groupId
+			if *pid > 0 {
+				idSlice = append(idSlice, strconv.Itoa(*pid))
+			} else {
+				idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
+			}
+			sid = strings.Join(idSlice, ",")
+			condition += " AND " + tableAlias + `group_id IN (` + sid + `) `
+			fmt.Println("condition:", condition)
+			//pars = append(pars, sysUser.GroupId)
+		} else if sysUser.Authority == 4 {
+			//ficc小组负责人
+			condition += " AND " + tableAlias + "group_id=?"
+			pars = append(pars, sysUser.GroupId)
+		} else {
+			//不知道什么类型的用户(后面新增的位置类型客户)
+			condition += " AND a.seller_id_init=?"
+			pars = append(pars, sysUser.AdminId)
+		}
+	}
+	newCondition = condition
+	newPars = pars
+	return
+}
+
+// getQueryParams 获取基础查询信息(最开始关联的销售信息)
+func getQueryParamsLast(condition string, pars []interface{}, sysUser *system.Admin, tableAlias string) (newCondition string, newPars []interface{}) {
+	if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
+		condition += " AND " + tableAlias + "product_id=?"
+		pars = append(pars, 1)
+	} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
+		condition += " AND " + tableAlias + "product_id=?"
+		pars = append(pars, 2)
+	} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FINANCE {
+		//超级管理员账户,不做条件限制
+	} else {
+		//如果不是研究员,那么去找对应的 部门、小组、销售
+		if sysUser.Authority == 0 {
+			//普通用户
+			condition += " AND c.seller_id_last=?"
+			pars = append(pars, sysUser.AdminId)
+		} else if sysUser.Authority == 1 {
+			//部门主管
+			condition += " AND " + tableAlias + "department_id=?"
+			pars = append(pars, sysUser.DepartmentId)
+		} else if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
+			//权益小组负责人
+			condition += " AND " + tableAlias + "group_id=?"
+			pars = append(pars, sysUser.GroupId)
+		} else if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
+			//ficc销售主管
+			pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
+			if err != nil {
+				fmt.Println(err.Error())
+				return
+			}
+			var ids []*string
+			if pid != nil && *pid != 0 {
+				ids, err = company.GetGroupIdsByParentId(*pid)
+				if err != nil {
+					fmt.Println(err.Error())
+				}
+			} else {
+				ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
+				if err != nil {
+					fmt.Println(err.Error())
+				}
+			}
+			var idSlice []string
+			var sid string
+			for _, id := range ids {
+				idSlice = append(idSlice, *id)
+			}
+			//加入父级groupId
+			if *pid > 0 {
+				idSlice = append(idSlice, strconv.Itoa(*pid))
+			} else {
+				idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
+			}
+			sid = strings.Join(idSlice, ",")
+			condition += " AND " + tableAlias + `group_id IN (` + sid + `) `
+			fmt.Println("condition:", condition)
+			//pars = append(pars, sysUser.GroupId)
+		} else if sysUser.Authority == 4 {
+			//ficc小组负责人
+			condition += " AND " + tableAlias + "group_id=?"
+			pars = append(pars, sysUser.GroupId)
+		} else {
+			//不知道什么类型的用户(后面新增的位置类型客户)
+			condition += " AND c.seller_id_last=?"
+			pars = append(pars, sysUser.AdminId)
+		}
+	}
+	newCondition = condition
+	newPars = pars
+	return
+}
+
+// getQueryParamsLastCompanyProduct 获取基础查询信息(最后一次正式转试用的时间点)
+func getQueryParamsLastCompanyProduct(condition string, pars []interface{}, sysUser *system.Admin, tableAlias string) (newCondition string, newPars []interface{}) {
+	if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
+		condition += " AND " + tableAlias + "product_id=?"
+		pars = append(pars, 1)
+	} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
+		condition += " AND " + tableAlias + "product_id=?"
+		pars = append(pars, 2)
+	} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FINANCE {
+		//超级管理员账户,不做条件限制
+	} else {
+		//如果不是研究员,那么去找对应的 部门、小组、销售
+		if sysUser.Authority == 0 {
+			//普通用户
+			condition += " AND " + tableAlias + "seller_id_last=?"
+			pars = append(pars, sysUser.AdminId)
+		} else if sysUser.Authority == 1 {
+			//部门主管
+			condition += " AND " + tableAlias + "department_id=?"
+			pars = append(pars, sysUser.DepartmentId)
+		} else if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
+			//权益小组负责人
+			condition += " AND " + tableAlias + "group_id=?"
+			pars = append(pars, sysUser.GroupId)
+		} else if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
+			//ficc销售主管
+			pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
+			if err != nil {
+				fmt.Println(err.Error())
+				return
+			}
+			var ids []*string
+			if pid != nil && *pid != 0 {
+				ids, err = company.GetGroupIdsByParentId(*pid)
+				if err != nil {
+					fmt.Println(err.Error())
+				}
+			} else {
+				ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
+				if err != nil {
+					fmt.Println(err.Error())
+				}
+			}
+			var idSlice []string
+			var sid string
+			for _, id := range ids {
+				idSlice = append(idSlice, *id)
+			}
+			//加入父级groupId
+			if *pid > 0 {
+				idSlice = append(idSlice, strconv.Itoa(*pid))
+			} else {
+				idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
+			}
+			sid = strings.Join(idSlice, ",")
+			condition += " AND " + tableAlias + `group_id IN (` + sid + `) `
+			fmt.Println("condition:", condition)
+			//pars = append(pars, sysUser.GroupId)
+		} else if sysUser.Authority == 4 {
+			//ficc小组负责人
+			condition += " AND " + tableAlias + "group_id=?"
+			pars = append(pars, sysUser.GroupId)
+		} else {
+			//不知道什么类型的用户(后面新增的位置类型客户)
+			condition += " AND  " + tableAlias + "seller_id_last=?"
+			pars = append(pars, sysUser.AdminId)
+		}
+	}
+	newCondition = condition
+	newPars = pars
+	return
+}
+
 // Home
 // @Title 获取首页工作台数据
 // @Description 获取首页工作台数据接口
@@ -2339,35 +2559,218 @@ func StackCompanyListExport(this *StatisticReportController, dataType string, re
 	br.Msg = "导出成功"
 }
 
-// 获取历史的数据
-func getHistoryStackCompanyList(sysUser *system.Admin, currentIndex, pageSize, isConfirm, companyAscribeId int, adminId, regionType, companyType, dataType, tryOutType, date, keyword string) (returnData response.StackCompanyListResp, err error) {
-	if date == "" {
-		err = errors.New("请选择日期")
+// StackCompanyListExportRai 获取存量客户数据报表导出
+func StackCompanyListExportRai(this *StatisticReportController, dataType string, resp response.StackCompanyListResp, 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
 	}
-
-	var startSize int
-	if pageSize <= 0 {
-		pageSize = utils.PageSize20
-	}
-	if currentIndex <= 0 {
-		currentIndex = 1
+	style := xlsx.NewStyle()
+	alignment := xlsx.Alignment{
+		Horizontal: "center",
+		Vertical:   "center",
+		WrapText:   true,
 	}
-	startSize = utils.StartIndex(currentIndex, pageSize)
 
-	var condition string
-	var pars []interface{}
+	style.Alignment = alignment
+	style.ApplyAlignment = true
 
-	//条件
-	condition += ` AND date = ? `
-	pars = append(pars, date)
+	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)
 
-	var conditionAscribRai string // 处理权益未续约客户检索列表SQL查询条件
-	var parsAscribeRai []interface{}
-	//是否确认续约 CRM 13.9
-	if isConfirm != -1 {
-		var conditionConfirm string
-		var parsConfirm []interface{}
+	//统计数据
+	statisticRow := sheel.AddRow()
+
+	cell1 := statisticRow.AddCell()
+	cell1.SetStyle(style)
+	cell1.SetValue(fmt.Sprint("新签客户数:", resp.NewCompanyTotal))
+
+	cell2 := statisticRow.AddCell()
+	cell2.SetStyle(style)
+	cell2.SetValue(fmt.Sprint("续约客户数:", resp.RenewalCompanyTotal))
+
+	cell3 := statisticRow.AddCell()
+	cell3.SetStyle(style)
+	cell3.SetValue(fmt.Sprint("未续约客户数:", resp.NotRenewalCompanyTotal))
+	//表头
+
+	titleRow := sheel.AddRow()
+
+	cellName := titleRow.AddCell()
+	cellName.SetStyle(style)
+	cellName.SetValue("客户名称")
+
+	cellProName := titleRow.AddCell()
+	cellProName.SetStyle(style)
+	cellProName.SetValue("客户类型")
+
+	cellSellerName := titleRow.AddCell()
+	cellSellerName.SetStyle(style)
+	cellSellerName.SetValue("所属销售")
+
+	switch dataType {
+	case "未续约客户":
+		cellTime := titleRow.AddCell()
+		cellTime.SetStyle(style)
+		cellTime.SetValue("最近合同到期时间")
+
+		cellRemark := titleRow.AddCell()
+		cellRemark.SetStyle(style)
+		cellRemark.SetValue("未续约说明")
+
+		cellDay := titleRow.AddCell()
+		cellDay.SetStyle(style)
+		cellDay.SetValue("超出过期天数")
+
+		cellAscribeContent := titleRow.AddCell()
+		cellAscribeContent.SetStyle(style)
+		cellAscribeContent.SetValue("不续约归因")
+
+		cellContent := titleRow.AddCell()
+		cellContent.SetStyle(style)
+		cellContent.SetValue("详细原因")
+	default:
+
+		cellShareSeller := titleRow.AddCell()
+		cellShareSeller.SetStyle(style)
+		cellShareSeller.SetValue("服务销售")
+
+		cellTime := titleRow.AddCell()
+		cellTime.SetStyle(style)
+		cellTime.SetValue("合同期限")
+
+		cellMoney := titleRow.AddCell()
+		cellMoney.SetStyle(style)
+		cellMoney.SetValue("合同金额")
+
+		cellPermissionName := titleRow.AddCell()
+		cellPermissionName.SetStyle(style)
+		cellPermissionName.SetValue("签约套餐")
+	}
+
+	for _, v := range resp.List {
+		dataRow := sheel.AddRow()
+		dataRow.SetHeight(20)
+
+		cellDataName := dataRow.AddCell()
+		cellDataName.SetStyle(style)
+		cellDataName.SetValue(v.CompanyName)
+
+		cellDataProName := dataRow.AddCell()
+		cellDataProName.SetStyle(style)
+		cellDataProName.SetValue(v.ProductName)
+
+		cellDataSellerName := dataRow.AddCell()
+		cellDataSellerName.SetStyle(style)
+		cellDataSellerName.SetValue(v.SellerName)
+
+		if dataType != "未续约客户" {
+			cellDataShareSeller := dataRow.AddCell()
+			cellDataShareSeller.SetStyle(style)
+			cellDataShareSeller.SetValue(v.ShareSeller)
+		}
+
+		cellDataTime := dataRow.AddCell()
+		cellDataTime.SetStyle(style)
+		switch dataType {
+		case "新签客户":
+			cellDataTime.SetValue(fmt.Sprint(v.StartDate, " ~  ", v.EndDate))
+		case "续约客户":
+			cellDataTime.SetValue(fmt.Sprint(v.StartDate, " ~  ", v.EndDate))
+		case "未续约客户":
+			cellDataTime.SetValue(v.EndDate)
+
+			//未续约说明
+			cellDataRemark := dataRow.AddCell()
+			cellDataRemark.SetStyle(style)
+			cellDataRemark.SetValue(v.RenewalReason)
+
+			cellDay := dataRow.AddCell()
+			cellDay.SetStyle(style)
+			cellDay.SetValue(v.ExpireDay)
+		}
+
+		if dataType == "新签客户" || dataType == "续约客户" {
+			cellMoney := dataRow.AddCell()
+			cellMoney.SetStyle(style)
+			cellMoney.SetValue(v.Money)
+
+			cellPermissionName := dataRow.AddCell()
+			cellPermissionName.SetStyle(style)
+			cellPermissionName.SetValue(v.PermissionName)
+		}
+
+		switch dataType {
+		case "未续约客户":
+			cellAscribeContent := dataRow.AddCell()
+			cellAscribeContent.SetStyle(style)
+			cellAscribeContent.SetValue(v.AscribeContent)
+
+			cellContent := dataRow.AddCell()
+			cellContent.SetStyle(style)
+			cellContent.SetValue(v.Content)
+		}
+
+	}
+	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 = "导出成功"
+}
+
+// 获取历史的数据
+func getHistoryStackCompanyList(sysUser *system.Admin, currentIndex, pageSize, isConfirm, companyAscribeId int, adminId, regionType, companyType, dataType, tryOutType, date, keyword string) (returnData response.StackCompanyListResp, err error) {
+	if date == "" {
+		err = errors.New("请选择日期")
+		return
+	}
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+
+	//条件
+	condition += ` AND date = ? `
+	pars = append(pars, date)
+
+	var conditionAscribRai string // 处理权益未续约客户检索列表SQL查询条件
+	var parsAscribeRai []interface{}
+	//是否确认续约 CRM 13.9
+	if isConfirm != -1 {
+		var conditionConfirm string
+		var parsConfirm []interface{}
 
 		companyConfirmList, e := company.GetCompanyNoRenewedAscribeList(conditionConfirm, parsConfirm, 0, 0)
 		if e != nil && e.Error() != utils.ErrNoRow() {
@@ -3802,6 +4205,9 @@ func (this *StatisticReportController) IncrementalCompanyList() {
 				item.AscribeContent = mapGetCompanyAscribeContent[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
 				item.Content = mapContent[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
 				item.IsShowNoRenewedNote = mapNoRenewedNote[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
+				if item.ProductId == utils.COMPANY_PRODUCT_RAI_ID { //权益客户的销售,按照创建时候对应的销售展示
+					item.SellerName = item.SellerNameInit
+				}
 			}
 			list = tmpList
 			dataTotal = total
@@ -5733,9 +6139,9 @@ func (this *StatisticReportController) InvoicePaymentList() {
 		pars = append(pars, kw)
 	}
 	if sellerIdstr != "" {
-		sellerIds := strings.Split(sellerIdstr, ",")
-		cond += ` AND (c.seller_id in ? OR d.seller_id in ?)`
-		pars = append(pars, sellerIds, sellerIds)
+		//sellerIds := strings.Split(sellerIdstr, ",")
+		cond += ` AND (c.seller_id in (` + sellerIdstr + `) OR d.seller_id in  (` + sellerIdstr + `))`
+		//pars = append(pars, sellerIds, sellerIds)
 	}
 	// 套餐筛选
 	if serviceType != "" {
@@ -5761,6 +6167,10 @@ func (this *StatisticReportController) InvoicePaymentList() {
 		depId = 5
 	}
 
+	dshiAdminId := 13
+	if utils.RunMode == "debug" {
+		dshiAdminId = 233
+	}
 	if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
 		sellerIdsList, err := system.GetSellerIdsByDepId(depId)
 		if err != nil {
@@ -5769,17 +6179,18 @@ func (this *StatisticReportController) InvoicePaymentList() {
 			return
 		}
 		cond += ` AND (c.seller_id IN (` + strings.Join(sellerIdsList, ",") + `) OR d.seller_id IN (` + strings.Join(sellerIdsList, ",") + `))`
-	} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
-		conf , err := company.GetConfigDetailByCode("ficc_group_seller_ids")
+	} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP && sysUser.AdminId == dshiAdminId {
+		groupTeamSellerList, err := system.GetSysUserByParentIdGroupId(5)
 		if err != nil {
-			fmt.Println("GetConfigDetailByCode Err:" + err.Error())
-		}
-		if conf.ConfigValue == "" {
-			err = errors.New("ID配置有误")
+			br.Msg = "获取销售失败"
+			br.ErrMsg = "获取销售失败,Err:" + err.Error()
 			return
 		}
-		sellerIdsList := conf.ConfigValue
-		sellerIdsList += "," + strconv.Itoa(sysUser.AdminId)
+		sellerIdsList := ""
+		for _, v := range groupTeamSellerList {
+			sellerIdsList += strconv.Itoa(v.AdminId) + ","
+		}
+		sellerIdsList = strings.TrimRight(sellerIdsList, ",")
 
 		cond += ` AND (c.seller_id IN (` + sellerIdsList + `) OR d.seller_id IN (` + sellerIdsList + `))`
 		pars = append(pars)
@@ -6525,3 +6936,475 @@ func (this *StatisticReportController) UnusualRenewCompanyList() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// StackCompanyListRai
+// @Title 获取权益存量客户数据列表
+// @Description 获取权益存量客户数据列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   Keyword   query   string  true       "客户名称"
+// @Param   AdminId   query   string  true       "销售id,多个用英文逗号隔开,空字符串为全部"
+// @Param   RegionType   query   string  false       "所属区域:传空字符串或者不传为全部,'国内','海外'"
+// @Param   DataType   query   string  false       "报表类型,枚举值:`新签客户`,`续约客户`,`未续约客户`"
+// @Param   TryOutType   query   string  false       " '试用', '非试用' 非试用即为冻结/流失"
+// @Param   IsExport   query   bool  false       "是否导出excel,默认是false"
+// @Param   CompanyAscribeId   query   int  false       "归因ID"
+// @Success 200 {object} response.StackCompanyListResp
+// @router /stack_company_list_rai [get]
+func (this *StatisticReportController) StackCompanyListRai() {
+	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
+	}
+
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	//是否导出报表
+	isExport, _ := this.GetBool("IsExport")
+	if isExport {
+		pageSize = 10000
+		currentIndex = 1
+	}
+
+	adminId := this.GetString("AdminId")
+	regionType := this.GetString("RegionType")
+	companyType := this.GetString("CompanyType")
+	dataType := this.GetString("DataType")
+	tryOutType := this.GetString("TryOutType")
+	keyword := this.GetString("Keyword")
+
+	companyAscribeId, _ := this.GetInt("CompanyAscribeId", -1) // CRM 13.9
+
+	var resp response.StackCompanyListResp
+	//历史统计数据
+	//获取实时统计数据(今天数据)
+	tmpResp, err := getTodayStackCompanyListV2Rai(sysUser, currentIndex, pageSize, companyAscribeId, adminId, regionType, companyType, dataType, tryOutType, keyword)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	resp = tmpResp
+
+	//导出excel
+	if isExport {
+		StackCompanyListExportRai(this, dataType, resp, br)
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+func getTodayStackCompanyListV2Rai(sysUser *system.Admin, currentIndex, pageSize, companyAscribeId int, adminId, regionType, companyType, dataType, tryOutType, keyword string) (returnData response.StackCompanyListResp, err error) {
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+	var condition, listCondition string
+	var pars, listPars []interface{}
+
+	today := utils.GetToday(utils.FormatDate)
+	//条件
+	var conditionAscribRai string // 处理权益未续约客户检索列表SQL查询条件
+	var parsAscribeRai []interface{}
+
+	//归因ID CRM 13.9
+	if companyAscribeId > 0 {
+		var conditionAscribe string
+		var parsAscribe []interface{}
+		conditionAscribe = "  AND  company_ascribe_id = ? "
+		parsAscribe = append(parsAscribe, companyAscribeId)
+		companyNoRenewedAscribeList, e := company.GetCompanyNoRenewedAscribeList(conditionAscribe, parsAscribe, 0, 0)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetCompanyNoRenewedAscribeList" + e.Error())
+			return
+		}
+		var companyIds []int
+		if len(companyNoRenewedAscribeList) == 0 {
+			companyIds = append(companyIds, 0) // 给一个不存在的ID
+		} else {
+			for _, v := range companyNoRenewedAscribeList {
+				companyIds = append(companyIds, v.CompanyId)
+			}
+		}
+		conditionAscribRai += ` AND c.company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)`
+		parsAscribeRai = append(parsAscribeRai, companyIds)
+	}
+
+	//if adminId != "" {
+	//	//condition += ` AND c.seller_id in  (` + adminId + `) `
+	//	//pars = append(pars, adminId)
+	//} else {
+	//	//根据当前角色来获取查询条件
+	//	condition, pars = getQueryParamsInit(condition, pars, sysUser, "c.")
+	//
+	//}
+	if regionType != "" {
+		condition += ` AND b.region_type = ? `
+		pars = append(pars, regionType)
+	}
+	//关键字搜索
+	if keyword != "" {
+		condition += ` and b.company_name like "%` + keyword + `%" `
+	}
+
+	condition += ` AND a.product_id = ? `
+	pars = append(pars, 2)
+
+	var dataTotal, newCompanyTotal, renewalCompanyTotal, notRenewalCompanyTotal int
+	var notRenewalTryOut, notRenewalNotTryOut int
+	var list []*models.IncrementalList
+
+	//var condition1 string
+	//var pars1 []interface{}
+	//新签客户数
+	{
+		//if adminId != "" {
+		//	//condition += ` AND c.seller_id in  (` + adminId + `) `
+		//	//pars = append(pars, adminId)
+		//} else {
+		//	//根据当前角色来获取查询条件
+		//	condition, pars = getQueryParamsInit(condition, pars, sysUser, "c.")
+		//
+		//}
+		condition1 := condition
+		pars1 := pars
+		if adminId != "" {
+			condition1 += ` AND a.seller_id_init in  (` + adminId + `) `
+		} else {
+			condition1, pars1 = getQueryParamsInit(condition1, pars1, sysUser, "c.")
+			//condition1 += condition2
+			//pars1 = append(pars1, pars2)
+		}
+
+		//condition1 += condition
+		//pars1 := pars
+		//condition1 += ` AND c.status = "正式"  `
+		condition1 += ` AND a.start_date <= ? AND a.end_date >= ? `
+		pars1 = append(pars1, today, today)
+		condition1 += ` AND a.contract_type = ? `
+		pars1 = append(pars1, "新签合同")
+
+		total, countErr := models.GetIncrementalNewCompanyCount(condition1, pars1)
+		if countErr != nil && countErr.Error() != utils.ErrNoRow() {
+			err = countErr
+			return
+		}
+		newCompanyTotal = total
+
+		if dataType == "新签客户" {
+			//页表页数据总和
+			total, countErr = models.GetTodayStackCompanyProductCount(condition1, pars1)
+			if countErr != nil && countErr.Error() != utils.ErrNoRow() {
+				err = countErr
+				return
+			}
+			dataTotal = total
+			listCondition = condition1
+			listPars = pars1
+		}
+	}
+
+	//续约客户数
+	{
+		condition1 := condition
+		pars1 := pars
+		if adminId != "" {
+			condition1 += ` AND a.seller_id_init in  (` + adminId + `) `
+		} else {
+			condition1, pars1 = getQueryParamsInit(condition1, pars1, sysUser, "c.")
+		}
+		//condition1 += condition
+		//pars1 = append(pars1, pars)
+		//pars1 := pars
+		//condition1 += ` AND c.status  = "正式" `
+		condition1 += ` AND a.start_date <= ? AND a.end_date >= ? `
+		pars1 = append(pars1, today, today)
+		condition1 += ` AND a.contract_type = ? `
+		pars1 = append(pars1, "续约合同")
+
+		//额外条件(续约合同的起始日期包含在所选时间段内且不包含在新签合同存续期内的客户)
+		pars1 = append(pars1, today)
+		total, countErr := models.GetIncrementalNewCompanyCountV2(condition1, pars1)
+		if countErr != nil && countErr.Error() != utils.ErrNoRow() {
+			err = countErr
+			return
+		}
+		renewalCompanyTotal = total
+
+		if dataType == "续约客户" {
+			//页表页数据总和
+			total, countErr = models.GetTodayStackCompanyProductCountV2(condition1, pars1)
+			if countErr != nil && countErr.Error() != utils.ErrNoRow() {
+				err = countErr
+				return
+			}
+			dataTotal = total
+			listCondition = condition1
+			listPars = pars1
+		}
+	}
+	//未续约客户数
+	{
+		condition1 := condition
+		pars1 := pars
+		if adminId != "" {
+			//condition1 += ` AND a.seller_id_last in  (` + adminId + `) `
+			condition1 += ` AND c.seller_id_last in  (` + adminId + `) `
+		} else {
+			condition1, pars1 = getQueryParamsLastCompanyProduct(condition1, pars1, sysUser, "c.")
+		}
+
+		//condition1 += condition
+		//pars1 = append(pars1, pars)
+
+		//condition1 := condition
+		//pars1 := pars
+		condition1 += ` AND c.status not in ("永续","正式") AND a.create_time <= ? `
+		pars1 = append(pars1, time.Now().Format(utils.FormatDateTime))
+		condition1 += ` AND a.operation = 'try_out' `
+
+		total, countErr := models.GetIncrementalCompanyCountByOperationRecord(condition1, pars1)
+		if countErr != nil && countErr.Error() != utils.ErrNoRow() {
+			err = countErr
+			return
+		}
+
+		notRenewalCompanyTotal = total
+		condition1 += conditionAscribRai
+		pars1 = append(pars1, parsAscribeRai)
+		if dataType == "未续约客户" {
+			//页表页数据总和
+			//统计数据
+			for _, v := range []string{"试用", "非试用"} {
+				totalCondition1 := condition1
+				totalPars1 := pars1
+				var tmpTotal int
+				if v == "试用" {
+					totalCondition1 += ` AND c.status = "试用" `
+					tmpTotal, err = models.GetIncrementalCompanyProductCountByOperationRecord(totalCondition1, totalPars1)
+					if err != nil {
+						return
+					}
+					notRenewalTryOut = tmpTotal
+				} else if v == "非试用" {
+					totalCondition1 += ` AND c.status IN ("冻结","流失") `
+					tmpTotal, err = models.GetIncrementalCompanyProductCountByOperationRecord(totalCondition1, totalPars1)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						return
+					}
+					notRenewalNotTryOut = tmpTotal
+				}
+
+			}
+			//列表数据数量
+			if tryOutType == "试用" {
+				condition1 += ` AND c.status = "试用" `
+				total = notRenewalTryOut
+			} else if tryOutType == "非试用" {
+				condition1 += ` AND c.status IN ("冻结","流失") `
+				total = notRenewalNotTryOut
+			}
+
+			//total, countErr := models.GetIncrementalCompanyProductCountByOperationRecord(condition1, pars1)
+			//if countErr != nil && countErr.Error() != utils.ErrNoRow() {
+			//	err = countErr
+			//	return
+			//}
+
+			dataTotal = total
+			listCondition = condition1
+			listPars = pars1
+			if tryOutType == "试用" {
+				listCondition += ` AND c.status = "试用" `
+			} else if tryOutType == "非试用" {
+				listCondition += ` AND c.status IN ("冻结","流失") `
+			}
+			tmpList, countErr := models.GetIncrementalCompanyListByOperationRecordLast(listCondition, listPars, startSize, pageSize)
+			if countErr != nil {
+				err = countErr
+				return
+			}
+			for i := 0; i < len(tmpList); i++ {
+				endDateTime, parseErr := time.Parse(utils.FormatDateTime, tmpList[i].CreateTime)
+				if parseErr != nil {
+					err = parseErr
+					return
+				}
+				tmpList[i].EndDate = endDateTime.Format(utils.FormatDate)
+			}
+			list = tmpList
+
+		}
+	}
+
+	switch dataType {
+	case "新签客户":
+		tmpList, countErr := models.GetTodayStackCompanyList(listCondition, listPars, startSize, pageSize)
+		if countErr != nil {
+			err = countErr
+			return
+		}
+		list = tmpList
+	case "续约客户":
+		tmpList, countErr := models.GetTodayStackCompanyListV2(listCondition, listPars, startSize, pageSize)
+		if countErr != nil {
+			err = countErr
+			return
+		}
+		list = tmpList
+	}
+
+	if dataType == "续约客户" {
+		var ids []string
+		oldCompanyMap := make(map[int]*models.IncrementalList)
+		oldMoneyMap := make(map[int]float64)
+		countMap := make(map[int]int)
+		for _, item := range list {
+			ids = append(ids, strconv.Itoa(item.CompanyId))
+		}
+		if len(ids) > 0 {
+			idStr := strings.Join(ids, ",")
+			lists, contractErr := models.GetLastContractMoney(idStr)
+			if contractErr != nil {
+				err = contractErr
+				return
+			}
+
+			for _, item := range lists {
+				_, countOk := countMap[item.CompanyId]
+				_, ok := oldCompanyMap[item.CompanyId]
+				if !ok {
+					oldCompanyMap[item.CompanyId] = item
+					oldMoneyMap[item.CompanyId] = item.Money
+				} else if !countOk {
+					countMap[item.CompanyId] = 1
+					oldCompanyMap[item.CompanyId] = item
+				}
+			}
+
+			//给list赋值
+			for _, item := range list {
+				if item.ProductName == "权益" {
+					oldMoney, _ := oldMoneyMap[item.CompanyId]
+					lastContract, _ := oldCompanyMap[item.CompanyId]
+					if oldMoney > lastContract.Money {
+						item.PackageDifference = "增加套餐"
+					} else if oldMoney < lastContract.Money {
+						item.PackageDifference = "减少套餐"
+					} else {
+						item.PackageDifference = "维持套餐"
+					}
+				}
+			}
+		}
+	}
+
+	var ascribecompanyIds []int
+	for _, item := range list {
+		ascribecompanyIds = append(ascribecompanyIds, item.CompanyId)
+	}
+	//归因标签
+	mapGetCompanyAscribeContent, mapContent := services.GetCompanyAscribeContentMap(ascribecompanyIds)
+	mapNoRenewedNote := services.GetCompanyNoRenewedNoteMap(ascribecompanyIds)
+	mapIsUserMaker := cygxService.GetCompanyProductIsUserMakerByCompanyIds(ascribecompanyIds) //根据公司ID获取近四周之内有决策人互动的客户
+	for _, item := range list {
+		item.AscribeContent = mapGetCompanyAscribeContent[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
+		item.Content = mapContent[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
+		item.IsShowNoRenewedNote = mapNoRenewedNote[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
+	}
+
+	listLen := len(list)
+	var companyContractIds []int
+	for i := 0; i < listLen; i++ {
+		item := list[i]
+
+		//剩余可用天数
+		expireDay := "0"
+		endDateTime, _ := time.Parse(utils.FormatDate, item.EndDate)
+		var sub time.Duration
+		if dataType != "未续约客户" {
+			endDateTime = endDateTime.AddDate(0, 0, 1)
+			sub = endDateTime.Sub(time.Now())
+			//if sub < 0 {
+			//	sub = 0
+			//}
+		} else {
+			sub = time.Now().Sub(endDateTime)
+		}
+		expireDay = fmt.Sprintf("%v", int(sub.Hours()/24))
+		list[i].ExpireDay = expireDay
+		companyContractIds = append(companyContractIds, item.CompanyContractId)
+	}
+
+	//合并合同所对应的权限
+	mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(companyContractIds)
+	if err != nil {
+		return
+	}
+	for _, v := range list {
+		v.PermissionName = mappermissionName[v.CompanyContractId]
+	}
+
+	var stackCompanyStatisticList []*models.StackCompanyStatisticList
+	for _, v := range list {
+		stackCompanyStatistic := models.StackCompanyStatisticList{
+			Type:        dataType,
+			CompanyId:   v.CompanyId,
+			CompanyName: v.CompanyName,
+			ProductId:   v.ProductId,
+			ProductName: v.ProductName,
+			ContractNum: v.Count,
+			SellerId:    v.SellerId,
+			SellerName:  v.SellerNameInit,
+			ShareSeller: v.ShareSellerInit,
+			Date:        today,
+			StartDate:   v.StartDate,
+			EndDate:     v.EndDate,
+			RegionType:  v.RegionType,
+			//CreateTime   :v.CreateTime,
+			CreateTimeStr:       v.CreateTime,
+			ExpireDay:           v.ExpireDay,
+			RenewalReason:       v.RenewalReason,
+			RenewalTodo:         v.RenewalTodo,
+			Status:              v.Status,
+			PackageDifference:   v.PackageDifference,
+			AscribeContent:      v.AscribeContent,
+			IsShowNoRenewedNote: v.IsShowNoRenewedNote,
+			Content:             v.Content,
+			PermissionName:      mappermissionName[v.CompanyContractId],
+			Money:               v.Money,
+			IsUserMaker:         mapIsUserMaker[v.CompanyId],
+		}
+		stackCompanyStatisticList = append(stackCompanyStatisticList, &stackCompanyStatistic)
+	}
+	page := paging.GetPaging(currentIndex, pageSize, dataTotal)
+	resp := response.StackCompanyListResp{
+		Paging:                 page,
+		List:                   stackCompanyStatisticList,
+		NewCompanyTotal:        newCompanyTotal,
+		RenewalCompanyTotal:    renewalCompanyTotal,
+		NotRenewalCompanyTotal: notRenewalCompanyTotal,
+		NotRenewalTryOut:       notRenewalTryOut,
+		NotRenewalNotTryOut:    notRenewalNotTryOut,
+	}
+	return resp, err
+}

+ 4 - 0
models/business_trip/business_apply.go

@@ -28,6 +28,7 @@ type BusinessApply struct {
 	CloseTime       time.Time `description:"关闭时间"`
 	CreateTime      time.Time `description:"创建时间"`
 	ModifyTime      time.Time `description:"修改时间"`
+	Itinerary       string    `description:"行程说明"`
 }
 
 // 添加出差申请
@@ -49,6 +50,7 @@ type BusinessApplyReq struct {
 	Transportation string `description:"交通工具"`
 	PeerPeopleId   string `description:"同行人id"`
 	PeerPeopleName string `description:"同行人"`
+	Itinerary      string `description:"行程说明"`
 }
 
 type BusinessApplyView struct {
@@ -73,6 +75,7 @@ type BusinessApplyView struct {
 	ModifyTime      string `description:"修改时间"`
 	IsClose         bool   `description:"true,可关闭,false,不可关闭"`
 	CloseReason     string `description:"关闭理由"`
+	Itinerary       string `description:"行程说明"`
 }
 
 func GetBusinessApplyListCount(condition string, pars []interface{}) (count int, err error) {
@@ -161,6 +164,7 @@ type BusinessApplyEditReq struct {
 	Transportation  string `description:"交通工具"`
 	PeerPeopleId    string `description:"同行人id"`
 	PeerPeopleName  string `description:"同行人"`
+	Itinerary       string `description:"行程说明"`
 }
 
 func CheckBusinessApplyDateCount(condition string, pars []interface{}) (count int, err error) {

+ 11 - 0
models/company/company_approval.go

@@ -1665,3 +1665,14 @@ GROUP BY
 
 	return
 }
+
+func GetCompanyApprovalList(condition string, pars []interface{}) (items []*CompanyApproval, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM company_approval WHERE 1 = 1  `
+
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 150 - 0
models/company/company_contract.go

@@ -3,6 +3,7 @@ package company
 import (
 	"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"strings"
 	"time"
 )
 
@@ -27,6 +28,14 @@ type CompanyContract struct {
 	PackageType       int       `description:"套餐类型,0:无,1:大套餐,2:小套餐"`
 	RaiPackageType    int       `description:"权益套餐类型: 0-无; 1-70w大套餐; 2-45w大套餐"`
 	RaiContractType   string    `description:"权益合同类型:枚举值:'新签合同','续约合同','补充协议'"`
+	SellerIdInit      int       `description:"销售id"`
+	SellerNameInit    string    `description:"销售名称"`
+	ShareSellerInit   string    `description:"共享销售员"`
+	ShareSellerIdInit int       `description:"共享销售员id"`
+	SellerIdLast      int       `description:"合同到期之前最后所属销售id"`
+	SellerNameLast    string    `description:"合同到期之前最后所属销售名称"`
+	ShareSellerLast   string    `description:"合同到期之前最后所属共享销售员"`
+	ShareSellerIdLast int       `description:"合同到期之前最后所属共享销售员id"`
 }
 
 // 新增客户合同
@@ -287,10 +296,22 @@ func GetCompanyContracDetail(condition string, pars []interface{}) (item *Compan
 	return
 }
 
+// 通过ID获取详情
+func GetCompanyContracList(condition string, pars []interface{}) (items []*CompanyContractResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM company_contract  WHERE 1= 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 type GetCompanyContractDetailResp struct {
 	Detail *CompanyContractResp
 }
 
+type GetCompanyContractDetailListResp struct {
+	List []*CompanyContractResp
+}
+
 // UpdateCompanyContractPackageDifference 更改合同与上一份合同金额对比信息
 func UpdateCompanyContractPackageDifference(packageDifference string, companyContractId int) (err error) {
 	o := orm.NewOrm()
@@ -346,3 +367,132 @@ func GetFirstContractRai(companyId int) (item *CompanyContract, err error) {
 	err = o.Raw(sql, companyId).QueryRow(&item)
 	return
 }
+
+// 更新合同类型
+func UpdateCompanyContractTypeinit16_1_01(share_seller_init string, share_seller_id_init, companyId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company_contract SET share_seller_init = ? , share_seller_id_init = ?  WHERE company_id = ?  AND product_id= 2 `
+	_, err = o.Raw(sql, share_seller_init, share_seller_id_init, companyId).Exec()
+	return
+}
+
+// 更新合同类型
+func UpdateCompanyContractTypeinit16_1_02(seller_name_init string, seller_id_init, company_contract_id int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company_contract SET seller_name_init = ? , seller_id_init = ?  WHERE company_contract_id = ?  AND product_id= 2 `
+	_, err = o.Raw(sql, seller_name_init, seller_id_init, company_contract_id).Exec()
+	return
+}
+
+// 合同未生效更新对应销售的信息
+func UpdateCompanyContractSellerNotEffective(sellerId, shareSellerInit int, sellerName, shareSeller string, companyContractId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company_contract SET seller_id_init = ? , seller_name_init = ? ,                         
+                            share_seller_id_init = ? , share_seller_init = ? ,
+                            seller_id_last = ? , seller_name_last = ? ,                          
+                           share_seller_id_last = ? ,    share_seller_last= ?
+                            WHERE company_contract_id = ?  AND product_id= 2 `
+	_, err = o.Raw(sql, sellerId, sellerName, shareSellerInit, shareSeller, sellerId, sellerName, shareSellerInit, shareSeller, companyContractId).Exec()
+	return
+}
+
+// 合同未到期更新对应销售的信息
+func UpdateCompanyContractSellerUnexpired(sellerId, shareSellerInit int, sellerName, shareSeller string, companyContractId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company_contract SET
+                            seller_id_last = ? , 
+                            seller_name_last = ? , 
+                            share_seller_id_last  = ? , 
+                            share_seller_last= ?  WHERE company_contract_id = ?  AND product_id= 2 `
+	_, err = o.Raw(sql, sellerId, sellerName, shareSellerInit, shareSeller, companyContractId).Exec()
+	return
+}
+
+type CompanyContractRespInit struct {
+	MaxCompanyContractId int
+	CompanyContractId    int       `orm:"column(company_contract_id);pk" description:"客户合同id"`
+	ContractType         string    `description:"合同类型:枚举值:'新签合同','续约合同','补充协议'"`
+	ProductId            int       `description:"产品id"`
+	ProductName          string    `description:"产品名称"`
+	CompanyId            int       `description:"客户id"`
+	CompanyProductId     int       `description:"客户产品id"`
+	ContractCode         string    `description:"合同编码"`
+	StartDate            string    `description:"合同开始时间"`
+	EndDate              string    `description:"合同结束时间"`
+	Money                float64   `description:"合同金额"`
+	PayMethod            string    `description:"支付方式"`
+	PayChannel           string    `description:"支付渠道"`
+	ImgUrl               string    `description:"合同图片,多个用#隔开"`
+	CreateTime           time.Time `description:"合同创建时间"`
+	ModifyTime           time.Time `description:"合同修改时间"`
+	Status               int       `description:"状态"`
+	Source               string    `description:"合同来源,枚举值:上传附件、系统合同,默认上传附件"`
+	PackageType          int       `description:"套餐类型,0:无,1:大套餐,2:小套餐"`
+	RaiPackageType       int       `description:"权益套餐类型: 0-无; 1-70w大套餐; 2-45w大套餐"`
+	PermissionName       string    `description:"权限名"`
+}
+
+// 通过ID获取详情
+func GetCompanyContracListInit(condition string, pars []interface{}) (items []*CompanyContractRespInit, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	MAX( company_contract_id ) AS max_company_contract_id,
+	COUNT(a.company_id) AS cc ,
+	a.* 
+FROM
+	company_contract a
+	JOIN company b ON a.company_id = b.company_id
+	JOIN company_product c ON a.company_id = c.company_id 
+	AND a.product_id = c.product_id 
+WHERE
+	1 = 1 -- 		AND b.company_name LIKE "%上海亘%"
+	
+	AND c.product_id = 2 -- 		AND b.company_name LIKE "%上海亘%"
+	
+	AND c.product_id = 2 
+	AND a.not_renewal_hide = 0 
+	AND a.STATUS = 1 
+	AND c.STATUS NOT IN ( "永续", "正式", "关闭" ) 
+	
+	AND a.company_contract_id  NOT IN (SELECT company_contract_id FROM company_contract_no_renewed_ascribe )
+GROUP BY
+	a.company_id
+ ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// 通过ID获取详情
+func GetCompanyContracListInit_CRM_16_1(condition string, pars []interface{}) (items []*CompanyContractRespInit, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	a.* 
+FROM
+	company_contract a
+	JOIN company b ON a.company_id = b.company_id
+	JOIN company_product c ON a.company_id = c.company_id 
+	AND a.product_id = c.product_id 
+WHERE
+	1 = 1 -- 		AND b.company_name LIKE "%上海亘%"
+	
+	AND c.product_id = 2 -- 		AND b.company_name LIKE "%上海亘%"
+	
+	AND c.product_id = 2 
+	AND a.not_renewal_hide = 0 
+	AND a.STATUS = 1 
+	AND c.STATUS NOT IN ( "永续", "正式", "关闭" ) 
+
+	AND a.company_contract_id  NOT IN (SELECT company_contract_id FROM company_contract_no_renewed_ascribe )
+ ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// 合同未生效更新对应销售的信息
+func UpdateCompanyContracthide(companyContractId []string) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company_contract SET not_renewal_hide = 1                                
+                            WHERE company_contract_id  IN  (` + strings.Join(companyContractId, ",") + `) `
+	_, err = o.Raw(sql).Exec()
+	return
+}

+ 9 - 2
models/company/company_operation_record.go

@@ -40,7 +40,7 @@ type CompanyOperationRecordList struct {
 	ProductName         string
 }
 
-//新增客户操作记录
+// 新增客户操作记录
 func AddCompanyOperationRecord(item *CompanyOperationRecord) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
@@ -59,7 +59,7 @@ type CompanyOperationRecordListResp struct {
 	ShowButton bool
 }
 
-//获取客户正式转试用的次数
+// 获取客户正式转试用的次数
 func GetCompanyProductOperationRecordCount(companyId, productId int) (total int64, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT count(1) ct FROM company_operation_record 
@@ -88,3 +88,10 @@ func GetTryOutCompanyOperationRecordList() (list []*CompanyOperationRecord, err
 	_, err = o.Raw(sql).QueryRows(&list)
 	return
 }
+
+func GetCompanyOperationRecordListinitcrm16_1() (items []*CompanyOperationRecord, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT  * FROM company_operation_record WHERE  product_id =2 AND operation = 'add'     `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 33 - 0
models/company/company_product.go

@@ -62,6 +62,8 @@ type CompanyProduct struct {
 	ShareSellerId       int       `description:"共享销售员id"`
 	ShareGroupId        int       `description:"共享销售员所属分组ID"`
 	IsUserMaker         int       `description:"近四周之内是否包含决策人互动过 ,0否,1是"`
+	SellerIdInit        int       `description:"初始化所属销售id"`
+	SellerNameInit      string    `description:"初始化所属销售名称"`
 }
 
 // 新增客户产品
@@ -701,3 +703,34 @@ func UpdateSharGroupid(sharGroupid, shareSellerId int) (err error) {
 	_, err = o.Raw(sql, sharGroupid, shareSellerId).Exec()
 	return
 }
+
+// 更新公司初始化销售
+func UpdateCompanyProductsellerInit(seller_id_init int, seller_name_init string, companyId, productId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company_product SET seller_id_init=? , seller_name_init = ? WHERE company_id=? AND product_id=? `
+	_, err = o.Raw(sql, seller_id_init, seller_name_init, companyId, productId).Exec()
+	return
+}
+
+// 合同未到期更新对应销售的信息
+func UpdateCompanyProductSellerUnexpired(sellerId, shareSellerInit int, sellerName, shareSeller string, companyId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company_product SET
+                            seller_id_last = ? , 
+                            seller_name_last = ? , 
+                            share_seller_id_last  = ? , 
+                            share_seller_last = ?  WHERE company_id = ?  AND product_id= 2 `
+	_, err = o.Raw(sql, sellerId, sellerName, shareSellerInit, shareSeller, companyId).Exec()
+	return
+}
+
+// 合同未到期更新对应销售的信息
+func UpdateCompanyProductSellerUnexpiredInitinit16_1_05(sellerId int, sellerName string, companyId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company_product SET
+                            seller_id_last = ? , 
+                            seller_name_last = ? 
+                            WHERE company_id = ?  AND product_id= 2 `
+	_, err = o.Raw(sql, sellerId, sellerName, companyId).Exec()
+	return
+}

+ 1 - 0
models/company/company_user.go

@@ -75,6 +75,7 @@ type CompanyUser struct {
 	MfyxInteractionNum       int       `description:"互动量"`
 	MfyxIsBinding            bool      `description:"买方研选是否绑定"`
 	MfyxBindingTime          string    `description:"买方研选绑定时间"`
+	HaveMoveButton           bool      `description:"是否移动过"`
 }
 
 type CompanyUserListResp struct {

+ 65 - 0
models/company/wx_user_move_log.go

@@ -0,0 +1,65 @@
+package company
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"hongze/hz_crm_api/utils"
+	"time"
+)
+
+// WxUserOpLog 联系人操作日志表
+type WxUserMoveLog struct {
+	Id              int       `orm:"column(id);pk"`
+	UserId          int       `description:"联系人id"`
+	RealName        string    `description:"联系人姓名"`
+	Mobile          string    `description:"当前手机号"`
+	Email           string    `description:"当前邮箱"`
+	CompanyId       int       `description:"当前客户id"`
+	CompanyName     string    `description:"当前客户名称"`
+	SysUserId       int       `description:"操作人ID"`
+	SysUserRealName string    `description:"操作人姓名"`
+	CompanyIdMove   int       `description:"移动后客户id"`
+	CompanyNameMove string    `description:"移动后客户名称"`
+	CreateTime      time.Time `description:"日志创建时间"`
+}
+
+// AddWxUserOpLog 联系人移动日志记录
+func AddWxUserMoveLog(item *WxUserMoveLog) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+// 列表
+func GetWxUserMoveLogListmByMobiles(mobiles []string) (items []*WxUserMoveLog, err error) {
+	lenarr := len(mobiles)
+	if lenarr == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	sql := `SELECT mobile FROM wx_user_move_log   WHERE  mobile	 IN (` + utils.GetOrmInReplace(lenarr) + `)  GROUP BY mobile   `
+	_, err = o.Raw(sql, mobiles).QueryRows(&items)
+	return
+}
+
+// 列表
+func GetWxUserMoveLogListmByMobile(mobile string) (items []*WxUserMoveLog, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM wx_user_move_log   WHERE  mobile	 = ?  ORDER BY   id  ASC    `
+	_, err = o.Raw(sql, mobile).QueryRows(&items)
+	return
+}
+
+type WxUserMoveLogResp struct {
+	UserName        string `description:"联系人姓名"`
+	Mobile          string `description:"手机号"`
+	Email           string `description:"邮箱地址"`
+	CompanyId       int    `description:"当前客户id"`
+	CompanyName     string `description:"当前客户名称"`
+	CompanyIdMove   int    `description:"移动后客户id"`
+	CompanyNameMove string `description:"移动后客户名称"`
+	CreateTime      string `description:"日志创建时间"`
+}
+
+type WxUserMoveLogListResp struct {
+	List []*WxUserMoveLogResp
+}

+ 34 - 0
models/cygx/activity.go

@@ -93,6 +93,7 @@ type ActivityRep struct {
 	BackgroundImg           string                       `description:"封面图片"`
 	ShareImg                string                       `description:"分享图片"`
 	AreaType                int                          `description:"地区,1国内,2海外,默认1"`
+	IsZoom                  int                          `description:"是否是Zoom模版  1是,0否"`
 }
 
 // 活动添加、修改入参
@@ -130,6 +131,7 @@ type ActivityDetail struct {
 	Theme                     string `description:"主题"`
 	Expert                    string `description:"专家"`
 	ActivityName              string `description:"活动名称"`
+	ActivityNameTask          string `description:"活动名称定时任务同步的时候使用"`
 	OnlineParticipation       string `description:"网络参会"`
 	ReportLink                string `description:"报告链接"`
 	City                      string `description:"城市"`
@@ -179,6 +181,7 @@ type ActivityDetail struct {
 	ShareImg                  string                     `description:"分享图片"`
 	TopTime                   int                        `description:"置顶时间"`
 	AreaType                  int                        `description:"地区,1国内,2海外,默认1"`
+	IsZoom                    int                        `description:"是否是Zoom模版  1是,0否"`
 }
 
 type ActivityDetailRep struct {
@@ -252,6 +255,8 @@ type CygxActivity struct {
 	ChartPermissionNameDeputy string    `description:"行业名称"`
 	CancelDeadline            string    `description:"取消报名截止时间"`
 	AreaType                  int       `description:"地区,1国内,2海外,默认1"`
+	IsZoom                    int       `description:"是否是Zoom模版  1是,0否"`
+	MeetingId                 string    `description:"会议ID"`
 }
 
 type CygxActivityEditDetail struct {
@@ -425,6 +430,8 @@ func EditActivity(item *CygxActivity, oldPublishStatus int, industrialActivityIt
 	updateParams["ChartPermissionIdDeputy"] = item.ChartPermissionIdDeputy
 	updateParams["CancelDeadline"] = item.CancelDeadline
 	updateParams["AreaType"] = item.AreaType
+	updateParams["MeetingId"] = item.MeetingId
+	updateParams["IsZoom"] = item.IsZoom
 	//修改活动信息
 	ptrStructOrTableName := "cygx_activity"
 	whereParam := map[string]interface{}{"activity_id": item.ActivityId}
@@ -732,3 +739,30 @@ func UpdateCygxActivityMomentsImg(momentsImg string, activityId int) (err error)
 	_, err = o.Raw(sql, momentsImg, activityId).Exec()
 	return
 }
+
+// UpdateCygxActivityyidongActivityId  ,建立与易董的活动关联
+func UpdateCygxActivityyidongActivityId(yidongActivityId string, activityId int) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := ` UPDATE cygx_activity SET yidong_activity_id_by_cygx = ?  WHERE activity_id=?   `
+	_, err = o.Raw(sql, yidongActivityId, activityId).Exec()
+	return
+}
+
+// UpdateCygxActivitySubmitMeetingByYidong  ,跟易董返回的用户状态修改活动以提交到会状态
+func UpdateCygxActivitySubmitMeetingByYidong(yidongActivityId string) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `UPDATE cygx_activity SET is_submit_meeting = 1 WHERE yidong_activity_id=? OR  yidong_activity_id_by_cygx = ? `
+	_, err = o.Raw(sql, yidongActivityId, yidongActivityId).Exec()
+	return
+}
+
+// UpdateCygxActivitySignupisMeetList 批量修改易董的活动,用户已到会
+func UpdateCygxActivitySignupisMeetList(condition string, pars []interface{}) (err error) {
+	if condition == "" {
+		return
+	}
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `UPDATE cygx_activity_signup SET is_meeting=1 WHERE  1= 1 ` + condition
+	_, err = o.Raw(sql, pars).Exec()
+	return
+}

+ 13 - 8
models/cygx/activity_attendance_detail.go

@@ -97,11 +97,16 @@ func AddAttendancDetail(items []*CygxActivityAttendanceDetail, activityId int, m
 		return
 	}
 	//插入提交信息
-	for _, v := range items {
-		_, err = to.Insert(v)
-		if err != nil {
-			return
-		}
+	//for _, v := range items {
+	//	_, err = to.Insert(v)
+	//	if err != nil {
+	//		return
+	//	}
+	//}
+
+	_, err = o.InsertMulti(len(items), items)
+	if err != nil {
+		return err
 	}
 	return
 }
@@ -246,10 +251,10 @@ type RoadshowDataTitleResp struct {
 	ActivityId int    `description:"活动ID"`
 }
 
-func GetRoadshowDataTitleList(title string) (list []*RoadshowDataTitle, err error) {
+func GetRoadshowDataTitleList(startTime, endTime, title string) (list []*RoadshowDataTitle, err error) {
 	o := orm.NewOrmUsingDB("comein_data")
-	sql := `SELECT roadshow_title, roadshow_begin_time as activity_time  FROM roadshow_data WHERE roadshow_title LIKE '%` + title + `%'  GROUP BY  roadshow_id `
-	_, err = o.Raw(sql).QueryRows(&list)
+	sql := `SELECT roadshow_title, roadshow_begin_time as activity_time  FROM roadshow_data WHERE  roadshow_begin_time > ? AND  roadshow_end_time < ?   AND roadshow_title LIKE '%` + title + `%'  GROUP BY  roadshow_id `
+	_, err = o.Raw(sql, startTime, endTime).QueryRows(&list)
 	return
 }
 

+ 35 - 0
models/cygx/activity_signup_detail.go

@@ -121,3 +121,38 @@ func UpdateActivitySignupDetailMulti(items []*CygxActivitySignupDetail) (err err
 	}
 	return
 }
+
+// UpdateActivitySignupDetailMultiByYiDong 易董批量修改用户报名信息且报名的人
+func UpdateActivitySignupDetailMultiByYiDong(items []*CygxActivitySignupDetail) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	p, err := o.Raw(` UPDATE cygx_activity_signup_detail SET 
+							first_meeting_time = ?,
+							last_meeting_time = ?,
+							meeting_status_str = ?,
+							position = ?,
+							real_name = ?,
+							duration = ?,
+							is_meeting = ?
+							WHERE mobile = ? AND activity_id = ? `).Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		_, err = p.Exec(
+			v.FirstMeetingTime,
+			v.LastMeetingTime,
+			v.MeetingStatusStr,
+			v.Position,
+			v.RealName,
+			v.Duration,
+			v.IsMeeting,
+			v.Mobile, v.ActivityId)
+		if err != nil {
+			return
+		}
+	}
+	return
+}

+ 1 - 0
models/cygx/cygx_user.go

@@ -52,6 +52,7 @@ type CygxCompanyUser struct {
 	IsRemind                    bool   `description:"是否添加互动提醒"`
 	IsSubscribeCygx             int    `description:"是否关注了查研观向微信公众号: 0-未关注; 1-已关注"`
 	IsUserMaker                 int    `description:"近四周之内是否包含决策人互动过 ,0否,1是"`
+	HaveMoveButton              bool   `description:"是否移动过"`
 }
 
 type CompanyUserListResp struct {

+ 1 - 23
models/cygx/cygx_user_company.go

@@ -840,7 +840,7 @@ func GetCygxRoadshowByCompanyList(condition string, startSize, pageSize int) (it
 func GetCompanyInteractionTableCountBytime(companyId int, startDate, endDate string) (item *GetUserInteractionTableCountResp, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
 	sql := `SELECT
-			( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h  INNER JOIN cygx_article  as art  ON  art.article_id = h.article_id  WHERE h.company_id = ? AND h.is_del = 0  	AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `'   AND h.create_time < date_format(now(),'%Y-%m-%d')  ) AS history_num,
+			( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h  INNER JOIN cygx_article  as art  ON  art.article_id = h.article_id  WHERE h.company_id = ? AND h.is_del = 0  	AND h.create_time BETWEEN '` + startDate + `'AND '` + endDate + `'   AND h.create_time < date_format(now(),'%Y-%m-%d')  ) AS history_num,
 			( SELECT COUNT( 1 ) FROM cygx_article_collect AS h WHERE h.company_id = ?  AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `'  AND h.create_time < date_format(now(),'%Y-%m-%d') ) AS count_num,
 			( SELECT COUNT( 1 ) FROM cygx_chart_collect AS h WHERE h.company_id = ?  AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `'  AND h.create_time < date_format(now(),'%Y-%m-%d') ) AS chart_num,
 			( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h WHERE h.company_id = ? AND h.type = 1  AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `'   AND h.create_time < date_format(now(),'%Y-%m-%d') ) AS industry_fllow_num,
@@ -856,28 +856,6 @@ func GetCompanyInteractionTableCountBytime(companyId int, startDate, endDate str
 	return
 }
 
-// 根据时间获取机构互动总数统计
-func GetCompanyInteractionTableCountBytimeold(companyId int, startDate, endDate string) (item *GetUserInteractionTableCountResp, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT
-			( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h  INNER JOIN cygx_article  as art  ON  art.article_id = h.article_id  WHERE h.company_id = u.company_id AND h.is_del = 0  	AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `'   AND h.create_time < date_format(now(),'%Y-%m-%d')  ) AS history_num,
-			( SELECT COUNT( 1 ) FROM cygx_article_collect AS h WHERE h.company_id = u.company_id  AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `'  AND h.create_time < date_format(now(),'%Y-%m-%d') ) AS count_num,
-			( SELECT COUNT( 1 ) FROM cygx_chart_collect AS h WHERE h.company_id = u.company_id  AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `'  AND h.create_time < date_format(now(),'%Y-%m-%d') ) AS chart_num,
-			( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h WHERE h.company_id = u.company_id AND h.type = 1  AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `'   AND h.create_time < date_format(now(),'%Y-%m-%d') ) AS industry_fllow_num,
-			( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.company_id = u.company_id  AND h.type = 1 AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `'   AND h.create_time < date_format(now(),'%Y-%m-%d') ) AS department_follow_num,
-			( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.company_id = u.company_id AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `'  AND h.create_time < date_format(now(),'%Y-%m-%d') ) AS key_word_num,
-			( SELECT 	COUNT( DISTINCT a.activity_id )  as count  FROM cygx_activity_signup AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.company_id = u.company_id  
-					 AND t.activity_type=1 AND h.do_fail_type = 0 AND a.activity_time BETWEEN '` + startDate + `'AND '` + endDate + `'   AND h.create_time < date_format(now(),'%Y-%m-%d') ) AS on_line_num,
-			( SELECT  	COUNT( DISTINCT a.activity_id )  as count  FROM cygx_activity_signup AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.company_id = u.company_id  
-					 AND t.activity_type = 0 AND h.do_fail_type = 0  AND a.activity_time BETWEEN '` + startDate + `'AND '` + endDate + `'  AND h.create_time < date_format(now(),'%Y-%m-%d') ) AS office_num
-		FROM
-			company  as u
-		WHERE
-			u.company_id = ?`
-	err = o.Raw(sql, companyId).QueryRow(&item)
-	return
-}
-
 // 机构阅读记录列表
 func GetCygxArticleHistoryRecordByCompanyList(condition string, startSize, pageSize int) (items []*UserInteraction, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")

+ 1 - 3
models/cygx/gushou_time_line_history.go

@@ -2,8 +2,6 @@ package cygx
 
 import (
 	"github.com/beego/beego/v2/client/orm"
-	"hongze/hz_crm_api/utils"
-	"strconv"
 	"time"
 )
 
@@ -25,7 +23,7 @@ type CygxGushouTimeLineHistory struct {
 func GetCygxGushouTimeLineHistoryList(condition string, pars []interface{}) (items []*CygxGushouTimeLineHistory, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
 	sql := `SELECT * FROM cygx_gushou_time_line_history as art WHERE 1= 1 `
-	condition += `  AND company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则来源
+	//condition += `  AND company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则来源
 	if condition != "" {
 		sql += condition
 	}

+ 1 - 0
models/cygx/industrial_subject.go

@@ -230,6 +230,7 @@ type CygxIndustrialSubjectListRep struct {
 	IndustrialManagementId int    `description:"产业id"`
 	SubjectName            string `description:"标的名称"`
 	IndustryName           string `description:"分析师名称"`
+	ShowName               string `description:"产业与标的展示名称"`
 }
 
 type CygxIndustrialSubjectList struct {

+ 12 - 1
models/cygx/report_article.go

@@ -32,6 +32,7 @@ type CygxReportArticleID struct {
 }
 
 type CygxReportArticle struct {
+	Id                int    `description:"主键ID"`
 	ReportId          int    `description:"报告id"`
 	ArticleId         int    `description:"文章id"`
 	Title             string `description:"标题"`
@@ -1045,7 +1046,17 @@ WHERE
 // 列表
 func GetArticleRoadshowEssenceList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResearchSummaryRep, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sql := `SELECT *,
+	sql := `SELECT 
+    			article_id,
+				title,
+				department,
+				abstract,
+				publish_status,
+				publish_date,
+				last_updated_time,
+				periods,
+				have_publish,
+				visible_range,
 				(SELECT COUNT(1) FROM cygx_article_history_record AS h WHERE h.article_id=art.article_id) AS pv,
         		(SELECT COUNT(DISTINCT user_id) FROM cygx_article_history_record AS h WHERE h.article_id=art.article_id) AS uv
 				FROM cygx_article as art WHERE 1= 1 `

+ 1 - 1
models/cygx/report_selection.go

@@ -310,7 +310,7 @@ func GetReportSelectionListPeriods(condition string, pars []interface{}, startSi
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` ORDER BY  rs.periods  DESC    LIMIT ?,?`
+	sql += `  ORDER BY  rs.periods  DESC    LIMIT ?,?`
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }

+ 63 - 51
models/cygx/report_selection_log.go

@@ -6,18 +6,21 @@ import (
 )
 
 type CygxReportSelectionLog struct {
-	ArticleSunId           int       `orm:"column(article_sun_id);pk"description:"子级报告id"`
-	ArticleId              int       `description:"父级报告Id"`
-	ChartPermissionId      int       `description:"行业ID"`
-	CreateTime             time.Time `description:"创建时间"`
-	Body                   string    `description:"内容"`
-	IndustrialSubjectId    string    `description:"标的ID"`
-	SubjectName            string    `description:"标的名称"`
-	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
-	CompanyLabel           string    `description:"公司标签多个用{|}隔开"`
-	OverviewArticleId      int       `description:"关联的综述报告ID"`
-	IsNew                  int       `description:"是否为New标签"`
-	IsShowOverviewArticle  int       `description:"是否展示综述报告 1展示,0隐藏"`
+	ArticleSunId              int       `orm:"column(article_sun_id);pk"description:"子级报告id"`
+	ArticleId                 int       `description:"父级报告Id"`
+	ChartPermissionId         int       `description:"行业ID"`
+	CreateTime                time.Time `description:"创建时间"`
+	Body                      string    `description:"内容"`
+	IndustrialSubjectId       string    `description:"标的ID"`
+	SubjectName               string    `description:"标的名称"`
+	IndustrialManagementId    string    `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementNames string    `description:"产业资源包名称  多个用 , 隔开"`
+	CompanyLabel              string    `description:"公司标签多个用{|}隔开"`
+	OverviewArticleId         int       `description:"关联的综述报告ID"`
+	IsNew                     int       `description:"是否为New标签"`
+	IsShowOverviewArticle     int       `description:"是否展示综述报告 1展示,0隐藏"`
+	ThirdId                   string    `description:"类似产业、标的的三方ID"`
+	ThirdName                 string    `description:"类似产业、标的的三方名称"`
 }
 
 type CygxReportSelectionLogRep struct {
@@ -31,35 +34,42 @@ type CygxReportSelectionLogRep struct {
 }
 
 type AddCygxReportSelectionLog struct {
-	ChartPermissionId        int      `description:"行业ID"`
-	IndustrialSubjectId      string   `description:"标的ID"`
-	SubjectName              string   `description:"标的名称"`
-	IndustrialSubjectName    string   `description:"标的ID"`
-	Body                     string   `description:"内容"`
-	IndustrialManagementId   string   `description:"产业资源包Id  多个用 , 隔开"`
-	IndustrialManagementName string   `description:"产业资源包Id  多个用 , 隔开"`
-	CompanyLabel             []string `description:"公司标签"`
-	Label                    string   `description:"公司标签"`
-	OverviewArticleId        int      `description:"综述报告Id"`
-	IsNew                    int      `description:"是否为New标签"`
-	IsShowOverviewArticle    int      `description:"是否展示综述报告 1展示,0隐藏"`
+	ChartPermissionId         int      `description:"行业ID"`
+	IndustrialSubjectId       string   `description:"标的ID"`
+	SubjectName               string   `description:"标的名称"`
+	IndustrialSubjectName     string   `description:"标的ID"`
+	Body                      string   `description:"内容"`
+	IndustrialManagementId    string   `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementName  string   `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementNames string   `description:"产业资源包Id  多个用 , 隔开"`
+	CompanyLabel              []string `description:"公司标签"`
+	Label                     string   `description:"公司标签"`
+	OverviewArticleId         int      `description:"综述报告Id"`
+	IsNew                     int      `description:"是否为New标签"`
+	IsShowOverviewArticle     int      `description:"是否展示综述报告 1展示,0隐藏"`
+	ThirdId                   string   `description:"类似产业、标的的三方ID"`
+	ThirdName                 string   `description:"类似产业、标的的三方名称"`
 }
 
 type CygxReportSelectionLogResp struct {
-	ChartPermissionId        int      `description:"行业ID"`
-	IndustrialSubjectId      string   `description:"标的ID"`
-	SubjectName              string   `description:"标的名称"`
-	IndustrialSubjectName    string   `description:"标的ID"`
-	Body                     string   `description:"内容"`
-	IndustrialManagementId   string   `description:"产业资源包Id  多个用 , 隔开"`
-	IndustrialManagementName string   `description:"产业资源包Id  多个用 , 隔开"`
-	CompanyLabel             []string `description:"公司标签"`
-	Label                    string   `description:"公司标签"`
-	OverviewArticleId        int      `description:"综述报告Id"`
-	OverviewArticleTitle     string   `description:"综述报告标题"`
-	IsNew                    int      `description:"是否为New标签"`
-	IsShowOverviewArticle    int      `description:"是否展示综述报告 1展示,0隐藏"`
-	ChartPermissionSort      int      `description:"品种排序"`
+	ChartPermissionId         int      `description:"行业ID"`
+	IndustrialSubjectId       string   `description:"标的ID"`
+	SubjectName               string   `description:"标的名称"`
+	ShowName                  string   `description:"产业与标的展示名称"`
+	IndustrialSubjectName     string   `description:"标的ID"`
+	Body                      string   `description:"内容"`
+	IndustrialManagementId    string   `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementName  string   `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementNames string   `description:"产业资源包Id  多个用 , 隔开"`
+	CompanyLabel              []string `description:"公司标签"`
+	Label                     string   `description:"公司标签"`
+	OverviewArticleId         int      `description:"综述报告Id"`
+	OverviewArticleTitle      string   `description:"综述报告标题"`
+	IsNew                     int      `description:"是否为New标签"`
+	IsShowOverviewArticle     int      `description:"是否展示综述报告 1展示,0隐藏"`
+	ChartPermissionSort       int      `description:"品种排序"`
+	ThirdId                   string   `description:"类似产业、标的的三方ID"`
+	ThirdName                 string   `description:"类似产业、标的的三方名称"`
 }
 
 type CygxReportSelectionChart struct {
@@ -92,18 +102,21 @@ func GetCygxReportSelectionSjdpList(articleId int, typeStr string) (items []*Cyg
 }
 
 type CygxReportSelectionLoglist struct {
-	ArticleSunId           int       `description:"子级报告id"`
-	ArticleId              int       `description:"父级报告Id"`
-	ChartPermissionId      int       `description:"行业ID"`
-	PermissionName         string    `description:"行业ID"`
-	CreateTime             time.Time `description:"创建时间"`
-	Body                   string    `description:"内容"`
-	IndustrialSubjectId    string    `description:"标的ID"`
-	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
-	SubjectName            string    `description:"标的名称"`
-	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
-	OverviewArticleId      int       `description:"关联的综述报告ID"`
-	IsNew                  int       `description:"是否为New标签"`
+	ArticleSunId              int       `description:"子级报告id"`
+	ArticleId                 int       `description:"父级报告Id"`
+	ChartPermissionId         int       `description:"行业ID"`
+	PermissionName            string    `description:"行业ID"`
+	CreateTime                time.Time `description:"创建时间"`
+	Body                      string    `description:"内容"`
+	IndustrialSubjectId       string    `description:"标的ID"`
+	IndustrialManagementId    string    `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementNames string    `description:"产业资源包名称  多个用 , 隔开"`
+	SubjectName               string    `description:"标的名称"`
+	ThirdId                   int       `description:"类似产业、标的的三方ID"`
+	ThirdName                 string    `description:"类似产业、标的的三方名称"`
+	IcoLink                   string    `orm:"column(image_url)"description:"图标链接"`
+	OverviewArticleId         int       `description:"关联的综述报告ID"`
+	IsNew                     int       `description:"是否为New标签"`
 }
 
 // 列表
@@ -112,7 +125,6 @@ func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLo
 	sql := `SELECT  l.* 
 			FROM
 			cygx_report_selection_log AS l
-			INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id 
 			WHERE l.article_id = ? `
 	_, err = o.Raw(sql, articleId).QueryRows(&items)
 	return

+ 12 - 10
models/cygx/report_selection_subject_history.go

@@ -6,16 +6,18 @@ import (
 )
 
 type CygxReportSelectionSubjectHistory struct {
-	Id                  int       `orm:"column(id);pk"`
-	ArticleId           int       `description:"文章ID"`
-	UserId              int       `description:"用户ID"`
-	CreateTime          time.Time `description:"创建时间"`
-	ModifyTime          time.Time `description:"修改时间"`
-	Mobile              string    `description:"手机号"`
-	Email               string    `description:"邮箱"`
-	CompanyId           int       `description:"公司id"`
-	CompanyName         string    `description:"公司名称"`
-	IndustrialSubjectId string    `description:"标的ID"`
+	Id                     int       `orm:"column(id);pk"`
+	ArticleId              int       `description:"文章ID"`
+	UserId                 int       `description:"用户ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	ModifyTime             time.Time `description:"修改时间"`
+	Mobile                 string    `description:"手机号"`
+	Email                  string    `description:"邮箱"`
+	CompanyId              int       `description:"公司id"`
+	CompanyName            string    `description:"公司名称"`
+	IndustrialSubjectId    string    `description:"标的ID"`
+	IndustrialManagementId int       `description:"产业ID"`
+	ThirdId                int       `description:"类似产业、标的的三方ID"`
 }
 
 // 列表

+ 33 - 0
models/cygx/report_selection_third_name.go

@@ -0,0 +1,33 @@
+package cygx
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+//重点公司三方名称 类似产业、标的的三方名称
+
+type CygxReportSelectionThirdName struct {
+	ThirdId             int       `orm:"column(third_id);pk"description:"类似产业、标的的三方ID"`
+	ThirdName           string    `description:"类似产业、标的的三方名称"`
+	ChartPermissionId   int       `description:"行业ID"`
+	ChartPermissionName string    `description:"行业名称"`
+	CreateTime          time.Time `description:"创建时间"`
+}
+
+type AddReportSelectionThirdNameReq struct {
+	ThirdName         string `description:"类似产业、标的的三方名称"`
+	ChartPermissionId int    `description:"行业ID"`
+}
+
+type AddReportSelectionThirdNameResp struct {
+	ThirdName string `description:"类似产业、标的的三方名称"`
+	ThirdId   string `description:"类似产业、标的的三方ID"`
+}
+
+// 添加
+func AddCygxReportSelectionThirdName(item *CygxReportSelectionThirdName) (lastId int64, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	lastId, err = o.Insert(item)
+	return
+}

+ 3 - 0
models/db.go

@@ -269,6 +269,7 @@ func initCompany() {
 		new(company.CrmConfig),                               // 管理后台基本配置表
 		new(company.CompanyRenewalRecord),                    // 客户续约状态记录表
 		new(company.CompanyHistoryRemark),                    // 客户记录历史记录表
+		new(company.WxUserMoveLog),                           // 客户联系人移动记录日志表
 	)
 }
 
@@ -386,6 +387,7 @@ func initRoadShow() {
 		new(roadshow.RsReportRecord),              //路演统计表
 		new(roadshow.RsCalendarMeetingUser),       //路演参会名单表
 		new(roadshow.RsCalendarMeetingLabelGroup), //路演参会名单关联的标签表
+		new(roadshow.RsCalendarApiLog),            //上海路演三方接口请求记录日志表
 	)
 }
 
@@ -485,6 +487,7 @@ func initCygx() {
 		new(cygx.CygxOrder),
 		new(cygx.CygxOrderAction),
 		new(cygx.CygxUserFeedback),
+		new(cygx.CygxReportSelectionThirdName),
 		new(cygx.CygxGushouTimeLine),
 	)
 }

+ 9 - 0
models/response/statistic_report.go

@@ -143,3 +143,12 @@ type IncrementalCompanyPercentageListResp struct {
 	ExpireRenewalContractTotal int    `description:"到期合同数量"`
 	ExpireRenewalContractMoney int    `description:"到期合同总金额"`
 }
+
+// 权益客户统计,续约率,返回类
+type IncrementalCompanyPercentageExportResp struct {
+	NoRenewalContractTotal      int    `description:"确认不续约合同数"`
+	NoRenewalContractMoney      int    `description:"确认不续约合同金额"`
+	ExpireRenewalContractTotal  int    `description:"到期合同数量"`
+	ExpireRenewalContractMoney  int    `description:"到期合同总金额"`
+	NoRenewalContractPercentage string `description:"确认不续约率"`
+}

+ 35 - 0
models/roadshow/rs_calendar_api_log.go

@@ -0,0 +1,35 @@
+package roadshow
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type RsCalendarApiLog struct {
+	Id                     int       `orm:"column(id);pk"`
+	Url                    string    `description:"链接"`
+	Body                   string    `description:"请求参数"`
+	Result                 string    `description:"返回参数"`
+	CreateTime             time.Time `description:"创建时间"`
+	Remark                 string    `description:"备注说明"`
+	RsCalendarResearcherId int       `description:"表rs_calendar_researcher 主键ID"`
+	RsCalendarId           int       `description:"日历活动id"`
+}
+
+// 添加日志记录
+func AddRsCalendarApiLog(item *RsCalendarApiLog) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 批量添加
+func AddRsCalendarApiLogList(items []*RsCalendarApiLog) (lastId int64, err error) {
+	lenitems := len(items)
+	if lenitems == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	_, err = o.InsertMulti(lenitems, items)
+	return
+}

+ 31 - 29
models/seal/request/seal_approval.go

@@ -2,56 +2,58 @@ package request
 
 // 用印审批申请请求
 type SealApprovalApplyReq struct {
-	ContractId     int      `description:"系统合同id"`
-	Use            string   `description:"用印用途,枚举值:'销售合同','渠道合同','付款通知函','招投标','战略合作协议','代付合同','总对总协议';默认:销售合同"`
-	CompanyName    string   `description:"客户名称,甲方名称,长度32位"`
-	UseCompanyName string   `description:"实际适用方客户名称,长度32位"`
-	CreditCode     string   `description:"社会统一信用代码,长度64位"`
-	ServiceType    string   `description:"业务类型,枚举值:'新签合同','续约合同','补充协议';默认:新签合同"`
-	SealType       string   `description:"加盖印章类型,多选,逗号拼接,值:'合同章','公章','法人章'"`
-	Remark         string   `description:"备注,长度255位"`
-	FileUrls       []string `description:"多个文件附件地址"`
-	FileNum        int      `description:"文件份数"`
+	ContractId        int      `description:"系统合同id"`
+	Use               string   `description:"用印用途,枚举值:'销售合同','渠道合同','付款通知函','招投标','战略合作协议','代付合同','总对总协议';默认:销售合同"`
+	CompanyName       string   `description:"客户名称,甲方名称,长度32位"`
+	UseCompanyName    string   `description:"实际适用方客户名称,长度32位"`
+	CreditCode        string   `description:"社会统一信用代码,长度64位"`
+	ServiceType       string   `description:"业务类型,枚举值:'新签合同','续约合同','补充协议';默认:新签合同"`
+	SealType          string   `description:"加盖印章类型,多选,逗号拼接,值:'合同章','公章','法人章'"`
+	Remark            string   `description:"备注,长度255位"`
+	FileUrls          []string `description:"多个文件附件地址"`
+	FileNum           int      `description:"文件份数"`
+	AffiliatedCompany string   `description:"归属公司"`
 }
 
 // 用印审批编辑请求
 type SealApprovalEditReq struct {
-	SealId         int      `description:"用印id"`
-	ContractId     int      `description:"系统合同id"`
-	Use            string   `description:"用印用途,枚举值:'销售合同', '渠道合同', '付款通知函', '招投标', '战略合作协议';默认:销售合同"`
-	CompanyName    string   `description:"客户名称,甲方名称,长度32位"`
-	UseCompanyName string   `description:"实际适用方客户名称,长度32位"`
-	CreditCode     string   `description:"社会统一信用代码,长度64位"`
-	ServiceType    string   `description:"业务类型,枚举值:'新签合同','续约合同','补充协议';默认:新签合同"`
-	SealType       string   `description:"加盖印章类型,多选,逗号拼接,值:'合同章','公章','法人章'"`
-	Remark         string   `description:"备注,长度255位"`
-	FileUrls       []string `description:"多个文件附件地址"`
-	FileNum        int      `description:"文件份数"`
+	SealId            int      `description:"用印id"`
+	ContractId        int      `description:"系统合同id"`
+	Use               string   `description:"用印用途,枚举值:'销售合同', '渠道合同', '付款通知函', '招投标', '战略合作协议';默认:销售合同"`
+	CompanyName       string   `description:"客户名称,甲方名称,长度32位"`
+	UseCompanyName    string   `description:"实际适用方客户名称,长度32位"`
+	CreditCode        string   `description:"社会统一信用代码,长度64位"`
+	ServiceType       string   `description:"业务类型,枚举值:'新签合同','续约合同','补充协议';默认:新签合同"`
+	SealType          string   `description:"加盖印章类型,多选,逗号拼接,值:'合同章','公章','法人章'"`
+	Remark            string   `description:"备注,长度255位"`
+	FileUrls          []string `description:"多个文件附件地址"`
+	FileNum           int      `description:"文件份数"`
+	AffiliatedCompany string   `description:"归属公司"`
 }
 
 // 用印审批撤回请求
 type SealApprovalCancelReq struct {
-	SealId		int		`description:"用印ID"`
+	SealId int `description:"用印ID"`
 }
 
 // 用印审批删除请求
 type SealApprovalDelReq struct {
-	SealId		int		`description:"用印ID"`
+	SealId int `description:"用印ID"`
 }
 
 // 用印审批作废请求
 type SealApprovalInvalidReq struct {
-	SealId		int		`description:"用印ID"`
+	SealId int `description:"用印ID"`
 }
 
 // 用印审批通过请求
 type SealApplyApprovedReq struct {
-	SealId	int		`description:"用印id"`
-	Remark	string 	`description:"备注字段"`
+	SealId int    `description:"用印id"`
+	Remark string `description:"备注字段"`
 }
 
 // 用印审批驳回请求
 type SealApplyRejectReq struct {
-	SealId	int		`description:"用印id"`
-	Remark	string 	`description:"驳回理由"`
-}
+	SealId int    `description:"用印id"`
+	Remark string `description:"驳回理由"`
+}

+ 65 - 1
models/seal/seal.go

@@ -33,6 +33,7 @@ type Seal struct {
 	ModifyTime        time.Time `description:"最近一次修改时间"`
 	CreateTime        time.Time `description:"添加时间"`
 	CheckBackFileTime time.Time `description:"签回用印附件时间"`
+	AffiliatedCompany string    `description:"归属公司"`
 }
 
 var EnumUse = []string{"销售合同", "渠道合同", "付款通知函", "招投标", "战略合作协议", "代付合同", "总对总协议"}
@@ -193,13 +194,14 @@ type SealApprovalItem struct {
 	InvalidTimeStr       string    `description:"作废时间(字符串)"`
 	CheckBackFileTimeStr string    `description:"签回用印附件时间(字符串)"`
 	ContractCode         string    `description:"合同编码"`
+	AffiliatedCompany    string    `description:"归属公司"`
 }
 
 // GetSealApprovalListByWhere 获取用印审批列表-分页
 func GetSealApprovalListByWhere(condition, joinCondition string, pars []interface{}, startSize, pageSize int) (list []*SealApprovalItem, total int, err error) {
 	o := orm.NewOrm()
 	fields := `a.contract_approval_id,c.contract_id,a.apply_content,a.approve_remark,a.apply_user_id,a.apply_user_name,a.curr_node_id,a.start_node_id,c.create_time,a.modify_time,a.status approval_status,
-			   c.status,c.seal_id,c.seal_type,c.service_type contract_type,c.use,c.company_name,c.file_url,c.approve_time,c.invalid_time,c.code,c.credit_code,c.check_back_file_time,c.check_back_file_url`
+			   c.status,c.seal_id,c.seal_type,c.service_type contract_type,c.use,c.company_name,c.file_url,c.approve_time,c.invalid_time,c.code,c.credit_code,c.check_back_file_time,c.check_back_file_url,c.affiliated_company `
 	sql := `SELECT ` + fields + ` from contract_approval a JOIN ( SELECT max( contract_approval_id ) max_id,contract_id FROM contract_approval where 1=1 and approval_type = "seal" `
 	sql += ` GROUP BY contract_id ) b on a.contract_approval_id=b.max_id
 	JOIN seal c ON c.seal_id = a.contract_id 
@@ -217,3 +219,65 @@ WHERE c.is_delete = 0 AND a.approval_type="seal" `
 
 	return
 }
+
+type SealApprovaExportlItem struct {
+	ContractApprovalId       int `description:"审批单ID"`
+	ContractId               int `description:"合同ID"`
+	ContractApprovalRecordId int `description:"审批流ID"`
+	//ContractCode             string                  `description:"合同编号"`
+	Use            string                  `description:"用印用途,枚举值:'销售合同','渠道合同','付款通知函','招投标','战略合作协议'"`
+	ContractType   string                  `description:"合同类型,枚举值:'新签合同','续约合同','补充协议','代付合同'"`
+	Status         string                  `description:"合同状态,枚举值:待审批','已审批','已驳回','已撤回','已签回',默认待审批"`
+	ApproveStatus  string                  `json:"-" description:"审批单状态,枚举值:待审批','已审批','已驳回','已撤回',默认待审批"`
+	ApplyContent   string                  `description:"申请内容"`
+	ApplyUserId    int                     `description:"申请人ID"`
+	ApplyUserName  string                  `description:"申请人名称"`
+	ContractDetail string                  `json:"-" description:"提交审批时的合同信息;用印快照"`
+	ContractInfo   contract.ContractDetail `json:"-" description:"提交审批时的合同信息;用印快照"`
+	ApproveRemark  string                  `description:"审核备注"`
+	SealType       string                  `description:"用印类型"`
+	CompanyName    string                  `description:"客户名称"`
+	FileUrl        string                  `description:"合同下载地址"`
+	CurrNodeId     int                     `description:"当前审批节点id"`
+	StartNodeId    int                     `description:"开始审批节点id"`
+	//UserId                   int                     `description:"申请人id"`
+	//UserName                 string                  `description:"申请人名称"`
+	SealId               int       `description:"用印审批ID"`
+	CreateTime           time.Time `description:"发起审批的时间"`
+	ModifyTime           time.Time `description:"最后一次修改的时间"`
+	ApproveTime          time.Time `description:"审批时间"`
+	InvalidTime          time.Time `description:"作废时间"`
+	CheckBackFileUrl     string    `description:"签回附件地址"`
+	CheckBackFileTime    time.Time `description:"签回用印附件时间"`
+	CreditCode           string    `description:"社会信用码"`
+	CreateTimeStr        string    `description:"发起审批的时间(字符串)"`
+	ModifyTimeStr        string    `description:"最后一次修改的时间(字符串)"`
+	ApproveTimeStr       string    `description:"审批时间(字符串)"`
+	InvalidTimeStr       string    `description:"作废时间(字符串)"`
+	CheckBackFileTimeStr string    `description:"签回用印附件时间(字符串)"`
+	ContractCode         string    `description:"合同编码"`
+	AffiliatedCompany    string    `description:"归属公司"`
+	FirstLevelApprovers  string    `description:"一级审批人"`
+	SecondLevelApprovers string    `description:"二级审批人"`
+	ThirdLevelApprovers  string    `description:"三级审批人"`
+	FirstLevelCC         string    `description:"一级抄送人"`
+	SecondLevelCC        string    `description:"二级抄送人"`
+	ThirdLevelCC         string    `description:"三级抄送人"`
+}
+
+// GetSealApprovalList 获取用印审批列表
+func GetSealApprovalList(condition, joinCondition string, pars []interface{}) (list []*SealApprovaExportlItem, err error) {
+	o := orm.NewOrm()
+	fields := `a.contract_approval_id,c.contract_id,a.apply_content,a.approve_remark,a.apply_user_id,a.apply_user_name,a.curr_node_id,a.start_node_id,c.create_time,a.modify_time,a.status approval_status,
+			   c.status,c.seal_id,c.seal_type,c.service_type contract_type,c.use,c.company_name,c.file_url,c.approve_time,c.invalid_time,c.code,c.credit_code,c.check_back_file_time,c.check_back_file_url,c.affiliated_company `
+	sql := `SELECT ` + fields + ` from contract_approval a JOIN ( SELECT max( contract_approval_id ) max_id,contract_id FROM contract_approval where 1=1 and approval_type = "seal" `
+	sql += ` GROUP BY contract_id ) b on a.contract_approval_id=b.max_id
+	JOIN seal c ON c.seal_id = a.contract_id 
+	JOIN contract_approval_record d on a.contract_approval_id=d.contract_approval_id ` + joinCondition + `
+WHERE c.is_delete = 0 AND a.approval_type="seal" `
+	sql += condition
+	sql += ` group by c.seal_id order by c.create_time desc`
+	_, err = o.Raw(sql, pars).QueryRows(&list)
+
+	return
+}

+ 4 - 0
models/stack_company_statistic.go

@@ -90,6 +90,7 @@ type StackCompanyStatisticList struct {
 	ContractNum         int       `description:"第几份合同,默认是:1"`
 	SellerId            int       `description:"所属销售id"`
 	SellerName          string    `description:"所属销售名称"`
+	ShareSeller         string    `description:"共享销售员"`
 	GroupId             int       `description:"所属销售分组id"`
 	DepartmentId        int       `description:"所属销售部门id"`
 	Date                string    `description:"记录日期"`
@@ -106,6 +107,9 @@ type StackCompanyStatisticList struct {
 	AscribeContent      string    `description:"归因标签说明"`
 	IsShowNoRenewedNote bool      `description:"是否展示未续约备注按钮"`
 	Content             string    `description:"归因内容说明"`
+	PermissionName      string    `description:"权限名"`
+	Money               float64   `description:"合同金额"`
+	IsUserMaker         int       `description:"近四周之内是否包含决策人互动过 ,0否,1是"`
 }
 
 func GetStackCompanyList(condition, orderBy string, pars []interface{}, startSize, pageSize int) (items []*StackCompanyStatisticList, err error) {

+ 39 - 6
models/statistic_report.go

@@ -377,6 +377,7 @@ type IncrementalList struct {
 	CompanyName          string                             `description:"企业客户名称"`
 	ProductId            int                                `description:"产品id"`
 	ProductName          string                             `description:"产品名称"`
+	ProductStatus        string                             `description:"产品名称"`
 	CompanyProductId     int                                `description:"客户购买产品授权id"`
 	ContractCode         string                             `description:"合同编码"`
 	StartDate            string                             `description:"合同开始日期"`
@@ -391,6 +392,7 @@ type IncrementalList struct {
 	RegionType           string                             `description:"企业客户所属区域;可选范围:国内,海外"`
 	SellerId             int                                `description:"归属销售id"`
 	SellerName           string                             `description:"归属销售名称"`
+	ShareSeller          string                             `description:"共享销售员"`
 	ExpireDay            string                             `description:"剩余可用天数"`
 	PermissionList       []*company.CompanyReportPermission `description:"产品权限"`
 	Count                int                                `json:"-" description:"合同数"`
@@ -405,7 +407,10 @@ type IncrementalList struct {
 	PermissionNameStatus string                             `description:"权限状态"`
 	CompanyProductStatus string                             `description:"客户状态"`
 	//CompanyContractIdGroup string                             `description:"表company_contract合并的 company_contract_id"`
-	IsUserMaker int `description:"近四周之内是否包含决策人互动过 ,0否,1是"`
+	IsUserMaker     int    `description:"近四周之内是否包含决策人互动过 ,0否,1是"`
+	SellerNameInit  string `description:"权益初始化销售"`
+	SellerIdInit    int    `description:"权益初始化销售ID"`
+	ShareSellerInit string `description:"共享销售员"`
 }
 
 // GetIncrementalNewCompanyCount 获取增量客户报表列表统计数据(根据合同来展示)
@@ -794,7 +799,36 @@ func GetIncrementalCompanyListByOperationRecord(condition string, pars []interfa
 	sql1 += ` GROUP BY a.company_id, a.product_id `
 
 	//查询真正的数据
-	sql := `SELECT a.id, a.company_id, b.company_name, c.seller_id, c.seller_name, a.product_id, a.product_name, a.create_time, b.region_type, c.renewal_reason, c.renewal_todo, c.status FROM company_operation_record a
+	sql := `SELECT a.id, a.company_id, b.company_name, c.seller_id, c.seller_name, c.seller_name_init, a.product_id, a.product_name, a.create_time, b.region_type, c.renewal_reason, c.renewal_todo, c.status FROM company_operation_record a
+		RIGHT JOIN company b ON a.company_id = b.company_id
+		JOIN company_product c ON b.company_id = c.company_id 
+		AND a.product_id = c.product_id
+where a.id in (` + sql1 + `) order by  create_time DESC,company_id DESC limit ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+// GetIncrementalCompanyListByOperationRecordLast 获取试用客户报表列表数据(根据新增客户时间来展示)
+func GetIncrementalCompanyListByOperationRecordLast(condition string, pars []interface{}, startSize, pageSize int) (items []*IncrementalList, err error) {
+	o := orm.NewOrm()
+	//	sql := `SELECT a.id,a.company_id,b.company_name,c.seller_id,c.seller_name,
+	//a.product_id,a.product_name,a.create_time,b.region_type,c.renewal_reason,c.status FROM company_operation_record a
+	//		RIGHT JOIN company b ON a.company_id = b.company_id
+	//		 JOIN company_product c ON b.company_id = c.company_id and a.product_id=c.product_id WHERE 1 = 1 `
+
+	//查询出最大id
+	sql1 := `SELECT max(id) id FROM company_operation_record a
+		RIGHT JOIN company b ON a.company_id = b.company_id
+		JOIN company_product c ON b.company_id = c.company_id 
+		AND a.product_id = c.product_id 
+	WHERE 1 = 1 `
+	if condition != "" {
+		sql1 += condition
+	}
+	sql1 += ` GROUP BY a.company_id, a.product_id `
+
+	//查询真正的数据
+	sql := `SELECT a.id, a.company_id, b.company_name, c.seller_id_last AS seller_id, c.seller_name_last  AS seller_name_init, c.share_seller_last  AS share_seller, a.product_id, a.product_name, a.create_time, b.region_type, c.renewal_reason, c.renewal_todo, c.status FROM company_operation_record a
 		RIGHT JOIN company b ON a.company_id = b.company_id
 		JOIN company_product c ON b.company_id = c.company_id 
 		AND a.product_id = c.product_id
@@ -863,7 +897,7 @@ func GetLastContractMoney(CompanyIds string) (items []*IncrementalList, err erro
 func GetIncrementalCompanyMergeList(condition string, pars []interface{}, startSize, pageSize int) (items []*IncrementalList, err error) {
 	o := orm.NewOrm()
 
-	sql := `SELECT a.*,b.region_type,c.seller_id,c.seller_name,b.company_name,c.renewal_reason FROM company_contract a
+	sql := `SELECT a.*,b.region_type,c.seller_id,a.seller_name_init as seller_name ,a.share_seller_init as share_seller ,b.company_name,c.renewal_reason FROM company_contract a
 		 JOIN company b ON a.company_id = b.company_id
 		 JOIN company_product c ON a.company_id = c.company_id and a.product_id=c.product_id WHERE 1 = 1 `
 
@@ -879,7 +913,7 @@ func GetIncrementalCompanyMergeList(condition string, pars []interface{}, startS
 func GetIncrementalCompanyMergeListEnd(condition string, pars []interface{}, startSize, pageSize int) (items []*IncrementalList, err error) {
 	o := orm.NewOrm()
 
-	sql := `SELECT a.*,b.region_type,c.seller_id,c.seller_name,b.company_name,c.renewal_reason FROM company_contract a
+	sql := `SELECT a.*,b.region_type,c.seller_id,c.seller_name,b.company_name,c.renewal_reason,c.status AS product_status FROM company_contract a
 		 JOIN company b ON a.company_id = b.company_id
 		 JOIN company_product c ON a.company_id = c.company_id and a.product_id=c.product_id WHERE 1 = 1 `
 
@@ -896,7 +930,7 @@ func GetIncrementalCompanyListByOperationRecordMerge(condition string, pars []in
 	o := orm.NewOrm()
 
 	//查询真正的数据
-	sql := `SELECT a.company_contract_id,a.contract_type ,a.company_product_id ,a.contract_code ,a.pay_method ,a.pay_channel ,a.package_difference ,a.company_id, a.start_date, a.end_date, a.money, b.company_name, c.seller_id, c.seller_name, a.product_id, a.product_name, a.create_time, b.region_type, c.renewal_reason, c.renewal_todo, c.status FROM company_contract a
+	sql := `SELECT a.company_contract_id,a.contract_type ,a.company_product_id ,a.contract_code ,a.pay_method ,a.pay_channel ,a.package_difference ,a.company_id, a.start_date, a.end_date, a.money, b.company_name, a.seller_id_last as seller_id, c.seller_name_last as  seller_name, c.share_seller_last as  share_seller, a.product_id, a.product_name, a.create_time, b.region_type, c.renewal_reason, c.renewal_todo, c.status  FROM company_contract a
 		RIGHT JOIN company b ON a.company_id = b.company_id
 		JOIN company_product c ON b.company_id = c.company_id 
 		AND a.product_id = c.product_id  where 1=1  `
@@ -911,7 +945,6 @@ func GetIncrementalCompanyListByOperationRecordMerge(condition string, pars []in
 	return
 }
 
-// GetIncrementalCompanyListByOperationRecordMerge 未续约合同
 func GetIncrementalCompanyListByOperationRecordMerge879() (items []*IncrementalList, err error) {
 	o := orm.NewOrm()
 	//查询真正的数据

+ 8 - 0
models/system/sys_admin.go

@@ -478,6 +478,14 @@ func GetSysuserRaiList() (items []*AdminItem, err error) {
 	return
 }
 
+// GetSysuserRaiList 获取除服务组之外的所有权益销售
+func GetSysuserRaiListNoServer() (items []*AdminItem, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT  * FROM admin WHERE role_type_code  IN ('rai_group','rai_seller')  AND enabled = 1  AND role_name NOT IN ('权益服务销售','权益服务组长')  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 func GetSellerIdsByDepId(depId int) (ids []string, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT

+ 7 - 0
models/system/sys_group.go

@@ -238,3 +238,10 @@ type RoadshowGroupSellers struct {
 	AdminId   int    `description:"销售ID"`
 	AdminName string `description:"销售名称"`
 }
+
+func GetAllSysGroupByGroupId(groupId int) (items []*SysGroup, err error) {
+	sql := `SELECT * FROM sys_group WHERE parent_id=? OR parent_id = ? ORDER BY sort ASC, create_time ASC`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, groupId, groupId).QueryRows(&items)
+	return
+}

+ 72 - 0
routers/commentsRouter.go

@@ -1771,6 +1771,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:IndustrialSubjectController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:IndustrialSubjectController"],
+        beego.ControllerComments{
+            Method: "IndustrialAndSubjectSearch",
+            Router: `/industrialAndSubject/search`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:IndustrialSubjectController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:IndustrialSubjectController"],
         beego.ControllerComments{
             Method: "IndustrialSubjectAdd",
@@ -2545,6 +2554,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ReportSelectionController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ReportSelectionController"],
+        beego.ControllerComments{
+            Method: "AddThirdName",
+            Router: `/reportSelection/add/third_name`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ReportSelectionController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ReportSelectionController"],
         beego.ControllerComments{
             Method: "ArticleHistoryExport",
@@ -7963,6 +7981,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/seal:SealApprovalController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/seal:SealApprovalController"],
+        beego.ControllerComments{
+            Method: "AffiliatedCompanyList",
+            Router: `/getAffiliatedCompany`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/seal:SealApprovalController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/seal:SealApprovalController"],
         beego.ControllerComments{
             Method: "List",
@@ -10051,6 +10078,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanySellerController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanySellerController"],
+        beego.ControllerComments{
+            Method: "InvoicePaymentCheckList",
+            Router: `/seller/check/invoice_payment/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanySellerController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanySellerController"],
         beego.ControllerComments{
             Method: "CheckList",
@@ -10411,6 +10447,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"],
+        beego.ControllerComments{
+            Method: "ListMoveLog",
+            Router: `/user/listMoveLog`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"],
         beego.ControllerComments{
             Method: "GetOtherProduct",
@@ -10978,6 +11023,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:StatisticCompanyMergerController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:StatisticCompanyMergerController"],
+        beego.ControllerComments{
+            Method: "CompanyContractPercentageListExport",
+            Router: `/merge_company/company_contract_percentage/list_export`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:StatisticCompanyMergerController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:StatisticCompanyMergerController"],
         beego.ControllerComments{
             Method: "CompanyContractPermissionList",
@@ -11014,6 +11068,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:StatisticCompanyMergerController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:StatisticCompanyMergerController"],
+        beego.ControllerComments{
+            Method: "CompanyPreviousLastYear",
+            Router: `/merge_company_previous/last_year`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:StatisticReportController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:StatisticReportController"],
         beego.ControllerComments{
             Method: "InvoicePaymentList",
@@ -11176,6 +11239,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:StatisticReportController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:StatisticReportController"],
+        beego.ControllerComments{
+            Method: "StackCompanyListRai",
+            Router: `/stack_company_list_rai`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:StatisticReportController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:StatisticReportController"],
         beego.ControllerComments{
             Method: "WillExpireList",

+ 76 - 0
services/company.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hz_crm_api/models"
 	"hongze/hz_crm_api/models/company"
 	"hongze/hz_crm_api/models/company_user"
+	"hongze/hz_crm_api/models/cygx"
 	"hongze/hz_crm_api/models/system"
 	"hongze/hz_crm_api/services/alarm_msg"
 	"hongze/hz_crm_api/utils"
@@ -2518,3 +2519,78 @@ func GetShareCompanyPermissionButton(roleTypeCode, statuses string, productId in
 	}
 	return
 }
+
+// AddWxUserMoveLog 添加用户移动日志记录
+func AddWxUserMoveLog(wxUser *models.WxUser, adminUser *system.Admin, newCompanyId int) (err error) {
+	if wxUser.CompanyId == newCompanyId {
+		return
+	}
+	defer func() {
+		if err != nil {
+			go alarm_msg.SendAlarmMsg("添加用户移动日志记录失败,AddWxUserMoveLog "+fmt.Sprint("UserId:", wxUser.UserId, ";err:", err), 3)
+		}
+	}()
+	//获取老的客户信息
+	companyInfoOld, e := company.GetCompanyById(wxUser.CompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyById, Old Err: " + e.Error())
+		return
+	}
+
+	//获取老的客户信息
+	companyInfoNew, e := company.GetCompanyById(newCompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyById, New Err: " + e.Error())
+		return
+	}
+
+	item := new(company.WxUserMoveLog)
+	item.UserId = int(wxUser.UserId)
+	item.RealName = wxUser.RealName
+	item.Mobile = wxUser.Mobile
+	item.Email = wxUser.Email
+	item.CompanyId = wxUser.CompanyId
+	item.CompanyName = companyInfoOld.CompanyName
+	item.CompanyIdMove = companyInfoNew.CompanyId
+	item.CompanyNameMove = companyInfoNew.CompanyName
+	item.SysUserId = adminUser.AdminId
+	item.SysUserRealName = adminUser.RealName
+	item.CreateTime = time.Now()
+	e = company.AddWxUserMoveLog(item)
+	if e != nil {
+		err = errors.New("AddWxUserMoveLog, New Err: " + e.Error())
+		return
+	}
+
+	e = cygx.RemoveCygxUserRemind(int(wxUser.UserId)) //取消个人提醒
+	if e != nil {
+		err = errors.New("RemoveCygxUserRemind, New Err: " + e.Error())
+		return
+	}
+	return
+}
+
+// GetWxUserHaveMoveMap 根据手机号,获取用户是否有过移动的记录
+func GetWxUserHaveMoveMap(mobiles []string) (moveMap map[string]bool) {
+	lenArr := len(mobiles)
+	if lenArr == 0 {
+		return
+	}
+	var err error
+	defer func() {
+		if err != nil {
+			go alarm_msg.SendAlarmMsg("添加用户移动日志记录失败,GetWxUserHaveMoveMap "+fmt.Sprint("mobiles:", mobiles, ";err:", err), 3)
+		}
+	}()
+
+	listMobileMove, e := company.GetWxUserMoveLogListmByMobiles(mobiles)
+	if e != nil {
+		err = errors.New("GetWxUserMoveLogListmByMobiles Err: " + e.Error())
+		return
+	}
+	moveMap = make(map[string]bool)
+	for _, v := range listMobileMove {
+		moveMap[v.Mobile] = true
+	}
+	return
+}

+ 1 - 0
services/company_apply/company_approval.go

@@ -425,6 +425,7 @@ func Approved(approvalRecord *contract.ContractApprovalRecord, opUser *system.Ad
 				//cygxService.HandleAllocationCompanyContractByYanXuan(recordInfo.CompanyContractId)     //如果合同只有研选的时候,自动处理派点
 				cygxService.HandleCompanyContractPackageDifference(recordInfo.CompanyContractId)      // 更新与上一份合同的金额的对比 '增加套餐','减少套餐','维持套餐'
 				cygxService.HandleCompanyContractPermissionContractType(recordInfo.CompanyContractId) // 更新合同权限表中的权限名称,以及对应的行业权限类型(行业新签、行业续约)
+				services.UpdateCompanyProductSellerMove(recordInfo.CompanyId, recordInfo.ProductId)   // 权益客户创建新的有效合同之后,更新所关联的销售信息
 			}
 		}()
 	} else {

+ 129 - 0
services/company_contract.go

@@ -1,5 +1,14 @@
 package services
 
+import (
+	"errors"
+	"fmt"
+	"hongze/hz_crm_api/models/company"
+	"hongze/hz_crm_api/services/alarm_msg"
+	"hongze/hz_crm_api/utils"
+	"time"
+)
+
 //func init() {
 //	InitCompanyContractMerge()
 //	//GetCompanyContractPermissionNameMapById(map[int]string{6513: "182,183", 6663: "435,542"})
@@ -396,3 +405,123 @@ package services
 //
 //	return
 //}
+
+//func init() {
+//	UpdateCompanyContractSellerMove(7034, 2)
+//}
+
+// UpdateCompanyContractSellerMove 权益客户移动所属销售之后,更新所关联的销售信息
+func UpdateCompanyContractSellerMove(companyId, productId int) {
+	if productId != utils.COMPANY_PRODUCT_RAI_ID {
+		return
+	}
+	time.Sleep(1 * time.Second) // 延迟1秒
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg("权益客户移动所属销售之后,更新所关联的销售信息失败,UpdateCompanyContractSellerMove "+fmt.Sprint("companyId:", companyId, ";err:", err), 3)
+		}
+	}()
+
+	cp, e := company.GetCompanyProductByCompanyIdAndProductId(companyId, productId)
+	if e != nil {
+		err = errors.New("GetCompanyProductByCompanyIdAndProductId Err: " + e.Error())
+		return
+	}
+
+	var updateCompanyProduct bool
+	//更新还没有生效的合同
+	{
+		var condition string
+		var pars []interface{}
+		pars = make([]interface{}, 0)
+		condition = " AND  company_id = ?  AND  product_id = ?  AND  start_date > ? "
+		pars = append(pars, companyId, productId, time.Now())
+		list, e := company.GetCompanyContracList(condition, pars) // 获取还没有生效的合同信息
+		if e != nil {
+			err = errors.New("GetCompanyContracList, Err: " + e.Error())
+			return
+		}
+		//fmt.Println("list1", len(list))
+		if len(list) > 0 {
+			for _, v := range list {
+				e = company.UpdateCompanyContractSellerNotEffective(cp.SellerId, cp.ShareSellerId, cp.SellerName, cp.ShareSeller, v.CompanyContractId)
+				if e != nil {
+					err = errors.New("UpdateCompanyContractSellerNotEffective, Err: " + e.Error())
+					return
+				}
+			}
+			e = company.UpdateCompanyProductSellerUnexpired(cp.SellerId, cp.ShareSellerId, cp.SellerName, cp.ShareSeller, cp.CompanyId)
+			if e != nil {
+				err = errors.New("UpdateCompanyProductSellerUnexpired, Err: " + e.Error())
+				return
+			}
+			updateCompanyProduct = true
+		}
+	}
+
+	//更新还没有到期的合同
+	{
+		var condition string
+		var pars []interface{}
+		pars = make([]interface{}, 0)
+		condition = " AND  company_id = ?  AND  product_id = ?  AND  start_date < ?  AND  end_date > ? "
+		pars = append(pars, companyId, productId, time.Now(), time.Now())
+		list, e := company.GetCompanyContracList(condition, pars) // 获取还没有到期的合同信息
+		if e != nil {
+			err = errors.New("GetCompanyContracList, Err: " + e.Error())
+			return
+		}
+		//fmt.Println("list2", len(list))
+		if len(list) > 0 {
+			for _, v := range list {
+				e = company.UpdateCompanyContractSellerUnexpired(cp.SellerId, cp.ShareSellerId, cp.SellerName, cp.ShareSeller, v.CompanyContractId)
+				if e != nil {
+					err = errors.New("UpdateCompanyContractSellerUnexpired, Err: " + e.Error())
+					return
+				}
+			}
+
+			if !updateCompanyProduct {
+				e = company.UpdateCompanyProductSellerUnexpired(cp.SellerId, cp.ShareSellerId, cp.SellerName, cp.ShareSeller, cp.CompanyId)
+				if e != nil {
+					err = errors.New("UpdateCompanyProductSellerUnexpired, Err: " + e.Error())
+					return
+				}
+			}
+
+		}
+	}
+
+	return
+}
+
+// 权益客户创建新的有效合同之后,更新所关联的销售信息
+func UpdateCompanyProductSellerMove(companyId, productId int) {
+	if productId != utils.COMPANY_PRODUCT_RAI_ID {
+		return
+	}
+	time.Sleep(1 * time.Second) // 延迟1秒
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg("权益客户创建新的有效合同之后,更新所关联的销售信息,UpdateCompanyProductSellerMove "+fmt.Sprint("companyId:", companyId, ";err:", err), 3)
+		}
+	}()
+
+	cp, e := company.GetCompanyProductByCompanyIdAndProductId(companyId, productId)
+	if e != nil {
+		err = errors.New("GetCompanyProductByCompanyIdAndProductId Err: " + e.Error())
+		return
+	}
+
+	e = company.UpdateCompanyProductSellerUnexpired(cp.SellerId, cp.ShareSellerId, cp.SellerName, cp.ShareSeller, cp.CompanyId)
+	if e != nil {
+		err = errors.New("UpdateCompanyProductSellerUnexpired, Err: " + e.Error())
+		return
+	}
+
+	return
+}

+ 28 - 1
services/contract/contract.go

@@ -86,6 +86,29 @@ func AddContract(req request.AddContractReq, sellerId, productId int, sellerName
 		err = errors.New(fmt.Sprint("合同编号生成异常,Err:", err))
 		return
 	}
+
+	//权益的新签合同重新定义,如果合同起始时间在第一份新签合同起始日期 1年之内的,仍为新签合同。
+	if productId == utils.COMPANY_PRODUCT_RAI_ID && req.ContractType == "" {
+		//根据社会信用码获取客户信息
+		companyInfo, tmpErr := company.GetCompanyByCreditCode(creditCode)
+		//如果查询异常,且并不是在系统中找不到该社会信用码,那么就异常返回
+		if tmpErr != nil {
+			err = errors.New(fmt.Sprint("根据社会信用码获取客户信息,Err:", tmpErr))
+			return
+		}
+		totalLastYear, tmpErr := GetCompanyContractCountRaiByLastYear(companyInfo.CompanyId, req.StartDate)
+		if tmpErr != nil {
+			err = errors.New(fmt.Sprint("获取第一份新签合同起始日期是否1年之内失败,Err:", tmpErr))
+			return
+		}
+		if totalLastYear > 0 {
+			req.ContractType = "新签合同"
+		} else {
+			req.ContractType = "续约合同"
+		}
+
+	}
+
 	contractInfo := &contract.Contract{
 		ContractCode:         contractCode,
 		SellerId:             sellerId,
@@ -1275,6 +1298,7 @@ func GetServicePermissionMap(serviceList []*contract.ContractServiceAndDetail) (
 			}
 		case 4, 5, 6: //权益大套餐
 			permissionFiccClassifyArr := []string{"权益"}
+			permissionFilterrr := []string{"固收", "路演服务", "研选扣点包", "调研", "专家", "研选订阅"} //不在大套餐中展示的权益权限
 			for _, v := range permissionFiccClassifyArr {
 				items, tmpErr := company.GetPermissionLookItems(2, v)
 				if tmpErr != nil {
@@ -1283,7 +1307,10 @@ func GetServicePermissionMap(serviceList []*contract.ContractServiceAndDetail) (
 				}
 				for _, n := range items {
 					//如果是专家行业,那么 结束当前循环,进入下一循环(产品需求:专家行业不在里面)
-					if n.ChartPermissionId == 29 || n.ChartPermissionId == 31 {
+					//if n.ChartPermissionId == 29 || n.ChartPermissionId == 31 {
+					//	continue
+					//}
+					if utils.InArrayByStr(permissionFilterrr, n.PermissionName) {
 						continue
 					}
 					checkPermissionIdMap[n.ChartPermissionId] = n.ChartPermissionId

+ 3 - 0
services/cygx/acitvity.go

@@ -690,6 +690,9 @@ func ActivityBodyAnalysis(body string, activeState int, req cygx.ActivityRep) (i
 		if strings.Contains(contentTxt, "腾讯会议号:") {
 			item.TencentConferenceNumber = strings.Replace(contentTxt, "腾讯会议号:", "", -1)
 		}
+		if strings.Contains(contentTxt, "会议ID:") {
+			item.MeetingId = strings.Replace(contentTxt, "会议ID:", "", -1)
+		}
 	})
 
 	strnum := strings.Index(body, "活动亮点:")

+ 14 - 17
services/cygx/activity_special.go

@@ -557,13 +557,21 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
 
 // 审批通过的时候专项调研次数更新
 func ActivitySpecialCompanyApproval(companyId, companyContractId int, companyName string) (err error) {
-	userType, packageType, _, _, _ := GetUserType(companyId)
+	//userType, packageType, _, _, _ := GetUserType(companyId)
 	// 获取继承点数
 	//inheritList, e := cygx.GetCygxActivitySpecialInheritPointsByCompanyId(companyId)
 	//if e != nil && e.Error() != utils.ErrNoRow() {
 	//	err = errors.New("GetCygxActivitySpecialInheritPointsByCompanyId, Err: " + e.Error())
 	//}
 	//chartNameMap := map[string]int{utils.YI_YAO_NAME: 0, utils.XIAO_FEI_NAME: 0, utils.KE_JI_NAME: 0, utils.ZHI_ZAO_NAME: 0}
+
+	// 获取合同信息-套餐信息
+	companyContract, e := company.GetCompanyContractById(companyContractId)
+	if e != nil {
+		err = errors.New("GetCompanyContractById, Err: " + e.Error())
+		return
+	}
+	packageType := companyContract.RaiPackageType
 	var items []*cygx.CygxActivitySpecialPermissionPoints
 
 	itemBill := new(cygx.CygxActivitySpecialTripBill)
@@ -573,12 +581,12 @@ func ActivitySpecialCompanyApproval(companyId, companyContractId int, companyNam
 	itemBill.Source = 2
 	itemBill.DoType = 2
 	itemBill.Way = 3
-	if userType == 2 {
-		packageTypeMap := map[int]int{1: 16, 2: 10}
+	if packageType > 0 {
+		packageTypeMap := map[int]int{1: 16, 2: 12}
 		totalTrip := packageTypeMap[packageType]
 		itemBill.BillDetailed = totalTrip
 		itemBill.Total = strconv.Itoa(itemBill.BillDetailed) + "次"
-		if totalTrip == 10 {
+		if packageType == 2 {
 			itemBill.Content = "45w大套餐转正"
 		} else {
 			itemBill.Content = "70w大套餐转正"
@@ -594,13 +602,6 @@ func ActivitySpecialCompanyApproval(companyId, companyContractId int, companyNam
 		items = append(items, item)
 
 	} else {
-		//list, e := company.GetCompanyReportPermissionByCompanyIdAndProductId(companyId, 2)
-		//if e != nil && e.Error() != utils.ErrNoRow() {
-		//	err = errors.New("GetCompanyReportPermissionUpgrade, Err: " + e.Error())
-		//}
-		//if len(list) == 0 {
-		//	return
-		//}
 
 		var condition string
 		var pars []interface{}
@@ -612,10 +613,6 @@ func ActivitySpecialCompanyApproval(companyId, companyContractId int, companyNam
 			err = errors.New("GetCompanyContractPermissionList, Err: " + e.Error())
 			return
 		}
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetCygxAllocationCompanyContractPermissionListById, Err: " + e.Error())
-			return
-		}
 
 		if len(list) == 0 {
 			return
@@ -649,12 +646,12 @@ func ActivitySpecialCompanyApproval(companyId, companyContractId int, companyNam
 		itemBill.Content = "行业升级套餐转正"
 	}
 
-	e := cygx.MultiAddCygxActivitySpecialPermissionPoints(items)
+	e = cygx.MultiAddCygxActivitySpecialPermissionPoints(items)
 	if e != nil {
 		err = errors.New("MultiAddCygxActivitySpecialPermissionPoints, Err:" + e.Error())
 		return
 	}
-	if userType != 2 && len(items) > 0 {
+	if packageType == 0 && len(items) > 0 {
 		var condition string
 		var pars []interface{}
 		pars = make([]interface{}, 0)

+ 369 - 0
services/cygx/yidong.go

@@ -83,6 +83,74 @@ type PersonUser struct {
 	CreatePersonName string `description:"创建人姓名:创建时必填" json:"createPersonName"`
 }
 
+type YidongActivityResult struct {
+	ActivityJoinType               string  `json:"activityJoinType"`               // 活动入会类型,01报名审核后可入会 02预约即可入会 03仅定向邀请人员可入会
+	Banner                         string  `json:"banner"`                         // 宣传图
+	BusinessCardOpen               string  `json:"businessCardOpen"`               // 上传名片是否开启,1是 0否
+	BusinessCardRequired           string  `json:"businessCardRequired"`           // 上传名片是否必填,1是 0否
+	CertificateInformationOpen     string  `json:"certificateInformationOpen"`     // 证件信息是否开启,1是 0否
+	CertificateInformationRequired string  `json:"certificateInformationRequired"` // 证件信息是否必填,1是 0否
+	CompanyCodeOpen                string  `json:"companyCodeOpen"`                // 公司代码是否开启,1是 0否
+	CompanyCodeRequired            string  `json:"companyCodeRequired"`            // 公司代码是否必填,1是 0否
+	CompanyInfo                    string  `json:"companyInfo"`                    // 公司名称
+	CompanyShortNameOpen           string  `json:"companyShortNameOpen"`           // 公司名称是否开启,1是 0否
+	CompanyShortNameRequired       string  `json:"companyShortNameRequired"`       // 公司名称是否必填,1是 0否
+	End                            string  `json:"end"`                            // 活动结束时间
+	ID                             string  `json:"id"`                             // 活动主键id
+	IndustrySwName                 string  `json:"industrySwName"`                 // 行业
+	InviteeOpen                    *string `json:"inviteeOpen"`                    // 邀请机构是否开启,1是 0否
+	InviteeRequired                *string `json:"inviteeRequired"`                // 邀请机构是否必填,1是 0否
+	JobNameOpen                    string  `json:"jobNameOpen"`                    // 职务是否开启,1是 0否
+	JobNameRequired                string  `json:"jobNameRequired"`                // 职务是否必填,1是 0否
+	MailOpen                       string  `json:"mailOpen"`                       // 邮箱是否开启,1是 0否
+	MailRequired                   string  `json:"mailRequired"`                   // 邮箱是否必填,1是 0否
+	PersonNameOpen                 string  `json:"personNameOpen"`                 // 姓名是否开启,1是 0否
+	PersonNameRequired             string  `json:"personNameRequired"`             // 姓名是否必填,1是 0否
+	PersonTelephoneOpen            string  `json:"personTelephoneOpen"`            // 手机号是否开启,1是 0否
+	PersonTelephoneRequired        string  `json:"personTelephoneRequired"`        // 手机号是否必填,1是 0否
+	SignUpEnd                      string  `json:"signUpEnd"`                      // 报名结束时间,适应于报名审核后可入会,为空表示不限制报名时间
+	SignUpStart                    string  `json:"signUpStart"`                    // 报名开始时间,适应于报名审核后可入会,为空表示不限制报名时间
+	Start                          string  `json:"start"`                          // 活动开始时间
+	SyncFlag                       string  `json:"syncFlag"`                       // 同步有效性,同步有效性 1有效,0失效
+	Title                          string  `json:"title"`                          // 活动主题
+	Type                           string  `json:"type"`                           // 路演类型
+	URL                            string  `json:"url"`                            // 活动短链接
+}
+
+type YidongApifoxModal struct {
+	ErrorCode interface{}            `json:"errorCode"`
+	ErrorMsg  interface{}            `json:"errorMsg"`
+	Result    []YidongActivityResult `json:"result"`
+	Success   bool                   `json:"success"`
+	Timestamp int64                  `json:"timestamp"`
+}
+
+type YidongResultuser struct {
+	DeviceType        string `json:"deviceType"`       // 参会方式,1-PC,2-Mac,3-Android,4-IOS,5-Web,6-iPad,7-Android Pad,8-小程序,0-PSTN
+	Duration          string `json:"duration"`         // 云会议参会时长
+	DurationInteract  string `json:"durationInteract"` // 互动交流参会时长
+	DurationLive      string `json:"durationLive"`     // 直播参会时长
+	DurationReview    string `json:"durationReview"`   // 回看参会时长
+	EndTime           string `json:"endTime"`          // 云会议最后退会时间
+	EndTimeInteract   string `json:"endTimeInteract"`  // 互动交流最后退会时间
+	EndTimeLive       string `json:"endTimeLive"`      // 直播最后退会时间
+	EndTimeReview     string `json:"endTimeReview"`    // 回看最后退会时间
+	ID                string `json:"id"`               // 主键id
+	Mail              string `json:"mail" comment:"电子邮件"`
+	CompanyName       string `json:"company_name" comment:"公司名称"`
+	JobName           string `json:"jobName"`           // 职务
+	MobileCountryCode string `json:"mobileCountryCode"` // 手机号国际区号码
+	PersonName        string `json:"personName"`        // 姓名
+	PersonTelephone   string `json:"personTelephone"`   // 用户手机号
+	StartTime         string `json:"startTime"`         // 云会议最早入会时间
+	StartTimeInteract string `json:"startTimeInteract"` // 互动交流最早入会时间
+	StartTimeLive     string `json:"startTimeLive"`     // 直播最早入会时间
+	StartTimeReview   string `json:"startTimeReview"`   // 回看最早入会时间
+	Status            string `json:"status"`            // 状态,D表示被删除
+	UserID            string `json:"userId,omitempty"`  // 用户id
+	SignUpStatus      string `json:"sign_up_status" comment:"报名状态"`
+}
+
 // CheckYidongActivitySignupTime 校验易董的活动是否可以 添加报名
 func CheckYidongActivitySignupTime(activityInfo *cygx.ActivityDetail) (errstr string) {
 	if activityInfo.YidongSignUpEnd == "0000-00-00 00:00:00" {
@@ -752,3 +820,304 @@ func YiDongUpdateActivityStatus(activityId int) {
 	err = cygx.UpdateCygxActivityTencentConferenceNumber(activityInfo)
 	return
 }
+
+// GetLoginAuthCodeReq 获取登录编码请求体
+type GetYiDongActivityByApiReq struct {
+	MeetingStatus   string `json:"meetingStatus" description:"会议状态必需(0未开始1进行中2已结束)多个逗号分隔"`
+	ConveneStartStr string `json:"conveneStartStr" description:"活动日期范围开始"`
+	ConveneEndStr   string `json:"conveneEndStr" description:"活动日期范围结束"`
+	LastUpdateTime  string `json:"lastUpdateTime" description:"上次同步时间(用于筛选更新时间大于同步时间的活动数据)"`
+}
+
+// 根据条件获取易董建会列表信息
+func GetYiDongActivityListByApi(param *GetYiDongActivityByApiReq) (yiDongResult []YidongActivityResult) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg(fmt.Sprint("根据条件获取易董建会列表信息  GetYiDongActivityListByApi"+err.Error(), param), 2)
+		}
+	}()
+	var token string
+	token, _ = GetYidongToken()
+	url := utils.YiDongZhengTongYunUrl + "interact/activityManageApi/getRoadshowList?access_token=" + token
+	method := "POST"
+	data, e := json.Marshal(param)
+	if e != nil {
+		err = errors.New("data json marshal err: " + e.Error())
+		return
+	}
+
+	payload := strings.NewReader(string(data))
+	client := &http.Client{}
+	req, e := http.NewRequest(method, url, payload)
+	if e != nil {
+		err = errors.New(" http.NewRequest err: " + e.Error())
+		return
+	}
+	req.Header.Add("Content-Type", "application/json")
+
+	res, e := client.Do(req)
+	if e != nil {
+		err = errors.New(" client.Do err: " + e.Error())
+		return
+	}
+	defer res.Body.Close()
+	var ApifoxModal *YidongApifoxModal
+	body, e := ioutil.ReadAll(res.Body)
+	if e != nil {
+		err = errors.New("  ioutil.ReadAll: " + e.Error())
+		return
+	}
+
+	//添加请求日志记录
+	itemApiLog := new(cygx.CygxThreeApiLog)
+	itemApiLog.CreateTime = time.Now()
+	itemApiLog.Source = 1
+	itemApiLog.Url = url
+	itemApiLog.Body = utils.ReplaceSpaceAndWrap(fmt.Sprint(payload))
+	itemApiLog.Result = string(body)
+	go cygx.AddCygxThreeApiLog(itemApiLog)
+
+	err = json.Unmarshal(body, &ApifoxModal)
+	if err != nil {
+		fmt.Println("Getres.PublicGetDate Err:", err.Error())
+		return
+	}
+	if len(ApifoxModal.Result) > 0 {
+		yiDongResult = ApifoxModal.Result
+	} else {
+		yiDongResult = make([]YidongActivityResult, 0)
+	}
+	return
+}
+
+type GetYiDongActivityMeetByActivityIdReq struct {
+	ActivityId string `json:"activityId" description:"活动ID"`
+}
+
+type YidongApifoxModaluser struct {
+	ErrorCode interface{}        `json:"errorCode"`
+	ErrorMsg  interface{}        `json:"errorMsg"`
+	Result    []YidongResultuser `json:"result"`
+	Success   bool               `json:"success"`
+	Timestamp int64              `json:"timestamp"`
+}
+
+// 根据条件获取易董活动ID获取到会信息
+func GetYiDongActivityMeetDataByaAtivityId(ativityId string) (yiDongResult []YidongResultuser) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg(fmt.Sprint("根据条件获取易董建会列表信息  GetYiDongActivityListByApi"+err.Error(), ativityId), 2)
+		}
+	}()
+	var token string
+	token, _ = GetYidongToken()
+	url := utils.YiDongZhengTongYunUrl + "interact/activityManageApi/getAttendPersonList?access_token=" + token
+	method := "POST"
+	param := new(GetYiDongActivityMeetByActivityIdReq)
+	param.ActivityId = ativityId
+	data, e := json.Marshal(param)
+	if e != nil {
+		err = errors.New("data json marshal err: " + e.Error())
+		return
+	}
+
+	payload := strings.NewReader(string(data))
+	client := &http.Client{}
+	req, e := http.NewRequest(method, url, payload)
+	if e != nil {
+		err = errors.New(" http.NewRequest err: " + e.Error())
+		return
+	}
+	req.Header.Add("Content-Type", "application/json")
+	res, e := client.Do(req)
+	if e != nil {
+		err = errors.New(" client.Do err: " + e.Error())
+		return
+	}
+	defer res.Body.Close()
+	var ApifoxModal *YidongApifoxModaluser
+	body, e := ioutil.ReadAll(res.Body)
+	if e != nil {
+		err = errors.New(" ioutil.ReadAll err: " + e.Error())
+		return
+	}
+	e = json.Unmarshal(body, &ApifoxModal)
+	if e != nil {
+		err = errors.New(" json.Unmarshal  err: " + e.Error())
+		return
+	}
+
+	//添加请求日志记录
+	itemApiLog := new(cygx.CygxThreeApiLog)
+	itemApiLog.CreateTime = time.Now()
+	itemApiLog.Source = 1
+	itemApiLog.Url = url
+	itemApiLog.Body = utils.ReplaceSpaceAndWrap(fmt.Sprint(payload))
+	itemApiLog.Result = string(body)
+	go cygx.AddCygxThreeApiLog(itemApiLog)
+
+	err = json.Unmarshal(body, &ApifoxModal)
+	if err != nil {
+		fmt.Println("Getres.PublicGetDate Err:", err.Error())
+		return
+	}
+	if len(ApifoxModal.Result) > 0 {
+		yiDongResult = ApifoxModal.Result
+	} else {
+		yiDongResult = make([]YidongResultuser, 0)
+	}
+	return
+}
+
+// 根据条件获取易董活动ID获取到会信息
+func GetYiDongActivityMeeting(yidongActivityId string, cygxActivityId int) (yiDongResult []YidongResultuser) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg(fmt.Sprint("根据条件获取易董建会列表信息  GetYiDongActivityMeeting"+err.Error(), cygxActivityId), 2)
+		}
+	}()
+
+	//跟易董返回的用户状态修改活动以提交到会状态
+	e := cygx.UpdateCygxActivitySubmitMeetingByYidong(yidongActivityId)
+	if e != nil {
+		err = errors.New("UpdateCygxActivitySubmitMeetingByYidong err: " + e.Error())
+		return
+	}
+	meetDataList := GetYiDongActivityMeetDataByaAtivityId(yidongActivityId)
+	var mobiles []string
+	var mobileStr string
+	var mobileStrMeet string
+	mapActivityAttendanceDetail := make(map[string]*cygx.CygxActivityAttendanceDetail)
+	if len(meetDataList) > 0 {
+
+		var itemsUpdate []*cygx.CygxActivitySignupDetail
+		needAddAttendanc := make([]*cygx.CygxActivityAttendanceDetail, 0)
+
+		for _, vresult := range meetDataList {
+			if vresult.PersonTelephone == "" {
+				continue
+			}
+			if vresult.Duration != "" || vresult.DurationReview != "" {
+				mobiles = append(mobiles, vresult.PersonTelephone)
+				var itemDetail = new(cygx.CygxActivitySignupDetail)
+				if vresult.Duration != "" {
+					itemDetail.FirstMeetingTime = vresult.StartTime
+					itemDetail.LastMeetingTime = vresult.EndTime
+					itemDetail.Duration = vresult.Duration
+					itemDetail.MeetingStatusStr = "直播"
+				} else if vresult.DurationReview != "" {
+					itemDetail.FirstMeetingTime = vresult.StartTimeReview
+					itemDetail.LastMeetingTime = vresult.EndTimeReview
+					itemDetail.Duration = vresult.DurationReview
+					itemDetail.MeetingStatusStr = "回放"
+				}
+				itemDetail.Position = vresult.JobName
+				itemDetail.RealName = vresult.PersonName
+
+				itemDetail.Mobile = vresult.PersonTelephone
+				itemDetail.OutboundMobile = vresult.PersonTelephone
+				itemDetail.IsMeeting = 1
+				itemDetail.ActivityId = cygxActivityId
+				mapActivityAttendanceDetail[vresult.PersonTelephone] = new(cygx.CygxActivityAttendanceDetail)
+				mapActivityAttendanceDetail[vresult.PersonTelephone].FirstMeetingTime = vresult.StartTime
+				mapActivityAttendanceDetail[vresult.PersonTelephone].LastMeetingTime = vresult.EndTime
+				mapActivityAttendanceDetail[vresult.PersonTelephone].Duration = utils.GetAttendanceDetailSecondsByYiDong(vresult.Duration)
+				itemsUpdate = append(itemsUpdate, itemDetail)
+			}
+
+			item := new(cygx.CygxActivityAttendanceDetail)
+			item.ActivityId = cygxActivityId
+			item.Mobile = vresult.PersonTelephone
+			if vresult.Duration != "" {
+				if vresult.Duration != "" {
+					item.FirstMeetingTime = vresult.StartTime
+					item.LastMeetingTime = vresult.EndTime
+					item.Duration = vresult.Duration
+					item.MeetingStatusStr = "直播"
+				} else if vresult.DurationReview != "" {
+					item.FirstMeetingTime = vresult.StartTimeReview
+					item.LastMeetingTime = vresult.EndTimeReview
+					item.Duration = vresult.DurationReview
+					item.MeetingStatusStr = "回放"
+				}
+				item.Position = vresult.JobName
+				item.RealName = vresult.PersonName
+
+				item.FirstMeetingTime = vresult.StartTime
+				item.LastMeetingTime = vresult.EndTime
+				item.Duration = vresult.Duration
+				item.IsMeetingStr = 1
+				mobileStrMeet += "'" + vresult.PersonTelephone + "'" + ","
+				item.CreateTime = time.Now()
+				needAddAttendanc = append(needAddAttendanc, item)
+			}
+			mobileStr += "'" + vresult.PersonTelephone + "'" + ","
+
+		}
+		lenmobiles := len(mobiles)
+		if lenmobiles > 0 {
+			var parsYd []interface{}
+			var conditionYd string
+			conditionYd = ` AND mobile  IN (` + utils.GetOrmInReplace(lenmobiles) + `) AND  activity_id=?  `
+			parsYd = append(parsYd, mobiles, cygxActivityId)
+			e = cygx.UpdateCygxActivitySignupisMeetList(conditionYd, parsYd)
+			if e != nil {
+				err = errors.New("UpdateCygxActivitySignupisMeetList err: " + e.Error())
+				return
+			}
+			e = cygx.UpdateActivitySignupDetailMultiByYiDong(itemsUpdate)
+			if e != nil {
+				err = errors.New("UpdateActivitySignupDetailMultiByYiDong err: " + e.Error())
+				return
+			}
+		}
+
+		mobileStr = strings.TrimRight(mobileStr, ",")
+		if mobileStr == "" {
+			mobileStr = "1"
+		}
+		mobileStrMeet = strings.TrimRight(mobileStrMeet, ",")
+		if mobileStrMeet == "" {
+			mobileStrMeet = "1"
+		}
+
+		listUser, e := cygx.GetWxUserOutboundMobile(mobileStr)
+		if e != nil {
+			err = errors.New("GetWxUserOutboundMobile err: " + e.Error())
+			return
+		}
+		for kAdd, vAdd := range needAddAttendanc {
+			for _, v2 := range listUser {
+				if v2.OutboundMobile == vAdd.Mobile || v2.Mobile == vAdd.Mobile {
+					if needAddAttendanc[kAdd].CompanyId <= 1 {
+						needAddAttendanc[kAdd].CompanyId = v2.CompanyId
+						needAddAttendanc[kAdd].SellerName = v2.SellerName
+						needAddAttendanc[kAdd].CompanyName = v2.CompanyName
+						//needAddAttendanc[k].IsMeetingStr = 1
+					}
+				}
+			}
+		}
+
+		//参会记录
+		e = cygx.AddAttendancDetail(needAddAttendanc, cygxActivityId, mobileStrMeet)
+		if e != nil {
+			err = errors.New("AddAttendancDetail err: " + e.Error())
+			return
+		}
+		////处理是否限制报名
+		e = AddCygxActivityRestrictSignupByAdmin(cygxActivityId)
+		if e != nil {
+			err = errors.New("AddCygxActivityRestrictSignupByAdmin err: " + e.Error())
+			return
+		}
+		AddctivitySignupDetailListByHand(needAddAttendanc, cygxActivityId)
+	}
+	return
+}

+ 36 - 4
services/roadshow/calendar.go

@@ -294,6 +294,15 @@ func getCurl(urlStr string, params url.Values, num int) (body []byte, err error)
 		err = errors.New(response.Msg)
 		return
 	}
+
+	itemApiLog := new(roadshow.RsCalendarApiLog)
+	itemApiLog.CreateTime = time.Now()
+	itemApiLog.Remark = "get请求上海接口"
+	itemApiLog.Url = getUrl
+	itemApiLog.Body = utils.ReplaceSpaceAndWrap(fmt.Sprint(params))
+	itemApiLog.Result = string(body)
+	go roadshow.AddRsCalendarApiLog(itemApiLog)
+
 	return
 }
 
@@ -342,7 +351,13 @@ func postCurl(urlStr string, form url.Values, num int) (body []byte, err error,
 		return
 	}
 	utils.FileLog.Info(fmt.Sprint("post request url:", finalUrl, ";params:", form.Encode(), ";response:", string(body)))
-
+	itemApiLog := new(roadshow.RsCalendarApiLog)
+	itemApiLog.CreateTime = time.Now()
+	itemApiLog.Remark = "post请求上海接口"
+	itemApiLog.Url = urlStr
+	itemApiLog.Body = utils.ReplaceSpaceAndWrap(fmt.Sprint(form))
+	itemApiLog.Result = string(body)
+	go roadshow.AddRsCalendarApiLog(itemApiLog)
 	//如果是token失效,同时只是第一次请求(没有尝试强制刷新token,那么重新请求)
 	if response.Code == 4001 && num <= 0 {
 		//token失效
@@ -378,6 +393,9 @@ func GetAccessToken(isRefresh bool) (token string, err error) {
 
 // CalendarToSH 创建活动时同步上海的前置函数
 func CalendarToSH(rsCalendar roadshow.RsCalendar, researcher roadshow.RsCalendarResearcher) {
+	if researcher.Status != 2 { //研究员的路演申请,需要研究员接受后,再同步到老CRM
+		return
+	}
 	var err error
 	errMsg := ``
 	defer func() {
@@ -405,7 +423,7 @@ func CalendarToSH(rsCalendar roadshow.RsCalendar, researcher roadshow.RsCalendar
 	endTime := eTime.Format("2006-01-02 15:04")
 
 	// 创建上海路演日程
-	err, errMsg = creatSHCalendar(userInfo.Mobile, researcherInfo.Mobile, rsCalendar.Title, startTime, endTime, 1, researcher.RsCalendarResearcherId)
+	err, errMsg = creatSHCalendar(userInfo.Mobile, researcherInfo.Mobile, rsCalendar.CompanyName+rsCalendar.Title, startTime, endTime, 1, researcher.RsCalendarResearcherId)
 	if err != nil {
 		utils.FileLog.Info("CreatSHCalendar err: " + err.Error())
 		fmt.Println(err)
@@ -568,6 +586,7 @@ func UpdateSHCalendarByMatter(req roadshow.UpdateMattersReq) (err error) {
 	if err != nil {
 		err = errors.New("GetRelationByPars err:" + err.Error())
 		fmt.Println(err)
+		return
 	}
 
 	sTime, _ := time.ParseInLocation(utils.FormatDateTime, req.StartDate+" "+req.StartTime, time.Now().Location())
@@ -576,7 +595,7 @@ func UpdateSHCalendarByMatter(req roadshow.UpdateMattersReq) (err error) {
 	endTime := eTime.Format("2006-01-02 15:04")
 	//发送更新请求
 
-	_, err = updateSHCalendar(fmt.Sprintf("%v", relationItem.ThirdCalendarId), relationItem.ResearcherMobile, req.MatterContent, startTime, endTime)
+	_, err = updateSHCalendar(fmt.Sprintf("%v", relationItem.ThirdCalendarId), relationItem.ResearcherMobile, relationItem.CustomerName+req.MatterContent, startTime, endTime)
 	if err == nil {
 		updateParams := make(map[string]interface{})
 		whereParams := make(map[string]interface{})
@@ -930,6 +949,7 @@ func SyncCalendarFromShanghai(userPhone, startDate, endDate string) (err error)
 		}
 	}
 
+	var itemsApiLog []*roadshow.RsCalendarApiLog
 	//上海那边已经删除了路演,这边也要同步删除
 	for _, deleteRsCalendarResearcherList := range deleteRsCalendarResearcherMap {
 		for _, deleteRsCalendarResearcher := range deleteRsCalendarResearcherList {
@@ -945,7 +965,14 @@ func SyncCalendarFromShanghai(userPhone, startDate, endDate string) (err error)
 				errMsgList = append(errMsgList, fmt.Sprint("第三方日历ID:", deleteRsCalendarResearcher.ThirdCalendarId, "删除关联关系失败;err:"+tmpErr.Error(), ";"))
 				continue
 			}
-
+			itemApiLog := new(roadshow.RsCalendarApiLog)
+			itemApiLog.CreateTime = time.Now()
+			itemApiLog.Remark = "对比上海接口之后手动删除"
+			itemApiLog.Url = fmt.Sprint("userPhone", userPhone, "currDay", currDay, "endDate", endDate)
+			itemApiLog.Body = ""
+			itemApiLog.Result = ""
+			itemApiLog.RsCalendarResearcherId = deleteRsCalendarResearcher.RsCalendarResearcherId
+			itemsApiLog = append(itemsApiLog, itemApiLog)
 			// 更新路演的同步字段
 			//calWhereParams := make(map[string]interface{})
 			//calUpdateParams := make(map[string]interface{})
@@ -954,6 +981,11 @@ func SyncCalendarFromShanghai(userPhone, startDate, endDate string) (err error)
 			//err = roadshow.UpdateRsCalendar(calWhereParams, calUpdateParams)
 		}
 	}
+
+	if len(itemsApiLog) > 0 {
+		go roadshow.AddRsCalendarApiLogList(itemsApiLog)
+	}
+
 	return
 }
 

+ 13 - 5
services/seal/seal.go

@@ -123,7 +123,7 @@ func ApplySeal(sysUser *system.Admin, req request.SealApprovalApplyReq) (err err
 	}()
 
 	// 添加用印
-	sealInfo, err := addSeal(sysUser.AdminId, req.ContractId, req.FileNum, sysUser.RealName, req.Use, req.CompanyName, req.UseCompanyName, req.CreditCode, req.ServiceType, req.SealType, req.Remark, req.FileUrls)
+	sealInfo, err := addSeal(sysUser.AdminId, req.ContractId, req.FileNum, sysUser.RealName, req.Use, req.CompanyName, req.UseCompanyName, req.CreditCode, req.ServiceType, req.SealType, req.Remark, req.FileUrls, req.AffiliatedCompany)
 	if err != nil {
 		return
 	}
@@ -140,7 +140,7 @@ func ApplySeal(sysUser *system.Admin, req request.SealApprovalApplyReq) (err err
 }
 
 // addSeal 新增用印
-func addSeal(userId, contractId, fileNum int, userName, use, companyName, useCompanyName, creditCode, serviceType, sealType, remark string, fileUrls []string) (sealInfo *seal.Seal, err error) {
+func addSeal(userId, contractId, fileNum int, userName, use, companyName, useCompanyName, creditCode, serviceType, sealType, remark string, fileUrls []string, affiliatedCompany string) (sealInfo *seal.Seal, err error) {
 	if !strings.Contains(strings.Join(seal.EnumUse, ","), use) {
 		err = errors.New("用印用途异常")
 		return
@@ -177,6 +177,7 @@ func addSeal(userId, contractId, fileNum int, userName, use, companyName, useCom
 		ContractId:     contractId,
 		ModifyTime:     now,
 		CreateTime:     now,
+		AffiliatedCompany:  affiliatedCompany,
 	}
 	err = seal.AddSeal(sealInfo)
 	if err != nil {
@@ -213,7 +214,7 @@ func EditApply(sysUser *system.Admin, req request.SealApprovalEditReq) (err erro
 	}()
 
 	// 编辑用印
-	sealInfo, err := editSeal(req.SealId, sysUser.AdminId, req.ContractId, req.FileNum, req.Use, req.CompanyName, req.UseCompanyName, req.CreditCode, req.ServiceType, req.SealType, req.Remark, req.FileUrls)
+	sealInfo, err := editSeal(req.SealId, sysUser.AdminId, req.ContractId, req.FileNum, req.Use, req.CompanyName, req.UseCompanyName, req.CreditCode, req.ServiceType, req.SealType, req.Remark, req.FileUrls, req.AffiliatedCompany)
 	if err != nil {
 		return
 	}
@@ -230,7 +231,7 @@ func EditApply(sysUser *system.Admin, req request.SealApprovalEditReq) (err erro
 }
 
 // editSeal 编辑用印申请
-func editSeal(sealId, userId, contractId, fileNum int, use, companyName, userCompanyName, creditCode, serviceType, sealType, remark string, fileUrls []string) (sealInfo *seal.Seal, err error) {
+func editSeal(sealId, userId, contractId, fileNum int, use, companyName, userCompanyName, creditCode, serviceType, sealType, remark string, fileUrls []string, affiliatedCompany string) (sealInfo *seal.Seal, err error) {
 	if !strings.Contains(strings.Join(seal.EnumUse, ","), use) {
 		err = errors.New("用印用途异常")
 		return
@@ -276,7 +277,8 @@ func editSeal(sealId, userId, contractId, fileNum int, use, companyName, userCom
 	sealInfo.ModifyTime = now
 	sealInfo.CreateTime = now // 更新提交时间
 	sealInfo.Status = "待提交"
-	err = sealInfo.Update([]string{"Use", "CompanyName", "UseCompanyName", "CreditCode", "ServiceType", "SealType", "Remark", "FileUrl", "FileNum", "ContractId", "ModifyTime", "CreateTime", "Status"})
+	sealInfo.AffiliatedCompany = affiliatedCompany
+	err = sealInfo.Update([]string{"Use", "CompanyName", "UseCompanyName", "CreditCode", "ServiceType", "SealType", "Remark", "FileUrl", "FileNum", "ContractId", "ModifyTime", "CreateTime", "Status", "AffiliatedCompany"})
 	if err != nil {
 		return
 	}
@@ -365,6 +367,10 @@ func VerifierEditApply(sysUser *system.Admin, req request.SealApprovalEditReq) (
 		updateContent = append(updateContent, "文件附件")
 		attachmentFlag = true
 	}
+	if sealInfo.AffiliatedCompany != req.AffiliatedCompany {
+		updateCol = append(updateCol, "AffiliatedCompany")
+		updateContent = append(updateContent, "归属公司")
+	}
 	if len(updateCol) <= 0 {
 		err = errors.New("没有变更信息")
 		return
@@ -393,6 +399,7 @@ func VerifierEditApply(sysUser *system.Admin, req request.SealApprovalEditReq) (
 		sealInfo.FileNum = req.FileNum
 		sealInfo.FileUrl = newFileUrl
 		sealInfo.ModifyTime = time.Now()
+		sealInfo.AffiliatedCompany = req.AffiliatedCompany
 		verifierEdit(sealInfo, updateCol, approvalRecord.ContractApprovalRecordId, content, sysUser, attachmentFlag, req.FileUrls)
 		// 重新获取最新的用印单
 		sealInfo, tmpErr := seal.GetSealInfoById(sealInfo.SealId)
@@ -413,6 +420,7 @@ func VerifierEditApply(sysUser *system.Admin, req request.SealApprovalEditReq) (
 		sealInfo.FileNum = req.FileNum
 		sealInfo.FileUrl = newFileUrl
 		sealInfo.ModifyTime = time.Now()
+		sealInfo.AffiliatedCompany = req.AffiliatedCompany
 		verifierEdit(sealInfo, updateCol, approvalRecord.ContractApprovalRecordId, content, sysUser, attachmentFlag, req.FileUrls)
 		// 审核通过
 		err = ApprovedApproval(sealInfo.SealId, sysUser, "")

+ 8 - 0
utils/common.go

@@ -2353,3 +2353,11 @@ func TruncateActivityNameString(s string) string {
 func GetLikeKeyword(keyword string) string {
 	return `%` + keyword + `%`
 }
+
+// 用户参会时间转换
+func GetAttendanceDetailSecondsByYiDong(str string) string {
+	var timeStr string
+	timeStr = strings.Replace(str, ":", "'", -1)
+	timeStr += "''"
+	return timeStr
+}