Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
payment
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
payment
Commits
5adb1afb
Commit
5adb1afb
authored
Oct 19, 2018
by
黄毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
双语
parent
4de105ca
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
155 additions
and
29 deletions
+155
-29
I18Config.java
src/main/java/com/egolm/payment/config/I18Config.java
+34
-0
WxApiController.java
...in/java/com/egolm/payment/controller/WxApiController.java
+3
-9
WxMiniApiController.java
...ava/com/egolm/payment/controller/WxMiniApiController.java
+19
-19
I18NUtils.java
src/main/java/com/egolm/payment/util/I18NUtils.java
+64
-0
application.properties
src/main/resources/application.properties
+2
-1
messages.properties
src/main/resources/messages.properties
+11
-0
messages_en.properties
src/main/resources/messages_en.properties
+11
-0
messages_zh_CN.properties
src/main/resources/messages_zh_CN.properties
+11
-0
No files found.
src/main/java/com/egolm/payment/config/I18Config.java
0 → 100644
View file @
5adb1afb
package
com
.
egolm
.
payment
.
config
;
import
java.util.Locale
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.LocaleResolver
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
org.springframework.web.servlet.i18n.LocaleChangeInterceptor
;
import
org.springframework.web.servlet.i18n.SessionLocaleResolver
;
@Configuration
public
class
I18Config
extends
WebMvcConfigurerAdapter
{
@Bean
public
LocaleResolver
localeResolver
()
{
SessionLocaleResolver
slr
=
new
SessionLocaleResolver
();
// 默认语言
slr
.
setDefaultLocale
(
Locale
.
SIMPLIFIED_CHINESE
);
return
slr
;
}
@Bean
public
LocaleChangeInterceptor
localeChangeInterceptor
()
{
LocaleChangeInterceptor
lci
=
new
LocaleChangeInterceptor
();
// 参数名
lci
.
setParamName
(
"langID"
);
return
lci
;
}
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
localeChangeInterceptor
());
}
}
src/main/java/com/egolm/payment/controller/WxApiController.java
View file @
5adb1afb
...
...
@@ -3,8 +3,6 @@ package com.egolm.payment.controller;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.SortedMap
;
import
java.util.TreeMap
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -16,14 +14,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.egolm.common.DateUtil
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.common.web.ServletUtil
;
import
com.egolm.payment.pojo.TSystemCtrl
;
import
com.egolm.payment.service.WxChatService
;
import
com.egolm.payment.util.PayContstrant
;
import
com.egolm.payment.util.WxSignUtil
;
import
com.egolm.payment.util.I18NUtils
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
...
...
@@ -58,7 +52,7 @@ public class WxApiController {
String
status
=
request
.
getParameter
(
"status"
);
if
(!
StringUtil
.
isNotEmpty
(
terminal
,
langID
,
orderId
,
status
)){
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"参数不能为空"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Param_notEmpty"
)
).
toJson
();
}
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"orderId"
,
orderId
);
...
...
@@ -82,7 +76,7 @@ public class WxApiController {
return
Rjx
.
jsonOk
().
toJson
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"查询异常"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Query_error"
)
).
toJson
();
}
}
}
src/main/java/com/egolm/payment/controller/WxMiniApiController.java
View file @
5adb1afb
...
...
@@ -22,6 +22,7 @@ import com.egolm.common.bean.Rjx;
import
com.egolm.common.web.ServletUtil
;
import
com.egolm.payment.pojo.TSystemCtrl
;
import
com.egolm.payment.service.WxChatService
;
import
com.egolm.payment.util.I18NUtils
;
import
com.egolm.payment.util.PayContstrant
;
import
com.egolm.payment.util.WxSignUtil
;
...
...
@@ -61,7 +62,7 @@ public class WxMiniApiController {
logger
.
info
(
terminal
+
" 获取openid时 code 为:"
+
code
);
if
(!
StringUtil
.
isNotEmpty
(
code
,
terminal
,
langID
))
{
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"参数不能为空"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Param_notEmpty"
)
).
toJson
();
}
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
...
...
@@ -72,7 +73,7 @@ public class WxMiniApiController {
params
.
put
(
"appid"
,
tSystemCtrl
.
getsValue1
());
params
.
put
(
"secret"
,
tSystemCtrl
.
getsValue2
());
}
else
{
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"openId获取失败"
).
set
(
"errorMsg"
,
"数据字典参数未配置"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Openid_failure"
)).
set
(
"errorMsg"
,
I18NUtils
.
getMessage
(
langID
,
"Msg_Datadictionary_notConfig"
)
).
toJson
();
}
params
.
put
(
"js_code"
,
code
);
...
...
@@ -111,11 +112,10 @@ public class WxMiniApiController {
})
@RequestMapping
(
value
=
"/unifiedorder"
,
method
=
RequestMethod
.
GET
)
public
String
unifiedorder
(
HttpServletRequest
request
,
HttpServletResponse
response
){
String
terminal
=
request
.
getParameter
(
"terminal"
);
String
langID
=
request
.
getParameter
(
"langID"
);
try
{
String
terminal
=
request
.
getParameter
(
"terminal"
);
String
langID
=
request
.
getParameter
(
"langID"
);
SortedMap
<
Object
,
Object
>
params
=
new
TreeMap
<
Object
,
Object
>();
String
appid
=
""
;
String
md5Key
=
""
;
...
...
@@ -132,11 +132,11 @@ public class WxMiniApiController {
params
.
put
(
"md5Key"
,
md5Key
);
if
(!
StringUtil
.
isNotEmpty
(
appid
,
mch_id
,
notify_url
,
md5Key
))
{
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"支付失败"
).
set
(
"errorMsg"
,
"数据字典参数配置不完整"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Pay_failure"
)).
set
(
"errorMsg"
,
I18NUtils
.
getMessage
(
langID
,
"Msg_Datadictionary_inComplete"
)
).
toJson
();
}
}
else
{
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"支付失败"
).
set
(
"errorMsg"
,
"数据字典参数未配置"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Pay_failure"
)).
set
(
"errorMsg"
,
I18NUtils
.
getMessage
(
langID
,
"Msg_Datadictionary_notConfig"
)
).
toJson
();
}
params
.
put
(
"nonce_str"
,
StringUtil
.
getNonceStr
());
...
...
@@ -165,7 +165,7 @@ public class WxMiniApiController {
resultMap
.
put
(
"md5Key"
,
md5Key
);
if
(!
WxSignUtil
.
checkSign
(
resultMap
,
return_sign
)){
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"微信下单失败"
).
set
(
"errorMsg"
,
"返回结果签名不一致"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_WXOrder_failure"
)).
set
(
"errorMsg"
,
I18NUtils
.
getMessage
(
langID
,
"Msg_backSign_isconsistent"
)
).
toJson
();
}
String
prepay_id
=
resultMap
.
get
(
"prepay_id"
);
...
...
@@ -188,20 +188,20 @@ public class WxMiniApiController {
if
(
return_code
.
equals
(
"FAIL"
)){
String
return_msg
=
resultMap
.
get
(
"return_msg"
);
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"微信下单失败"
).
set
(
"errorMsg"
,
return_msg
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_WXOrder_failure"
)
).
set
(
"errorMsg"
,
return_msg
).
toJson
();
}
if
(
return_code
.
equals
(
"SUCCESS"
)
&&
result_code
.
equals
(
"FAIL"
)){
String
err_code
=
resultMap
.
get
(
"err_code"
);
String
err_code_des
=
resultMap
.
get
(
"err_code_des"
);
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"微信下单失败"
).
set
(
"errorMsg"
,
err_code
).
set
(
"err_code_des"
,
err_code_des
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_WXOrder_failure"
)
).
set
(
"errorMsg"
,
err_code
).
set
(
"err_code_des"
,
err_code_des
).
toJson
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"微信下单失败"
).
set
(
"errorMsg"
,
"生成预支付订单异常"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_WXOrder_failure"
)).
set
(
"errorMsg"
,
I18NUtils
.
getMessage
(
langID
,
"Msg_Prepaid_order_error"
)
).
toJson
();
}
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"微信下单失败"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_WXOrder_failure"
)
).
toJson
();
}
...
...
@@ -240,11 +240,11 @@ public class WxMiniApiController {
md5Key
=
tSystemCtrl
.
getsValue5
();
if
(!
StringUtil
.
isNotEmpty
(
appid
,
mch_id
,
md5Key
))
{
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"支付失败"
).
set
(
"errorMsg"
,
"数据字典参数配置不完整"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Pay_failure"
)).
set
(
"errorMsg"
,
I18NUtils
.
getMessage
(
langID
,
"Msg_Datadictionary_inComplete"
)
).
toJson
();
}
}
else
{
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"支付失败"
).
set
(
"errorMsg"
,
"数据字典参数未配置"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Pay_failure"
)).
set
(
"errorMsg"
,
I18NUtils
.
getMessage
(
langID
,
"Msg_Datadictionary_notConfig"
)
).
toJson
();
}
...
...
@@ -276,20 +276,20 @@ public class WxMiniApiController {
resultMap
.
put
(
"md5Key"
,
md5Key
);
if
(!
WxSignUtil
.
checkSign
(
resultMap
,
return_sign
)){
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"退款失败"
).
set
(
"errorMsg"
,
"返回结果签名不一致"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Refund_failure"
)).
set
(
"errorMsg"
,
I18NUtils
.
getMessage
(
langID
,
"Msg_backSign_isconsistent"
)
).
toJson
();
}
return
Rjx
.
jsonOk
().
setMessage
(
"微信退款成功"
).
toJson
();
return
Rjx
.
jsonOk
().
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Refund_success"
)
).
toJson
();
}
if
(
return_code
.
equals
(
"FAIL"
)){
String
return_msg
=
resultMap
.
get
(
"return_msg"
);
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"退款失败"
).
set
(
"errorMsg"
,
return_msg
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Refund_failure"
)
).
set
(
"errorMsg"
,
return_msg
).
toJson
();
}
if
(
return_code
.
equals
(
"SUCCESS"
)
&&
result_code
.
equals
(
"FAIL"
)){
String
err_code
=
resultMap
.
get
(
"err_code"
);
String
err_code_des
=
resultMap
.
get
(
"err_code_des"
);
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"退款失败"
).
set
(
"err_code"
,
err_code
).
set
(
"errorMsg"
,
err_code_des
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Refund_failure"
)
).
set
(
"err_code"
,
err_code
).
set
(
"errorMsg"
,
err_code_des
).
toJson
();
}
...
...
src/main/java/com/egolm/payment/util/I18NUtils.java
0 → 100644
View file @
5adb1afb
package
com
.
egolm
.
payment
.
util
;
import
java.text.MessageFormat
;
import
java.util.Locale
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.MessageSource
;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.stereotype.Component
;
import
com.egolm.common.StringUtil
;
/**
*
* @ClassName: I18NUtil
* @Description: TODO( 图际化工具类)
* @author 张永
* @date 2018年4月11日 下午5:36:27
*
*/
@Component
public
class
I18NUtils
{
private
static
MessageSource
source
;
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
getMessage
(
"zh"
,
"Msg_check_key_set"
,
"AAA"
));
}
@Autowired
public
void
init
(
MessageSource
source
)
{
I18NUtils
.
source
=
source
;
}
/**
*
* <p>Title: </p>
* <p>Description: </p>
* @param LangID 语言标识 与IDC中设置 的对应
* @param key 获取的key
* @param values key中对应的值用于替换 里面的 {0} {1}...
* @return
* @author 张永
* @date 2018年4月11日 下午8:35:15
*/
public
static
String
getMessage
(
String
LangID
,
String
key
,
Object
...
values
){
if
(
StringUtil
.
isEmpty
(
LangID
)){
//为空默认为中文
Locale
.
setDefault
(
Locale
.
CHINA
);
}
else
{
if
(
LangID
.
equals
(
"900"
)){
//英文
Locale
.
setDefault
(
Locale
.
ENGLISH
);
}
else
{
Locale
.
setDefault
(
Locale
.
CHINA
);
}
}
Locale
locale
=
LocaleContextHolder
.
getLocale
();
System
.
out
.
println
(
"locale---------------"
+
locale
);
String
msg
=
source
.
getMessage
(
key
,
null
,
locale
);
return
MessageFormat
.
format
(
msg
,
values
);
}
}
src/main/resources/application.properties
View file @
5adb1afb
spring.profiles.active
=
dev
\ No newline at end of file
spring.profiles.active
=
dev
spring.messages.basename
=
messages
\ No newline at end of file
src/main/resources/messages.properties
0 → 100644
View file @
5adb1afb
Msg_Param_notEmpty
=
参数不能为空
Msg_Query_error
=
查询异常
Msg_Openid_failure
=
openId获取失败
Msg_Datadictionary_notConfig
=
数据字典参数未配置
Msg_Datadictionary_inComplete
=
数据字典参数配置不完整
Msg_Pay_failure
=
支付失败
Msg_WXOrder_failure
=
微信下单失败
Msg_backSign_isconsistent
=
返回结果签名不一致
Msg_Prepaid_order_error
=
生成预支付订单异常
Msg_Refund_failure
=
退款失败
Msg_Refund_success
=
微信退款成功
\ No newline at end of file
src/main/resources/messages_en.properties
0 → 100644
View file @
5adb1afb
Msg_Param_notEmpty
=
Parameter can not be empty
Msg_Query_error
=
Query error
Msg_Openid_failure
=
Get openId failure
Msg_Datadictionary_notConfig
=
Data dictionary parameters not configured
Msg_Datadictionary_inComplete
=
Data dictionary parameter configuration is incomplete
Msg_Pay_failure
=
Pay failure
Msg_WXOrder_failure
=
WxChat order failure
Msg_backSign_isconsistent
=
Return result signature is inconsistent
Msg_Prepaid_order_error
=
Generate prepaid order exception
Msg_Refund_failure
=
Refund failure
Msg_Refund_success
=
WxChat refund success
src/main/resources/messages_zh_CN.properties
0 → 100644
View file @
5adb1afb
Msg_Param_notEmpty
=
\u
53C2
\u6570\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
Msg_Query_error
=
\u
67E5
\u
8BE2
\u
5F02
\u
5E38
Msg_Openid_failure
=
openId
\u
83B7
\u
53D6
\u5931\u
8D25
Msg_Datadictionary_notConfig
=
\u6570\u
636E
\u
5B57
\u5178\u
53C2
\u6570\u
672A
\u
914D
\u
7F6E
Msg_Datadictionary_inComplete
=
\u6570\u
636E
\u
5B57
\u5178\u
53C2
\u6570\u
914D
\u
7F6E
\u
4E0D
\u
5B8C
\u6574
Msg_Pay_failure=
\u
652F
\u
4ED8
\u5931\u
8D25
Msg_WXOrder_failure
=
\u
5FAE
\u
4FE1
\u
4E0B
\u5355\u5931\u
8D25
Msg_backSign_isconsistent
=
\u
8FD4
\u
56DE
\u
7ED3
\u
679C
\u
7B7E
\u
540D
\u
4E0D
\u
4E00
\u
81F4
Msg_Prepaid_order_error
=
\u
751F
\u6210\u9884\u
652F
\u
4ED8
\u
8BA2
\u5355\u
5F02
\u
5E38
Msg_Refund_failure
=
\u9000\u
6B3E
\u5931\u
8D25
Msg_Refund_success
=
\u
5FAE
\u
4FE1
\u9000\u
6B3E
\u6210\u
529F
\ No newline at end of file
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