|
|
@ -58,11 +58,13 @@ public class UnifiedPayServiceImpl implements UnifiedPayService { |
|
|
@Override |
|
|
@Override |
|
|
public InOrderVo inOrder(InOrderDto dto, HttpServletRequest request) { |
|
|
public InOrderVo inOrder(InOrderDto dto, HttpServletRequest request) { |
|
|
//支付金额
|
|
|
//支付金额
|
|
|
String payAmount = ""; |
|
|
String payAmount; |
|
|
//商品类型:快手支付需要
|
|
|
//商品类型:快手支付需要
|
|
|
int goodsType; |
|
|
int goodsType; |
|
|
//payId
|
|
|
//payId
|
|
|
String payId; |
|
|
String payId; |
|
|
|
|
|
//商品描述
|
|
|
|
|
|
String goodsDesc; |
|
|
EnumSceneCode enumSceneCode = EnumSceneCode.getSceneCodeByCode(dto.getSceneCode()); |
|
|
EnumSceneCode enumSceneCode = EnumSceneCode.getSceneCodeByCode(dto.getSceneCode()); |
|
|
switch (enumSceneCode){ |
|
|
switch (enumSceneCode){ |
|
|
//会员充值场景
|
|
|
//会员充值场景
|
|
|
@ -79,12 +81,13 @@ public class UnifiedPayServiceImpl implements UnifiedPayService { |
|
|
goodsType = KSPayConstants.GOODS_TYPE_VIP; |
|
|
goodsType = KSPayConstants.GOODS_TYPE_VIP; |
|
|
payId = OrderUtil.getOrderNo("RV",new Date(), EnumUserClientType.getCodeByType(vipOrderVo.getUserClientType()) |
|
|
payId = OrderUtil.getOrderNo("RV",new Date(), EnumUserClientType.getCodeByType(vipOrderVo.getUserClientType()) |
|
|
,String.valueOf(vipOrderVo.getUserId())); |
|
|
,String.valueOf(vipOrderVo.getUserId())); |
|
|
|
|
|
goodsDesc = enumSceneCode.getName() + ":" + vipOrderVo.getVipTypeName() + "-" + vipOrderVo.getVipName(); |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
throw new ServiceException("sceneCode未匹配上对应支付场景"); |
|
|
throw new ServiceException("sceneCode未匹配上对应支付场景"); |
|
|
} |
|
|
} |
|
|
//构建统一下单请求实体
|
|
|
//构建统一下单请求实体
|
|
|
UnifiedOrderBo unifiedOrderBo = buildUnifiedOrderDto(dto, goodsType,payAmount,payId, request); |
|
|
UnifiedOrderBo unifiedOrderBo = buildUnifiedOrderDto(dto,goodsDesc, goodsType,payAmount,payId, request); |
|
|
//下单,获取第三方返回信息
|
|
|
//下单,获取第三方返回信息
|
|
|
IPayStrategy payStrategy = PayFactory.getInstance().getConcreteStrategy(dto.getPayType()); |
|
|
IPayStrategy payStrategy = PayFactory.getInstance().getConcreteStrategy(dto.getPayType()); |
|
|
if (Objects.isNull(payStrategy)){ |
|
|
if (Objects.isNull(payStrategy)){ |
|
|
@ -118,6 +121,7 @@ public class UnifiedPayServiceImpl implements UnifiedPayService { |
|
|
addPayInfoDto.setAppid(thirdInOrderVo.getAppId()); |
|
|
addPayInfoDto.setAppid(thirdInOrderVo.getAppId()); |
|
|
addPayInfoDto.setGoodsSubject(unifiedOrderBo.getGoodsSubject()); |
|
|
addPayInfoDto.setGoodsSubject(unifiedOrderBo.getGoodsSubject()); |
|
|
addPayInfoDto.setGoodsDesc(unifiedOrderBo.getGoodsDesc()); |
|
|
addPayInfoDto.setGoodsDesc(unifiedOrderBo.getGoodsDesc()); |
|
|
|
|
|
addPayInfoDto.setTradeType(dto.getTradeType()); |
|
|
// addPayInfoDto.setThirdNo(thirdInOrderVo.getPrepayid());
|
|
|
// addPayInfoDto.setThirdNo(thirdInOrderVo.getPrepayid());
|
|
|
addPayInfoDto.setIp(unifiedOrderBo.getIp()); |
|
|
addPayInfoDto.setIp(unifiedOrderBo.getIp()); |
|
|
return addPayInfoDto; |
|
|
return addPayInfoDto; |
|
|
@ -127,13 +131,14 @@ public class UnifiedPayServiceImpl implements UnifiedPayService { |
|
|
* 构建统一下单请求实体 |
|
|
* 构建统一下单请求实体 |
|
|
* |
|
|
* |
|
|
* @param dto 入参 |
|
|
* @param dto 入参 |
|
|
|
|
|
* @param goodsDesc |
|
|
* @param goodsType 商品类型 |
|
|
* @param goodsType 商品类型 |
|
|
* @param payAmount 不同支付场景下的支付金额 |
|
|
* @param payAmount 不同支付场景下的支付金额 |
|
|
* @param payId 内部系统支付单号 |
|
|
* @param payId 内部系统支付单号 |
|
|
* @param request 请求request用于获取ip地址 |
|
|
* @param request 请求request用于获取ip地址 |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
private UnifiedOrderBo buildUnifiedOrderDto(InOrderDto dto, int goodsType, String payAmount, String payId, HttpServletRequest request) { |
|
|
private UnifiedOrderBo buildUnifiedOrderDto(InOrderDto dto, String goodsDesc, int goodsType, String payAmount, String payId, HttpServletRequest request) { |
|
|
String openId = ""; |
|
|
String openId = ""; |
|
|
//当前时间
|
|
|
//当前时间
|
|
|
Date currDate = new Date(); |
|
|
Date currDate = new Date(); |
|
|
@ -146,7 +151,7 @@ public class UnifiedPayServiceImpl implements UnifiedPayService { |
|
|
unifiedOrderBo.setPayAmount(payAmount); |
|
|
unifiedOrderBo.setPayAmount(payAmount); |
|
|
unifiedOrderBo.setGoodsType(goodsType); |
|
|
unifiedOrderBo.setGoodsType(goodsType); |
|
|
unifiedOrderBo.setGoodsSubject(EnumSceneCode.getSceneCodeName(dto.getSceneCode())); |
|
|
unifiedOrderBo.setGoodsSubject(EnumSceneCode.getSceneCodeName(dto.getSceneCode())); |
|
|
unifiedOrderBo.setGoodsDesc(EnumSceneCode.getSceneCodeName(dto.getSceneCode())); |
|
|
unifiedOrderBo.setGoodsDesc(goodsDesc); |
|
|
return unifiedOrderBo; |
|
|
return unifiedOrderBo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -159,6 +164,9 @@ public class UnifiedPayServiceImpl implements UnifiedPayService { |
|
|
public QueryOrderVo queryOrder(QueryOrderDto dto) { |
|
|
public QueryOrderVo queryOrder(QueryOrderDto dto) { |
|
|
//先查询系统支付单是否已经完成支付,如果因为延迟导致没有及时同步,在调用第三方接口查询支付状态返回
|
|
|
//先查询系统支付单是否已经完成支付,如果因为延迟导致没有及时同步,在调用第三方接口查询支付状态返回
|
|
|
PayInfoDetailsVo payInfoDetailsVo = payInfoService.queryOrder(dto.getPayId()); |
|
|
PayInfoDetailsVo payInfoDetailsVo = payInfoService.queryOrder(dto.getPayId()); |
|
|
|
|
|
if (Objects.isNull(payInfoDetailsVo)){ |
|
|
|
|
|
throw new ServiceException(ResponseEnum.NOT_EXIST); |
|
|
|
|
|
} |
|
|
Integer payStatus = payInfoDetailsVo.getPayStatus(); |
|
|
Integer payStatus = payInfoDetailsVo.getPayStatus(); |
|
|
EnumPayStatus enumPayStatus = EnumPayStatus.getEnumPayStatusByStatus(payStatus); |
|
|
EnumPayStatus enumPayStatus = EnumPayStatus.getEnumPayStatusByStatus(payStatus); |
|
|
if (EnumPayStatus.NO_PAY != enumPayStatus){ |
|
|
if (EnumPayStatus.NO_PAY != enumPayStatus){ |
|
|
@ -168,16 +176,17 @@ public class UnifiedPayServiceImpl implements UnifiedPayService { |
|
|
return queryOrderVo; |
|
|
return queryOrderVo; |
|
|
} |
|
|
} |
|
|
//获取第三方订单信息
|
|
|
//获取第三方订单信息
|
|
|
IPayStrategy strategy = PayFactory.getInstance().getConcreteStrategy(dto.getPayType()); |
|
|
IPayStrategy strategy = PayFactory.getInstance().getConcreteStrategy(payInfoDetailsVo.getPayType()); |
|
|
if (Objects.isNull(strategy)){ |
|
|
if (Objects.isNull(strategy)){ |
|
|
throw new ServiceException("暂不支持该支付方式"); |
|
|
throw new ServiceException("暂不支持该支付方式"); |
|
|
} |
|
|
} |
|
|
//构建统一订单查询实体
|
|
|
//构建统一订单查询实体
|
|
|
QueryOrderBo queryOrderBo = EntityConvertUtil.copy(dto, QueryOrderBo.class); |
|
|
QueryOrderBo queryOrderBo = EntityConvertUtil.copy(dto, QueryOrderBo.class); |
|
|
|
|
|
queryOrderBo.setTradeType(payInfoDetailsVo.getTradeType()); |
|
|
ThirdQueryOrderVo thirdQueryOrderVo = strategy.queryOrder(queryOrderBo); |
|
|
ThirdQueryOrderVo thirdQueryOrderVo = strategy.queryOrder(queryOrderBo); |
|
|
QueryOrderVo queryOrderVo = new QueryOrderVo(); |
|
|
QueryOrderVo queryOrderVo = new QueryOrderVo(); |
|
|
queryOrderVo.setPayId(dto.getPayId()); |
|
|
queryOrderVo.setPayId(dto.getPayId()); |
|
|
queryOrderVo.setPayStatus(getPayStatus(dto.getPayType(), thirdQueryOrderVo.getPayStatus())); |
|
|
queryOrderVo.setPayStatus(getPayStatus(payInfoDetailsVo.getPayType(), thirdQueryOrderVo.getPayStatus())); |
|
|
return queryOrderVo; |
|
|
return queryOrderVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|