浏览代码

add kdn subscribe to publish version

stanley-king 9 年之前
父节点
当前提交
e1f2f98c5f
共有 4 个文件被更改,包括 37 次插入18 次删除
  1. 1 1
      data/logic/queue.logic.php
  2. 21 4
      helper/kdn_helper.php
  3. 12 10
      mobile/dispatch_notify.php
  4. 3 3
      mobile/kdniao_notify.php

+ 1 - 1
data/logic/queue.logic.php

@@ -460,7 +460,7 @@ class queueLogic
      *
      * @return bool
      */
-    public function dispatchKDN($param)
+    public function subscribeKDN($param)
     {
         if (empty($param) || empty($param['order_sn'])) {
             Log::record("kdn_helper: 数据有误! param:" . json_encode($param));

+ 21 - 4
helper/kdn_helper.php

@@ -18,16 +18,31 @@ class kdn_helper
     static public function query($shipperCode, $logisticCode)
     {
         $requestData = json_encode(array('ShipperCode' => $shipperCode,'LogisticCode' => $logisticCode));
+
+        $account = self::get_account();
         $datas = array(
-            'EBusinessID' => '1256051',
+            'EBusinessID' => $account['EBusinessID'],
             'RequestType' => '1002',
             'RequestData' => urlencode($requestData),
             'DataType' => '2',
-            'DataSign' => self::encrypt($requestData, '6718d260-e2b6-4329-ad78-daff173309ac')
+            'DataSign' => self::encrypt($requestData, $account['AppID'])
         );
         $result = http_post_data(self::req_url,$datas);
         return $result;
     }
+    static public function cur_businessid() {
+        $account = self::get_account();
+        return $account['EBusinessID'];
+    }
+
+    static public function get_account()
+    {
+        if(defined('MOBILE_PUBLISH') && MOBILE_PUBLISH == true) {
+            return array('EBusinessID' => '1256766','AppID' => '22c88d88-3565-4023-b5ac-0201792869ed');
+        } else {
+            return array('EBusinessID' => '1256051','AppID' => '6718d260-e2b6-4329-ad78-daff173309ac');
+        }
+    }
 
     static private function encrypt($data, $appkey)
     {
@@ -59,12 +74,14 @@ class kdn_helper
     {
         $datas = array(array('Code' => $e_code,'Item' => array(array('No' => $logisticCode,'Bk' => $order_sn))));
         $requestData = json_encode($datas);
+
+        $account = self::get_account();
         $datas = array(
-            'EBusinessID' => '1256051',
+            'EBusinessID' => $account['EBusinessID'],
             'RequestType' => '1005',
             'RequestData' => urlencode($requestData),
             'DataType' => '2',
-            'DataSign' => self::encrypt($requestData, '6718d260-e2b6-4329-ad78-daff173309ac')
+            'DataSign' => self::encrypt($requestData, $account['AppID'])
         );
         $result = http_post_data(self::req_url, $datas);
         return $result;

+ 12 - 10
mobile/dispatch_notify.php

@@ -9,9 +9,9 @@
 require_once(BASE_ROOT_PATH . '/helper/kdn_helper.php');
 
 fcgi_header("Content-Type: text/plain; charset=UTF-8");
-try {
+try
+{
     //tid-订单号,status-1,consign_time-发货时间,logistics_no-快递流水,logistics_company-快递公司
-
     $order_sn = trim($_POST['tid']);
     $status = intval($_POST['status']);
     $consign_time = urldecode(trim($_POST['consign_time']));
@@ -30,26 +30,28 @@ try {
     $shipping_express_id = $express[0]['id'];
     $remote_addr = $_SERVER['REMOTE_ADDR'];
 
-    if (!empty($order_sn) && !empty($logistics_no)) {
-        if ($status == 1) {
+    if (!empty($order_sn) && !empty($logistics_no))
+    {
+        if ($status == 1)
+        {
             $order = Model('order');
             $ret = $order->setOrderDelivery($order_sn, $shipping_express_id, $logistics_no, $ship_time);
             if ($ret) {
-                //kdn_helper::subscribe($order_sn);
-                QueueClient::push('dispatchKDN',array('order_sn'=>$order_sn));
+                QueueClient::push('subscribeKDN',array('order_sn'=>$order_sn));
                 echo 'SUCCESS';
             } else {
-                echo 'AGAIN';
+                echo 'SUCCESS';
             }
         } else {
-           // kdn_helper::subscribe($order_sn);
-            QueueClient::push('dispatchKDN',array('order_sn'=>$order_sn));
+            QueueClient::push('subscribeKDN',array('order_sn'=>$order_sn));
             echo 'SUCCESS';
         }
     } else {
         echo 'FAIL';
     }
-} catch (Exception $e) {
+}
+catch (Exception $e)
+{
     Log::record($e->getMessage(), Log::ERR);
     echo 'AGAIN';
 }

+ 3 - 3
mobile/kdniao_notify.php

@@ -20,9 +20,9 @@ else
 {
     Log::record("start handle....",Log::DEBUG);
     $count = intval($deliver_info['Count']);
-    if($count <= 0 || $deliver_info['EBusinessID'] != '1256051') {
+    if($count <= 0 || $deliver_info['EBusinessID'] != kdn_helper::cur_businessid()) {
         $success = false;
-        $reson = "count={$count} or EBusinessID = {$deliver_info['EBusinessID']} != 1256051";
+        $reson = "count={$count} or EBusinessID = {$deliver_info['EBusinessID']} != " . kdn_helper::cur_businessid();
     }
     else
     {
@@ -32,6 +32,6 @@ else
     }
 }
 
-echo (json_encode(array('EBusinessID' => '1256051','UpdateTime' => strftime("%Y-%m-%d %H:%M:%S",time()), 'Success' => $success,'Reason' => $reson)));
+echo (json_encode(array('EBusinessID' => kdn_helper::cur_businessid(),'UpdateTime' => strftime("%Y-%m-%d %H:%M:%S",time()), 'Success' => $success,'Reason' => $reson)));
 
 ?>