作者 tangxuhui

添加 确定分红 操作

package command
import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
type ConfimDividendsEstimateCommand struct {
//操作人
Operator domain.Operator `json:"-"`
DividendsEstimateId []string `json:"dividendsEstimateId"`
}
... ...
... ... @@ -172,3 +172,15 @@ func (dividendsEmmateService *DividendsEstimateService) MoneyIncentivesSelector(
}
return data, nil
}
//ConfimDividendsEstimate 确定分红预算
func (dividendsEstimateService *DividendsEstimateService) ConfimDividendsEstimate(confimDividendsEstimateCommand *command.ConfimDividendsEstimateCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(confimDividendsEstimateCommand.Operator)
_, err := creationCooperationGateway.CreditAccountsAdd(allied_creation_cooperation.ReqCreditAccountsAdd{
DividendsEstimateIds: confimDividendsEstimateCommand.DividendsEstimateId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return confimDividendsEstimateCommand, nil
}
... ...
... ... @@ -164,3 +164,34 @@ func (gateway HttplibAlliedCreationCooperation) CreditAccountGet(param ReqCredit
err = gateway.GetResponseData(result, &data)
return &data, err
}
// CreditAccountsAdd 创建账期结算
func (gateway HttplibAlliedCreationCooperation) CreditAccountsAdd(param ReqCreditAccountsAdd) (*DataCreditAccountsAdd, 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 DataCreditAccountsAdd
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
... ... @@ -106,3 +106,13 @@ type (
CreditAccount
}
)
//创建账期结算
type (
ReqCreditAccountsAdd struct {
DividendsEstimateIds []string `json:"dividendsEstimateIdss"`
}
DataCreditAccountsAdd []struct {
}
)
... ...
... ... @@ -101,3 +101,16 @@ func (controller *DividendsEstimateController) MoneyIncentivesSelector() {
data, err := dividendsEstimateService.MoneyIncentivesSelector(moneyIncentivesSelectorQuery)
controller.Response(data, err)
}
//ConfimDividendsEstimate 确定分红预算
func (controller *DividendsEstimateController) ConfimDividendsEstimate() {
dividendsEstimateService := service.NewDividendsEstimateService(nil)
confimDividendsEstimateCommand := &command.ConfimDividendsEstimateCommand{}
err := controller.Unmarshal(confimDividendsEstimateCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
confimDividendsEstimateCommand.Operator = controller.GetOperator()
data, err := dividendsEstimateService.ConfimDividendsEstimate(confimDividendsEstimateCommand)
controller.Response(data, err)
}
... ...
... ... @@ -13,4 +13,6 @@ func init() {
web.Router("/v1/web/dividends-estimate/money-incentives/estimate", &web_client.DividendsEstimateController{}, "Post:EstimateMoneyIncentives")
web.Router("/v1/web/dividends-estimate/dividends-incentives/estimate", &web_client.DividendsEstimateController{}, "Post:EstimateDividendsIncentives")
web.Router("/v1/web/dividends-estimate/money-incentives/selector", &web_client.DividendsEstimateController{}, "Post:MoneyIncentivesSelector")
web.Router("/v1/web/dividends-estimate/confim", &web_client.DividendsEstimateController{}, "Post:ConfimDividendsEstimate")
}
... ...