123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517 |
- package controllers
- import (
- "encoding/json"
- "fmt"
- "hongze/hz_crm_api/models"
- "hongze/hz_crm_api/models/company"
- "hongze/hz_crm_api/models/contract"
- "hongze/hz_crm_api/models/contract/response"
- "hongze/hz_crm_api/services"
- contractService "hongze/hz_crm_api/services/contract"
- "hongze/hz_crm_api/utils"
- "strconv"
- "strings"
- "time"
- )
- // 申请管理
- type CompanyApplyController struct {
- BaseAuthController
- }
- // @Title 申请服务更新-签约历史
- // @Description 申请服务更新-签约历史接口
- // @Param CompanyId query int true "客户ID"
- // @Param CompanyType query string true "客户类型:传空字符串或者不传为全部,'ficc','权益'"
- // @Success 200 {object} company.CompanyContractHistoryResp
- // @router /apply/contract/history/list [get]
- func (this *CompanyApplyController) ApplyContractHistoryList() {
- 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
- }
- companyId, _ := this.GetInt("CompanyId")
- if companyId <= 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误,客户id小于等于0"
- return
- }
- roleTypeCode := sysUser.RoleTypeCode
- productId := services.GetProductId(roleTypeCode)
- productIdStr := ``
- if productId == 0 {
- productIdStr = "1,2"
- } else {
- productIdStr = strconv.Itoa(productId)
- }
- list, err := company.GetCompanyContractHistoryList(companyId, productIdStr)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- listLen := len(list)
- // 权益permissions
- //raiPermissions := make([]*company.PermissionLookItem, 0)
- //if strings.Contains(productIdStr, "2") {
- // ps, e := company.GetPermissionLookItemsExt("2", utils.COMPANY_PRODUCT_RAI_NAME)
- // if e != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取权益权限列表失败, Err: " + e.Error()
- // return
- // }
- // raiPermissions = ps
- //}
- //expMap := map[int]string{0: "(3w)", 1: "(5w)"} // 买方研选价格
- for i := 0; i < listLen; i++ {
- companyContract := list[i]
- list[i].ModifyTimeStr = companyContract.ModifyTime.Format(utils.FormatDateTime)
- productId = list[i].ProductId
- if productId == 1 {
- permissionClassifyArr, e := services.GetPermissionFirstArr(utils.COMPANY_PRODUCT_FICC_ID)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限分类失败,Err:" + e.Error()
- return
- }
- for _, v := range permissionClassifyArr {
- checkList := make([]int, 0)
- plist := new(company.ContractPermissionList)
- plist.Items = make([]*company.PermissionLookItem, 0)
- items, err := company.GetPermissionLookItemsExtByParentId(productIdStr, v.ChartPermissionId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- return
- }
- if len(items) > 0 {
- for _, n := range items {
- count, err := company.GetCompanyContractPermissionCheckByContractId(companyId, companyContract.CompanyContractId, n.ChartPermissionId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- return
- }
- if count > 0 {
- checkList = append(checkList, n.ChartPermissionId)
- }
- }
- plist.Items = items
- }
- plist.ClassifyName = v.PermissionName
- plist.CheckList = checkList
- list[i].PermissionList = append(list[i].PermissionList, plist)
- }
- continue
- }
- // 权益
- if productId == utils.COMPANY_PRODUCT_RAI_ID {
- //classifyName := "权益"
- checkList := make([]int, 0)
- plist := new(company.ContractPermissionList)
- //items, err := company.GetPermissionLookItemsExt(productIdStr, utils.COMPANY_PRODUCT_RAI_NAME)
- //if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- // return
- //}
- var expensiveYx int
- var pints float64 // 现在就一个行业有点数,先这么写吧
- hasPermissions, e := company.GetCompanyContractPermissionByCompanyContractId(companyContract.CompanyContractId)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取合同权限信息失败,Err:" + e.Error()
- return
- }
- hasMap := make(map[int]*company.CompanyContractPermission)
- for _, p := range hasPermissions {
- hasMap[p.ChartPermissionId] = p
- if p.ExpensiveYx > 0 {
- expensiveYx = p.ExpensiveYx
- }
- if p.Points > 0 {
- pints = p.Points
- }
- }
- checkItems := make([]*company.PermissionLookItem, 0)
- raiPermissions, e := company.GetPermissionLookItemsExt("2", utils.COMPANY_PRODUCT_RAI_NAME)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权益权限列表失败, Err: " + e.Error()
- return
- }
- //大套餐类型单独展示
- if companyContract.RaiPackageType > 0 {
- n := new(company.PermissionLookItem)
- if companyContract.RaiPackageType == 1 {
- n.PermissionName = "70W套餐"
- } else if companyContract.RaiPackageType == 2 {
- n.PermissionName = "45W套餐"
- }
- checkList = append(checkList, 0)
- checkItems = append(checkItems, n)
- for _, n := range raiPermissions {
- match := hasMap[n.ChartPermissionId]
- if match == nil {
- continue
- }
- //研选订阅、研选扣点包、专家也要单独处理
- if n.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN || n.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID || n.ChartPermissionId == utils.ZHUAN_JIA_ID {
- if n.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- if expensiveYx == 1 {
- n.PermissionName += "(5w)"
- } else if expensiveYx == 2 {
- n.PermissionName += "(10w)"
- } else if expensiveYx == 0 {
- //n.PermissionName += "(3w)"
- }
- }
- if n.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
- n.PermissionName += "(" + fmt.Sprint(pints) + "点)"
- }
- checkList = append(checkList, n.ChartPermissionId)
- checkItems = append(checkItems, n)
- }
- }
- } else {
- // PS:本来想把这个移到循环外面去优化一下...但是发现有指针引用变量被改掉的问题, BUG太多了改不完了先这样吧=_=!
- for _, n := range raiPermissions {
- match := hasMap[n.ChartPermissionId]
- if match == nil {
- continue
- }
- // 升级
- if match.IsUpgrade == 1 {
- n.IsUpgrade = 1
- checkList = append(checkList, n.ChartPermissionId)
- checkItems = append(checkItems, n)
- continue
- }
- // 买方研选(3w/5w)、 研选扣点包,拼接点数
- if n.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN || n.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
- if expensiveYx == 1 {
- n.PermissionName += "(5w)"
- } else if expensiveYx == 2 {
- n.PermissionName += "(10w)"
- } else if expensiveYx == 0 {
- //n.PermissionName += "(3w)"
- }
- if n.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
- n.PermissionName += "(" + fmt.Sprint(pints) + "点)"
- }
- //n.PermissionName += expMap[match.ExpensiveYx]
- checkList = append(checkList, n.ChartPermissionId)
- checkItems = append(checkItems, n)
- continue
- }
- checkList = append(checkList, n.ChartPermissionId)
- checkItems = append(checkItems, n)
- //count, err := company.GetCompanyContractUpgradePermissionCheckByContractId(companyId, companyContract.CompanyContractId, n.ChartPermissionId, 0)
- //if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- // return
- //}
- //if count > 0 {
- // checkList = append(checkList, n.ChartPermissionId)
- // checkItems = append(checkItems, n)
- //} else {
- // count2, err := company.GetCompanyContractUpgradePermissionCheckByContractId(companyId, companyContract.CompanyContractId, n.ChartPermissionId, 1)
- // if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- // return
- // }
- // if count2 > 0 {
- // n.IsUpgrade = 1
- // checkList = append(checkList, n.ChartPermissionId)
- // checkItems = append(checkItems, n)
- // }
- //}
- }
- }
- //合并主观客观
- //mapPermissionNameList := make(map[string]int)
- //for _, v := range items {
- // if mapPermissionNameList[v.PermissionName] == 0 {
- // plist.Items = append(plist.Items, v)
- // mapPermissionNameList[v.PermissionName] = v.ChartPermissionId
- // }
- //}
- plist.Items = checkItems
- plist.ClassifyName = utils.COMPANY_PRODUCT_RAI_NAME
- plist.CheckList = checkList
- list[i].PermissionList = append(list[i].PermissionList, plist)
- // CRM8.8-权限主客观合并
- newPermissionLookList := contractService.HandleEquityContractPermissionList(list[i].PermissionList)
- list[i].PermissionList = newPermissionLookList
- }
- }
- resp := new(company.CompanyContractHistoryResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // GetApplyTurnContractType
- // @Title 获取客户申请转正的合同类型
- // @Description 获取客户申请转正的合同类型接口
- // @Param CompanyId query int true "客户ID"
- // @Success 200 {object} company.ApplyContractTypeResp
- // @router /apply/contract/getApplyTurnContractType [get]
- func (this *CompanyApplyController) GetApplyTurnContractType() {
- 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
- }
- companyId, _ := this.GetInt("CompanyId")
- if companyId <= 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误,客户id小于等于0"
- return
- }
- roleTypeCode := sysUser.RoleTypeCode
- productId := services.GetProductId(roleTypeCode)
- if productId == 0 {
- br.Msg = "账户异常"
- br.ErrMsg = "账户类型异常为:" + roleTypeCode
- return
- }
- contractType, err := services.GetApplyTurnContractType(companyId, productId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取合同类型失败,Err:" + err.Error()
- return
- }
- //companyProduct, err := company.GetCompanyProductByCompanyIdAndProductId(companyId, productId)
- //if err != nil {
- // br.Msg = "获取客户信息失败"
- // br.ErrMsg = "获取客户信息失败"
- // return
- //}
- //
- ////合同类型
- //contractType := "新签合同"
- //var condition string
- //var pars []interface{}
- //condition += " AND product_id = ?"
- //pars = append(pars, productId)
- //condition += " AND status = ?"
- //pars = append(pars, 1)
- //list, err := company.GetCompanyContractListByCompanyId(companyId, condition, pars)
- //if err != nil {
- // br.Msg = "获取合同信息失败"
- // br.ErrMsg = "获取合同信息失败,Err:" + err.Error()
- // return
- //}
- //if len(list) > 0 {
- // contractType = "续约合同"
- //}
- ////查询是否存在正式转试用的记录,如果存在,那么合同类型是续约合同
- //total, err := company.GetCompanyProductOperationRecordCount(companyProduct.CompanyId, companyProduct.ProductId)
- //if err != nil {
- // br.Msg = "查询用户信息异常"
- // br.ErrMsg = "查询用户变更记录异常"
- // return
- //}
- //if total > 0 {
- // contractType = "续约合同"
- //}
- resp := company.ApplyContractTypeResp{
- ContractType: contractType,
- }
- br.Data = resp
- //合同类型 end
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- }
- // @Title 申请服务更新-续约申请详情
- // @Description 申请服务更新-续约申请详情接口
- // @Param CompanyId query int true "客户ID"
- // @Param CompanyContractId query int true "合同id"
- // @Success 200 {object} company.CompanyContractDetailResp
- // @router /apply/contract/detail [get]
- func (this *CompanyApplyController) ApplyContractDetail() {
- 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
- }
- companyId, _ := this.GetInt("CompanyId")
- if companyId <= 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误,客户id小于等于0"
- return
- }
- companyContractId, _ := this.GetInt("CompanyContractId")
- roleTypeCode := sysUser.RoleTypeCode
- productId := services.GetProductId(roleTypeCode)
- //if productId == 0 {
- // br.Msg = "参数错误"
- // br.ErrMsg = "客户类型为:" + roleTypeCode
- // return
- //}
- detail, err := company.GetCompanyContractDetail(companyId, productId, companyContractId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if detail.Source == "系统合同" {
- detail.SourceTag = "标准合同"
- } else {
- detail.SourceTag = "非标合同"
- }
- if detail.ProductId == 1 {
- //子权限切片集合
- allFiccPermissions, permissionMap, e := services.GetBasePermissionLookItem(utils.COMPANY_PRODUCT_FICC_ID)
- if e != nil {
- br.Msg = "查询基础权限失败"
- br.ErrMsg = "查询基础权限失败,Err:" + e.Error()
- return
- }
- //遍历获取
- for _, v := range allFiccPermissions {
- if v.ParentId == 0 {
- checkList := make([]int, 0)
- plist := new(company.PermissionLookList)
- items, ok := permissionMap[v.ChartPermissionId]
- if !ok {
- br.Msg = "获取权限信息失败"
- return
- }
- for _, n := range items {
- count, err := company.GetCompanyContractPermissionCheckByContractId(companyId, detail.CompanyContractId, n.ChartPermissionId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- return
- }
- if count > 0 {
- checkList = append(checkList, n.ChartPermissionId)
- }
- }
- plist.Items = items
- plist.ClassifyName = v.PermissionName
- plist.CheckList = checkList
- detail.PermissionList = append(detail.PermissionList, plist)
- }
- }
- }
- if detail.ProductId == 2 {
- classifyName := "权益"
- checkList := make([]int, 0)
- plist := new(company.PermissionLookList)
- plist.ClassifyName = classifyName
- items, e := company.GetPermissionLookItems(detail.ProductId, classifyName)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限信息失败,Err:" + e.Error()
- return
- }
- mapExpensive := make(map[int]bool) // 通过合同获取所勾选的买方研选5w
- permissionList, err := company.GetCompanyContractPermissionByCompanyContractId(companyContractId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取合同权限信息失败,Err:" + err.Error()
- return
- }
- permissions := make([]int, 0) // 合同权限IDs
- checkItems := make([]*company.PermissionLookItem, 0)
- //expMap := map[bool]string{false: "(3w)", true: "(5w)"} // 买方研选价格
- //var expensiveYx int
- // 未选大套餐, 走老逻辑
- var points float64
- if detail.RaiPackageType == 0 {
- totalForever, err := company.GetCompanyProductRaiForeverCount(companyId) //判断是否是权益的永续客户
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- return
- }
- if totalForever > 0 {
- detail.Quarter, err = utils.GetQuarterStrStartDatesInRange(detail.StartDate, detail.EndDate) //通过开始时间,结束时间,获取对应季度的拼接字符串
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取季度息失败,Err:" + err.Error()
- return
- }
- }
- mapUpgrade := make(map[int]bool) // 通过合同获取所勾选的升级行业权限
- for _, v := range permissionList {
- if v.IsUpgrade == 1 {
- mapUpgrade[v.ChartPermissionId] = true
- }
- if v.ExpensiveYx > 0 {
- mapExpensive[v.ChartPermissionId] = true
- //expensiveYx = v.ExpensiveYx
- }
- if v.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
- points = v.Points
- }
- permissions = append(permissions, v.ChartPermissionId)
- }
- for _, n := range items {
- if n.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
- n.PermissionName += fmt.Sprint("(", points, "点)")
- }
- if utils.InArrayByInt(permissions, n.ChartPermissionId) {
- checkList = append(checkList, n.ChartPermissionId)
- checkItems = append(checkItems, n)
- }
- }
- plist.Items = checkItems
- plist.CheckList = checkList
- detail.PermissionList = append(detail.PermissionList, plist)
- // CRM8.8-权限主客观合并
- newPermissionLookList := contractService.HandleEquityPermissionLookList(detail.PermissionList)
- for _, c := range newPermissionLookList {
- if c.ClassifyName != "权益" {
- continue
- }
- for _, p := range c.Items {
- // 行业升级
- if mapUpgrade[p.ChartPermissionId] {
- if strings.Contains(p.PermissionName, "主观") {
- p.PermissionName = strings.Replace(p.PermissionName, "主观", "升级", -1)
- continue
- }
- if strings.Contains(p.PermissionName, "客观") {
- p.PermissionName = strings.Replace(p.PermissionName, "客观", "升级", -1)
- continue
- }
- p.PermissionName += "(升级)"
- continue
- }
- // 买方研选
- //if p.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- // if expensiveYx == 1 {
- // p.PermissionName += "(5w)"
- // } else if expensiveYx == 2 {
- // p.PermissionName += "(10w)"
- // }
- // //p.PermissionName += expMap[mapExpensive[p.ChartPermissionId]]
- //}
- }
- }
- detail.PermissionList = newPermissionLookList
- }
- // 如果选择的是大套餐, 那么不再展示每个具体的权限, 除大套餐外还需遍历一下专家和研选3w/5w是否有选(这两个与大套餐不互斥, 可额外选择)
- if detail.RaiPackageType > 0 {
- // 大套餐
- bigPackage := new(company.PermissionLookItem)
- if detail.RaiPackageType == 1 {
- bigPackage.PermissionName = utils.CHART_PERMISSION_NAME_70W
- bigPackage.ChartPermissionId = utils.CHART_PERMISSION_ID_70W
- checkList = append(checkList, utils.CHART_PERMISSION_ID_70W)
- }
- if detail.RaiPackageType == 2 {
- bigPackage.PermissionName = utils.CHART_PERMISSION_NAME_45W
- bigPackage.ChartPermissionId = utils.CHART_PERMISSION_ID_45W
- checkList = append(checkList, utils.CHART_PERMISSION_ID_45W)
- }
- checkItems = append(checkItems, bigPackage)
- for _, v := range permissionList {
- if v.ExpensiveYx == 1 {
- mapExpensive[v.ChartPermissionId] = true
- }
- if v.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
- points = v.Points
- }
- permissions = append(permissions, v.ChartPermissionId)
- }
- // 专家、研选订阅、研选扣点包
- for _, n := range items {
- if n.ChartPermissionId != utils.ZHUAN_JIA_ID && n.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN && n.ChartPermissionId != utils.YAN_XUAN_KOU_DIAN_BAO_ID {
- continue
- }
- //if n.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- // //n.PermissionName += expMap[mapExpensive[n.ChartPermissionId]]
- // if expensiveYx == 1 {
- // n.PermissionName += "(5w)"
- // } else if expensiveYx == 2 {
- // n.PermissionName += "(10w)"
- // }
- //}
- if n.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
- n.PermissionName += fmt.Sprint("(", points, "点)")
- }
- if utils.InArrayByInt(permissions, n.ChartPermissionId) {
- checkList = append(checkList, n.ChartPermissionId)
- checkItems = append(checkItems, n)
- }
- }
- plist.Items = checkItems
- plist.CheckList = checkList
- detail.PermissionList = append(detail.PermissionList, plist)
- }
- }
- resp := new(company.CompanyContractDetailResp)
- resp.Item = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取客户大于今天的有效合同权限详情
- // @Description 获取客户大于今天的有效合同权限详情接口
- // @Param CompanyId query int true "客户ID"
- // @Success 200 {object} []company.PermissionLookItem
- // @router /company/last_contract/detail [get]
- func (this *CompanyApplyController) GetLastContractDetail() {
- 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
- }
- companyId, _ := this.GetInt("CompanyId")
- if companyId <= 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误,客户id小于等于0"
- return
- }
- roleTypeCode := sysUser.RoleTypeCode
- productId := services.GetProductId(roleTypeCode)
- if productId == 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "客户类型为:" + roleTypeCode
- return
- }
- //permissionMap := make(map[int]company.PermissionLookItem)
- //contractList, err := company.GetCompanyWillContractList(companyId, productId)
- //if err != nil {
- // br.Msg = "获取合同信息失败"
- // br.ErrMsg = "获取合同信息失败,Err:" + err.Error()
- // return
- //}
- //for _, contractInfo := range contractList {
- // permissionList, permissionErr := company.GetCompanyContractPermissionListByContractIds(strconv.Itoa(contractInfo.CompanyContractId))
- // if permissionErr != nil {
- // br.Msg = "获取权限失败"
- // br.ErrMsg = "获取权限失败,Err:" + permissionErr.Error()
- // return
- // }
- // for _, v := range permissionList {
- // if permission, ok := permissionMap[v.ChartPermissionId]; ok {
- // nowEndDateTime, err := time.Parse(utils.FormatDate, v.EndDate)
- // if err != nil {
- // br.Msg = "获取合同信息失败"
- // br.ErrMsg = "获取合同信息失败,合同结束日期格式化失败,Err:" + err.Error()
- // return
- // }
- // perEndDateTime, err := time.Parse(utils.FormatDate, permission.EndDate)
- // if err != nil {
- // br.Msg = "获取合同信息失败"
- // br.ErrMsg = "获取合同信息失败,合同结束日期格式化失败2,Err:" + err.Error()
- // return
- // }
- // //如果当前合同的权限期限晚于已经记录的权限期限,那么重新赋值
- // if nowEndDateTime.After(perEndDateTime) {
- // permissionMap[v.ChartPermissionId] = company.PermissionLookItem{
- // ChartPermissionId: v.ChartPermissionId,
- // PermissionName: v.ChartPermissionName,
- // StartDate: v.StartDate,
- // EndDate: v.EndDate,
- // //Status string `description:"'正式','试用','关闭'"`
- // //ExpireDay string `description:"到期天数"`
- // ClassifyName: v.ClassifyName,
- // }
- // }
- // } else {
- // permissionMap[v.ChartPermissionId] = company.PermissionLookItem{
- // ChartPermissionId: v.ChartPermissionId,
- // PermissionName: v.ChartPermissionName,
- // StartDate: v.StartDate,
- // EndDate: v.EndDate,
- // //Status string `description:"'正式','试用','关闭'"`
- // //ExpireDay string `description:"到期天数"`
- // ClassifyName: v.ClassifyName,
- // }
- // }
- // }
- //}
- //
- ////获取权限
- //permissionList, permissionErr := company.GetCompanyReportPermissionListByProductId(companyId, productId)
- //if permissionErr != nil {
- // br.Msg = "获取权限失败"
- // br.ErrMsg = "获取权限失败,Err:" + permissionErr.Error()
- // return
- //}
- //for _, v := range permissionList {
- // if permission, ok := permissionMap[v.ChartPermissionId]; ok {
- // nowEndDateTime, err := time.Parse(utils.FormatDate, v.EndDate)
- // if err != nil {
- // br.Msg = "获取合同信息失败"
- // br.ErrMsg = "获取合同信息失败,合同结束日期格式化失败,Err:" + err.Error()
- // return
- // }
- // perEndDateTime, err := time.Parse(utils.FormatDate, permission.EndDate)
- // if err != nil {
- // br.Msg = "获取合同信息失败"
- // br.ErrMsg = "获取合同信息失败,合同结束日期格式化失败2,Err:" + err.Error()
- // return
- // }
- // //如果当前合同的权限期限晚于已经记录的权限期限,那么重新赋值
- // if nowEndDateTime.After(perEndDateTime) {
- // permissionMap[v.ChartPermissionId] = company.PermissionLookItem{
- // ChartPermissionId: v.ChartPermissionId,
- // PermissionName: v.PermissionName,
- // StartDate: v.StartDate,
- // EndDate: v.EndDate,
- // //Status string `description:"'正式','试用','关闭'"`
- // //ExpireDay string `description:"到期天数"`
- // ClassifyName: v.ClassifyName,
- // }
- // }
- // } else {
- // permissionMap[v.ChartPermissionId] = company.PermissionLookItem{
- // ChartPermissionId: v.ChartPermissionId,
- // PermissionName: v.PermissionName,
- // StartDate: v.StartDate,
- // EndDate: v.EndDate,
- // //Status string `description:"'正式','试用','关闭'"`
- // //ExpireDay string `description:"到期天数"`
- // ClassifyName: v.ClassifyName,
- // }
- // }
- //}
- permissionMap, err := services.GetLastContractPermissionList(companyId, productId)
- if err != nil {
- br.Msg = "获取合同权限信息失败"
- br.ErrMsg = "获取合同信息失败,Err:" + err.Error()
- return
- }
- //数据处理
- permissionSlice := make([]company.PermissionLookItem, 0)
- for _, permission := range permissionMap {
- permissionSlice = append(permissionSlice, permission)
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = permissionSlice
- }
- // ApplyServiceUpdateOld
- // @Title 申请服务更新
- // @Description 申请服务更新接口
- // @Param request body company.CompanyApplyServiceUpdateReq true "type json string"
- // @Success Ret=200 申请成功
- //func (this *CompanyApplyController) ApplyServiceUpdateOld() {
- // 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 req company.CompanyApplyServiceUpdateReq
- // err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- // if err != nil {
- // br.Msg = "参数解析异常!"
- // br.ErrMsg = "参数解析失败,Err:" + err.Error()
- // return
- // }
- // if req.CompanyId <= 0 {
- // br.Msg = "参数错误"
- // br.ErrMsg = "参数错误,客户id小于等于0"
- // return
- // }
- // if req.StartDate == "" {
- // br.Msg = "请选择合同开始日期"
- // return
- // }
- // if req.EndDate == "" {
- // br.Msg = "请选择合同结束日期"
- // return
- // }
- // if req.Money <= 0 {
- // br.Msg = "合同金额不能小于等于0"
- // }
- //
- // if req.ContractType == "" {
- // req.ContractType = "续约合同"
- // //br.Msg = "请选择合同类型"
- // //return
- // }
- // roleTypeCode := sysUser.RoleTypeCode
- // productId := services.GetProductId(roleTypeCode)
- // if productId == 0 {
- // br.Msg = "参数错误"
- // br.ErrMsg = "客户类型为:" + req.CompanyType
- // 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 {
- // br.Msg = "客户状态为:" + companyProduct.Status + ";不可进行服务更新申请"
- // br.ErrMsg = "客户状态为:" + companyProduct.Status + ";不可进行服务更新申请"
- // return
- // }
- // var approveUserId int
- // var approveUserRealName string
- // approveContent := `正式客户申请服务更新`
- //
- // approveUser, err := company.GetApproveUser(approveRoleTypeCode)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // br.Msg = "获取审批信息失败"
- // br.ErrMsg = "获取审批人信息失败,Err:" + err.Error()
- // return
- // }
- // if approveUser == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
- // br.Msg = "审批用户不存在"
- // br.ErrMsg = "审批用户不存在"
- // return
- // }
- //
- // var companyApprovalId int
- // if req.CompanyApprovalId <= 0 {
- // contractCode, err := company.GetCompanyContractCode()
- // if err != nil {
- // br.Msg = "生成合同编码失败"
- // br.ErrMsg = "生成合同编码失败,Err:" + err.Error()
- // return
- // }
- // //当前待审批的合同,有且只能存在一条
- // count, err := company.GetCompanyContractApproveCount(req.CompanyId, productId)
- // if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "判断是否已存在待审批合同失败,Err:" + err.Error()
- // return
- // }
- // if count > 0 {
- // br.Msg = "此客户已提交过申请,请在客户审批列表重新提交"
- // return
- // }
- // contract := new(company.CompanyContract)
- // contract.CompanyId = req.CompanyId
- // contract.ProductId = productId
- // contract.ProductName = companyProduct.ProductName
- // contract.CompanyProductId = companyProduct.CompanyProductId
- // contract.ContractType = req.ContractType
- // contract.ContractCode = contractCode
- // contract.StartDate = req.StartDate
- // contract.EndDate = req.EndDate
- // contract.Money = req.Money
- // contract.PayMethod = req.PayMethod
- // contract.PayChannel = req.PayChannel
- // contract.ImgUrl = req.ImgUrl
- // contract.Status = 0
- // contract.Source = "上传附件"
- // contract.CreateTime = time.Now()
- // contract.ModifyTime = time.Now()
- // newId, err := company.AddCompanyContract(contract)
- // if err != nil {
- // br.Msg = "新增合同失败"
- // br.ErrMsg = "新增合同失败,Err:" + err.Error()
- // return
- // }
- // permissionArr := strings.Split(req.PermissionIds, ",")
- // for _, v := range permissionArr {
- // item := new(company.CompanyContractPermission)
- // item.CompanyId = req.CompanyId
- // item.CompanyContractId = int(newId)
- //
- // chartPermissionId, tmpErr := strconv.Atoi(v)
- // if tmpErr != nil {
- // err = tmpErr
- // return
- // }
- // item.ChartPermissionId = chartPermissionId
- //
- // item.StartDate = req.StartDate
- // item.EndDate = req.EndDate
- // item.ModifyTime = time.Now()
- // item.CreateTime = time.Now()
- // err = company.AddCompanyContractPermission(item)
- // if err != nil {
- // br.Msg = "新增合同失败"
- // br.ErrMsg = "新增合同权限失败,Err:" + err.Error()
- // return
- // }
- // //新增日志
- // {
- // itemLog := new(company.CompanyContractPermissionLog)
- // itemLog.CompanyId = req.CompanyId
- // itemLog.CompanyContractId = int(newId)
- // itemLog.ChartPermissionId = v
- // itemLog.StartDate = req.StartDate
- // itemLog.EndDate = req.EndDate
- // itemLog.ModifyTime = time.Now()
- // itemLog.CreateTime = time.Now()
- // itemLog.LogCreateTime = time.Now()
- // go company.AddCompanyContractPermissionLog(itemLog)
- // }
- // }
- // applyMethod := 5
- // //申请类型:1:试用->正式,2:冻结—>试用,3:试用延期,4:原销售申请领取流失客户,5:正式客户申请服务更新,6:正式客户补充协议
- // approval := new(company.CompanyApproval)
- // approval.CompanyId = req.CompanyId
- // approval.ProductId = productId
- // approval.ApproveStatus = "待审批"
- // approval.ApproveUserId = 0
- // approval.ApproveRoleTypeCode = approveRoleTypeCode
- // approval.ApproveRealName = ""
- // approval.ApproveTime = time.Now()
- // approval.ApproveContent = "服务更新"
- // approval.ApplyMethod = applyMethod
- // approval.ApplyReasons = ""
- // approval.ApplyUserId = sysUser.AdminId
- // approval.ApplyRealName = sysUser.RealName
- // approval.CreateTime = time.Now()
- // approval.ModifyTime = time.Now()
- // approval.CompanyContractId = int(newId)
- // companyApprovalId, err = company.AddCompanyApproval(approval)
- // if err != nil {
- // br.Msg = "申请失败"
- // br.ErrMsg = "申请失败,Err:" + err.Error()
- // return
- // }
- // } else {
- // recode, err := company.GetCompanyApprovalByApprovalId(req.CompanyApprovalId)
- // if err != nil {
- // br.Msg = "申请失败"
- // br.ErrMsg = "获取审批记录失败,Err:" + err.Error()
- // return
- // }
- // err = company.ModifyCompanyApplyServiceUpdate(&req, productId, companyProduct.IsFormal, recode.CompanyContractId)
- // if err != nil {
- // br.Msg = "申请失败"
- // br.ErrMsg = "申请失败,Err:" + err.Error()
- // return
- // }
- // companyApprovalId = req.CompanyApprovalId
- // }
- // //新增操作记录
- // {
- // remark := "服务更新"
- // operation := "service_update"
- // services.AddCompanyOperationRecord(req.CompanyId, companyProduct.SellerId, sysUser.AdminId, productId, approveUserId, companyProduct.CompanyName,
- // companyProduct.ProductName, sysUser.RealName, remark, operation, approveContent, approveUserRealName, "", companyProduct.Status)
- // }
- // //新增客户产品日志
- // {
- // logType := "modify"
- // go services.AddCompanyProductLog(companyProduct, this.SysUser.AdminId, logType)
- // }
- // //待办通知
- // {
- // for _, v := range approveUser {
- // approveUserId = v.AdminId
- // approveUserRealName = v.RealName
- // mobile := v.Mobile
- // content := "服务更新申请单"
- // err = services.AddCompanyApprovalMessage(sysUser.AdminId, approveUserId, req.CompanyId, companyApprovalId, 1, 1, 1, companyProduct.CompanyName, content, content, mobile)
- // if err != nil {
- // br.Msg = "申请失败"
- // br.ErrMsg = "新增待办通知失败,Err:" + err.Error()
- // return
- // }
- // }
- // }
- // br.Ret = 200
- // br.Success = true
- // br.Msg = "申请成功"
- //}
- // ApplyTurnPositiveOld
- // @Title 申请转正
- // @Description 申请转正接口
- // @Param request body company.CompanyApplyTurnPositiveReq true "type json string"
- // @Success Ret=200 申请成功
- //func (this *CompanyApplyController) ApplyTurnPositiveOld() {
- // 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 req company.CompanyApplyTurnPositiveReq
- // err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- // if err != nil {
- // br.Msg = "参数解析异常!"
- // br.ErrMsg = "参数解析失败,Err:" + err.Error()
- // return
- // }
- // if req.CompanyId <= 0 {
- // br.Msg = "参数错误"
- // br.ErrMsg = "参数错误,客户id小于等于0"
- // return
- // }
- // if req.StartDate == "" {
- // br.Msg = "请选择合同开始日期"
- // return
- // }
- // if req.EndDate == "" {
- // br.Msg = "请选择合同结束日期"
- // return
- // }
- //
- // if req.Money <= 0 {
- // br.Msg = "合同金额不能小于等于0"
- // return
- // }
- // roleTypeCode := sysUser.RoleTypeCode
- // productId := services.GetProductId(roleTypeCode)
- // if productId == 0 {
- // br.Msg = "参数错误"
- // br.ErrMsg = "客户类型为:" + roleTypeCode
- // return
- // }
- // companyProduct, err := company.GetCompanyProductByCompanyIdAndProductId(req.CompanyId, productId)
- // if err != nil {
- // br.Msg = "获取客户信息失败"
- // br.ErrMsg = "获取客户信息失败"
- // return
- // }
- // if companyProduct == nil {
- // br.Msg = "获取客户信息失败"
- // br.ErrMsg = "客户不存在,不可提交审批:companyId:" + strconv.Itoa(req.CompanyId) + ";productId:" + strconv.Itoa(productId)
- // return
- // }
- // if companyProduct.Status != utils.COMPANY_STATUS_TRY_OUT {
- // br.Msg = "客户状态为:" + companyProduct.Status + ";不可进行转正申请"
- // br.ErrMsg = "客户状态为:" + companyProduct.Status + ";不可进行转正申请"
- // return
- // }
- //
- // if companyProduct.ApproveStatus == "待审批" {
- // br.Msg = "存在待审批订单,不可重复提交"
- // return
- // }
- // approveContent := `试用转正式`
- // var approveUserId int
- // var approveUserRealName string
- // approveRoleTypeCode := ""
- // if productId == 1 {
- // approveRoleTypeCode = utils.ROLE_TYPE_CODE_FICC_ADMIN
- // } else {
- // approveRoleTypeCode = utils.ROLE_TYPE_CODE_RAI_ADMIN
- // }
- // approveUser, err := company.GetApproveUser(approveRoleTypeCode)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // br.Msg = "获取审批信息失败"
- // br.ErrMsg = "获取审批人信息失败,Err:" + err.Error()
- // return
- // }
- // if approveUser == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
- // br.Msg = "审批用户不存在"
- // br.ErrMsg = "审批用户不存在"
- // return
- // }
- //
- // //合同类型
- // contractType := req.ContractType
- // if contractType == "" {
- // contractType = "新签合同"
- // }
- // var condition string
- // var pars []interface{}
- // condition += " AND product_id = ?"
- // pars = append(pars, productId)
- // condition += " AND status = ?"
- // pars = append(pars, 1)
- // list, err := company.GetCompanyContractListByCompanyId(req.CompanyId, condition, pars)
- // if err != nil {
- // br.Msg = "获取合同信息失败"
- // br.ErrMsg = "获取合同信息失败,Err:" + err.Error()
- // return
- // }
- // if len(list) > 0 {
- // contractType = "续约合同"
- // }
- // //查询是否存在正式转试用的记录,如果存在,那么合同类型是续约合同
- // total, err := company.GetCompanyProductOperationRecordCount(companyProduct.CompanyId, companyProduct.ProductId)
- // if err != nil {
- // br.Msg = "查询用户信息异常"
- // br.ErrMsg = "查询用户变更记录异常"
- // return
- // }
- // if total > 0 {
- // contractType = "续约合同"
- // }
- // //合同类型 end
- //
- // var companyApprovalId int
- // if req.CompanyApprovalId <= 0 {
- // contractCode, err := company.GetCompanyContractCode()
- // if err != nil {
- // br.Msg = "生成合同编码失败"
- // br.ErrMsg = "生成合同编码失败,Err:" + err.Error()
- // return
- // }
- // //当前待审批的合同,有且只能存在一条
- // count, err := company.GetCompanyContractApproveCount(req.CompanyId, productId)
- // if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "判断是否已存在待审批合同失败,Err:" + err.Error()
- // return
- // }
- // if count > 0 {
- // br.Msg = "此客户已提交过申请,请在客户审批列表重新提交"
- // return
- // }
- // contract := new(company.CompanyContract)
- // contract.CompanyId = req.CompanyId
- // contract.ProductId = productId
- // contract.ContractType = contractType
- // contract.ProductName = companyProduct.ProductName
- // contract.CompanyProductId = companyProduct.CompanyProductId
- // contract.ContractCode = contractCode
- // contract.StartDate = req.StartDate
- // contract.EndDate = req.EndDate
- // contract.Money = req.Money
- // contract.PayMethod = req.PayMethod
- // contract.PayChannel = req.PayChannel
- // contract.ImgUrl = req.ImgUrl
- // contract.Status = 0
- // contract.Source = "上传附件"
- // contract.CreateTime = time.Now()
- // contract.ModifyTime = time.Now()
- // newId, err := company.AddCompanyContract(contract)
- // if err != nil {
- // br.Msg = "新增合同失败"
- // br.ErrMsg = "新增合同失败,Err:" + err.Error()
- // return
- // }
- // permissionArr := strings.Split(req.PermissionIds, ",")
- // for _, v := range permissionArr {
- // item := new(company.CompanyContractPermission)
- // item.CompanyId = req.CompanyId
- // item.CompanyContractId = int(newId)
- //
- // chartPermissionId, tmpErr := strconv.Atoi(v)
- // if tmpErr != nil {
- // err = tmpErr
- // return
- // }
- // item.ChartPermissionId = chartPermissionId
- //
- // item.StartDate = req.StartDate
- // item.EndDate = req.EndDate
- // item.ModifyTime = time.Now()
- // item.CreateTime = time.Now()
- // err = company.AddCompanyContractPermission(item)
- // if err != nil {
- // br.Msg = "新增合同失败"
- // br.ErrMsg = "新增合同权限失败,Err:" + err.Error()
- // return
- // }
- // //新增日志
- // {
- // itemLog := new(company.CompanyContractPermissionLog)
- // itemLog.CompanyId = req.CompanyId
- // itemLog.CompanyContractId = int(newId)
- // itemLog.ChartPermissionId = v
- // itemLog.StartDate = req.StartDate
- // itemLog.EndDate = req.EndDate
- // itemLog.ModifyTime = time.Now()
- // itemLog.CreateTime = time.Now()
- // itemLog.LogCreateTime = time.Now()
- // go company.AddCompanyContractPermissionLog(itemLog)
- // }
- // }
- // applyMethod := 1
- // approval := new(company.CompanyApproval)
- // approval.CompanyId = req.CompanyId
- // approval.ProductId = productId
- // approval.ApproveStatus = "待审批"
- // approval.ApproveUserId = 0
- // approval.ApproveRoleTypeCode = approveRoleTypeCode
- // approval.ApproveRealName = ""
- // approval.ApproveTime = time.Now()
- // approval.ApproveContent = "试用转正式"
- // approval.ApplyMethod = applyMethod
- // approval.ApplyReasons = ""
- // approval.ApplyUserId = sysUser.AdminId
- // approval.ApplyRealName = sysUser.RealName
- // approval.CreateTime = time.Now()
- // approval.ModifyTime = time.Now()
- // approval.CompanyContractId = int(newId)
- // companyApprovalId, err = company.AddCompanyApproval(approval)
- // if err != nil {
- // br.Msg = "申请失败"
- // br.ErrMsg = "申请失败,Err:" + err.Error()
- // return
- // }
- // } else {
- // recode, err := company.GetCompanyApprovalByApprovalId(req.CompanyApprovalId)
- // if err != nil {
- // br.Msg = "申请失败"
- // br.ErrMsg = "获取审批记录失败,Err:" + err.Error()
- // return
- // }
- // err = company.ModifyCompanyTurnPositive(&req, productId, recode.CompanyContractId, companyProduct.IsFormal, map[int]int{})
- // if err != nil {
- // br.Msg = "申请失败"
- // br.ErrMsg = "申请失败,Err:" + err.Error()
- // return
- // }
- // companyApprovalId = req.CompanyApprovalId
- // }
- // //新增操作记录
- // {
- // remark := "申请转正"
- // operation := "turn_positive"
- // services.AddCompanyOperationRecord(req.CompanyId, companyProduct.SellerId, sysUser.AdminId, productId, approveUserId, companyProduct.CompanyName,
- // companyProduct.ProductName, sysUser.RealName, remark, operation, approveContent, approveUserRealName, "", companyProduct.Status)
- // }
- // //新增客户产品日志
- // {
- // logType := "modify"
- // go services.AddCompanyProductLog(companyProduct, this.SysUser.AdminId, logType)
- // }
- // //待办通知
- // {
- // for _, v := range approveUser {
- // approveUserId = v.AdminId
- // approveUserRealName = v.RealName
- // mobile := v.Mobile
- // content := "试用转正式申请单"
- // err = services.AddCompanyApprovalMessage(sysUser.AdminId, approveUserId, req.CompanyId, companyApprovalId, 1, 1, 1, companyProduct.CompanyName, content, content, mobile)
- // if err != nil {
- // br.Msg = "申请失败"
- // br.ErrMsg = "新增待办通知失败,Err:" + err.Error()
- // return
- // }
- // }
- // }
- // br.Ret = 200
- // br.Success = true
- // br.Msg = "申请成功"
- //}
- // ApplyThawOld
- // @Title 申请解冻
- // @Description 申请解冻接口
- // @Param request body company.CompanyApplyThawReq true "type json string"
- // @Success Ret=200 申请成功
- func (this *CompanyApplyController) ApplyThawOld() {
- 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 req company.CompanyApplyThawReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.CompanyId <= 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误,客户id小于等于0"
- return
- }
- roleTypeCode := sysUser.RoleTypeCode
- productId := services.GetProductId(roleTypeCode)
- if productId == 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "客户类型为:" + roleTypeCode
- 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 == nil {
- br.Msg = "获取客户信息失败"
- br.ErrMsg = "客户不存在,不可提交审批:companyId:" + strconv.Itoa(req.CompanyId) + ";productId:" + strconv.Itoa(productId)
- return
- }
- if companyProduct.Status != utils.COMPANY_STATUS_FREEZE {
- br.Msg = "客户状态为:" + companyProduct.Status + ";不可进行解冻申请"
- br.ErrMsg = "客户状态为:" + companyProduct.Status + ";不可进行解冻申请"
- return
- }
- if companyProduct.ApproveStatus == utils.COMPANY_APPROVE_STATUS {
- br.Msg = "存在待审批订单,不可重复提交"
- return
- }
- approveUser, err := company.GetApproveUser(approveRoleTypeCode)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取审批信息失败"
- br.ErrMsg = "获取审批人信息失败,Err:" + err.Error()
- return
- }
- if approveUser == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
- br.Msg = "审批用户不存在"
- br.ErrMsg = "审批用户不存在"
- return
- }
- //申请类型:1:试用->正式,2:冻结—>试用,3:试用延期,4:原销售申请领取流失客户,5:正式客户申请服务更新,6:正式客户补充协议
- approveContent := `冻结转试用`
- var companyApprovalId int
- if req.CompanyApprovalId <= 0 {
- applyMethod := 2
- approval := new(company.CompanyApproval)
- approval.CompanyId = req.CompanyId
- approval.ProductId = productId
- approval.ApproveStatus = "待审批"
- approval.ApproveUserId = 0
- approval.ApproveRoleTypeCode = approveRoleTypeCode
- approval.ApproveRealName = ""
- approval.ApproveTime = time.Now()
- approval.ApproveContent = approveContent
- approval.ApplyMethod = applyMethod
- approval.ApplyReasons = req.ApplyRemark
- approval.ApplyUserId = sysUser.AdminId
- approval.ApplyRealName = sysUser.RealName
- approval.CreateTime = time.Now()
- approval.ModifyTime = time.Now()
- companyApprovalId, err = company.AddCompanyApproval(approval)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "申请失败,Err:" + err.Error()
- return
- }
- } else {
- err = company.ModifyCompanyApproval(req.CompanyId, productId, req.CompanyApprovalId, approveContent, req.ApplyRemark)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "申请失败,Err:" + err.Error()
- return
- }
- companyApprovalId = req.CompanyApprovalId
- //先删除之前申请的权限
- _ = company.DeleteCompanyDelayPermission(req.CompanyApprovalId)
- }
- //处理权限
- {
- if req.PermissionIds != "" {
- permissionArr := strings.Split(req.PermissionIds, ",")
- for _, v := range permissionArr {
- //fmt.Println(k, v)
- //新增
- if v != "" {
- permissionId, err := strconv.Atoi(v)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "权限格式转换失败,Err:" + err.Error()
- return
- }
- delayItem := new(company.CompanyDelayPermission)
- delayItem.CompanyId = req.CompanyId
- delayItem.CompanyApplyId = companyApprovalId
- delayItem.ChartPermissionId = permissionId
- delayItem.StartDate = time.Now().Format(utils.FormatDate)
- delayItem.EndDate = time.Now().AddDate(0, 2, 0).Format(utils.FormatDate)
- delayItem.CreateTime = time.Now()
- delayItem.ModifyTime = time.Now()
- err = company.AddCompanyDelayPermission(delayItem)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "新增冻结转试用审批权限失败,Err:" + err.Error()
- return
- }
- }
- }
- }
- }
- //新增操作记录
- {
- remark := "申请解冻"
- operation := "thaw"
- services.AddCompanyOperationRecord(req.CompanyId, companyProduct.SellerId, sysUser.AdminId, productId, 0, companyProduct.CompanyName,
- companyProduct.ProductName, sysUser.RealName, remark, operation, approveContent, "", "", companyProduct.Status)
- }
- //新增客户产品日志
- {
- logType := "modify"
- go services.AddCompanyProductLog(companyProduct, this.SysUser.AdminId, logType)
- }
- //待办通知
- {
- for _, v := range approveUser {
- approveUserId := v.AdminId
- //approveUserRealName := v.RealName
- mobile := v.Mobile
- content := "冻结转试用申请单"
- err = services.AddCompanyApprovalMessage(sysUser.AdminId, approveUserId, req.CompanyId, companyApprovalId, 1, 1, 1, companyProduct.CompanyName, content, content, mobile)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "新增待办通知失败,Err:" + err.Error()
- return
- }
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "申请成功"
- }
- // ApplyDelayOld
- // @Title 申请延期
- // @Description 申请延期接口
- // @Param request body company.CompanyApplyDelayReq true "type json string"
- // @Success Ret=200 申请成功
- func (this *CompanyApplyController) ApplyDelayOld() {
- 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 req company.CompanyApplyDelayReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.CompanyId <= 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误,客户id小于等于0"
- return
- }
- roleTypeCode := sysUser.RoleTypeCode
- productId := services.GetProductId(roleTypeCode)
- if productId == 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "客户类型为:" + roleTypeCode
- 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 == nil {
- br.Msg = "获取客户信息失败"
- br.ErrMsg = "客户不存在,不可提交审批:companyId:" + strconv.Itoa(req.CompanyId) + ";productId:" + strconv.Itoa(productId)
- return
- }
- if companyProduct.Status != utils.COMPANY_STATUS_TRY_OUT {
- br.Msg = "客户状态为:" + companyProduct.Status + ";不可进行延期申请"
- br.ErrMsg = "客户状态为:" + companyProduct.Status + ";不可进行延期申请"
- return
- }
- if companyProduct.ApproveStatus == "待审批" {
- br.Msg = "存在待审批订单,不可重复提交"
- return
- }
- approveUser, err := company.GetApproveUser(approveRoleTypeCode)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取审批信息失败"
- br.ErrMsg = "获取审批人信息失败,Err:" + err.Error()
- return
- }
- if approveUser == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
- br.Msg = "审批用户不存在"
- br.ErrMsg = "审批用户不存在"
- return
- }
- //申请类型:1:试用->正式,2:冻结—>试用,3:试用延期,4:原销售申请领取流失客户,5:正式客户申请服务更新,6:正式客户补充协议
- approveContent := `试用延期`
- var companyApprovalId int
- utils.FileLog.Info("试用延期申请:%d", req.CompanyApprovalId)
- if req.CompanyApprovalId > 0 {
- utils.FileLog.Info("试用延期申请:%d", req.CompanyApprovalId)
- err = company.ModifyCompanyApproval(req.CompanyId, productId, req.CompanyApprovalId, approveContent, req.ApplyRemark)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "申请失败,Err:" + err.Error()
- return
- }
- companyApprovalId = req.CompanyApprovalId
- } else {
- applyMethod := 3
- approval := new(company.CompanyApproval)
- approval.CompanyId = req.CompanyId
- approval.ProductId = productId
- approval.ApproveStatus = "待审批"
- approval.ApproveUserId = 0
- approval.ApproveRoleTypeCode = approveRoleTypeCode
- approval.ApproveRealName = ""
- approval.ApproveTime = time.Now()
- approval.ApproveContent = "试用延期"
- approval.ApplyMethod = applyMethod
- approval.ApplyReasons = req.ApplyRemark
- approval.ApplyUserId = sysUser.AdminId
- approval.ApplyRealName = sysUser.RealName
- approval.CreateTime = time.Now()
- approval.ModifyTime = time.Now()
- companyApprovalId, err = company.AddCompanyApproval(approval)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "申请失败,Err:" + err.Error()
- return
- }
- //处理权限
- {
- if req.PermissionIds != "" {
- permissionArr := strings.Split(req.PermissionIds, ",")
- for k, v := range permissionArr {
- fmt.Println(k, v)
- permissionId, _ := strconv.Atoi(v)
- //companyId, companyApplyId, chartPermissionId int
- count, err := company.GetDelayPermissionCount(req.CompanyId, companyApprovalId, permissionId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "申请失败"
- br.ErrMsg = "判断权限是否存在失败,Err:" + err.Error()
- return
- }
- if count > 0 { //修改
- err = company.ModifyCompanyDelayPermission(req.CompanyId, companyApprovalId, permissionId)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "修改权限失败,Err:" + err.Error()
- return
- }
- } else { //新增
- if v != "" {
- permissionId, err := strconv.Atoi(v)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "权限格式转换失败,Err:" + err.Error()
- return
- }
- delayItem := new(company.CompanyDelayPermission)
- delayItem.CompanyId = req.CompanyId
- delayItem.CompanyApplyId = companyApprovalId
- delayItem.ChartPermissionId = permissionId
- delayItem.StartDate = time.Now().Format(utils.FormatDate)
- delayItem.EndDate = time.Now().AddDate(0, 2, 0).Format(utils.FormatDate)
- delayItem.CreateTime = time.Now()
- delayItem.ModifyTime = time.Now()
- err = company.AddCompanyDelayPermission(delayItem)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "新增延期审批权限失败,Err:" + err.Error()
- return
- }
- }
- }
- }
- }
- }
- }
- //新增操作记录
- {
- remark := "申请延期"
- operation := "delay"
- go services.AddCompanyOperationRecord(req.CompanyId, companyProduct.SellerId, sysUser.AdminId, productId, 0, companyProduct.CompanyName,
- companyProduct.ProductName, sysUser.RealName, remark, operation, approveContent, "", "", companyProduct.Status)
- }
- //新增客户产品日志
- {
- logType := "modify"
- go services.AddCompanyProductLog(companyProduct, this.SysUser.AdminId, logType)
- }
- //待办通知
- {
- for _, v := range approveUser {
- approveUserId := v.AdminId
- //approveUserRealName := v.RealName
- mobile := v.Mobile
- content := "试用延期申请单"
- utils.FileLog.Info("mobile:%s", mobile)
- go services.AddCompanyApprovalMessage(sysUser.AdminId, approveUserId, req.CompanyId, companyApprovalId, 1, 1, 1, companyProduct.CompanyName, content, content, mobile)
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "申请成功"
- }
- // ApplyReceiveOld
- // @Title 申请领取
- // @Description 申请领取接口
- // @Param request body company.CompanyApplyReceiveReq true "type json string"
- // @Success Ret=200 申请成功
- func (this *CompanyApplyController) ApplyReceiveOld() {
- 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 req company.CompanyApplyReceiveReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.CompanyId <= 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误,客户id小于等于0"
- return
- }
- roleTypeCode := sysUser.RoleTypeCode
- productId := services.GetProductId(roleTypeCode)
- if productId == 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "客户类型为:" + roleTypeCode
- 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 == nil {
- br.Msg = "获取客户信息失败"
- br.ErrMsg = "客户不存在,不可提交审批:companyId:" + strconv.Itoa(req.CompanyId) + ";productId:" + strconv.Itoa(productId)
- return
- }
- if companyProduct.Status != utils.COMPANY_STATUS_LOSE {
- br.Msg = "客户状态为:" + companyProduct.Status + ";不可进行延期申请"
- br.ErrMsg = "客户状态为:" + companyProduct.Status + ";不可进行延期申请"
- return
- }
- if companyProduct.ApproveStatus == "待审批" {
- br.Msg = "存在待审批订单,不可重复提交"
- return
- }
- approveUser, err := company.GetApproveUser(approveRoleTypeCode)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取审批信息失败"
- br.ErrMsg = "获取审批人信息失败,Err:" + err.Error()
- return
- }
- if approveUser == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
- br.Msg = "审批用户不存在"
- br.ErrMsg = "审批用户不存在"
- return
- }
- approveContent := `原销售申领客户`
- applyMethod := 4
- var companyApprovalId int
- //申请类型:1:试用->正式,2:冻结—>试用,3:试用延期,4:原销售申请领取流失客户,5:正式客户申请服务更新,6:正式客户补充协议
- if req.CompanyApprovalId <= 0 {
- approval := new(company.CompanyApproval)
- approval.CompanyId = req.CompanyId
- approval.ProductId = productId
- approval.ApproveStatus = "待审批"
- approval.ApproveUserId = 0
- approval.ApproveRoleTypeCode = approveRoleTypeCode
- approval.ApproveRealName = ""
- approval.ApproveTime = time.Now()
- approval.ApproveContent = approveContent
- approval.ApplyMethod = applyMethod
- approval.ApplyReasons = req.ApplyRemark
- approval.ApplyUserId = sysUser.AdminId
- approval.ApplyRealName = sysUser.RealName
- approval.CreateTime = time.Now()
- approval.ModifyTime = time.Now()
- companyApprovalId, err = company.AddCompanyApproval(approval)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "申请失败,Err:" + err.Error()
- return
- }
- } else {
- err = company.ModifyCompanyApproval(req.CompanyId, productId, req.CompanyApprovalId, approveContent, req.ApplyRemark)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "申请失败,Err:" + err.Error()
- return
- }
- companyApprovalId = req.CompanyApprovalId
- //先删除之前申请的权限
- _ = company.DeleteCompanyDelayPermission(req.CompanyApprovalId)
- }
- //处理权限
- {
- if req.PermissionIds != "" {
- permissionArr := strings.Split(req.PermissionIds, ",")
- for _, v := range permissionArr {
- if v != "" {
- permissionId, err := strconv.Atoi(v)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "权限格式转换失败,Err:" + err.Error()
- return
- }
- delayItem := new(company.CompanyDelayPermission)
- delayItem.CompanyId = req.CompanyId
- delayItem.CompanyApplyId = companyApprovalId
- delayItem.ChartPermissionId = permissionId
- delayItem.StartDate = time.Now().Format(utils.FormatDate)
- delayItem.EndDate = time.Now().AddDate(0, 2, 0).Format(utils.FormatDate)
- delayItem.CreateTime = time.Now()
- delayItem.ModifyTime = time.Now()
- err = company.AddCompanyDelayPermission(delayItem)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "新增领取客户审批权限失败,Err:" + err.Error()
- return
- }
- }
- }
- }
- }
- //新增操作记录
- {
- remark := "申请领取"
- operation := "apply_receive"
- services.AddCompanyOperationRecord(req.CompanyId, companyProduct.SellerId, sysUser.AdminId, productId, 0, companyProduct.CompanyName,
- companyProduct.ProductName, sysUser.RealName, remark, operation, approveContent, "", "", companyProduct.Status)
- }
- //新增客户产品日志
- {
- logType := "modify"
- go services.AddCompanyProductLog(companyProduct, this.SysUser.AdminId, logType)
- }
- //待办通知
- {
- for _, v := range approveUser {
- approveUserId := v.AdminId
- //approveUserRealName := v.RealName
- mobile := v.Mobile
- content := "申请领取申请单"
- err = services.AddCompanyApprovalMessage(sysUser.AdminId, approveUserId, req.CompanyId, companyApprovalId, 1, 1, 1, companyProduct.CompanyName, content, content, mobile)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "新增待办通知失败,Err:" + err.Error()
- return
- }
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "申请成功"
- }
- // ApplyRevokeOld
- // @Title 申请撤回
- // @Description 申请撤回接口
- // @Param request body company.CompanyApplyRevokeReq true "type json string"
- // @Success Ret=200 成功
- func (this *CompanyApprovalController) ApplyRevokeOld() {
- 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 req company.CompanyApplyRevokeReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.CompanyId <= 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "客户Id小于等于0:"
- return
- }
- roleTypeCode := sysUser.RoleTypeCode
- productId := services.GetProductId(roleTypeCode)
- if productId == 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "客户类型为:" + roleTypeCode
- return
- }
- companyProduct, err := company.GetCompanyProductByCompanyIdAndProductId(req.CompanyId, productId)
- if err != nil {
- br.Msg = "获取客户信息失败"
- br.ErrMsg = "获取客户信息失败"
- return
- }
- if companyProduct == nil {
- br.Msg = "获取客户信息失败"
- br.ErrMsg = "客户不存在,不可提交审批:companyId:" + strconv.Itoa(req.CompanyId) + ";productId:" + strconv.Itoa(productId)
- return
- }
- approvalItem, err := company.GetCompanyApprovalById(req.CompanyId, productId)
- if err != nil {
- if err.Error() == utils.ErrNoRow() {
- br.Msg = "待审批信息不存在"
- br.ErrMsg = "待审批信息不存在,CompanyId:" + strconv.Itoa(req.CompanyId) + ";productId:" + strconv.Itoa(productId)
- return
- }
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if approvalItem == nil {
- br.Msg = "待审批信息不存在"
- br.ErrMsg = "待审批信息不存在,CompanyId:" + strconv.Itoa(req.CompanyId) + ";productId:" + strconv.Itoa(productId)
- return
- }
- if approvalItem.ApproveStatus != "待审批" {
- br.Msg = "客户状态为:" + companyProduct.Status + ";不可进行撤回操作"
- br.ErrMsg = "客户状态为:" + companyProduct.Status + ";不可进行撤回操作"
- return
- }
- err = company.ApplyRevoke(approvalItem.CompanyApprovalId, approvalItem.CompanyId, approvalItem.ProductId)
- if err != nil {
- br.Msg = "撤回失败"
- br.ErrMsg = "撤回失败,Err:" + err.Error()
- return
- }
- //新增操作记录
- {
- remark := "撤回"
- operation := "apply_revoke"
- services.AddCompanyOperationRecord(req.CompanyId, companyProduct.SellerId, sysUser.AdminId, productId, 0, companyProduct.CompanyName,
- companyProduct.ProductName, sysUser.RealName, remark, operation, "", "", "", companyProduct.Status)
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "撤回成功"
- }
- // ApplyContract
- // @Title 申请服务更新/转正-审批合同信息
- // @Description 申请服务更新/转正-审批合同信息接口
- // @Param CompanyApprovalId query int true "审批记录ID"
- // @Success 200 {object} company.ApplyContractResp
- // @router /apply/contract [get]
- func (this *CompanyApplyController) ApplyContract() {
- 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
- }
- companyApprovalId, _ := this.GetInt("CompanyApprovalId")
- if companyApprovalId <= 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误,客户id小于等于0"
- return
- }
- approvalRecord, err := company.GetCompanyApprovalByCompanyApprovalId(companyApprovalId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取审批信息失败,Err:" + err.Error()
- return
- }
- contractItem, err := company.GetCompanyContractById(approvalRecord.CompanyContractId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取合同信息失败,Err:" + err.Error()
- return
- }
- productId := approvalRecord.ProductId
- companyId := approvalRecord.CompanyId
- if productId == 1 {
- allFiccPermissions, e := company.GetPermissionLookItemsByProductId(utils.COMPANY_PRODUCT_FICC_ID)
- if e != nil {
- br.Msg = "获取权限信息失败"
- br.ErrMsg = "获取权限信息失败,Err:" + e.Error()
- return
- }
- permissionMap := make(map[int][]*company.PermissionLookItem, 0)
- permissionCheckMap := make(map[int][]int, 0)
- for _, v := range allFiccPermissions {
- if v.ParentId > 0 {
- permissionMap[v.ParentId] = append(permissionMap[v.ParentId], v)
- if v.IsPublic == 1 {
- permissionCheckMap[v.ParentId] = append(permissionCheckMap[v.ParentId], v.ChartPermissionId)
- }
- }
- }
- for _, v := range allFiccPermissions {
- if v.ParentId == 0 {
- checkList := make([]int, 0)
- plist := new(company.PermissionLookList)
- plist.Items = make([]*company.PermissionLookItem, 0)
- items, ok := permissionMap[v.ChartPermissionId]
- if ok {
- for _, n := range items {
- count, err := company.GetCompanyContractPermissionCheckByContractId(companyId, contractItem.CompanyContractId, n.ChartPermissionId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- return
- }
- if count > 0 {
- checkList = append(checkList, n.ChartPermissionId)
- }
- }
- plist.Items = items
- }
- plist.ClassifyName = v.PermissionName
- plist.CheckList = checkList
- contractItem.PermissionList = append(contractItem.PermissionList, plist)
- }
- }
- }
- if productId == 2 {
- name := "权益"
- checkList := make([]int, 0)
- //p := new(company.PermissionSetList)
- plist := new(company.PermissionLookList)
- //pListType := new(company.PermissionSetListType)
- //p.ClassifyName = name
- //pListType.ClassifyName = v
- items, err := company.GetPermissionLookItems(productId, name)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- return
- }
- totalForever, err := company.GetCompanyProductRaiForeverCount(companyId) //判断是否是权益的永续客户
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- return
- }
- // 大套餐
- bigPackage70, bigPackage45 := new(company.PermissionLookItem), new(company.PermissionLookItem)
- if totalForever > 0 {
- //filterPermissionName := []string{"专家", "路演服务", "调研", "研选订阅", "研选扣点包"} //权益的永续客户这些不展示
- //for _, v := range items {
- // if utils.InArrayByStr(filterPermissionName, v.PermissionName) {
- // continue
- // }
- // p.Items = append(p.Items, v)
- //}
- } else {
- bigPackage70.PermissionName = utils.CHART_PERMISSION_NAME_70W
- bigPackage45.PermissionName = utils.CHART_PERMISSION_NAME_45W
- plist.Items = append(plist.Items, bigPackage45, bigPackage70)
- }
- // 是否为内部人员, 内部人员需要拆分行业主客观
- isRai, e := services.CheckRaiAdmin(sysUser.AdminId)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "判断是否为权益内部人员失败, GetRaiAdmin Err: " + e.Error()
- return
- }
- // 获取行业主客观权限ID
- childSubMap, childObjMap := make(map[string]int), make(map[string]int)
- {
- permissions, e := models.GetChartPermissionList()
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限列表失败, GetChartPermissionList Err: " + e.Error()
- return
- }
- for _, v := range permissions {
- if !strings.Contains("医药消费科技智造", v.PermissionName) {
- continue
- }
- if strings.Contains(v.Remark, "主观") {
- childSubMap[v.PermissionName] = v.ChartPermissionId
- continue
- }
- childObjMap[v.PermissionName] = v.ChartPermissionId
- }
- }
- //升级
- mapUpgrade := make(map[int]int)
- mapExpensive := make(map[int]bool)
- var expensiveYx int
- permissionList, err := company.GetCompanyContractPermissionByCompanyContractId(contractItem.CompanyContractId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取合同权限信息失败,Err:" + err.Error()
- return
- }
- permissionIds := make([]int, 0)
- for _, v := range permissionList {
- if v.IsUpgrade == 1 {
- mapUpgrade[v.ChartPermissionId] = v.ChartPermissionId
- }
- if v.ExpensiveYx > 0 {
- mapExpensive[v.ChartPermissionId] = true
- expensiveYx = v.ExpensiveYx
- }
- permissionIds = append(permissionIds, v.ChartPermissionId)
- }
- //mapChartPermissionId := make(map[int]int)
- mapChartPermissionName := make(map[string]string) // 行业主客观防止重复写入Items用的
- filterPermissionName := []string{}
- mapPermissionNameUpgrade := make(map[string]bool) //升级权限重复
- if totalForever == 0 {
- filterPermissionName = []string{"专家", "路演服务"} // 需要过滤不展示的行业
- } else {
- filterPermissionName = []string{"专家", "路演服务", "调研", "研选订阅", "研选扣点包"} //权益的永续客户这些不展示
- }
- for _, n := range items {
- if utils.InArrayByStr(filterPermissionName, n.PermissionName) {
- continue
- }
- if n.PermissionType == 2 && totalForever > 0 {
- continue
- }
- if utils.InArrayByInt(permissionIds, n.ChartPermissionId) {
- n.Checked = true
- if _, ok := mapUpgrade[n.ChartPermissionId]; ok {
- checkList = append(checkList, n.ChartPermissionId+utils.PERMISSION_ID_UPGRADE)
- } else {
- if mapExpensive[n.ChartPermissionId] {
- // 研选5w与10W
- if expensiveYx == 1 {
- checkList = append(checkList, n.ChartPermissionId+utils.PERMISSION_ID_YANXUAN_DIFF) // 5W
- } else {
- checkList = append(checkList, utils.PERMISSION_ID_YANXUAN_10W_DIFF) // 10W
- }
- } else {
- // 非内部人员, 忽略掉已有的客观权限, 否则前端升级的反选会出现问题, 重新提交的时候只提交主观权限也有对应的处理
- if !strings.Contains(n.Remark, "客观") {
- checkList = append(checkList, n.ChartPermissionId)
- }
- // 正常的非客观权限
- if strings.Contains(n.Remark, "客观") && isRai {
- checkList = append(checkList, n.ChartPermissionId)
- }
- }
- }
- }
- // 买方研选3w/5w/10w
- if n.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
- m3 := new(company.PermissionLookItem)
- m3.ChartPermissionId = n.ChartPermissionId
- m3.PermissionName = n.PermissionName
- plist.Items = append(plist.Items, m3)
- continue
- }
- //if totalForever == 0 {
- // 四行业主客观/升级
- if mapChartPermissionName[n.PermissionName] == "" {
- mapChartPermissionName[n.PermissionName] = n.PermissionName
- if !strings.Contains("医药消费科技智造", n.PermissionName) {
- plist.Items = append(plist.Items, n)
- continue
- }
- // 内部人员需要拆分主客观权限
- if isRai && totalForever == 0 {
- n.Child = make([]*company.PermissionLookItem, 0)
- n.Child = append(n.Child, &company.PermissionLookItem{
- ChartPermissionId: childSubMap[n.PermissionName],
- PermissionName: "主观",
- PermissionType: 1,
- }, &company.PermissionLookItem{
- ChartPermissionId: childObjMap[n.PermissionName],
- PermissionName: "客观",
- PermissionType: 2,
- })
- }
- }
- plist.Items = append(plist.Items, n)
- if totalForever == 0 && !mapPermissionNameUpgrade[n.PermissionName] {
- t := new(company.PermissionLookItem)
- t.ChartPermissionId = n.ChartPermissionId + utils.PERMISSION_ID_UPGRADE
- t.PermissionName = n.PermissionName + "(升级)"
- t.PermissionType = n.PermissionType
- t.Checked = n.Checked
- plist.Items = append(plist.Items, t)
- mapPermissionNameUpgrade[n.PermissionName] = true
- }
- }
- //}
- // 如果checklist 里的值 没有在items里,则不返回给前端
- itemsIds := make([]int, 0)
- itemsIdExist := make(map[int]bool)
- for _, v := range plist.Items {
- if v.Child != nil && len(v.Child) > 0 {
- for _, v2 := range v.Child {
- if !itemsIdExist[v2.ChartPermissionId] {
- itemsIds = append(itemsIds, v2.ChartPermissionId)
- itemsIdExist[v2.ChartPermissionId] = true
- }
- }
- }
- if !itemsIdExist[v.ChartPermissionId] {
- itemsIds = append(itemsIds, v.ChartPermissionId)
- itemsIdExist[v.ChartPermissionId] = true
- }
- }
- checkList = utils.IntersectInt(checkList, itemsIds)
- //finalCheckList := make([]int, 0)
- //for _, v := range plist.Items {
- // for _, i := range checkList {
- // if v.ChartPermissionId == i {
- // finalCheckList = append(finalCheckList, i)
- // break
- // }
- // }
- //}
- //p.CheckList = checkList
- //plist.ItemsType = pListType.Items
- plist.ClassifyName = name
- //plist.CheckList = finalCheckList
- plist.CheckList = checkList
- contractItem.PermissionList = append(contractItem.PermissionList, plist)
- contractItem.Quarter, _ = utils.GetQuarterStrStartDatesInRangeHaveYear(contractItem.StartDate, contractItem.EndDate) //季度信息
- }
- resp := new(company.ApplyContractResp)
- resp.Item = contractItem
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // SearchContractList
- // @Title 系统合同搜索列表(用于申请转正、服务更新)
- // @Description 系统合同搜索列表接口(用于申请转正、服务更新)
- // @Param Keyword query string false "搜索关键字"
- // @Param CreditCode query string false "社会组织信用码"
- // @Success 200 {object} []contract.ContractList
- // @router /system_contract/list [get]
- func (this *CompanyApplyController) SearchContractList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- productId := services.GetProductId(sysUser.RoleTypeCode)
- if productId <= 0 {
- br.Msg = "获取合同列表失败!"
- br.ErrMsg = "获取合同列表失败,当前账户类型异常:" + sysUser.RoleTypeCode
- return
- }
- keyword := this.GetString("Keyword")
- creditCode := this.GetString("CreditCode")
- if keyword == "" && creditCode == "" {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- return
- }
- //companyIdStr, err := company.GetCompanyIdByKeyWordAll(keyword)
- //if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- //}
- //if companyIdStr != "" {
- // companyIdStr = strings.Trim(companyIdStr, ",")
- //}
- list, err := contract.GetSearchContractList(productId, sysUser.AdminId, keyword, creditCode)
- for _, v := range list {
- v.StartDateStr = v.StartDate.Format(utils.FormatDate)
- v.EndDateStr = v.EndDate.Format(utils.FormatDate)
- }
- if err != nil {
- br.Msg = "获取合同列表失败!"
- br.ErrMsg = "获取合同列表失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = list
- }
- // GetContractApplyDetail
- // @Title 系统合同详情(用于申请转正、服务更新)
- // @Description 系统合同详情(用于申请转正、服务更新)
- // @Param ContractId query int false "合同id"
- // @Success 200 {object} []response.ContractApplyDetailResp
- // @router /system_contract/detail [get]
- func (this *CompanyApplyController) GetContractApplyDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- productId := services.GetProductId(sysUser.RoleTypeCode)
- if productId <= 0 {
- br.Msg = "获取合同列表失败!"
- br.ErrMsg = "获取合同列表失败,当前账户类型异常:" + sysUser.RoleTypeCode
- return
- }
- contractId, err := this.GetInt("ContractId")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- //合同id
- if contractId <= 0 {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,合同id必传"
- return
- }
- contractDetail, err := contractService.GetContractDetail(contractId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- permissionList, err := contractService.GetPermissionByContractService(contractDetail.ProductId, contractDetail.Service)
- if contractDetail.ProductId == 2 {
- newPermissionList := contractService.HandleEquityPermissionLookList(permissionList)
- permissionList = newPermissionList
- }
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限失败,Err:" + err.Error()
- return
- }
- resp := response.ContractApplyDetailResp{
- ContractDetail: contractDetail,
- PermissionList: permissionList,
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取客户最近的历史合同权限详情
- // @Description 获取客户最近的历史合同权限详情接口
- // @Param CompanyId query int true "客户ID"
- // @Success 200 {object} *company.CompanyContractDetail
- // @router /company/last_contract/detail/withoutDate [get]
- func (this *CompanyApplyController) GetLastContractDetailWithoutDate() {
- 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
- }
- companyId, _ := this.GetInt("CompanyId")
- if companyId <= 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误,客户id小于等于0"
- return
- }
- companyInfo, err := company.GetCompanyDetailById(companyId)
- if err != nil {
- if err.Error() == utils.ErrNoRow() {
- br.Msg = "参数错误"
- br.ErrMsg = "客户不存在"
- return
- } else {
- br.Msg = "查询客户信息失败"
- br.ErrMsg = "查询客户信息失败:" + err.Error()
- return
- }
- }
- contractInfo, err := contract.GetContractListByCompanyName(companyInfo.CompanyName)
- if err != nil {
- if err.Error() != utils.ErrNoRow() {
- br.Msg = "获取合同失败"
- br.ErrMsg = "获取合同失败:" + err.Error()
- return
- } else {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- return
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = contractInfo
- }
- // @Title 申请服务更新-签约历史(单个详情)
- // @Description 申请服务更新-签约历史接口(单个详情)
- // @Param ContractCode query string true "合同编码"
- // @Success 200 {object} company.CompanyContractHistoryResp
- // @router /apply/contract/history/detail [get]
- func (this *CompanyApplyController) ApplyContractHistoryDetail() {
- 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
- }
- contractCode := this.GetString("ContractCode")
- if contractCode == "" {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误,客户id小于等于0"
- return
- }
- roleTypeCode := sysUser.RoleTypeCode
- productId := services.GetProductId(roleTypeCode)
- list, err := company.GetCompanyContractHistoryListByContractCode(contractCode)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- listLen := len(list)
- if listLen == 0 {
- br.Msg = "获取信息失败"
- br.ErrMsg = "签约信息不存在 contractCode:" + contractCode
- return
- }
- expMap := map[int]string{0: "(3w)", 1: "(5w)"} // 买方研选价格
- for i := 0; i < listLen; i++ {
- companyContract := list[i]
- list[i].ModifyTimeStr = companyContract.ModifyTime.Format(utils.FormatDateTime)
- productId = list[i].ProductId
- if productId == utils.COMPANY_PRODUCT_RAI_ID {
- //classifyName := "权益"
- checkList := make([]int, 0)
- plist := new(company.ContractPermissionList)
- hasPermissions, e := company.GetCompanyContractPermissionByCompanyContractId(companyContract.CompanyContractId)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取合同权限信息失败,Err:" + e.Error()
- return
- }
- hasMap := make(map[int]*company.CompanyContractPermission)
- for _, p := range hasPermissions {
- hasMap[p.ChartPermissionId] = p
- }
- checkItems := make([]*company.PermissionLookItem, 0)
- // PS:本来想把这个移到循环外面去优化一下...但是发现有指针引用变量被改掉的问题, BUG太多了改不完了先这样吧=_=!
- raiPermissions, e := company.GetPermissionLookItemsExt("2", utils.COMPANY_PRODUCT_RAI_NAME)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权益权限列表失败, Err: " + e.Error()
- return
- }
- for _, n := range raiPermissions {
- match := hasMap[n.ChartPermissionId]
- if match == nil {
- continue
- }
- // 升级
- if match.IsUpgrade == 1 {
- n.IsUpgrade = 1
- checkList = append(checkList, n.ChartPermissionId)
- checkItems = append(checkItems, n)
- continue
- }
- // 买方研选(3w/5w)
- if n.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
- n.PermissionName += expMap[match.ExpensiveYx]
- checkList = append(checkList, n.ChartPermissionId)
- checkItems = append(checkItems, n)
- continue
- }
- checkList = append(checkList, n.ChartPermissionId)
- checkItems = append(checkItems, n)
- }
- plist.Items = checkItems
- plist.ClassifyName = utils.COMPANY_PRODUCT_RAI_NAME
- plist.CheckList = checkList
- list[i].PermissionList = append(list[i].PermissionList, plist)
- // CRM8.8-权限主客观合并
- newPermissionLookList := contractService.HandleEquityContractPermissionList(list[i].PermissionList)
- list[i].PermissionList = newPermissionLookList
- }
- }
- resp := new(company.CompanyContractHistoryResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|