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
69b9fd2d
Commit
69b9fd2d
authored
Jan 08, 2020
by
yanlveming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步
parent
3ae2713a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
174 deletions
+107
-174
src/com/library/TopUp/Statel/SeatelSentUtils.java
+0
-0
src/com/library/TopUp/model/ResultsModel.java
+9
-0
src/com/library/TopUp/smart/SmartSentUtils.java
+0
-37
src/com/library/controller/CommonController.java
+22
-122
src/com/library/service/Impl/AutomaticCodeServiceImpl.java
+10
-12
src/com/library/test/ylmTest.java
+66
-3
No files found.
src/com/library/TopUp/Statel/SeatelSentUtils.java
View file @
69b9fd2d
This diff is collapsed.
Click to expand it.
src/com/library/TopUp/model/ResultsModel.java
View file @
69b9fd2d
...
...
@@ -5,6 +5,7 @@ public class ResultsModel {
private
boolean
isSuccessful
;
private
String
tip
;
private
String
expandText
;
private
String
topUpNum
;
public
ResultsModel
(
boolean
isSuccessful
,
String
tip
)
{
...
...
@@ -44,4 +45,12 @@ public class ResultsModel {
public
void
setExpandText
(
String
expandText
)
{
this
.
expandText
=
expandText
;
}
public
String
getTopUpNum
()
{
return
topUpNum
;
}
public
void
setTopUpNum
(
String
topUpNum
)
{
this
.
topUpNum
=
topUpNum
;
}
}
src/com/library/TopUp/smart/SmartSentUtils.java
View file @
69b9fd2d
...
...
@@ -174,43 +174,6 @@ public class SmartSentUtils {
}
}
public
static
void
main2222
(
String
[]
args
)
{
String
json
=
getToken
();
// //{"access_token":"372b5f81-9662-3d75-abcf-639920880ce3","refresh_token":"d62d9da3-3730-35f7-9368-c82b43509db1","scope":"default","token_type":"Bearer","expires_in":3249}//
System
.
out
.
println
(
json
);
String
tip
=
""
;
if
(!
TextUtils
.
isEmpty
(
json
))
{
JsonParser
jsonParser
=
new
JsonParser
();
JsonObject
jsonObject
=
jsonParser
.
parse
(
json
).
getAsJsonObject
();
String
token
=
jsonObject
.
get
(
"access_token"
).
getAsString
();
if
(!
TextUtils
.
isEmpty
(
token
))
{
access_token
=
token
;
refresh_token
=
jsonObject
.
get
(
"refresh_token"
).
getAsString
();
token_type
=
jsonObject
.
get
(
"token_type"
).
getAsString
();
expires_in
=
jsonObject
.
get
(
"expires_in"
).
getAsInt
();
}
else
{
tip
+=
"返回结果:"
+
json
;
}
}
else
{
tip
+=
"返回值为空"
;
}
System
.
out
.
println
(
tip
);
String
jsonQuery
=
queryRechargePhone
(
"58cam:87234159:100025"
);
System
.
out
.
println
(
jsonQuery
);
if
(!
TextUtils
.
isEmpty
(
jsonQuery
))
{
JsonParser
jsonQueryParser
=
new
JsonParser
();
JsonObject
jsonObjectQuery
=
jsonQueryParser
.
parse
(
jsonQuery
).
getAsJsonObject
();
String
recharge_status
=
jsonObjectQuery
.
get
(
"recharge_status"
).
getAsString
();
if
(
recharge_status
.
equals
(
"Succeeded"
))
{
System
.
out
.
println
(
"充值成功"
);
}
}
}
public
static
void
main
(
String
[]
args
)
{
String
phone
=
"87234159"
;
...
...
src/com/library/controller/CommonController.java
View file @
69b9fd2d
...
...
@@ -5,6 +5,7 @@ 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.TopUp.model.ResultsModel
;
import
com.library.respcode.ServerResponse
;
import
com.library.service.AdminService
;
import
com.library.service.CommService
;
...
...
@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
...
...
@@ -36,6 +38,8 @@ public class CommonController {
@Resource
private
CommService
commService
;
@Resource
private
HttpServletRequest
request
;
//获取七牛云的token
@ResponseBody
...
...
@@ -61,11 +65,11 @@ public class CommonController {
//登录
@ResponseBody
@RequestMapping
(
"test"
)
@RequestMapping
(
"test
1
"
)
private
ServerResponse
test
()
{
String
json
=
CellcardSentUtils
.
getToken
()
;
S
ystem
.
out
.
println
(
json
);
String
phone
=
"0189464112"
;
S
tring
json
=
SeatelSentUtils
.
checkPhone
(
phone
);
return
ServerResponse
.
createBySuccess
(
json
);
}
...
...
@@ -75,7 +79,7 @@ public class CommonController {
private
ServerResponse
test2
()
{
String
phone
=
"0189464112"
;
String
json
=
SeatelSentUtils
.
checkPhone
(
phone
);
String
json
=
SeatelSentUtils
.
checkPhone
2
(
phone
);
return
ServerResponse
.
createBySuccess
(
json
);
}
...
...
@@ -88,136 +92,32 @@ public class CommonController {
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
);
@RequestMapping
(
"test4"
)
private
ServerResponse
test4
()
{
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
=
SeatelSentUtils
.
crmRecharge
(
phone
,
1
);
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
);
@RequestMapping
(
"test5"
)
private
ServerResponse
test5
()
{
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"
);
String
str
=
request
.
getParameter
(
"str"
);
String
type
=
request
.
getParameter
(
"type"
);
String
json
=
SeatelSentUtils
.
queryCrmRecharge
(
str
);
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
;
@RequestMapping
(
"sentTopUp"
)
private
ServerResponse
sentTopUp
()
{
String
phone
=
request
.
getParameter
(
"phone"
);
// String phone = "0189464112";
ResultsModel
resultsModel
=
SeatelSentUtils
.
sentTopUp
(
phone
,
1
);
return
ServerResponse
.
createBySuccess
(
new
Gson
().
toJson
(
resultsModel
));
}
...
...
src/com/library/service/Impl/AutomaticCodeServiceImpl.java
View file @
69b9fd2d
package
com
.
library
.
service
.
Impl
;
import
com.library.TopUp.Statel.SeatelSentUtils
;
import
com.library.TopUp.cellcard.CellcardSentUtils
;
import
com.library.TopUp.mefont.MetfoneSentUtils
;
import
com.library.TopUp.model.ResultsModel
;
...
...
@@ -90,7 +91,6 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
currencyMapper
.
AddTableForMysql
(
TransformationTools
.
CreatAddMysql
(
orderLogModel
,
NameValue
.
Table_order_log
,
"id"
,
null
));
//生成充值的订单编号。每次都会变,以后可能会复查使用到。
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
top_up_num
=
sdf
.
format
(
new
Date
());
...
...
@@ -99,6 +99,7 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
ResultsModel
resultsModel
=
sentTopup
(
automaticQueueModel
,
top_up_num
);
desc
=
resultsModel
.
getTip
();
success
=
resultsModel
.
isSuccessful
();
top_up_num
=
resultsModel
.
getTopUpNum
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -106,7 +107,7 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
}
// 自动处理结果
this
.
automaticForTackResult
(
automaticQueueModel
,
success
,
desc
,
top_up_num
);
this
.
automaticForTackResult
(
automaticQueueModel
,
success
,
desc
,
top_up_num
);
}
}
...
...
@@ -131,21 +132,16 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
if
(
segmentModel
.
getOperator
().
equals
(
SegmentType_Cellcard
))
{
//Cellcard的手机号,则选择Cellcard公司的api发起充值
resultsModel
=
CellcardSentUtils
.
sentTopUp
(
automaticQueueModel
.
getOrder_phone
(),
orderNumId
,
automaticQueueModel
.
getOrder_money
().
intValue
());
resultsModel
.
setTopUpNum
(
orderNumId
);
}
else
if
(
segmentModel
.
getOperator
().
equals
(
SegmentType_Metfone
))
{
resultsModel
=
MetfoneSentUtils
.
sentTopUp
(
automaticQueueModel
.
getOrder_phone
(),
automaticQueueModel
.
getOrder_money
().
intValue
(),
orderNumId
);
resultsModel
.
setTopUpNum
(
orderNumId
);
}
else
if
(
segmentModel
.
getOperator
().
equals
(
SegmentType_Smart
))
{
resultsModel
=
SmartSentUtils
.
sentTopUp
(
automaticQueueModel
.
getOrder_phone
(),
automaticQueueModel
.
getOrder_money
().
intValue
(),
orderNumId
);
resultsModel
.
setTopUpNum
(
orderNumId
);
}
else
if
(
segmentModel
.
getOperator
().
equals
(
SegmentType_Seatel
))
{
Paygo24Utils
paygo
=
new
Paygo24Utils
();
String
result
=
paygo
.
payment
(
automaticQueueModel
.
getOrder_phone
(),
automaticQueueModel
.
getSegment_id
(),
automaticQueueModel
.
getOrder_money
());
resultsModel
=
new
ResultsModel
();
resultsModel
.
setTip
(
result
);
//描述
if
(
result
.
equals
(
Paygo24Utils
.
SUCCESS
))
{
resultsModel
.
setSuccessful
(
true
);
}
else
{
resultsModel
.
setSuccessful
(
false
);
}
resultsModel
=
SeatelSentUtils
.
sentTopUp
(
automaticQueueModel
.
getOrder_phone
(),
automaticQueueModel
.
getOrder_money
().
intValue
());
//这个不用返回订单num,里面已经做了处理
}
else
{
Paygo24Utils
paygo
=
new
Paygo24Utils
();
String
result
=
paygo
.
payment
(
automaticQueueModel
.
getOrder_phone
(),
automaticQueueModel
.
getSegment_id
(),
automaticQueueModel
.
getOrder_money
());
...
...
@@ -157,6 +153,8 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
}
else
{
resultsModel
.
setSuccessful
(
false
);
}
resultsModel
.
setTopUpNum
(
orderNumId
);
}
return
resultsModel
;
...
...
src/com/library/test/ylmTest.java
View file @
69b9fd2d
...
...
@@ -10,9 +10,7 @@ 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
;
import
java.util.*
;
/**
* Created by Administrator on 2018\10\31 0031.
...
...
@@ -43,5 +41,70 @@ public class ylmTest {
System
.
out
.
println
(
MD5Util
.
MD5Encode
(
"123456"
,
""
));
System
.
out
.
println
(
MD5Util
.
MD5Encode
(
"123456"
,
"utf-8"
));
System
.
out
.
println
(
new
Random
().
nextInt
(
10000
));
System
.
out
.
println
(
"--------"
);
System
.
out
.
println
(
getCurrentTime
());
System
.
out
.
println
(
getFormatedDateString
(
7
));
}
public
static
String
getCurrentTime
(){
//获取指定格式的时间
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
sdf
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"GMT-7"
));
//指定时区
return
sdf
.
format
(
new
Date
());
}
/**
* 取北京时间
* @return
*/
public
static
String
getBeijingTime
(){
return
getFormatedDateString
(
8
);
}
/**
* 取班加罗尔时间
* @return
*/
public
static
String
getBangaloreTime
(){
return
getFormatedDateString
(
5.5f
);
}
/**
* 取纽约时间
* @return
*/
public
static
String
getNewyorkTime
(){
return
getFormatedDateString
(-
5
);
}
/**
* 此函数非原创,从网上搜索而来,timeZoneOffset原为int类型,为班加罗尔调整成float类型
* timeZoneOffset表示时区,如中国一般使用东八区,因此timeZoneOffset就是8
* @param timeZoneOffset
* @return
*/
public
static
String
getFormatedDateString
(
float
timeZoneOffset
){
if
(
timeZoneOffset
>
13
||
timeZoneOffset
<
-
12
)
{
timeZoneOffset
=
0
;
}
int
newTime
=(
int
)(
timeZoneOffset
*
60
*
60
*
1000
);
TimeZone
timeZone
;
String
[]
ids
=
TimeZone
.
getAvailableIDs
(
newTime
);
if
(
ids
.
length
==
0
)
{
timeZone
=
TimeZone
.
getDefault
();
}
else
{
timeZone
=
new
SimpleTimeZone
(
newTime
,
ids
[
0
]);
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
sdf
.
setTimeZone
(
timeZone
);
return
sdf
.
format
(
new
Date
());
}
}
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