|
|
package allied_creation_cooperation
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"strconv"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
|
|
|
)
|
|
|
|
|
|
//DividendsReturnedOrderAdd 创建分红退货单
|
|
|
func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderAdd(param ReqDividendsReturnedOrderAdd) (*DataDividendsReturnedOrderAdd, error) {
|
|
|
url := gateway.baseUrL + "/dividends-returned-orders"
|
|
|
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 DataDividendsReturnedOrderAdd
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
// DividendsReturnedOrderUpdate 更新分红退货单
|
|
|
func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderUpdate(param ReqDividendsReturnedOrderUpdate) (
|
|
|
*DataDividendsReturnedOrderUpdate, error) {
|
|
|
url := gateway.baseUrL + "/dividends-returned-orders/" + strconv.Itoa(param.DividendsReturnedOrderID)
|
|
|
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 DataDividendsReturnedOrderUpdate
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
// DividendsReturnedOrderSearch 查找分红退货单
|
|
|
func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderSearch(param ReqDividendsReturnedOrderSearch) (*DataDividendsReturnedOrderSearch, error) {
|
|
|
url := gateway.baseUrL + "/dividends-returned-orders/search"
|
|
|
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 DataDividendsReturnedOrderSearch
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
// DividendsReturnedOrderRemove 移除分红退货单
|
|
|
func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderRemove(param ReqDividendsReturnedOrderRemove) (
|
|
|
*DataDividendsReturnedOrderRemove, error) {
|
|
|
url := gateway.baseUrL + "/dividends-returned-orders/" + strconv.Itoa(param.DividendsReturnedOrderID)
|
|
|
method := "DELETE"
|
|
|
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 DataDividendsReturnedOrderRemove
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
// DividendsReturnedOrders 返回分红退货单列表
|
|
|
func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderList(param ReqDividendsReturnedOrderList) (*DataDividendsReturnedOrderList, error) {
|
|
|
url := gateway.baseUrL + "/dividends-returned-orders"
|
|
|
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 DataDividendsReturnedOrderList
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
// DividendsReturnedOrderGet 返回分红退货单详情
|
|
|
func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderGet(param ReqDividendsReturnedOrderGet) (*DataDividendsReturnedOrderGet, error) {
|
|
|
url := gateway.baseUrL + "/dividends-returned-orders" + strconv.Itoa(param.DividendsReturnedOrderId)
|
|
|
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 DataDividendsReturnedOrderGet
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
} |
...
|
...
|
|