作者 tangxuhui
... ... @@ -120,7 +120,7 @@ func (srv CompanyCreditAccountService) PaymentHistoryStatistics(cmd *command.Cre
if cmd.EndTime > 0 {
queryOptions["endTime"] = time.Unix(cmd.EndTime/1000, 0)
}
cooperationUsersStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.CompanyCooperationUsersStatistics, queryOptions)
cooperationUsersStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.CompanyPaymentHistoryStatistics, queryOptions)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
... ...
... ... @@ -7,6 +7,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/domainService"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
"strconv"
"time"
... ... @@ -61,6 +62,10 @@ func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.Co
// ImportCompanyUser 导入公司用户信息
func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
excelImport := excel.NewExcelImport()
excelImport.RowBegin = 2 //第二行开始读取
excelImport.DataFields = []excel.DataField{
... ... @@ -70,13 +75,13 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD
{EnName: "DepartmentID", CnName: "*所属部门"},
{EnName: "Phone", CnName: "*手机号"},
{EnName: "Email", CnName: "邮箱"},
{EnName: "Status", CnName: "状态"},
}
excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
users := make([]allied_creation_user.BatchAddUserItem, 0)
var fail int
for _, v := range excelData {
item := allied_creation_user.BatchAddUserItem{
CompanyID: importDataCommand.Operator.CompanyId,
... ... @@ -93,19 +98,18 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD
}
item.OrganizationID, err = strconv.Atoi(v["OrganizationID"])
if err != nil {
fail++
continue
return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("用户:%v 组织值:%v 类型无效(数值类型)", item.UserInfo.UserName, item.OrganizationID))
}
item.DepartmentID, err = strconv.Atoi(v["DepartmentID"])
if err != nil {
fail++
continue
return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("用户:%v 部门值:%v 类型无效(数值类型)", item.UserInfo.UserName, item.DepartmentID))
}
users = append(users, item)
}
userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
Users: users,
Password: initPassword,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ... @@ -115,6 +119,10 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD
// ImportCooperationUser 导入共创用户信息
func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
excelImport := excel.NewExcelImport()
excelImport.RowBegin = 2 //第二行开始读取
excelImport.DataFields = []excel.DataField{
... ... @@ -156,6 +164,7 @@ func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.Imp
userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
Users: users,
Password: initPassword,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
package domainService
import (
"crypto/sha1"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"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"
)
//GetInitPassword 获取公司初始化密码
func GetInitPassword(operator domain.Operator) (string, string, error) {
var password string
alliedCreationBasic := allied_creation_basic.NewHttplibAlliedCreationBasic(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
}
... ...
... ... @@ -28,6 +28,8 @@ const (
CompanyCooperationUsersStatistics = "CompanyCooperationUsersStatistics"
//公司 - 共创用户模式统计
CooperationUserModeStatistics = "CooperationUserModeStatistics"
// 公司 - 共创用户分红支付统计
CompanyPaymentHistoryStatistics = "CompanyPaymentHistoryStatistics"
// 个人 - 共创企业统计
CooperationCompanyStatistics = "CooperationCompanyStatistics"
... ...
... ... @@ -342,7 +342,7 @@ type (
type (
ReqBatchAddUser struct {
Users []BatchAddUserItem `json:"users"`
Password int `json:"password"`
Password string `json:"password"`
}
DataBatchAddUser struct {
... ...
... ... @@ -118,7 +118,7 @@ func (controller *BaseController) GetExcelFile() (io.Reader, error) {
return nil, fmt.Errorf("上传文件不存在")
}
ext := filepath.Ext(fileHeader.Filename)
if !(ext == "xlsx" || ext == "xls") {
if !(ext == ".xlsx" || ext == ".xls") {
return nil, fmt.Errorf("仅支持上传文件格式 xls/xlsx")
}
return excelFile, nil
... ...