作者 tangxuhui

预算分红

... ... @@ -3,8 +3,7 @@ package command
import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
type PayCreditAccountCommand struct {
//操作人
Operator domain.Operator `json:"-"`
Operator domain.Operator `json:"-"` //操作人
CreditAccountId int `json:"creditAccountId"` //账期结算id
ActuallyPaidAmount float64 `json:"actuallyPaidAmount"` //实际金额
Remarks string `json:"remarks"` //备注
... ...
package dto
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_cooperation"
)
type CreditAccountItem struct {
CreditAccountId int `json:"creditAccountId,string"` // 账期结算单ID
ActuallyPaidAmount float64 `json:"actuallyPaidAmount"` // 账期结算实付金额
CreditAccountOrderNum string `json:"creditAccountOrderNum"` // 账期结算单号
PaymentStatus int `json:"paymentStatus"` // 账期结算支付状态,1待支付,2已支付
PaymentTime int64 `json:"paymentTime"` // 共创账期结算支付时间
SettlementAmount float64 `json:"settlementAmount"` // 账期结算金额
SettlementTime int64 `json:"settlementTime"` // 共创账期结算时间
CooperationContractNumber string `json:"cooperationContractNumber"` // 关联共创合约编号
Participator struct {
UserName string `json:"userName"` // 用户姓名
UserPhone string `json:"userPhone"` // 用户手机号
UserType int `json:"userType"` // 用户类型,1员工,2共创用户,3公开
} `json:"participator"` // 参与人
ParticipateType string `json:"participateType"` // 参与类型
PaymentDocumentAttachment domain.Attachment `json:"paymentDocumentAttachment"` // 支付凭证附件
Org domain.Org `json:"org"` // 数据所属组织机构
Company domain.CompanyData `json:"company"` // 公司
CreatedAt int64 `json:"createdAt"` // 创建时间
UpdatedAt int64 `json:"updatedAt"` // 更新时间
AccountDetail []struct {
DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"`
DividendsType string `json:"dividendsType"`
DividendsAmount float64 `json:"dividendsAmount"`
} `json:"accountDetail"` //结算明细
}
func ToCreditAccountItem(param *allied_creation_cooperation.CreditAccount) *CreditAccountItem {
data := CreditAccountItem{
CreditAccountId: param.CreditAccountId,
ActuallyPaidAmount: param.ActuallyPaidAmount,
CreditAccountOrderNum: param.CreditAccountOrderNum,
PaymentStatus: param.PaymentStatus,
PaymentTime: param.PaymentTime.Unix(),
SettlementAmount: param.SettlementAmount,
SettlementTime: param.SettlementTime.Unix(),
CooperationContractNumber: param.CooperationContractNumber,
ParticipateType: param.ParticipateType, // 参与类型
PaymentDocumentAttachment: param.PaymentDocumentAttachment, // 支付凭证附件
Org: param.Org, // 数据所属组织机构
Company: param.Company, // 公司
CreatedAt: param.CreatedAt.Unix(), // 创建时间
UpdatedAt: param.UpdatedAt.Unix(), // 更新时间
AccountDetail: param.AccountDetail,
}
data.Participator.UserName = param.Participator.UserName
data.Participator.UserPhone = param.Participator.UserPhone
data.Participator.UserType = param.Participator.UserType
return &data
}
... ...
... ... @@ -3,6 +3,7 @@ package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/creditAccount/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/creditAccount/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/creditAccount/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
... ... @@ -15,14 +16,34 @@ func NewCreditAccountService(option map[string]interface{}) CreditAccountService
//ListCreditAccount返回账期结算列表
func (srv *CreditAccountService) ListCreditAccount(listQuery *query.ListCreditAccountQuery) (int64, interface{}, error) {
return 0, nil, nil
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(listQuery.Operator)
result, err := creationCooperationGateway.CreditAccountsSearch(allied_creation_cooperation.ReqCreditAccountsSearch{
PageNumber: int64(listQuery.PageNumber),
PageSize: int64(listQuery.PageSize),
CreditAccountOrderNum: listQuery.CreditAccountOrderNum,
ParticipatorName: listQuery.Participator,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var listData []dto.CreditAccountItem
for i := range result.Grid.List {
item := dto.ToCreditAccountItem(&result.Grid.List[i])
listData = append(listData, *item)
}
return int64(result.Grid.Total), listData, nil
}
//GetCreditAccount 返回账期结算详情
func (srv *CreditAccountService) GetCreditAccount(getQuery *query.GetCreditAccountQuery) (interface{}, error) {
return nil, nil
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(getQuery.Operator)
result, err := creationCooperationGateway.CreditAccountGet(allied_creation_cooperation.ReqCreditAccountGet{
CreditAccountId: getQuery.CreditAccountId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return dto.ToCreditAccountItem(&result.CreditAccount), nil
}
//PayCreditAccount 支付账期结算
... ...
... ... @@ -7,17 +7,18 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
//业绩分红 确定预算。。。
type EstimateDividendsIncentivesCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 分红订单号/退货单号
OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum" valid:"Required"`
OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"`
// 合约编号
CooperationContractNumber string `json:"cooperationContractNumber" valid:"Required"`
CooperationContractNumber string `json:"cooperationContractNumber" `
}
func (estimateDividendsIncentivesCommand *EstimateDividendsIncentivesCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (estimateDividendsIncentivesCommand *EstimateDividendsIncentivesCommand) ValidateCommand() error {
... ...
... ... @@ -14,10 +14,12 @@ type EstimateMoneyIncentivesCommand struct {
CooperationContractNumber string `json:"cooperationContractNumber" valid:"Required"`
// 承接人UID
UndertakerUid string `json:"undertakerUid,omitempty"`
//分红阶段
DividendsIncentivesStage int `json:"dividendsIncentivesStage"`
}
func (estimateMoneyIncentivesCommand *EstimateMoneyIncentivesCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (estimateMoneyIncentivesCommand *EstimateMoneyIncentivesCommand) ValidateCommand() error {
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type UpdateDividendsEstimateCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 承接人分红预算记录ID
DividendsEstimateId int64 `json:"dividendsEstimateId" valid:"Required"`
}
func (updateDividendsEstimateCommand *UpdateDividendsEstimateCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateDividendsEstimateCommand *UpdateDividendsEstimateCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateDividendsEstimateCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
//MoneyIncentivesItem 金额激励分红列表
type MoneyIncentivesItem struct {
}
//业绩分红列表
type DividendsEstimateDividendItem struct {
CooperationContractNumber string `json:"cooperationContractNumber"` //共创合约编号
CustomerName string `json:"customerName"` //客户名称
DividendsIncentivesAmount int `json:"dividendsIncentivesAmount"` //业绩激励分红金额
OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"` //分红订单号或退货单号
OrderTime int64 `json:"orderTime"` //订单/退货单日期
OriginalOrderNum string `json:"originalOrderNum"` //来源单号,源单号,订单号
RegionName string `json:"regionName"` //区域名称
}
func ToDividendsEstimateDividendItem(param *allied_creation_cooperation.DataDividendsEstimateSearchDividend) []DividendsEstimateDividendItem {
var listdata []DividendsEstimateDividendItem
for _, v := range param.Grid.List {
item := DividendsEstimateDividendItem{
CooperationContractNumber: v.CooperationContractNumber,
CustomerName: v.CustomerName,
DividendsIncentivesAmount: v.DividendsIncentivesAmount,
OrderOrReturnedOrderNum: v.OrderOrReturnedOrderNum,
OrderTime: v.OrderTime.Unix(),
OriginalOrderNum: v.OriginalOrderNum,
RegionName: v.Region.RegionName,
}
listdata = append(listdata, item)
}
return listdata
}
type DividendsEstimateMoneyItem struct {
CooperationContractName string `json:"cooperationContractName"` //合约名称
CooperationContractNumber string `json:"cooperationContractNumber"` //合约编码
CooperationMode struct {
CooperationModeId int `json:"cooperationModeId"`
CooperationModeName string `json:"cooperationModeName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
} `json:"cooperationMode"` //共创模式
CreatedAt int64 `json:"createdAt"` //合约建立时间
Department struct {
DepartmentId int `json:"departmentId"`
DepartmentName string `json:"departmentName"`
} `json:"department"` //发起部门
CooperationContractSponsor struct {
UserId int `json:"userId"`
UserBaseId int `json:"userBaseId"`
UsersName string `json:"userName"`
Phone string `json:"phone"`
} `json:"cooperationContractSponsor"` //合约发起人
}
func ToDividendsEstimateMoneyItem(param *allied_creation_cooperation.DataDividendsEstimateSearchMoney) []DividendsEstimateMoneyItem {
var listdata []DividendsEstimateMoneyItem
for _, v := range param.Grid.List {
item := DividendsEstimateMoneyItem{
CooperationContractName: v.CooperationContractName,
CooperationContractNumber: v.CooperationContractNumber,
CreatedAt: v.CreatedAt.Unix(),
}
item.CooperationMode.CooperationModeId = v.CooperationMode.CooperationModeId
item.CooperationMode.CooperationModeName = v.CooperationMode.CooperationModeName
item.CooperationMode.CooperationModeNumber = v.CooperationMode.CooperationModeNumber
item.Department.DepartmentId = v.Department.DepartmentId
item.Department.DepartmentName = v.Department.DepartmentName
item.CooperationContractSponsor.UserId = v.CooperationContractSponsor.UserId
item.CooperationContractSponsor.Phone = v.CooperationContractSponsor.UserInfo.Phone
item.CooperationContractSponsor.UsersName = v.CooperationContractSponsor.UserInfo.UsersName
listdata = append(listdata, item)
}
return listdata
}
//合约承接人
type ContractUndertaker struct {
UserId int `json:"userId,string,"`
UsersName string `json:"userName"`
ContractIncentivesRules []int `json:"contractIncentivesRules"`
}
// 金额激励规则
type MoneyIncentivesRule struct {
MoneyIncentivesStage int //阶段
MoneyIncentivesStageStart int //阶段开始时间
}
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type GetDividendsEstimateQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 承接人分红预算记录ID
DividendsEstimateId int64 `json:"dividendsEstimateId" valid:"Required"`
}
func (getDividendsEstimateQuery *GetDividendsEstimateQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (getDividendsEstimateQuery *GetDividendsEstimateQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(getDividendsEstimateQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type ListDividendsEstimateQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 查询偏离量
PageNumber int `json:"pageNumber" `
// 查询限制
PageSize int `json:"pageSize"`
}
func (listDividendsEstimateQuery *ListDividendsEstimateQuery) Valid(validation *validation.Validation) {
}
func (listDividendsEstimateQuery *ListDividendsEstimateQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listDividendsEstimateQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type ListDividendsIncentivesQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 查询偏离量
PageNumber int `json:"pageNumber" `
// 查询限制
PageSize int `json:"pageSize" `
}
func (listDividendsIncentivesQuery *ListDividendsIncentivesQuery) Valid(validation *validation.Validation) {
}
func (listDividendsIncentivesQuery *ListDividendsIncentivesQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listDividendsIncentivesQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type ListMoneyIncentivesQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 查询偏离量
PageNumber int `json:"pageNumber" valid:"Required"`
// 查询限制
PageSize int `json:"pageSize" valid:"Required"`
CooperationContractName string `json:"cooperationContractName"` //合约名称
DepartmentName string `json:"department"`
}
func (listMoneyIncentivesQuery *ListMoneyIncentivesQuery) Valid(validation *validation.Validation) {
}
func (listMoneyIncentivesQuery *ListMoneyIncentivesQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listMoneyIncentivesQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
package query
import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
type MoneyIncentiveSelectorQuery struct {
//操作人
Operator domain.Operator `json:"-"`
CooperationContractNumber string `json:"cooperationContractNumber"`
}
... ...
... ... @@ -3,6 +3,7 @@ package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/dividendsEstimate/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/dividendsEstimate/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/dividendsEstimate/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
... ... @@ -25,17 +26,31 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat
// 确定预算分红激励
func (dividendsEstimateService *DividendsEstimateService) EstimateDividendsIncentives(estimateDividendsIncentivesCommand *command.EstimateDividendsIncentivesCommand) (interface{}, error) {
// creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
// estimateDividendsIncentivesCommand.Operator)
return nil, nil
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
estimateDividendsIncentivesCommand.Operator)
_, err := creationCooperationGateway.DividendsEstimateDividendsIncentives(allied_creation_cooperation.ReqDividendsEstimateDividendsIncentives{
CooperationContractNumber: estimateDividendsIncentivesCommand.CooperationContractNumber,
OrderOrReturnedOrderNum: estimateDividendsIncentivesCommand.OrderOrReturnedOrderNum,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return estimateDividendsIncentivesCommand, nil
}
// 确定预算金额激励分红
func (dividendsEstimateService *DividendsEstimateService) EstimateMoneyIncentives(estimateMoneyIncentivesCommand *command.EstimateMoneyIncentivesCommand) (interface{}, error) {
// creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
// estimateMoneyIncentivesCommand.Operator)
return nil, nil
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
estimateMoneyIncentivesCommand.Operator)
result, err := creationCooperationGateway.DividendsEstimatesEstimateMoneys(allied_creation_cooperation.ReqDividendsEstimateMoneyIncentives{
CooperationContractNumber: estimateMoneyIncentivesCommand.CooperationContractNumber,
DividendsIncentivesStage: estimateMoneyIncentivesCommand.DividendsIncentivesStage,
UndertakerUid: estimateMoneyIncentivesCommand.UndertakerUid,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, nil
}
// 查询分红预算单列表
... ... @@ -43,10 +58,8 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsEstimat
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
searchDividendsEstimateQuery.Operator)
result, err := creationCooperationGateway.DividendsEstimatesSearch(allied_creation_cooperation.ReqDividendsEstimateSearch{
//承接人分红预算单号
DividendsEstimateOrderNumber: searchDividendsEstimateQuery.DividendsEstimateOrderNumber,
//分红类型,1订单分红,2退货冲销,3金额激励
DividendsType: searchDividendsEstimateQuery.DividendsType,
DividendsEstimateOrderNumber: searchDividendsEstimateQuery.DividendsEstimateOrderNumber, //承接人分红预算单号
DividendsType: searchDividendsEstimateQuery.DividendsType, //分红类型,1订单分红,2退货冲销,3金额激励
PageNumber: searchDividendsEstimateQuery.PageNumber,
PageSize: searchDividendsEstimateQuery.PageSize,
})
... ... @@ -57,7 +70,8 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsEstimat
}
// 查询业绩分红
func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncentives(searchDividendsIncentivesQuery *query.SearchDividendsIncentivesQuery) (interface{}, error) {
func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncentives(searchDividendsIncentivesQuery *query.SearchDividendsIncentivesQuery) (
int, interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
searchDividendsIncentivesQuery.Operator)
result, err := creationCooperationGateway.DividendsEstimateSearchDividends(
... ... @@ -68,13 +82,15 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti
OrderOrReturnedOrderNum: searchDividendsIncentivesQuery.OrderOrReturnedOrderNum,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, nil
listdata := dto.ToDividendsEstimateDividendItem(result)
return result.Grid.Total, listdata, nil
}
// 查询金额激励分红
func (dividendsEmmateService *DividendsEstimateService) SearchMoneyIncentives(searchMoneyIncentivesQuery *query.SearchMoneyIncentivesQuery) (interface{}, error) {
func (dividendsEmmateService *DividendsEstimateService) SearchMoneyIncentives(searchMoneyIncentivesQuery *query.SearchMoneyIncentivesQuery) (
int, interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
searchMoneyIncentivesQuery.Operator)
result, err := creationCooperationGateway.DividendsEstimatesSearchMoney(allied_creation_cooperation.ReqDividendsEstimateSearchMoney{
... ... @@ -84,12 +100,63 @@ func (dividendsEmmateService *DividendsEstimateService) SearchMoneyIncentives(se
DepartmentName: searchMoneyIncentivesQuery.DepartmentName,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, nil
dataList := dto.ToDividendsEstimateMoneyItem(result)
return result.Grid.Total, dataList, nil
}
func NewDividendsEstimateService(options map[string]interface{}) *DividendsEstimateService {
newDividendsEstimateService := &DividendsEstimateService{}
return newDividendsEstimateService
}
func (dividendsEmmateService *DividendsEstimateService) MoneyIncentivesSelector(queryParam query.MoneyIncentiveSelectorQuery) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
queryParam.Operator)
resultContract, err := creationCooperationGateway.CooperationContractSearch(allied_creation_cooperation.ReqCooperationContractSearch{
CooperationContractNumber: queryParam.CooperationContractNumber,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if len(resultContract.Grid.List) == 0 {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "未找到对应的合约数据")
}
contractData := resultContract.Grid.List[0]
resultDividendsEstimate, err := creationCooperationGateway.DividendsEstimatesSearch(allied_creation_cooperation.ReqDividendsEstimateSearch{
CooperationContractNumber: queryParam.CooperationContractNumber,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
rules := []dto.MoneyIncentivesRule{}
for _, v := range contractData.MoneyIncentivesRules {
r := dto.MoneyIncentivesRule{
MoneyIncentivesStage: v.MoneyIncentivesStage,
MoneyIncentivesStageStart: int(v.MoneyIncentivesTime.Unix()),
}
rules = append(rules, r)
}
contractUndertaker := []dto.ContractUndertaker{}
for _, v := range contractData.Undertakers {
ruleStage := []int{}
for _, vv := range resultDividendsEstimate.Grid.List {
if v.UserId == vv.DividendsUser.UserId {
ruleStage = append(ruleStage, vv.DividendsIncentivesStage)
}
}
temp := dto.ContractUndertaker{
UserId: v.UserId,
UsersName: v.UserName,
ContractIncentivesRules: ruleStage,
}
contractUndertaker = append(contractUndertaker, temp)
}
data := map[string]interface{}{
"contractUndertaker": contractUndertaker,
"moneyIncentivesRule": rules,
}
return data, nil
}
... ...
... ... @@ -10,37 +10,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
)
// CreditAccountCreate 创建账期结算单
func (gateway HttplibAlliedCreationCooperation) CreditAccountCreate(param ReqCreditAccountCreate) (*DataCreditAccountCreate, error) {
url := gateway.baseUrL + "/credit-accounts"
method := "POST"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:创建账期结算单。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求创建账期结算单失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取创建账期结算单失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:创建账期结算单。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析创建账期结算单:%w", err)
}
var data DataCreditAccountCreate
err = gateway.GetResponseData(result, &data)
return &data, err
}
// Credit-accountsPay 支付账期结算
func (gateway HttplibAlliedCreationCooperation) CreditAccountsPay(param ReqCreditAccountsPay) (*DataCreditAccountsPay, error) {
url := gateway.baseUrL + "/credit-accounts/pay"
... ... @@ -72,37 +41,6 @@ func (gateway HttplibAlliedCreationCooperation) CreditAccountsPay(param ReqCredi
return &data, err
}
// Credit-accounts[creditAccountId} 更新账期结算单
func (gateway HttplibAlliedCreationCooperation) CreditAccountUpdate(param ReqCreditAccountUpdate) (*DataCreditAccountUpdate, error) {
url := gateway.baseUrL + "/credit-accounts/{creditAccountId}"
method := "PUT"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:更新账期结算单。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求更新账期结算单失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取更新账期结算单失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:更新账期结算单。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析更新账期结算单:%w", err)
}
var data DataCreditAccountUpdate
err = gateway.GetResponseData(result, &data)
return &data, err
}
// Credit-accountsSearch 查询账期结算单
func (gateway HttplibAlliedCreationCooperation) CreditAccountsSearch(param ReqCreditAccountsSearch) (*DataCreditAccountsSearch, error) {
url := gateway.baseUrL + "/credit-accounts/search"
... ...
... ... @@ -9,37 +9,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
// DividendsEstimateUpdate 更新分红预算
// func (gateway HttplibAlliedCreationCooperation) DividendsEstimateUpdate(param ReqDividendsEstimateUpdate) (*DataDividendsEstimateUpdate, error) {
// url := gateway.baseUrL + "/dividends-estimates/{dividendsEstimateId}"
// method := "PUT"
// req := gateway.CreateRequest(url, method)
// log.Logger.Debug("向业务模块请求数据:更新分红预算。", map[string]interface{}{
// "api": method + ":" + url,
// "param": param,
// })
// req, err := req.JSONBody(param)
// if err != nil {
// return nil, fmt.Errorf("请求更新分红预算失败:%w", err)
// }
// byteResult, err := req.Bytes()
// if err != nil {
// return nil, fmt.Errorf("获取更新分红预算失败:%w", err)
// }
// log.Logger.Debug("获取业务模块请求数据:更新分红预算。", map[string]interface{}{
// "result": string(byteResult),
// })
// var result service_gateway.GatewayResponse
// err = json.Unmarshal(byteResult, &result)
// if err != nil {
// return nil, fmt.Errorf("解析更新分红预算:%w", err)
// }
// var data DataDividendsEstimateUpdate
// err = gateway.GetResponseData(result, &data)
// return &data, err
// }
// Dividends-estimatesSearch-dividends-incentives 查询业绩分红
func (gateway HttplibAlliedCreationCooperation) DividendsEstimateSearchDividends(param ReqDividendsEstimateSearchDividend) (*DataDividendsEstimateSearchDividend, error) {
url := gateway.baseUrL + "/dividends-estimates/search-dividends-incentives"
... ... @@ -195,157 +164,64 @@ func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesEstimateMoneys
return &data, err
}
// DividendsEstimateListDividend 返回业绩激励分红详情
func (gateway HttplibAlliedCreationCooperation) DividendsEstimateListDividend(param ReqDividendsEstimateListDividend) (*DataDividendsEstimateListDividend, error) {
url := gateway.baseUrL + "/dividends-estimates/list-dividends-incentives"
method := "GET"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:返回业绩激励分红详情。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求返回业绩激励分红详情失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取返回业绩激励分红详情失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:返回业绩激励分红详情。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析返回业绩激励分红详情:%w", err)
}
var data DataDividendsEstimateListDividend
err = gateway.GetResponseData(result, &data)
return &data, err
}
// DividendsEstimateList 返回分红预算列表
func (gateway HttplibAlliedCreationCooperation) DividendsEstimateList(param ReqDividendsEstimateList) (*DataDividendsEstimateList, error) {
url := gateway.baseUrL + "/dividends-estimates"
method := "GET"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:返回分红预算列表。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求返回分红预算列表失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取返回分红预算列表失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:返回分红预算列表。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析返回分红预算列表:%w", err)
}
var data DataDividendsEstimateList
err = gateway.GetResponseData(result, &data)
return &data, err
}
//DividendsEstimateGet 返回分红预算详情
func (gateway HttplibAlliedCreationCooperation) DividendsEstimateGet(param ReqDividendsEstimateGet) (*DataDividendsEstimateGet, error) {
url := gateway.baseUrL + "/dividends-estimates/" + strconv.Itoa(param.DividendsEstimateId)
method := "GET"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:返回分红预算详情。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求返回分红预算详情失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取返回分红预算详情失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:返回分红预算详情。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析返回分红预算详情:%w", err)
}
var data DataDividendsEstimateGet
err = gateway.GetResponseData(result, &data)
return &data, err
}
// DividendsEstimatesListMoney 返回金额激励分红列表
func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesListMoney(param ReqDividendsEstimatesListMoney) (*DataDividendsEstimatesListMoney, error) {
url := gateway.baseUrL + "/dividends-estimates/list-money-incentives"
method := "GET"
// DividendsEstimatesBatchCancel 批量取消分红预算
func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesBatchCancel(param ReqDividendsEstimateBatchCancel) (*DataDividendsEstimateBatchCancel, error) {
url := gateway.baseUrL + "/dividends-estimates/batch-cancel"
method := "POST"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:返回金额激励分红列表。", map[string]interface{}{
log.Logger.Debug("向业务模块请求数据:批量取消分红预算。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求返回金额激励分红列表失败:%w", err)
return nil, fmt.Errorf("请求批量取消分红预算失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取返回金额激励分红列表失败:%w", err)
return nil, fmt.Errorf("获取批量取消分红预算失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:返回金额激励分红列表。", map[string]interface{}{
log.Logger.Debug("获取业务模块请求数据:批量取消分红预算。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析返回金额激励分红列表:%w", err)
return nil, fmt.Errorf("解析批量取消分红预算:%w", err)
}
var data DataDividendsEstimatesListMoney
var data DataDividendsEstimateBatchCancel
err = gateway.GetResponseData(result, &data)
return &data, err
}
// DividendsEstimatesBatchCancel 批量取消分红预算
func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesBatchCancel(param ReqDividendsEstimateBatchCancel) (*DataDividendsEstimateBatchCancel, error) {
url := gateway.baseUrL + "/dividends-estimates/batch-cancel"
// DividendsEstimatesEstimateMoneys 确定业绩分红激励
func (gateway HttplibAlliedCreationCooperation) DividendsEstimateDividendsIncentives(param ReqDividendsEstimateDividendsIncentives) (*DataDividendsEstimateDividendsIncentives, error) {
url := gateway.baseUrL + "/dividends-estimates/estimate-dividends-incentives"
method := "POST"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:批量取消分红预算。", map[string]interface{}{
log.Logger.Debug("向业务模块请求数据:确定预算分红激励。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求批量取消分红预算失败:%w", err)
return nil, fmt.Errorf("请求确定预算分红激励失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取批量取消分红预算失败:%w", err)
return nil, fmt.Errorf("获取确定预算分红激励失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:批量取消分红预算。", map[string]interface{}{
log.Logger.Debug("获取业务模块请求数据:确定预算分红激励。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析批量取消分红预算:%w", err)
return nil, fmt.Errorf("解析确定预算分红激励:%w", err)
}
var data DataDividendsEstimateBatchCancel
var data DataDividendsEstimateDividendsIncentives
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
... ... @@ -200,6 +200,8 @@ type (
PageNumber int `json:"pageNumber"`
// 查询限制
PageSize int `json:"pageSize"`
CooperationContractNumber string `json:"cooperationContractNumber"` //合约编号
SponsorName string `json:"sponsorName"` //发起人名字
}
DataCooperationContractSearch struct {
... ...
... ... @@ -7,7 +7,7 @@ import (
)
type CreditAccount struct {
CreditAccountId int64 `json:"creditAccountId,string"` // 账期结算单ID
CreditAccountId int `json:"creditAccountId,string,"` // 账期结算单ID
ActuallyPaidAmount float64 `json:"actuallyPaidAmount"` // 账期结算实付金额
CreditAccountOrderNum string `json:"creditAccountOrderNum"` // 账期结算单号
PaymentStatus int `json:"paymentStatus"` // 账期结算支付状态,1待支付,2已支付
... ... @@ -15,46 +15,35 @@ type CreditAccount struct {
SettlementAmount float64 `json:"settlementAmount"` // 账期结算金额
SettlementTime time.Time `json:"settlementTime"` // 共创账期结算时间
CooperationContractNumber string `json:"cooperationContractNumber"` // 关联共创合约编号
// 参与人uid,包括承接人、推荐人、关联业务员
Participator struct {
UserId int64 `json:"userId,string"` // 用户ID,
UserBaseId int64 `json:"userBaseId,string"` // 用户基本id
Org domain.Org `json:"org"` // 用户所属的组织机构
Department domain.Department `json:"department"` // 用户所属的部门
UserId int `json:"userId,string,"` // 用户ID,
UserBaseId int `json:"userBaseId,string,"` // 用户基本id
// Org domain.Org `json:"org"` // 用户所属的组织机构
// Department domain.Department `json:"department"` // 用户所属的部门
UserInfo domain.UserInfo `json:"userInfo"` //
UserName string `json:"userName"` // 用户姓名
UserPhone string `json:"userPhone"` // 用户手机号
UserType int32 `json:"userType"` // 用户类型,1员工,2共创用户,3公开
Status int32 `json:"status"` // 状态
} `json:"participator"`
// 参与类型
ParticipateType string `json:"participateType"`
// 支付凭证附件
PaymentDocumentAttachment domain.Attachment `json:"paymentDocumentAttachment"`
// 数据所属组织机构
Org domain.Org `json:"org"`
// 公司
Company domain.CompanyData `json:"company"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt"`
UserType int `json:"userType"` // 用户类型,1员工,2共创用户,3公开
Status int `json:"status"` // 状态
} `json:"participator"` // 参与人
ParticipateType string `json:"participateType"` // 参与类型
PaymentDocumentAttachment domain.Attachment `json:"paymentDocumentAttachment"` // 支付凭证附件
Org domain.Org `json:"org"` // 数据所属组织机构
Company domain.CompanyData `json:"company"` // 公司
CreatedAt time.Time `json:"createdAt"` // 创建时间
UpdatedAt time.Time `json:"updatedAt"` // 更新时间
AccountDetail []struct {
DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"`
DividendsType string `json:"dividendsType"`
DividendsAmount float64 `json:"dividendsAmount"`
} `json:"accountDetail"` //结算明细
}
//创建账期结算单
type (
ReqCreditAccountCreate struct {
}
DataCreditAccountCreate struct {
}
)
//支付账期结算
type (
ReqCreditAccountsPay struct {
CreditAccountId int `json:"creditAccountId"`
ActuallyPaidAmount float64 `json:"actuallyPaidAmount"`
ActuallyPaidAmount float64 `json:"actuallyPaidAmount"` //实际支付金额
Remarks string `json:"remarks"`
Attachment domain.Attachment `json:"attachment"` //附件
}
... ... @@ -63,15 +52,6 @@ type (
}
)
//更新账期结算单
type (
ReqCreditAccountUpdate struct {
}
DataCreditAccountUpdate struct {
}
)
//查询账期结算单
type (
ReqCreditAccountsSearch struct {
... ...
... ... @@ -7,16 +7,25 @@ type (
ReqDividendsEstimateSearchDividend struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
//合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
//分红订单号/退货单号
OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"`
CooperationContractNumber string `json:"cooperationContractNumber"` //合约编号
OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"` //分红订单号/退货单号
}
DataDividendsEstimateSearchDividend struct {
Grid struct {
Total int `json:"total"`
List []struct{} `json:"list"`
List []struct {
CooperationContractNumber string `json:"cooperationContractNumber"` //共创合约编号
CustomerName string `json:"customerName"` //客户名称
DividendsIncentivesAmount int `json:"dividendsIncentivesAmount"` //业绩激励分红金额
OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"` //分红订单号或退货单号
OrderTime time.Time `json:"orderTime"` //订单/退货单日期
OriginalOrderNum string `json:"originalOrderNum"` //来源单号,源单号,订单号
Region struct {
RegionName string `json:"regionName"` //区域名称
RegionNumber string `json:"regionNumber"` //区域编码
} `json:"region"`
} `json:"list"`
} `json:"grid"`
}
)
... ... @@ -26,6 +35,7 @@ type (
ReqDividendsEstimateSearch struct {
//承接人分红预算单号
DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"`
CooperationContractNumber string `json:"orderOrReturnedOrderNum"` //合约编号
//分红类型,1订单分红,2退货冲销,3金额激励
DividendsType int `json:"dividendsType"`
PageNumber int `json:"pageNumber"`
... ... @@ -45,6 +55,7 @@ type (
DividendsType int `json:"dividendsType"` // 分红类型,1订单分红,2退货冲销,3金额激励
OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"` // 分红订单号或退货单号
CooperationProjectNumber string `json:"cooperationProjectNumber"` // 共创项目编号,
DividendsIncentivesStage int `json:"DividendsIncentivesStage"` //分红阶段
DividendsUser struct {
UserId int `json:"userId,string,"` // 用户ID,
UserBaseId int `json:"userBaseId,string,"` // 用户基本id
... ... @@ -83,6 +94,7 @@ type (
List []struct {
CooperationContractName string `json:"cooperationContractName"` //合约名称
CooperationContractNumber string `json:"cooperationContractNumber"` //合约编码
DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"` //订单编号
CooperationMode struct {
CooperationModeId int `json:"cooperationModeId"`
CooperationModeName string `json:"cooperationModeName"`
... ... @@ -95,10 +107,11 @@ type (
} `json:"department"` //发起部门
CooperationContractSponsor struct {
UserId int `json:"userId"`
UserBaseId int `json:"userBaseId"`
UserInfo struct {
UsersName string `json:"userName"`
Phone string `json:"phone"`
UsersId int `json:"userId,string"`
UsersId int `json:"userId,string,"`
UserCode string `json:"userCode"`
} `json:"userInfo"`
} `json:"cooperationContractSponsor"` //合约发起人
... ... @@ -121,36 +134,15 @@ type (
type (
ReqDividendsEstimateMoneyIncentives struct {
//合约编码
CooperationContractNumber string
//
CooperationContractNumber string `json:"cooperationContractNumber"`
DividendsIncentivesStage int `json:"dividendsIncentivesStage"`
UndertakerUid string `json:"undertakerUid"`
}
DataDividendsEstimateMoneyIncentives struct {
}
)
//返回业绩激励分红详情
type (
ReqDividendsEstimateListDividend struct {
}
DataDividendsEstimateListDividend struct {
}
)
//返回分红预算列表
type (
ReqDividendsEstimateList struct {
}
DataDividendsEstimateList struct {
Grid struct {
Total int
List []struct{}
}
}
)
//返回分红预算详情
type (
ReqDividendsEstimateGet struct {
... ... @@ -186,25 +178,24 @@ type (
}
)
//返回金额激励分红列表
//批量取消分红预算
type (
ReqDividendsEstimatesListMoney struct {
ReqDividendsEstimateBatchCancel struct {
DividendsEstimateIds []string `json:"dividendsEstimateIds"`
}
DataDividendsEstimatesListMoney struct {
Grid struct {
Total int `json:"total"`
List []struct{} `json:"list"`
} `json:"grid"`
DataDividendsEstimateBatchCancel struct {
}
)
//取消分红预算
// DividendsEstimateDividendsIncentives
//确定业绩分红激励
type (
ReqDividendsEstimateBatchCancel struct {
DividendsEstimateIds []string `json:"dividendsEstimateIds"`
ReqDividendsEstimateDividendsIncentives struct {
CooperationContractNumber string `json:"cooperationContractNumber"`
OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"`
}
DataDividendsEstimateBatchCancel struct {
DataDividendsEstimateDividendsIncentives struct {
}
)
... ...
... ... @@ -46,8 +46,8 @@ func (controller *DividendsEstimateController) SearchDividendsIncentives() {
log.Logger.Debug("json err:" + err.Error())
}
searchDividendsIncentivesQuery.Operator = controller.GetOperator()
data, err := dividendsEstimateService.SearchDividendsIncentives(searchDividendsIncentivesQuery)
controller.Response(data, err)
cnt, data, err := dividendsEstimateService.SearchDividendsIncentives(searchDividendsIncentivesQuery)
controller.ReturnPageListData(int64(cnt), data, err, searchDividendsIncentivesQuery.PageNumber)
}
//SearchMoneyIncentives 查询金额激励分红
... ... @@ -59,8 +59,8 @@ func (controller *DividendsEstimateController) SearchMoneyIncentives() {
log.Logger.Debug("json err:" + err.Error())
}
searchMoneyIncentivesQuery.Operator = controller.GetOperator()
data, err := dividendsEstimateService.SearchMoneyIncentives(searchMoneyIncentivesQuery)
controller.Response(data, err)
cnt, data, err := dividendsEstimateService.SearchMoneyIncentives(searchMoneyIncentivesQuery)
controller.ReturnPageListData(int64(cnt), data, err, searchMoneyIncentivesQuery.PageNumber)
}
//EstimateMoneyIncentives 确定预算金额激励分红
... ...