作者 tangxuhui
@@ -320,14 +320,13 @@ func (svr AuthService) OrgSwitch(switchOrgCommand *command.SwitchOrgCommand) (in @@ -320,14 +320,13 @@ func (svr AuthService) OrgSwitch(switchOrgCommand *command.SwitchOrgCommand) (in
320 320
321 // CompanySignUp 企业注册 321 // CompanySignUp 企业注册
322 func (svr AuthService) CompanySignUp(companySignUpCommand *command.CompanySignUpCommand) (interface{}, error) { 322 func (svr AuthService) CompanySignUp(companySignUpCommand *command.CompanySignUpCommand) (interface{}, error) {
323 - //TODO:验证码验证测试去掉,后期恢复回来  
324 - //smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()  
325 - //err := smsServeGateway.CheckSmsCode(companySignUpCommand.Phone, companySignUpCommand.SmsCode)  
326 - //if err != nil {  
327 - // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())  
328 - //} 323 + smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
  324 + err := smsServeGateway.CheckSmsCode(companySignUpCommand.Phone, companySignUpCommand.SmsCode)
  325 + if err != nil {
  326 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  327 + }
329 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) 328 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
330 - _, err := creationUserGateway.AuthCompanySignUp(allied_creation_user.ReqAuthCompanySignUp{ 329 + _, err = creationUserGateway.AuthCompanySignUp(allied_creation_user.ReqAuthCompanySignUp{
331 CompanyName: companySignUpCommand.CompanyName, 330 CompanyName: companySignUpCommand.CompanyName,
332 Phone: companySignUpCommand.Phone, 331 Phone: companySignUpCommand.Phone,
333 Password: companySignUpCommand.Password, 332 Password: companySignUpCommand.Password,
@@ -21,25 +21,37 @@ func (srv CompanyStatisticsService) GetDividendContracts(userMenusCommand *comma @@ -21,25 +21,37 @@ func (srv CompanyStatisticsService) GetDividendContracts(userMenusCommand *comma
21 } 21 }
22 22
23 // GetDividendContracts 企业的合约列表(分红信息按合约划分) 23 // GetDividendContracts 企业的合约列表(分红信息按合约划分)
24 -func (srv CompanyStatisticsService) SearchDividendContracts(userMenusCommand *command.SearchDividendContractsCommand) (interface{}, error) { 24 +func (srv CompanyStatisticsService) SearchDividendContracts(userMenusCommand *command.SearchDividendContractsCommand) (int64, interface{}, error) {
25 var items []*dto.CompanyContractDividendDto 25 var items []*dto.CompanyContractDividendDto
26 for i := 0; i < 2; i++ { 26 for i := 0; i < 2; i++ {
27 item := dto.NewCompanyContractDividendDto() 27 item := dto.NewCompanyContractDividendDto()
28 item.LoadDto() 28 item.LoadDto()
29 items = append(items, item) 29 items = append(items, item)
30 } 30 }
31 - return map[string]interface{}{  
32 - "list": items,  
33 - }, nil 31 + return 2, items, nil
34 } 32 }
35 33
36 // DividendsStatistics TODO:企业的合约统计(分红统计) 34 // DividendsStatistics TODO:企业的合约统计(分红统计)
37 func (srv CompanyStatisticsService) DividendsStatistics(userMenusCommand *command.DividendsStatisticsCommand) (interface{}, error) { 35 func (srv CompanyStatisticsService) DividendsStatistics(userMenusCommand *command.DividendsStatisticsCommand) (interface{}, error) {
38 return map[string]interface{}{ 36 return map[string]interface{}{
39 - "sumTotal": 9000,  
40 - "waitSettle": 6000,  
41 - "hasBeenSettle": 3000,  
42 - "hasBeenPay": 2000, 37 + "allDividends": map[string]interface{}{
  38 + "sumTotal": 9000,
  39 + "accounting": 6000,
  40 + "accounted": 3000,
  41 + "paid": 2000,
  42 + },
  43 + "annualDividends": map[string]interface{}{
  44 + "sumTotal": 9000,
  45 + "accounting": 6000,
  46 + "accounted": 3000,
  47 + "paid": 2000,
  48 + },
  49 + "quarterDividends": map[string]interface{}{
  50 + "sumTotal": 9000,
  51 + "accounting": 6000,
  52 + "accounted": 3000,
  53 + "paid": 2000,
  54 + },
43 }, nil 55 }, nil
44 } 56 }
45 57
@@ -21,25 +21,37 @@ func (srv PersonDividendsService) GetDividendContracts(userMenusCommand *command @@ -21,25 +21,37 @@ func (srv PersonDividendsService) GetDividendContracts(userMenusCommand *command
21 } 21 }
22 22
23 // GetDividendContracts 企业的合约列表(分红信息按合约划分) 23 // GetDividendContracts 企业的合约列表(分红信息按合约划分)
24 -func (srv PersonDividendsService) SearchDividendContracts(userMenusCommand *command.SearchDividendContractsCommand) (interface{}, error) { 24 +func (srv PersonDividendsService) SearchDividendContracts(userMenusCommand *command.SearchDividendContractsCommand) (int64, interface{}, error) {
25 var items []*dto.CompanyContractDividendDto 25 var items []*dto.CompanyContractDividendDto
26 for i := 0; i < 2; i++ { 26 for i := 0; i < 2; i++ {
27 item := dto.NewCompanyContractDividendDto() 27 item := dto.NewCompanyContractDividendDto()
28 item.LoadDto() 28 item.LoadDto()
29 items = append(items, item) 29 items = append(items, item)
30 } 30 }
31 - return map[string]interface{}{  
32 - "list": items,  
33 - }, nil 31 + return 2, items, nil
34 } 32 }
35 33
36 // DividendsStatistics TODO:企业的合约统计(分红统计) 34 // DividendsStatistics TODO:企业的合约统计(分红统计)
37 func (srv PersonDividendsService) DividendsStatistics(userMenusCommand *command.DividendsStatisticsCommand) (interface{}, error) { 35 func (srv PersonDividendsService) DividendsStatistics(userMenusCommand *command.DividendsStatisticsCommand) (interface{}, error) {
38 return map[string]interface{}{ 36 return map[string]interface{}{
39 - "sumTotal": 9000,  
40 - "waitSettle": 6000,  
41 - "hasBeenSettle": 3000,  
42 - "hasBeenPay": 2000, 37 + "allDividends": map[string]interface{}{
  38 + "sumTotal": 9000,
  39 + "accounting": 6000,
  40 + "accounted": 3000,
  41 + "paid": 2000,
  42 + },
  43 + "annualDividends": map[string]interface{}{
  44 + "sumTotal": 9000,
  45 + "accounting": 6000,
  46 + "accounted": 3000,
  47 + "paid": 2000,
  48 + },
  49 + "quarterDividends": map[string]interface{}{
  50 + "sumTotal": 9000,
  51 + "accounting": 6000,
  52 + "accounted": 3000,
  53 + "paid": 2000,
  54 + },
43 }, nil 55 }, nil
44 } 56 }
45 57
1 package dto 1 package dto
2 2
3 -import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" 3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  6 +)
4 7
5 type DepartmentUsersDto struct { 8 type DepartmentUsersDto struct {
6 Departments []*Department `json:"departments"` 9 Departments []*Department `json:"departments"`
@@ -19,6 +22,11 @@ type User struct { @@ -19,6 +22,11 @@ type User struct {
19 22
20 func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error { 23 func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error {
21 var mapDepartment = make(map[int64]*Department) 24 var mapDepartment = make(map[int64]*Department)
  25 + mapDepartment[-1] = &Department{
  26 + DepartmentID: -1,
  27 + DepartmentName: "共创部门",
  28 + }
  29 + dto.Departments = append(dto.Departments, mapDepartment[-1])
22 30
23 for i := range subDepartment.Orgs { 31 for i := range subDepartment.Orgs {
24 org := subDepartment.Orgs[i] 32 org := subDepartment.Orgs[i]
@@ -33,18 +41,20 @@ func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataO @@ -33,18 +41,20 @@ func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataO
33 41
34 for i := range userSearch.Users { 42 for i := range userSearch.Users {
35 user := userSearch.Users[i] 43 user := userSearch.Users[i]
36 - if user.Department == nil { 44 + u := User{
  45 + UserID: user.UserId,
  46 + UserCode: user.UserCode,
  47 + UserInfo: map[string]interface{}{
  48 + "userName": user.UserInfo.UserName,
  49 + "phone": user.UserInfo.Phone,
  50 + },
  51 + }
  52 + if (user.UserType & domain.UserTypeCooperation) > 0 {
  53 + mapDepartment[-1].Users = append(mapDepartment[-1].Users, u)
37 continue 54 continue
38 } 55 }
39 if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok { 56 if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok {
40 - v.Users = append(v.Users, User{  
41 - UserID: user.UserId,  
42 - UserCode: user.UserCode,  
43 - UserInfo: map[string]interface{}{  
44 - "userName": user.UserInfo.UserName,  
45 - "phone": user.UserInfo.Phone,  
46 - },  
47 - }) 57 + v.Users = append(v.Users, u)
48 } 58 }
49 } 59 }
50 return nil 60 return nil
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "crypto/sha1"
  5 + "fmt"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
4 "strconv" 8 "strconv"
5 "time" 9 "time"
6 10
@@ -102,6 +106,10 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command. @@ -102,6 +106,10 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.
102 orgId, _ := strconv.Atoi(companyUserAddCommand.OrgId) 106 orgId, _ := strconv.Atoi(companyUserAddCommand.OrgId)
103 userOrg := []int64{} 107 userOrg := []int64{}
104 userRole := []int64{} 108 userRole := []int64{}
  109 + initPassword, _, err := usersService.GetInitPassword()
  110 + if err != nil {
  111 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  112 + }
105 for _, v := range companyUserAddCommand.UserOrg { 113 for _, v := range companyUserAddCommand.UserOrg {
106 id, err := strconv.Atoi(v.OrgId) 114 id, err := strconv.Atoi(v.OrgId)
107 if err == nil { 115 if err == nil {
@@ -129,7 +137,7 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command. @@ -129,7 +137,7 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.
129 Phone: companyUserAddCommand.Phone, 137 Phone: companyUserAddCommand.Phone,
130 Avatar: companyUserAddCommand.Avatar, 138 Avatar: companyUserAddCommand.Avatar,
131 Email: companyUserAddCommand.Email, 139 Email: companyUserAddCommand.Email,
132 - Password: "123456", //TODO 填充密码 140 + Password: initPassword,
133 }) 141 })
134 if err != nil { 142 if err != nil {
135 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 143 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -213,14 +221,18 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw @@ -213,14 +221,18 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw
213 id, _ := strconv.Atoi(companyUserResetPasswordCommand.UserIds[i]) 221 id, _ := strconv.Atoi(companyUserResetPasswordCommand.UserIds[i])
214 userIds = append(userIds, int64(id)) 222 userIds = append(userIds, int64(id))
215 } 223 }
216 - _, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{  
217 - Password: "123456", //TODO 填充密码 224 + initPassword, primitivePassword, err := usersService.GetInitPassword()
  225 + if err != nil {
  226 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  227 + }
  228 + _, err = creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
  229 + Password: initPassword,
218 UserIds: userIds, 230 UserIds: userIds,
219 }) 231 })
220 if err != nil { 232 if err != nil {
221 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 233 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
222 } 234 }
223 - return "123456", err 235 + return primitivePassword, err
224 } 236 }
225 237
226 // 更新公司用户信息 238 // 更新公司用户信息
@@ -268,6 +280,10 @@ func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *co @@ -268,6 +280,10 @@ func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *co
268 func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *command.CooperationUserAddCommand) (interface{}, error) { 280 func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *command.CooperationUserAddCommand) (interface{}, error) {
269 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( 281 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
270 cooperationUserAddCommand.Operator) 282 cooperationUserAddCommand.Operator)
  283 + initPassword, _, err := usersService.GetInitPassword()
  284 + if err != nil {
  285 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  286 + }
271 result, err := creationUserGateway.CooperatorUserCreate(allied_creation_user.ReqCreateCooperatorUser{ 287 result, err := creationUserGateway.CooperatorUserCreate(allied_creation_user.ReqCreateCooperatorUser{
272 CompanyId: cooperationUserAddCommand.Operator.CompanyId, 288 CompanyId: cooperationUserAddCommand.Operator.CompanyId,
273 CooperationCompany: cooperationUserAddCommand.CooperationCompany, 289 CooperationCompany: cooperationUserAddCommand.CooperationCompany,
@@ -279,7 +295,7 @@ func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand * @@ -279,7 +295,7 @@ func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *
279 Avatar: cooperationUserAddCommand.Avatar, 295 Avatar: cooperationUserAddCommand.Avatar,
280 OrgId: cooperationUserAddCommand.Operator.OrgId, 296 OrgId: cooperationUserAddCommand.Operator.OrgId,
281 Phone: cooperationUserAddCommand.Phone, 297 Phone: cooperationUserAddCommand.Phone,
282 - Password: "123456", //TODO 填充默认密码 298 + Password: initPassword,
283 }) 299 })
284 if err != nil { 300 if err != nil {
285 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 301 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -380,20 +396,23 @@ func (usersService *UsersService) CooperationUserList(cooperationUserListQuery * @@ -380,20 +396,23 @@ func (usersService *UsersService) CooperationUserList(cooperationUserListQuery *
380 func (usersService *UsersService) CooperationUserResetPassword(cooperationUserResetPasswordCommand *command.CooperationUserResetPasswordCommand) (interface{}, error) { 396 func (usersService *UsersService) CooperationUserResetPassword(cooperationUserResetPasswordCommand *command.CooperationUserResetPasswordCommand) (interface{}, error) {
381 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( 397 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
382 cooperationUserResetPasswordCommand.Operator) 398 cooperationUserResetPasswordCommand.Operator)
  399 + initPassword, primitivePassword, err := usersService.GetInitPassword()
  400 + if err != nil {
  401 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  402 + }
383 var userIds []int64 403 var userIds []int64
384 for i := range cooperationUserResetPasswordCommand.UserIds { 404 for i := range cooperationUserResetPasswordCommand.UserIds {
385 id, _ := strconv.Atoi(cooperationUserResetPasswordCommand.UserIds[i]) 405 id, _ := strconv.Atoi(cooperationUserResetPasswordCommand.UserIds[i])
386 userIds = append(userIds, int64(id)) 406 userIds = append(userIds, int64(id))
387 } 407 }
388 - _, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{  
389 - Password: "123456", //TODO 填充密码 408 + _, err = creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
  409 + Password: initPassword, //TODO 填充密码
390 UserIds: userIds, 410 UserIds: userIds,
391 }) 411 })
392 if err != nil { 412 if err != nil {
393 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 413 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
394 } 414 }
395 - // TODO:返回消息提示 密码重置成功,初始密码为TL123456!  
396 - return "123456", err 415 + return primitivePassword, err
397 } 416 }
398 417
399 // 编辑共创用户信息 418 // 编辑共创用户信息
@@ -509,3 +528,21 @@ func (usersService *UsersService) SelectorCompanyOrgAll(selectorQuery *query.Com @@ -509,3 +528,21 @@ func (usersService *UsersService) SelectorCompanyOrgAll(selectorQuery *query.Com
509 } 528 }
510 return int64(result.Count), dataList, nil 529 return int64(result.Count), dataList, nil
511 } 530 }
  531 +
  532 +//GetInitPassword 获取公司初始化密码
  533 +func (usersService *UsersService) GetInitPassword() (string, string, error) {
  534 + var password string
  535 + alliedCreationBasic := allied_creation_basic.NewHttplibAlliedCreationBasic(domain.Operator{})
  536 + reqResult, err := alliedCreationBasic.SystemSettingGet(allied_creation_basic.ReqSystemSettingGet{
  537 + domain.InitPasswordSettingKey,
  538 + })
  539 + if err != nil {
  540 + log.Logger.Error(err.Error())
  541 + return "", "", err
  542 + }
  543 + if len(reqResult.Value) == 0 {
  544 + return "", "", fmt.Errorf("初始化密码不能为空 ")
  545 + }
  546 + password = fmt.Sprintf("%x", sha1.Sum([]byte(reqResult.Value)))
  547 + return password, reqResult.Value, err
  548 +}
@@ -12,7 +12,7 @@ var LOG_LEVEL = "debug" @@ -12,7 +12,7 @@ var LOG_LEVEL = "debug"
12 var HTTP_PORT int = 8083 12 var HTTP_PORT int = 8083
13 13
14 //天联共创基础模块 14 //天联共创基础模块
15 -var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" 15 +var ALLIED_CREATION_BASIC_HOST = "http://allied-creation-basic-dev.fjmaimaimai.com"
16 16
17 //天联共创用户模块 17 //天联共创用户模块
18 var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creation-user-dev.fjmaimaimai.com" 18 var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creation-user-dev.fjmaimaimai.com"
  1 +package domain
  2 +
  3 +const (
  4 + InitPasswordSettingKey = "XT001"
  5 +)
@@ -23,6 +23,6 @@ func NewHttplibAlliedCreationBasic(operator domain.Operator) *HttplibAlliedCreat @@ -23,6 +23,6 @@ func NewHttplibAlliedCreationBasic(operator domain.Operator) *HttplibAlliedCreat
23 UserId: operator.UserId, 23 UserId: operator.UserId,
24 UserBaseId: operator.UserBaseId, 24 UserBaseId: operator.UserBaseId,
25 }, 25 },
26 - baseUrL: constant.ALLIED_CREATION_USER_HOST, 26 + baseUrL: constant.ALLIED_CREATION_BASIC_HOST,
27 } 27 }
28 } 28 }
@@ -374,8 +374,8 @@ func (controller *CooperationController) SearchDividendContracts() { @@ -374,8 +374,8 @@ func (controller *CooperationController) SearchDividendContracts() {
374 return 374 return
375 } 375 }
376 cmd.Operator = controller.GetOperator() 376 cmd.Operator = controller.GetOperator()
377 - data, err := svr.SearchDividendContracts(cmd)  
378 - controller.Response(data, err) 377 + total, data, err := svr.SearchDividendContracts(cmd)
  378 + controller.ReturnPageListData(int64(total), data, err, cmd.PageNumber)
379 } 379 }
380 380
381 func (controller *CooperationController) DividendsStatistics() { 381 func (controller *CooperationController) DividendsStatistics() {
@@ -428,8 +428,8 @@ func (controller *CooperationController) SearchDividendContractsPerson() { @@ -428,8 +428,8 @@ func (controller *CooperationController) SearchDividendContractsPerson() {
428 return 428 return
429 } 429 }
430 cmd.Operator = controller.GetOperator() 430 cmd.Operator = controller.GetOperator()
431 - data, err := svr.SearchDividendContracts(cmd)  
432 - controller.Response(data, err) 431 + total, data, err := svr.SearchDividendContracts(cmd)
  432 + controller.ReturnPageListData(int64(total), data, err, cmd.PageNumber)
433 } 433 }
434 434
435 func (controller *CooperationController) DividendsStatisticsPerson() { 435 func (controller *CooperationController) DividendsStatisticsPerson() {