Browse Source

增加售后模块

master
lijianbin 3 years ago
parent
commit
dc698fe8a4
3 changed files with 189 additions and 1 deletions
  1. +173
    -0
      client.createorder.go
  2. +12
    -1
      client.createorder_test.go
  3. +4
    -0
      order.proto

+ 173
- 0
client.createorder.go View File

@ -61,3 +61,176 @@ func CreateOrder(dbname, siteid, order_sn string, url ...string) (bool, error) {
return return_res, nil
}
// 确认收货
func ConfirmReceive(dbname, siteid, supplier_order_sn string, url ...string) (bool, error) {
if dbname == "" || siteid == "" || supplier_order_sn == "" {
return false, errors.New("参数错误")
}
conn, err := rpc_server_conn(url...)
if err != nil {
return false, err
}
defer conn.Close()
data := map[string]string{}
data["database"] = dbname
data["site_id"] = siteid
data["supplier_order_sn"] = supplier_order_sn
req, err := SetReqData(data)
if err != nil {
log.Println("confirmReceive crypter error:", err)
return false, err
}
res := &Response{}
err = conn.ConfirmReceive(req, res)
if err != nil {
log.Println("yytrpc confirmReceive error:", err)
return false, err
}
res_data_de, err := GetResData(res)
if err != nil {
return false, err
}
if res_data_de == "" {
return false, nil
}
var return_res bool
err = json.Unmarshal([]byte(res_data_de), &return_res)
if err != nil {
return false, err
}
return return_res, nil
}
// 申请售后
func ApplyRefund(dbname, siteid, supplier_order_sn, refund_type, refund_reason string, url ...string) (bool, error) {
if dbname == "" || siteid == "" || supplier_order_sn == "" || refund_type == "" || refund_reason == "" {
return false, errors.New("参数错误")
}
conn, err := rpc_server_conn(url...)
if err != nil {
return false, err
}
defer conn.Close()
data := map[string]string{}
data["database"] = dbname
data["site_id"] = siteid
data["supplier_order_sn"] = supplier_order_sn
data["refund_type"] = refund_type
data["refund_reason"] = refund_reason
req, err := SetReqData(data)
if err != nil {
log.Println("ApplyRefund crypter error:", err)
return false, err
}
res := &Response{}
err = conn.ApplyRefund(req, res)
if err != nil {
log.Println("yytrpc ApplyRefund error:", err)
return false, err
}
res_data_de, err := GetResData(res)
if err != nil {
return false, err
}
if res_data_de == "" {
return false, nil
}
var return_res bool
err = json.Unmarshal([]byte(res_data_de), &return_res)
if err != nil {
return false, err
}
return return_res, nil
}
// 撤销售后
func CancelRefund(dbname, siteid, supplier_refund_sn, supplier_buyer_id string, url ...string) (bool, error) {
if dbname == "" || siteid == "" || supplier_refund_sn == "" || supplier_buyer_id == "" {
return false, errors.New("参数错误")
}
conn, err := rpc_server_conn(url...)
if err != nil {
return false, err
}
defer conn.Close()
data := map[string]string{}
data["database"] = dbname
data["site_id"] = siteid
data["supplier_refund_sn"] = supplier_refund_sn
data["supplier_buyer_id"] = supplier_buyer_id
req, err := SetReqData(data)
if err != nil {
log.Println("CancelRefund crypter error:", err)
return false, err
}
res := &Response{}
err = conn.CancelRefund(req, res)
if err != nil {
log.Println("yytrpc CancelRefund error:", err)
return false, err
}
res_data_de, err := GetResData(res)
if err != nil {
return false, err
}
if res_data_de == "" {
return false, nil
}
var return_res bool
err = json.Unmarshal([]byte(res_data_de), &return_res)
if err != nil {
return false, err
}
return return_res, nil
}

+ 12
- 1
client.createorder_test.go View File

@ -7,7 +7,18 @@ import (
func Test_CreateOrder(t *testing.T) {
dbname := "shop"
siteid := "1198881"
order_sn := "1638859609193467246"
order_sn := "1639708334549937512"
list, err := CreateOrder(dbname,siteid,order_sn)
t.Log(list)
t.Log(err)
}
func Test_ConfirmReceive(t *testing.T) {
dbname := "shop"
siteid := "1198881"
order_sn := "1639708334549937512"
list, err := CreateOrder(dbname,siteid,order_sn)


+ 4
- 0
order.proto View File

@ -20,4 +20,8 @@ message Response {
// rpc方法
service OrderService {
rpc CreateOrder (Request) returns (Response); //
rpc ConfirmReceive (Request) returns (Response); //
rpc ApplyRefund (Request) returns (Response); //
rpc CancelRefund (Request) returns (Response); //
rpc SendReturnGoods (Request) returns (Response); //
}

Loading…
Cancel
Save