Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…
…ion-cooperation into dev
正在显示
13 个修改的文件
包含
180 行增加
和
28 行删除
| @@ -101,18 +101,31 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop | @@ -101,18 +101,31 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop | ||
| 101 | 101 | ||
| 102 | var newCooperationApplication *domain.CooperationApplication | 102 | var newCooperationApplication *domain.CooperationApplication |
| 103 | 103 | ||
| 104 | - if applyForCooperationCommand.CompanyId == 0 && applyForCooperationCommand.OrgId == 0 && applyForCooperationCommand.UserId == 0 { // 游客操作 | ||
| 105 | - // TODO 获取申请人信息 | 104 | + if applyForCooperationCommand.CompanyId == 0 && applyForCooperationCommand.OrgId == 0 && applyForCooperationCommand.UserId == 0 && applyForCooperationCommand.UserBaseId != 0 { // 游客操作 |
| 105 | + // 获取申请人信息 | ||
| 106 | + var applicant *domain.User | ||
| 107 | + if data, err := userService.VisitorFrom(applyForCooperationCommand.CompanyId, applyForCooperationCommand.OrgId, applyForCooperationCommand.UserBaseId); err != nil { | ||
| 108 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取申请人失败") | ||
| 109 | + } else { | ||
| 110 | + applicant = data | ||
| 111 | + } | ||
| 106 | 112 | ||
| 107 | - // TODO 校验:同一个用户,不能多次申请同一个项目 | 113 | + // 校验:同一个用户,不能多次申请同一个项目 |
| 114 | + applicationExist, _ := cooperationApplicationDao.CheckApplicationExist(map[string]interface{}{ | ||
| 115 | + "visitorUserBaseId": applicant.UserBaseId, | ||
| 116 | + "cooperationApplicationId": cooperationProject.CooperationProjectId, | ||
| 117 | + }) | ||
| 118 | + if applicationExist { | ||
| 119 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "抱歉,您已经申请过该项目") | ||
| 120 | + } | ||
| 108 | 121 | ||
| 109 | - // TODO 校验:判断用户类型是否属于承接对象 | ||
| 110 | - //if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType) { | ||
| 111 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象") | ||
| 112 | - //} | 122 | + // 校验:判断用户类型是否属于承接对象 |
| 123 | + if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType) { | ||
| 124 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象") | ||
| 125 | + } | ||
| 113 | 126 | ||
| 114 | newCooperationApplication = &domain.CooperationApplication{ | 127 | newCooperationApplication = &domain.CooperationApplication{ |
| 115 | - CooperationApplicationApplicant: nil, // TODO 获取游客(申请人)信息 | 128 | + CooperationApplicationApplicant: applicant, |
| 116 | CooperationApplicationAttachment: applyForCooperationCommand.CooperationApplicationAttachment, | 129 | CooperationApplicationAttachment: applyForCooperationCommand.CooperationApplicationAttachment, |
| 117 | CooperationApplicationDescription: applyForCooperationCommand.CooperationApplicationDescription, | 130 | CooperationApplicationDescription: applyForCooperationCommand.CooperationApplicationDescription, |
| 118 | CooperationApplicationStatus: 1, | 131 | CooperationApplicationStatus: 1, |
| @@ -157,6 +170,7 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop | @@ -157,6 +170,7 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop | ||
| 157 | applicationExist, _ := cooperationApplicationDao.CheckApplicationExist(map[string]interface{}{ | 170 | applicationExist, _ := cooperationApplicationDao.CheckApplicationExist(map[string]interface{}{ |
| 158 | "companyId": applyForCooperationCommand.CompanyId, | 171 | "companyId": applyForCooperationCommand.CompanyId, |
| 159 | "orgId": applyForCooperationCommand.OrgId, | 172 | "orgId": applyForCooperationCommand.OrgId, |
| 173 | + "applicantId": applicant.UserId, | ||
| 160 | "cooperationApplicationId": cooperationProject.CooperationProjectId, | 174 | "cooperationApplicationId": cooperationProject.CooperationProjectId, |
| 161 | }) | 175 | }) |
| 162 | if applicationExist { | 176 | if applicationExist { |
| @@ -16,9 +16,9 @@ type PayCreditAccountCommand struct { | @@ -16,9 +16,9 @@ type PayCreditAccountCommand struct { | ||
| 16 | // 账期结算实付金额 | 16 | // 账期结算实付金额 |
| 17 | ActuallyPaidAmount float64 `cname:"账期结算实付金额" json:"actuallyPaidAmount" valid:"Required"` | 17 | ActuallyPaidAmount float64 `cname:"账期结算实付金额" json:"actuallyPaidAmount" valid:"Required"` |
| 18 | // 备注 | 18 | // 备注 |
| 19 | - Remarks string `cname:"备注" json:"remarks" valid:"Required"` | 19 | + Remarks string `cname:"备注" json:"remarks"` |
| 20 | // 支付凭证附件 | 20 | // 支付凭证附件 |
| 21 | - PaymentDocumentAttachments []*domain.Attachment `cname:"支付凭证附件" json:"paymentDocumentAttachment" valid:"Required"` | 21 | + PaymentDocumentAttachments []*domain.Attachment `cname:"支付凭证附件" json:"paymentDocumentAttachment"` |
| 22 | // 公司ID,通过集成REST上下文获取 | 22 | // 公司ID,通过集成REST上下文获取 |
| 23 | CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"` | 23 | CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"` |
| 24 | // 组织机构ID | 24 | // 组织机构ID |
| @@ -30,7 +30,6 @@ type PayCreditAccountCommand struct { | @@ -30,7 +30,6 @@ type PayCreditAccountCommand struct { | ||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | func (payCreditAccountCommand *PayCreditAccountCommand) Valid(validation *validation.Validation) { | 32 | func (payCreditAccountCommand *PayCreditAccountCommand) Valid(validation *validation.Validation) { |
| 33 | - //validation.SetError("CustomValid", "未实现的自定义认证") | ||
| 34 | } | 33 | } |
| 35 | 34 | ||
| 36 | func (payCreditAccountCommand *PayCreditAccountCommand) ValidateCommand() error { | 35 | func (payCreditAccountCommand *PayCreditAccountCommand) ValidateCommand() error { |
| @@ -609,6 +609,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -609,6 +609,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 609 | }) | 609 | }) |
| 610 | } | 610 | } |
| 611 | 611 | ||
| 612 | + // 统计分红订单 | ||
| 613 | + var countDividendsOrders int32 | ||
| 614 | + | ||
| 612 | // 获取订单产品 | 615 | // 获取订单产品 |
| 613 | if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{ | 616 | if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{ |
| 614 | "orderGoodIds": orderGoodIds, | 617 | "orderGoodIds": orderGoodIds, |
| @@ -634,9 +637,15 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -634,9 +637,15 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 634 | if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoods); err != nil { | 637 | if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoods); err != nil { |
| 635 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 638 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 636 | } else { | 639 | } else { |
| 637 | - for _, dividendsEstimateDetail := range dividendsEstimateDetails { | 640 | + // 统计当前分红预算单数 |
| 641 | + count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{}) | ||
| 642 | + if err != nil { | ||
| 643 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 644 | + } | ||
| 645 | + | ||
| 646 | + for i, dividendsEstimateDetail := range dividendsEstimateDetails { | ||
| 638 | // 生成分红预算单号 | 647 | // 生成分红预算单号 |
| 639 | - dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber() | 648 | + dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), int64(i)) |
| 640 | if err != nil { | 649 | if err != nil { |
| 641 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 650 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 642 | } | 651 | } |
| @@ -718,25 +727,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -718,25 +727,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 718 | "dividendsEstimates": dividendsEstimates, | 727 | "dividendsEstimates": dividendsEstimates, |
| 719 | }) | 728 | }) |
| 720 | 729 | ||
| 721 | - // 创建成功的分红预算单 | ||
| 722 | - var dividendsEstimatesSavedSuccessfully []*domain.DividendsEstimate | ||
| 723 | - // 创建失败的分红预算单 | ||
| 724 | - var dividendsEstimateSaveFailed []*domain.DividendsEstimate | ||
| 725 | - for _, dividendsEstimate := range dividendsEstimates { | ||
| 726 | - if dividendsEstimateSaved, err := dividendsEstimateRepository.Save(dividendsEstimate); err != nil { | ||
| 727 | - dividendsEstimateSaveFailed = append(dividendsEstimateSaveFailed, dividendsEstimate) | 730 | + if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil { |
| 728 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 731 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 729 | - } else if dividendsEstimateSaved != nil { | ||
| 730 | - dividendsEstimatesSavedSuccessfully = append(dividendsEstimatesSavedSuccessfully, dividendsEstimate) | ||
| 731 | - } | ||
| 732 | - } | ||
| 733 | - | 732 | + } else { |
| 734 | if err := transactionContext.CommitTransaction(); err != nil { | 733 | if err := transactionContext.CommitTransaction(); err != nil { |
| 735 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 734 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 736 | } | 735 | } |
| 737 | // TODO 分析成功和失败原因 | 736 | // TODO 分析成功和失败原因 |
| 738 | - | ||
| 739 | - return dividendsEstimatesSavedSuccessfully, nil | 737 | + successfullyCount := len(dividendsEstimatesSaved) |
| 738 | + return fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d订单分红预算失败,失败原因:%s", countDividendsOrders, successfullyCount, 0, ""), nil | ||
| 739 | + } | ||
| 740 | } | 740 | } |
| 741 | } | 741 | } |
| 742 | 742 |
| @@ -643,6 +643,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD | @@ -643,6 +643,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD | ||
| 643 | 643 | ||
| 644 | // 统计当前分红订单数 | 644 | // 统计当前分红订单数 |
| 645 | count, err := dividendsOrderDao.CountDividendsOrder(map[string]interface{}{}) | 645 | count, err := dividendsOrderDao.CountDividendsOrder(map[string]interface{}{}) |
| 646 | + if err != nil { | ||
| 647 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 648 | + } | ||
| 646 | 649 | ||
| 647 | // 批量创建分红订单 | 650 | // 批量创建分红订单 |
| 648 | for i, dividendsOrder := range createDividendsOrderCommands { | 651 | for i, dividendsOrder := range createDividendsOrderCommands { |
| 1 | package service | 1 | package service |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "fmt" | ||
| 4 | coreDomain "github.com/linmadan/egglib-go/core/domain" | 5 | coreDomain "github.com/linmadan/egglib-go/core/domain" |
| 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
| 7 | + "time" | ||
| 6 | ) | 8 | ) |
| 7 | 9 | ||
| 8 | type DividendsEstimateDetail struct { | 10 | type DividendsEstimateDetail struct { |
| @@ -12,6 +14,28 @@ type DividendsEstimateDetail struct { | @@ -12,6 +14,28 @@ type DividendsEstimateDetail struct { | ||
| 12 | DividendsAmount float64 `json:"dividendsAmount"` // 分红金额 | 14 | DividendsAmount float64 `json:"dividendsAmount"` // 分红金额 |
| 13 | } | 15 | } |
| 14 | 16 | ||
| 17 | +// GenerateSpecificDividendsEstimateNumber 批量生成自定义分红预算单号 | ||
| 18 | +func (DividendsEstimateDetail *DividendsEstimateDetail) GenerateSpecificDividendsEstimateNumber(count int64, index int64) (string, error) { | ||
| 19 | + currentTime := time.Now() | ||
| 20 | + if count+index < 1000 { | ||
| 21 | + countStr := fmt.Sprintf("%03d", count+index+1) | ||
| 22 | + timestamp := currentTime.Unix() | ||
| 23 | + timeNow := time.Unix(timestamp, 0) | ||
| 24 | + timeString := timeNow.Format("20060102") | ||
| 25 | + timeString = timeString[2:len(timeString)] | ||
| 26 | + dividendsEstimateNumber := "FH" + timeString + "#" + countStr | ||
| 27 | + return dividendsEstimateNumber, nil | ||
| 28 | + } else { | ||
| 29 | + countStr := fmt.Sprintf("%d", count+index+1) | ||
| 30 | + timestamp := currentTime.Unix() | ||
| 31 | + timeNow := time.Unix(timestamp, 0) | ||
| 32 | + timeString := timeNow.Format("20060102") | ||
| 33 | + timeString = timeString[2:len(timeString)] | ||
| 34 | + dividendsEstimateNumber := "FH" + timeString + "#" + countStr | ||
| 35 | + return dividendsEstimateNumber, nil | ||
| 36 | + } | ||
| 37 | +} | ||
| 38 | + | ||
| 15 | type ConfirmDividendsIncentivesEstimateService interface { | 39 | type ConfirmDividendsIncentivesEstimateService interface { |
| 16 | coreDomain.DomainEventPublisher | 40 | coreDomain.DomainEventPublisher |
| 17 | Confirm(orderGoods []*domain.OrderGood) ([]*DividendsEstimateDetail, error) | 41 | Confirm(orderGoods []*domain.OrderGood) ([]*DividendsEstimateDetail, error) |
| @@ -9,4 +9,5 @@ type UserService interface { | @@ -9,4 +9,5 @@ type UserService interface { | ||
| 9 | RelevantFrom(companyId int64, orgId int64, userId int64) (*domain.Relevant, error) // 获取相关人 | 9 | RelevantFrom(companyId int64, orgId int64, userId int64) (*domain.Relevant, error) // 获取相关人 |
| 10 | SalesmanFrom(companyId int64, orgId int64, userId int64) (*domain.Salesman, error) // 获取业务员 | 10 | SalesmanFrom(companyId int64, orgId int64, userId int64) (*domain.Salesman, error) // 获取业务员 |
| 11 | OperatorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) // 获取操作人 | 11 | OperatorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) // 获取操作人 |
| 12 | + VisitorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) // 获取游客 | ||
| 12 | } | 13 | } |
| @@ -27,6 +27,9 @@ func (dao *CooperationApplicationDao) CheckApplicationExist(queryOptions map[str | @@ -27,6 +27,9 @@ func (dao *CooperationApplicationDao) CheckApplicationExist(queryOptions map[str | ||
| 27 | if applicantId, ok := queryOptions["applicantId"]; ok && applicantId.(int64) != 0 { | 27 | if applicantId, ok := queryOptions["applicantId"]; ok && applicantId.(int64) != 0 { |
| 28 | query = query.Where(`cooperation_application.cooperation_application_applicant @>'{"userId":"?"}'`, applicantId) | 28 | query = query.Where(`cooperation_application.cooperation_application_applicant @>'{"userId":"?"}'`, applicantId) |
| 29 | } | 29 | } |
| 30 | + if visitorUserBaseId, ok := queryOptions["visitorUserBaseId"]; ok && visitorUserBaseId.(int64) != 0 { | ||
| 31 | + query = query.Where(`cooperation_application.cooperation_application_applicant @>'{"userBaseId":"?"}'`, visitorUserBaseId) | ||
| 32 | + } | ||
| 30 | if applicantBaseId, ok := queryOptions["applicantBaseId"]; ok && applicantBaseId.(int64) != 0 { | 33 | if applicantBaseId, ok := queryOptions["applicantBaseId"]; ok && applicantBaseId.(int64) != 0 { |
| 31 | query = query.Where(`cooperation_application.cooperation_application_applicant @>'{"userBaseId":"?"}'`, applicantBaseId) | 34 | query = query.Where(`cooperation_application.cooperation_application_applicant @>'{"userBaseId":"?"}'`, applicantBaseId) |
| 32 | } | 35 | } |
| @@ -75,6 +75,18 @@ func (dao *DividendsEstimateDao) UserEstimated(queryOptions map[string]interface | @@ -75,6 +75,18 @@ func (dao *DividendsEstimateDao) UserEstimated(queryOptions map[string]interface | ||
| 75 | return ok, err | 75 | return ok, err |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | +// CountDividendsEstimate 统计当前分红预算单总数 | ||
| 79 | +func (dao *DividendsEstimateDao) CountDividendsEstimate(queryOptions map[string]interface{}) (int, error) { | ||
| 80 | + tx := dao.transactionContext.PgTx | ||
| 81 | + var dividendsEstimateModels []*models.DividendsEstimate | ||
| 82 | + query := tx.Model(÷ndsEstimateModels) | ||
| 83 | + if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { | ||
| 84 | + return 0, err | ||
| 85 | + } else { | ||
| 86 | + return count, nil | ||
| 87 | + } | ||
| 88 | +} | ||
| 89 | + | ||
| 78 | func NewDividendsEstimateDao(transactionContext *pgTransaction.TransactionContext) (*DividendsEstimateDao, error) { | 90 | func NewDividendsEstimateDao(transactionContext *pgTransaction.TransactionContext) (*DividendsEstimateDao, error) { |
| 79 | if transactionContext == nil { | 91 | if transactionContext == nil { |
| 80 | return nil, fmt.Errorf("transactionContext参数不能为空") | 92 | return nil, fmt.Errorf("transactionContext参数不能为空") |
| @@ -172,6 +172,33 @@ func (service *UserService) OperatorFrom(companyId int64, orgId int64, userId in | @@ -172,6 +172,33 @@ func (service *UserService) OperatorFrom(companyId int64, orgId int64, userId in | ||
| 172 | } | 172 | } |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | +// VisitorFrom 获取游客 | ||
| 176 | +func (service *UserService) VisitorFrom(companyId int64, orgId int64, userBaseId int64) (*domain.User, error) { | ||
| 177 | + var returnData *domain.User | ||
| 178 | + if userAdaptor, err := adaptor.NewUserAdaptor(); err != nil { | ||
| 179 | + return nil, err | ||
| 180 | + } else { | ||
| 181 | + if visitor, err := userAdaptor.ToParticipator(companyId, orgId, userBaseId, "Visitor"); err != nil { | ||
| 182 | + return nil, err | ||
| 183 | + } else { | ||
| 184 | + if visitor != nil { | ||
| 185 | + log.Logger.Debug("游客", map[string]interface{}{ | ||
| 186 | + "visitor interface": visitor, | ||
| 187 | + }) | ||
| 188 | + visitorJson, err1 := json.Marshal(visitor) | ||
| 189 | + if err1 != nil { | ||
| 190 | + return nil, err | ||
| 191 | + } | ||
| 192 | + err2 := json.Unmarshal(visitorJson, &returnData) | ||
| 193 | + if err2 != nil { | ||
| 194 | + return nil, err2 | ||
| 195 | + } | ||
| 196 | + } | ||
| 197 | + return returnData, nil | ||
| 198 | + } | ||
| 199 | + } | ||
| 200 | +} | ||
| 201 | + | ||
| 175 | func NewUserService() (*UserService, error) { | 202 | func NewUserService() (*UserService, error) { |
| 176 | return &UserService{}, nil | 203 | return &UserService{}, nil |
| 177 | } | 204 | } |
| @@ -164,7 +164,16 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do | @@ -164,7 +164,16 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do | ||
| 164 | tx := repository.transactionContext.PgTx | 164 | tx := repository.transactionContext.PgTx |
| 165 | var dividendsEstimateModels []*models.DividendsEstimate | 165 | var dividendsEstimateModels []*models.DividendsEstimate |
| 166 | for _, dividendsEstimate := range dividendsEstimates { | 166 | for _, dividendsEstimate := range dividendsEstimates { |
| 167 | + if dividendsEstimate.Identify() == nil { | ||
| 168 | + dividendsEstimateId, err := repository.nextIdentify() | ||
| 169 | + if err != nil { | ||
| 170 | + return nil, err | ||
| 171 | + } else { | ||
| 172 | + dividendsEstimate.DividendsEstimateId = dividendsEstimateId | ||
| 173 | + } | ||
| 174 | + } | ||
| 167 | dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{ | 175 | dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{ |
| 176 | + DividendsEstimateId: dividendsEstimate.DividendsEstimateId, | ||
| 168 | DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus, | 177 | DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus, |
| 169 | DividendsAmount: dividendsEstimate.DividendsAmount, | 178 | DividendsAmount: dividendsEstimate.DividendsAmount, |
| 170 | DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber, | 179 | DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber, |
| @@ -54,6 +54,12 @@ func (adaptor *UserAdaptor) ToParticipator(companyId int64, orgId int64, userId | @@ -54,6 +54,12 @@ func (adaptor *UserAdaptor) ToParticipator(companyId int64, orgId int64, userId | ||
| 54 | return map[string]interface{}{}, nil | 54 | return map[string]interface{}{}, nil |
| 55 | } | 55 | } |
| 56 | return user, nil | 56 | return user, nil |
| 57 | + case "Visitor": // 游客 | ||
| 58 | + visitor, err := userTranslator.ToVisitorFromRepresentation(response) | ||
| 59 | + if err != nil { | ||
| 60 | + return map[string]interface{}{}, nil | ||
| 61 | + } | ||
| 62 | + return visitor, nil | ||
| 57 | } | 63 | } |
| 58 | } | 64 | } |
| 59 | return map[string]interface{}{}, nil | 65 | return map[string]interface{}{}, nil |
| @@ -42,6 +42,33 @@ func (serviceGateway *HttplibUserServiceGateway) GetUser(companyId int64, orgId | @@ -42,6 +42,33 @@ func (serviceGateway *HttplibUserServiceGateway) GetUser(companyId int64, orgId | ||
| 42 | return &data, err | 42 | return &data, err |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | +// GetUserInfo 获取用户信息 | ||
| 46 | +func (serviceGateway *HttplibUserServiceGateway) GetUserInfo(companyId int64, orgId int64, userBaseId int64) (*translator.UserDetail, error) { | ||
| 47 | + url := serviceGateway.baseURL + "/auth/user-info" | ||
| 48 | + request := serviceGateway.createRequest(url, "post") | ||
| 49 | + options := make(map[string]interface{}) | ||
| 50 | + options["userBaseId"] = userBaseId | ||
| 51 | + _, err1 := request.JSONBody(options) | ||
| 52 | + if err1 != nil { | ||
| 53 | + return nil, err1 | ||
| 54 | + } | ||
| 55 | + byteResult, err := request.Bytes() | ||
| 56 | + if err != nil { | ||
| 57 | + return nil, fmt.Errorf("获取获取用户信息失败:%w", err) | ||
| 58 | + } | ||
| 59 | + log.Logger.Debug("获取用户模块请求数据:获取用户信息。", map[string]interface{}{ | ||
| 60 | + "result": string(byteResult), | ||
| 61 | + }) | ||
| 62 | + var result GatewayResponse | ||
| 63 | + err = json.Unmarshal(byteResult, &result) | ||
| 64 | + if err != nil { | ||
| 65 | + return nil, fmt.Errorf("解析获取用户:%w", err) | ||
| 66 | + } | ||
| 67 | + var data translator.UserDetail | ||
| 68 | + err = serviceGateway.getResponseData(result, &data) | ||
| 69 | + return &data, err | ||
| 70 | +} | ||
| 71 | + | ||
| 45 | // GetUsers 获取用户 | 72 | // GetUsers 获取用户 |
| 46 | func (serviceGateway *HttplibUserServiceGateway) GetUsers(companyId int64, orgId int64, uids []int64) (map[string]interface{}, error) { | 73 | func (serviceGateway *HttplibUserServiceGateway) GetUsers(companyId int64, orgId int64, uids []int64) (map[string]interface{}, error) { |
| 47 | companyIdStr := strconv.FormatInt(companyId, 10) | 74 | companyIdStr := strconv.FormatInt(companyId, 10) |
| @@ -8,6 +8,20 @@ import ( | @@ -8,6 +8,20 @@ import ( | ||
| 8 | type UserTranslator struct { | 8 | type UserTranslator struct { |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | +type UserInfoDetail struct { | ||
| 12 | + UserBaseId int64 `json:"userBaseId"` | ||
| 13 | + UserType int32 `json:"userType"` | ||
| 14 | + UserInfo struct { | ||
| 15 | + UserName string `json:"userName"` | ||
| 16 | + Phone string `json:"phone"` | ||
| 17 | + } `json:"userInfo,omitempty"` | ||
| 18 | + Im struct { | ||
| 19 | + Accid string `json:"accid"` | ||
| 20 | + ImToken string `json:"imToken"` | ||
| 21 | + CsAccountId string `json:"csAccountId"` | ||
| 22 | + } `json:"im,omitempty"` | ||
| 23 | +} | ||
| 24 | + | ||
| 11 | type UserDetail struct { | 25 | type UserDetail struct { |
| 12 | UserId int64 `json:"userId"` | 26 | UserId int64 `json:"userId"` |
| 13 | UserBaseId int64 `json:"userBaseId"` | 27 | UserBaseId int64 `json:"userBaseId"` |
| @@ -348,7 +362,7 @@ func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*d | @@ -348,7 +362,7 @@ func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*d | ||
| 348 | var roles []*domain.Role | 362 | var roles []*domain.Role |
| 349 | for _, role := range user.UserRole { | 363 | for _, role := range user.UserRole { |
| 350 | roles = append(roles, &domain.Role{ | 364 | roles = append(roles, &domain.Role{ |
| 351 | - RoleId: int64(role.RoleID), | 365 | + RoleId: role.RoleID, |
| 352 | RoleName: role.RoleName, | 366 | RoleName: role.RoleName, |
| 353 | }) | 367 | }) |
| 354 | } | 368 | } |
| @@ -386,6 +400,19 @@ func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*d | @@ -386,6 +400,19 @@ func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*d | ||
| 386 | }, nil | 400 | }, nil |
| 387 | } | 401 | } |
| 388 | 402 | ||
| 403 | +func (translator *UserTranslator) ToVisitorFromRepresentation(user *UserDetail) (*domain.User, error) { | ||
| 404 | + return &domain.User{ | ||
| 405 | + UserBaseId: user.UserBaseId, | ||
| 406 | + UserInfo: &domain.UserInfo{ | ||
| 407 | + UserName: user.UserInfo.UserName, | ||
| 408 | + UserPhone: user.UserInfo.Phone, | ||
| 409 | + }, | ||
| 410 | + UserType: user.UserType, | ||
| 411 | + UserName: user.UserInfo.UserName, | ||
| 412 | + UserPhone: user.UserInfo.Phone, | ||
| 413 | + }, nil | ||
| 414 | +} | ||
| 415 | + | ||
| 389 | func NewUserTranslator() (*UserTranslator, error) { | 416 | func NewUserTranslator() (*UserTranslator, error) { |
| 390 | return &UserTranslator{}, nil | 417 | return &UserTranslator{}, nil |
| 391 | } | 418 | } |
-
请 注册 或 登录 后发表评论