作者 yangfu

个人端统计修改

@@ -98,6 +98,86 @@ func (srv PersonStatisticsService) IndexStatistics(cmd *command.IndexStatisticsC @@ -98,6 +98,86 @@ func (srv PersonStatisticsService) IndexStatistics(cmd *command.IndexStatisticsC
98 }, nil 98 }, nil
99 } 99 }
100 100
  101 +// IndexStatistics 个人端 - 首页统计 (入口页面统计数据)
  102 +func (srv PersonStatisticsService) IndexStatisticsV2(cmd *command.IndexStatisticsCommand) (interface{}, error) {
  103 + gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
  104 + cmd.Operator)
  105 +
  106 + // 1.项目概览统计
  107 + contractStatisticsResult, err := gateway.CooperationStatistics(allied_creation_cooperation.PersonCooperationContractStatistics, map[string]interface{}{
  108 + "userBaseId": cmd.Operator.UserBaseId,
  109 + })
  110 + if err != nil {
  111 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  112 + }
  113 + type contractStatistics struct {
  114 + ContractSum int `json:"contractSum"`
  115 + ContractStoppedSum int `json:"contractStoppedSum"`
  116 + }
  117 + var cs = &contractStatistics{}
  118 + if err := json.UnmarshalFromString(json.MarshalToString(contractStatisticsResult), cs); err != nil {
  119 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  120 + }
  121 +
  122 + var response = struct {
  123 + OrgIds []int `json:"orgIds"`
  124 + }{}
  125 + err = gateway.CooperationStatisticsWithObject(allied_creation_cooperation.PersonCooperationCompany, map[string]interface{}{
  126 + "userBaseId": cmd.Operator.UserBaseId,
  127 + }, &response)
  128 + if err != nil {
  129 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  130 + }
  131 + var overview = map[string]interface{}{
  132 + "contractSum": cs.ContractSum, //总合约数
  133 + "contractStoppedSum": cs.ContractStoppedSum, //停止的合约数
  134 + "companySum": len(response.OrgIds), //共创企业数
  135 + }
  136 + year, month, _ := time.Now().Date()
  137 + beginTime := time.Date(year, month, 1, 0, 0, 0, 0, time.Local)
  138 + endTime := beginTime.AddDate(0, 1, 0)
  139 + // 2.本月分红统计 - 个人
  140 + unPaidResult, err := gateway.CooperationStatistics(allied_creation_cooperation.CreditAccountStatistics, map[string]interface{}{
  141 + "userBaseId": cmd.Operator.UserBaseId,
  142 + "beginTime": beginTime,
  143 + "endTime": endTime,
  144 + })
  145 + if err != nil {
  146 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  147 + }
  148 + type AnnualDividend struct {
  149 + Total float64 `json:"total"`
  150 + Accounting float64 `json:"accounting"`
  151 + Accounted float64 `json:"accounted"`
  152 + Paid float64 `json:"paid"`
  153 + Unpaid float64 `json:"unpaid"`
  154 + }
  155 + var annualUnPaidDividend = &AnnualDividend{}
  156 + if err := json.UnmarshalFromString(json.MarshalToString(unPaidResult), annualUnPaidDividend); err != nil {
  157 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  158 + }
  159 + // 2.本月分红统计 - 个人
  160 + paymentResult, err := gateway.CooperationStatistics(allied_creation_cooperation.CreditAccountStatistics, map[string]interface{}{
  161 + "userBaseId": cmd.Operator.UserBaseId,
  162 + "paymentBeginTime": beginTime,
  163 + "paymentEndTime": endTime,
  164 + })
  165 + var annualPaymentDividend = &AnnualDividend{}
  166 + if err := json.UnmarshalFromString(json.MarshalToString(paymentResult), annualPaymentDividend); err != nil {
  167 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  168 + }
  169 + dividendStatistics := map[string]interface{}{
  170 + "dividendAmount": annualPaymentDividend.Paid + annualUnPaidDividend.Unpaid, // 分红金额 annualDividend.Total
  171 + "paidAmount": annualPaymentDividend.Paid, // 已支付
  172 + "unPaidAmount": annualUnPaidDividend.Unpaid, // 未支付
  173 + }
  174 +
  175 + return map[string]interface{}{
  176 + "overview": overview,
  177 + "dividendStatistics": dividendStatistics,
  178 + }, nil
  179 +}
  180 +
