|
@@ -15,7 +15,7 @@ require_once (BASE_CORE_PATH . '/framework/function/http.php');
|
|
|
class deliveryLogic
|
|
|
{
|
|
|
const oms_url = 'https://oapi.lrlz.com/lrlzApiRest/router/rest';
|
|
|
- //const oms_url = 'http://oapitest.lrlz.com/lrlzApiRest/router/rest';
|
|
|
+// const oms_url = 'http://oapitest.lrlz.com/lrlzApiRest/router/rest';
|
|
|
|
|
|
|
|
|
private static $appkey = '2015panda';
|
|
@@ -166,7 +166,7 @@ class deliveryLogic
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- public function cancel_oms($order_sn)
|
|
|
+ public function cancel_order($order_sn)
|
|
|
{
|
|
|
$param = array('type' => 'TRADE_INTERCEPT','data' => array('tids' => $order_sn,'remark' => '用户退款'));
|
|
|
$body = json_encode($param,JSON_UNESCAPED_UNICODE);
|
|
@@ -183,6 +183,66 @@ class deliveryLogic
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ const CANCEL_SUCCESS = 99;
|
|
|
+ public function query_order($order_sn)
|
|
|
+ {
|
|
|
+ $param = array('type' => 'TIDS_TRADE_STATUTS','data' => array('tids' => $order_sn,'remark' => '订单查询'));
|
|
|
+ $body = json_encode($param,JSON_UNESCAPED_UNICODE);
|
|
|
+ $sign = $this->sign($body);
|
|
|
+ $headers = array('v_appkey: '.self::$appkey, 'v_sign: '.$sign, 'Content-Type: application/json');
|
|
|
+ $resp = http_post_data(self::oms_url,urlencode($body),$headers);
|
|
|
+
|
|
|
+ if($resp === false) {
|
|
|
+ Log::record(__METHOD__ . " NET Error",Log::ERR);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log::record($resp,Log::DEBUG);
|
|
|
+ return $this->order_status($resp,$err_state,$reson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function cancel_status($order_sn)
|
|
|
+ {
|
|
|
+ $status = $this->query_order($order_sn);
|
|
|
+ if($status == self::CANCEL_SUCCESS) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function order_status($resp,&$err_state,&$reson)
|
|
|
+ {
|
|
|
+ $err_state = 0;
|
|
|
+
|
|
|
+ //1:成功 0 :失败
|
|
|
+ // 1:新订单 2:等待仓库处理 99:已拦截 90:库存不足 7:已发货
|
|
|
+ // -99:发货失败 -2:订单关闭 -3:订单已存在(没有进行拦截的订单不予更新) -1:异常订单 -2:订单关闭
|
|
|
+ $result = json_decode($resp, true);
|
|
|
+ if (!empty($result) && is_array($result))
|
|
|
+ {
|
|
|
+ if ($result['apiCode'] == 'success')
|
|
|
+ {
|
|
|
+ if (!empty($result['data']) && is_array($result['data']) && count($result['data']) > 0)
|
|
|
+ {
|
|
|
+ // 填充错误理由
|
|
|
+ $reson = $result['data'][0]['errorMessge'];
|
|
|
+ if (!empty($result['data'][0]['status'])) {
|
|
|
+ $status = intval($result['data'][0]['status']);
|
|
|
+ return $status;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @param $pay_sn
|
|
|
* @param $trade_no
|