Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TopUpCambodian-java
Overview
Overview
Details
Activity
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
TopUpCambodian-java
Commits
3ae2713a
Commit
3ae2713a
authored
Jan 07, 2020
by
yanlveming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步
parent
1018d0bd
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
876 additions
and
28 deletions
+876
-28
.gitignore
+43
-0
src/com/library/TopUp/Statel/HttpClientResult.java
+55
-0
src/com/library/TopUp/Statel/HttpClientUtils.java
+387
-0
src/com/library/TopUp/Statel/SeatelSentUtils.java
+159
-0
src/com/library/TopUp/cellcard/HttpClientUtils.java
+2
-2
src/com/library/TopUp/mefont/MetfoneRSAUtils.java
+16
-7
src/com/library/TopUp/mefont/MetfoneSentUtils.java
+6
-1
src/com/library/TopUp/smart/HttpClientUtils.java
+2
-2
src/com/library/TopUp/smart/SmartSentUtils.java
+4
-0
src/com/library/controller/CommonController.java
+162
-0
src/com/library/service/AutomaticCodeService.java
+1
-1
src/com/library/service/Impl/AutomaticCodeServiceImpl.java
+17
-15
src/com/library/test/ylmTest.java
+22
-0
No files found.
.gitignore
0 → 100644
View file @
3ae2713a
*.class
*/build/*
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
#kdiff3 ignore
*.orig
#maven ignore
.settings
.classpatch
.classpath
.project
.myumldata
#idea
.idea/
/idea/
*.ipr
*.iml
*.iws
# temp file
*.log
*.cache
*.diff
*.patch
*.tmp
# system ignore
.DS_StoreThumbs.db
/target/
/out/
*/out/*
/CoordinationTools
src/com/library/TopUp/Statel/HttpClientResult.java
0 → 100644
View file @
3ae2713a
package
com
.
library
.
TopUp
.
Statel
;
import
java.io.Serializable
;
/**
* Description: 封装httpClient响应结果
*
* @author JourWon
* @date Created on 2018年4月19日
*/
public
class
HttpClientResult
implements
Serializable
{
public
HttpClientResult
(){
}
public
HttpClientResult
(
int
code
)
{
this
.
code
=
code
;
this
.
content
=
""
;
}
public
HttpClientResult
(
int
code
,
String
content
)
{
this
.
code
=
code
;
this
.
content
=
content
;
}
/**
* 响应状态码
*/
private
int
code
;
/**
* 响应数据
*/
private
String
content
;
public
int
getCode
()
{
return
code
;
}
public
void
setCode
(
int
code
)
{
this
.
code
=
code
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
}
src/com/library/TopUp/Statel/HttpClientUtils.java
0 → 100644
View file @
3ae2713a
package
com
.
library
.
TopUp
.
Statel
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.HttpStatus
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.*
;
import
org.apache.http.client.utils.URIBuilder
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.message.BasicHeader
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.protocol.HTTP
;
import
org.apache.http.util.EntityUtils
;
import
java.io.*
;
import
java.util.*
;
/**
* Description: httpClient工具类
*
* @author JourWon
* @date Created on 2018年4月19日
*/
public
class
HttpClientUtils
{
// 编码格式。发送编码格式统一用UTF-8
private
static
final
String
ENCODING
=
"UTF-8"
;
// 设置连接超时时间,单位毫秒。
private
static
final
int
CONNECT_TIMEOUT
=
10000
;
// 请求获取数据的超时时间(即响应时间),单位毫秒。
private
static
final
int
SOCKET_TIMEOUT
=
10000
;
/**
* 发送get请求;不带请求头和请求参数
*
* @param url 请求地址
* @return
* @throws Exception
*/
public
static
HttpClientResult
doGet
(
String
url
)
throws
Exception
{
return
doGet
(
url
,
null
,
null
);
}
/**
* 发送get请求;带请求参数
*
* @param url 请求地址
* @param params 请求参数集合
* @return
* @throws Exception
*/
public
static
HttpClientResult
doGet
(
String
url
,
Map
<
String
,
String
>
params
)
throws
Exception
{
return
doGet
(
url
,
null
,
params
);
}
/**
* 发送get请求;带请求头和请求参数
*
* @param url 请求地址
* @param headers 请求头集合
* @param params 请求参数集合
* @return
* @throws Exception
*/
public
static
HttpClientResult
doGet
(
String
url
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
params
)
throws
Exception
{
// 创建httpClient对象
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
// 创建访问的地址
URIBuilder
uriBuilder
=
new
URIBuilder
(
url
);
if
(
params
!=
null
)
{
Set
<
Map
.
Entry
<
String
,
String
>>
entrySet
=
params
.
entrySet
();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
entrySet
)
{
uriBuilder
.
setParameter
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
// 创建http对象
HttpGet
httpGet
=
new
HttpGet
(
uriBuilder
.
build
());
/**
* setConnectTimeout:设置连接超时时间,单位毫秒。
* setConnectionRequestTimeout:设置从connect Manager(连接池)获取Connection
* 超时时间,单位毫秒。这个属性是新加的属性,因为目前版本是可以共享连接池的。
* setSocketTimeout:请求获取数据的超时时间(即响应时间),单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。
*/
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
CONNECT_TIMEOUT
).
setSocketTimeout
(
SOCKET_TIMEOUT
).
build
();
httpGet
.
setConfig
(
requestConfig
);
// 设置请求头
packageHeader
(
headers
,
httpGet
);
// 创建httpResponse对象
CloseableHttpResponse
httpResponse
=
null
;
try
{
// 执行请求并获得响应结果
return
getHttpClientResult
(
httpResponse
,
httpClient
,
httpGet
);
}
finally
{
// 释放资源
release
(
httpResponse
,
httpClient
);
}
}
/**
* 发送post请求;不带请求头和请求参数
*
* @param url 请求地址
* @return
* @throws Exception
*/
public
static
HttpClientResult
doPost
(
String
url
)
throws
Exception
{
return
doPost
(
url
,
null
,
null
);
}
/**
* 发送post请求;带请求参数
*
* @param url 请求地址
* @param params 参数集合
* @return
* @throws Exception
*/
public
static
HttpClientResult
doPost
(
String
url
,
Map
<
String
,
String
>
params
)
throws
Exception
{
return
doPost
(
url
,
null
,
params
);
}
/**
* 发送post请求;带请求头和请求参数
*
* @param url 请求地址
* @param headers 请求头集合
* @param params 请求参数集合
* @return
* @throws Exception
*/
public
static
HttpClientResult
doPost
(
String
url
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
params
)
throws
Exception
{
// 创建httpClient对象
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
// 创建http对象
HttpPost
httpPost
=
new
HttpPost
(
url
);
/**
* setConnectTimeout:设置连接超时时间,单位毫秒。
* setConnectionRequestTimeout:设置从connect Manager(连接池)获取Connection
* 超时时间,单位毫秒。这个属性是新加的属性,因为目前版本是可以共享连接池的。
* setSocketTimeout:请求获取数据的超时时间(即响应时间),单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。
*/
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
CONNECT_TIMEOUT
).
setSocketTimeout
(
SOCKET_TIMEOUT
).
build
();
httpPost
.
setConfig
(
requestConfig
);
// 设置请求头
/*httpPost.setHeader("Cookie", "");
httpPost.setHeader("Connection", "keep-alive");
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Accept-Language", "zh-CN,zh;q=0.9");
httpPost.setHeader("Accept-Encoding", "gzip, deflate, br");
httpPost.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36");*/
packageHeader
(
headers
,
httpPost
);
System
.
out
.
println
(
"URL: "
+
url
);
// 封装请求参数
packageParam
(
params
,
httpPost
);
// 创建httpResponse对象
CloseableHttpResponse
httpResponse
=
null
;
try
{
// 执行请求并获得响应结果
return
getHttpClientResult
(
httpResponse
,
httpClient
,
httpPost
);
}
finally
{
// 释放资源
release
(
httpResponse
,
httpClient
);
}
}
/**
* 发送put请求;不带请求参数
*
* @param url 请求地址
* @return
* @throws Exception
*/
public
static
HttpClientResult
doPut
(
String
url
)
throws
Exception
{
return
doPut
(
url
);
}
/**
* 发送put请求;带请求参数
*
* @param url 请求地址
* @param params 参数集合
* @return
* @throws Exception
*/
public
static
HttpClientResult
doPut
(
String
url
,
Map
<
String
,
String
>
params
)
throws
Exception
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
HttpPut
httpPut
=
new
HttpPut
(
url
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
CONNECT_TIMEOUT
).
setSocketTimeout
(
SOCKET_TIMEOUT
).
build
();
httpPut
.
setConfig
(
requestConfig
);
packageParam
(
params
,
httpPut
);
CloseableHttpResponse
httpResponse
=
null
;
try
{
return
getHttpClientResult
(
httpResponse
,
httpClient
,
httpPut
);
}
finally
{
release
(
httpResponse
,
httpClient
);
}
}
/**
* 发送delete请求;不带请求参数
*
* @param url 请求地址
* @return
* @throws Exception
*/
public
static
HttpClientResult
doDelete
(
String
url
)
throws
Exception
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
HttpDelete
httpDelete
=
new
HttpDelete
(
url
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
CONNECT_TIMEOUT
).
setSocketTimeout
(
SOCKET_TIMEOUT
).
build
();
httpDelete
.
setConfig
(
requestConfig
);
CloseableHttpResponse
httpResponse
=
null
;
try
{
return
getHttpClientResult
(
httpResponse
,
httpClient
,
httpDelete
);
}
finally
{
release
(
httpResponse
,
httpClient
);
}
}
/**
* 发送delete请求;带请求参数
*
* @param url 请求地址
* @param params 参数集合
* @return
* @throws Exception
*/
public
static
HttpClientResult
doDelete
(
String
url
,
Map
<
String
,
String
>
params
)
throws
Exception
{
if
(
params
==
null
)
{
params
=
new
HashMap
<
String
,
String
>();
}
params
.
put
(
"_method"
,
"delete"
);
return
doPost
(
url
,
params
);
}
/**
* Description: 封装请求头
*
* @param params
* @param httpMethod
*/
public
static
void
packageHeader
(
Map
<
String
,
String
>
params
,
HttpRequestBase
httpMethod
)
{
// 封装请求头
if
(
params
!=
null
)
{
Set
<
Map
.
Entry
<
String
,
String
>>
entrySet
=
params
.
entrySet
();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
entrySet
)
{
// 设置到请求头到HttpRequestBase对象中
httpMethod
.
setHeader
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
}
/**
* Description: 封装请求参数
*
* @param params
* @param httpMethod
* @throws UnsupportedEncodingException
*/
public
static
void
packageParam
(
Map
<
String
,
String
>
params
,
HttpEntityEnclosingRequestBase
httpMethod
)
throws
UnsupportedEncodingException
{
// 封装请求参数
if
(
params
!=
null
)
{
List
<
NameValuePair
>
nvps
=
new
ArrayList
<
NameValuePair
>();
Set
<
Map
.
Entry
<
String
,
String
>>
entrySet
=
params
.
entrySet
();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
entrySet
)
{
nvps
.
add
(
new
BasicNameValuePair
(
entry
.
getKey
(),
entry
.
getValue
()));
System
.
out
.
println
(
""
+
entry
.
getKey
()
+
" : "
+
entry
.
getValue
());
}
// 设置到请求的http对象中
httpMethod
.
setEntity
(
new
UrlEncodedFormEntity
(
nvps
,
ENCODING
));
}
}
/**
* Description: 获得响应结果
*
* @param httpResponse
* @param httpClient
* @param httpMethod
* @return
* @throws Exception
*/
public
static
HttpClientResult
getHttpClientResult
(
CloseableHttpResponse
httpResponse
,
CloseableHttpClient
httpClient
,
HttpRequestBase
httpMethod
)
throws
Exception
{
// 执行请求
httpResponse
=
httpClient
.
execute
(
httpMethod
);
// 获取返回结果
if
(
httpResponse
!=
null
&&
httpResponse
.
getStatusLine
()
!=
null
)
{
String
content
=
""
;
if
(
httpResponse
.
getEntity
()
!=
null
)
{
content
=
EntityUtils
.
toString
(
httpResponse
.
getEntity
(),
ENCODING
);
}
return
new
HttpClientResult
(
httpResponse
.
getStatusLine
().
getStatusCode
(),
content
);
}
return
new
HttpClientResult
(
HttpStatus
.
SC_INTERNAL_SERVER_ERROR
);
}
/**
* Description: 释放资源
*
* @param httpResponse
* @param httpClient
* @throws IOException
*/
public
static
void
release
(
CloseableHttpResponse
httpResponse
,
CloseableHttpClient
httpClient
)
throws
IOException
{
// 释放资源
if
(
httpResponse
!=
null
)
{
httpResponse
.
close
();
}
if
(
httpClient
!=
null
)
{
httpClient
.
close
();
}
}
public
static
String
postWithJson
(
String
json
,
String
URL
,
Map
<
String
,
String
>
headers
)
{
HttpClient
client
=
new
DefaultHttpClient
();
HttpPost
post
=
new
HttpPost
(
URL
);
String
result
=
""
;
//加入请求头
packageHeader
(
headers
,
post
);
try
{
StringEntity
s
=
new
StringEntity
(
json
,
"utf-8"
);
s
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
"application/json"
));
post
.
setEntity
(
s
);
// 发送请求
HttpResponse
httpResponse
=
client
.
execute
(
post
);
// 获取响应输入流
InputStream
inStream
=
httpResponse
.
getEntity
().
getContent
();
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
inStream
,
"utf-8"
));
StringBuilder
strber
=
new
StringBuilder
();
String
line
=
null
;
while
((
line
=
reader
.
readLine
())
!=
null
)
strber
.
append
(
line
+
"\n"
);
inStream
.
close
();
result
=
strber
.
toString
();
// System.out.println(result);
System
.
out
.
println
(
httpResponse
.
getStatusLine
().
getStatusCode
()
+
" ==== "
+
HttpStatus
.
SC_OK
);
if
(
httpResponse
.
getStatusLine
().
getStatusCode
()
==
HttpStatus
.
SC_OK
||
httpResponse
.
getStatusLine
().
getStatusCode
()
==
HttpStatus
.
SC_CREATED
)
{
System
.
out
.
println
(
"请求服务器成功,做相应处理"
);
}
else
{
System
.
out
.
println
(
"请求服务端失败"
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"请求异常"
);
throw
new
RuntimeException
(
e
);
}
return
result
;
}
}
src/com/library/TopUp/Statel/SeatelSentUtils.java
0 → 100644
View file @
3ae2713a
package
com
.
library
.
TopUp
.
Statel
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
com.library.TopUp.Http.HttpUtils
;
import
com.library.TopUp.Http.HttpsTool
;
import
com.library.TopUp.model.ResultsModel
;
import
com.wechat.pay.MD5Util
;
import
org.apache.http.util.TextUtils
;
import
java.net.URLEncoder
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Random
;
public
class
SeatelSentUtils
{
public
final
static
String
url
=
"http://172.22.188.20:11999/SeatelPayment/pay.jsp"
;
//测试
// public final static String url = "http://172.22.188.20:11800/SeatelPayment/pay.jsp";//生产
private
final
static
String
shopid
=
"shoptest"
;
private
final
static
String
private_key
=
"9834a62b4ec7c78a5424932bfdedfd74"
;
private
final
static
String
terminalid
=
"shoptest0001"
;
/**
* 检查手机是否能充值
*
* @param phone
* @return
*/
public
static
String
checkPhone
(
String
phone
)
{
try
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
time
=
sdf
.
format
(
new
Date
());
String
cmd
=
"queryphonenumberstatus"
;
String
terminaltrace
=
"shoptest186"
+
new
Random
().
nextInt
(
10000
);
Map
params
=
new
HashMap
();
params
.
put
(
"cmd"
,
cmd
);
params
.
put
(
"shopid"
,
shopid
);
params
.
put
(
"terminalid"
,
terminalid
);
params
.
put
(
"terminaltrace"
,
terminaltrace
);
params
.
put
(
"transtime"
,
time
);
params
.
put
(
"phone"
,
phone
);
params
.
put
(
"signtype"
,
"MD5"
);
String
sign
=
getSignStr
(
cmd
,
terminaltrace
,
time
,
phone
);
params
.
put
(
"sign"
,
sign
);
Map
<
String
,
String
>
heardMap
=
new
HashMap
<>();
heardMap
.
put
(
"Content-Type"
,
"application/json"
);
heardMap
.
put
(
"Accept"
,
"application/json"
);
// HttpClientResult clientResult = HttpClientUtils.doGet(url, heardMap, params);
String
json
=
HttpClientUtils
.
postWithJson
(
new
Gson
().
toJson
(
params
),
url
,
heardMap
);
return
json
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
/**
* 检查手机是否能充值
*
* @return
*/
public
static
String
queryAgentFee
()
{
try
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
time
=
sdf
.
format
(
new
Date
());
String
cmd
=
"queryagentfee"
;
String
terminaltrace
=
"shoptest183"
+
new
Random
().
nextInt
(
10000
);
Map
params
=
new
HashMap
();
params
.
put
(
"cmd"
,
cmd
);
params
.
put
(
"shopid"
,
shopid
);
params
.
put
(
"terminalid"
,
terminalid
);
params
.
put
(
"terminaltrace"
,
terminaltrace
);
params
.
put
(
"transtime"
,
time
);
params
.
put
(
"signtype"
,
"MD5"
);
String
sign
=
getSignStr
(
cmd
,
terminaltrace
,
time
,
""
);
params
.
put
(
"sign"
,
sign
);
Map
<
String
,
String
>
heardMap
=
new
HashMap
<>();
heardMap
.
put
(
"Content-Type"
,
"application/json"
);
heardMap
.
put
(
"Accept"
,
"application/json"
);
// String json = HttpUtils.post(url, params, heardMap, 10000, 10000, "utf-8");
String
json
=
HttpsTool
.
send
(
new
Gson
().
toJson
(
params
),
heardMap
,
url
,
"utf-8"
,
"utf-8"
,
10000
,
10000
,
"application/json"
);
return
json
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
private
static
String
getSignStr
(
String
cmd
,
String
terminaltrace
,
String
transtime
,
String
phone
)
{
String
str
=
cmd
+
""
+
shopid
+
terminalid
+
terminaltrace
+
transtime
+
phone
+
private_key
;
String
md5Text
=
MD5Util
.
MD5Encode
(
str
,
""
);
return
md5Text
;
}
public
static
void
main
(
String
[]
args
)
{
String
phone
=
"0189464112"
;
String
json
=
checkPhone
(
phone
);
System
.
out
.
println
(
json
);
// ResultsModel resultsModel = sentTopUp(phone, 1, "99999912");
//
// System.out.println("充值是否成功:" + resultsModel.isSuccessful());
// System.out.println("充值日志:" + resultsModel.getTip());
}
/**
* 发送Smart充值请求
*
* @param phone 手机号
* @param topUpAmount 单位1美元,里面已经做了1分钱转1元的处理了
* @param orderNum 需要确保唯一性,建议使用订单id
*/
public
static
ResultsModel
sentTopUp
(
String
phone
,
int
topUpAmount
,
String
orderNum
)
{
String
tip
=
""
;
boolean
topUpSuccess
=
false
;
try
{
ResultsModel
resultsModel
=
new
ResultsModel
(
topUpSuccess
,
tip
);
return
resultsModel
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
ResultsModel
resultsModel
=
new
ResultsModel
(
topUpSuccess
,
tip
);
return
resultsModel
;
}
}
}
src/com/library/TopUp/cellcard/HttpClientUtils.java
View file @
3ae2713a
...
...
@@ -27,10 +27,10 @@ public class HttpClientUtils {
private
static
final
String
ENCODING
=
"UTF-8"
;
// 设置连接超时时间,单位毫秒。
private
static
final
int
CONNECT_TIMEOUT
=
6
000
;
private
static
final
int
CONNECT_TIMEOUT
=
10
000
;
// 请求获取数据的超时时间(即响应时间),单位毫秒。
private
static
final
int
SOCKET_TIMEOUT
=
6
000
;
private
static
final
int
SOCKET_TIMEOUT
=
10
000
;
/**
* 发送get请求;不带请求头和请求参数
...
...
src/com/library/TopUp/mefont/MetfoneRSAUtils.java
View file @
3ae2713a
...
...
@@ -4,6 +4,7 @@ import org.apache.commons.codec.binary.Base64;
import
javax.crypto.Cipher
;
import
java.io.FileInputStream
;
import
java.net.URLDecoder
;
import
java.security.KeyFactory
;
import
java.security.PrivateKey
;
import
java.security.PublicKey
;
...
...
@@ -12,12 +13,16 @@ import java.security.spec.X509EncodedKeySpec;
public
class
MetfoneRSAUtils
{
final
static
String
pripath
=
"
./src
/com/library/TopUp/mefont/keys/ePayTest.pri"
;
final
static
String
pubpath
=
"
./src
/com/library/TopUp/mefont/keys/ePayTest.pub"
;
final
static
String
pripath
=
"/com/library/TopUp/mefont/keys/ePayTest.pri"
;
final
static
String
pubpath
=
"/com/library/TopUp/mefont/keys/ePayTest.pub"
;
public
static
String
encryptRSA
(
String
plainData
)
{
try
{
FileInputStream
fis
=
new
FileInputStream
(
pubpath
);
String
path
=
MetfoneRSAUtils
.
class
.
getResource
(
"/"
).
toString
();
path
=
path
.
substring
(
6
,
path
.
length
()
-
1
);
path
=
URLDecoder
.
decode
(
path
)
+
pubpath
;
FileInputStream
fis
=
new
FileInputStream
(
path
);
byte
[]
byteKeyFromFile
=
new
byte
[
fis
.
available
()];
fis
.
read
(
byteKeyFromFile
);
fis
.
close
();
...
...
@@ -39,7 +44,11 @@ public class MetfoneRSAUtils {
public
static
String
decryptRSA
(
String
encryptedData
)
{
try
{
FileInputStream
fis
=
new
FileInputStream
(
pripath
);
String
path
=
MetfoneRSAUtils
.
class
.
getResource
(
"/"
).
toString
();
path
=
path
.
substring
(
6
,
path
.
length
()
-
1
);
path
=
URLDecoder
.
decode
(
path
)
+
pripath
;
FileInputStream
fis
=
new
FileInputStream
(
path
);
byte
[]
byteKeyFromFile
=
new
byte
[
fis
.
available
()];
fis
.
read
(
byteKeyFromFile
);
fis
.
close
();
...
...
@@ -67,7 +76,7 @@ public class MetfoneRSAUtils {
"7hdb4bGn1/15+M4C3OlpOcp7PuFzBuDO1HRkoLXeayFhMKoLHBj1s0wWaFHbPQIYxpCBFW6lzdO"
+
"6rVVuhA1YoaoKNZOnYk9fVZ+vQUj5nY2i4yH8u4GJKw=="
;
String
token2
=
"iljUgme83Rj3dCvhFHwFdBB+DXkPpmxTjSFGlsjJJeXQRmQRP62lO9lNYGBkz827TPOjrycRg0BuPLH4I497iuMo7LUMt0mg3C7B3ejRkgcqWoiQxaSjB79mQa8lip/w6Q9S74Wwim/tDw/horrQ/a50+sTe+UYuHh1hjwnr61KQwieNDRFC3rYxeA5WkwpMCVQMHWfTqK3mPjXHqJgoMySUekg0NCbYQYmqWsgetakUuSlaKmrjpK90WfjOsnIeuTWEYHh+tlrI3VVIGF/Pknw6xzLOG+rTi1IZ7RkuHKh8nbiR4uLDkXpvGiiL1Hiq3H2Sz897MZKs1HeqWdrMng=="
;
String
token2
=
"iljUgme83Rj3dCvhFHwFdBB+DXkPpmxTjSFGlsjJJeXQRmQRP62lO9lNYGBkz827TPOjrycRg0BuPLH4I497iuMo7LUMt0mg3C7B3ejRkgcqWoiQxaSjB79mQa8lip/w6Q9S74Wwim/tDw/horrQ/a50+sTe+UYuHh1hjwnr61KQwieNDRFC3rYxeA5WkwpMCVQMHWfTqK3mPjXHqJgoMySUekg0NCbYQYmqWsgetakUuSlaKmrjpK90WfjOsnIeuTWEYHh+tlrI3VVIGF/Pknw6xzLOG+rTi1IZ7RkuHKh8nbiR4uLDkXpvGiiL1Hiq3H2Sz897MZKs1HeqWdrMng=="
;
// System.out.println(System.getProperty("user.dir"));
...
...
@@ -78,8 +87,8 @@ public class MetfoneRSAUtils {
String
retStr
=
encryptRSA
(
encryptText
);
System
.
out
.
println
(
"解密后的数据:"
+
str
);
System
.
out
.
println
(
"加上PIN加密的数据:"
+
retStr
);
System
.
out
.
println
(
"解密后的数据:"
+
str
);
System
.
out
.
println
(
"加上PIN加密的数据:"
+
retStr
);
}
...
...
src/com/library/TopUp/mefont/MetfoneSentUtils.java
View file @
3ae2713a
...
...
@@ -8,6 +8,8 @@ import com.library.TopUp.Http.HttpsTool;
import
com.library.TopUp.model.ResultsModel
;
import
org.apache.http.util.TextUtils
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -222,7 +224,10 @@ public class MetfoneSentUtils {
public
static
void
main
(
String
[]
args
)
{
String
phone
=
"0979530750"
;
ResultsModel
resultsModel
=
sentTopUp
(
phone
,
1
,
"123124"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyMMddHHmmss"
);
String
hms
=
sdf
.
format
(
new
Date
());
ResultsModel
resultsModel
=
sentTopUp
(
phone
,
1
,
hms
);
System
.
out
.
println
(
"充值日志:"
+
resultsModel
.
getTip
());
System
.
out
.
println
(
"充值状态:"
+
resultsModel
.
isSuccessful
());
System
.
out
.
println
(
"拓展字段:"
+
resultsModel
.
getExpandText
());
...
...
src/com/library/TopUp/smart/HttpClientUtils.java
View file @
3ae2713a
...
...
@@ -33,10 +33,10 @@ public class HttpClientUtils {
private
static
final
String
ENCODING
=
"UTF-8"
;
// 设置连接超时时间,单位毫秒。
private
static
final
int
CONNECT_TIMEOUT
=
6
000
;
private
static
final
int
CONNECT_TIMEOUT
=
10
000
;
// 请求获取数据的超时时间(即响应时间),单位毫秒。
private
static
final
int
SOCKET_TIMEOUT
=
6
000
;
private
static
final
int
SOCKET_TIMEOUT
=
10
000
;
/**
* 发送get请求;不带请求头和请求参数
...
...
src/com/library/TopUp/smart/SmartSentUtils.java
View file @
3ae2713a
...
...
@@ -233,6 +233,10 @@ public class SmartSentUtils {
boolean
topUpSuccess
=
false
;
try
{
//以0开头,去掉0
if
(
phone
.
startsWith
(
"0"
))
{
phone
=
phone
.
substring
(
1
);
}
String
json
=
getToken
();
/**
...
...
src/com/library/controller/CommonController.java
View file @
3ae2713a
package
com
.
library
.
controller
;
import
com.google.gson.Gson
;
import
com.library.TopUp.Http.HttpUtils
;
import
com.library.TopUp.Statel.HttpClientUtils
;
import
com.library.TopUp.Statel.SeatelSentUtils
;
import
com.library.TopUp.cellcard.CellcardSentUtils
;
import
com.library.respcode.ServerResponse
;
import
com.library.service.AdminService
;
import
com.library.service.CommService
;
import
com.library.util.QiniuUtils
;
import
com.wechat.pay.MD5Util
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.annotation.Resource
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Random
;
/*
* @项目名: yunVpay
...
...
@@ -59,4 +69,156 @@ public class CommonController {
return
ServerResponse
.
createBySuccess
(
json
);
}
//登录
@ResponseBody
@RequestMapping
(
"test2"
)
private
ServerResponse
test2
()
{
String
phone
=
"0189464112"
;
String
json
=
SeatelSentUtils
.
checkPhone
(
phone
);
return
ServerResponse
.
createBySuccess
(
json
);
}
//登录
@ResponseBody
@RequestMapping
(
"test3"
)
private
ServerResponse
test3
()
{
String
json
=
SeatelSentUtils
.
queryAgentFee
();
return
ServerResponse
.
createBySuccess
(
json
);
}
final
String
url
=
"http://172.22.188.20:11999/SeatelPayment/pay.jsp"
;
//测试
// public final static String url = "http://172.22.188.20:11800/SeatelPayment/pay.jsp";//生产
final
String
shopid
=
"shoptest"
;
final
String
private_key
=
"9834a62b4ec7c78a5424932bfdedfd74"
;
final
String
terminalid
=
"shoptest0001"
;
@ResponseBody
@RequestMapping
(
"test11"
)
private
ServerResponse
test11
()
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
time
=
sdf
.
format
(
new
Date
());
String
cmd
=
"queryphonenumberstatus"
;
String
terminaltrace
=
"shoptest186"
+
new
Random
().
nextInt
(
10000
);
String
phone
=
"0189464112"
;
Map
params
=
new
HashMap
();
params
.
put
(
"cmd"
,
cmd
);
params
.
put
(
"shopid"
,
shopid
);
params
.
put
(
"terminalid"
,
terminalid
);
params
.
put
(
"terminaltrace"
,
terminaltrace
);
params
.
put
(
"transtime"
,
time
);
params
.
put
(
"phone"
,
phone
);
params
.
put
(
"signtype"
,
"MD5"
);
String
sign
=
getSignStr
(
cmd
,
terminaltrace
,
time
,
phone
);
params
.
put
(
"sign"
,
sign
);
Map
<
String
,
String
>
heardMap
=
new
HashMap
<>();
heardMap
.
put
(
"Content-Type"
,
"application/json"
);
heardMap
.
put
(
"Accept"
,
"application/json"
);
// HttpClientResult clientResult = HttpClientUtils.doGet(url, heardMap, params);
String
json
=
HttpClientUtils
.
postWithJson
(
new
Gson
().
toJson
(
params
),
url
,
heardMap
);
return
ServerResponse
.
createBySuccess
(
json
);
}
@ResponseBody
@RequestMapping
(
"test12"
)
private
ServerResponse
test12
()
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
time
=
sdf
.
format
(
new
Date
());
String
cmd
=
"queryphonenumberstatus"
;
String
terminaltrace
=
"shoptest186"
+
new
Random
().
nextInt
(
10000
);
String
phone
=
"0189464112"
;
Map
params
=
new
HashMap
();
params
.
put
(
"cmd"
,
cmd
);
params
.
put
(
"shopid"
,
shopid
);
params
.
put
(
"terminalid"
,
terminalid
);
params
.
put
(
"terminaltrace"
,
terminaltrace
);
params
.
put
(
"transtime"
,
time
);
params
.
put
(
"phone"
,
phone
);
params
.
put
(
"signtype"
,
"MD5"
);
String
sign
=
getSignStr
(
cmd
,
terminaltrace
,
time
,
phone
);
params
.
put
(
"sign"
,
sign
);
Map
<
String
,
String
>
heardMap
=
new
HashMap
<>();
heardMap
.
put
(
"Content-Type"
,
"application/json"
);
heardMap
.
put
(
"Accept"
,
"application/json"
);
// HttpClientResult clientResult = HttpClientUtils.doGet(url, heardMap, params);
// String json = HttpClientUtils.postWithJson(new Gson().toJson(params), url, heardMap);
String
json
=
HttpUtils
.
post
(
url
,
params
,
heardMap
,
30000
,
30000
,
"utf-8"
);
return
ServerResponse
.
createBySuccess
(
json
);
}
@ResponseBody
@RequestMapping
(
"test13"
)
private
ServerResponse
test13
()
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
time
=
sdf
.
format
(
new
Date
());
String
cmd
=
"queryphonenumberstatus"
;
String
terminaltrace
=
"shoptest186"
+
new
Random
().
nextInt
(
10000
);
String
phone
=
"0189464112"
;
Map
params
=
new
HashMap
();
params
.
put
(
"cmd"
,
cmd
);
params
.
put
(
"shopid"
,
shopid
);
params
.
put
(
"terminalid"
,
terminalid
);
params
.
put
(
"terminaltrace"
,
terminaltrace
);
params
.
put
(
"transtime"
,
time
);
params
.
put
(
"phone"
,
phone
);
params
.
put
(
"signtype"
,
"MD5"
);
String
sign
=
getSignStr
(
cmd
,
terminaltrace
,
time
,
phone
);
params
.
put
(
"sign"
,
sign
);
Map
<
String
,
String
>
heardMap
=
new
HashMap
<>();
heardMap
.
put
(
"Content-Type"
,
"application/json"
);
heardMap
.
put
(
"Accept"
,
"application/json"
);
// HttpClientResult clientResult = HttpClientUtils.doGet(url, heardMap, params);
// String json = HttpClientUtils.postWithJson(new Gson().toJson(params), url, heardMap);
String
strJson
=
"{"
+
"\"cmd\":"
+
"\""
+
cmd
+
"\""
+
","
+
"\"shopid\":"
+
"\""
+
shopid
+
"\""
+
","
+
"\"terminalid\":"
+
"\""
+
terminalid
+
"\""
+
","
+
"\"terminaltrace\":"
+
"\""
+
terminaltrace
+
"\""
+
","
+
"\"transtime\":"
+
"\""
+
time
+
"\""
+
","
+
"\"phone\":"
+
"\""
+
phone
+
"\""
+
","
+
"\"signtype\":"
+
"\""
+
"MD5"
+
"\""
+
","
+
"\"sign\":"
+
"\""
+
sign
+
"\""
+
","
+
"}"
;
String
json
=
HttpClientUtils
.
postWithJson
(
strJson
,
url
,
heardMap
);
return
ServerResponse
.
createBySuccess
(
json
);
}
private
String
getSignStr
(
String
cmd
,
String
terminaltrace
,
String
transtime
,
String
phone
)
{
String
str
=
cmd
+
""
+
shopid
+
terminalid
+
terminaltrace
+
transtime
+
phone
+
private_key
;
String
md5Text
=
MD5Util
.
MD5Encode
(
str
,
""
);
return
md5Text
;
}
}
src/com/library/service/AutomaticCodeService.java
View file @
3ae2713a
...
...
@@ -37,7 +37,7 @@ public interface AutomaticCodeService {
* @param success 成功=true,失败=false
* @param desc 描述 (失败的订单要描述失败的原因)
*/
public
void
automaticForTackResult
(
AutomaticQueueModel
early
,
boolean
success
,
String
desc
);
public
void
automaticForTackResult
(
AutomaticQueueModel
early
,
boolean
success
,
String
desc
,
String
top_up_num
);
/***
*
* Description:人工转自动处理
...
...
src/com/library/service/Impl/AutomaticCodeServiceImpl.java
View file @
3ae2713a
...
...
@@ -21,6 +21,8 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.sql.Timestamp
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.regex.Pattern
;
...
...
@@ -69,6 +71,8 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
//自动处理状态说明
String
desc
=
""
;
AutomaticQueueModel
automaticQueueModel
=
null
;
String
top_up_num
=
""
;
try
{
automaticQueueModel
=
(
AutomaticQueueModel
)
TransformationTools
.
ToObjectOne
(
AutomaticQueueModel
.
class
,
map
);
// 修改状态
...
...
@@ -85,18 +89,14 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
//添加订单操作日志
currencyMapper
.
AddTableForMysql
(
TransformationTools
.
CreatAddMysql
(
orderLogModel
,
NameValue
.
Table_order_log
,
"id"
,
null
));
// //去充值
// Paygo24Utils paygo = new Paygo24Utils();
// String result = paygo.payment(automaticQueueModel.getOrder_phone(), automaticQueueModel.getSegment_id(), automaticQueueModel.getOrder_money());
// desc = result;//描述
// if (result.equals(Paygo24Utils.SUCCESS)) {
// success = true;
// } else {
// success = false;
// }
//生成充值的订单编号。每次都会变,以后可能会复查使用到。
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
top_up_num
=
sdf
.
format
(
new
Date
());
//去充值
ResultsModel
resultsModel
=
sentTopup
(
automaticQueueModel
);
ResultsModel
resultsModel
=
sentTopup
(
automaticQueueModel
,
top_up_num
);
desc
=
resultsModel
.
getTip
();
success
=
resultsModel
.
isSuccessful
();
...
...
@@ -106,7 +106,7 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
}
// 自动处理结果
this
.
automaticForTackResult
(
automaticQueueModel
,
success
,
desc
);
this
.
automaticForTackResult
(
automaticQueueModel
,
success
,
desc
,
top_up_num
);
}
}
...
...
@@ -115,12 +115,12 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
private
final
static
String
SegmentType_Smart
=
"Smart"
;
private
final
static
String
SegmentType_Seatel
=
"Seatel"
;
private
ResultsModel
sentTopup
(
AutomaticQueueModel
automaticQueueModel
)
{
private
ResultsModel
sentTopup
(
AutomaticQueueModel
automaticQueueModel
,
String
top_up_num
)
{
ResultsModel
resultsModel
=
null
;
try
{
//
订单id 统一一下长度八位数
String
orderNumId
=
String
.
valueOf
(
automaticQueueModel
.
getOrder_code_id
()
+
10000000
)
;
//
充值订单编号
String
orderNumId
=
top_up_num
;
//通过手机前三位获取到运营商
String
phoneThree
=
automaticQueueModel
.
getOrder_phone
().
substring
(
0
,
3
);
...
...
@@ -169,7 +169,7 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
//自动处理结果
@Override
public
void
automaticForTackResult
(
AutomaticQueueModel
early
,
boolean
success
,
String
desc
)
{
public
void
automaticForTackResult
(
AutomaticQueueModel
early
,
boolean
success
,
String
desc
,
String
top_up_num
)
{
Timestamp
newTime
=
new
Timestamp
(
System
.
currentTimeMillis
());
if
(
success
)
{
//充值成功
try
{
...
...
@@ -178,6 +178,7 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
orderModel
.
setState
(
3
);
orderModel
.
setPaygo_time
(
newTime
);
orderModel
.
setPaygo_remark
(
desc
);
orderModel
.
setTop_up_num
(
top_up_num
);
//更新订单表的状态
currencyMapper
.
updateTableForMysql
(
TransformationTools
.
CreatUpdateMysql
(
orderModel
,
NameValue
.
Table_order
,
"id"
,
null
));
...
...
@@ -203,6 +204,7 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
OrderModel
orderModel
=
(
OrderModel
)
TransformationTools
.
ToObjectOne
(
OrderModel
.
class
,
mapOrder
);
orderModel
.
setState
(
4
);
orderModel
.
setPaygo_remark
(
desc
+
"-处理时间:"
+
newTime
);
orderModel
.
setTop_up_num
(
top_up_num
);
//更新订单表的状态
currencyMapper
.
updateTableForMysql
(
TransformationTools
.
CreatUpdateMysql
(
orderModel
,
NameValue
.
Table_order
,
"id"
,
null
));
...
...
src/com/library/test/ylmTest.java
View file @
3ae2713a
...
...
@@ -9,8 +9,10 @@ import javax.xml.datatype.DatatypeConfigurationException;
import
javax.xml.datatype.DatatypeFactory
;
import
javax.xml.datatype.XMLGregorianCalendar
;
import
java.sql.Timestamp
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.GregorianCalendar
;
import
java.util.Random
;
/**
* Created by Administrator on 2018\10\31 0031.
...
...
@@ -20,6 +22,26 @@ public class ylmTest {
//{"status":0,"code":"MSG_SUCCESS","message":"Success","txDetail":{"transDetailId":4551,"transDetailCode":"37363eef5895e3b0db52f3f79f611251","merchantId":null,"merchantCode":"ePayTest","merchantServiceId":null,"merchantServiceType":"TOPUP","transTime":1577946364313,"emServiceProvideId":null,"emServiceId":null,"emServiceCode":null,"status":1,"paymentType":null,"refId":"1121","transDescription":null,"transAmount":1.0,"currencyCode":"USD","transAmountConvert":null,"currencyExchangeRate":null,"acceptPaymentCurrencyCode":null,"discountType":"1","discountAmount":0.05,"commissionAmount":null,"transFee":0.0,"transTotalAmount":0.95,"transTotalAmountConvert":null,"customerPhoneNumber":"855883970777","customerName":null,"description":null,"paidTime":null,"paidTid":null,"paidEmoneyAccount":null,"paidFee":null,"paidChanel":null,"paidAmount":null,"paidCurrencyCode":null,"paidTip":null,"paidTotalAmount":null,"emCoporationId":null,"emCoporationMsisdn":null,"txPaymentTokenId":"S6a6oWb3RB2YAU48Wy6RbZwT01AUTh10xtNvcqOgMib32KB+KnUy68bVTm/G0GPKMRUHEM4OqAsYGxOKpkgANCDtX133IKCmw2+Y9OhUQkQOUq8HAD4EySiM0GZ/xkbJey9dPYmebRCouy5iwRl7acQbuMsHWsTCc7CEFUFNyyZzkGKjOXW8v/nq5tB7D/lxeXsspd9rHURVC4gc/NDU7MZPRxd4QPMMyRR2tZ7xHxIOXt6map1msd7Ce5uMD5mgFgNnyc4IVitNbAqGJuBeR3ixWYlaLF41LqJXgMwvGMhMbcAGlPzTMw97dREegXWCnpi4iLygk5tieyUZ5S34hg==","paymentQrCode":null},"pinCode":null,"billPaymentInfo":null}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyMMddHHmmss"
);
String
hms
=
sdf
.
format
(
new
Date
());
System
.
out
.
println
(
hms
);
String
phone
=
"12011101231211211"
;
if
(
phone
.
startsWith
(
"0"
))
{
phone
=
phone
.
substring
(
1
);
}
System
.
out
.
println
(
phone
);
System
.
out
.
println
(
"==============="
);
String
sign
=
"queryphonenumberstatus"
+
"shoptest"
+
"shoptest0001"
+
"shoptest181218006"
+
"2018-12-13 16:14:28"
+
"0189464112"
+
"2200ded1a890515641248dd1d6ea966e"
;
System
.
out
.
println
(
MD5Util
.
MD5Encode
(
sign
,
"utf-8"
));
System
.
out
.
println
(
MD5Util
.
MD5Encode
(
"123456"
,
""
));
System
.
out
.
println
(
MD5Util
.
MD5Encode
(
"123456"
,
"utf-8"
));
System
.
out
.
println
(
new
Random
().
nextInt
(
10000
));
}
}
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