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

Commit b0cb215b authored by anjiabin's avatar anjiabin

提交支付查询

parent 8cbbe97f
...@@ -272,4 +272,11 @@ public class DragonConstant { ...@@ -272,4 +272,11 @@ public class DragonConstant {
this.message = message; this.message = message;
} }
} }
public static void main(String[] args) {
Integer aaa = 1;
if(aaa.toString().equals(DragonConstant.PayStatusEnum.STATUS_PAID.getCode())){
System.out.println("支付成功");
}
}
} }
package com.liquidnet.service.dragon.dto;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: DragonPayAlipayAppReqDto
* @Package com.liquidnet.service.dragon.dto
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 11:00
*/
public class DragonPayAlipayAppReqDto {
}
package com.liquidnet.service.dragon.dto;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: DragonPayAlipayAppReqDto
* @Package com.liquidnet.service.dragon.dto
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 11:00
*/
public class DragonPayAlipayAppRespDto {
}
...@@ -2,6 +2,8 @@ package com.liquidnet.service.dragon.dto; ...@@ -2,6 +2,8 @@ package com.liquidnet.service.dragon.dto;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -13,9 +15,11 @@ import lombok.Data; ...@@ -13,9 +15,11 @@ import lombok.Data;
*/ */
@Data @Data
public class DragonPayOrderQueryRespDto { public class DragonPayOrderQueryRespDto {
private Integer status;
private String type;
private String code; private String code;
private String paymentId;
private String orderCode; private String orderCode;
private BigDecimal price;
private String status; private String paymentType;
} }
...@@ -119,9 +119,6 @@ public class AlipayBiz extends DragonPayBiz { ...@@ -119,9 +119,6 @@ public class AlipayBiz extends DragonPayBiz {
*/ */
public static Map<String, Object> tradeQuery(String outTradeNo) { public static Map<String, Object> tradeQuery(String outTradeNo) {
log.info("======>支付宝交易查询"); log.info("======>支付宝交易查询");
String charset = "UTF-8";
String format = "json";
String signType = "RSA2";
AlipayClient alipayClient = PayAlipayUtils.getInstance().getHttpClient(); AlipayClient alipayClient = PayAlipayUtils.getInstance().getHttpClient();
SortedMap<String, Object> bizContentMap = new TreeMap<>(); SortedMap<String, Object> bizContentMap = new TreeMap<>();
......
...@@ -140,8 +140,13 @@ public class PayChannelStrategyAlipayImpl implements IPayChannelStrategy { ...@@ -140,8 +140,13 @@ public class PayChannelStrategyAlipayImpl implements IPayChannelStrategy {
@Override @Override
public DragonPayOrderQueryRespDto checkOrderStatus(String code) { public DragonPayOrderQueryRespDto checkOrderStatus(String code) {
Map<String, Object> result = alipayBiz.tradeQuery(code); Map<String, Object> resultMap = alipayBiz.tradeQuery(code);
DragonPayOrderQueryRespDto respDto = new DragonPayOrderQueryRespDto(); DragonPayOrderQueryRespDto respDto = new DragonPayOrderQueryRespDto();
if ("10000".equals(resultMap.get("code"))) {
}else{
}
return respDto; return respDto;
} }
......
...@@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
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.Set;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.TreeMap; import java.util.TreeMap;
...@@ -52,15 +51,11 @@ public class WepayBiz extends DragonPayBiz{ ...@@ -52,15 +51,11 @@ public class WepayBiz extends DragonPayBiz{
String sign = PayWepayUtils.getInstance().createSign(paramMap); String sign = PayWepayUtils.getInstance().createSign(paramMap);
paramMap.put("sign", sign); paramMap.put("sign", sign);
Set<String> ks = paramMap.keySet();
String data = PayWepayUtils.getInstance().getRequestXml(paramMap); String data = PayWepayUtils.getInstance().getRequestXml(paramMap);
try{ try{
HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/pay/orderquery"); HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/pay/orderquery");
httpost.setEntity(new StringEntity(data, "UTF-8")); httpost.setEntity(new StringEntity(data, "UTF-8"));
CloseableHttpResponse response = null; CloseableHttpResponse response = PayWepayUtils.getInstance().getHttpClient().execute(httpost);
response = PayWepayUtils.getInstance().getHttpClient().execute(httpost);
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
//接受到返回信息 //接受到返回信息
String xmlStr = EntityUtils.toString(response.getEntity(), "UTF-8"); String xmlStr = EntityUtils.toString(response.getEntity(), "UTF-8");
......
...@@ -158,8 +158,12 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy { ...@@ -158,8 +158,12 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
WepayOrderQueryRespDto result = wepayBiz.tradeQuery(code,this.getAppid()); WepayOrderQueryRespDto result = wepayBiz.tradeQuery(code,this.getAppid());
DragonPayOrderQueryRespDto respDto = new DragonPayOrderQueryRespDto(); DragonPayOrderQueryRespDto respDto = new DragonPayOrderQueryRespDto();
respDto.setCode(code); respDto.setCode(code);
respDto.setOrderCode(""); // respDto.setOrderCode("");
respDto.setStatus(""); // respDto.setStatus("");
// respDto.setType();
// respDto.setPaymentId();
// respDto.setPrice();
// respDto.setPaymentType();
return respDto; return respDto;
} }
......
...@@ -66,7 +66,7 @@ public class PayController { ...@@ -66,7 +66,7 @@ public class PayController {
@RequestParam(value = "notifyUrl") @NotNull(message = "通知Url不能为空") String notifyUrl, @RequestParam(value = "notifyUrl") @NotNull(message = "通知Url不能为空") String notifyUrl,
@RequestParam(value = "returnUrl",required = false) String returnUrl, @RequestParam(value = "returnUrl",required = false) String returnUrl,
// @RequestParam(value = "quitUrl",required = false) String quitUrl, // @RequestParam(value = "quitUrl",required = false) String quitUrl,
// @RequestParam(value = "showUrl",required = false) String showUrl, @RequestParam(value = "showUrl",required = false) String showUrl,
// @RequestParam(value = "code",required = false) String code, // @RequestParam(value = "code",required = false) String code,
@RequestParam(value = "createDate",required = true) String createDate, @RequestParam(value = "createDate",required = true) String createDate,
@RequestParam(value = "expireTime",required = true) String expireTime){ @RequestParam(value = "expireTime",required = true) String expireTime){
...@@ -91,14 +91,14 @@ public class PayController { ...@@ -91,14 +91,14 @@ public class PayController {
dragonPayBaseReqDto.setNotifyUrl(notifyUrl); dragonPayBaseReqDto.setNotifyUrl(notifyUrl);
dragonPayBaseReqDto.setReturnUrl(returnUrl); dragonPayBaseReqDto.setReturnUrl(returnUrl);
// dragonPayBaseReqDto.setQuitUrl(quitUrl); // dragonPayBaseReqDto.setQuitUrl(quitUrl);
// dragonPayBaseReqDto.setShowUrl(showUrl); dragonPayBaseReqDto.setShowUrl(showUrl);
// dragonPayBaseReqDto.setCode(code); // dragonPayBaseReqDto.setCode(code);
dragonPayBaseReqDto.setCreateDate(createDate); dragonPayBaseReqDto.setCreateDate(createDate);
dragonPayBaseReqDto.setExpireTime(expireTime); dragonPayBaseReqDto.setExpireTime(expireTime);
return dragonOrdersService.dragonPay(dragonPayBaseReqDto); return dragonOrdersService.dragonPay(dragonPayBaseReqDto);
} }
@PostMapping("/checkOrder") @GetMapping("/checkOrder")
@ApiOperation("订单查询") @ApiOperation("订单查询")
@ApiResponse(code = 200, message = "接口返回对象参数") @ApiResponse(code = 200, message = "接口返回对象参数")
@ApiImplicitParams({ @ApiImplicitParams({
......
...@@ -51,12 +51,26 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService { ...@@ -51,12 +51,26 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
if(StringUtil.isEmpty(ordersDto)){ if(StringUtil.isEmpty(ordersDto)){
throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getCode(),DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getMessage()); throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getCode(),DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getMessage());
} }
//如果已支付 直接返回结果
if(!ordersDto.getStatus().toString().equals(DragonConstant.PayStatusEnum.STATUS_UNPAID.getCode())){
DragonPayOrderQueryRespDto queryRespDto = new DragonPayOrderQueryRespDto();
queryRespDto.setStatus(ordersDto.getStatus());
queryRespDto.setType(ordersDto.getType());
queryRespDto.setCode(ordersDto.getCode());
queryRespDto.setPaymentId(ordersDto.getPaymentId());
queryRespDto.setOrderCode(ordersDto.getOrderCode());
queryRespDto.setPrice(ordersDto.getPrice());
queryRespDto.setPaymentType(ordersDto.getPaymentType());
return queryRespDto;
}
//如果未支付进行三方查询
String payType = DragonConstant.PayTypeEnum.getEnumByCode(ordersDto.getPaymentType()).getPayType(); String payType = DragonConstant.PayTypeEnum.getEnumByCode(ordersDto.getPaymentType()).getPayType();
return payChannelStrategyContext.getStrategy(payType).checkOrderStatus(code); return payChannelStrategyContext.getStrategy(payType).checkOrderStatus(code);
} }
@Override @Override
public DragonPayOrderQueryRespDto checkOrderStatusByOrderCode(String orderCode) { public DragonPayOrderQueryRespDto checkOrderStatusByOrderCode(String orderCode) {
return null; String code = dataUtils.getCodeByOrderCode(orderCode);
return this.checkOrderStatusByCode(code);
} }
} }
...@@ -11,6 +11,16 @@ public class DataUtils { ...@@ -11,6 +11,16 @@ public class DataUtils {
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
/**
* 根据订单编号获取支付code
* @param orderCode
* @return
*/
public String getCodeByOrderCode(String orderCode) {
//获取支付订单号
return (String) redisUtil.get(DragonConstant.REDIS_KET_PAY_ORDERCODE + orderCode);
}
public void createPayOrder(String orderCode, String code, DragonOrdersDto ordersDto) { public void createPayOrder(String orderCode, String code, DragonOrdersDto ordersDto) {
if (!redisUtil.hasKey(DragonConstant.REDIS_KET_PAY_ORDERCODE + orderCode)) { if (!redisUtil.hasKey(DragonConstant.REDIS_KET_PAY_ORDERCODE + orderCode)) {
redisUtil.set(DragonConstant.REDIS_KET_PAY_ORDERCODE + orderCode, code); redisUtil.set(DragonConstant.REDIS_KET_PAY_ORDERCODE + orderCode, code);
......
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