CT分销商系统的接口文件
parent
83f8351ffe
commit
3d25adf592
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class TrainDMS extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model("dms_model");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 接口总汇,根据接受数据,调用不同接口,返回数据
|
||||
* @return {*}
|
||||
* @Date Changed:
|
||||
*/
|
||||
public function dmsCallback(){
|
||||
$back_json = file_get_contents('php://input');
|
||||
$dms_backdata = json_decode($back_json);
|
||||
|
||||
if(!empty($dms_backdata)){
|
||||
//判断接口调用是否合法
|
||||
$TimeStamp = $dms_backdata->authentication->timeStamp;
|
||||
$serviceName = $dms_backdata->authentication->serviceName; //每个接口都有自己名称
|
||||
$companyId = "haina";
|
||||
$key = "dms001";
|
||||
|
||||
$strSign = $TimeStamp.$serviceName.$companyId.$key; //加密前的令牌
|
||||
$Sign = md5($strSign);
|
||||
$messageIdentity = $dms_backdata->authentication->messageIdentity;
|
||||
$ResultNoticeResponse = new stdClass();
|
||||
if ($Sign == $messageIdentity){
|
||||
$ResultNoticeResponse->returnCode = 1;
|
||||
$ResultNoticeResponse->returnMsg = "success";
|
||||
//这里正常处理各种接口调用
|
||||
if ($serviceName=="dms.login"){ //登录
|
||||
$username = $dms_backdata->loginInfo->username;
|
||||
$password = $dms_backdata->loginInfo->password;
|
||||
$ResultNoticeResponse->loginInfo = new stdClass();
|
||||
$LoginInfo = $this->dms_model->Login($username,$password);
|
||||
if (empty($LoginInfo)){
|
||||
$ResultNoticeResponse->loginInfo->status = 0; //账号密码错误。
|
||||
$ResultNoticeResponse->loginInfo->dt_username = '';
|
||||
$ResultNoticeResponse->loginInfo->dt_payrule = "";
|
||||
$ResultNoticeResponse->loginInfo->dt_usertype = "";
|
||||
$ResultNoticeResponse->loginInfo->dt_HtId = "";
|
||||
$ResultNoticeResponse->loginInfo->dt_id = "";
|
||||
}else{
|
||||
$ResultNoticeResponse->loginInfo->status = 1; //账号密码是否正常。
|
||||
$ResultNoticeResponse->loginInfo->dt_username = $LoginInfo->dt_username;
|
||||
$ResultNoticeResponse->loginInfo->dt_payrule = $LoginInfo->dt_payrule;
|
||||
$ResultNoticeResponse->loginInfo->dt_usertype = $LoginInfo->dt_usertype;
|
||||
$ResultNoticeResponse->loginInfo->dt_HtId = $LoginInfo->dt_HtId;
|
||||
$ResultNoticeResponse->loginInfo->dt_id = $LoginInfo->dt_id;
|
||||
}
|
||||
|
||||
}else if($serviceName=="dms.dmlist"){ //分销商列表
|
||||
$arrKeyword = new stdClass();
|
||||
$arrKeyword = $dms_backdata->arrKeyword;
|
||||
|
||||
$dmlist = $this->dms_model->get_DmList($arrKeyword);
|
||||
$resultData = $dmlist["data"];
|
||||
$total = $dmlist["total"];
|
||||
$ResultNoticeResponse->dmlist = new stdClass();
|
||||
$ResultNoticeResponse->dmlist->data=$resultData;
|
||||
$ResultNoticeResponse->dmlist->total = $total;
|
||||
// "arrKeyword": {
|
||||
// "s_username": "ssss",
|
||||
// "s_ename": "vvv",
|
||||
// "page": false,
|
||||
// "per_page": 20
|
||||
// }
|
||||
}else if($serviceName=="dms.getpayrule"){ //获取支付规则列表数据
|
||||
$getpayrule = $this->dms_model->get_payrule();
|
||||
$ResultNoticeResponse->getpayrule = $getpayrule;
|
||||
}else if ($serviceName=="dms.addsave"){ //添加供应商操作
|
||||
$formData = new stdClass() ;
|
||||
$formData = $dms_backdata->formInfo;
|
||||
$rStatus = $this->dms_model->addsave($formData);
|
||||
$ResultNoticeResponse->addsave = $rStatus;
|
||||
}else if ($serviceName=="dms.getDmsDetail") { //修改分销商详细页
|
||||
$id = $dms_backdata->DmsDetail->dtid;
|
||||
$dmsDetail = $this->dms_model->getDmsDetail($id);
|
||||
$ResultNoticeResponse->DmsDetail = $dmsDetail;
|
||||
}else if ($serviceName=="dms.editsave"){ //修改分销商保存
|
||||
|
||||
$formData = new stdClass() ;
|
||||
$formData = $dms_backdata->formInfo;
|
||||
$rStatus = $this->dms_model->editsave($formData);
|
||||
$ResultNoticeResponse->editsave = $rStatus;
|
||||
}else if ($serviceName=="dms.delete"){ //删除分销商
|
||||
$id = $dms_backdata->DmsDetail->dtid;
|
||||
$rStatus = $this->dms_model->dmdDelete($id);
|
||||
$ResultNoticeResponse->dmsdelete = $rStatus;
|
||||
}else if ($serviceName == "dms.payrecord"){ //支付记录
|
||||
$arrKeyword = new stdClass();
|
||||
$arrKeyword = $dms_backdata->arrKeyword;
|
||||
$payrecord = $this->dms_model->payrecord($arrKeyword);
|
||||
$resultData = $payrecord["data"];
|
||||
$total = $payrecord["total"];
|
||||
$ResultNoticeResponse->payrecord = new stdClass();
|
||||
$ResultNoticeResponse->payrecord->data=$resultData;
|
||||
$ResultNoticeResponse->payrecord->total = $total;
|
||||
}else if ($serviceName=="dms.payrecord_addsave"){ //支付记录添加
|
||||
$formData = new stdClass() ;
|
||||
$formData = $dms_backdata->formInfo;
|
||||
$rStatus = $this->dms_model->payrecord_addsave($formData);
|
||||
$ResultNoticeResponse->addsave = $rStatus;
|
||||
}else if ($serviceName=="dms.payrecord_delete"){ //支付记录删除
|
||||
$id = $dms_backdata->payrecord->dp_id;
|
||||
$htid = $dms_backdata->payrecord->dp_HtId;
|
||||
$rStatus = $this->dms_model->payrecord_delete($id,$htid);
|
||||
$ResultNoticeResponse->dmsdelete = $rStatus;
|
||||
}else if ($serviceName=="dms.trainorder"){ //订单列表-火车
|
||||
$arrKeyword = new stdClass();
|
||||
$arrKeyword = $dms_backdata->arrKeyword;
|
||||
$trainorder = $this->dms_model->trainorder($arrKeyword);
|
||||
$resultData = $trainorder["data"];
|
||||
$total = $trainorder["total"];
|
||||
$ResultNoticeResponse->trainorder = new stdClass();
|
||||
$ResultNoticeResponse->trainorder->data=$resultData;
|
||||
$ResultNoticeResponse->trainorder->total = $total;
|
||||
}else if ($serviceName == "dms.dmslisteasy"){ //所有分销商数据,下拉框使用
|
||||
$getdmseasy = $this->dms_model->get_dmseasy();
|
||||
$ResultNoticeResponse->getpayrule = $getdmseasy;
|
||||
}else if ($serviceName=="dms.getpaydetail"){ //获取某一个分销商的所有财务信息
|
||||
$id = $dms_backdata->htid;
|
||||
$getpaydetail = $this->dms_model->get_paydetail($id);
|
||||
$ResultNoticeResponse->getpaydetail = $getpaydetail;
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
$ResultNoticeResponse->returnCode = 0;
|
||||
$ResultNoticeResponse->returnMsg = "messageIdentity is error!";
|
||||
}
|
||||
echo json_encode($ResultNoticeResponse);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @return {*}
|
||||
* @Date Changed:
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function login (){
|
||||
|
||||
}
|
||||
|
||||
public function addUser(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file TrainDMS.php */
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
class Des
|
||||
{
|
||||
|
||||
function encrypt($string,$key)
|
||||
{
|
||||
$size = mcrypt_get_block_size('des','ecb');
|
||||
//$string = mb_convert_encoding($string, 'GBK', 'UTF-8');
|
||||
$string = $this->pkcs5_pad($string, $size);
|
||||
$td = mcrypt_module_open('des', '', 'ecb', '');
|
||||
$iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
|
||||
@mcrypt_generic_init($td, $key, $iv);
|
||||
$data = mcrypt_generic($td, $string);
|
||||
mcrypt_generic_deinit($td);
|
||||
mcrypt_module_close($td);
|
||||
$data = base64_encode($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
function decrypt($string,$key)
|
||||
{
|
||||
$string = base64_decode($string);
|
||||
$td = mcrypt_module_open('des', '', 'ecb', '');
|
||||
//使用MCRYPT_DES算法,cbc模式
|
||||
$iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
|
||||
$ks = mcrypt_enc_get_key_size($td);
|
||||
@mcrypt_generic_init($td, $key, $iv);
|
||||
//初始处理
|
||||
$decrypted = mdecrypt_generic($td, $string);
|
||||
//解密
|
||||
mcrypt_generic_deinit($td);
|
||||
//结束
|
||||
mcrypt_module_close($td);
|
||||
|
||||
$result = $this->pkcs5_unpad($decrypted);
|
||||
//$result = mb_convert_encoding($result, 'UTF-8', 'GBK');
|
||||
return $result;
|
||||
}
|
||||
|
||||
function pkcs5_pad($text, $blocksize)
|
||||
{
|
||||
$pad = $blocksize - (strlen($text) % $blocksize);
|
||||
return $text . str_repeat(chr($pad), $pad);
|
||||
}
|
||||
|
||||
function pkcs5_unpad($text)
|
||||
{
|
||||
$pad = ord($text{strlen($text) - 1});
|
||||
if ($pad > strlen($text)) {
|
||||
return false;
|
||||
}
|
||||
if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) {
|
||||
return false;
|
||||
}
|
||||
return substr($text, 0, -1 * $pad);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue