From 0e77b42fc5a29f573fc8adf7371c5debc536a6e1 Mon Sep 17 00:00:00 2001 From: lyt Date: Fri, 30 Nov 2018 11:03:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E9=AA=8C=E8=AF=81;=20=E6=B5=8B=E8=AF=95=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vendorPlanSync/controllers/Tulanduo.php | 34 +++++++++++++++---- .../vendorPlanSync/controllers/index.php | 33 ++++++++++-------- .../vendorPlanSync/models/UserAuth_model.php | 24 +++++-------- 3 files changed, 56 insertions(+), 35 deletions(-) diff --git a/webht/third_party/vendorPlanSync/controllers/Tulanduo.php b/webht/third_party/vendorPlanSync/controllers/Tulanduo.php index dbaa9ba3..0ff6e7a6 100644 --- a/webht/third_party/vendorPlanSync/controllers/Tulanduo.php +++ b/webht/third_party/vendorPlanSync/controllers/Tulanduo.php @@ -114,9 +114,10 @@ class Tulanduo extends CI_Controller $last_date = count($grd_info)-1; $end_date = $grd_info[$last_date]->day_no_raw; $request_info = $this->Group_model->get_plan_request($gri_sn); + $order_type = 1; $this->tldOrderBuilder->setUserId($userId) ->setKey($userKey) - ->setOrderType(1) + ->setOrderType($order_type) ->setRouteName($routeName) ->setRouteType($routeType) ->setAgcOrderNo($agcOrderNo) @@ -183,7 +184,7 @@ class Tulanduo extends CI_Controller } } // 查询是否变更 - $sync_orderstate = 1; + $sync_orderstate = 10; $vps_sn = 0; $vendor_orderid = 0; $modifyLogInfo = "
$change_info
"; @@ -203,11 +204,32 @@ class Tulanduo extends CI_Controller // $this->tldOrderBuilder->setModifyLogInfo($modifyLogInfo) ; } - - return $this->tldOrderBuilder->getBizContent(); // $resp = $this->excute_curl($this->neworder_url, $this->tldOrderBuilder); - // $response = json_decode($resp); - // return $resp; + $resp = '{"status":1,"errMsg":"","responseData":{"orderId":' . rand(1000,9999) . '}}'; // test + $response = json_decode($resp); + if ($response->status == 1) { + /** VendorPlanSync */ + $sync_ret = array( + "VPS_VAS_SN" => $vas_sn + ,"VPS_GRI_SN" => $gri_sn + ,"VPS_VEI_SN" => $vei_sn + ,"VPS_startDate" => $first_date + ,"VPS_endDate" => $end_date + ,"VPS_sendHost" => $userId + ,"VPS_externalId" => $response->responseData->orderId + ,"VPS_externalorderType" => $order_type + ,"VPS_externalorderState" => $sync_orderstate + ,"VPS_latestTime" => date('Y-m-d H:i:s') + ); + if ($vps_sn === 0) { + $sync_id = $this->Group_model->insert_VendorPlanSync($sync_ret); + } else { + $update = $this->Group_model->update_VendorPlanSync($vps_sn, $sync_ret); + } + /** VendorArrangeState VAS_IsReceive */ + $this->Group_model->set_plan_received($vas_sn); + } + return $this->tldOrderBuilder->getBizContent() . "Order Push done. "; } /*! diff --git a/webht/third_party/vendorPlanSync/controllers/index.php b/webht/third_party/vendorPlanSync/controllers/index.php index 2b6f1035..61a00740 100644 --- a/webht/third_party/vendorPlanSync/controllers/index.php +++ b/webht/third_party/vendorPlanSync/controllers/index.php @@ -13,16 +13,13 @@ class Index extends CI_Controller { $this->load->model('Group_model'); $this->load->model('BIZ_Orders_model'); - $opend_id = $this->input->post('openId'); - $opend_key = $this->input->post('key'); - $match = $this->UserAuth_model->if_user_key($open_id, $open_key, 11, 1); - if ($match !== TRUE) { - $ret['status'] = -1; - $ret['errMsg'] = "用户验证失败"; - return $this->output->set_content_type('application/json')->set_output(json_encode($ret)); - } } + /*! + * TODO + * 请求的openID和订单的VEI_SN不相等 + */ + public function index() { $vendor_plan = $this->Group_model->get_vendor_plan_info(214600, 1343); @@ -48,6 +45,14 @@ class Index extends CI_Controller { return $this->output->set_output("Not found vendor function. " . $order->GRI_SN); } + public function verify_user() + { + $open_id = $this->input->post('openId'); + $open_key = $this->input->post('key'); + $match = $this->UserAuth_model->if_user_key($open_id, $open_key, 1); + return $match; + } + /** * 接收地接社的信息上报 * * 信息类型代码: @@ -62,13 +67,13 @@ class Index extends CI_Controller { { $ret['status'] = -1; $ret['errMsg'] = "未知错误"; - $input = $this->input->post(); - $vendorID = $input['openId']; - $validate = $this->calc_key($vendorID, $input['key']); - if ($validate !== TRUE) { - $ret['errMsg'] = "身份验证失败."; + $user_verify = $this->verify_user(); + if ($user_verify !== TRUE) { + $ret['errMsg'] = '用户验证失败'; return $this->output->set_content_type('application/json')->set_output(json_encode($ret)); } + $input = $this->input->post(); + $vendorID = $input['openId']; $vps = $this->Group_model->get_sync_info_by_vendororder($input['orderId']); if (empty($vps)) { $ret['errMsg'] = "未找到相应的订单."; @@ -178,7 +183,7 @@ class Index extends CI_Controller { { $default = "b825e39422a54875a95752fc7ed6f5d2"; $ret = md5(hash("sha256", $userId.$default)); - return $ret===$key; + return $ret; } } diff --git a/webht/third_party/vendorPlanSync/models/UserAuth_model.php b/webht/third_party/vendorPlanSync/models/UserAuth_model.php index 87cf9569..3e92c037 100644 --- a/webht/third_party/vendorPlanSync/models/UserAuth_model.php +++ b/webht/third_party/vendorPlanSync/models/UserAuth_model.php @@ -9,27 +9,21 @@ class UserAuth_model extends CI_Model { } /*! - * TPA_Direction - * 1 外部调用我社系统 - * 2 我社调用外部系统 * * TPA_AccountType - * - 1* 外部调用我社系统 - * - 11 地接社 - * - 2* 我社调用外部系统 - * - 21 所属小组 + * - 1 地接社 * */ - public function get_user_key($account_id, $account_type, $direction) + public function get_user_key($account_id, $account_type) { $sql = "SELECT * FROM [Tourmanager].[dbo].[ThirdPartyAuth] - where TPA_Direction=? + where 1=1 and TPA_AccountType=? and TPA_AccountID=? order by TPA_ExpiredTime desc "; - return $this->HT->query($sql, array($direction, $account_type, $account_id))->row(); + return $this->HT->query($sql, array($account_type, $account_id))->row(); } /*! @@ -40,16 +34,16 @@ class UserAuth_model extends CI_Model { * @param integer $direction 默认是1-外部调用 * @return boolean */ - public function if_user_key($open_id, $open_key, $account_type, $direction=1) + public function if_user_key($open_id, $open_key, $account_type) { $sql = "SELECT tpa_sn FROM [Tourmanager].[dbo].[ThirdPartyAuth] - where tpa_direction=? + where 1=1 and TPA_AccountType=? - and tpa_openid=? - and tpa_openkey=? + and TPA_OpenId=? + and TPA_OpenKey=? "; - return ($this->HT->query($sql, array($direction, $account_type, $open_id, $open_key))->num_rows() > 0); + return ($this->HT->query($sql, array($account_type, $open_id, $open_key))->num_rows() > 0); } }