Commit 1a287fb3 authored by 蒋林's avatar 蒋林

海信-对外接口

parent 94e16b4e
<?php
/**
* Created by PhpStorm.
* User: LinJiangL
* Date: 16/10/24
* Time: 上午10:54
*/
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Class Hisense 海信相关接口
*
* @property api_log_model api_log_model
* @property SourceHisense SourceHisense
* @property ReceiveHisense ReceiveHisense
*/
class Hisense extends BaseController
{
public function __construct()
{
parent::__construct();
ini_set("max_execution_time", 1800);
}
public function informationFeedbackCondition()
{
$param = $this->input->post();
//验证参数
$obj = $this->receiveObj();
$obj->SetValues($param);
$obj->CheckValues();
$values = $obj->GetValues();
$this->saveLog('', 'informationFeedbackCondition', $values);
$sourceObj = $this->sourceObj($values['account'], $values['pwd']);
$result = $sourceObj->InformationFeedbackCondition();
$obj->ReturnMessage(true, '', $result);
}
public function informationFeedbackList()
{
$param = $this->input->post();
//验证参数
$obj = $this->receiveObj();
$obj->SetValues($param);
$obj->CheckInformationFeedbackListValues();
$values = $obj->GetValues();
$this->saveLog('', 'informationFeedbackList', $values);
$sourceObj = $this->sourceObj($values['account'], $values['pwd']);
$result = $sourceObj->InformationFeedbackList($values);
$obj->ReturnMessage(true, '', $result);
}
public function informationFeedbackDetail()
{
$param = $this->input->post();
//验证参数
$obj = $this->receiveObj();
$obj->SetValues($param);
$obj->CheckInformationFeedbackDetailValues();
$values = $obj->GetValues();
$this->saveLog($values['out_no'], 'informationFeedbackList', $values);
$sourceObj = $this->sourceObj($values['account'], $values['pwd']);
$result = $sourceObj->InformationFeedbackDetail($values['out_no']);
$obj->ReturnMessage(true, '', $result);
}
/**
* 保存日志
*
* @param $search
* @param $method
* @param $data
*/
protected function saveLog($search, $method, $data)
{
//记录日志
$this->load->model('api_log_model');
$this->api_log_model->add($search, 'hisense', $method, $data);
}
protected function sourceObj($username, $pwd)
{
$account = [
'username' => $username,
'pwd' => $pwd
];
$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
...@@ -58,11 +58,96 @@ class Hisense extends BaseController ...@@ -58,11 +58,96 @@ class Hisense extends BaseController
echo $str; echo $str;
} }
public function informationFeedbackCondition()
{
$obj = $this->receiveObj();
$data = [
'appid' => '10001',
'account' => self::$testu,
'pwd' => self::$testp,
];
$data['nonce_str'] = $obj->GetNonceStr();
$obj->SetValues($data);
$obj->SetSign();
$values = $obj->GetValues();
$url = self::$apiUrl . "api/hisense/informationFeedbackCondition";
$result = curl_post($url, $values);
$this->show($result);
}
public function informationFeedbackList()
{
$obj = $this->receiveObj();
$data = [
'appid' => '10001',
'account' => self::$testu,
'pwd' => self::$testp,
'out_no' => '',
'area_code' => '',
'phone' => '',
'customer_name' => '',
'return_bill' => '',
'service_type' => '',
'start_time' => '201611270120',
'end_time' => '201611280120',
'wb_status' => '',
'service_stime' => '20161127',
'service_etime' => '20161128',
'wb_type' => '',
'product_id' => '',
'login_id' => '',
'special_deal' => '',
'engineer_finished' => '',
];
$data['nonce_str'] = $obj->GetNonceStr();
$obj->SetValues($data);
$obj->SetSign();
$values = $obj->GetValues();
$url = self::$apiUrl . "api/hisense/informationFeedbackList";
$result = curl_post($url, $values);
$this->show($result);
}
public function informationFeedbackDetail()
{
$obj = $this->receiveObj();
$data = [
'appid' => '10001',
'account' => self::$testu,
'pwd' => self::$testp,
'out_no' => 'CC16112702933567'
];
$data['nonce_str'] = $obj->GetNonceStr();
$obj->SetValues($data);
$obj->SetSign();
$values = $obj->GetValues();
$url = self::$apiUrl . "api/hisense/informationFeedbackDetail";
$result = curl_post($url, $values);
$this->show($result);
}
protected function show($data) protected function show($data)
{ {
$ss = json_decode($data['data'], true);
echo "<pre>"; echo "<pre>";
echo $data['data'];
echo "<br/>";
print_r($data); print_r($data);
echo "<br/>";
print_r($ss);
} }
protected function sourceObj() protected function sourceObj()
......
...@@ -172,7 +172,7 @@ class Receive ...@@ -172,7 +172,7 @@ class Receive
* 检查参数 * 检查参数
* @param array $fields * @param array $fields
*/ */
protected function CheckValues($fields = []) public function CheckValues($fields = [])
{ {
if (!$this->GetValues()) { if (!$this->GetValues()) {
$this->ReturnMessage(false, '参数错误!'); $this->ReturnMessage(false, '参数错误!');
...@@ -213,7 +213,7 @@ class Receive ...@@ -213,7 +213,7 @@ class Receive
* 给指定参数增加默认值 * 给指定参数增加默认值
* @param $fields * @param $fields
*/ */
protected function SetDefaultValues($fields) public function SetDefaultValues($fields)
{ {
if ($fields) { if ($fields) {
foreach ($fields as $v) { foreach ($fields as $v) {
...@@ -226,7 +226,7 @@ class Receive ...@@ -226,7 +226,7 @@ class Receive
} }
} }
protected function SelectValues($val, $options, $default='') public function SelectValues($val, $options, $default='')
{ {
if ($val == '') { if ($val == '') {
return $val; return $val;
...@@ -235,7 +235,7 @@ class Receive ...@@ -235,7 +235,7 @@ class Receive
return isset($options[$val]) ? $options[$val] : $default; return isset($options[$val]) ? $options[$val] : $default;
} }
protected function IntValues($val, $out='int') public function IntValues($val, $out='int')
{ {
if ($val == '') { if ($val == '') {
return $val; return $val;
...@@ -246,7 +246,7 @@ class Receive ...@@ -246,7 +246,7 @@ class Receive
return $out=='int' ? $val : strval($val); return $out=='int' ? $val : strval($val);
} }
protected function DateFormatValues($date, $format='Y-m-d') public function DateFormatValues($date, $format='Y-m-d')
{ {
if ($date == '') { if ($date == '') {
return $date; return $date;
...@@ -255,7 +255,7 @@ class Receive ...@@ -255,7 +255,7 @@ class Receive
return date($format, strtotime($date)); return date($format, strtotime($date));
} }
protected function TimeFormatValues($time, $format='Y-m-d') public function TimeFormatValues($time, $format='Y-m-d')
{ {
if ($time == '') { if ($time == '') {
return $time; return $time;
......
...@@ -5,6 +5,42 @@ require 'Receive.php'; ...@@ -5,6 +5,42 @@ require 'Receive.php';
class ReceiveHisense extends Receive class ReceiveHisense extends Receive
{ {
public function CheckInformationFeedbackListValues()
{
$fileds = [];
$this->CheckValues($fileds);
$dfields = [
'out_no',
'area_code',
'phone',
'customer_name',
'return_bill',
'service_type',
'start_time',
'end_time',
'wb_status',
'service_stime',
'service_etime',
'wb_type',
'product_id',
'login_id',
'special_deal',
'engineer_finished',
];
$this->SetDefaultValues($dfields);
$this->values['start_time'] = $this->DateFormatValues($this->values['start_time'], 'Y-m-d H:i');
$this->values['end_time'] = $this->DateFormatValues($this->values['end_time'], 'Y-m-d H:i');
$this->values['service_stime'] = $this->DateFormatValues($this->values['service_stime']);
$this->values['service_etime'] = $this->DateFormatValues($this->values['service_etime']);
}
public function CheckInformationFeedbackDetailValues()
{
$fileds = ['out_no'];
$this->CheckValues($fileds);
}
} }
\ No newline at end of file
...@@ -69,28 +69,33 @@ class SourceHisense extends Source ...@@ -69,28 +69,33 @@ class SourceHisense extends Source
public function InformationFeedbackList($condition, $order='', $sort='', $page='1', $limit='10') public function InformationFeedbackList($condition, $order='', $sort='', $page='1', $limit='10')
{ {
$post = [ $post = [
'cache_row_id' => isset($condition['out_no']) ? $condition['out_no'] : '', 'cache_row_id' => isset($condition['out_no']) ? $condition['out_no'] : '', //信息编号
'cache_area_code1' => isset($condition['area_code']) ? $condition['area_code'] : '', 'cache_area_code1' => isset($condition['area_code']) ? $condition['area_code'] : '', //区号
'cache_telephone' => isset($condition['phone']) ? $condition['phone'] : '', 'cache_telephone' => isset($condition['phone']) ? $condition['phone'] : '', //用户电话
'cache_customer_name' => isset($condition['customer_name']) ? $condition['customer_name'] : '', 'cache_customer_name' => isset($condition['customer_name']) ? $condition['customer_name'] : '', //用户姓名
'cache_is_return_bill' => isset($condition['return_bill']) ? $condition['return_bill'] : '', 'cache_is_return_bill' => isset($condition['return_bill']) ? $condition['return_bill'] : '', //是否回访退单
'cache_service_type' => isset($condition['service_type']) ? $condition['service_type'] : '', 'cache_service_type' => isset($condition['service_type']) ? $condition['service_type'] : '', //实际服务类型
'cache_START_TIME' => isset($condition['start_time']) ? $condition['start_time'] : '', 'cache_START_TIME' => isset($condition['start_time']) ? $condition['start_time'] : '', //登记时间 格式:Y-m-d H:i
'cache_END_TIME' => isset($condition['end_time']) ? $condition['end_time'] : '', 'cache_END_TIME' => isset($condition['end_time']) ? $condition['end_time'] : '',
'cache_wb_status' => isset($condition['wb_status']) ? $condition['wb_status'] : '', 'cache_wb_status' => isset($condition['wb_status']) ? $condition['wb_status'] : '', //工单状态
'cache_START_require_service_date' => isset($condition['service_stime']) ? $condition['service_stime'] : '', 'cache_START_require_service_date' => isset($condition['service_stime']) ? $condition['service_stime'] : '', //要求服务时间 格式: Y-m-d
'cache_END_require_service_date' => isset($condition['service_etime']) ? $condition['service_etime'] : '', 'cache_END_require_service_date' => isset($condition['service_etime']) ? $condition['service_etime'] : '',
'cache_wb_type' => isset($condition['wb_type']) ? $condition['wb_type'] : '', 'cache_wb_type' => isset($condition['wb_type']) ? $condition['wb_type'] : '', //工单类型
'cache_product_id' => isset($condition['product_id']) ? $condition['product_id'] : '', 'cache_product_id' => isset($condition['product_id']) ? $condition['product_id'] : '', //产品大类
'cache_logo_id' => isset($condition['login_id']) ? $condition['login_id'] : '', 'cache_logo_id' => isset($condition['login_id']) ? $condition['login_id'] : '', //品牌
'cache_if_special_deal' => isset($condition['special_deal']) ? $condition['special_deal'] : '', 'cache_if_special_deal' => isset($condition['special_deal']) ? $condition['special_deal'] : '', //是否特殊申请
'cache_engineer_if_finished' => isset($condition['engineer_finished']) ? $condition['engineer_finished'] : '', 'cache_engineer_if_finished' => isset($condition['engineer_finished']) ? $condition['engineer_finished'] : '', //工程师是否完成
'rows' => $limit, //条数 'rows' => $limit, //条数
'page' => $page, //当前页 'page' => $page, //当前页
'order' => $order, //排序类型: asc, desc 'order' => $order, //排序类型: asc, desc
'sort' => $sort, //排序字段: row_id 'sort' => $sort, //排序字段: row_id
]; ];
//debug
$this->Debug('InformationFeedbackList-post', $post);
//return_msg(true, '', $post);
$url = "http://222.173.107.86/HisenseCRM/queryFWS.do?method=atelicinfoList3"; $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"; $hurl = "http://222.173.107.86/HisenseCRM/menu.do?method=setMenuLoaction&href=/atelic.do?method=begin&menuName=fws";
$headers = $this->Header($hurl, true); $headers = $this->Header($hurl, true);
...@@ -138,7 +143,7 @@ class SourceHisense extends Source ...@@ -138,7 +143,7 @@ class SourceHisense extends Source
$info['rows'] = $this->HandelFiled($filed, $info['rows']); $info['rows'] = $this->HandelFiled($filed, $info['rows']);
return $info; return $info['rows'];
} }
//工单管理-工单实施-信息反馈-明细 //工单管理-工单实施-信息反馈-明细
...@@ -479,6 +484,15 @@ class SourceHisense extends Source ...@@ -479,6 +484,15 @@ class SourceHisense extends Source
protected function HandelFiled($filed, $data) protected function HandelFiled($filed, $data)
{ {
foreach ($data as $key => $val) { foreach ($data as $key => $val) {
//检查字段
if ($key == 0) {
$filedl = count($filed);
$orderl = count($val);
if ($filedl != $orderl) {
return_msg(false, '列表列字段有变化,请联系服务商.', [['fieldl' => $filedl, 'orderl' => $orderl]]);
}
}
$data[$key] = array_combine($filed, $val); $data[$key] = array_combine($filed, $val);
} }
......
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