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
66ed7f99
Commit
66ed7f99
authored
Mar 19, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改为payGo进行话费充值
parent
68786c20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
82 deletions
+110
-82
src/com/library/service/Impl/AutomaticCodeServiceImpl.java
+72
-59
src/com/library/test/PaygoTest.java
+0
-0
src/com/library/util/Paygo24Utils.java
+38
-23
No files found.
src/com/library/service/Impl/AutomaticCodeServiceImpl.java
View file @
66ed7f99
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
;
import
com.library.TopUp.smart.SmartSentUtils
;
import
com.library.config.NameValue
;
import
com.library.mapper.AutomaticQueueMapper
;
import
com.library.mapper.CurrencyMapper
;
...
...
@@ -53,7 +49,6 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
String
removePhone
=
phone
;
if
(
phone
.
startsWith
(
PREFIX_ZERO
))
{
removePhone
=
phone
;
}
// 判断是否是中国手机号
// 是
...
...
@@ -65,49 +60,50 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
public
void
automaticForTack
()
{
// 得到最早的一条充值记录
Map
<
String
,
Object
>
map
=
automaticQueueMapper
.
selectEarlyOne
();
if
(
map
!=
null
)
{
// 充值业务状态
boolean
success
=
false
;
//自动处理状态说明
String
desc
=
""
;
AutomaticQueueModel
automaticQueueModel
=
null
;
String
top_up_num
=
""
;
try
{
automaticQueueModel
=
(
AutomaticQueueModel
)
TransformationTools
.
ToObjectOne
(
AutomaticQueueModel
.
class
,
map
);
// 修改状态
automaticQueueModel
.
setStatus
(
1
);
currencyMapper
.
updateTableForMysql
(
TransformationTools
.
CreatUpdateMysql
(
automaticQueueModel
,
NameValue
.
Table_automatic_queue
,
"id"
,
null
));
//获取订单信息
Map
<
String
,
Object
>
mapOrder
=
automaticQueueMapper
.
selectOrderByNumber
(
automaticQueueModel
.
getOrder_num
());
OrderModel
orderModel
=
(
OrderModel
)
TransformationTools
.
ToObjectOne
(
OrderModel
.
class
,
mapOrder
);
OrderLogModel
orderLogModel
=
new
OrderLogModel
();
orderLogModel
.
setLog_order_number
(
orderModel
.
getOrder_number
());
orderLogModel
.
setLog_type
(
5
);
orderLogModel
.
setTime
(
new
Timestamp
(
System
.
currentTimeMillis
()));
orderLogModel
.
setLog_content
(
"自动充值-准备开始充值"
);
//添加订单操作日志
currencyMapper
.
AddTableForMysql
(
TransformationTools
.
CreatAddMysql
(
orderLogModel
,
NameValue
.
Table_order_log
,
"id"
,
null
));
if
(
map
==
null
)
{
return
;
}
//生成充值的订单编号。每次都会变,以后可能会复查使用到。
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
top_up_num
=
sdf
.
format
(
new
Date
());
// 充值业务状态
boolean
success
=
false
;
//自动处理状态说明
String
desc
=
""
;
AutomaticQueueModel
automaticQueueModel
=
null
;
//去充值
ResultsModel
resultsModel
=
sentTopup
(
automaticQueueModel
,
top_up_num
);
desc
=
resultsModel
.
getTip
();
success
=
resultsModel
.
isSuccessful
();
top_up_num
=
resultsModel
.
getTopUpNum
();
String
top_up_num
=
""
;
try
{
automaticQueueModel
=
(
AutomaticQueueModel
)
TransformationTools
.
ToObjectOne
(
AutomaticQueueModel
.
class
,
map
);
// 修改状态
automaticQueueModel
.
setStatus
(
1
);
currencyMapper
.
updateTableForMysql
(
TransformationTools
.
CreatUpdateMysql
(
automaticQueueModel
,
NameValue
.
Table_automatic_queue
,
"id"
,
null
));
//获取订单信息
Map
<
String
,
Object
>
mapOrder
=
automaticQueueMapper
.
selectOrderByNumber
(
automaticQueueModel
.
getOrder_num
());
OrderModel
orderModel
=
(
OrderModel
)
TransformationTools
.
ToObjectOne
(
OrderModel
.
class
,
mapOrder
);
OrderLogModel
orderLogModel
=
new
OrderLogModel
();
orderLogModel
.
setLog_order_number
(
orderModel
.
getOrder_number
());
orderLogModel
.
setLog_type
(
5
);
orderLogModel
.
setTime
(
new
Timestamp
(
System
.
currentTimeMillis
()));
orderLogModel
.
setLog_content
(
"自动充值-准备开始充值"
);
//添加订单操作日志
currencyMapper
.
AddTableForMysql
(
TransformationTools
.
CreatAddMysql
(
orderLogModel
,
NameValue
.
Table_order_log
,
"id"
,
null
));
//生成充值的订单编号。每次都会变,以后可能会复查使用到。
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
top_up_num
=
sdf
.
format
(
new
Date
());
//去充值
ResultsModel
resultsModel
=
sentTopup
(
automaticQueueModel
,
top_up_num
);
desc
=
resultsModel
.
getTip
();
success
=
resultsModel
.
isSuccessful
();
top_up_num
=
resultsModel
.
getTopUpNum
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
desc
=
"System error."
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
desc
=
"System error."
;
}
// 自动处理结果
this
.
automaticForTackResult
(
automaticQueueModel
,
success
,
desc
,
top_up_num
);
}
this
.
automaticForTackResult
(
automaticQueueModel
,
success
,
desc
,
top_up_num
);
}
private
ResultsModel
sentTopup
(
AutomaticQueueModel
automaticQueueModel
,
String
top_up_num
)
{
...
...
@@ -123,29 +119,46 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
//1.先判断这是哪个公司的充值订单,然后发起充值
SegmentModel
segmentModel
=
(
SegmentModel
)
TransformationTools
.
ToObjectOne
(
SegmentModel
.
class
,
map
);
// 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)) {
// resultsModel = SeatelSentUtils.sentTopUp(automaticQueueModel.getOrder_phone(), automaticQueueModel.getOrder_money().intValue());
// //这个不用返回订单num,里面已经做了处理
// } else {
// payGo的运营商对应id
int
serviceId
;
if
(
segmentModel
.
getOperator
().
equals
(
SegmentType_Cellcard
))
{
//Cellcard的手机号,则选择Cellcard公司的api发起充值
resultsModel
=
CellcardSentUtils
.
sentTopUp
(
automaticQueueModel
.
getOrder_phone
(),
orderNumId
,
automaticQueueModel
.
getOrder_money
().
intValue
());
resultsModel
.
setTopUpNum
(
orderNumId
);
serviceId
=
3
;
}
else
if
(
segmentModel
.
getOperator
().
equals
(
SegmentType_Metfone
))
{
resultsModel
=
MetfoneSentUtils
.
sentTopUp
(
automaticQueueModel
.
getOrder_phone
(),
automaticQueueModel
.
getOrder_money
().
intValue
(),
orderNumId
);
resultsModel
.
setTopUpNum
(
orderNumId
);
serviceId
=
4
;
}
else
if
(
segmentModel
.
getOperator
().
equals
(
SegmentType_Smart
))
{
resultsModel
=
SmartSentUtils
.
sentTopUp
(
automaticQueueModel
.
getOrder_phone
(),
automaticQueueModel
.
getOrder_money
().
intValue
(),
orderNumId
);
resultsModel
.
setTopUpNum
(
orderNumId
);
serviceId
=
2
;
}
else
if
(
segmentModel
.
getOperator
().
equals
(
SegmentType_Seatel
))
{
resultsModel
=
SeatelSentUtils
.
sentTopUp
(
automaticQueueModel
.
getOrder_phone
(),
automaticQueueModel
.
getOrder_money
().
intValue
());
//这个不用返回订单num,里面已经做了处理
serviceId
=
111
;
}
else
{
Paygo24Utils
paygo
=
new
Paygo24Utils
();
String
result
=
paygo
.
payment
(
automaticQueueModel
.
getOrder_phone
(),
automaticQueueModel
.
getSegment_id
(),
automaticQueueModel
.
getOrder_money
());
// 没找到
return
null
;
}
resultsModel
=
new
ResultsModel
();
resultsModel
.
setTip
(
result
);
//描述
resultsModel
.
setSuccessful
(
result
.
equals
(
Paygo24Utils
.
SUCCESS
));
Paygo24Utils
paygo
=
new
Paygo24Utils
();
String
result
=
paygo
.
payment
(
automaticQueueModel
.
getOrder_phone
(),
serviceId
,
automaticQueueModel
.
getOrder_money
());
resultsModel
.
setTopUpNum
(
orderNumId
);
}
resultsModel
=
new
ResultsModel
();
resultsModel
.
setTip
(
result
);
//描述
resultsModel
.
setSuccessful
(
result
.
equals
(
Paygo24Utils
.
SUCCESS
));
resultsModel
.
setTopUpNum
(
orderNumId
);
return
resultsModel
;
}
catch
(
Exception
e
)
{
...
...
src/com/library/test/PaygoTest.java
0 → 100644
View file @
66ed7f99
This diff is collapsed.
Click to expand it.
src/com/library/util/Paygo24Utils.java
View file @
66ed7f99
package
com
.
library
.
util
;
import
com.google.gson.Gson
;
import
com.library.util.currency.AESUtils
;
import
com.library.util.currency.DiscountFileUtils
;
import
com.paygo24.v3.protocol.*
;
import
org.apache.commons.lang3.StringUtils
;
import
org.tempuri.PayGoService
;
import
org.tempuri.PayGoServiceSoap
;
...
...
@@ -44,26 +42,43 @@ public class Paygo24Utils {
private
static
final
String
CORRECT_PAYMENT_STATE_ACCEPTED
=
"0"
;
/** 充值还没有处理完返回的状态码 */
private
static
final
String
CORRECT_PAYMENT_STATE_WAS
=
"3"
;
/** 充值还没有处理完返回的状态码 */
/**
* 充值还没有处理完返回的状态码
*/
private
static
final
String
CORRECT_PAYMENT_STATE_DELAYED
=
"4"
;
/** 充值还没有处理完返回的状态码 */
/**
* 充值还没有处理完返回的状态码
*/
private
static
final
String
CORRECT_PAYMENT_STATE_PROVIDER
=
"6"
;
/** 处理成功返回给调用者的状态码 */
/**
* 处理成功返回给调用者的状态码
*/
public
static
final
String
SUCCESS
=
"SUCCESS"
;
/** 配置文件中的paygo24 id */
/**
* 配置文件中的paygo24 id
*/
private
static
Integer
POINT_ID
;
/** 配置文件中的paygo24 密码 */
/**
* 配置文件中的paygo24 密码
*/
private
static
String
PASSWORD
;
/** 配置文件中是否存在paygo24账号 */
/**
* 配置文件中是否存在paygo24账号
*/
private
static
boolean
hasAccount
=
true
;
/** 付款后余额 */
/**
* 付款后余额
*/
private
BigDecimal
availableBalance
;
/** 当前账号余额 */
/**
* 当前账号余额
*/
private
BigDecimal
currentBalance
;
/*** 重新查询的次数 ****/
private
Integer
count
;
private
static
boolean
ISTEST
=
true
;
private
static
boolean
ISTEST
;
static
{
Map
<
String
,
String
>
map
;
try
{
...
...
@@ -71,10 +86,9 @@ public class Paygo24Utils {
if
(
map
.
get
(
"paygo.pointid"
)
!=
null
&&
map
.
get
(
"paygo.password"
)
!=
null
)
{
// POINT_ID = Integer.parseInt(map.get("paygo.pointid"));
// PASSWORD = AESUtils.decryptData(AESUtils.DEFAULT_KEY, map.get("paygo.password"));
POINT_ID
=
326386
;
PASSWORD
=
"5TNO+4kpAXtphf1eIlGCLw=="
;
// POINT_ID =46 ;
// PASSWORD = "4QrcOUm6Wau+VuBX8g+IPg==";
// POINT_ID =326386 ;
// PASSWORD = "5TNO+4kpAXtphf1eIlGCLw==";
System
.
out
.
println
(
PASSWORD
);
// paygo.pointid=326386
...
...
@@ -100,9 +114,9 @@ public class Paygo24Utils {
}
public
static
void
main
(
String
[]
args
)
{
Paygo24Utils
paygo24Utils
=
new
Paygo24Utils
();
String
result
=
paygo24Utils
.
payment
(
"066301180"
,
4
,
new
BigDecimal
(
1.0
));
System
.
out
.
println
(
result
);
Paygo24Utils
paygo24Utils
=
new
Paygo24Utils
();
String
result
=
paygo24Utils
.
payment
(
"0960000000"
,
2
,
new
BigDecimal
(
1.0
));
System
.
out
.
println
(
"result:"
+
result
);
}
/**
...
...
@@ -127,11 +141,11 @@ public class Paygo24Utils {
// QName.valueOf("{http://tempuri.org/}PayGoService"));
PayGoService
service
;
ISTEST
=
fals
e
;
if
(
ISTEST
)
{
service
=
new
PayGoService
(
new
URL
(
"https://api2.paygo24.com/paygoservice.asmx
?wsdl
"
),
ISTEST
=
tru
e
;
if
(
ISTEST
)
{
service
=
new
PayGoService
(
new
URL
(
"https://api2.paygo24.com/paygoservice.asmx"
),
QName
.
valueOf
(
"{http://tempuri.org/}PayGoService"
));
}
else
{
}
else
{
service
=
new
PayGoService
(
new
URL
(
"https://processing2.paygo24.com/paygoservice.asmx"
),
QName
.
valueOf
(
"{http://tempuri.org/}PayGoService"
));
}
...
...
@@ -153,7 +167,8 @@ public class Paygo24Utils {
registerCheckRequest
.
setPaymentParameters
(
ap
);
sendRequest
.
setRequest
(
registerCheckRequest
);
SendRequestResponse
response
=
soap
.
sendRequest
(
sendRequest
);
System
.
out
.
println
(
new
Gson
().
toJson
(
response
));
System
.
out
.
println
(
"RegisterCheckRequest response:"
+
new
Gson
().
toJson
(
response
));
if
(
response
.
getSendRequestResult
()
instanceof
RegisterCheckResponse
)
{
// Success. You can get result
Duration
duaration
=
((
RegisterCheckResponse
)
response
.
getSendRequestResult
())
...
...
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