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
0562463e
Commit
0562463e
authored
Jan 13, 2020
by
yanlveming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步
parent
32323ba5
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
581 additions
and
105 deletions
+581
-105
src/com/library/TopUp/mefont/MetfoneSentUtils.java
+1
-1
src/com/library/TopUp/smart/SmartSentUtils.java
+75
-5
src/com/library/config/NameValue.java
+1
-0
src/com/library/controller/CommonController.java
+26
-75
src/com/library/mapper/CommMapper.java
+6
-0
src/com/library/mapper/CommMapper.xml
+29
-0
src/com/library/model/OperatorBalanceModel.java
+88
-0
src/com/library/service/CommService.java
+12
-0
src/com/library/service/Impl/CommServiceImpl.java
+261
-20
src/com/library/util/SendEmailTools.java
+3
-3
src/com/library/util/SpringContextUtil.java
+61
-1
src/com/library/util/UrlInterceptor.java
+18
-0
No files found.
src/com/library/TopUp/mefont/MetfoneSentUtils.java
View file @
0562463e
...
...
@@ -217,7 +217,7 @@ public class MetfoneSentUtils {
System.out.println(str);*/
String
str
=
checkMyMoneyPost
(
"20010818431127"
,
"0979530750"
);
String
str
=
checkMyMoneyPost
(
"2001081843112
2
7"
,
"0979530750"
);
System
.
out
.
println
(
str
);
}
...
...
src/com/library/TopUp/smart/SmartSentUtils.java
View file @
0562463e
...
...
@@ -11,8 +11,8 @@ import net.sf.json.JSONObject;
import
org.apache.http.util.TextUtils
;
import
java.net.URLEncoder
;
import
java.
util.HashMap
;
import
java.util.
Map
;
import
java.
text.SimpleDateFormat
;
import
java.util.
*
;
public
class
SmartSentUtils
{
...
...
@@ -175,9 +175,51 @@ public class SmartSentUtils {
}
public
static
void
main222
(
String
[]
args
)
{
/**
* {
* "correlation_id": "Link Asia:87234159:20200109105959",
* "institution_id": "98198198",
* "subscriber_id": "tel:+85587234159",
* "amount": 100,
* "channel": "WEB",
* "instance_id": "0109110016004792"
* }
*/
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
=
""
;
String
tokenStr
=
""
;
//判断是否成功获取到token
if
(!
TextUtils
.
isEmpty
(
json
))
{
JsonParser
jsonParser
=
new
JsonParser
();
JsonObject
jsonObject
=
jsonParser
.
parse
(
json
).
getAsJsonObject
();
tokenStr
=
jsonObject
.
get
(
"access_token"
)
==
null
?
""
:
jsonObject
.
get
(
"access_token"
).
getAsString
();
if
(!
TextUtils
.
isEmpty
(
tokenStr
))
{
access_token
=
tokenStr
;
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
+=
" 返回值为空"
;
}
String
jsonQuery
=
queryRechargePhone
(
"Link Asia:87234159:20200109105959"
);
//发起校验
System
.
out
.
println
(
jsonQuery
);
System
.
out
.
println
(
tip
);
}
public
static
void
main
(
String
[]
args
)
{
String
phone
=
"87234159"
;
ResultsModel
resultsModel
=
sentTopUp
(
phone
,
1
,
"99999912"
);
ResultsModel
resultsModel
=
sentTopUp
(
phone
,
1
,
getFormatedDateString
(
7
)
);
System
.
out
.
println
(
"充值是否成功:"
+
resultsModel
.
isSuccessful
());
System
.
out
.
println
(
"充值日志:"
+
resultsModel
.
getTip
());
...
...
@@ -248,7 +290,7 @@ public class SmartSentUtils {
//校验成功
tip
+=
" 手机号码校验成功 !!!"
;
String
rechId
=
"
58cam
:"
+
phone
+
":"
+
orderNum
;
String
rechId
=
"
LinkAsia
:"
+
phone
+
":"
+
orderNum
;
int
amount
=
topUpAmount
*
100
;
//需要乘以100,文档写在至少100分美元,则1美元,以分为单位
String
rechargeJson
=
rechargePhone
(
phone
,
String
.
valueOf
(
amount
),
rechId
);
//发起充值
System
.
out
.
println
(
rechargeJson
);
...
...
@@ -266,7 +308,7 @@ public class SmartSentUtils {
JsonParser
jsonParserRecharge
=
new
JsonParser
();
JsonObject
jsonObjectRecharge
=
jsonParserRecharge
.
parse
(
rechargeJson
).
getAsJsonObject
();
correlation_id
=
jsonObjectRecharge
.
get
(
"correlation_id"
)
==
null
?
""
:
jsonObjectRecharge
.
get
(
"correlation_id"
).
getAsString
();
//不为空,则充值成功
tip
+=
" 充值发起成功!!!"
;
tip
+=
" 充值发起
请求
成功!!!"
;
}
else
{
tip
+=
" 充值请求返回值为空;"
;
}
...
...
@@ -318,4 +360,32 @@ public class SmartSentUtils {
return
resultsModel
;
}
}
/**
* 此函数非原创,从网上搜索而来,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
(
"yyyyMMddHHmmss"
);
sdf
.
setTimeZone
(
timeZone
);
return
sdf
.
format
(
new
Date
());
}
}
src/com/library/config/NameValue.java
View file @
0562463e
...
...
@@ -21,6 +21,7 @@ public class NameValue {
public
static
String
Table_order_log
=
"pre_dz_pay_order_log"
;
//订单日志表
public
static
String
Table_order
=
"pre_dz_pay_order"
;
//订单表
public
static
String
Table_pay_segment
=
"pre_dz_pay_segment"
;
//订单表
public
static
String
Table_pay_operator_balance
=
"pre_dz_pay_operator_balance"
;
//运营商余额
...
...
src/com/library/controller/CommonController.java
View file @
0562463e
...
...
@@ -7,6 +7,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.mefont.MetfoneSentUtils
;
import
com.library.TopUp.model.ResultsModel
;
import
com.library.respcode.ServerResponse
;
import
com.library.service.AdminService
;
...
...
@@ -22,10 +23,7 @@ import javax.annotation.Resource;
import
javax.servlet.http.HttpServletRequest
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.*
;
/*
* @项目名: yunVpay
...
...
@@ -45,94 +43,47 @@ public class CommonController {
@Resource
private
HttpServletRequest
request
;
//查询剩余的余额
@ResponseBody
@RequestMapping
(
"checkMyMoney"
)
private
ServerResponse
checkMyMoney
()
{
return
commService
.
checkMyMoney
();
}
//保存邮箱
@ResponseBody
@RequestMapping
(
"saveTheEmail"
)
private
ServerResponse
saveTheEmail
()
{
return
commService
.
saveTheEmail
();
}
//检查Seatel运营商的手机
@ResponseBody
@RequestMapping
(
"checkPhoneInSeatel"
)
private
ServerResponse
checkPhoneInSeatel
()
{
return
commService
.
checkPhoneInSeatel
();
}
String
phone
=
request
.
getParameter
(
"phone"
);
String
json
=
SeatelSentUtils
.
checkPhone2
(
phone
);
return
ServerResponse
.
createBySuccess
(
json
);
//查询Metfone手机号剩余的余额
@ResponseBody
@RequestMapping
(
"checkMyMoneyInMetfone"
)
private
ServerResponse
checkMyMoneyInMetfone
()
{
return
commService
.
checkMyMoneyInMetfone
();
}
//查询Seatel运营商剩余的余额
@ResponseBody
@RequestMapping
(
"queryAgentFeeInSeatel"
)
private
ServerResponse
queryAgentFeeInSeatel
()
{
String
feeJson
=
SeatelSentUtils
.
queryAgentFee
();
String
tip
=
""
;
String
myAmount
=
""
;
if
(!
TextUtils
.
isEmpty
(
feeJson
))
{
JsonParser
jsonParserFee
=
new
JsonParser
();
JsonObject
jsonObjectFee
=
jsonParserFee
.
parse
(
feeJson
).
getAsJsonObject
();
String
codeCheck
=
jsonObjectFee
.
get
(
"code"
)
==
null
?
""
:
jsonObjectFee
.
get
(
"code"
).
getAsString
();
if
(!
TextUtils
.
isEmpty
(
codeCheck
)
&&
codeCheck
.
equals
(
"0"
))
{
//接口查询成功,比较金额大小
if
(
jsonObjectFee
.
get
(
"amount"
)
!=
null
)
{
myAmount
=
jsonObjectFee
.
get
(
"amount"
).
getAsString
();
tip
+=
"您当前的余额为:$"
+
myAmount
+
""
;
}
else
{
tip
+=
"获取不到余额信息"
;
}
}
else
{
tip
+=
"查询余额失败;结果为:"
+
feeJson
;
}
}
return
ServerResponse
.
createBySuccess
(
tip
,
myAmount
);
return
commService
.
queryAgentFeeInSeatel
();
}
//查询Cellcard运营商剩余的余额
//
查询Cellcard运营商剩余的余额
@ResponseBody
@RequestMapping
(
"queryAgentFeeInCellcard"
)
private
ServerResponse
queryAgentFeeInCellcard
()
{
String
feeJson
=
""
;
try
{
feeJson
=
CellcardSentUtils
.
checkBalance
();
String
tip
=
""
;
String
myAmount
=
""
;
if
(!
TextUtils
.
isEmpty
(
feeJson
))
{
JsonParser
jsonParserFee
=
new
JsonParser
();
JsonObject
jsonObjectFee
=
jsonParserFee
.
parse
(
feeJson
).
getAsJsonObject
();
if
(
jsonObjectFee
.
get
(
"data"
)
!=
null
)
{
JsonObject
data
=
jsonObjectFee
.
get
(
"data"
).
getAsJsonObject
();
String
error_message
=
data
.
get
(
"error_message"
)
==
null
?
""
:
data
.
get
(
"error_message"
).
getAsString
();
String
error_code
=
data
.
get
(
"error_code"
)
==
null
?
""
:
data
.
get
(
"error_code"
).
getAsString
();
if
(!
TextUtils
.
isEmpty
(
error_code
)
&&
error_code
.
equals
(
"0"
))
{
//接口查询成功,比较金额大小
if
(
data
.
get
(
"distributor_balance"
)
!=
null
)
{
myAmount
=
data
.
get
(
"distributor_balance"
).
getAsString
();
tip
+=
"您当前的余额为:$"
+
myAmount
+
""
;
return
ServerResponse
.
createByErrorCodeMessage
(
3002
,
tip
);
}
else
{
tip
+=
"获取不到余额信息;"
+
error_message
;
}
}
else
{
tip
+=
"查询余额失败;结果为:"
+
feeJson
;
}
}
else
{
tip
+=
"解析data为空"
;
}
}
else
{
tip
+=
"请求的数据为空"
;
}
return
ServerResponse
.
createByErrorCodeMessage
(
3001
,
tip
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ServerResponse
.
createByErrorCodeMessage
(-
1
,
feeJson
);
}
return
commService
.
queryAgentFeeInCellcard
();
}
...
...
src/com/library/mapper/CommMapper.java
View file @
0562463e
...
...
@@ -79,5 +79,11 @@ public interface CommMapper {
*/
public
List
<
Map
<
String
,
Object
>>
findAllProducts
(
@Param
(
"page"
)
int
page
,
@Param
(
"number"
)
int
number
);
/**
* 更新余额
*
* @return
*/
public
int
updateTheBalance
(
@Param
(
"map"
)
Map
<
String
,
Object
>
map
);
}
src/com/library/mapper/CommMapper.xml
View file @
0562463e
...
...
@@ -219,4 +219,33 @@
LIMIT #{page},#{number}
</select>
<update
id=
"updateTheBalance"
parameterType=
"map"
>
UPDATE pre_dz_pay_operator_balance
SET
<if
test=
"map.statel != null"
>
statel = #{map.statel} ,
</if>
<if
test=
"map.mefont != null"
>
mefont = #{map.mefont} ,
</if>
<if
test=
"map.cellcard != null"
>
cellcard = #{map.cellcard} ,
</if>
<if
test=
"map.smart != null"
>
smart = #{map.smart} ,
</if>
<if
test=
"map.remark != null"
>
remark = #{map.remark} ,
</if>
<if
test=
"map.email != null"
>
email = #{map.email} ,
</if>
<if
test=
"map.lackbalance != null"
>
lackbalance = #{map.lackbalance} ,
</if>
update_time = now()
WHERE id = 1
</update>
</mapper>
src/com/library/model/OperatorBalanceModel.java
0 → 100644
View file @
0562463e
package
com
.
library
.
model
;
import
java.sql.Timestamp
;
public
class
OperatorBalanceModel
{
public
int
id
;
public
String
statel
;
public
String
mefont
;
public
String
cellcard
;
public
String
smart
;
public
String
remark
;
public
String
email
;
public
String
lackbalance
;
public
Timestamp
update_time
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
String
getStatel
()
{
return
statel
;
}
public
void
setStatel
(
String
statel
)
{
this
.
statel
=
statel
;
}
public
String
getMefont
()
{
return
mefont
;
}
public
void
setMefont
(
String
mefont
)
{
this
.
mefont
=
mefont
;
}
public
String
getCellcard
()
{
return
cellcard
;
}
public
void
setCellcard
(
String
cellcard
)
{
this
.
cellcard
=
cellcard
;
}
public
String
getSmart
()
{
return
smart
;
}
public
void
setSmart
(
String
smart
)
{
this
.
smart
=
smart
;
}
public
String
getRemark
()
{
return
remark
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
public
Timestamp
getUpdate_time
()
{
return
update_time
;
}
public
void
setUpdate_time
(
Timestamp
update_time
)
{
this
.
update_time
=
update_time
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getLackbalance
()
{
return
lackbalance
;
}
public
void
setLackbalance
(
String
lackbalance
)
{
this
.
lackbalance
=
lackbalance
;
}
}
src/com/library/service/CommService.java
View file @
0562463e
...
...
@@ -21,4 +21,16 @@ public interface CommService {
* @return
*/
ServerResponse
adminLogin
();
ServerResponse
checkPhoneInSeatel
();
ServerResponse
queryAgentFeeInSeatel
();
ServerResponse
queryAgentFeeInCellcard
();
ServerResponse
checkMyMoneyInMetfone
();
ServerResponse
checkMyMoney
();
ServerResponse
saveTheEmail
();
}
src/com/library/service/Impl/CommServiceImpl.java
View file @
0562463e
package
com
.
library
.
service
.
Impl
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
com.library.TopUp.Statel.SeatelSentUtils
;
import
com.library.TopUp.cellcard.CellcardSentUtils
;
import
com.library.TopUp.mefont.MetfoneSentUtils
;
import
com.library.config.NameValue
;
import
com.library.mapper.CommMapper
;
import
com.library.mapper.CurrencyMapper
;
...
...
@@ -12,19 +17,21 @@ import com.library.service.CommService;
import
com.library.util.MSMmethodUtil
;
import
com.library.util.Paygo24Utils
;
import
com.library.util.SendEmailTools
;
import
com.library.util.TransformationTools
;
import
com.wechat.pay.MD5Util
;
import
com.wechat.pay.WeChatManager
;
import
com.wechat.pay.WeChatManager.UserInfo
;
import
org.apache.http.util.TextUtils
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.math.BigDecimal
;
import
java.net.URLDecoder
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
@Service
public
class
CommServiceImpl
implements
CommService
{
...
...
@@ -43,7 +50,7 @@ public class CommServiceImpl implements CommService {
public
ServerResponse
Recharge
()
{
try
{
return
ServerResponse
.
createBy
Success
(
);
return
ServerResponse
.
createBy
ErrorCodeMessage
(-
1
,
"无此接口"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ServerResponse
.
createByError
();
...
...
@@ -52,30 +59,264 @@ public class CommServiceImpl implements CommService {
@Override
public
ServerResponse
adminLogin
()
{
return
ServerResponse
.
createByErrorCodeMessage
(-
1
,
"无此接口"
);
}
@Override
public
ServerResponse
checkPhoneInSeatel
()
{
String
phone
=
request
.
getParameter
(
"phone"
);
String
json
=
SeatelSentUtils
.
checkPhone2
(
phone
);
return
ServerResponse
.
createBySuccess
(
json
);
}
@Override
public
ServerResponse
queryAgentFeeInSeatel
()
{
String
feeJson
=
SeatelSentUtils
.
queryAgentFee
();
String
tip
=
""
;
String
myAmount
=
""
;
if
(!
TextUtils
.
isEmpty
(
feeJson
))
{
JsonParser
jsonParserFee
=
new
JsonParser
();
JsonObject
jsonObjectFee
=
jsonParserFee
.
parse
(
feeJson
).
getAsJsonObject
();
String
codeCheck
=
jsonObjectFee
.
get
(
"code"
)
==
null
?
""
:
jsonObjectFee
.
get
(
"code"
).
getAsString
();
if
(!
TextUtils
.
isEmpty
(
codeCheck
)
&&
codeCheck
.
equals
(
"0"
))
{
//接口查询成功,比较金额大小
if
(
jsonObjectFee
.
get
(
"amount"
)
!=
null
)
{
myAmount
=
jsonObjectFee
.
get
(
"amount"
).
getAsString
();
tip
+=
"您当前的余额为:$"
+
myAmount
+
""
;
// if (!TextUtils.isEmpty(myAmount)) {
// Map<String, Object> map = new HashMap<>();
// map.put("statel", myAmount);
// commMapper.updateTheBalance(map);
// }
changeTheAmountLog
(
myAmount
,
""
,
""
,
""
,
""
);
}
else
{
tip
+=
"获取不到余额信息"
;
}
}
else
{
tip
+=
"查询余额失败;结果为:"
+
feeJson
;
}
}
System
.
out
.
println
(
tip
);
return
ServerResponse
.
createBySuccess
(
tip
,
myAmount
);
}
@Override
public
ServerResponse
queryAgentFeeInCellcard
()
{
String
feeJson
=
""
;
try
{
String
phone
=
TransformationTools
.
TransactSQLInjection
(
request
.
getParameter
(
"account"
));
//手机号码(type=1,2)
String
password
=
TransformationTools
.
TransactSQLInjection
(
request
.
getParameter
(
"password"
));
//密码(type=2)
// if (phone.length() < 6) {
// return ServerResponse.createByErrorMessage("账户或者密码错误!");
// }
String
new_password
=
MD5Util
.
MD5Encode
(
MD5Util
.
MD5Encode
(
password
,
null
),
null
);
List
<
Map
<
String
,
Object
>>
list
=
currencyMapper
.
FindDataListWhere
(
NameValue
.
Table_admin
,
0
,
1
,
" where account = '"
+
phone
+
"' and password ='"
+
new_password
+
"'"
);
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
//登陆账户
AdminModel
adminModel
=
(
AdminModel
)
TransformationTools
.
ToObjectOne
(
UserModel
.
class
,
list
.
get
(
0
));
request
.
getSession
().
setAttribute
(
NameValue
.
Admin_Session
,
adminModel
);
return
ServerResponse
.
createBySuccess
();
}
else
{
//账户或者密码错误
return
ServerResponse
.
createByErrorMessage
(
"账户或者密码错误!"
);
feeJson
=
CellcardSentUtils
.
checkBalance
();
String
tip
=
""
;
String
myAmount
=
""
;
if
(!
TextUtils
.
isEmpty
(
feeJson
))
{
JsonParser
jsonParserFee
=
new
JsonParser
();
JsonObject
jsonObjectFee
=
jsonParserFee
.
parse
(
feeJson
).
getAsJsonObject
();
if
(
jsonObjectFee
.
get
(
"data"
)
!=
null
)
{
JsonObject
data
=
jsonObjectFee
.
get
(
"data"
).
getAsJsonObject
();
String
error_message
=
data
.
get
(
"error_message"
)
==
null
?
""
:
data
.
get
(
"error_message"
).
getAsString
();
String
error_code
=
data
.
get
(
"error_code"
)
==
null
?
""
:
data
.
get
(
"error_code"
).
getAsString
();
if
(!
TextUtils
.
isEmpty
(
error_code
)
&&
error_code
.
equals
(
"0"
))
{
//接口查询成功,比较金额大小
if
(
data
.
get
(
"distributor_balance"
)
!=
null
)
{
myAmount
=
data
.
get
(
"distributor_balance"
).
getAsString
();
tip
+=
"您当前的余额为:$"
+
myAmount
+
""
;
// if (!TextUtils.isEmpty(myAmount)) {
// Map<String, Object> map = new HashMap<>();
// map.put("cellcard", myAmount);
// commMapper.updateTheBalance(map);
// }
changeTheAmountLog
(
""
,
""
,
myAmount
,
""
,
""
);
return
ServerResponse
.
createBySuccess
(
tip
,
myAmount
);
}
else
{
tip
+=
"获取不到余额信息;"
+
error_message
;
}
}
else
{
tip
+=
"查询余额失败;结果为:"
+
feeJson
;
}
}
else
{
tip
+=
"解析data为空"
;
}
}
else
{
tip
+=
"请求的数据为空"
;
}
System
.
out
.
println
(
tip
);
return
ServerResponse
.
createByErrorCodeMessage
(
3001
,
tip
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ServerResponse
.
createByErrorCodeMessage
(-
1
,
feeJson
);
}
}
@Override
public
ServerResponse
checkMyMoneyInMetfone
()
{
String
feeJson
=
""
;
try
{
String
refId
=
getFormatedDateString
(
7
);
String
phone
=
request
.
getParameter
(
"phone"
);
// {"status":0,"code":"MSG_SUCCESS","message":"Success","msisdn":null,"accountName":null,"accountType":null,"balances":{"KHR":"498,983","USD":"4,748.00"}}
feeJson
=
MetfoneSentUtils
.
checkMyMoneyPost
(
refId
,
phone
);
String
tip
=
""
;
JsonObject
data
=
null
;
if
(!
TextUtils
.
isEmpty
(
feeJson
))
{
JsonParser
jsonParserFee
=
new
JsonParser
();
JsonObject
jsonObjectFee
=
jsonParserFee
.
parse
(
feeJson
).
getAsJsonObject
();
String
status
=
jsonObjectFee
.
get
(
"status"
)
==
null
?
""
:
jsonObjectFee
.
get
(
"status"
).
getAsString
();
if
(
status
.
equals
(
"0"
))
{
if
(
jsonObjectFee
.
get
(
"balances"
)
!=
null
)
{
data
=
jsonObjectFee
.
get
(
"balances"
).
getAsJsonObject
();
return
ServerResponse
.
createBySuccess
(
data
);
}
else
{
String
message
=
jsonObjectFee
.
get
(
"message"
)
==
null
?
""
:
jsonObjectFee
.
get
(
"message"
).
getAsString
();
tip
+=
""
+
message
;
}
}
else
{
tip
+=
"请求的数据为空"
;
}
}
else
{
tip
+=
"请求的数据为空"
;
}
return
ServerResponse
.
createByErrorCodeMessage
(
3001
,
tip
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ServerResponse
.
createByErrorCodeMessage
(-
1
,
feeJson
);
}
}
@Override
public
ServerResponse
checkMyMoney
()
{
try
{
Map
<
String
,
Object
>
map
=
currencyMapper
.
FindDataById
(
NameValue
.
Table_pay_operator_balance
,
1
);
return
ServerResponse
.
createBySuccess
(
map
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ServerResponse
.
createByError
();
}
}
@Override
public
ServerResponse
saveTheEmail
()
{
try
{
String
email
=
request
.
getParameter
(
"email"
);
email
=
URLDecoder
.
decode
(
email
,
"UTF-8"
);
System
.
out
.
println
(
email
);
Map
<
String
,
Object
>
mapUpdate
=
new
HashMap
<>();
mapUpdate
.
put
(
"email"
,
email
);
int
rest
=
commMapper
.
updateTheBalance
(
mapUpdate
);
return
ServerResponse
.
createBySuccess
(
rest
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ServerResponse
.
createByError
();
}
}
//修改运营商剩余余额记录
private
void
changeTheAmountLog
(
String
statel
,
String
mefont
,
String
cellcard
,
String
smart
,
String
remark
)
{
try
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
if
(!
TextUtils
.
isEmpty
(
statel
))
{
map
.
put
(
"statel"
,
statel
);
sentMail
(
statel
,
"statel"
);
}
if
(!
TextUtils
.
isEmpty
(
mefont
))
{
map
.
put
(
"mefont"
,
mefont
);
sentMail
(
mefont
,
"mefont"
);
}
if
(!
TextUtils
.
isEmpty
(
cellcard
))
{
map
.
put
(
"cellcard"
,
cellcard
);
sentMail
(
cellcard
,
"cellcard"
);
}
if
(!
TextUtils
.
isEmpty
(
smart
))
{
map
.
put
(
"smart"
,
smart
);
sentMail
(
smart
,
"smart"
);
}
if
(!
TextUtils
.
isEmpty
(
remark
))
{
map
.
put
(
"remark"
,
remark
);
}
commMapper
.
updateTheBalance
(
map
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
private
void
sentMail
(
String
money
,
String
operation
)
{
try
{
Map
<
String
,
Object
>
map
=
currencyMapper
.
FindDataById
(
NameValue
.
Table_pay_operator_balance
,
1
);
String
email
=
map
.
get
(
"email"
)
==
null
?
""
:
map
.
get
(
"email"
).
toString
();
String
lackbalance
=
map
.
get
(
"lackbalance"
)
==
null
?
""
:
map
.
get
(
"lackbalance"
).
toString
();
if
(!
TextUtils
.
isEmpty
(
email
)
&&
!
TextUtils
.
isEmpty
(
lackbalance
))
{
if
(
new
BigDecimal
(
money
).
compareTo
(
new
BigDecimal
(
lackbalance
))
<
0
)
{
String
[]
els
=
email
.
split
(
","
);
for
(
int
i
=
0
;
i
<
els
.
length
;
i
++)
{
SendEmailTools
.
SendMail
(
"充值系统-余额不足"
+
lackbalance
+
"美元"
,
operation
+
"运营商当前剩余余额:"
+
money
,
els
[
i
]);
}
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* 此函数非原创,从网上搜索而来,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
(
"yyyyMMddHHmmss"
);
sdf
.
setTimeZone
(
timeZone
);
return
sdf
.
format
(
new
Date
());
}
}
src/com/library/util/SendEmailTools.java
View file @
0562463e
...
...
@@ -11,16 +11,16 @@ import javax.mail.internet.MimeMessage;
public
class
SendEmailTools
{
//用于给用户发送邮件的邮箱
private
static
String
from
=
"
503781495@qq.com"
;
private
static
String
from
=
"
2142497421@qq.com"
;
//授权码 从QQ上获得
private
static
String
password
=
"
gflhiysqjvwebgfb"
;
private
static
String
password
=
"
myxetjyyawzebbdi"
;
/*
主方法测试用
*/
public
static
void
main
(
String
[]
args
)
{
SendMail
(
"
有新下的订单"
,
"aohdoiajdfjasdjf;l"
,
"503781495@qq
.com"
);
SendMail
(
"
测试"
,
"aohdoiajdfjasdjf;l"
,
"yanlveming@aliyun
.com"
);
}
...
...
src/com/library/util/SpringContextUtil.java
View file @
0562463e
...
...
@@ -2,7 +2,9 @@ package com.library.util;
import
java.util.Locale
;
import
com.library.controller.CommonController
;
import
com.library.service.AutomaticCodeService
;
import
com.library.service.CommService
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
...
...
@@ -20,6 +22,8 @@ public class SpringContextUtil implements ApplicationContextAware {
@Autowired
private
AutomaticCodeService
automaticCodeService
;
@Autowired
private
CommService
commService
;
/* (non Javadoc)
* @Title: setApplicationContext
...
...
@@ -33,6 +37,8 @@ public class SpringContextUtil implements ApplicationContextAware {
throws
BeansException
{
System
.
out
.
println
(
"========充值系统-开始系统自检========="
);
new
CheckSystem
().
start
();
new
CheckOperatorBalance1
().
start
();
new
CheckOperatorBalance2
().
start
();
context
=
applicationContext
;
}
...
...
@@ -45,7 +51,7 @@ public class SpringContextUtil implements ApplicationContextAware {
@Override
public
void
run
()
{
while
(
true
){
while
(
true
)
{
System
.
out
.
println
(
"========自检次数:"
+
i
+
"========="
);
i
++;
automaticCodeService
.
automaticForTack
();
...
...
@@ -61,6 +67,60 @@ public class SpringContextUtil implements ApplicationContextAware {
}
/**
* 进行运营商余额自检
*/
class
CheckOperatorBalance1
extends
Thread
{
int
i
=
0
;
@Override
public
void
run
()
{
while
(
true
)
{
System
.
out
.
println
(
"========进行运营商余额自检次数:"
+
i
+
"========="
);
i
++;
commService
.
queryAgentFeeInSeatel
();
try
{
sleep
(
1000
*
60
*
60
*
24
);
//24个小时更新一次
}
catch
(
InterruptedException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
}
}
/**
* 进行运营商余额自检
*/
class
CheckOperatorBalance2
extends
Thread
{
int
i
=
0
;
@Override
public
void
run
()
{
while
(
true
)
{
System
.
out
.
println
(
"========进行运营商余额自检次数:"
+
i
+
"========="
);
i
++;
commService
.
queryAgentFeeInCellcard
();
try
{
sleep
(
1000
*
60
*
60
*
24
);
//24个小时更新一次
}
catch
(
InterruptedException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
}
}
public
static
<
T
>
T
getBean
(
String
beanName
)
{
return
(
T
)
context
.
getBean
(
beanName
);
...
...
src/com/library/util/UrlInterceptor.java
View file @
0562463e
package
com
.
library
.
util
;
import
java.io.IOException
;
import
java.sql.Timestamp
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.Set
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -47,6 +50,21 @@ public class UrlInterceptor implements HandlerInterceptor{
@Override
public
boolean
preHandle
(
HttpServletRequest
req
,
HttpServletResponse
resp
,
Object
arg2
)
throws
Exception
{
/* // 设置允许多个域名请求
String[] allowDomains = {"http://www.toheart.xin","http://localhost:8080"};
Set allowOrigins = new HashSet(Arrays.asList(allowDomains));
// if (Arrays.asList(Constants.ALLOW_DOMAIN).contains(originHeader)) {
String originHeads = req.getHeader("Origin");
if(allowOrigins.contains(originHeads)){
//设置允许跨域的配置
// 这里填写你允许进行跨域的主机ip(正式上线时可以动态配置具体允许的域名和IP)
}*/
resp
.
setHeader
(
"Access-Control-Allow-Origin"
,
req
.
getHeader
(
"Origin"
));
String
reqURL
=
req
.
getRequestURI
();
System
.
out
.
println
(
Tools
.
format3
.
format
(
new
Timestamp
(
System
.
currentTimeMillis
()))+
" IP("
+
req
.
getRemoteAddr
()+
")访问的地址:"
+
reqURL
);
if
(!
CanVisit
(
reqURL
,
req
,
resp
)){
//判断管理员是否能访问
...
...
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