Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
soss
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hooloo
ms
soss
Commits
be82bb8a
Commit
be82bb8a
authored
Mar 11, 2023
by
caiyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复redis读取pickCode为空的问题,增加微信回调内容打印
parent
08790613
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
61 deletions
+62
-61
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
+58
-61
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
+4
-0
No files found.
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
View file @
be82bb8a
...
...
@@ -173,10 +173,10 @@ public class WeixinServiceImpl {
return
sessionKeyOrOpenId
;
}
private
LoginUser
transLoginUser
(
Customer
customer
){
private
LoginUser
transLoginUser
(
Customer
customer
)
{
SysUser
user
=
new
SysUser
();
user
.
setUserName
(
customer
.
getUserName
());
LoginUser
loginUser
=
new
LoginUser
(
user
,
null
);
LoginUser
loginUser
=
new
LoginUser
(
user
,
null
);
loginUser
.
setLoginTime
(
System
.
currentTimeMillis
());
loginUser
.
setOpenId
(
customer
.
getId
());
user
.
setPhonenumber
(
customer
.
getPhone
());
...
...
@@ -209,9 +209,9 @@ public class WeixinServiceImpl {
order
.
setOut_trade_no
(
"wuyye9w8akwbq1nc60o4affwwqnxh9dn"
);
//order.setSign_type("MD5");
//生成签名
String
sign
=
Signature
.
getSign
(
order
,
key
);
String
sign
=
Signature
.
getSign
(
order
,
key
);
order
.
setSign
(
sign
);
String
result
=
restTemplate
.
postForObject
(
queryUrl
,
order
,
String
.
class
);
String
result
=
restTemplate
.
postForObject
(
queryUrl
,
order
,
String
.
class
);
System
.
out
.
println
(
result
);
XStream
xStream
=
new
XStream
();
xStream
.
alias
(
"xml"
,
QueryReturnInfo
.
class
);
...
...
@@ -230,7 +230,7 @@ public class WeixinServiceImpl {
@Autowired
private
WxPayService
wxPayService
;
public
Map
<
String
,
String
>
weChatPay
(
HttpServletRequest
r
,
String
body
,
String
orderNo
,
String
openId
,
int
money
)
{
public
Map
<
String
,
String
>
weChatPay
(
HttpServletRequest
r
,
String
body
,
String
orderNo
,
String
openId
,
int
money
)
{
/**
* 处理内部业务,校验订单等
*/
...
...
@@ -248,7 +248,7 @@ public class WeixinServiceImpl {
//回调的 URL 地址
.
notifyUrl
(
"http://我们的域名/api/client/pay/weChatPayNotify"
)
.
build
();
WxPayUnifiedOrderResult
wxPayUnifiedOrderResult
=
null
;
WxPayUnifiedOrderResult
wxPayUnifiedOrderResult
=
null
;
try
{
wxPayUnifiedOrderResult
=
wxPayService
.
unifiedOrder
(
wxPayUnifiedOrderRequest
);
}
catch
(
WxPayException
e
)
{
...
...
@@ -258,7 +258,7 @@ public class WeixinServiceImpl {
return
null
;
}
public
String
refund
(
String
orderNo
,
String
refundNo
,
Integer
totalFee
,
Integer
refundFee
)
{
public
String
refund
(
String
orderNo
,
String
refundNo
,
Integer
totalFee
,
Integer
refundFee
)
{
//申请退款
WxPayRefundRequest
refundInfo
=
WxPayRefundRequest
.
newBuilder
()
//订单号
...
...
@@ -291,12 +291,8 @@ public class WeixinServiceImpl {
}
public
Map
<
String
,
String
>
pay
(
HttpServletRequest
r
,
String
body
,
String
orderNo
,
String
openId
,
int
money
)
{
try
{
public
Map
<
String
,
String
>
pay
(
HttpServletRequest
r
,
String
body
,
String
orderNo
,
String
openId
,
int
money
)
{
try
{
HttpClientUtils
client
=
new
HttpClientUtils
(
url
);
//组装接口参数
Map
<
String
,
String
>
params
=
new
HashMap
<>();
...
...
@@ -327,22 +323,22 @@ public class WeixinServiceImpl {
Map
<
String
,
String
>
resultMap
=
WXPayUtil
.
xmlToMap
(
resultXml
);
//错误处理
if
(
"FAIL"
.
equals
(
resultMap
.
get
(
"return_code"
))
||
"FAIL"
.
equals
(
resultMap
.
get
(
"result_code"
)))
{
if
(
"FAIL"
.
equals
(
resultMap
.
get
(
"return_code"
))
||
"FAIL"
.
equals
(
resultMap
.
get
(
"result_code"
)))
{
log
.
error
(
"微信支付统一下单错误 ===> {} "
,
resultXml
);
throw
new
RuntimeException
(
"微信支付统一下单错误"
);
}
long
time
=
System
.
currentTimeMillis
()
/
1000
;
Map
<
String
,
String
>
signInfo
=
new
HashMap
<>();
signInfo
.
put
(
"appId"
,
appid
);
signInfo
.
put
(
"timeStamp"
,
String
.
valueOf
(
time
));
signInfo
.
put
(
"nonceStr"
,
WXPayUtil
.
generateNonceStr
());
signInfo
.
put
(
"repay_id"
,
"prepay_id="
+
resultMap
.
get
(
"prepay_id"
));
signInfo
.
put
(
"signType"
,
"MD5"
);
Map
<
String
,
String
>
signInfo
=
new
HashMap
<>();
signInfo
.
put
(
"appId"
,
appid
);
signInfo
.
put
(
"timeStamp"
,
String
.
valueOf
(
time
));
signInfo
.
put
(
"nonceStr"
,
WXPayUtil
.
generateNonceStr
());
signInfo
.
put
(
"repay_id"
,
"prepay_id="
+
resultMap
.
get
(
"prepay_id"
));
signInfo
.
put
(
"signType"
,
"MD5"
);
//生成签名
Map
<
String
,
String
>
payInfo
=
new
HashMap
<>();
payInfo
.
put
(
"appId"
,
appid
);
payInfo
.
put
(
"appId"
,
appid
);
payInfo
.
put
(
"timeStamp"
,
signInfo
.
get
(
"timeStamp"
));
payInfo
.
put
(
"nonceStr"
,
signInfo
.
get
(
"nonceStr"
));
payInfo
.
put
(
"package"
,
signInfo
.
get
(
"repay_id"
));
...
...
@@ -352,8 +348,8 @@ public class WeixinServiceImpl {
// 此处可以写唤起支付前的业务逻辑
// 业务逻辑结束 回传给小程序端唤起支付
return
payInfo
;
}
catch
(
Exception
e
)
{
log
.
error
(
"微信支付发生异常"
,
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"微信支付发生异常"
,
e
);
throw
new
ServiceException
(
"微信支付异常"
);
}
}
...
...
@@ -364,9 +360,10 @@ public class WeixinServiceImpl {
//处理通知参数
String
body
=
this
.
readData
(
request
);
log
.
info
(
"wx notify receive: \n{}"
,
body
);
//验签
if
(!
WXPayUtil
.
isSignatureValid
(
body
,
key
))
{
if
(!
WXPayUtil
.
isSignatureValid
(
body
,
key
))
{
log
.
error
(
"通知验签失败"
);
//失败应答
returnMap
.
put
(
"return_code"
,
"FAIL"
);
...
...
@@ -378,7 +375,7 @@ public class WeixinServiceImpl {
//解析xml数据
Map
<
String
,
String
>
notifyMap
=
WXPayUtil
.
xmlToMap
(
body
);
//判断通信和业务是否成功
if
(!
"SUCCESS"
.
equals
(
notifyMap
.
get
(
"return_code"
))
||
!
"SUCCESS"
.
equals
(
notifyMap
.
get
(
"result_code"
)))
{
if
(!
"SUCCESS"
.
equals
(
notifyMap
.
get
(
"return_code"
))
||
!
"SUCCESS"
.
equals
(
notifyMap
.
get
(
"result_code"
)))
{
log
.
error
(
"失败"
);
//失败应答
returnMap
.
put
(
"return_code"
,
"FAIL"
);
...
...
@@ -400,7 +397,7 @@ public class WeixinServiceImpl {
// }
//处理订单
if
(
lock
.
tryLock
())
{
if
(
lock
.
tryLock
())
{
Order
order
=
new
Order
();
order
.
setOrderNo
(
orderNo
);
List
<
Order
>
orders
=
orderService
.
selectOrderList
(
order
);
...
...
@@ -467,7 +464,7 @@ public class WeixinServiceImpl {
Order
order
=
new
Order
();
order
.
setOrderNo
(
orderNo
);
List
<
Order
>
orders
=
orderService
.
selectOrderList
(
order
);
if
(
orders
.
isEmpty
())
{
if
(
orders
.
isEmpty
())
{
return
"没有该订单"
;
}
...
...
@@ -483,11 +480,11 @@ public class WeixinServiceImpl {
// }
//处理订单
if
(
lock
.
tryLock
())
{
if
(
lock
.
tryLock
())
{
try
{
//处理重复的通知
//接口调用的幂等性:无论接口被调用多少次,产生的结果是一致的。
String
orderStatus
=
order
.
getState
();
String
orderStatus
=
order
.
getState
();
if
(
OrderStatusConstant
.
Unpaid
.
equals
(
orderStatus
))
{
//更新订单状态
order
.
setPayTime
(
new
Date
());
...
...
@@ -657,76 +654,76 @@ public class WeixinServiceImpl {
shop1
.
setOrderState
(
1
);
}
String
province
=
shop1
.
getProvince
();
if
(
proString
.
contains
(
province
))
{
if
(
proString
.
contains
(
province
))
{
for
(
JSONObject
provinceObject
:
proviceList
)
{
if
(
province
.
equals
(
provinceObject
.
getString
(
"value"
)))
{
if
(
province
.
equals
(
provinceObject
.
getString
(
"value"
)))
{
JSONArray
cityChild
=
provinceObject
.
getJSONArray
(
"children"
);
boolean
cityboo
=
true
;
for
(
int
i
=
0
;
i
<
cityChild
.
size
();
i
++)
{
boolean
cityboo
=
true
;
for
(
int
i
=
0
;
i
<
cityChild
.
size
();
i
++)
{
JSONObject
city
=
cityChild
.
getJSONObject
(
i
);
if
(
shop1
.
getCity
().
equals
(
city
.
getString
(
"value"
)))
{
cityboo
=
false
;
if
(
shop1
.
getCity
().
equals
(
city
.
getString
(
"value"
)))
{
cityboo
=
false
;
JSONArray
zooeObject
=
city
.
getJSONArray
(
"children"
);
boolean
zoneBoo
=
true
;
for
(
int
j
=
0
;
j
<
zooeObject
.
size
();
j
++)
{
for
(
int
j
=
0
;
j
<
zooeObject
.
size
();
j
++)
{
JSONObject
zooe
=
zooeObject
.
getJSONObject
(
j
);
if
(
shop1
.
getZone
().
equals
(
zooe
.
getString
(
"value"
)))
{
if
(
shop1
.
getZone
().
equals
(
zooe
.
getString
(
"value"
)))
{
zoneBoo
=
false
;
JSONArray
shopInfos
=
zooe
.
getJSONArray
(
"shops"
);
shopInfos
.
add
(
shop1
);
ArrayList
<
Shop
>
shopList
=
(
ArrayList
<
Shop
>)
shopInfos
.
toJavaList
(
Shop
.
class
);
List
<
Shop
>
collect
=
shopList
.
stream
().
sorted
((
a
,
b
)
->
a
.
getDistance
().
compareTo
(
b
.
getDistance
())).
collect
(
Collectors
.
toList
());
zooe
.
put
(
"shops"
,
collect
);
zooe
.
put
(
"shops"
,
collect
);
}
}
if
(
zoneBoo
)
{
JSONObject
zone
=
new
JSONObject
();
zone
.
put
(
"value"
,
shop1
.
getZone
());
zone
.
put
(
"name"
,
JSONPath
.
read
(
areaData
,
String
.
format
(
zoneString
,
province
,
shop1
.
getCity
(),
shop1
.
getZone
())));
if
(
zoneBoo
)
{
JSONObject
zone
=
new
JSONObject
();
zone
.
put
(
"value"
,
shop1
.
getZone
());
zone
.
put
(
"name"
,
JSONPath
.
read
(
areaData
,
String
.
format
(
zoneString
,
province
,
shop1
.
getCity
(),
shop1
.
getZone
())));
zooeObject
.
add
(
zone
);
List
<
Shop
>
shopList
=
new
ArrayList
<>();
shopList
.
add
(
shop1
);
zone
.
put
(
"shops"
,
shopList
);
zone
.
put
(
"shops"
,
shopList
);
}
}
}
if
(
cityboo
)
{
if
(
cityboo
)
{
JSONObject
city
=
new
JSONObject
();
city
.
put
(
"value"
,
shop1
.
getCity
());
city
.
put
(
"name"
,
JSONPath
.
read
(
areaData
,
String
.
format
(
cityString
,
province
,
shop1
.
getCity
())));
city
.
put
(
"value"
,
shop1
.
getCity
());
city
.
put
(
"name"
,
JSONPath
.
read
(
areaData
,
String
.
format
(
cityString
,
province
,
shop1
.
getCity
())));
cityChild
.
add
(
city
);
JSONObject
zone
=
new
JSONObject
();
zone
.
put
(
"value"
,
shop1
.
getZone
());
zone
.
put
(
"name"
,
JSONPath
.
read
(
areaData
,
String
.
format
(
zoneString
,
province
,
shop1
.
getCity
(),
shop1
.
getZone
())));
JSONObject
zone
=
new
JSONObject
();
zone
.
put
(
"value"
,
shop1
.
getZone
());
zone
.
put
(
"name"
,
JSONPath
.
read
(
areaData
,
String
.
format
(
zoneString
,
province
,
shop1
.
getCity
(),
shop1
.
getZone
())));
List
<
Shop
>
shopList
=
new
ArrayList
<>();
shopList
.
add
(
shop1
);
zone
.
put
(
"shops"
,
shopList
);
zone
.
put
(
"shops"
,
shopList
);
List
<
JSONObject
>
zones
=
new
ArrayList
<>();
zones
.
add
(
zone
);
city
.
put
(
"children"
,
zones
);
city
.
put
(
"children"
,
zones
);
}
}
}
}
else
{
}
else
{
proString
.
add
(
province
);
JSONObject
provice
=
new
JSONObject
();
provice
.
put
(
"value"
,
province
);
provice
.
put
(
"value"
,
province
);
String
format
=
String
.
format
(
provinceString
,
province
);
provice
.
put
(
"name"
,
JSONPath
.
read
(
areaData
,
format
));
provice
.
put
(
"name"
,
JSONPath
.
read
(
areaData
,
format
));
proviceList
.
add
(
provice
);
JSONObject
city
=
new
JSONObject
();
city
.
put
(
"value"
,
shop1
.
getCity
());
city
.
put
(
"name"
,
JSONPath
.
read
(
areaData
,
String
.
format
(
cityString
,
province
,
shop1
.
getCity
())));
List
<
JSONObject
>
citys
=
new
ArrayList
<>();
city
.
put
(
"value"
,
shop1
.
getCity
());
city
.
put
(
"name"
,
JSONPath
.
read
(
areaData
,
String
.
format
(
cityString
,
province
,
shop1
.
getCity
())));
List
<
JSONObject
>
citys
=
new
ArrayList
<>();
citys
.
add
(
city
);
provice
.
put
(
"children"
,
citys
);
JSONObject
zone
=
new
JSONObject
();
zone
.
put
(
"value"
,
shop1
.
getZone
());
zone
.
put
(
"name"
,
JSONPath
.
read
(
areaData
,
String
.
format
(
zoneString
,
province
,
shop1
.
getCity
(),
shop1
.
getZone
())));
provice
.
put
(
"children"
,
citys
);
JSONObject
zone
=
new
JSONObject
();
zone
.
put
(
"value"
,
shop1
.
getZone
());
zone
.
put
(
"name"
,
JSONPath
.
read
(
areaData
,
String
.
format
(
zoneString
,
province
,
shop1
.
getCity
(),
shop1
.
getZone
())));
List
<
Shop
>
shopList
=
new
ArrayList
<>();
shopList
.
add
(
shop1
);
zone
.
put
(
"shops"
,
shopList
);
...
...
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
View file @
be82bb8a
...
...
@@ -92,8 +92,10 @@ public class OrderServiceImpl implements IOrderService {
public
Order
selectOrderById
(
Long
id
)
{
Order
order
=
orderMapper
.
selectOrderById
(
id
);
order
.
setShop
(
shopMapper
.
selectShopById
(
order
.
getShopId
()));
if
(!
StringUtils
.
isEmpty
(
order
.
getPickCode
()))
{
String
pickCode
=
stringRedisTemplate
.
opsForValue
().
get
(
order
.
getPickCode
());
order
.
setPickCode
(
pickCode
);
}
OrderSnapshot
orderSnapshot
=
orderSnapshotService
.
selectOrderSnapshotByOrderId
(
order
.
getId
());
String
snapshot
=
orderSnapshot
.
getSnapshot
();
List
<
OrderDetail
>
orderDetails
=
JSONObject
.
parseArray
(
snapshot
,
OrderDetail
.
class
);
...
...
@@ -615,8 +617,10 @@ public class OrderServiceImpl implements IOrderService {
String
waitTime
=
getWaitTimeByOrderId
(
order
.
getId
());
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"waitTime"
,
waitTime
);
if
(
StringUtils
.
isNotEmpty
(
order
.
getPickCode
()))
{
String
pickCode
=
stringRedisTemplate
.
opsForValue
().
get
(
order
.
getPickCode
());
map
.
put
(
"pickCode"
,
pickCode
);
}
map
.
put
(
"orderNum"
,
order
.
getOrderNum
());
map
.
put
(
"state"
,
order
.
getState
());
return
map
;
...
...
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