作者 tangxuhui
@@ -120,7 +120,7 @@ func (srv CompanyCreditAccountService) PaymentHistoryStatistics(cmd *command.Cre @@ -120,7 +120,7 @@ func (srv CompanyCreditAccountService) PaymentHistoryStatistics(cmd *command.Cre
120 if cmd.EndTime > 0 { 120 if cmd.EndTime > 0 {
121 queryOptions["endTime"] = time.Unix(cmd.EndTime/1000, 0) 121 queryOptions["endTime"] = time.Unix(cmd.EndTime/1000, 0)
122 } 122 }
123 - cooperationUsersStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.CompanyCooperationUsersStatistics, queryOptions) 123 + cooperationUsersStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.CompanyPaymentHistoryStatistics, queryOptions)
124 if err != nil { 124 if err != nil {
125 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 125 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
126 } 126 }
@@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/command" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/command"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/domainService"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
11 "strconv" 12 "strconv"
12 "time" 13 "time"
@@ -61,6 +62,10 @@ func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.Co @@ -61,6 +62,10 @@ func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.Co
61 62
62 // ImportCompanyUser 导入公司用户信息 63 // ImportCompanyUser 导入公司用户信息
63 func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportDataCommand) (interface{}, error) { 64 func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
  65 + initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
  66 + if err != nil {
  67 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  68 + }
64 excelImport := excel.NewExcelImport() 69 excelImport := excel.NewExcelImport()
65 excelImport.RowBegin = 2 //第二行开始读取 70 excelImport.RowBegin = 2 //第二行开始读取
66 excelImport.DataFields = []excel.DataField{ 71 excelImport.DataFields = []excel.DataField{
@@ -70,13 +75,13 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD @@ -70,13 +75,13 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD
70 {EnName: "DepartmentID", CnName: "*所属部门"}, 75 {EnName: "DepartmentID", CnName: "*所属部门"},
71 {EnName: "Phone", CnName: "*手机号"}, 76 {EnName: "Phone", CnName: "*手机号"},
72 {EnName: "Email", CnName: "邮箱"}, 77 {EnName: "Email", CnName: "邮箱"},
  78 + {EnName: "Status", CnName: "状态"},
73 } 79 }
74 excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader) 80 excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
75 if err != nil { 81 if err != nil {
76 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 82 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
77 } 83 }
78 users := make([]allied_creation_user.BatchAddUserItem, 0) 84 users := make([]allied_creation_user.BatchAddUserItem, 0)
79 - var fail int  
80 for _, v := range excelData { 85 for _, v := range excelData {
81 item := allied_creation_user.BatchAddUserItem{ 86 item := allied_creation_user.BatchAddUserItem{
82 CompanyID: importDataCommand.Operator.CompanyId, 87 CompanyID: importDataCommand.Operator.CompanyId,
@@ -93,19 +98,18 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD @@ -93,19 +98,18 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD
93 } 98 }
94 item.OrganizationID, err = strconv.Atoi(v["OrganizationID"]) 99 item.OrganizationID, err = strconv.Atoi(v["OrganizationID"])
95 if err != nil { 100 if err != nil {
96 - fail++  
97 - continue 101 + return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("用户:%v 组织值:%v 类型无效(数值类型)", item.UserInfo.UserName, item.OrganizationID))
98 } 102 }
99 item.DepartmentID, err = strconv.Atoi(v["DepartmentID"]) 103 item.DepartmentID, err = strconv.Atoi(v["DepartmentID"])
100 if err != nil { 104 if err != nil {
101 - fail++  
102 - continue 105 + return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("用户:%v 部门值:%v 类型无效(数值类型)", item.UserInfo.UserName, item.DepartmentID))
103 } 106 }
104 users = append(users, item) 107 users = append(users, item)
105 } 108 }
106 userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator) 109 userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
107 result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{ 110 result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
108 Users: users, 111 Users: users,
  112 + Password: initPassword,
109 }) 113 })
110 if err != nil { 114 if err != nil {
111 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 115 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -115,6 +119,10 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD @@ -115,6 +119,10 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD
115 119
116 // ImportCooperationUser 导入共创用户信息 120 // ImportCooperationUser 导入共创用户信息
117 func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.ImportDataCommand) (interface{}, error) { 121 func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
  122 + initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
  123 + if err != nil {
  124 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  125 + }
118 excelImport := excel.NewExcelImport() 126 excelImport := excel.NewExcelImport()
119 excelImport.RowBegin = 2 //第二行开始读取 127 excelImport.RowBegin = 2 //第二行开始读取
120 excelImport.DataFields = []excel.DataField{ 128 excelImport.DataFields = []excel.DataField{
@@ -156,6 +164,7 @@ func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.Imp @@ -156,6 +164,7 @@ func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.Imp
156 userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator) 164 userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
157 result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{ 165 result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
158 Users: users, 166 Users: users,
  167 + Password: initPassword,
159 }) 168 })
160 if err != nil { 169 if err != nil {
161 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 170 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  1 +package domainService
  2 +
  3 +import (
  4 + "crypto/sha1"
  5 + "fmt"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
  9 +)
  10 +
  11 +//GetInitPassword 获取公司初始化密码
  12 +func GetInitPassword(operator domain.Operator) (string, string, error) {
  13 + var password string
  14 + alliedCreationBasic := allied_creation_basic.NewHttplibAlliedCreationBasic(operator)
  15 + reqResult, err := alliedCreationBasic.SystemSettingGet(allied_creation_basic.ReqSystemSettingGet{
  16 + domain.InitPasswordSettingKey,
  17 + })
  18 + if err != nil {
  19 + log.Logger.Error(err.Error())
  20 + return "", "", err
  21 + }
  22 + if len(reqResult.Value) == 0 {
  23 + return "", "", fmt.Errorf("初始化密码不能为空 ")
  24 + }
  25 + password = fmt.Sprintf("%x", sha1.Sum([]byte(reqResult.Value)))
  26 + return password, reqResult.Value, err
  27 +}
@@ -28,6 +28,8 @@ const ( @@ -28,6 +28,8 @@ const (
28 CompanyCooperationUsersStatistics = "CompanyCooperationUsersStatistics" 28 CompanyCooperationUsersStatistics = "CompanyCooperationUsersStatistics"
29 //公司 - 共创用户模式统计 29 //公司 - 共创用户模式统计
30 CooperationUserModeStatistics = "CooperationUserModeStatistics" 30 CooperationUserModeStatistics = "CooperationUserModeStatistics"
  31 + // 公司 - 共创用户分红支付统计
  32 + CompanyPaymentHistoryStatistics = "CompanyPaymentHistoryStatistics"
31 33
32 // 个人 - 共创企业统计 34 // 个人 - 共创企业统计
33 CooperationCompanyStatistics = "CooperationCompanyStatistics" 35 CooperationCompanyStatistics = "CooperationCompanyStatistics"
@@ -342,7 +342,7 @@ type ( @@ -342,7 +342,7 @@ type (
342 type ( 342 type (
343 ReqBatchAddUser struct { 343 ReqBatchAddUser struct {
344 Users []BatchAddUserItem `json:"users"` 344 Users []BatchAddUserItem `json:"users"`
345 - Password int `json:"password"` 345 + Password string `json:"password"`
346 } 346 }
347 347
348 DataBatchAddUser struct { 348 DataBatchAddUser struct {
@@ -118,7 +118,7 @@ func (controller *BaseController) GetExcelFile() (io.Reader, error) { @@ -118,7 +118,7 @@ func (controller *BaseController) GetExcelFile() (io.Reader, error) {
118 return nil, fmt.Errorf("上传文件不存在") 118 return nil, fmt.Errorf("上传文件不存在")
119 } 119 }
120 ext := filepath.Ext(fileHeader.Filename) 120 ext := filepath.Ext(fileHeader.Filename)
121 - if !(ext == "xlsx" || ext == "xls") { 121 + if !(ext == ".xlsx" || ext == ".xls") {
122 return nil, fmt.Errorf("仅支持上传文件格式 xls/xlsx") 122 return nil, fmt.Errorf("仅支持上传文件格式 xls/xlsx")
123 } 123 }
124 return excelFile, nil 124 return excelFile, nil