接口调用账户验证; 测试返回数据

feature/pay
lyt 7 years ago
parent 1bd077bf52
commit 0e77b42fc5

@ -114,9 +114,10 @@ class Tulanduo extends CI_Controller
$last_date = count($grd_info)-1; $last_date = count($grd_info)-1;
$end_date = $grd_info[$last_date]->day_no_raw; $end_date = $grd_info[$last_date]->day_no_raw;
$request_info = $this->Group_model->get_plan_request($gri_sn); $request_info = $this->Group_model->get_plan_request($gri_sn);
$order_type = 1;
$this->tldOrderBuilder->setUserId($userId) $this->tldOrderBuilder->setUserId($userId)
->setKey($userKey) ->setKey($userKey)
->setOrderType(1) ->setOrderType($order_type)
->setRouteName($routeName) ->setRouteName($routeName)
->setRouteType($routeType) ->setRouteType($routeType)
->setAgcOrderNo($agcOrderNo) ->setAgcOrderNo($agcOrderNo)
@ -183,7 +184,7 @@ class Tulanduo extends CI_Controller
} }
} }
// 查询是否变更 // 查询是否变更
$sync_orderstate = 1; $sync_orderstate = 10;
$vps_sn = 0; $vps_sn = 0;
$vendor_orderid = 0; $vendor_orderid = 0;
$modifyLogInfo = "<br>$change_info<br>"; $modifyLogInfo = "<br>$change_info<br>";
@ -203,11 +204,32 @@ class Tulanduo extends CI_Controller
// $this->tldOrderBuilder->setModifyLogInfo($modifyLogInfo) // $this->tldOrderBuilder->setModifyLogInfo($modifyLogInfo)
; ;
} }
return $this->tldOrderBuilder->getBizContent();
// $resp = $this->excute_curl($this->neworder_url, $this->tldOrderBuilder); // $resp = $this->excute_curl($this->neworder_url, $this->tldOrderBuilder);
// $response = json_decode($resp); $resp = '{"status":1,"errMsg":"","responseData":{"orderId":' . rand(1000,9999) . '}}'; // test
// return $resp; $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. ";
} }
/*! /*!

@ -13,16 +13,13 @@ class Index extends CI_Controller {
$this->load->model('Group_model'); $this->load->model('Group_model');
$this->load->model('BIZ_Orders_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() public function index()
{ {
$vendor_plan = $this->Group_model->get_vendor_plan_info(214600, 1343); $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); 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['status'] = -1;
$ret['errMsg'] = "未知错误"; $ret['errMsg'] = "未知错误";
$input = $this->input->post(); $user_verify = $this->verify_user();
$vendorID = $input['openId']; if ($user_verify !== TRUE) {
$validate = $this->calc_key($vendorID, $input['key']); $ret['errMsg'] = '用户验证失败';
if ($validate !== TRUE) {
$ret['errMsg'] = "身份验证失败.";
return $this->output->set_content_type('application/json')->set_output(json_encode($ret)); 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']); $vps = $this->Group_model->get_sync_info_by_vendororder($input['orderId']);
if (empty($vps)) { if (empty($vps)) {
$ret['errMsg'] = "未找到相应的订单."; $ret['errMsg'] = "未找到相应的订单.";
@ -178,7 +183,7 @@ class Index extends CI_Controller {
{ {
$default = "b825e39422a54875a95752fc7ed6f5d2"; $default = "b825e39422a54875a95752fc7ed6f5d2";
$ret = md5(hash("sha256", $userId.$default)); $ret = md5(hash("sha256", $userId.$default));
return $ret===$key; return $ret;
} }
} }

@ -9,27 +9,21 @@ class UserAuth_model extends CI_Model {
} }
/*! /*!
* TPA_Direction
* 1 外部调用我社系统
* 2 我社调用外部系统
* *
* TPA_AccountType * TPA_AccountType
* - 1* 外部调用我社系统 * - 1 地接社
* - 11 地接社
* - 2* 我社调用外部系统
* - 21 所属小组
* *
*/ */
public function get_user_key($account_id, $account_type, $direction) public function get_user_key($account_id, $account_type)
{ {
$sql = "SELECT * $sql = "SELECT *
FROM [Tourmanager].[dbo].[ThirdPartyAuth] FROM [Tourmanager].[dbo].[ThirdPartyAuth]
where TPA_Direction=? where 1=1
and TPA_AccountType=? and TPA_AccountType=?
and TPA_AccountID=? and TPA_AccountID=?
order by TPA_ExpiredTime desc "; 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-外部调用 * @param integer $direction 默认是1-外部调用
* @return boolean * @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 $sql = "SELECT tpa_sn
FROM [Tourmanager].[dbo].[ThirdPartyAuth] FROM [Tourmanager].[dbo].[ThirdPartyAuth]
where tpa_direction=? where 1=1
and TPA_AccountType=? and TPA_AccountType=?
and tpa_openid=? and TPA_OpenId=?
and tpa_openkey=? 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);
} }
} }

Loading…
Cancel
Save