transfer_middleware/cmd/rpc/internal/logic/do/physical.go

43 lines
1018 B
Go
Raw Normal View History

2024-11-06 17:35:59 +08:00
package do
import (
"encoding/json"
"trasfer_middleware/cmd/rpc/internal/logic/vo"
"trasfer_middleware/cmd/rpc/pb/transfer"
"trasfer_middleware/genModel"
)
type PhysicalRes struct {
Code float64 `json:"code"`
Data map[string]interface{} `json:"data"`
Message string `json:"message"`
}
func PhysicalDataSet(order *genModel.ServerOrderPhysical, resq string, resp string) (err error) {
var (
orderInfoReq *transfer.PhysicalOrderSubReq
orderInfoRes PhysicalRes
)
err = json.Unmarshal([]byte(resp), &orderInfoRes)
if orderInfoRes.Code != vo.PHYSICAL_SUCCESS {
return err
}
err = json.Unmarshal([]byte(resq), &orderInfoReq)
if err != nil {
return err
}
order.CustomerOrderNum = orderInfoReq.OrderBasic.CustomerOrderNum
if err != nil {
return err
}
order.AppId = orderInfoReq.AppId
if err != nil {
return err
}
order.CustomerOrderNum = orderInfoReq.OrderBasic.CustomerOrderNum
order.OrderNum = orderInfoRes.Data["order_num"].(string)
return nil
}