Commit 5dfbc27c by 朱继来

调整后台下单curl请求

parent 0d0c70a1
......@@ -176,7 +176,11 @@ Class AddOrderController extends Controller
$url = Config('website.api_domain').'ucoupon/bestusebyordersystem';
$response = json_decode(curlApi($url, $data), true);
$res = curlApi($url, $data);
if (!$res) return ['errcode'=>1, 'errmsg'=>'未访问到API接口,请重新尝试'];
$response = json_decode($res, true);
if ($response['err_code'] == 0) {
return ['errcode' => $response['err_code'], 'errmsg' => $response['err_msg'], 'data'=>$response['data']];
......@@ -244,7 +248,11 @@ Class AddOrderController extends Controller
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$response = json_decode(curlApi($url, $data, 'POST'), true);
$res = curlApi($url, $data, 'POST');
if (!$res) return ['errcode'=>1, 'errmsg'=>'未访问到API接口,请重新尝试'];
$response = json_decode($res, true);
if (!empty($response['data'])) {
return ['errcode' => 0, 'errmsg' => '', 'data' => $response['data']];
......@@ -271,7 +279,11 @@ Class AddOrderController extends Controller
$url = Config('website.api_domain').'cart/addByOrderSystem';
$response = json_decode(curlApi($url, $data), true);
$res = curlApi($url, $data);
if (!$res) return ['errcode'=>1, 'errmsg'=>'未访问到API接口,请重新尝试'];
$response = json_decode($res, true);
if ($response['err_code'] == 0) {
return ['errcode' => $response['err_code'], 'errmsg' => $response['err_msg'], 'data'=>$response['data']];
......@@ -293,7 +305,11 @@ Class AddOrderController extends Controller
$url = Config('website.api_domain').'cart/switchSaleType';
$response = json_decode(curlApi($url, $data), true);
$res = curlApi($url, $data);
if (!$res) return ['errcode'=>1, 'errmsg'=>'未访问到API接口,请重新尝试'];
$response = json_decode($res, true);
return ['errcode' => $response['err_code'], 'errmsg' => $response['err_msg']];
}
......@@ -312,7 +328,11 @@ Class AddOrderController extends Controller
$url = Config('website.api_domain').'cart/listsByOrderSystem';
$response = json_decode(curlApi($url, $data), true);
$res = curlApi($url, $data);
if (!$res) return ['errcode'=>1, 'errmsg'=>'未访问到API接口,请重新尝试'];
$response = json_decode($res, true);
if ($response['err_code'] == 0) {
return ['errcode' => $response['err_code'], 'errmsg' => $response['err_msg'], 'data'=>$response['data']];
......@@ -341,7 +361,11 @@ Class AddOrderController extends Controller
$url = Config('website.api_domain').'cart/changeNumByOrderSystem';
}
$response = json_decode(curlApi($url, $data), true);
$res = curlApi($url, $data);
if (!$res) return ['errcode'=>1, 'errmsg'=>'未访问到API接口,请重新尝试'];
$response = json_decode($res, true);
if ($response['err_code'] == 0) {
return ['errcode' => $response['err_code'], 'errmsg' => $response['err_msg'], 'data'=>$response['data']];
......@@ -363,7 +387,11 @@ Class AddOrderController extends Controller
$url = Config('website.api_domain').'cart/deleteByOrderSystem';
$response = json_decode(curlApi($url, $data), true);
$res = curlApi($url, $data);
if (!$res) return ['errcode'=>1, 'errmsg'=>'未访问到API接口,请重新尝试'];
$response = json_decode($res, true);
if ($response['err_code'] == 0) {
return ['errcode' => $response['err_code'], 'errmsg' => $response['err_msg'], 'data'=>$response['data']];
......@@ -396,7 +424,11 @@ Class AddOrderController extends Controller
$url = Config('website.api_domain').'cart/confirm';
$response = json_decode(curlApi($url, $data), true);
$res = curlApi($url, $data);
if (!$res) return ['errcode'=>1, 'errmsg'=>'未访问到API接口,请重新尝试'];
$response = json_decode($res, true);
if ($response['err_code'] == 0) {
return ['errcode' => $response['err_code'], 'errmsg' => $response['err_msg'], 'data'=>$response['data']];
......@@ -423,7 +455,11 @@ Class AddOrderController extends Controller
foreach ($cart_info as $k=>$v) {
$data['id'] = $v['gid'];
$response = json_decode(curlApi($url, $data), true);
$res = curlApi($url, $data);
if (!$res) return ['errcode'=>1, 'errmsg'=>'未访问到API接口,请重新尝试'];
$response = json_decode($res, true);
if ($sale_type == 1) {
// 现货订单--判断下单数量是否大于库存,若大于则弹出提示信息
......@@ -482,7 +518,11 @@ Class AddOrderController extends Controller
$url = Config('website.api_domain').'order/create';
$response = json_decode(curlApi($url, $data), true);
$res = curlApi($url, $data);
if (!$res) return ['errcode'=>1, 'errmsg'=>'未访问到API接口,请重新尝试'];
$response = json_decode($res, true);
if ($response['err_code'] == 0) {
return ['errcode' => $response['err_code'], 'errmsg' => $response['err_msg'], 'data'=>['order_id' => $response['data'], 'type' => $data['type']]];
......
......@@ -47,7 +47,7 @@
}
// curl
function curlApi( $url , $params = array(), $method = 'GET' , $multi = false, $extheaders = array())
function curlApi($url , $params = array(), $method = 'GET' , $multi = false, $extheaders = array())
{
if(!function_exists('curl_init')) exit('Need to open the curl extension');
$method = strtoupper($method);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment