作者 tangxuhui
... ... @@ -320,14 +320,13 @@ func (svr AuthService) OrgSwitch(switchOrgCommand *command.SwitchOrgCommand) (in
// CompanySignUp 企业注册
func (svr AuthService) CompanySignUp(companySignUpCommand *command.CompanySignUpCommand) (interface{}, error) {
//TODO:验证码验证测试去掉,后期恢复回来
//smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
//err := smsServeGateway.CheckSmsCode(companySignUpCommand.Phone, companySignUpCommand.SmsCode)
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
err := smsServeGateway.CheckSmsCode(companySignUpCommand.Phone, companySignUpCommand.SmsCode)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
_, err := creationUserGateway.AuthCompanySignUp(allied_creation_user.ReqAuthCompanySignUp{
_, err = creationUserGateway.AuthCompanySignUp(allied_creation_user.ReqAuthCompanySignUp{
CompanyName: companySignUpCommand.CompanyName,
Phone: companySignUpCommand.Phone,
Password: companySignUpCommand.Password,
... ...
... ... @@ -21,25 +21,37 @@ func (srv CompanyStatisticsService) GetDividendContracts(userMenusCommand *comma
}
// GetDividendContracts 企业的合约列表(分红信息按合约划分)
func (srv CompanyStatisticsService) SearchDividendContracts(userMenusCommand *command.SearchDividendContractsCommand) (interface{}, error) {
func (srv CompanyStatisticsService) SearchDividendContracts(userMenusCommand *command.SearchDividendContractsCommand) (int64, interface{}, error) {
var items []*dto.CompanyContractDividendDto
for i := 0; i < 2; i++ {
item := dto.NewCompanyContractDividendDto()
item.LoadDto()
items = append(items, item)
}
return map[string]interface{}{
"list": items,
}, nil
return 2, items, nil
}
// DividendsStatistics TODO:企业的合约统计(分红统计)
func (srv CompanyStatisticsService) DividendsStatistics(userMenusCommand *command.DividendsStatisticsCommand) (interface{}, error) {
return map[string]interface{}{
"allDividends": map[string]interface{}{
"sumTotal": 9000,
"accounting": 6000,
"accounted": 3000,
"paid": 2000,
},
"annualDividends": map[string]interface{}{
"sumTotal": 9000,
"accounting": 6000,
"accounted": 3000,
"paid": 2000,
},
"quarterDividends": map[string]interface{}{
"sumTotal": 9000,
"waitSettle": 6000,
"hasBeenSettle": 3000,
"hasBeenPay": 2000,
"accounting": 6000,
"accounted": 3000,
"paid": 2000,
},
}, nil
}
... ...
... ... @@ -21,25 +21,37 @@ func (srv PersonDividendsService) GetDividendContracts(userMenusCommand *command
}
// GetDividendContracts 企业的合约列表(分红信息按合约划分)
func (srv PersonDividendsService) SearchDividendContracts(userMenusCommand *command.SearchDividendContractsCommand) (interface{}, error) {
func (srv PersonDividendsService) SearchDividendContracts(userMenusCommand *command.SearchDividendContractsCommand) (int64, interface{}, error) {
var items []*dto.CompanyContractDividendDto
for i := 0; i < 2; i++ {
item := dto.NewCompanyContractDividendDto()
item.LoadDto()
items = append(items, item)
}
return map[string]interface{}{
"list": items,
}, nil
return 2, items, nil
}
// DividendsStatistics TODO:企业的合约统计(分红统计)
func (srv PersonDividendsService) DividendsStatistics(userMenusCommand *command.DividendsStatisticsCommand) (interface{}, error) {
return map[string]interface{}{
"allDividends": map[string]interface{}{
"sumTotal": 9000,
"accounting": 6000,
"accounted": 3000,
"paid": 2000,
},
"annualDividends": map[string]interface{}{
"sumTotal": 9000,
"accounting": 6000,
"accounted": 3000,
"paid": 2000,
},
"quarterDividends": map[string]interface{}{
"sumTotal": 9000,
"waitSettle": 6000,
"hasBeenSettle": 3000,
"hasBeenPay": 2000,
"accounting": 6000,
"accounted": 3000,
"paid": 2000,
},
}, nil
}
... ...
package dto
import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
type DepartmentUsersDto struct {
Departments []*Department `json:"departments"`
... ... @@ -19,6 +22,11 @@ type User struct {
func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error {
var mapDepartment = make(map[int64]*Department)
mapDepartment[-1] = &Department{
DepartmentID: -1,
DepartmentName: "共创部门",
}
dto.Departments = append(dto.Departments, mapDepartment[-1])
for i := range subDepartment.Orgs {
org := subDepartment.Orgs[i]
... ... @@ -33,18 +41,20 @@ func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataO
for i := range userSearch.Users {
user := userSearch.Users[i]
if user.Department == nil {
continue
}
if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok {
v.Users = append(v.Users, User{
u := User{
UserID: user.UserId,
UserCode: user.UserCode,
UserInfo: map[string]interface{}{
"userName": user.UserInfo.UserName,
"phone": user.UserInfo.Phone,
},
})
}
if (user.UserType & domain.UserTypeCooperation) > 0 {
mapDepartment[-1].Users = append(mapDepartment[-1].Users, u)
continue
}
if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok {
v.Users = append(v.Users, u)
}
}
return nil
... ...
package service
import (
"crypto/sha1"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"strconv"
"time"
... ... @@ -102,6 +106,10 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.
orgId, _ := strconv.Atoi(companyUserAddCommand.OrgId)
userOrg := []int64{}
userRole := []int64{}
initPassword, _, err := usersService.GetInitPassword()
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
for _, v := range companyUserAddCommand.UserOrg {
id, err := strconv.Atoi(v.OrgId)
if err == nil {
... ... @@ -129,7 +137,7 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.
Phone: companyUserAddCommand.Phone,
Avatar: companyUserAddCommand.Avatar,
Email: companyUserAddCommand.Email,
Password: "123456", //TODO 填充密码
Password: initPassword,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ... @@ -213,14 +221,18 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw
id, _ := strconv.Atoi(companyUserResetPasswordCommand.UserIds[i])
userIds = append(userIds, int64(id))
}
_, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
Password: "123456", //TODO 填充密码
initPassword, primitivePassword, err := usersService.GetInitPassword()
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
_, err = creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
Password: initPassword,
UserIds: userIds,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return "123456", err
return primitivePassword, err
}
// 更新公司用户信息
... ... @@ -268,6 +280,10 @@ func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *co
func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *command.CooperationUserAddCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserAddCommand.Operator)
initPassword, _, err := usersService.GetInitPassword()
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
result, err := creationUserGateway.CooperatorUserCreate(allied_creation_user.ReqCreateCooperatorUser{
CompanyId: cooperationUserAddCommand.Operator.CompanyId,
CooperationCompany: cooperationUserAddCommand.CooperationCompany,
... ... @@ -279,7 +295,7 @@ func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *
Avatar: cooperationUserAddCommand.Avatar,
OrgId: cooperationUserAddCommand.Operator.OrgId,
Phone: cooperationUserAddCommand.Phone,
Password: "123456", //TODO 填充默认密码
Password: initPassword,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ... @@ -380,20 +396,23 @@ func (usersService *UsersService) CooperationUserList(cooperationUserListQuery *
func (usersService *UsersService) CooperationUserResetPassword(cooperationUserResetPasswordCommand *command.CooperationUserResetPasswordCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserResetPasswordCommand.Operator)
initPassword, primitivePassword, err := usersService.GetInitPassword()
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var userIds []int64
for i := range cooperationUserResetPasswordCommand.UserIds {
id, _ := strconv.Atoi(cooperationUserResetPasswordCommand.UserIds[i])
userIds = append(userIds, int64(id))
}
_, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
Password: "123456", //TODO 填充密码
_, err = creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
Password: initPassword, //TODO 填充密码
UserIds: userIds,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
// TODO:返回消息提示 密码重置成功,初始密码为TL123456!
return "123456", err
return primitivePassword, err
}
// 编辑共创用户信息
... ... @@ -509,3 +528,21 @@ func (usersService *UsersService) SelectorCompanyOrgAll(selectorQuery *query.Com
}
return int64(result.Count), dataList, nil
}
//GetInitPassword 获取公司初始化密码
func (usersService *UsersService) GetInitPassword() (string, string, error) {
var password string
alliedCreationBasic := allied_creation_basic.NewHttplibAlliedCreationBasic(domain.Operator{})
reqResult, err := alliedCreationBasic.SystemSettingGet(allied_creation_basic.ReqSystemSettingGet{
domain.InitPasswordSettingKey,
})
if err != nil {
log.Logger.Error(err.Error())
return "", "", err
}
if len(reqResult.Value) == 0 {
return "", "", fmt.Errorf("初始化密码不能为空 ")
}
password = fmt.Sprintf("%x", sha1.Sum([]byte(reqResult.Value)))
return password, reqResult.Value, err
}
... ...
... ... @@ -12,7 +12,7 @@ var LOG_LEVEL = "debug"
var HTTP_PORT int = 8083
//天联共创基础模块
var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080"
var ALLIED_CREATION_BASIC_HOST = "http://allied-creation-basic-dev.fjmaimaimai.com"
//天联共创用户模块
var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creation-user-dev.fjmaimaimai.com"
... ...
package domain
const (
InitPasswordSettingKey = "XT001"
)
... ...
... ... @@ -23,6 +23,6 @@ func NewHttplibAlliedCreationBasic(operator domain.Operator) *HttplibAlliedCreat
UserId: operator.UserId,
UserBaseId: operator.UserBaseId,
},
baseUrL: constant.ALLIED_CREATION_USER_HOST,
baseUrL: constant.ALLIED_CREATION_BASIC_HOST,
}
}
... ...
... ... @@ -374,8 +374,8 @@ func (controller *CooperationController) SearchDividendContracts() {
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.SearchDividendContracts(cmd)
controller.Response(data, err)
total, data, err := svr.SearchDividendContracts(cmd)
controller.ReturnPageListData(int64(total), data, err, cmd.PageNumber)
}
func (controller *CooperationController) DividendsStatistics() {
... ... @@ -428,8 +428,8 @@ func (controller *CooperationController) SearchDividendContractsPerson() {
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.SearchDividendContracts(cmd)
controller.Response(data, err)
total, data, err := svr.SearchDividendContracts(cmd)
controller.ReturnPageListData(int64(total), data, err, cmd.PageNumber)
}
func (controller *CooperationController) DividendsStatisticsPerson() {
... ...