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
2e51d49a
Commit
2e51d49a
authored
Oct 25, 2022
by
weijiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下单时校验订单中sku数量
parent
2ba99dc6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
0 deletions
+80
-0
soss-admin/src/main/java/com/soss/web/controller/coffee/WeixinController.java
+11
-0
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
+69
-0
No files found.
soss-admin/src/main/java/com/soss/web/controller/coffee/WeixinController.java
View file @
2e51d49a
...
@@ -8,6 +8,7 @@ import com.soss.common.utils.StringUtils;
...
@@ -8,6 +8,7 @@ import com.soss.common.utils.StringUtils;
import
com.soss.framework.web.service.TokenService
;
import
com.soss.framework.web.service.TokenService
;
import
com.soss.framework.web.service.WeixinServiceImpl
;
import
com.soss.framework.web.service.WeixinServiceImpl
;
import
com.soss.system.domain.Customer
;
import
com.soss.system.domain.Customer
;
import
com.soss.system.domain.Order
;
import
com.soss.system.domain.Shop
;
import
com.soss.system.domain.Shop
;
import
com.soss.system.service.ICustomerService
;
import
com.soss.system.service.ICustomerService
;
import
com.soss.system.service.impl.AppServiceImpl
;
import
com.soss.system.service.impl.AppServiceImpl
;
...
@@ -87,6 +88,16 @@ public class WeixinController {
...
@@ -87,6 +88,16 @@ public class WeixinController {
return
weixinService
.
wxNotify
(
request
);
return
weixinService
.
wxNotify
(
request
);
}
}
/**
* 测试支付通知
* 微信支付通过支付通知接口将用户支付成功消息通知给商户
*/
@PostMapping
(
"/native/notify/test"
)
public
String
wxNotifyTest
(
@RequestBody
Order
order
)
throws
Exception
{
System
.
out
.
println
(
"微信发送的回调"
);
return
weixinService
.
wxNotifyTest
(
order
);
}
@RequestMapping
(
"/getShop"
)
@RequestMapping
(
"/getShop"
)
public
AjaxResult
getShop
(
HttpServletRequest
request
,
@RequestParam
(
required
=
false
)
String
lng
,
@RequestParam
(
required
=
false
)
String
lat
)
{
public
AjaxResult
getShop
(
HttpServletRequest
request
,
@RequestParam
(
required
=
false
)
String
lng
,
@RequestParam
(
required
=
false
)
String
lat
)
{
...
...
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
View file @
2e51d49a
...
@@ -435,6 +435,75 @@ public class WeixinServiceImpl {
...
@@ -435,6 +435,75 @@ public class WeixinServiceImpl {
return
returnXml
;
return
returnXml
;
}
}
public
String
wxNotifyTest
(
Order
orderPo
)
throws
Exception
{
// Map<String, String> returnMap = new HashMap<>();//应答对象
//处理通知参数
// String body = this.readData(request);
// //验签
// if(!WXPayUtil.isSignatureValid(body, key)) {
// log.error("通知验签失败");
// //失败应答
// returnMap.put("return_code", "FAIL");
// returnMap.put("return_msg", "验签失败");
// String returnXml = WXPayUtil.mapToXml(returnMap);
// return returnXml;
// }
//解析xml数据
// Map<String, String> notifyMap = WXPayUtil.xmlToMap(body);
// //判断通信和业务是否成功
// if(!"SUCCESS".equals(notifyMap.get("return_code")) || !"SUCCESS".equals(notifyMap.get("result_code"))) {
// log.error("失败");
// //失败应答
// returnMap.put("return_code", "FAIL");
// returnMap.put("return_msg", "失败");
// String returnXml = WXPayUtil.mapToXml(returnMap);
// return returnXml;
// }
//获取商户订单号
// String orderNo = notifyMap.get("out_trade_no");
Order
order
=
new
Order
();
order
.
setOrderNo
(
orderPo
.
getOrderNo
());
List
<
Order
>
orders
=
orderService
.
selectOrderList
(
order
);
if
(
orders
.
isEmpty
()){
return
"没有该订单"
;
}
order
=
orders
.
get
(
0
);
//并校验返回的订单金额是否与商户侧的订单金额一致
// if (order1 != null && order1.get() != Long.parseLong(notifyMap.get("total_fee"))) {
// log.error("金额校验失败");
// //失败应答
// returnMap.put("return_code", "FAIL");
// returnMap.put("return_msg", "金额校验失败");
// String returnXml = WXPayUtil.mapToXml(returnMap);
// return returnXml;
// }
//处理订单
if
(
lock
.
tryLock
()){
try
{
//处理重复的通知
//接口调用的幂等性:无论接口被调用多少次,产生的结果是一致的。
String
orderStatus
=
order
.
getState
();
if
(
OrderStatusConstant
.
Unpaid
.
equals
(
orderStatus
))
{
//更新订单状态
order
.
setPayTime
(
new
Date
());
order
.
setState
(
OrderStatusConstant
.
Paid
);
order
.
setPickCode
(
generatePickCode
(
order
));
orderService
.
updateOrder
(
order
);
}
}
finally
{
//要主动释放锁
lock
.
unlock
();
}
}
return
"支付成功,已应答"
;
}
public
String
generatePickCode
(
Order
order
)
{
public
String
generatePickCode
(
Order
order
)
{
String
uid
=
UUID
.
randomUUID
().
toString
();
String
uid
=
UUID
.
randomUUID
().
toString
();
stringRedisTemplate
.
opsForValue
().
set
(
uid
,
String
.
valueOf
(
order
.
getId
()));
stringRedisTemplate
.
opsForValue
().
set
(
uid
,
String
.
valueOf
(
order
.
getId
()));
...
...
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