优惠券rpc数据结构及方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
831 B

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