Commit 955a849f authored by 蒋林's avatar 蒋林

1. 海信系统

2. 账号密码错误提示
parent 035cb9ce
......@@ -43,7 +43,7 @@ class Galanz extends BaseController
9 => ['u' => 'W75509335', 'p' => 'szwxh!755'],
];
$key = 8;
$key = 0;
self::$testu = $account[$key]['u'];
self::$testp = $account[$key]['p'];
//self::$testp = urlencode(str_aes($account[5]['p']));
......@@ -53,7 +53,7 @@ class Galanz extends BaseController
{
$sobj = $this->sourceGalanzObj();
$order = $sobj->WorkOrderDetail('677beebf-ace7-4dc0-8a58-d2a4e7d3622');
$order = $sobj->searchOrder();
print_r($order);
}
......@@ -62,12 +62,12 @@ class Galanz extends BaseController
{
// $mail= '18611475060@163.com';
// $pwd = 'aimi1012';
//
// $mail= 'weixiuhui1688@163.com';
// $pwd = 'wxh16888';
$mail = 'wxh__8888@163.com';
$pwd = 'WXH888888';
$mail= 'weixiuhui1688@163.com';
$pwd = 'wxh16888';
// $mail = 'wxh__8888@163.com';
// $pwd = 'WXH888888';
$code = phone_code($mail, $pwd);
......
<?php
/**
* Created by PhpStorm.
* User: LinJiangL
* Date: 16/11/18
* Time: 下午1:48
*/
/**
* Class Hisense
*
* @property SourceHisense SourceHisense
* @property ReceiveHisense ReceiveHisense
*/
class Hisense extends BaseController
{
public static $testu = '';
public static $testp = '';
protected static $apiUrl = 'http://wxh.pp.cn/';
public function __construct()
{
//ini_set('display_errors', 1);
parent::__construct();
self::$apiUrl = "http://{$_SERVER['HTTP_HOST']}/";
$account = [
0 => ['u' => 'gdjdhfzh1', 'p' => 'BBb66666'],
];
$key = 0;
self::$testu = $account[$key]['u'];
self::$testp = $account[$key]['p'];
}
public function test()
{
$sobj = $this->sourceObj();
$res = $sobj->InformationFeedbackList('');
print_r($res);
}
public function param()
{
$str = "mark=1&partner=869218&objectId=&mobPhoneNum=&startTime=2016-11-09&endTime=2016-11-29&printTypeName=&processType=&statusName=&orderStatus=";
parse_str($str, $r);
$str = '';
foreach ($r as $k => $v) {
$str .= "'{$k}' => {$v},<br/>";
}
echo $str;
}
protected function show($data)
{
echo "<pre>";
print_r($data);
}
protected function sourceObj()
{
$account = [
'username' => self::$testu,
'pwd' => self::$testp
];
$this->load->library('Source/SourceHisense', $account, 'SourceHisense');
return $this->SourceHisense;
}
protected function receiveObj()
{
$this->load->library('Receive/ReceiveHisense', null, 'ReceiveHisense');
return $this->ReceiveHisense;
}
}
\ No newline at end of file
<?php
require 'Receive.php';
class ReceiveHisense extends Receive
{
}
\ No newline at end of file
......@@ -50,11 +50,12 @@ class Source
curl_setopt($curl, CURLOPT_COOKIEFILE, self::$cookieFilePath);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
$result = curl_exec($curl);
$info = curl_getinfo($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
$this->ReturnError($result, $url);
return ['code' => $code, 'data' => $result];
return ['code' => $code, 'info' => $info, 'data' => $result];
}
protected function CurlPostHttps($url, $post, $headers, $type="")
......
......@@ -20,6 +20,9 @@ class SourceGalanz extends Source
self::$cookieFilePath = PUBDIR . "cookie/galanz_". self::$account['username'] .".cookie";
self::$captchaFilePath = PUBDIR . "captcha/galanz_". self::$account['username'] .".gif";
//debug
self::$debug = false;
//判断是否登陆
$result = $this->IsLogin();
if ($result == false) {
......@@ -84,8 +87,17 @@ class SourceGalanz extends Source
}
$headers = $this->Header($loginUrl);
$result = $this->CurlPost($loginUrl, $post, $headers);
$result['data'] = gzdecode($result['data']);
return $this->CurlPost($loginUrl, $post, $headers);
//debug
$this->Debug('login', $result);
if (stripos($result['data'], '用户密码不正确') !== false) {
return_msg(false, '用户密码不正确(-10001)');
}
return $result;
}
/**
......
<?php
/**
* Created by PhpStorm.
* User: LinJiangL
* Date: 16/10/17
* Time: 下午1:35
*/
require 'Source.php';
class SourceHisense extends Source
{
private static $account = [];
private static $app = 'hisense';
public function __construct($account)
{
self::$account = $account;
self::$cookieFilePath = PUBDIR . "cookie/" . self::$app . "_" . md5(self::$account['username']) . ".cookie";
self::$captchaFilePath = PUBDIR . "captcha/" . self::$app . "_" . md5(self::$account['username']) . ".gif";
//debug
self::$debug = true;
//判断是否登陆
$result = $this->IsLogin();
if ($result == false) {
return_msg(false, '登陆失败');
} else {
$this->LoginInit();
}
}
//工单管理-工单实施-接收派工
public function AcceptAssign()
{
$url = "http://222.173.107.86/HisenseCRM/menu.do?method=setMenuLoaction&href=/HisenseCRM/acceptAssign.do?method=acceptAssign&menuName=AcceptAssign";
$result = $this->HttpCurlGet($url);
$result = $this->GbkToUtf8($result['data']);
return $result;
}
//工单管理-工单实施-信息反馈-列表
public function InformationFeedbackList($condition, $order='', $sort='', $page='1', $limit='10')
{
$post = [
'cache_row_id' => 'CC16111602468037',
'cache_area_code1' => '',
'cache_telephone' => '',
'cache_customer_name' => '',
'cache_is_return_bill' => '',
'cache_service_type' => '',
'cache_START_TIME' => '',
'cache_END_TIME' => '',
'cache_wb_status' => '',
'cache_START_require_service_date' => '',
'cache_END_require_service_date' => '',
'cache_wb_type' => '',
'cache_product_id' => '',
'cache_logo_id' => '',
'cache_if_special_deal' => '',
'cache_engineer_if_finished' => '',
'rows' => $limit, //条数
'page' => $page, //当前页
'order' => $order, //排序类型: asc, desc
'sort' => $sort, //排序字段: row_id
];
$url = "http://222.173.107.86/HisenseCRM/queryFWS.do?method=atelicinfoList3";
$hurl = "http://222.173.107.86/HisenseCRM/menu.do?method=setMenuLoaction&href=/atelic.do?method=begin&menuName=fws";
$headers = $this->Header($hurl, true);
$result = $this->HttpCurlPost($url, $post, $headers);
$info = json_decode($result['data'], true);
$info['rows'] = $this->TableTrPreg($info['rows']);
//输出字段
$filed = [
'no', //序号
'check', //
'days', //延迟天数
'out_no', //信息编号
'work_order_type', //工单类型
'feedback_people', //要求反馈人
'is_project', //工程单
'work_order_status', //工单状态
'dispatching_status', //派工状态
'is_completion', //是否完成
'customer_name', //用户姓名
'address', //详细地址
'phone', //电话
'engineer', //工程师
'acceptance_time', //服务受理时间
'product_id', //产品大类
'product_mid', //产品中类
'product_brand', //品牌
'product_type', //产品类型
'service_type', //服务类型
'service_time', //服务时间
'problem_desc', //问题描述
'fault_phenomenon', //故障现象
'fault_cause', //故障原因
'maintenance', //维修措施
'belong_branch', //所属公司
'call_center', //呼叫中心
'call_num', //联系次数
'amend_treaty', //改约
'receive_name', //接入员姓名
'customer_orgin', //客户来源
'print_num', //打印次数
'last_change', //最后修改人
'last_feedback', //最后反馈结果
];
$info['rows'] = $this->HandelFiled($filed, $info['rows']);
return $info;
}
//工单管理-工单实施-信息反馈-明细
public function InformationFeedbackDetail($outNo)
{
$url = "http://222.173.107.86/HisenseCRM/menu.do?method=setMenuLoaction&href=/HisenseCRM/QueryWb.do?method=doDetail&&row={$outNo}&menuName=undefined";
$result = $this->HttpCurlGet($url);
$result = $this->GbkToUtf8($result['data']);
return $result;
}
public function IsLogin($num = 0)
{
if ($num > 3) {
return false;
}
$isLogin = $this->IsLoginHtml();
//debug
$this->Debug('IsLogin', $isLogin);
if (!$isLogin) {
$num++;
$this->Login();
return $this->IsLogin($num);
}
return $isLogin;
}
public function IsLoginHtml()
{
$url = "http://222.173.107.86/HisenseCRM/loginext.do?method=login";
$html = $this->HttpCurlGet($url, false);
$result = false;
if (stripos($html['data'], '/HisenseCRM/IdCard.do?method=IdCardPassword') !== false) {
$result = true;
}
return $result;
}
public function LoginInit()
{
$url1 = "http://222.173.107.86/HisenseCRM/main/pages/indexCRM.jsp";
$this->HttpCurlGet($url1, false);
$url2 = "http://222.173.107.86/HisenseCRM/main/pages/callTemp.jsp";
$this->HttpCurlGet($url2, false);
$url3 = "http://222.173.107.86/HisenseCRM/main/pages/indexCRMLink.jsp";
$this->HttpCurlGet($url3, false);
}
public function Login()
{
//设置cookie
$url = "http://222.173.107.86/HisenseCRM/login.do?method=begin";
$headers = $this->Header($url);
$this->SetUrlCookie($url);
$post = [
'j_validate' => $this->GetImageCode(),
'username' => self::$account['username'],
'password' => self::$account['pwd'],
];
$url = "http://222.173.107.86/HisenseCRM/LoginCRM.do?method=validateCode";
$res1 = $this->HttpCurlPost($url, $post, $headers);
$res1['data'] = json_decode($res1['data'], true);
//debug
$this->Debug('Login1', $res1);
//账号/密码错误
if ($res1['data']['result'] != '0' || $res1['data']['msg'] != '成功') {
return_msg(false, '账户名与密码不匹配(-10001)');
}
$url = "http://222.173.107.86/HisenseCRM/LoginCRM.do?method=getPsnInfo&username=" . self::$account['username'];
$res2 = $this->HttpCurlPost($url, [], $headers);
//debug
$this->Debug('Login2', $res2);
$post1 = [
'j_validate' => $post['j_validate'],
'j_username' => $post['username'],
'j_password' => $post['password'],
];
$url = "http://222.173.107.86/HisenseCRM/j_unieap_security_check.do";
$res3 = $this->HttpCurlPost($url, $post1, $headers);
//debug
$this->Debug('Login3', $res3);
}
protected function SetLoginCookie()
{
$url = "http://222.173.107.86/HisenseCRM/login.do?method=begin";
$this->SetUrlCookie($url);
}
protected function GetImageCode()
{
$url = "http://222.173.107.86/HisenseCRM/servlet/Image";
$this->SaveUrlCaptcha($url);
return get_uuapi(self::$captchaFilePath, self::$app, self::$account['username']);
}
protected function GbkToUtf8($txt)
{
return iconv('GBK', 'UTF-8', $txt);
}
protected function GetFormData($formHtml)
{
preg_match_all('/<input[^>]+name="([^"]+)"[^>]+value="([^"]*)"/', $formHtml, $arr);
$formData = [];
if (isset($arr[1]) && $arr[1]) {
foreach ($arr[1] as $k => $v) {
$formData[$v] = $arr[2][$k];
}
}
return $formData;
}
protected function HandelFiled($filed, $data)
{
foreach ($data as $key => $val) {
$data[$key] = array_combine($filed, $val);
}
return $data;
}
protected function TableTrPreg($html)
{
$result = [];
if (empty($html)) {
return $result;
}
preg_match_all('/<tr[^>]*>[\s\S]*?<\/tr>/', $html, $tr);
if ($tr[0]) {
foreach ($tr[0] as $k => $v) {
$v && $tr[$k] = $this->TableTdPreg($v);
}
}
return $tr;
}
protected function TableTdPreg($tr)
{
preg_match_all('/<td[^>]*>[\s\S]*?<\/td>/', $tr, $td);
print_r($td);
foreach ($td[0] as $kk => $vv) {
$vv = preg_replace('/<[^>]+>/', '', $vv);
$vv = trim($vv);
$td[0][$kk] = $vv;
}
return $td[0];
}
/**
* 请求头信息
* @param $referer
* @param $json
* @return array
*/
protected function Header($referer, $json=false)
{
$parseUrl = parse_url($referer);
if ($json) {
$accept = 'application/json, text/javascript, */*; q=0.01';
} else {
$accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
}
$header = [
'Accept: ' . $accept,
'Accept-Encoding: gzip, deflate',
'Accept-Language: zh-CN,zh;q=0.8,en;q=0.6',
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8',
'Host: ' . $parseUrl['host'],
'Origin: ' . $parseUrl['scheme'] . '//' .$parseUrl['host'],
'Referer: ' . $referer,
'Proxy-Connection: keep-alive',
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36',
'X-Requested-With: XMLHttpRequest',
];
return $header;
}
protected function HttpCurlGet($url, $isCheck = true)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
curl_setopt($curl, CURLOPT_COOKIEFILE, self::$cookieFilePath);
curl_setopt($curl, CURLOPT_COOKIEJAR, self::$cookieFilePath);
$rs = curl_exec($curl); //执行cURL抓取页面内容
$info = curl_getinfo($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($isCheck) {
$this->ReturnError($rs, $url);
}
return ['code' => $code, 'info' => $info, 'data' => $rs];
}
protected function HttpCurlPost($url, $post, $headers)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
//curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
// curl_setopt($curl, CURLOPT_COOKIESESSION,true);
// curl_setopt($curl, CURLOPT_COOKIE, "JSESSIONID=00007KzdffJ7MtZuee1PXsTInSE:1a69socgn");
curl_setopt($curl, CURLOPT_COOKIEFILE, self::$cookieFilePath);
curl_setopt($curl, CURLOPT_COOKIEJAR, self::$cookieFilePath);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
$result = curl_exec($curl);
$info = curl_getinfo($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
//$this->ReturnError($result, $url);
return ['code' => $code, 'info' => $info, 'data' => $result];
}
}
\ No newline at end of file
......@@ -467,11 +467,11 @@ class SourceSuning extends Source
break;
case "badPassword.msg1":
return_msg(false, "您输入的账户名与密码不匹配,请重新输入!");
return_msg(false, "您输入的账户名与密码不匹配,请重新输入!(-10001)");
break;
case "badPassword.msg2":
return_msg(false, "您输入的账户名与密码不匹配,请重新输入!重试次数过多,账号将会被锁定。");
return_msg(false, "您输入的账户名与密码不匹配,请重新输入!重试次数过多,账号将会被锁定。(-10001)");
break;
case "badVerifyCode":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment