Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
weixiuhui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
蒋林
weixiuhui
Commits
bd796fa2
Commit
bd796fa2
authored
Oct 21, 2016
by
蒋林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
苏宁订单作业接口
parent
f0c864f5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
238 additions
and
48 deletions
+238
-48
database.php
application/config/production/database.php
+3
-3
SourceSuning.php
application/libraries/Source/SourceSuning.php
+235
-45
No files found.
application/config/production/database.php
View file @
bd796fa2
...
@@ -75,9 +75,9 @@ $query_builder = TRUE;
...
@@ -75,9 +75,9 @@ $query_builder = TRUE;
$db
[
'default'
]
=
array
(
$db
[
'default'
]
=
array
(
'dsn'
=>
''
,
'dsn'
=>
''
,
'hostname'
=>
'192.168.1.
181
'
,
'hostname'
=>
'192.168.1.
33:3304
'
,
'username'
=>
'pp_
share
'
,
'username'
=>
'pp_
wxh
'
,
'password'
=>
'
123456
'
,
'password'
=>
'
8v@XRSQ#EMVo!JdRUK@xvZ#Lk
'
,
'database'
=>
'pp_wxh'
,
'database'
=>
'pp_wxh'
,
'dbdriver'
=>
'mysqli'
,
'dbdriver'
=>
'mysqli'
,
'dbprefix'
=>
'wxh_'
,
'dbprefix'
=>
'wxh_'
,
...
...
application/libraries/Source/SourceSuning.php
View file @
bd796fa2
...
@@ -12,7 +12,7 @@ class SourceSuning extends Source
...
@@ -12,7 +12,7 @@ class SourceSuning extends Source
{
{
private
static
$account
=
[];
private
static
$account
=
[];
private
static
$app
=
'suning'
;
private
static
$app
=
'suning'
;
private
static
$debug
=
tru
e
;
private
static
$debug
=
fals
e
;
public
function
__construct
(
$account
)
public
function
__construct
(
$account
)
...
@@ -21,7 +21,6 @@ class SourceSuning extends Source
...
@@ -21,7 +21,6 @@ class SourceSuning extends Source
self
::
$cookieFilePath
=
PUBDIR
.
"cookie/"
.
self
::
$app
.
"_"
.
md5
(
self
::
$account
[
'username'
])
.
".cookie"
;
self
::
$cookieFilePath
=
PUBDIR
.
"cookie/"
.
self
::
$app
.
"_"
.
md5
(
self
::
$account
[
'username'
])
.
".cookie"
;
self
::
$captchaFilePath
=
PUBDIR
.
"captcha/"
.
self
::
$app
.
"_"
.
md5
(
self
::
$account
[
'username'
])
.
".gif"
;
self
::
$captchaFilePath
=
PUBDIR
.
"captcha/"
.
self
::
$app
.
"_"
.
md5
(
self
::
$account
[
'username'
])
.
".gif"
;
//判断是否登陆
//判断是否登陆
$isLogin
=
$this
->
IsLogin
();
$isLogin
=
$this
->
IsLogin
();
if
(
$isLogin
==
false
)
{
if
(
$isLogin
==
false
)
{
...
@@ -29,6 +28,177 @@ class SourceSuning extends Source
...
@@ -29,6 +28,177 @@ class SourceSuning extends Source
}
}
}
}
/**
* 服务订单作业条件
* @param int $type 1:待接收; 2:可重派; 3:待核销;
* @return array
*/
public
function
ServiceOrderCondition
(
$type
=
1
)
{
$type
=
$type
-
1
;
$post
=
[
'choosedtab'
=>
$type
];
$url
=
"https://asvp.suning.com/asvp/serviceOrder/toMain.action"
;
$headers
=
$this
->
Header
(
$url
);
$result
=
$this
->
CurlHttpsPost
(
$url
,
$post
,
$headers
);
//debug
$this
->
Debug
(
'ServiceOrderCondition'
,
$result
);
//select
preg_match_all
(
'/<div[^>]+class="fake-select-option"[^>]*>[\s\S]+?<\/div>/'
,
$result
[
'data'
],
$select
);
//debug
$this
->
Debug
(
'ServiceOrderCondition-select'
,
$select
);
$condition
=
[];
if
(
isset
(
$select
[
0
])
&&
$select
[
0
])
{
//select名称
$selectName
=
[
'siteBp'
,
'processType'
];
foreach
(
$select
[
0
]
as
$key
=>
$val
)
{
preg_match_all
(
'/<span[^>]+code="([^"]+)"[^>]*>([\s\S]+?)<\/span>/'
,
$val
,
$option
);
$temp
=
[];
foreach
(
$option
[
1
]
as
$k
=>
$v
)
{
$temp
[
$v
]
=
preg_replace
(
'/\s+/'
,
''
,
$option
[
2
][
$k
]);
}
$temp
&&
$condition
[
$selectName
[
$key
]]
=
$temp
;
}
}
return
$condition
;
}
public
function
ServiceOrderQuery
()
{
$post
=
[
'mark'
=>
'1'
,
'partner'
=>
'904102'
,
'objectId'
=>
''
,
'mobPhoneNum'
=>
''
,
'startTime'
=>
''
,
'endTime'
=>
''
,
'printTypeName'
=>
''
,
'processType'
=>
''
,
'statusName'
=>
''
,
'orderStatus'
=>
''
];
}
/**
* 服务订单作业
* @param int $type 1:待接收; 2:可重派; 3:待核销;
* @return array
*/
public
function
ServiceOrder
(
$type
=
1
)
{
$post
=
[
'choosedFlag'
=>
''
,
//类型
'siteBp'
=>
'904102'
,
//网点BP
'objectIds'
=>
''
,
//订单号,多个用(,)隔开
'applyStartTime'
=>
'2016-10-20'
,
//开始时间
'applyEndTime'
=>
'2016-11-10'
,
//结束时间
'choosedtabNow'
=>
''
,
'processTypeName'
=>
''
,
//订单类型名称
'processType'
=>
''
//订单类型编号
];
switch
(
$type
)
{
case
1
:
$post
[
'choosedFlag'
]
=
'0'
;
$post
[
'choosedtabNow'
]
=
'0'
;
$result
=
$this
->
ServiceOrderTab1
(
$post
);
break
;
default
:
$result
=
[];
}
return
$result
;
}
/**
* 返回待接收的订单数据
* @param $param
* @return array
*/
private
function
ServiceOrderTab1
(
$param
)
{
$url
=
'https://asvp.suning.com/asvp/serviceOrder/serviceOrderTab1.action'
;
$headers
=
$this
->
Header
(
$url
);
$result
=
$this
->
CurlHttpsPost
(
$url
,
$param
,
$headers
);
//debug
$this
->
Debug
(
'ServiceOrderTab1-html'
,
$result
);
//订单处理
$result
=
$this
->
HandelServiceOrder
(
$result
[
'data'
]);
return
$result
;
}
/**
* 处理订单列表数据
* @param $orderHtml
* @return array
*/
private
function
HandelServiceOrder
(
$orderHtml
)
{
$order
=
[];
//table
preg_match
(
'/<table[^>]+class="order-table-search"[^>]*>[\s\S]+?<\/table>/'
,
$orderHtml
,
$table
);
//debug
$this
->
Debug
(
'ServiceOrderTab1-table'
,
$table
);
if
(
!
isset
(
$table
[
0
])
&&
!
$table
[
0
])
{
return
$order
;
}
//tbody
preg_match
(
'/<tbody[^>]*>[\s\S]+?<\/tbody>/'
,
$table
[
0
],
$tbody
);
//debug
$this
->
Debug
(
'ServiceOrderTab1-tbody'
,
$tbody
);
if
(
!
isset
(
$tbody
[
0
])
&&
!
$tbody
[
0
])
{
return
$order
;
}
//order
preg_match_all
(
'/class="order-number"([^>]+)>/'
,
$tbody
[
0
],
$srvOrder
);
if
(
!
isset
(
$srvOrder
[
1
])
&&
!
$srvOrder
[
1
])
{
return
$order
;
}
foreach
(
$srvOrder
[
1
]
as
$key
=>
$val
)
{
$val
=
preg_replace
(
'/"\s+/'
,
'",'
,
trim
(
$val
));
$val
=
explode
(
','
,
str_replace
(
'"'
,
''
,
$val
));
if
(
!
empty
(
$val
))
{
foreach
(
$val
as
$vall
)
{
$vall
=
explode
(
"="
,
$vall
);
$order
[
$key
][
$vall
[
0
]]
=
html_entity_decode
(
$vall
[
1
]);
}
}
}
return
$order
;
}
/**
* 判断是否登录, 及手机验证登录流程
* @return bool
*/
public
function
IsLogin
()
public
function
IsLogin
()
{
{
$isLogin
=
$this
->
IsLoginHtml
();
$isLogin
=
$this
->
IsLoginHtml
();
...
@@ -73,16 +243,18 @@ class SourceSuning extends Source
...
@@ -73,16 +243,18 @@ class SourceSuning extends Source
return
$this
->
IsLoginHtml
();
return
$this
->
IsLoginHtml
();
}
}
/**
* 判断是否需要登录的页面
* @return bool
*/
public
function
IsLoginHtml
()
public
function
IsLoginHtml
()
{
{
$url
=
"https://asvp.suning.com/asvp/portal/jumpToportal.action"
;
$url
=
"https://asvp.suning.com/asvp/portal/jumpToportal.action"
;
$result
=
$this
->
GetUrlContents
(
$url
,
false
);
$result
=
$this
->
GetUrlContents
(
$url
,
false
);
$result
=
$this
->
HandelHtmlScript
(
$result
);
$result
=
$this
->
HandelHtmlScript
(
$result
);
//调试
//debug
if
(
self
::
$debug
)
{
$this
->
Debug
(
'IsLoginHtml'
,
$result
);
$this
->
Debug
(
'IsLoginHtml'
,
$result
);
}
$islogin
=
false
;
$islogin
=
false
;
if
(
stripos
(
$result
,
'showIndex.action'
)
!==
false
)
{
if
(
stripos
(
$result
,
'showIndex.action'
)
!==
false
)
{
...
@@ -92,6 +264,10 @@ class SourceSuning extends Source
...
@@ -92,6 +264,10 @@ class SourceSuning extends Source
return
$islogin
;
return
$islogin
;
}
}
/**
* 登录页面处理
* @return array
*/
public
function
Login
()
public
function
Login
()
{
{
$loginUrl
=
"https://mpassport.suning.com/ids/login?service=https%3A%2F%2Fasvp.suning.com%2Fasvp%2Fportal%2Flogon.do&loginTheme=asvp"
;
$loginUrl
=
"https://mpassport.suning.com/ids/login?service=https%3A%2F%2Fasvp.suning.com%2Fasvp%2Fportal%2Flogon.do&loginTheme=asvp"
;
...
@@ -122,6 +298,9 @@ class SourceSuning extends Source
...
@@ -122,6 +298,9 @@ class SourceSuning extends Source
//登陆返回处理
//登陆返回处理
preg_match
(
'/errorCode = "([^"]+)"/'
,
$result
[
'data'
],
$errorCode
);
preg_match
(
'/errorCode = "([^"]+)"/'
,
$result
[
'data'
],
$errorCode
);
//debug
$this
->
Debug
(
'Login'
,
[
$post
,
$result
,
$errorCode
]);
//登陆返回参数
//登陆返回参数
if
(
isset
(
$errorCode
[
1
])
&&
$errorCode
[
1
])
{
if
(
isset
(
$errorCode
[
1
])
&&
$errorCode
[
1
])
{
...
@@ -143,13 +322,16 @@ class SourceSuning extends Source
...
@@ -143,13 +322,16 @@ class SourceSuning extends Source
}
}
}
}
if
(
self
::
$debug
)
{
$this
->
Debug
(
'Login'
,
[
$post
,
$result
]);
}
return
$result
;
return
$result
;
}
}
/**
* 登录返回参数处理
* @param $errorCode
* @param $loginHtml
* @param $loginFormData
* @return array
*/
private
function
HandelLoginReturnMsg
(
$errorCode
,
$loginHtml
,
$loginFormData
)
private
function
HandelLoginReturnMsg
(
$errorCode
,
$loginHtml
,
$loginFormData
)
{
{
$result
=
[];
$result
=
[];
...
@@ -218,14 +400,18 @@ class SourceSuning extends Source
...
@@ -218,14 +400,18 @@ class SourceSuning extends Source
return
$result
;
return
$result
;
}
}
/**
* 登陆后需要手机验证的页面
* @param $checkPhoneUrl
* @return array
*/
public
function
CheckPhone
(
$checkPhoneUrl
)
public
function
CheckPhone
(
$checkPhoneUrl
)
{
{
$result
=
$this
->
GetUrlContents
(
$checkPhoneUrl
);
$result
=
$this
->
GetUrlContents
(
$checkPhoneUrl
);
$formData
=
$this
->
GetFormData
(
$result
);
$formData
=
$this
->
GetFormData
(
$result
);
if
(
self
::
$debug
)
{
//debug
$this
->
Debug
(
'CheckPhone'
,
$formData
);
$this
->
Debug
(
'CheckPhone'
,
$formData
);
}
if
(
empty
(
$formData
))
{
if
(
empty
(
$formData
))
{
return_msg
(
false
,
'手机短信验证表单参数错误'
);
return_msg
(
false
,
'手机短信验证表单参数错误'
);
...
@@ -234,15 +420,20 @@ class SourceSuning extends Source
...
@@ -234,15 +420,20 @@ class SourceSuning extends Source
return
$formData
;
return
$formData
;
}
}
/**
* 获取手机验证码
* @param int $num
* @return array|bool
*/
public
function
GetPhoneCode
(
$num
=
0
)
public
function
GetPhoneCode
(
$num
=
0
)
{
{
$result
=
parent
::
GetPhoneCode
();
$result
=
parent
::
Get
Mail
PhoneCode
();
if
(
$num
>
45
)
{
if
(
$num
>
45
)
{
return
false
;
return
false
;
}
}
if
(
$result
[
'st'
]
>
60
)
{
if
(
empty
(
$result
)
||
$result
[
'st'
]
>
15
)
{
$num
++
;
$num
++
;
sleep
(
1
);
sleep
(
1
);
return
$this
->
GetPhoneCode
(
$num
);
return
$this
->
GetPhoneCode
(
$num
);
...
@@ -251,6 +442,12 @@ class SourceSuning extends Source
...
@@ -251,6 +442,12 @@ class SourceSuning extends Source
return
$result
;
return
$result
;
}
}
/**
* 发送手机验证码
* @param $data
* @param $checkPhoneUrl
* @return array
*/
public
function
SendPhoneCode
(
$data
,
$checkPhoneUrl
)
public
function
SendPhoneCode
(
$data
,
$checkPhoneUrl
)
{
{
$sendData
=
[
$sendData
=
[
...
@@ -263,9 +460,8 @@ class SourceSuning extends Source
...
@@ -263,9 +460,8 @@ class SourceSuning extends Source
$sendPhoneCodeUrl
=
"https://masc.suning.com/masc/suspiciousOpt/toSendValCodeSuspiciousLogin.htm"
;
$sendPhoneCodeUrl
=
"https://masc.suning.com/masc/suspiciousOpt/toSendValCodeSuspiciousLogin.htm"
;
$result
=
$this
->
CurlHttpsPost
(
$sendPhoneCodeUrl
,
$sendData
,
$headers
);
$result
=
$this
->
CurlHttpsPost
(
$sendPhoneCodeUrl
,
$sendData
,
$headers
);
if
(
self
::
$debug
)
{
//debug
$this
->
Debug
(
'SendPhoneCode'
,
$sendData
);
$this
->
Debug
(
'SendPhoneCode'
,
$sendData
);
}
if
(
$result
[
'data'
]
==
6
)
{
if
(
$result
[
'data'
]
==
6
)
{
return_msg
(
false
,
'您当前累计获取验证码已达到5次,请您1小时后重新获取验证码'
);
return_msg
(
false
,
'您当前累计获取验证码已达到5次,请您1小时后重新获取验证码'
);
...
@@ -274,6 +470,12 @@ class SourceSuning extends Source
...
@@ -274,6 +470,12 @@ class SourceSuning extends Source
return
$result
;
return
$result
;
}
}
/**
* 检验手机验证码
* @param $data
* @param $checkPhoneUrl
* @return array
*/
public
function
CheckPhoneCode
(
$data
,
$checkPhoneUrl
)
public
function
CheckPhoneCode
(
$data
,
$checkPhoneUrl
)
{
{
$checkData
=
[
$checkData
=
[
...
@@ -286,13 +488,18 @@ class SourceSuning extends Source
...
@@ -286,13 +488,18 @@ class SourceSuning extends Source
$checkPhoneCodeUrl
=
"https://masc.suning.com/masc/suspiciousOpt/validateCodeSuspiciousLogin.htm"
;
$checkPhoneCodeUrl
=
"https://masc.suning.com/masc/suspiciousOpt/validateCodeSuspiciousLogin.htm"
;
$result
=
$this
->
CurlHttpsPost
(
$checkPhoneCodeUrl
,
$checkData
,
$headers
);
$result
=
$this
->
CurlHttpsPost
(
$checkPhoneCodeUrl
,
$checkData
,
$headers
);
if
(
self
::
$debug
)
{
//debug
$this
->
Debug
(
'CheckPhoneCode'
,
$checkData
);
$this
->
Debug
(
'CheckPhoneCode'
,
$checkData
);
}
return
$result
;
return
$result
;
}
}
/**
* 手机验证码检验通过后,自动登录
* @param $data
* @param $checkPhoneUrl
* @return array
*/
public
function
ToAutoLogin
(
$data
,
$checkPhoneUrl
)
public
function
ToAutoLogin
(
$data
,
$checkPhoneUrl
)
{
{
...
@@ -310,27 +517,8 @@ class SourceSuning extends Source
...
@@ -310,27 +517,8 @@ class SourceSuning extends Source
$loginUrl
=
"https://masc.suning.com/masc/suspiciousOpt/toAutoLogin.htm"
;
$loginUrl
=
"https://masc.suning.com/masc/suspiciousOpt/toAutoLogin.htm"
;
$result
=
$this
->
CurlHttpsPost
(
$loginUrl
,
$post
,
$headers
);
$result
=
$this
->
CurlHttpsPost
(
$loginUrl
,
$post
,
$headers
);
return
$result
;
//debug
}
$this
->
Debug
(
'ToAutoLogin'
,
$data
);
public
function
OrderList
()
{
$url
=
'https://asvp.suning.com/asvp/serviceOrder/serviceOrderTab1.action'
;
$post
=
[
'choosedFlag'
=>
0
,
'siteBp'
=>
904102
,
'objectIds'
=>
''
,
'applyStartTime'
=>
''
,
'applyEndTime'
=>
''
,
'choosedtabNow'
=>
0
,
'processTypeName'
=>
''
,
'processType'
=>
''
];
$headers
=
$this
->
Header
(
$url
);
$result
=
$this
->
CurlHttpsPost
(
$url
,
$post
,
$headers
);
return
$result
;
return
$result
;
}
}
...
@@ -363,10 +551,12 @@ class SourceSuning extends Source
...
@@ -363,10 +551,12 @@ class SourceSuning extends Source
private
function
Debug
(
$function
,
$data
)
private
function
Debug
(
$function
,
$data
)
{
{
if
(
self
::
$debug
)
{
echo
"
{
$function
}
<br/>"
;
echo
"
{
$function
}
<br/>"
;
echo
"<pre>"
;
echo
"<pre>"
;
print_r
(
$data
);
print_r
(
$data
);
}
}
}
private
function
CurlHttpsPost
(
$url
,
$post
,
$headers
)
private
function
CurlHttpsPost
(
$url
,
$post
,
$headers
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment