使用达达即时配送方案,在预下单(https://api.weixin.qq.com/cgi-bin/express/local/business/order/pre_add?access_token=ACCESS_TOKEN)时,出现2003错误,错误返回如下:
{“resultcode”:2003,“resultmsg”:“签名错误”,“fee”:0,“deliverfee”:0,“tips”:0,“insurancefee”:0,“distance”:0,“delivery_token”:"",“dispatch_duration”:0}
请求信息如下($data):
{
“cargo”: {
“goods_value”: “97.80”,
“goods_weight”: “3”,
“goods_pickup_info”: “”,
“goods_delivery_info”: “”,
“cargo_first_class”: “\u65e5\u7528\u767e\u8d27”,
“cargo_second_class”: “\u5ba0\u7269\u7528\u54c1”
},
“delivery_sign”: “a6967774e37d812ca9d887efce235ce5606540d3”,
“delivery_id”: “DADA”,
“openid”: “o7OLI5V-JEIH-5qwuonh-ThNCinA”,
“order_info”: {
“order_type”: “0”
},
“receiver”: {
“name”: “\u5f20\u4e09”,
“city”: “\u5357\u4eac”,
“address”: “\u5e7f\u5dde\u5e02\u6d77\u73e0\u533a\u65b0\u6e2f\u4e2d\u8def397\u53f7”,
“address_detail”: “\u5e7f\u5dde\u5e02\u6d77\u73e0\u533a\u65b0\u6e2f\u4e2d\u8def397\u53f7”,
“phone”: “020-81167888”,
“lng”: “113.3237686157”,
“lat”: “23.0964202881”
},
“shop_id”: “dadae5e77242bf27905”,
“shop_order_id”: “110”,
“shop_no”: “39160-433264”,
“shop”: {
“wxa_path”: “\/historyOrderDetail\/historyOrderDetail?order_id=110”,
“img_url”: “https:\/\/cyanlake.cn\/crd\/shopImg\/1\/coverImg.jpg”,
“goods_name”: “\u9752\u6e56\u6d4b\u8bd5\u5e97”,
“goods_count”: “10”
}
}
达达提供的appkey:$dada_shop_id=“dadae5e77242bf27905”;$dada_app_secret=“如需要可提供”;
加密算法:$delivery_sign=sha1($dada_shop_id.$shop_order_id.$dada_app_secret);
请求发送:
$data = array(//主参数构建
"cargo"=>$cargo,
"delivery\_sign"=>$delivery\_sign,
"delivery\_id"=>$delivery\_id,
"openid"=>$user\_openid,
"order\_info"=>$order\_info,
"receiver"=>$receiver,
"shop\_id" =>$dada\_shop\_id,
"shop\_order\_id"=>$shop\_order\_id,
"shop\_no"=>$dadaID,
"shop"=>$shop
);
$url=“https://api.weixin.qq.com/cgi-bin/express/local/business/order/pre_add?access_token=”.$accessToken;
$data=json_encode($data,JSON_UNESCAPED_UNICODE);
$options = array(
'http' => array(
'method' => 'POST',
'header'=>"Content-type: application/x-www-form-urlencoded;charset=gb2312\\r\\n".
"Content-length:".strlen($data)."\\r\\n",
'content' => $data,
)
);
$context = stream_context_create($options);
$codeinfo = file_get_contents($url,false,$context);
服务器使用php7.3
文档算法
delivery_sign=SHA1(shopid + shop_order_id + AppSecret)
我的算法
$delivery_sign=sha1($dada_shop_id.$shop_order_id.$dada_app_secret);
其中$dada_shop_id=达达APP_Key=dadae5e77242bf27905
$dada_app_secret=达达APP_Secret
以上两个值,从达达开放平台-我是商户入口进入并获得,且和immediateDelivery.getBindAccount接口查询结果一致
$shop_order_id=自定义订单编号
且我算出来的$delivery_sign和网上工具算出来的sha1结果相等
所以。。。想请教一下这个$delivery_sign是不是还有什么我没考虑到的坑?