101 // CompanyStatistics 共创用户-共创企业统计 181 // CompanyStatistics 共创用户-共创企业统计
102 func (srv PersonStatisticsService) CompanyStatistics(cmd *command.CooperationPersonStatisticsCommand) (interface{}, error) { 182 func (srv PersonStatisticsService) CompanyStatistics(cmd *command.CooperationPersonStatisticsCommand) (interface{}, error) {
103 183
@@ -235,20 +315,19 @@ func (srv PersonStatisticsService) CompanyStatisticsV2(cmd *command.CooperationP @@ -235,20 +315,19 @@ func (srv PersonStatisticsService) CompanyStatisticsV2(cmd *command.CooperationP
235 if cooperationCompanyStatisticsResponses[j].OrgId == int64(companyList[i]) { 315 if cooperationCompanyStatisticsResponses[j].OrgId == int64(companyList[i]) {
236 orgData, err := gatewayUser.OrgGet(allied_creation_user.ReqOrgGet{ 316 orgData, err := gatewayUser.OrgGet(allied_creation_user.ReqOrgGet{
237 OrgId: companyList[i], 317 OrgId: companyList[i],
  318 + FetchFlag: 1,
238 }) 319 })
239 if err != nil { 320 if err != nil {
240 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 321 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
241 } 322 }
242 - //orgData,err:= gatewayUser.CompanyGet(allied_creation_user.ReqCompanyGet{  
243 - // OrgId: companyList[i],  
244 - //})  
245 - if err != nil {  
246 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 323 + var companyLog string
  324 + if orgData.Company != nil {
  325 + companyLog = orgData.Company.Logo
247 } 326 }
248 cooperationCompanyStatisticsResponses[j].Company = domain.Company{ 327 cooperationCompanyStatisticsResponses[j].Company = domain.Company{
249 CompanyID: orgData.OrgID, 328 CompanyID: orgData.OrgID,
250 CompanyName: orgData.OrgName, 329 CompanyName: orgData.OrgName,
251 - //Logo: user.Company.Logo, 330 + Logo: companyLog,
252 } 331 }
253 values = append(values, cooperationCompanyStatisticsResponses[j]) 332 values = append(values, cooperationCompanyStatisticsResponses[j])
254 } 333 }
@@ -167,6 +167,9 @@ func (gateway HttplibAlliedCreationUser) OrgEnable(param ReqOrgEnable) (*DataOrg @@ -167,6 +167,9 @@ func (gateway HttplibAlliedCreationUser) OrgEnable(param ReqOrgEnable) (*DataOrg
167 // Org[orgId} 返回组织 167 // Org[orgId} 返回组织
168 func (gateway HttplibAlliedCreationUser) OrgGet(param ReqOrgGet) (*DataOrgGet, error) { 168 func (gateway HttplibAlliedCreationUser) OrgGet(param ReqOrgGet) (*DataOrgGet, error) {
169 url := gateway.baseUrL + "/org/" + strconv.Itoa(param.OrgId) 169 url := gateway.baseUrL + "/org/" + strconv.Itoa(param.OrgId)
  170 + if param.FetchFlag > 0 {
  171 + url += fmt.Sprintf("?fetchFlag=%v", param.FetchFlag)
  172 + }
170 method := "get" 173 method := "get"
171 req := gateway.CreateRequest(url, method) 174 req := gateway.CreateRequest(url, method)
172 log.Logger.Debug("向用户模块请求数据:返回组织。", map[string]interface{}{ 175 log.Logger.Debug("向用户模块请求数据:返回组织。", map[string]interface{}{
1 package allied_creation_user 1 package allied_creation_user
2 2
  3 +import "time"
  4 +
3 //创建组织 5 //创建组织
4 type ( 6 type (
5 ReqOrgCreate struct { 7 ReqOrgCreate struct {
@@ -84,6 +86,8 @@ type ( @@ -84,6 +86,8 @@ type (
84 type ( 86 type (
85 ReqOrgGet struct { 87 ReqOrgGet struct {
86 OrgId int `json:"orgId"` 88 OrgId int `json:"orgId"`
  89 + // 获取标记 bit 0:获取企业数据
  90 + FetchFlag int `json:"fetchFlag"`
87 } 91 }
88 92
89 DataOrgGet struct { 93 DataOrgGet struct {
@@ -103,6 +107,17 @@ type ( @@ -103,6 +107,17 @@ type (
103 ParentID int `json:"parentId"` 107 ParentID int `json:"parentId"`
104 ParentPath string `json:"parentPath"` 108 ParentPath string `json:"parentPath"`
105 //} `json:"org"` 109 //} `json:"org"`
  110 + Company *struct {
  111 + CompanyId int `json:"companyId"`
  112 + CompanyName string `json:"companyName"`
  113 + Scale string `json:"scale"`
  114 + IndustryCategory string `json:"industryCategory"`
  115 + RegisteredTime time.Time `json:"registeredTime"`
  116 + Status int64 `json:"status"`
  117 + Logo string `json:"logo"`
  118 + Address string `json:"address"`
  119 + SystemName string `json:"systemName"`
  120 + } `json:"company,omitempty"`
106 } 121 }
107 ) 122 )
108 123
@@ -601,7 +601,7 @@ func (controller *CooperationController) PersonIndexStatistics() { @@ -601,7 +601,7 @@ func (controller *CooperationController) PersonIndexStatistics() {
601 return 601 return
602 } 602 }
603 cmd.Operator = controller.GetOperator() 603 cmd.Operator = controller.GetOperator()
604 - data, err := svr.IndexStatistics(cmd) 604 + data, err := svr.IndexStatisticsV2(cmd)
605 controller.Response(data, err) 605 controller.Response(data, err)
606 } 606 }
607 607
@@ -614,7 +614,7 @@ func (controller *CooperationController) PersonCompanyStatistics() { @@ -614,7 +614,7 @@ func (controller *CooperationController) PersonCompanyStatistics() {
614 return 614 return
615 } 615 }
616 cmd.Operator = controller.GetOperator() 616 cmd.Operator = controller.GetOperator()
617 - data, err := svr.CompanyStatistics(cmd) 617 + data, err := svr.CompanyStatisticsV2(cmd)
618 controller.Response(data, err) 618 controller.Response(data, err)
619 } 619 }
620 620