From 1bd077bf526f6c2d14c67f59eb6a9da56dccfc7b Mon Sep 17 00:00:00 2001 From: lyt Date: Thu, 29 Nov 2018 18:09:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8F=91=E9=80=81/=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E7=9B=B8=E5=85=B3=E7=8A=B6=E6=80=81;=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=B0=83=E7=94=A8=E8=B4=A6=E6=88=B7=E9=AA=8C=E8=AF=81?= =?UTF-8?q?;=20=E5=AF=BC=E6=B8=B8=E4=B8=8A=E6=8A=A5=E5=90=8E=E5=BD=95?= =?UTF-8?q?=E5=85=A5=E6=98=AF=E5=90=A6=E6=88=90=E5=8A=9F=E7=8A=B6=E6=80=81?= =?UTF-8?q?;=20=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + .../vendorPlanSync/controllers/Tulanduo.php | 53 +++++++++++++---- .../vendorPlanSync/controllers/index.php | 34 +++++++++-- .../vendorPlanSync/models/Group_model.php | 2 +- .../vendorPlanSync/models/UserAuth_model.php | 58 +++++++++++++++++++ 5 files changed, 130 insertions(+), 19 deletions(-) create mode 100644 webht/third_party/vendorPlanSync/models/UserAuth_model.php diff --git a/.gitignore b/.gitignore index 4954fc1d..f4ff3920 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ /author/document/* */statement_files/* */paypal_activities/* +test122.php +/test122/* diff --git a/webht/third_party/vendorPlanSync/controllers/Tulanduo.php b/webht/third_party/vendorPlanSync/controllers/Tulanduo.php index 747649a7..dbaa9ba3 100644 --- a/webht/third_party/vendorPlanSync/controllers/Tulanduo.php +++ b/webht/third_party/vendorPlanSync/controllers/Tulanduo.php @@ -182,6 +182,28 @@ class Tulanduo extends CI_Controller } } } + // 查询是否变更 + $sync_orderstate = 1; + $vps_sn = 0; + $vendor_orderid = 0; + $modifyLogInfo = "
$change_info
"; + if (intval($is_send_vary)===1) { + $vps = $this->Group_model->get_sync_info($vas_sn); + if ( ! empty($vps)) { + $vps_sn = $vps->VPS_SN; + $vendor_orderid = $vps->VPS_externalId; + $sync_orderstate = 11; + // $modifyLogInfo = "
https://www.trippest.com
"; + $this->tldOrderBuilder->setOrderId($vendor_orderid) + ->setModifyLogInfo($modifyLogInfo) + ; + } + } else { + $this->tldOrderBuilder->clearModifyLogInfo(); + // $this->tldOrderBuilder->setModifyLogInfo($modifyLogInfo) + ; + } + return $this->tldOrderBuilder->getBizContent(); // $resp = $this->excute_curl($this->neworder_url, $this->tldOrderBuilder); // $response = json_decode($resp); @@ -195,7 +217,7 @@ class Tulanduo extends CI_Controller */ public function push_trippest($vas=null) { - return "[Tulanduo>push_trippest] Done. "; // test + // return "[Tulanduo>push_trippest] Done. "; // test /** 目的地 */ $userId = $this->send_host["30"]["userId"]; $userKey = $this->send_host["30"]["key"]; @@ -419,7 +441,7 @@ class Tulanduo extends CI_Controller } } // 查询是否变更 - $sync_orderstate = 1; + $sync_orderstate = 10; $vps_sn = 0; $vendor_orderid = 0; if (intval($is_send_vary)===1) { @@ -441,8 +463,9 @@ class Tulanduo extends CI_Controller } // echo(($this->tldOrderBuilder->getBizContent())); // $this->output->set_content_type('application/json')->set_output($this->tldOrderBuilder->getBizContent()); - $resp = $this->excute_curl($this->neworder_url, $this->tldOrderBuilder); + // $resp = $this->excute_curl($this->neworder_url, $this->tldOrderBuilder); // var_dump($resp); + $resp = '{"status":1,"errMsg":"","responseData":{"orderId":' . rand(1000,9999) . '}}'; // test $response = json_decode($resp); if ($response->status == 1) { /** VendorPlanSync */ @@ -474,6 +497,7 @@ class Tulanduo extends CI_Controller public function tourguide_update($input, $vps, $eva) { $ret['status'] = -1; + $ret['err'] = 100; $ret['errMsg'] = "未知错误"; $eva_g_sn = $eva[0]->has_tourguide; if (strval($vps->department)==="30") { @@ -486,12 +510,14 @@ class Tulanduo extends CI_Controller $this->tld_order->setOrderId($vps->VPS_externalId) ->setUserId($userId) ->setKey($userKey); - $detail_resp = $this->excute_curl($this->detail_url, $this->tld_order); + // $detail_resp = $this->excute_curl($this->detail_url, $this->tld_order); + $detail_resp = '{"status":1,"errMsg":"","orderDetail":{"orderId":' . rand(1000,9999) . ',"operationDetails": {"guiderOperations":[{"name":"北京翟梦琪Susie","mobelPhone":"18801326155","startDate":"2017-04-25","endDate":"2017-04-25","sumMoney":400,"remark":"","guiderPhoto":"http://djb3c.ltsoftware.net:9921/projects/djb3c//uploadImages/guider/1526898234415.png"}]}}}'; // test $detail_jsonResp = json_decode($detail_resp); // 判断 if ($detail_jsonResp->status !== 1) { log_message('error','TulanduoApi get_orderdetail failed. Msg:' . $detail_jsonResp->errMsg . "; Request: " . $this->tld_order->getBizContent()); - $ret['errMsg'] = "查询失败"; + $ret['err'] = 100; // 获取详情失败 + $ret['errMsg'] = "获取详情失败"; return $ret; } // 导游信息 @@ -502,6 +528,7 @@ class Tulanduo extends CI_Controller $tourguide_mobile = real_phone_number($detail_jsonResp->orderDetail->operationDetails->guiderOperations[0]->mobelPhone, 86); } if ($tourguige_name === "") { + $ret['err'] = 102; // 未查询到导游 $ret['errMsg'] = "未查询到导游"; return $ret; } @@ -511,24 +538,26 @@ class Tulanduo extends CI_Controller $tourguige_name_en = characet($en_name_arr[0][0],'UTF-8'); $ht_tourguide = $this->Group_model->search_tourguide($input['openId'], $tourguige_name_cn, $tourguige_name_en, $tourguide_mobile); if (empty($ht_tourguide)) { + $ret['err'] = 200; // 导游信息未录入 $ret['errMsg'] = "导游信息未录入"; return $ret; } $eva_tgi_column = array( "EOI_Type" => 3 - ,"EOI_GRI_SN" => $eva->EOI_GRI_SN - ,"EOI_VEI_SN" => $eva->EOI_ObjSN + ,"EOI_GRI_SN" => $eva[0]->EOI_GRI_SN + ,"EOI_VEI_SN" => $eva[0]->EOI_ObjSN ,"EOI_ObjSN" => $ht_tourguide->TGI_SN - ,"EOI_CII_SN" => $eva->EOI_CII_SN - ,"EOI_GetDate" => $eva->EOI_GetDate - ,"EOI_Date" => $eva->EOI_Date - ,"EOI_Cancel" => $eva->EOI_Cancel - ,"EOI_GroupType" => $eva->EOI_GroupType + ,"EOI_CII_SN" => $eva[0]->EOI_CII_SN + ,"EOI_GetDate" => $eva[0]->EOI_GetDate + ,"EOI_Date" => $eva[0]->EOI_Date + ,"EOI_Cancel" => $eva[0]->EOI_Cancel + ,"EOI_GroupType" => $eva[0]->EOI_GroupType ,"EOI_FillWorkers_SN" => 0 // todo ,"EOI_FWks_LastEditTime" => date('Y-m-d H:i:s') ); $this->Group_model->set_plan_tourguide($eva_g_sn, $eva_tgi_column); $ret['status'] = 1; + $ret['err'] = 0; $ret['errMsg'] = ""; return $ret; } diff --git a/webht/third_party/vendorPlanSync/controllers/index.php b/webht/third_party/vendorPlanSync/controllers/index.php index 92071230..2b6f1035 100644 --- a/webht/third_party/vendorPlanSync/controllers/index.php +++ b/webht/third_party/vendorPlanSync/controllers/index.php @@ -9,8 +9,18 @@ class Index extends CI_Controller { bcscale(4); $this->load->helper('array'); $this->load->library('vendor'); - $this->load->model('BIZ_Orders_model'); + $this->load->model('UserAuth_model'); $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)); + } } public function index() @@ -77,10 +87,10 @@ class Index extends CI_Controller { $ret = $this->fill_tourguide($input, $vps); break; case '4001': - # code... - break; case '4002': - # code... + $ret['status'] = 1; + $ret['errMsg'] = ""; + log_message('error','上报确认取消. ' . json_encode($input)); break; default: @@ -103,7 +113,7 @@ class Index extends CI_Controller { $ret['status'] = 1; $ret['errMsg'] = ""; $sync_arr = array( - "VPS_externalorderState" => 2 + "VPS_externalorderState" => 20 ,"VPS_latestTime" => date('Y-m-d H:i:s') ); /** VendorPlanSync */ @@ -147,7 +157,19 @@ class Index extends CI_Controller { $controller_name = $this->vendor->vendor_fun[strval($input['openId'])]; require_once($controller_name . '.php'); $vendor_class = new $controller_name(); - return $vendor_class->tourguide_update($input, $vps, $eva); + $ret = $vendor_class->tourguide_update($input, $vps, $eva); + $err_code = $ret['err']; + unset($ret['err']); // 不返回给接收方 + $sync_ret = array( + "VPS_latestTime" => date('Y-m-d H:i:s') + ); + if ($err_code === 0) { + // 录入成功 + $sync_ret['VPS_externalorderState'] = 31; + } else { + $sync_ret['VPS_externalorderState'] = 32; + } + $this->Group_model->update_VendorPlanSync($vps->VPS_SN, $sync_ret); } return $ret; } diff --git a/webht/third_party/vendorPlanSync/models/Group_model.php b/webht/third_party/vendorPlanSync/models/Group_model.php index dc8d46f7..457ff90b 100644 --- a/webht/third_party/vendorPlanSync/models/Group_model.php +++ b/webht/third_party/vendorPlanSync/models/Group_model.php @@ -176,7 +176,7 @@ class Group_model extends CI_Model { public function search_tourguide($vendor, $cn_name, $en_name=null, $mobile=null) { - $param_arr = array($cn_name); + $param_arr = array(); $en_sql = " "; if (strval($en_name)!=="") { $en_sql = " and tgi_en.TGI2_Name =? "; diff --git a/webht/third_party/vendorPlanSync/models/UserAuth_model.php b/webht/third_party/vendorPlanSync/models/UserAuth_model.php new file mode 100644 index 00000000..87cf9569 --- /dev/null +++ b/webht/third_party/vendorPlanSync/models/UserAuth_model.php @@ -0,0 +1,58 @@ +HT = $this->load->database('HT', TRUE); + } + + /*! + * TPA_Direction + * 1 外部调用我社系统 + * 2 我社调用外部系统 + * + * TPA_AccountType + * - 1* 外部调用我社系统 + * - 11 地接社 + * - 2* 我社调用外部系统 + * - 21 所属小组 + * + */ + + public function get_user_key($account_id, $account_type, $direction) + { + $sql = "SELECT * + FROM [Tourmanager].[dbo].[ThirdPartyAuth] + where TPA_Direction=? + and TPA_AccountType=? + and TPA_AccountID=? + order by TPA_ExpiredTime desc "; + return $this->HT->query($sql, array($direction, $account_type, $account_id))->row(); + } + + /*! + * 验证openID,openKey是否有效 + * @date 2018-11-29 + * @param int $open_id + * @param string $open_key + * @param integer $direction 默认是1-外部调用 + * @return boolean + */ + public function if_user_key($open_id, $open_key, $account_type, $direction=1) + { + $sql = "SELECT tpa_sn + FROM [Tourmanager].[dbo].[ThirdPartyAuth] + where tpa_direction=? + and TPA_AccountType=? + and tpa_openid=? + and tpa_openkey=? + "; + return ($this->HT->query($sql, array($direction, $account_type, $open_id, $open_key))->num_rows() > 0); + } + +} + +/* End of file UserAuth_model.php */ +/* Location: ./third_party/vendorPlanSync/models/UserAuth_model.php */