审查视图

pkg/infrastructure/service_gateway/allied_creation_cooperation/module_dividends_estimate.go 8.6 KB
1 2 3 4
package allied_creation_cooperation

import (
	"fmt"
yangfu authored
5
	"github.com/linmadan/egglib-go/utils/json"
6 7 8 9 10 11 12
	"strconv"

	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)

// Dividends-estimatesSearch-dividends-incentives 查询业绩分红
13
func (gateway HttplibAlliedCreationCooperation) DividendsEstimateSearchDividends(param ReqDividendsEstimateSearchDividend) (*DataDividendsEstimateSearchDividend, error) {
14 15 16
	url := gateway.baseUrL + "/dividends-estimates/search-dividends-incentives"
	method := "POST"
	req := gateway.CreateRequest(url, method)
tangxuhui authored
17
	log.Logger.Debug("向业务模块请求数据:查询业绩分红。", map[string]interface{}{
18 19 20 21 22 23 24 25 26 27 28 29
		"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)
	}
tangxuhui authored
30
	log.Logger.Debug("获取业务模块请求数据:查询业绩分红。", map[string]interface{}{
31 32 33 34 35 36 37 38 39 40 41 42 43
		"result": string(byteResult),
	})
	var result service_gateway.GatewayResponse
	err = json.Unmarshal(byteResult, &result)
	if err != nil {
		return nil, fmt.Errorf("解析查询业绩分红:%w", err)
	}
	var data DataDividendsEstimateSearchDividend
	err = gateway.GetResponseData(result, &data)
	return &data, err
}

// DividendsEstimatesSearch查询分红预算单
44
func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesSearch(param ReqDividendsEstimateSearch) (*DataDividendsEstimateSearch, error) {
45 46 47
	url := gateway.baseUrL + "/dividends-estimates/search"
	method := "POST"
	req := gateway.CreateRequest(url, method)
tangxuhui authored
48
	log.Logger.Debug("向业务模块请求数据:查询分红预算单。", map[string]interface{}{
49 50 51 52 53 54 55 56 57 58 59 60
		"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)
	}
tangxuhui authored
61
	log.Logger.Debug("获取业务模块请求数据:查询分红预算单。", map[string]interface{}{
62 63 64 65 66 67 68
		"result": string(byteResult),
	})
	var result service_gateway.GatewayResponse
	err = json.Unmarshal(byteResult, &result)
	if err != nil {
		return nil, fmt.Errorf("解析查询分红预算单:%w", err)
	}
69
	var data DataDividendsEstimateSearch
70 71 72 73 74 75 76 77 78
	err = gateway.GetResponseData(result, &data)
	return &data, err
}

// DividendsEstimatesSearchMoney 查询金额激励分红
func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesSearchMoney(param ReqDividendsEstimateSearchMoney) (*DataDividendsEstimateSearchMoney, error) {
	url := gateway.baseUrL + "/dividends-estimates/search-money-incentives"
	method := "POST"
	req := gateway.CreateRequest(url, method)
tangxuhui authored
79
	log.Logger.Debug("向业务模块请求数据:查询金额激励分红。", map[string]interface{}{
80 81 82 83 84 85 86 87 88 89 90 91
		"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)
	}
tangxuhui authored
92
	log.Logger.Debug("获取业务模块请求数据:查询金额激励分红。", map[string]interface{}{
93 94 95 96 97 98 99 100 101 102 103 104 105
		"result": string(byteResult),
	})
	var result service_gateway.GatewayResponse
	err = json.Unmarshal(byteResult, &result)
	if err != nil {
		return nil, fmt.Errorf("解析查询金额激励分红:%w", err)
	}
	var data DataDividendsEstimateSearchMoney
	err = gateway.GetResponseData(result, &data)
	return &data, err
}

// Dividends-estimates[dividendsEstimateId}Cancel 取消分红预算
106 107
func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesCancel(param ReqDividendsEstimateCancel) (*DataDividendsEstimateCancel, error) {
	url := gateway.baseUrL + "/dividends-estimates/" + strconv.Itoa(param.DividendsEstimateId) + "/cancel"
108 109
	method := "POST"
	req := gateway.CreateRequest(url, method)
tangxuhui authored
110
	log.Logger.Debug("向业务模块请求数据:取消分红预算。", map[string]interface{}{
111 112 113 114 115 116 117 118 119 120 121 122
		"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)
	}
tangxuhui authored
123
	log.Logger.Debug("获取业务模块请求数据:取消分红预算。", map[string]interface{}{
124 125 126 127 128 129 130
		"result": string(byteResult),
	})
	var result service_gateway.GatewayResponse
	err = json.Unmarshal(byteResult, &result)
	if err != nil {
		return nil, fmt.Errorf("解析取消分红预算:%w", err)
	}
131
	var data DataDividendsEstimateCancel
132 133 134 135
	err = gateway.GetResponseData(result, &data)
	return &data, err
}
136
// DividendsEstimatesEstimateMoneys 确定预算金额激励分红
tangxuhui authored
137
func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesEstimateMoneys(param ReqDividendsEstimateMoneyIncentives) (DataDividendsEstimateMoneyIncentives, error) {
138 139 140
	url := gateway.baseUrL + "/dividends-estimates/estimate-money-incentives"
	method := "POST"
	req := gateway.CreateRequest(url, method)
tangxuhui authored
141
	log.Logger.Debug("向业务模块请求数据:确定预算金额激励分红。", map[string]interface{}{
142 143 144 145 146 147 148 149 150 151 152 153
		"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)
	}
tangxuhui authored
154
	log.Logger.Debug("获取业务模块请求数据:确定预算金额激励分红。", map[string]interface{}{
155 156 157 158 159 160 161
		"result": string(byteResult),
	})
	var result service_gateway.GatewayResponse
	err = json.Unmarshal(byteResult, &result)
	if err != nil {
		return nil, fmt.Errorf("解析确定预算金额激励分红:%w", err)
	}
162
	var data DataDividendsEstimateMoneyIncentives
163
	err = gateway.GetResponseData(result, &data)
tangxuhui authored
164
	return data, err
165 166
}
tangxuhui authored
167 168 169 170
// DividendsEstimatesBatchCancel 批量取消分红预算
func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesBatchCancel(param ReqDividendsEstimateBatchCancel) (*DataDividendsEstimateBatchCancel, error) {
	url := gateway.baseUrL + "/dividends-estimates/batch-cancel"
	method := "POST"
171
	req := gateway.CreateRequest(url, method)
tangxuhui authored
172
	log.Logger.Debug("向业务模块请求数据:批量取消分红预算。", map[string]interface{}{
173 174 175 176 177
		"api":   method + ":" + url,
		"param": param,
	})
	req, err := req.JSONBody(param)
	if err != nil {
tangxuhui authored
178
		return nil, fmt.Errorf("请求批量取消分红预算失败:%w", err)
179 180 181 182
	}

	byteResult, err := req.Bytes()
	if err != nil {
tangxuhui authored
183
		return nil, fmt.Errorf("获取批量取消分红预算失败:%w", err)
184
	}
tangxuhui authored
185
	log.Logger.Debug("获取业务模块请求数据:批量取消分红预算。", map[string]interface{}{
186 187 188 189 190
		"result": string(byteResult),
	})
	var result service_gateway.GatewayResponse
	err = json.Unmarshal(byteResult, &result)
	if err != nil {
tangxuhui authored
191
		return nil, fmt.Errorf("解析批量取消分红预算:%w", err)
192
	}
tangxuhui authored
193
	var data DataDividendsEstimateBatchCancel
194 195 196
	err = gateway.GetResponseData(result, &data)
	return &data, err
}
tangxuhui authored
197
tangxuhui authored
198 199 200
// DividendsEstimatesEstimateMoneys 确定业绩分红激励
func (gateway HttplibAlliedCreationCooperation) DividendsEstimateDividendsIncentives(param ReqDividendsEstimateDividendsIncentives) (*DataDividendsEstimateDividendsIncentives, error) {
	url := gateway.baseUrL + "/dividends-estimates/estimate-dividends-incentives"
tangxuhui authored
201 202
	method := "POST"
	req := gateway.CreateRequest(url, method)
tangxuhui authored
203
	log.Logger.Debug("向业务模块请求数据:确定预算分红激励。", map[string]interface{}{
tangxuhui authored
204 205 206 207 208
		"api":   method + ":" + url,
		"param": param,
	})
	req, err := req.JSONBody(param)
	if err != nil {
tangxuhui authored
209
		return nil, fmt.Errorf("请求确定预算分红激励失败:%w", err)
tangxuhui authored
210 211 212 213
	}

	byteResult, err := req.Bytes()
	if err != nil {
tangxuhui authored
214
		return nil, fmt.Errorf("获取确定预算分红激励失败:%w", err)
tangxuhui authored
215
	}
tangxuhui authored
216
	log.Logger.Debug("获取业务模块请求数据:确定预算分红激励。", map[string]interface{}{
tangxuhui authored
217 218 219 220
		"result": string(byteResult),
	})
	var result service_gateway.GatewayResponse
	err = json.Unmarshal(byteResult, &result)
tangxuhui authored
221
	log.Logger.Debug("获取业务模块请求数据:确定预算分红激励+++++" + string(byteResult))
tangxuhui authored
222
	if err != nil {
tangxuhui authored
223
		return nil, fmt.Errorf("解析确定预算分红激励:%w", err)
tangxuhui authored
224
	}
tangxuhui authored
225
	var data DataDividendsEstimateDividendsIncentives
tangxuhui authored
226 227 228
	err = gateway.GetResponseData(result, &data)
	return &data, err
}