module_excel_data.go 3.4 KB
package allied_creation_cooperation

import (
	"encoding/json"
	"fmt"
	"time"

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

//ReqImportDividendsReturnedOrder 导入退货数据
type (
	ImportDividendsReturnedOrderGood struct {
		OrderGoodAmount           float64 `json:"orderGoodAmount"`           // 订单产品金额
		OrderGoodName             string  `json:"orderGoodName"`             // 订单产品名称
		OrderGoodPrice            float64 `json:"orderGoodPrice"`            // 订单产品单价
		OrderGoodQuantity         int64   `json:"orderGoodQuantity"`         // 订单产品数量
		DividendsOrderNumber      int64   `json:"dividendsOrderNumber"`      // 关联分红订单号
		CooperationContractNumber string  `json:"cooperationContractNumber"` // 关联的共创合约编号
		OrderGoodExpense          float64 `json:"orderGoodExpense"`          // 订单产品费用
	}
	ImportDividendsReturnedOrderData struct {
		DividendsReturnedOrderRefund  float64                             `json:"dividendsReturnedOrderRefund"`  // 退货金额
		DividendsReturnedCustomerName string                              `json:"dividendsReturnedCustomerName"` //退货客户名称
		OriginalOrderNum              string                              `json:"originalOrderNum"`              // 来源单号,源单号,订单号
		DividendsReturnedDate         time.Time                           `json:"dividendsReturnedDate"`         //退货日期
		RegionName                    string                              `json:"regionName"`                    // 退货区域名称
		OrderGoods                    []*ImportDividendsReturnedOrderGood `json:"orderGoods"`                    // 订单产品列表
		Remarks                       string                              `json:"remarks"`                       // 备注
	}
	//请求参数
	ReqImportDividendsReturnedOrder struct {
		// 分红退货单数据
		DividendsReturnedOrderData []ImportDividendsReturnedOrderData `json:"dividendsReturnedOrderData"` //分红退货单数据列表
	}
	//响应参数
	DataImportDividendsReturnedOrder struct {
	}
)

// ImportDividendsReturnedOrder 导入退货数据
func (gateway HttplibAlliedCreationCooperation) ImportDividendsReturnedOrder(param ReqDividendsEstimateSearchDividend) (*DataDividendsEstimateSearchDividend, error) {
	url := gateway.baseUrL + "/dividends-returned-orders/import"
	method := "POST"
	req := gateway.CreateRequest(url, method)
	// oneDemo
	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 DataDividendsEstimateSearchDividend
	err = gateway.GetResponseData(result, &data)
	return &data, err
}