package couponrpc
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
)
|
|
|
|
func GetCouponInfo(dbname,couponId string, url ...string) (string, error) {
|
|
|
|
if dbname == "" {
|
|
return "", errors.New("参数错误")
|
|
}
|
|
|
|
conn, err := rpc_server_conn(url...)
|
|
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
defer conn.Close()
|
|
|
|
arg := map[string]string{
|
|
"dbname": dbname,
|
|
"coupon_id": couponId,
|
|
}
|
|
|
|
req, err := SetReqData(arg)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
res := &CouponResponse{}
|
|
|
|
err = conn.GetCouponInfo(req, res)
|
|
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
res_data_de, err := GetResData(res)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
var bankCode string
|
|
err = json.Unmarshal([]byte(res_data_de),&bankCode)
|
|
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
if res_data_de == "" {
|
|
return "", nil
|
|
}
|
|
|
|
return bankCode, nil
|
|
}
|