Authored by tanling

银联云闪付

... ... @@ -31,6 +31,8 @@ public class PayRefundBo {
private String serialNo;
private int orderCreateTime;
/**
* 订单类型: 买家订单 or 卖家订单
*/
... ...
... ... @@ -533,7 +533,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
Payment payment = Payment.getPayment(buyerOrder.getPayment());
if (payment != null && status == OrderStatus.WAITING_PAY.getCode()){
AbstractPayService payService = paymentService.getPayService(payment.getCode());
PayQueryBo payQueryBo = payService.payQuery(String.valueOf(buyerOrder.getOrderCode()));
PayQueryBo payQueryBo = payService.payQuery(String.valueOf(buyerOrder.getOrderCode()), buyerOrder.getCreateTime());
if (payQueryBo != null && payQueryBo.isPayStatus()){
logger.warn("check status failed ,confirm paid, uid is {}, orderCode is {}, status is {}",
... ...
... ... @@ -278,7 +278,7 @@ public class PaymentServiceImpl implements IPaymentService {
tradeNo = tradeNo + hbfqEnum.getTradeNoPostfix();
}
PayQueryBo payQueryBo = payService.payQuery(tradeNo);
PayQueryBo payQueryBo = payService.payQuery(tradeNo, orderInfo.getCreateTime());
if (!payQueryBo.isPayStatus()) {
logger.info("payConfirm has not paid, orderCode is {}", request.getOrderCode());
... ... @@ -505,7 +505,7 @@ public class PaymentServiceImpl implements IPaymentService {
// 退款
AbstractPayService payService = getPayService(orderInfo.getPayment());
PayRefundBo payRefundBo = buildRefundRequest(request, ordersPay);
PayRefundBo payRefundBo = buildRefundRequest(orderInfo, request, ordersPay);
PayRefundBo refundBo = payService.refundOpenApi(payRefundBo);
//退款申请成功的记录添加到orders_pay_refund表
... ... @@ -517,7 +517,7 @@ public class PaymentServiceImpl implements IPaymentService {
}
private PayRefundBo buildRefundRequest(PaymentRequest request, OrdersPay ordersPay) {
private PayRefundBo buildRefundRequest(OrderInfo orderInfo, PaymentRequest request, OrdersPay ordersPay) {
PayRefundBo payRefundBo = new PayRefundBo();
payRefundBo.setOrderCode(String.valueOf(request.getOrderCode()));
payRefundBo.setPayOrderCode(ordersPay.getPayOrderCode());
... ... @@ -525,7 +525,9 @@ public class PaymentServiceImpl implements IPaymentService {
payRefundBo.setOrderTotalFee(ordersPay.getAmount().doubleValue());
payRefundBo.setRefundOrderCode(String.valueOf(ordersPay.getOrderCode()) + ordersPay.getId());
payRefundBo.setUid(ordersPay.getUid());
payRefundBo.setOrderCreateTime(orderInfo.getCreateTime());
payRefundBo.setAttach(request.getRefundattch());
payRefundBo.setSerialNo(ordersPay.getSerialNo());
return payRefundBo;
}
... ... @@ -1030,6 +1032,7 @@ public class PaymentServiceImpl implements IPaymentService {
payRefundBo.setOrderTotalFee(ordersPay.getAmount().doubleValue());
payRefundBo.setRefundOrderCode(String.valueOf(ordersPay.getOrderCode()) + ordersPay.getId());
payRefundBo.setUid(ordersPay.getUid());
payRefundBo.setOrderCreateTime(orderInfo.getCreateTime());
refundBo = payService.refundOpenApi(payRefundBo);
... ...
... ... @@ -21,7 +21,7 @@ public abstract class AbstractPayService {
* @param orderCode
* @return
*/
public abstract PayQueryBo payQuery(String orderCode);
public abstract PayQueryBo payQuery(String orderCode, int orderCreateTime);
public abstract PayRefundBo refundOpenApi(PayRefundBo refundBo);
... ...
... ... @@ -108,7 +108,7 @@ public abstract class AlipayServiceAbstract extends AbstractPayService {
// }
public PayQueryBo payQuery(String tradeNo) {
public PayQueryBo payQuery(String tradeNo, int orderCreateTime) {
Map<String, String> queryParams = buildOpenApiQueryParams(tradeNo);
String respTxt = sendOpenApiRequest(tradeNo, queryParams);
QueryBo queryBo = JSON.parseObject(JSONObject.toJSONString(JSON.parseObject(respTxt).getJSONObject("alipay_trade_query_response")), QueryBo.class);
... ...
... ... @@ -192,8 +192,8 @@ public abstract class UnionpayServiceAbstract extends AbstractPayService {
return paymentData;
}
public PayQueryBo payQuery(String tradeNo) {
Map<String, String> datas = buildQueryParams(tradeNo);
public PayQueryBo payQuery(String tradeNo, int orderCreateTime) {
Map<String, String> datas = buildQueryParams(tradeNo, orderCreateTime);
Map<String, String> submitFromData = AcpService.sign(datas,
SDKConfig.getConfig().getSignCertPath() + getUnionpaySignCert(),
... ... @@ -205,7 +205,7 @@ public abstract class UnionpayServiceAbstract extends AbstractPayService {
return queryBo;
}
private Map<String, String> buildQueryParams(String tradeNo) {
private Map<String, String> buildQueryParams(String tradeNo, int orderCreateTime) {
/**
* 组装请求报文
*/
... ... @@ -227,7 +227,7 @@ public abstract class UnionpayServiceAbstract extends AbstractPayService {
// 商户代码
data.put("merId", getUnionpayMerId()); // "898111453110466");
// 订单发送时间
// data.put("txnTime", txnTime); // ❓必填吗 订单发送时间
data.put("txnTime", TimeUtils.timeStamp2Date(orderCreateTime));
// 商户订单号
data.put("orderId", tradeNo);
return data;
... ... @@ -310,7 +310,7 @@ public abstract class UnionpayServiceAbstract extends AbstractPayService {
// 商户代码
data.put("merId", getUnionpayMerId()); // "898111453110466");
// 订单发送时间
// data.put("txnTime", TimeUtils.timeStamp2Date(refundBo.getOrderCreateTime()));
data.put("txnTime", TimeUtils.timeStamp2Date(refundBo.getOrderCreateTime()));
// 商户退款单号
data.put("orderId", refundBo.getRefundOrderCode());
//原始流水号
... ...
... ... @@ -38,7 +38,7 @@ public class WalletPayService extends AbstractPayService {
* @param orderCode
* @return
*/
public PayQueryBo payQuery(String orderCode) {
public PayQueryBo payQuery(String orderCode, int payQuery) {
return null;
}
... ...
... ... @@ -69,22 +69,9 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
}
/**
* 微信交易状态查询
* @param tradeNo
* @param payType
* @param appId
* @return
*/
public PayQueryBo payQuery(String tradeNo, Payment payType) {
logger.info("WeixinQuerier enter, tradeNo: {}, payment: {}", tradeNo, payType.getCode());
PayQueryBo queryBo = payQuery(tradeNo);
logger.info("WeixinQuerier exit, tradeNo: {}, payStatus: {}, refundStatus: {}", tradeNo, queryBo.isPayStatus(), queryBo.isRefundStatus());
return queryBo;
}
public PayQueryBo payQuery(String tradeNo) {
public PayQueryBo payQuery(String tradeNo, int orderCreateTime) {
Map<String, String> queryParams = buildPayQureyParams(tradeNo);
String requestXml = WXUtils.createWXPayXml(queryParams);
String respXml = sendQueryRequest(tradeNo, requestXml);
... ...
... ... @@ -336,7 +336,7 @@ public class SellerOrderCancelService {
Payment payment = Payment.getPayment(sellerOrder.getPayment());
if (SellerOrderStatus.WAITING_PAY.getCode() == status && payment != null){
AbstractPayService payService = paymentService.getPayService(payment.getCode());
PayQueryBo payQueryBo = payService.payQuery(String.valueOf(sellerOrder.getOrderCode()));
PayQueryBo payQueryBo = payService.payQuery(String.valueOf(sellerOrder.getOrderCode()), sellerOrder.getCreateTime());
if (payQueryBo != null && payQueryBo.isPayStatus()){
logger.info("in seller timeout cancel failed, confirm paid. uid is {}, orderCode is {}", uid, orderCode);
... ...