记得上下班打卡 | git大法好,push需谨慎

Commit 0762d4f3 authored by anjiabin's avatar anjiabin

修改支付通知逻辑

parent 8bb6aaa3
...@@ -27,7 +27,9 @@ public enum DragonErrorCodeEnum { ...@@ -27,7 +27,9 @@ public enum DragonErrorCodeEnum {
TRADE_ALIPAY_QUERY_ERROR("PAY0010010","支付宝订单查询失败!"), TRADE_ALIPAY_QUERY_ERROR("PAY0010010","支付宝订单查询失败!"),
TRADE_WEPAY_SIGN_ERROR("PAY0020001","微信签名异常!"); TRADE_WEPAY_SIGN_ERROR("PAY0020001","微信签名异常!"),
TRADE_WEPAY_QUERY_ERROR("PAY0020002","微信订单查询失败!");
private String code; private String code;
private String message; private String message;
......
...@@ -152,7 +152,8 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl ...@@ -152,7 +152,8 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ALIPAY_QUERY_ERROR.getCode(),DragonErrorCodeEnum.TRADE_ALIPAY_QUERY_ERROR.getMessage()); throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ALIPAY_QUERY_ERROR.getCode(),DragonErrorCodeEnum.TRADE_ALIPAY_QUERY_ERROR.getMessage());
} }
// 当返回状态为“TRADE_FINISHED”交易成功结束和“TRADE_SUCCESS”支付成功时更新交易状态 // 当返回状态为“TRADE_FINISHED”交易成功结束和“TRADE_SUCCESS”支付成功时更新交易状态
if ("TRADE_SUCCESS".equals(resultMap.get("tradeStatus")) || "TRADE_FINISHED".equals(resultMap.get("tradeStatus"))) { if (AlipayConstant.AlipayTradeStateEnum.TRADE_SUCCESS.getCode().equals(resultMap.get("tradeStatus"))
|| AlipayConstant.AlipayTradeStateEnum.TRADE_FINISHED.getCode().equals(resultMap.get("tradeStatus"))) {
respDto.setStatus(Integer.valueOf(DragonConstant.PayStatusEnum.STATUS_PAID.getCode())); respDto.setStatus(Integer.valueOf(DragonConstant.PayStatusEnum.STATUS_PAID.getCode()));
} }
return respDto; return respDto;
......
package com.liquidnet.service.dragon.channel.wepay.biz; package com.liquidnet.service.dragon.channel.wepay.biz;
import com.liquidnet.service.dragon.channel.wepay.resp.WepayOrderQueryRespDto;
import com.liquidnet.service.dragon.utils.PayWepayUtils; import com.liquidnet.service.dragon.utils.PayWepayUtils;
import com.liquidnet.service.dragon.utils.XmlUtil; import com.liquidnet.service.dragon.utils.XmlUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -12,6 +11,8 @@ import org.apache.http.util.EntityUtils; ...@@ -12,6 +11,8 @@ import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.TreeMap; import java.util.TreeMap;
...@@ -35,9 +36,9 @@ public class WepayBiz{ ...@@ -35,9 +36,9 @@ public class WepayBiz{
* *
* @return * @return
*/ */
public WepayOrderQueryRespDto tradeQuery(String outTradeNo,String appid) { public Map<String, Object> tradeQuery(String outTradeNo, String appid) {
Map<String, Object> respMap = new HashMap<>();
log.info("======>支付宝交易查询"); log.info("======>支付宝交易查询");
WepayOrderQueryRespDto respDto = null;
SortedMap<String, Object> paramMap = new TreeMap<>(); SortedMap<String, Object> paramMap = new TreeMap<>();
paramMap.put("appid", appid); paramMap.put("appid", appid);
paramMap.put("mch_id", merchantId); paramMap.put("mch_id", merchantId);
...@@ -57,11 +58,11 @@ public class WepayBiz{ ...@@ -57,11 +58,11 @@ public class WepayBiz{
String xmlStr = EntityUtils.toString(response.getEntity(), "UTF-8"); String xmlStr = EntityUtils.toString(response.getEntity(), "UTF-8");
EntityUtils.consume(entity); EntityUtils.consume(entity);
log.info("dragonPay:wepay:wap response xmlStr: {} ",xmlStr); log.info("dragonPay:wepay:wap response xmlStr: {} ",xmlStr);
respDto = XmlUtil.toBean(xmlStr, WepayOrderQueryRespDto.class); respMap = XmlUtil.xmlToMap(xmlStr);
}catch (Exception e){ }catch (Exception e){
log.error(e.getMessage()); log.error(e.getMessage());
} }
return respDto; return respMap;
} }
} }
...@@ -4,15 +4,18 @@ import com.liquidnet.common.exception.LiquidnetServiceException; ...@@ -4,15 +4,18 @@ import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.commons.lang.util.DateUtil; import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.biz.DragonServiceCommonBiz; import com.liquidnet.service.dragon.biz.DragonServiceCommonBiz;
import com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz;
import com.liquidnet.service.dragon.channel.wepay.biz.WepayBiz; import com.liquidnet.service.dragon.channel.wepay.biz.WepayBiz;
import com.liquidnet.service.dragon.channel.wepay.constant.WepayConstant; import com.liquidnet.service.dragon.channel.wepay.constant.WepayConstant;
import com.liquidnet.service.dragon.channel.wepay.resp.WepayOrderQueryRespDto;
import com.liquidnet.service.dragon.channel.wepay.resp.WepayPayRespDto; import com.liquidnet.service.dragon.channel.wepay.resp.WepayPayRespDto;
import com.liquidnet.service.dragon.channel.wepay.strategy.IWepayStrategy; import com.liquidnet.service.dragon.channel.wepay.strategy.IWepayStrategy;
import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.constant.DragonErrorCodeEnum; import com.liquidnet.service.dragon.constant.DragonErrorCodeEnum;
import com.liquidnet.service.dragon.dto.DragonOrdersDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto; import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto; import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto; import com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto;
import com.liquidnet.service.dragon.utils.DataUtils;
import com.liquidnet.service.dragon.utils.PayWepayUtils; import com.liquidnet.service.dragon.utils.PayWepayUtils;
import com.liquidnet.service.dragon.utils.XmlUtil; import com.liquidnet.service.dragon.utils.XmlUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -26,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -26,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.util.Map;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.TreeMap; import java.util.TreeMap;
...@@ -43,9 +47,15 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy { ...@@ -43,9 +47,15 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
@Autowired @Autowired
private WepayBiz wepayBiz; private WepayBiz wepayBiz;
@Autowired
private DataUtils dataUtils;
@Autowired @Autowired
private DragonServiceCommonBiz dragonServiceCommonBiz; private DragonServiceCommonBiz dragonServiceCommonBiz;
@Autowired
private DragonPayBiz dragonPayBiz;
@Override @Override
public ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto) { public ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto) {
...@@ -159,15 +169,19 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy { ...@@ -159,15 +169,19 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
@Override @Override
public DragonPayOrderQueryRespDto checkOrderStatus(String code) { public DragonPayOrderQueryRespDto checkOrderStatus(String code) {
WepayOrderQueryRespDto result = wepayBiz.tradeQuery(code,this.getAppid()); DragonOrdersDto ordersDto = dataUtils.getPayOrderByCode(code);
DragonPayOrderQueryRespDto respDto = new DragonPayOrderQueryRespDto(); Map<String, Object> resultMap = wepayBiz.tradeQuery(code,this.getAppid());
respDto.setCode(code); DragonPayOrderQueryRespDto respDto = dragonPayBiz.buildPayOrderQueryRespDto(ordersDto);
// respDto.setOrderCode("");
// respDto.setStatus(""); Object returnCode = resultMap.get("return_code");
// respDto.setType(); // 查询失败
// respDto.setPaymentId(); if (null == returnCode || "FAIL".equals(returnCode)) {
// respDto.setPrice(); throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_WEPAY_QUERY_ERROR.getCode(),DragonErrorCodeEnum.TRADE_WEPAY_QUERY_ERROR.getMessage());
// respDto.setPaymentType(); }
// 当trade_state为SUCCESS时才返回result_code
if ("SUCCESS".equals(resultMap.get("trade_state"))) {
respDto.setStatus(Integer.valueOf(DragonConstant.PayStatusEnum.STATUS_PAID.getCode()));
}
return respDto; return respDto;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment