常见问题

代码示例

推单示例Java

/**
 * post方式推送给返利
 * @version 1.0
 */
private String post2Fanli(String orderData) {
    if (StringUtils.isNotBlank(orderData)) {
        try {
            //转义
            orderData = URLEncoder.encode(orderData, "utf-8");
            String formData = "content=" + orderData;
            URL url = new URL("http://union.fanli.com/dingdan/push/shopid/****");
            System.out.println(url.getPath());
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setDoOutput(true); // 设置post方式
            conn.setDoInput(true);
            conn.setRequestMethod("POST");
            
            DataOutputStream out = new DataOutputStream(conn.getOutputStream()); // 获得连接输出流
            out.writeBytes(formData);
            out.flush();
            out.close();
            
            //设置编码,否则中文乱码
            BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
            // 接收返回代码
            StringBuffer result = new StringBuffer();
            String s = null;
            while ((s = reader.readLine()) != null) {
                result.append(s);
            }
            reader.close();
            conn.disconnect();
            //返回推送结果
            //Logger.info("推单结果", result.toString());
            return result.toString();
        } catch (Exception e) {
            //Logger.error("订单推送失败",orderData);
        }
    }
    return null;
}

推单示例PHP

<?php
/**
 * post方式推送给返利
 * @version 1.0
 */
function post2Fanli($orderData) {
    $post_data = array(
        "content" => $orderData,
    );
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://union.fanli.com/dingdan/push/shopid/****');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    //推送结果
    $re = curl_exec($ch);
    curl_close($ch);
    return $re;
}

订单报文示例

B2C订单报文示例

<?xml version="1.0" encoding="utf-8"?>
<orders version="4.0">
  <order>
    <s_id>12345</s_id>
    <order_id_parent>2017071212345</order_id_parent>
    <order_id>2017071212345</order_id>
    <order_time>2017-07-12 16:07:56</order_time>
    <uid>6</uid>
    <uname>6@51fanli</uname>
    <tc>abc1234</tc>
    <pay_time>2017-07-12 16:07:56</pay_time>
    <status>0</status>
    <locked/>
    <lastmod>2017-07-12 16:07:56</lastmod>
    <is_newbuyer>1</is_newbuyer>
    <platform>2</platform>
    <remark/>
    <extension>
      <reg_time>2017-06-16 21:45:00</reg_time>
      <moblie>13012345678</moblie>
    </extension>
    <products>
      <product>
        <pid>12345678</pid>
        <title><![CDATA[泰国进口百香果 西番莲12个装 单果70-90克]]></title>
        <category>12</category>
        <category_title>进口水果</category_title>
        <url><![CDATA[http://www.shop.com/product/12345678.html]]></url>
        <num>2</num>
        <price>20.00</price>
        <real_pay_fee>35.00</real_pay_fee>
        <refund_num/>
        <commission>7.50</commission>
        <comm_type>A</comm_type>
        <extension>
          <data1>扩展属性1</data1>
          <data2>扩展属性2</data2>
        </extension>
      </product>
    </products>
  </order>
</orders>