作者 yangfu

分红合约 公共接口修改

package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query"
"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 CommonService struct {
... ... @@ -66,23 +62,23 @@ func (srv *CommonService) GetDictionaryByCode(getDictionaryQuery *query.GetDicti
return map[string]interface{}{"dictionarys": dictionaries}, nil
}
//CompanySignUp 公司注册
func (srv *CommonService) CompanySignUp(signUpCommand *command.CompanySignUpCommand) (interface{}, error) {
if err := signUpCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//校验验证码
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
_, err := creationUserGateway.AuthCompanySignUp(allied_creation_user.ReqAuthCompanySignUp{
CompanyName: signUpCommand.CompanyName,
Contacts: signUpCommand.Contacts,
IndustryCategory: signUpCommand.IndustryCategory,
Password: signUpCommand.Password,
Phone: signUpCommand.Phone,
Scale: signUpCommand.Scale,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return signUpCommand, nil
//LatestVersionInfo 版本升级
func (srv *CommonService) LatestVersionInfo() (interface{}, error) {
return map[string]interface{}{
"version": map[string]interface{}{
"downloadPage": "www.baidu.com",
"downloadFile": "test.iso",
"updateType": 0,
},
}, nil
}
//AppSharing 获取分享链接地址
func (srv *CommonService) AppSharing() (interface{}, error) {
return map[string]interface{}{
"version": map[string]interface{}{
"downloadPage": "www.baidu.com",
"downloadFile": "test.iso",
},
}, nil
}
... ...
... ... @@ -11,11 +11,12 @@ type GetDividendContractsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 查询偏离量
PageNumber int `json:"pageIndex" valid:"Required"`
//PageNumber int `json:"pageIndex" valid:"Required"`
// 查询限制
PageSize int `json:"pageSize" valid:"Required"`
//PageSize int `json:"pageSize" valid:"Required"`
//审核状态
//Status int `json:"status"`
ContractId int `json:"contractId" valid:"Required"`
}
func (cmd *GetDividendContractsCommand) Valid(validation *validation.Validation) {
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type SearchDividendContractsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 查询偏离量
PageNumber int `json:"pageIndex" valid:"Required"`
// 查询限制
PageSize int `json:"pageSize" valid:"Required"`
//审核状态
//Status int `json:"status"`
}
func (cmd *SearchDividendContractsCommand) Valid(validation *validation.Validation) {
}
func (cmd *SearchDividendContractsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -11,14 +11,17 @@ type CompanyDividendsService struct {
// GetDividendContracts 企业的合约列表(分红信息按合约划分)
func (srv CompanyStatisticsService) GetDividendContracts(userMenusCommand *command.GetDividendContractsCommand) (interface{}, error) {
//creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
// userMenusCommand.Operator)
//resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
// UserId: int(userMenusCommand.Operator.UserId),
//})
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//var items []*dto.CompanyContractDividendDto
//for i := 0; i < 2; i++ {
// item := dto.NewCompanyContractDividendDto()
// item.LoadDto()
// items = append(items, item)
//}
return struct{}{}, nil
}
// GetDividendContracts 企业的合约列表(分红信息按合约划分)
func (srv CompanyStatisticsService) SearchDividendContracts(userMenusCommand *command.SearchDividendContractsCommand) (interface{}, error) {
var items []*dto.CompanyContractDividendDto
for i := 0; i < 2; i++ {
item := dto.NewCompanyContractDividendDto()
... ... @@ -32,14 +35,6 @@ func (srv CompanyStatisticsService) GetDividendContracts(userMenusCommand *comma
// DividendsStatistics TODO:企业的合约统计(分红统计)
func (srv CompanyStatisticsService) DividendsStatistics(userMenusCommand *command.DividendsStatisticsCommand) (interface{}, error) {
//creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
// userMenusCommand.Operator)
//resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
// UserId: int(userMenusCommand.Operator.UserId),
//})
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
return map[string]interface{}{
"sumTotal": 9000,
"waitSettle": 6000,
... ... @@ -50,14 +45,6 @@ func (srv CompanyStatisticsService) DividendsStatistics(userMenusCommand *comman
// SearchDividendsEstimates 企业的合约明细列表(分红预算信息)
func (srv CompanyStatisticsService) SearchDividendsEstimates(userMenusCommand *command.SearchDividendsEstimatesCommand) (interface{}, error) {
//creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
// userMenusCommand.Operator)
//resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
// UserId: int(userMenusCommand.Operator.UserId),
//})
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
var items []*dto.DividendsEstimatesDto
for i := 0; i < 2; i++ {
item := dto.NewDividendsEstimatesDto()
... ...
package service
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/dto"
)
// 企业端分红服务
type PersonDividendsService struct {
}
// GetDividendContracts 企业的合约列表(分红信息按合约划分)
func (srv PersonDividendsService) GetDividendContracts(userMenusCommand *command.GetDividendContractsCommand) (interface{}, error) {
//var items []*dto.CompanyContractDividendDto
//for i := 0; i < 2; i++ {
// item := dto.NewCompanyContractDividendDto()
// item.LoadDto()
// items = append(items, item)
//}
return struct{}{}, nil
}
// GetDividendContracts 企业的合约列表(分红信息按合约划分)
func (srv PersonDividendsService) SearchDividendContracts(userMenusCommand *command.SearchDividendContractsCommand) (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
}
// DividendsStatistics TODO:企业的合约统计(分红统计)
func (srv PersonDividendsService) DividendsStatistics(userMenusCommand *command.DividendsStatisticsCommand) (interface{}, error) {
return map[string]interface{}{
"sumTotal": 9000,
"waitSettle": 6000,
"hasBeenSettle": 3000,
"hasBeenPay": 2000,
}, nil
}
// SearchDividendsEstimates 企业的合约明细列表(分红预算信息)
func (srv PersonDividendsService) SearchDividendsEstimates(userMenusCommand *command.SearchDividendsEstimatesCommand) (interface{}, error) {
var items []*dto.DividendsEstimatesDto
for i := 0; i < 2; i++ {
item := dto.NewDividendsEstimatesDto()
item.LoadDto()
items = append(items, item)
}
return map[string]interface{}{
"list": items,
}, nil
}
... ...
package common_controller
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/service"
)
... ... @@ -19,10 +18,18 @@ func (controller *CommonController) GetDictionaryByCode() {
controller.Response(data, err)
}
func (controller *CommonController) CompanySignUp() {
func (controller *CommonController) LatestVersionInfo() {
commonService := service.NewCommonService(nil)
queryParm := command.CompanySignUpCommand{}
_ = controller.Unmarshal(queryParm)
data, err := commonService.CompanySignUp(&queryParm)
queryParam := &query.GetDictionaryByCodeQuery{}
_ = controller.Unmarshal(queryParam)
data, err := commonService.LatestVersionInfo()
controller.Response(data, err)
}
func (controller *CommonController) AppSharing() {
commonService := service.NewCommonService(nil)
queryParam := &query.GetDictionaryByCodeQuery{}
_ = controller.Unmarshal(queryParam)
data, err := commonService.AppSharing()
controller.Response(data, err)
}
... ...
... ... @@ -360,10 +360,24 @@ func (controller *CooperationController) GetDividendContracts() {
return
}
cmd.Operator = controller.GetOperator()
cmd.ContractId, _ = controller.GetInt("contractId")
data, err := svr.GetDividendContracts(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) SearchDividendContracts() {
svr := service.CompanyStatisticsService{}
cmd := &command.SearchDividendContractsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.SearchDividendContracts(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) DividendsStatistics() {
svr := service.CompanyStatisticsService{}
cmd := &command.DividendsStatisticsCommand{}
... ... @@ -390,6 +404,60 @@ func (controller *CooperationController) SearchDividendsEstimates() {
controller.Response(data, err)
}
/***** PersonDividends 个人端分红 *****/
func (controller *CooperationController) GetDividendContractsPerson() {
svr := service.PersonDividendsService{}
cmd := &command.GetDividendContractsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
cmd.ContractId, _ = controller.GetInt("contractId")
data, err := svr.GetDividendContracts(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) SearchDividendContractsPerson() {
svr := service.PersonDividendsService{}
cmd := &command.SearchDividendContractsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.SearchDividendContracts(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) DividendsStatisticsPerson() {
svr := service.PersonDividendsService{}
cmd := &command.DividendsStatisticsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.DividendsStatistics(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) SearchDividendsEstimatesPerson() {
svr := service.PersonDividendsService{}
cmd := &command.SearchDividendsEstimatesCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.SearchDividendsEstimates(cmd)
controller.Response(data, err)
}
/***** CompanyStatistics 企业端统计 *****/
func (controller *CooperationController) IndexStatistics() {
... ...
... ... @@ -2,10 +2,11 @@ package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/common_controller"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
)
func init() {
web.Router("/v1/common/dictionary/search", &common_controller.CommonController{}, "Post:GetDictionaryByCode")
//web.Router("/common/dictionary/search", &common_controller.CommonController{}, "Post:GetDictionaryByCode")
web.Router("/v1/common/dictionary/search", &controllers.CommonController{}, "Post:GetDictionaryByCode")
web.Router("/v1/common/version/getLatestVersionInfo", &controllers.CommonController{}, "Post:LatestVersionInfo")
web.Router("/v1/common/app-sharing", &controllers.CommonController{}, "Post:AppSharing")
}
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/common_controller"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client"
)
func init() {
//登录注册
web.Router("/v1/app/users/regist/company", &common_controller.CommonController{}, "Post:CompanySignUp")
web.Router("/v1/app/auth/login", &mobile_client.AuthController{}, "Post:Login")
web.Router("/v1/app/auth/access-token", &mobile_client.AuthController{}, "Post:GetAuthAccessToken")
web.Router("/v1/app/auth/refresh-token", &mobile_client.AuthController{}, "Post:RefreshAuthAccessToken")
//web.Router("/v1/app/users/regist/company", &common_controller.CommonController{}, "Post:CompanySignUp")
//web.Router("/v1/app/auth/login", &mobile_client.AuthController{}, "Post:Login")
//web.Router("/v1/app/auth/access-token", &mobile_client.AuthController{}, "Post:GetAuthAccessToken")
//web.Router("/v1/app/auth/refresh-token", &mobile_client.AuthController{}, "Post:RefreshAuthAccessToken")
//获取用户数据
web.Router("/v1/app/user/user-info", &mobile_client.AuthController{}, "Post:GetUserInfo")
web.Router("/v1/app/user/user-menu", &mobile_client.AuthController{}, "Post:GetUserMenus")
web.Router("/v1/app/user/user-orgs", &mobile_client.AuthController{}, "Post:GetUserOrg")
//公司用户注册
web.Router("/v1/app/auth/company-sign-up", &mobile_client.AuthController{}, "Post:CompanySignUp")
//公司重置密码
web.Router("/v1/app/auth/reset-password", &mobile_client.AuthController{}, "Post:ResetPassword")
web.Router("/v1/app/auth/org-switch", &mobile_client.AuthController{}, "Post:OrgSwitch")
//web.Router("/v1/app/user/user-info", &mobile_client.AuthController{}, "Post:GetUserInfo")
//web.Router("/v1/app/user/user-menu", &mobile_client.AuthController{}, "Post:GetUserMenus")
//web.Router("/v1/app/user/user-orgs", &mobile_client.AuthController{}, "Post:GetUserOrg")
////公司用户注册
//web.Router("/v1/app/auth/company-sign-up", &mobile_client.AuthController{}, "Post:CompanySignUp")
////公司重置密码
//web.Router("/v1/app/auth/reset-password", &mobile_client.AuthController{}, "Post:ResetPassword")
//web.Router("/v1/app/auth/org-switch", &mobile_client.AuthController{}, "Post:OrgSwitch")
}
... ...
... ... @@ -49,11 +49,18 @@ func init() {
web.Router("/v1/app/credit-accounts/payment-history/statistics", &mobile_client.CooperationController{}, "Post:PersonPaymentHistoryStatistics")
web.Router("/v1/app/credit-accounts/payment-history/histogram-statistics", &mobile_client.CooperationController{}, "Post:PersonPaymentHistoryHistogramStatistics")
/***** CompanyDividends 企业端分红 *****/
web.Router("/v1/app/cooperation/company/dividends/contracts", &mobile_client.CooperationController{}, "Post:GetDividendContracts")
/***** CompanyDividends 企业端合约分红 *****/
web.Router("/v1/app/cooperation/company/dividends/contracts", &mobile_client.CooperationController{}, "Post:SearchDividendContracts")
web.Router("/v1/app/cooperation/company/dividends/contracts/:contractId", &mobile_client.CooperationController{}, "Get:GetDividendContracts")
web.Router("/v1/app/cooperation/company/dividends/sum", &mobile_client.CooperationController{}, "Post:DividendsStatistics")
web.Router("/v1/app/cooperation/company/dividends-estimates/search", &mobile_client.CooperationController{}, "Post:SearchDividendsEstimates")
/***** PersonDividends 个人端合约分红 *****/
web.Router("/v1/app/cooperation/dividends/contracts", &mobile_client.CooperationController{}, "Post:SearchDividendContractsPerson")
web.Router("/v1/app/cooperation/dividends/contracts/:contractId", &mobile_client.CooperationController{}, "Get:GetDividendContractsPerson")
web.Router("/v1/app/cooperation/dividends/sum", &mobile_client.CooperationController{}, "Post:DividendsStatisticsPerson")
web.Router("/v1/app/cooperation/dividends-estimates/search", &mobile_client.CooperationController{}, "Post:SearchDividendsEstimatesPerson")
/***** CompanyStatistics 企业端统计 *****/
web.Router("/v1/app/cooperation/index", &mobile_client.CooperationController{}, "Get:IndexStatistics")
web.Router("/v1/app/cooperation/person/statistics", &mobile_client.CooperationController{}, "Post:CooperationPersonStatistics")
... ...