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

41 lines
1001 B
Go
Raw Normal View History

2024-07-09 17:07:22 +08:00
package do
import (
"encoding/json"
"strconv"
"trasfer_middleware/cmd/rpc/internal/logic/vo"
"trasfer_middleware/genModel"
)
func MarketKeyDataSet(order *genModel.ServerOrderMarket, resq string, resp string) (err error) {
var (
orderInfoReq map[string]interface{}
orderInfoRes map[string]interface{}
)
err = json.Unmarshal([]byte(resp), &orderInfoRes)
2024-10-15 18:35:45 +08:00
if _, ok := orderInfoRes["errCode"]; !ok {
return nil
}
2024-07-16 16:57:26 +08:00
if orderInfoRes["errCode"].(string) != vo.MARKET_SUCCESS {
2024-07-09 17:07:22 +08:00
return err
}
2024-07-16 16:57:26 +08:00
err = json.Unmarshal([]byte(resq), &orderInfoReq)
2024-07-09 17:07:22 +08:00
if err != nil {
return err
}
order.Num, err = strconv.ParseInt(orderInfoReq["voucher_num"].(string), 16, 64)
if err != nil {
return err
}
2024-07-16 16:57:26 +08:00
order.ProductId = orderInfoReq["voucher_id"].(string)
2024-07-09 17:07:22 +08:00
if err != nil {
return err
}
order.VoucherNum = orderInfoReq["mem_id"].(string)
order.OutBizNo = orderInfoReq["req_serial_no"].(string)
2024-07-16 16:57:26 +08:00
order.OrderNum = orderInfoRes["data"].(map[string]interface{})["voucher_code"].(string)
2024-07-09 17:07:22 +08:00
return nil
}