| 
						
					 | 
				
			
			 | 
			 | 
			
				@ -10,13 +10,13 @@ import (
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					"git.selly.red/Selly-Modules/3pl/util/pjson"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				func New(degestKey, companyID string, isProd, debug bool) *Client {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				func New(digestKey, companyID string, isProd, debug bool) *Client {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					host := apiHostDev
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if isProd {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						host = apiHostProd
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					c := &Client{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						DigestKey:    degestKey,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						DigestKey:    digestKey,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						EccompanyID:  companyID,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						IsProduction: isProd,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Debug:        debug,
 | 
			
		
		
	
	
		
			
				
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@ -35,71 +35,79 @@ type Client struct {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					httpClient   *resty.Client
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				func (c *Client) EstimateFee(req *EstimateFeeReq) (*EstimateFeeItemRes, error) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				func (c *Client) EstimateFee(req *EstimateFeeReq) (r Response) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					path := c.host + apiPathEstimateFee
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					data := pjson.ToJSONString(req)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					body := map[string]string{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						"logistics_interface": data,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						"data_digest":         c.getDigest(data),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						"msg_type":            msgTypeEstimateFee,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						"eccompanyid":         c.EccompanyID,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					r.Request.Body = pjson.ToBytes(body)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					r.Request.URL = path
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					resp, err := c.httpClient.R().
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						SetFormData(map[string]string{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							"logistics_interface": data,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							"data_digest":         c.getDigest(data),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							"msg_type":            msgTypeEstimateFee,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							"eccompanyid":         c.EccompanyID,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}).
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						SetResult(&EstimateFeeRes{}).
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						SetFormData(body).
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Post(path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if err != nil {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return nil, fmt.Errorf("jtepxress: request %s, err %v", path, err)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						r.Error = fmt.Errorf("jtepxress: request %s, err %v", path, err)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return r
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					res := resp.Result().(*EstimateFeeRes)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if len(res.ResponseItems) == 0 {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return nil, fmt.Errorf("jtepxress: estimate fee empty response")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					return res.ResponseItems[0], nil
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					r.Response.StatusCode = resp.StatusCode()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					r.Response.Body = resp.Body()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					return r
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				func (c *Client) CancelOrder(req *CancelOrderReq) (*CancelOrderRes, error) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				func (c *Client) CancelOrder(req *CancelOrderReq) (r Response) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					path := c.host + apiPathCancelOrder
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					data := pjson.ToJSONString(req)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					body := map[string]string{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						"logistics_interface": data,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						"data_digest":         c.getDigest(data),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						"msg_type":            msgTypeEstimateFee,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						"eccompanyid":         c.EccompanyID,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					r.Request.Body = pjson.ToBytes(body)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					r.Request.URL = path
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					resp, err := c.httpClient.R().
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						SetFormData(map[string]string{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							"logistics_interface": data,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							"data_digest":         c.getDigest(data),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							"msg_type":            msgTypeEstimateFee,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							"eccompanyid":         c.EccompanyID,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}).
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						SetResult(&CancelOrderRes{}).
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						SetFormData(body).
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Post(path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if err != nil {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return nil, fmt.Errorf("jtepxress: request %s, err %v", path, err)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						r.Error = fmt.Errorf("jtepxress: request %s, err %v", path, err)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return r
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					res := resp.Result().(*CancelOrderRes)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if len(res.ResponseItems) == 0 {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return nil, fmt.Errorf("jtepxress: cancel order empty response")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// return res.ResponseItems[0], nil
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					return nil, err
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					r.Response.StatusCode = resp.StatusCode()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					r.Response.Body = resp.Body()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					return r
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				func (c *Client) CreateOrder(req *CreateOrderReq) (*CreateOrderItemRes, error) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				func (c *Client) CreateOrder(req *CreateOrderReq) (r Response) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					path := c.host + apiPathCreateOrder
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					data := pjson.ToJSONString(req)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					body := map[string]string{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						"logistics_interface": data,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						"data_digest":         c.getDigest(data),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						"msg_type":            msgTypeCreateOrder,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						"eccompanyid":         c.EccompanyID,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					r.Request.Body = pjson.ToBytes(body)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					r.Request.URL = path
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					resp, err := c.httpClient.R().
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						SetFormData(map[string]string{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							"logistics_interface": data,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							"data_digest":         c.getDigest(data),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							"msg_type":            msgTypeCreateOrder,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							"eccompanyid":         c.EccompanyID,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}).
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						SetResult(&CreateOrderRes{}).
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						SetFormData(body).
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Post(path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if err != nil {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return nil, fmt.Errorf("jtepxress: request %s, err %v", path, err)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						r.Error = fmt.Errorf("jtepxress: request %s, err %v", path, err)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return r
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					res := resp.Result().(*CreateOrderRes)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if len(res.ResponseItems) == 0 {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return nil, fmt.Errorf("jtepxress: create order empty response")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					return res.ResponseItems[0], nil
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					r.Response.StatusCode = resp.StatusCode()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					r.Response.Body = resp.Body()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					return r
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				func (c *Client) getDigest(data string) string {
 | 
			
		
		
	
	
		
			
				
					| 
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |