记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
045817da
Commit
045817da
authored
Jul 21, 2021
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
order 修改 HttpOrderUtil
parent
6c4759e7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
194 additions
and
16 deletions
+194
-16
HttpOrderUtil.java
...n/java/com/liquidnet/commons/lang/util/HttpOrderUtil.java
+187
-0
HttpUtil.java
...c/main/java/com/liquidnet/commons/lang/util/HttpUtil.java
+1
-14
KylinOrderTicketsController.java
...service/order/controller/KylinOrderTicketsController.java
+3
-0
KylinOrderTicketsServiceImpl.java
...vice/order/service/impl/KylinOrderTicketsServiceImpl.java
+3
-2
No files found.
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/util/HttpOrderUtil.java
0 → 100644
View file @
045817da
package
com
.
liquidnet
.
commons
.
lang
.
util
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.client.RestTemplate
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.util.List
;
import
java.util.Map
;
@Component
public
class
HttpOrderUtil
{
@Autowired
private
RestTemplate
restTemplate
;
/**
* get请求
*
* @param url
* @param params 请求参数
* @return
*/
public
String
get
(
String
url
,
MultiValueMap
<
String
,
String
>
params
)
{
return
get
(
url
,
params
,
null
);
}
/**
* get请求
*
* @param url
* @param params 请求参数
* @param headers 请求头
* @return
*/
public
String
get
(
String
url
,
MultiValueMap
<
String
,
String
>
params
,
MultiValueMap
<
String
,
String
>
headers
)
{
return
request
(
url
,
params
,
headers
,
HttpMethod
.
GET
);
}
/**
* post请求
*
* @param url
* @param params 请求参数
* @return
*/
public
String
post
(
String
url
,
MultiValueMap
<
String
,
String
>
params
)
{
return
post
(
url
,
params
,
null
);
}
/**
* post请求
*
* @param url
* @param params 请求参数
* @param headers 请求头
* @return
*/
public
String
post
(
String
url
,
MultiValueMap
<
String
,
String
>
params
,
MultiValueMap
<
String
,
String
>
headers
)
{
return
request
(
url
,
params
,
headers
,
HttpMethod
.
POST
);
}
/**
* put请求
*
* @param url
* @param params 请求参数
* @return
*/
public
String
put
(
String
url
,
MultiValueMap
<
String
,
String
>
params
)
{
return
put
(
url
,
params
,
null
);
}
/**
* put请求
*
* @param url
* @param params 请求参数
* @param headers 请求头
* @return
*/
public
String
put
(
String
url
,
MultiValueMap
<
String
,
String
>
params
,
MultiValueMap
<
String
,
String
>
headers
)
{
return
request
(
url
,
params
,
headers
,
HttpMethod
.
PUT
);
}
/**
* delete请求
*
* @param url
* @param params 请求参数
* @return
*/
public
String
delete
(
String
url
,
MultiValueMap
<
String
,
String
>
params
)
{
return
delete
(
url
,
params
,
null
);
}
/**
* delete请求
*
* @param url
* @param params 请求参数
* @param headers 请求头
* @return
*/
public
String
delete
(
String
url
,
MultiValueMap
<
String
,
String
>
params
,
MultiValueMap
<
String
,
String
>
headers
)
{
return
request
(
url
,
params
,
headers
,
HttpMethod
.
DELETE
);
}
/**
* 表单请求
*
* @param url
* @param params 请求参数
* @param headers 请求头
* @param method 请求方式
* @return
*/
public
String
request
(
String
url
,
MultiValueMap
<
String
,
String
>
params
,
MultiValueMap
<
String
,
String
>
headers
,
HttpMethod
method
)
{
if
(
params
==
null
)
{
params
=
new
LinkedMultiValueMap
<>();
}
return
request
(
url
,
params
,
headers
,
method
,
MediaType
.
APPLICATION_FORM_URLENCODED
);
}
/**
* http请求
*
* @param url
* @param params 请求参数
* @param headers 请求头
* @param method 请求方式
* @param mediaType 参数类型
* @return
*/
public
String
request
(
String
url
,
Object
params
,
MultiValueMap
<
String
,
String
>
headers
,
HttpMethod
method
,
MediaType
mediaType
)
{
if
(
url
==
null
||
url
.
trim
().
isEmpty
())
{
return
null
;
}
// header
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
if
(
headers
!=
null
)
{
httpHeaders
.
addAll
(
headers
);
}
HttpEntity
<
Object
>
httpEntity
;
if
(
headers
!=
null
)
{
// header
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
addAll
(
headers
);
httpHeaders
.
setContentType
(
mediaType
);
httpEntity
=
new
HttpEntity
(
params
,
httpHeaders
);
}
else
{
httpEntity
=
new
HttpEntity
(
params
,
null
);
}
// 提交方式:表单、json
ResponseEntity
<
String
>
response
=
restTemplate
.
exchange
(
url
,
method
,
httpEntity
,
String
.
class
);
return
response
.
getBody
();
}
private
final
String
PHP_API_KEY
=
"R7tXY9smPQPG9Ku5yI0u6sfnlckmk04V"
;
public
String
postToPhpApi
(
String
url
,
MultiValueMap
<
String
,
String
>
params
)
{
params
.
add
(
"sign"
,
processForPhpApi
(
params
).
concat
(
"&key="
).
concat
(
PHP_API_KEY
).
toUpperCase
());
return
post
(
url
,
params
,
null
);
}
private
String
processForPhpApi
(
MultiValueMap
<
String
,
String
>
map
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
map
.
entrySet
())
{
sb
.
append
(
entry
.
getKey
()).
append
(
"="
).
append
(
entry
.
getValue
().
get
(
0
)).
append
(
"&"
);
}
String
targetStr
=
sb
.
substring
(
0
,
sb
.
length
()
-
1
);
try
{
targetStr
=
URLDecoder
.
decode
(
targetStr
,
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
targetStr
=
targetStr
.
replace
(
"%3D"
,
"="
).
replace
(
"%26"
,
"&"
);
return
targetStr
;
}
}
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/util/HttpUtil.java
View file @
045817da
package
com
.
liquidnet
.
commons
.
lang
.
util
;
package
com
.
liquidnet
.
commons
.
lang
.
util
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.*
;
import
org.springframework.http.*
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.util.MultiValueMap
;
...
@@ -13,9 +12,6 @@ import java.util.Map;
...
@@ -13,9 +12,6 @@ import java.util.Map;
public
class
HttpUtil
{
public
class
HttpUtil
{
@Autowired
private
static
RestTemplate
restTemplate
;
/**
/**
* get请求
* get请求
*
*
...
@@ -146,16 +142,7 @@ public class HttpUtil {
...
@@ -146,16 +142,7 @@ public class HttpUtil {
}
}
HttpEntity
<
Object
>
httpEntity
=
new
HttpEntity
(
params
,
httpHeaders
);
HttpEntity
<
Object
>
httpEntity
=
new
HttpEntity
(
params
,
httpHeaders
);
// HttpEntity<Object> httpEntity;
RestTemplate
restTemplate
=
new
RestTemplate
();
// if (headers != null) {
// // header
// HttpHeaders httpHeaders = new HttpHeaders();
// httpHeaders.addAll(headers);
// httpHeaders.setContentType(mediaType);
// httpEntity = new HttpEntity(params, httpHeaders);
// } else {
// httpEntity = new HttpEntity(params, null);
// }
// 提交方式:表单、json
// 提交方式:表单、json
ResponseEntity
<
String
>
response
=
restTemplate
.
exchange
(
url
,
method
,
httpEntity
,
String
.
class
);
ResponseEntity
<
String
>
response
=
restTemplate
.
exchange
(
url
,
method
,
httpEntity
,
String
.
class
);
return
response
.
getBody
();
return
response
.
getBody
();
...
...
liquidnet-bus-service/liquidnet-service-order/liquidnet-service-order-impl/src/main/java/com/liquidnet/service/order/controller/KylinOrderTicketsController.java
View file @
045817da
package
com
.
liquidnet
.
service
.
order
.
controller
;
package
com
.
liquidnet
.
service
.
order
.
controller
;
import
com.liquidnet.commons.lang.util.HttpOrderUtil
;
import
com.liquidnet.commons.lang.util.HttpUtil
;
import
com.liquidnet.service.base.ErrorMapping
;
import
com.liquidnet.service.base.ErrorMapping
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.codec.annotation.DecryptAndVerify
;
import
com.liquidnet.service.base.codec.annotation.DecryptAndVerify
;
...
@@ -17,6 +19,7 @@ import io.swagger.annotations.ApiResponse;
...
@@ -17,6 +19,7 @@ import io.swagger.annotations.ApiResponse;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
sun.net.www.http.HttpClient
;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
...
...
liquidnet-bus-service/liquidnet-service-order/liquidnet-service-order-impl/src/main/java/com/liquidnet/service/order/service/impl/KylinOrderTicketsServiceImpl.java
View file @
045817da
...
@@ -78,6 +78,8 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
...
@@ -78,6 +78,8 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
@Autowired
@Autowired
private
RedisUtil
redisUtil
;
private
RedisUtil
redisUtil
;
@Autowired
@Autowired
private
HttpOrderUtil
httpOrderUtil
;
@Autowired
private
OrderUtils
orderUtils
;
private
OrderUtils
orderUtils
;
@Autowired
@Autowired
private
RedisLockUtil
redisLockUtil
;
private
RedisLockUtil
redisLockUtil
;
...
@@ -552,12 +554,11 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
...
@@ -552,12 +554,11 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
}
}
currentTime
=
System
.
currentTimeMillis
();
currentTime
=
System
.
currentTimeMillis
();
String
returnData
=
Http
Util
.
post
(
payUrl
,
httpData
);
String
returnData
=
httpOrder
Util
.
post
(
payUrl
,
httpData
);
// log.debug("httpData = " + JSON.toJSONString(httpData));
// log.debug("httpData = " + JSON.toJSONString(httpData));
currentTime
=
System
.
currentTimeMillis
()
-
currentTime
;
currentTime
=
System
.
currentTimeMillis
()
-
currentTime
;
log
.
debug
(
"调用 PHP 支付 -> time:"
+
(
currentTime
)
+
"毫秒"
);
log
.
debug
(
"调用 PHP 支付 -> time:"
+
(
currentTime
)
+
"毫秒"
);
PayResultVo
payResultVo
=
JsonUtils
.
fromJson
(
returnData
,
PayResultVo
.
class
);
PayResultVo
payResultVo
=
JsonUtils
.
fromJson
(
returnData
,
PayResultVo
.
class
);
log
.
debug
(
"调用 PHP 支付 结果 -> "
+
JSON
.
toJSONString
(
payResultVo
));
payResultVo
.
getData
().
setOrderId
(
orderTicketId
);
payResultVo
.
getData
().
setOrderId
(
orderTicketId
);
payResultVo
.
getData
().
setPrice
(
orderTickets
.
getPriceActual
());
payResultVo
.
getData
().
setPrice
(
orderTickets
.
getPriceActual
());
orderTickets
.
setPayCode
(
payResultVo
.
getData
().
getCode
());
orderTickets
.
setPayCode
(
payResultVo
.
getData
().
getCode
());
...
...
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