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

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;
$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 = "<br>$change_info<br>";
@ -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. ";
}
/*!

@ -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;
}
}

@ -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);
}
}

Loading…
Cancel
Save