|
@@ -211,16 +211,63 @@ public class AppPayController extends BaseController {
|
|
|
String returnCode = MapUtils.getString("return_code", result);
|
|
|
String returnMsg = MapUtils.getString("return_msg", result);
|
|
|
if (StringUtils.isNotBlank(returnCode) && returnCode.equals("SUCCESS")) {
|
|
|
- String refundStatus = "";
|
|
|
- //TODO:改成jdk8的形式
|
|
|
- for ( String key : result.keySet()) {
|
|
|
- if(key.startsWith("refund_status_")){
|
|
|
- refundStatus = (String) result.get(key);
|
|
|
- break;
|
|
|
+ // 响应报文
|
|
|
+ String return_code = MapUtils.getString("return_code", result);
|
|
|
+ String return_msg = MapUtils.getString("return_msg", result);
|
|
|
+ if (return_code.equalsIgnoreCase("FAIL")) {
|
|
|
+ String err_code = MapUtils.getString("err_code", result);
|
|
|
+ if(StringUtils.equals(err_code , "已全额退款")){
|
|
|
+ boolean needUpdate = false;
|
|
|
+ if(null != dbOrder.getStatus() && OrderStatusEnum.ORDER_CANCEL.getStatus().compareTo(dbOrder.getStatus()) != 0){
|
|
|
+ needUpdate = true;
|
|
|
+ dbOrder.setStatus(OrderStatusEnum.ORDER_CANCEL.getStatus());
|
|
|
+ }
|
|
|
+ if(null != dbOrder.getPayStatus() && OrderPayStatusEnum.REFUND_SUCCESS.getStatus().compareTo(dbOrder.getPayStatus()) != 0){
|
|
|
+ needUpdate = true;
|
|
|
+ dbOrder.setPayStatus(OrderPayStatusEnum.REFUND_SUCCESS.getStatus());
|
|
|
+ }
|
|
|
+ if(needUpdate){
|
|
|
+ log.info("需要更新订单状态为退款成功");
|
|
|
+ if(tmOrderService.updateWithId(dbOrder) != 1){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "更新订单为取消成功状态失败");
|
|
|
+ }
|
|
|
+ log.info("更新订单[{}]的支付状态为退款成功" , dbOrder.getId());
|
|
|
+ TmDesk tmDesk = tmDeskService.getById(dbOrder.getDeskId());
|
|
|
+ if(null != tmDesk){
|
|
|
+ if(null == tmDesk.getStatus() || tmDesk.getStatus().compareTo(1) == 0){
|
|
|
+ tmDesk.setStatus(0);
|
|
|
+ if(tmDeskService.updateWithId(tmDesk) != 1){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "更新订单为取消成功状态失败");
|
|
|
+ }
|
|
|
+ log.info("更新桌子[{}]的状态为可预订" , tmDesk.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.failure("退款处理中," + return_msg);
|
|
|
+ } else if (return_code.equalsIgnoreCase("SUCCESS")) {
|
|
|
+ String refundStatus = "";
|
|
|
+ //TODO:改成jdk8的形式
|
|
|
+ for ( String key : result.keySet()) {
|
|
|
+ if(key.startsWith("refund_status_")){
|
|
|
+ refundStatus = (String) result.get(key);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if("SUCCESS".equals(refundStatus)){
|
|
|
+ //退款成功,更新状态
|
|
|
+
|
|
|
+ return Result.success( "退款成功");
|
|
|
+ }else if("REFUNDCLOSE".equals(refundStatus)){
|
|
|
+ log.info("微信支付退款查询,微信返回退款关闭");
|
|
|
+ //退款关闭
|
|
|
+ }else if("PROCESSING".equals(refundStatus)){
|
|
|
+ //退款处理中
|
|
|
+ log.info("微信支付退款查询,微信返回退款处理中");
|
|
|
+ }else if("CHANGE".equals(refundStatus)){
|
|
|
+ //退款异常
|
|
|
+ log.info("微信支付退款查询,微信返回退款异常");
|
|
|
}
|
|
|
- }
|
|
|
- if("SUCCESS".equals(refundStatus)){
|
|
|
- //退款成功,更新状态
|
|
|
boolean needUpdate = false;
|
|
|
if(null != dbOrder.getStatus() && OrderStatusEnum.ORDER_CANCEL.getStatus().compareTo(dbOrder.getStatus()) != 0){
|
|
|
needUpdate = true;
|
|
@@ -231,9 +278,11 @@ public class AppPayController extends BaseController {
|
|
|
dbOrder.setPayStatus(OrderPayStatusEnum.REFUND_SUCCESS.getStatus());
|
|
|
}
|
|
|
if(needUpdate){
|
|
|
+ log.info("需要更新订单状态为退款成功");
|
|
|
if(tmOrderService.updateWithId(dbOrder) != 1){
|
|
|
throw new CommonBaseException(ResultCodeEnum.D101 , "更新订单为取消成功状态失败");
|
|
|
}
|
|
|
+ log.info("更新订单[{}]的支付状态为退款成功" , dbOrder.getId());
|
|
|
TmDesk tmDesk = tmDeskService.getById(dbOrder.getDeskId());
|
|
|
if(null != tmDesk){
|
|
|
if(null == tmDesk.getStatus() || tmDesk.getStatus().compareTo(1) == 0){
|
|
@@ -241,21 +290,12 @@ public class AppPayController extends BaseController {
|
|
|
if(tmDeskService.updateWithId(tmDesk) != 1){
|
|
|
throw new CommonBaseException(ResultCodeEnum.D101 , "更新订单为取消成功状态失败");
|
|
|
}
|
|
|
+ log.info("更新桌子[{}]的状态为可预订" , tmDesk.getId());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return Result.success( "退款成功");
|
|
|
- }else if("REFUNDCLOSE".equals(refundStatus)){
|
|
|
- log.info("微信支付退款查询,微信返回退款关闭");
|
|
|
- //退款关闭
|
|
|
- }else if("PROCESSING".equals(refundStatus)){
|
|
|
- //退款处理中
|
|
|
- log.info("微信支付退款查询,微信返回退款处理中");
|
|
|
- }else if("CHANGE".equals(refundStatus)){
|
|
|
- //退款异常
|
|
|
- log.info("微信支付退款查询,微信返回退款异常");
|
|
|
}
|
|
|
- return Result.success( "退款处理中");
|
|
|
+ return Result.success( "退款成功");
|
|
|
} else {
|
|
|
return Result.failure( "退款查询失败:"+ returnMsg);
|
|
|
}
|