|
@@ -12,6 +12,8 @@
|
|
|
|
|
|
defined('InShopNC') or exit('Access Invalid!');
|
|
|
|
|
|
+require_once(BASE_ROOT_PATH . '/helper/kdn_helper.php');
|
|
|
+
|
|
|
class member_orderControl extends mbMemberControl
|
|
|
{
|
|
|
public function __construct()
|
|
@@ -44,7 +46,8 @@ class member_orderControl extends mbMemberControl
|
|
|
$order_list_array = $model_order->getNormalOrderList($condition, $this->page, '*', 'order_id desc', '', array('order_address', 'order_goods'));
|
|
|
$order_group_list = array();
|
|
|
$order_pay_sn_array = array();
|
|
|
- foreach ($order_list_array as $value) {
|
|
|
+ foreach ($order_list_array as $value)
|
|
|
+ {
|
|
|
//显示取消订单
|
|
|
$value['if_cancel'] = $model_order->getOrderOperateState('buyer_cancel', $value);
|
|
|
//显示收货
|
|
@@ -81,12 +84,13 @@ class member_orderControl extends mbMemberControl
|
|
|
$model_order->cls();
|
|
|
|
|
|
$array_data = array('order_group_list' => $new_order_group_list);
|
|
|
- if (isset($_GET['getpayment']) && $_GET['getpayment'] == "true") {
|
|
|
+ if (isset($_GET['getpayment']) && $_GET['getpayment'] == "true")
|
|
|
+ {
|
|
|
$model_mb_payment = Model('mb_payment');
|
|
|
-
|
|
|
$payment_list = $model_mb_payment->getMbPaymentOpenList();
|
|
|
$payment_array = array();
|
|
|
- if (!empty($payment_list)) {
|
|
|
+ if (!empty($payment_list))
|
|
|
+ {
|
|
|
foreach ($payment_list as $value) {
|
|
|
$payment_array[] = array('payment_code' => $value['payment_code'], 'payment_name' => $value['payment_name']);
|
|
|
}
|
|
@@ -95,7 +99,7 @@ class member_orderControl extends mbMemberControl
|
|
|
}
|
|
|
|
|
|
$array_data['mobile_page'] = mobile_page($page_count);
|
|
|
- joutput_data($array_data);
|
|
|
+ self::outsuccess($array_data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -110,8 +114,8 @@ class member_orderControl extends mbMemberControl
|
|
|
$order_list_array = $model_order->getNormalOrderList($condition, $this->page, '*', 'order_id desc', '', array('order_address', 'order_goods'));
|
|
|
|
|
|
$array_data = array();
|
|
|
- foreach ($order_list_array as $value) {
|
|
|
-
|
|
|
+ foreach ($order_list_array as $value)
|
|
|
+ {
|
|
|
//显示取消订单
|
|
|
$value['if_cancel'] = $model_order->getOrderOperateState('buyer_cancel', $value);
|
|
|
//显示收货
|
|
@@ -127,7 +131,7 @@ class member_orderControl extends mbMemberControl
|
|
|
$array_data[] = $value;
|
|
|
}
|
|
|
|
|
|
- joutput_data(array("order_list" => $array_data));
|
|
|
+ self::outsuccess(array("order_list" => $array_data));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -142,7 +146,7 @@ class member_orderControl extends mbMemberControl
|
|
|
} else if (!empty($_POST['order_sn'])) {
|
|
|
$condition['order_sn'] = trim($_POST['order_sn']);
|
|
|
} else {
|
|
|
- return joutput_error(errcode::ErrParamter, "请传入order_sn.");
|
|
|
+ return self::outerr(errcode::ErrParamter, "请传入order_sn.");
|
|
|
}
|
|
|
|
|
|
$model_order = Model('order');
|
|
@@ -154,18 +158,18 @@ class member_orderControl extends mbMemberControl
|
|
|
$order_info = $model_order->getOrderInfo($condition);
|
|
|
// $if_allow = $model_order->getOrderOperateState('buyer_cancel', $order_info);
|
|
|
// if (!$if_allow) {
|
|
|
-// return joutput_error(errcode::ErrOrder, '无权操作');
|
|
|
+// return self::outerr(errcode::ErrOrder, '无权操作');
|
|
|
// }
|
|
|
if ($order_info['order_state'] != ORDER_STATE_NEW) {
|
|
|
Log::record("order_state = {$order_info['order_state']}.", Log::ERR);
|
|
|
- return joutput_error(errcode::ErrOrder, "已支付和已发货订单不能取消.");
|
|
|
+ return self::outerr(errcode::ErrOrder, "已支付和已发货订单不能取消.");
|
|
|
}
|
|
|
|
|
|
$result = $logic_order->changeOrderStateCancel($order_info, 'buyer', $_SESSION['member_name'], '其它原因');
|
|
|
if (!$result['state']) {
|
|
|
- return joutput_error(errcode::ErrOrder, $result['msg']);
|
|
|
+ return self::outerr(errcode::ErrOrder, $result['msg']);
|
|
|
} else {
|
|
|
- joutput_data(array('result' => '1'));
|
|
|
+ self::outsuccess(array('result' => '1'));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -183,15 +187,15 @@ class member_orderControl extends mbMemberControl
|
|
|
$order_info = $model_order->getOrderInfo($condition);
|
|
|
$if_allow = $model_order->getOrderOperateState('receive', $order_info);
|
|
|
if (!$if_allow) {
|
|
|
- return joutput_error(errcode::ErrOrder, '无权操作');
|
|
|
+ return self::outerr(errcode::ErrOrder, '无权操作');
|
|
|
}
|
|
|
|
|
|
$logic_order = Logic('order');
|
|
|
$result = $logic_order->changeOrderStateReceive($order_info, 'buyer', $_SESSION['member_name']);
|
|
|
if (!$result['state']) {
|
|
|
- return joutput_error(errcode::ErrOrder, $result['msg']);
|
|
|
+ return self::outerr(errcode::ErrOrder, $result['msg']);
|
|
|
} else {
|
|
|
- joutput_data(array('result' => '1'));
|
|
|
+ self::outsuccess(array('result' => '1'));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -208,7 +212,7 @@ class member_orderControl extends mbMemberControl
|
|
|
Tpl::showpage('express_info');
|
|
|
return;
|
|
|
} else {
|
|
|
- return joutput_error($this->err_code);
|
|
|
+ return self::outerr($this->err_code);
|
|
|
}
|
|
|
|
|
|
$order_id = intval($_POST['order_id']);
|
|
@@ -219,7 +223,7 @@ class member_orderControl extends mbMemberControl
|
|
|
Tpl::showpage('express_info');
|
|
|
return;
|
|
|
} else {
|
|
|
- return joutput_error(errcode::ErrOrder, '订单不存在');
|
|
|
+ return self::outerr(errcode::ErrOrder, '订单不存在');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -235,7 +239,7 @@ class member_orderControl extends mbMemberControl
|
|
|
Tpl::showpage('express_info');
|
|
|
return;
|
|
|
} else {
|
|
|
- return joutput_error(errcode::ErrOrder, '订单不存在');
|
|
|
+ return self::outerr(errcode::ErrOrder, '订单不存在');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -247,7 +251,7 @@ class member_orderControl extends mbMemberControl
|
|
|
$deliver_info = rkcache($key);
|
|
|
if (empty($deliver_info))
|
|
|
{
|
|
|
- $deliver_info = $this->getOrderTracesByJson($e_code, $order_info['shipping_code']);
|
|
|
+ $deliver_info = kdn_helper::query($e_code, $order_info['shipping_code']);
|
|
|
if ($deliver_info === false || empty($deliver_info))
|
|
|
{
|
|
|
Log::record("search_deliver:cannot query delivery info from kuaidn.",Log::ERR);
|
|
@@ -289,37 +293,6 @@ class member_orderControl extends mbMemberControl
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 从第三方取快递信息
|
|
|
- *
|
|
|
- */
|
|
|
- public function _get_express($e_code, $shipping_code)
|
|
|
- {
|
|
|
- $url = 'http://www.kuaidi100.com/query?type=' . $e_code . '&postid=' . $shipping_code . '&id=1&valicode=&temp=' . random(4) . '&sessionid=&tmp=' . random(4);
|
|
|
- import('function.ftp');
|
|
|
- $content = dfsockopen($url);
|
|
|
- $content = json_decode($content, true);
|
|
|
-
|
|
|
- if ($content['status'] != 200) {
|
|
|
- joutput_error(errcode::ErrOrder, '物流信息查询失败');
|
|
|
- return false;
|
|
|
- }
|
|
|
- $content['data'] = array_reverse($content['data']);
|
|
|
- $output = array();
|
|
|
- if (is_array($content['data'])) {
|
|
|
- foreach ($content['data'] as $k => $v) {
|
|
|
- if ($v['time'] == '') continue;
|
|
|
- $output[] = $v['time'] . ' ' . $v['context'];
|
|
|
- }
|
|
|
- }
|
|
|
- if (empty($output)) exit(json_encode(false));
|
|
|
- if (strtoupper(CHARSET) == 'GBK') {
|
|
|
- $output = Language::getUTF8($output);//网站GBK使用编码时,转换为UTF-8,防止json输出汉字问题
|
|
|
- }
|
|
|
-
|
|
|
- return $output;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 获取不同状态下订单数量
|
|
|
*/
|
|
|
public function orderCountStateOp()
|
|
@@ -328,77 +301,6 @@ class member_orderControl extends mbMemberControl
|
|
|
$condition['buyer_id'] = $_SESSION['member_id'];
|
|
|
$result = Model()->table('order')->field('order_state, count(*) as count')->where($condition)->group('order_state')->select();
|
|
|
|
|
|
- joutput_data(array('order_count' => $result));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 快递鸟接口方式
|
|
|
- * Json方式 查询订单物流轨迹
|
|
|
- */
|
|
|
- public function getOrderTracesByJson($shipperCode, $logisticCode)
|
|
|
- {
|
|
|
- $requestData = "{\"OrderCode\":\"\",\"ShipperCode\":\"" . $shipperCode . "\",\"LogisticCode\":\"" . $logisticCode . "\"}";
|
|
|
- $datas = array(
|
|
|
- 'EBusinessID' => '1256051',
|
|
|
- 'RequestType' => '1002',
|
|
|
- 'RequestData' => urlencode($requestData),
|
|
|
- 'DataType' => '2',
|
|
|
- );
|
|
|
- $datas['DataSign'] = $this->encrypt($requestData, '6718d260-e2b6-4329-ad78-daff173309ac');
|
|
|
- $result = $this->sendPost('http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx', $datas);
|
|
|
- return $result;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 快递鸟接口方式
|
|
|
- * post提交数据
|
|
|
- * @param string $url 请求Url
|
|
|
- * @param array $datas 提交的数据
|
|
|
- * @return url响应返回的html
|
|
|
- */
|
|
|
- public function sendPost($url, $datas)
|
|
|
- {
|
|
|
- $temps = array();
|
|
|
- foreach ($datas as $key => $value) {
|
|
|
- $temps[] = sprintf('%s=%s', $key, $value);
|
|
|
- }
|
|
|
- $post_data = implode('&', $temps);
|
|
|
- $url_info = parse_url($url);
|
|
|
- $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n";
|
|
|
- $httpheader .= "Host:" . $url_info['host'] . "\r\n";
|
|
|
- $httpheader .= "Content-Type:application/x-www-form-urlencoded\r\n";
|
|
|
- $httpheader .= "Content-Length:" . strlen($post_data) . "\r\n";
|
|
|
- $httpheader .= "Connection:close\r\n\r\n";
|
|
|
- $httpheader .= $post_data;
|
|
|
- $fd = fsockopen($url_info['host'], 80);
|
|
|
- fwrite($fd, $httpheader);
|
|
|
-
|
|
|
- while (!feof($fd)) {
|
|
|
- if (($header = @fgets($fd)) && ($header == "\r\n" || $header == "\n")) {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $gets = false;
|
|
|
- while (!feof($fd)) {
|
|
|
- $gets .= fread($fd, 128);
|
|
|
- }
|
|
|
- fclose($fd);
|
|
|
-
|
|
|
- return $gets;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 快递鸟接口方式
|
|
|
- * 电商Sign签名生成
|
|
|
- * @param data
|
|
|
- * @param appkey Appkey
|
|
|
- * @return DataSign签名
|
|
|
- */
|
|
|
- public function encrypt($data, $appkey)
|
|
|
- {
|
|
|
- return urlencode(base64_encode(md5($data . $appkey)));
|
|
|
+ self::outsuccess(array('order_count' => $result));
|
|
|
}
|
|
|
}
|