Authored by tanling

跨境支付 推送支付单

@@ -44,6 +44,8 @@ public class DateUtil { @@ -44,6 +44,8 @@ public class DateUtil {
44 public static final String HH_mm = "HH:mm"; 44 public static final String HH_mm = "HH:mm";
45 public final static String YYYY_MM_DD_DOT="yyyy.MM.dd"; 45 public final static String YYYY_MM_DD_DOT="yyyy.MM.dd";
46 46
  47 + public final static String YYYYMMDD = "yyyymmdd";
  48 +
47 public static final String yyyyMM = "yyyyMM"; 49 public static final String yyyyMM = "yyyyMM";
48 public static final String MM_dd_yyyy_HH_mm_ssEx = "yyyy.MM.dd HH:mm"; 50 public static final String MM_dd_yyyy_HH_mm_ssEx = "yyyy.MM.dd HH:mm";
49 51
@@ -91,6 +93,11 @@ public class DateUtil { @@ -91,6 +93,11 @@ public class DateUtil {
91 } 93 }
92 94
93 95
  96 + public static String getCurrentYYYYMMDD(){
  97 + return getDateFormatEx(getCurrentTimeSecond(), YYYYMMDD);
  98 + }
  99 +
  100 +
94 public static String formatYYMMddHHmmssPoint(Integer time) 101 public static String formatYYMMddHHmmssPoint(Integer time)
95 { 102 {
96 if (time == null || time==0) { 103 if (time == null || time==0) {
@@ -68,7 +68,7 @@ @@ -68,7 +68,7 @@
68 #{payLevel,jdbcType=INTEGER}, #{serialNo,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER} 68 #{payLevel,jdbcType=INTEGER}, #{serialNo,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER}
69 ) 69 )
70 </insert> 70 </insert>
71 - <insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.OrdersPay" > 71 + <insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.OrdersPay" keyProperty="id" useGeneratedKeys="true" >
72 <!-- 72 <!--
73 WARNING - @mbggenerated 73 WARNING - @mbggenerated
74 This element is automatically generated by MyBatis Generator, do not modify. 74 This element is automatically generated by MyBatis Generator, do not modify.
@@ -8,8 +8,10 @@ import java.util.Map; @@ -8,8 +8,10 @@ import java.util.Map;
8 import javax.servlet.http.HttpServletRequest; 8 import javax.servlet.http.HttpServletRequest;
9 import javax.servlet.http.HttpServletResponse; 9 import javax.servlet.http.HttpServletResponse;
10 10
  11 +import com.yohobuy.ufo.model.order.bo.PaymentData;
11 import com.yohoufo.order.service.pay.alipay.AlipayCrossBorderService; 12 import com.yohoufo.order.service.pay.alipay.AlipayCrossBorderService;
12 import com.yohoufo.order.service.pay.alipay.AbstractAlipayService; 13 import com.yohoufo.order.service.pay.alipay.AbstractAlipayService;
  14 +import com.yohoufo.order.service.pay.alipay.bean.AlipayCustomsResponse;
13 import com.yohoufo.order.service.pay.unionpay.JsUnionpayService; 15 import com.yohoufo.order.service.pay.unionpay.JsUnionpayService;
14 import org.apache.commons.lang.StringUtils; 16 import org.apache.commons.lang.StringUtils;
15 import org.slf4j.Logger; 17 import org.slf4j.Logger;
@@ -29,7 +31,6 @@ import com.yohoufo.common.utils.WXUtil; @@ -29,7 +31,6 @@ import com.yohoufo.common.utils.WXUtil;
29 import com.yohoufo.order.constants.RefundContant; 31 import com.yohoufo.order.constants.RefundContant;
30 import com.yohoufo.order.model.NotifyResponse; 32 import com.yohoufo.order.model.NotifyResponse;
31 import com.yohoufo.order.model.PayRefundBo; 33 import com.yohoufo.order.model.PayRefundBo;
32 -import com.yohoufo.order.model.PaymentData;  
33 import com.yohoufo.order.model.TransferData; 34 import com.yohoufo.order.model.TransferData;
34 import com.yohoufo.order.model.request.PaymentRequest; 35 import com.yohoufo.order.model.request.PaymentRequest;
35 import com.yohoufo.order.model.response.PaymentConfirmRsp; 36 import com.yohoufo.order.model.response.PaymentConfirmRsp;
@@ -42,7 +43,6 @@ import com.yohoufo.order.service.pay.weixin.WeixinPayUFORealAppService; @@ -42,7 +43,6 @@ import com.yohoufo.order.service.pay.weixin.WeixinPayUFORealAppService;
42 @RequestMapping(value = "/payment") 43 @RequestMapping(value = "/payment")
43 public class PaymentController { 44 public class PaymentController {
44 45
45 -  
46 private final Logger logger = LoggerFactory.getLogger(getClass()); 46 private final Logger logger = LoggerFactory.getLogger(getClass());
47 47
48 48
@@ -120,6 +120,23 @@ public class PaymentController { @@ -120,6 +120,23 @@ public class PaymentController {
120 120
121 } 121 }
122 122
  123 + /**
  124 + * 跨境支付宝推送支付单
  125 + * @param orderCode
  126 + * @param outRequestNo
  127 + * @param tradeNo
  128 + * @param amount
  129 + * @return
  130 + */
  131 + @RequestMapping(params = "method=ufo.order.customs")
  132 + public ApiResponse customs(@RequestParam(name = "orderCode") long orderCode,
  133 + @RequestParam(name = "outRequestNo") String outRequestNo,
  134 + @RequestParam(name = "tradeNo") String tradeNo,
  135 + @RequestParam(name = "amount") double amount){
  136 + AlipayCustomsResponse alipayCustomsResponse = paymentService.customs(orderCode, outRequestNo, tradeNo, amount);
  137 + return new ApiResponse.ApiResponseBuilder().code(PrepayResponse.SUCCESS).data(alipayCustomsResponse).message("推送支付单").build();
  138 + }
  139 +
123 140
124 /** 141 /**
125 * 退款结果确认 142 * 退款结果确认
1 package com.yohoufo.order.model; 1 package com.yohoufo.order.model;
2 2
  3 +import com.yohobuy.ufo.model.order.bo.PaymentData;
  4 +
3 public class NotifyResponse { 5 public class NotifyResponse {
4 /** 6 /**
5 * 支付回调处理结果 7 * 支付回调处理结果
1 -package com.yohoufo.order.model;  
2 -  
3 -import lombok.Data;  
4 -import lombok.ToString;  
5 -  
6 -@Data  
7 -@ToString  
8 -public class PaymentData {  
9 -  
10 -  
11 - /**  
12 - * 订单Code  
13 - */  
14 - private String orderCode = "";  
15 -  
16 - /**  
17 - * 支付阶段  
18 - */  
19 - private int payLevel;  
20 -  
21 - /**  
22 - * 支付平台ID  
23 - */  
24 - private byte paymentID;  
25 -  
26 - /**  
27 - * 支付的总金额  
28 - */  
29 - private double totalFee;  
30 -  
31 - /**  
32 - * 付款时间  
33 - */  
34 - private String paymentTime = "";  
35 -  
36 -  
37 - /**  
38 - * 支付时的交易单号  
39 - */  
40 - private String outTradeNo = "";  
41 -  
42 - /**  
43 - * 回调时间  
44 - * @return  
45 - */  
46 - private String callbackTime = "";  
47 -  
48 - /**  
49 - * 银行名称,中文  
50 - */  
51 - private String bankName = "";  
52 -  
53 - /**  
54 - * 银行代码  
55 - */  
56 - private String bankCode = "";  
57 -  
58 -  
59 - /**  
60 - * 支付平台流水号  
61 - */  
62 - private String tradeNo = "";  
63 -  
64 - /**  
65 - * 银行的流水号  
66 - */  
67 - private String bankBillNo = "";  
68 -  
69 - /**  
70 - * 用户id  
71 - */  
72 - private int uid;  
73 -  
74 - /**  
75 - * 订单类型  
76 - */  
77 - private int orderType;  
78 -  
79 - /**  
80 - * 商户号  
81 - */  
82 - private String mchId;  
83 -  
84 -  
85 - //微信支付的appId  
86 - private String appId;  
87 -  
88 - //消息id  
89 - private String messageId;  
90 -  
91 - //买家  
92 - private String buyerId;  
93 -  
94 -  
95 -  
96 -  
97 -}  
@@ -3,9 +3,9 @@ package com.yohoufo.order.service; @@ -3,9 +3,9 @@ package com.yohoufo.order.service;
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONObject; 4 import com.alibaba.fastjson.JSONObject;
5 import com.github.rholder.retry.*; 5 import com.github.rholder.retry.*;
6 -import com.google.common.base.Predicates;  
7 import com.yoho.error.ServiceError; 6 import com.yoho.error.ServiceError;
8 import com.yoho.error.exception.ServiceException; 7 import com.yoho.error.exception.ServiceException;
  8 +import com.yoho.message.sdk.utils.DateUtils;
9 import com.yohobuy.ufo.model.order.bo.OrderInfo; 9 import com.yohobuy.ufo.model.order.bo.OrderInfo;
10 import com.yohobuy.ufo.model.order.common.*; 10 import com.yohobuy.ufo.model.order.common.*;
11 import com.yohobuy.ufo.model.order.constants.DepotType; 11 import com.yohobuy.ufo.model.order.constants.DepotType;
@@ -31,6 +31,8 @@ import com.yohoufo.order.service.cache.CacheCleaner; @@ -31,6 +31,8 @@ import com.yohoufo.order.service.cache.CacheCleaner;
31 import com.yohoufo.order.service.impl.*; 31 import com.yohoufo.order.service.impl.*;
32 import com.yohoufo.order.service.listener.BuyerOrderChangeEvent; 32 import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
33 import com.yohoufo.order.service.listener.OrderChangeListenerContainer; 33 import com.yohoufo.order.service.listener.OrderChangeListenerContainer;
  34 +import com.yohoufo.order.service.pay.alipay.AlipayCrossBorderService;
  35 +import com.yohoufo.order.service.pay.alipay.bean.AlipayCustomsResponse;
34 import com.yohoufo.order.service.proxy.*; 36 import com.yohoufo.order.service.proxy.*;
35 import com.yohoufo.order.utils.BuyerOrderUtils; 37 import com.yohoufo.order.utils.BuyerOrderUtils;
36 import com.yohoufo.order.utils.SellerGoodsHelper; 38 import com.yohoufo.order.utils.SellerGoodsHelper;
@@ -43,7 +45,6 @@ import org.springframework.stereotype.Service; @@ -43,7 +45,6 @@ import org.springframework.stereotype.Service;
43 45
44 import java.util.Arrays; 46 import java.util.Arrays;
45 import java.util.List; 47 import java.util.List;
46 -import java.util.concurrent.ExecutionException;  
47 import java.util.concurrent.ExecutorService; 48 import java.util.concurrent.ExecutorService;
48 import java.util.concurrent.Executors; 49 import java.util.concurrent.Executors;
49 import java.util.concurrent.TimeUnit; 50 import java.util.concurrent.TimeUnit;
@@ -108,6 +109,9 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService { @@ -108,6 +109,9 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
108 @Autowired 109 @Autowired
109 FastDeliveryProxyService fastDeliveryProxyService; 110 FastDeliveryProxyService fastDeliveryProxyService;
110 111
  112 + @Autowired
  113 + private AlipayCrossBorderService crossBorderService;
  114 +
111 private ExecutorService executors = Executors.newFixedThreadPool(1); 115 private ExecutorService executors = Executors.newFixedThreadPool(1);
112 116
113 Retryer<Object> retryer = RetryerBuilder.<Object>newBuilder() 117 Retryer<Object> retryer = RetryerBuilder.<Object>newBuilder()
@@ -438,6 +442,24 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService { @@ -438,6 +442,24 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
438 break; 442 break;
439 case OVERSEAS_IN_STOCK: 443 case OVERSEAS_IN_STOCK:
440 processOverSeasOrder(buyerOrder, sellerOrderGoods); 444 processOverSeasOrder(buyerOrder, sellerOrderGoods);
  445 +
  446 + // 跨境支付 推送支付单
  447 + if (buyerOrder.getPayment() == Payment.CROSS_BORDER_ALIPAY.getCode() && orderInfo.getPaymentData()!=null){
  448 + String outRequestNo = DateUtil.getCurrentYYYYMMDD()+orderInfo.getPaymentData().getId();
  449 + try{
  450 + AlipayCustomsResponse alipayCustomsResponse = crossBorderService.customsOpenApi(buyerOrder.getOrderCode(),
  451 + outRequestNo,
  452 + orderInfo.getPaymentData().getTradeNo(), buyerOrder.getAmount().doubleValue());
  453 + if (alipayCustomsResponse.getIs_success().equalsIgnoreCase("F")){
  454 + logger.warn("customs error. {},{},{},{}",buyerOrder.getOrderCode(), outRequestNo,
  455 + orderInfo.getPaymentData().getTradeNo(), buyerOrder.getAmount().doubleValue());
  456 + }
  457 + }catch (Exception e){
  458 + logger.warn("customs error. {},{},{},{},{}",buyerOrder.getOrderCode(), outRequestNo,
  459 + orderInfo.getPaymentData().getTradeNo(), buyerOrder.getAmount().doubleValue(),e);
  460 + }
  461 + }
  462 +
441 break; 463 break;
442 464
443 } 465 }
@@ -2,18 +2,30 @@ package com.yohoufo.order.service; @@ -2,18 +2,30 @@ package com.yohoufo.order.service;
2 2
3 3
4 import com.yohobuy.ufo.model.order.bo.OrderInfo; 4 import com.yohobuy.ufo.model.order.bo.OrderInfo;
  5 +import com.yohobuy.ufo.model.order.bo.PaymentData;
5 import com.yohobuy.ufo.model.order.req.ManualDealRequest; 6 import com.yohobuy.ufo.model.order.req.ManualDealRequest;
6 import com.yohoufo.order.model.PayRefundBo; 7 import com.yohoufo.order.model.PayRefundBo;
7 -import com.yohoufo.order.model.PaymentData;  
8 import com.yohoufo.order.model.TransferData; 8 import com.yohoufo.order.model.TransferData;
9 import com.yohoufo.order.model.request.PaymentRequest; 9 import com.yohoufo.order.model.request.PaymentRequest;
10 import com.yohoufo.order.model.request.TransferMoneyRequest; 10 import com.yohoufo.order.model.request.TransferMoneyRequest;
11 import com.yohoufo.order.model.response.PaymentConfirmRsp; 11 import com.yohoufo.order.model.response.PaymentConfirmRsp;
12 import com.yohoufo.order.model.response.PrepayResponse; 12 import com.yohoufo.order.model.response.PrepayResponse;
13 import com.yohoufo.order.service.pay.AbstractPayService; 13 import com.yohoufo.order.service.pay.AbstractPayService;
  14 +import com.yohoufo.order.service.pay.alipay.bean.AlipayCustomsResponse;
14 15
15 public interface IPaymentService { 16 public interface IPaymentService {
16 17
  18 +
  19 + /**
  20 + * 推送支付单
  21 + * @param orderCode
  22 + * @param outRequestNo
  23 + * @param tradeNo
  24 + * @param amount
  25 + * @return
  26 + */
  27 + public AlipayCustomsResponse customs(long orderCode, String outRequestNo, String tradeNo, double amount);
  28 +
17 /** 29 /**
18 * 获取订单信息(买家订单|卖家订单|入驻充值) 30 * 获取订单信息(买家订单|卖家订单|入驻充值)
19 * @param uid 31 * @param uid
@@ -10,6 +10,7 @@ import com.yoho.tools.common.beans.ApiResponse; @@ -10,6 +10,7 @@ import com.yoho.tools.common.beans.ApiResponse;
10 import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo; 10 import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
11 import com.yohobuy.ufo.model.order.bo.OrderInfo; 11 import com.yohobuy.ufo.model.order.bo.OrderInfo;
12 import com.yohobuy.ufo.model.order.bo.OutTradeNoMeta; 12 import com.yohobuy.ufo.model.order.bo.OutTradeNoMeta;
  13 +import com.yohobuy.ufo.model.order.bo.PaymentData;
13 import com.yohobuy.ufo.model.order.common.OrderCodeType; 14 import com.yohobuy.ufo.model.order.common.OrderCodeType;
14 import com.yohobuy.ufo.model.order.common.Payment; 15 import com.yohobuy.ufo.model.order.common.Payment;
15 import com.yohobuy.ufo.model.order.constants.OrderConstant; 16 import com.yohobuy.ufo.model.order.constants.OrderConstant;
@@ -30,7 +31,6 @@ import com.yohoufo.order.common.TransferCase; @@ -30,7 +31,6 @@ import com.yohoufo.order.common.TransferCase;
30 import com.yohoufo.order.constants.RefundContant; 31 import com.yohoufo.order.constants.RefundContant;
31 import com.yohoufo.order.model.PayQueryBo; 32 import com.yohoufo.order.model.PayQueryBo;
32 import com.yohoufo.order.model.PayRefundBo; 33 import com.yohoufo.order.model.PayRefundBo;
33 -import com.yohoufo.order.model.PaymentData;  
34 import com.yohoufo.order.model.TransferData; 34 import com.yohoufo.order.model.TransferData;
35 import com.yohoufo.order.model.request.PaymentRequest; 35 import com.yohoufo.order.model.request.PaymentRequest;
36 import com.yohoufo.order.model.request.TransferMoneyRequest; 36 import com.yohoufo.order.model.request.TransferMoneyRequest;
@@ -49,6 +49,7 @@ import com.yohoufo.order.service.handler.transfer.TransferChancelSelector; @@ -49,6 +49,7 @@ import com.yohoufo.order.service.handler.transfer.TransferChancelSelector;
49 import com.yohoufo.order.service.pay.AbstractPayService; 49 import com.yohoufo.order.service.pay.AbstractPayService;
50 import com.yohoufo.order.service.pay.alipay.AlipayCrossBorderService; 50 import com.yohoufo.order.service.pay.alipay.AlipayCrossBorderService;
51 import com.yohoufo.order.service.pay.alipay.AlipayOuyinService; 51 import com.yohoufo.order.service.pay.alipay.AlipayOuyinService;
  52 +import com.yohoufo.order.service.pay.alipay.bean.AlipayCustomsResponse;
52 import com.yohoufo.order.service.pay.unionpay.JsUnionpayService; 53 import com.yohoufo.order.service.pay.unionpay.JsUnionpayService;
53 import com.yohoufo.order.service.pay.wallet.WalletPayService; 54 import com.yohoufo.order.service.pay.wallet.WalletPayService;
54 import com.yohoufo.order.service.pay.weixin.WeixinMiniappPayService; 55 import com.yohoufo.order.service.pay.weixin.WeixinMiniappPayService;
@@ -181,6 +182,30 @@ public class PaymentServiceImpl implements IPaymentService { @@ -181,6 +182,30 @@ public class PaymentServiceImpl implements IPaymentService {
181 @Autowired 182 @Autowired
182 private RedisLockFactory redisLockFactory; 183 private RedisLockFactory redisLockFactory;
183 184
  185 + @Autowired
  186 + private AlipayCrossBorderService crossBorderService;
  187 +
  188 +
  189 + /**
  190 + * 推送支付单
  191 + * @param orderCode
  192 + * @param outRequestNo
  193 + * @param tradeNo
  194 + * @param amount
  195 + * @return
  196 + */
  197 + public AlipayCustomsResponse customs(long orderCode, String outRequestNo, String tradeNo, double amount){
  198 +
  199 + if (orderCode<0
  200 + || StringUtils.isEmpty(outRequestNo)
  201 + || StringUtils.isEmpty(tradeNo)
  202 + || amount < 0){
  203 + logger.warn("payConfirm request empty");
  204 + throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
  205 + }
  206 +
  207 + return crossBorderService.customsOpenApi(orderCode, outRequestNo, tradeNo, amount);
  208 + }
184 209
185 /** 210 /**
186 * 订单支付结果确认 211 * 订单支付结果确认
@@ -394,6 +419,8 @@ public class PaymentServiceImpl implements IPaymentService { @@ -394,6 +419,8 @@ public class PaymentServiceImpl implements IPaymentService {
394 ordersPay.setAttach(attach.toJSONString()); 419 ordersPay.setAttach(attach.toJSONString());
395 420
396 ordersPayMapper.insertSelective(ordersPay); 421 ordersPayMapper.insertSelective(ordersPay);
  422 +
  423 + orderInfo.setPaymentData(paymentData);
397 return ordersPay; 424 return ordersPay;
398 } 425 }
399 426
@@ -7,6 +7,7 @@ import com.yoho.error.ServiceError; @@ -7,6 +7,7 @@ import com.yoho.error.ServiceError;
7 import com.yoho.error.exception.ServiceException; 7 import com.yoho.error.exception.ServiceException;
8 import com.yohobuy.ufo.model.order.bo.OrderInfo; 8 import com.yohobuy.ufo.model.order.bo.OrderInfo;
9 import com.yohobuy.ufo.model.order.bo.OutTradeNoMeta; 9 import com.yohobuy.ufo.model.order.bo.OutTradeNoMeta;
  10 +import com.yohobuy.ufo.model.order.bo.PaymentData;
10 import com.yohobuy.ufo.model.order.common.Payment; 11 import com.yohobuy.ufo.model.order.common.Payment;
11 import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO; 12 import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
12 import com.yohoufo.common.utils.DateUtil; 13 import com.yohoufo.common.utils.DateUtil;
@@ -19,7 +20,6 @@ import com.yohoufo.order.config.AlipayConfig; @@ -19,7 +20,6 @@ import com.yohoufo.order.config.AlipayConfig;
19 import com.yohoufo.order.constants.RefundContant; 20 import com.yohoufo.order.constants.RefundContant;
20 import com.yohoufo.order.model.PayQueryBo; 21 import com.yohoufo.order.model.PayQueryBo;
21 import com.yohoufo.order.model.PayRefundBo; 22 import com.yohoufo.order.model.PayRefundBo;
22 -import com.yohoufo.order.model.PaymentData;  
23 import com.yohoufo.order.model.TransferData; 23 import com.yohoufo.order.model.TransferData;
24 import com.yohoufo.order.service.PaymentSupportService; 24 import com.yohoufo.order.service.PaymentSupportService;
25 import com.yohoufo.order.service.pay.AbstractPayService; 25 import com.yohoufo.order.service.pay.AbstractPayService;
@@ -9,6 +9,7 @@ import com.yohoufo.order.config.AlipayConfig; @@ -9,6 +9,7 @@ import com.yohoufo.order.config.AlipayConfig;
9 import com.yohoufo.order.constants.RefundContant; 9 import com.yohoufo.order.constants.RefundContant;
10 import com.yohoufo.order.model.PayQueryBo; 10 import com.yohoufo.order.model.PayQueryBo;
11 import com.yohoufo.order.model.PayRefundBo; 11 import com.yohoufo.order.model.PayRefundBo;
  12 +import com.yohoufo.order.service.pay.alipay.bean.AlipayCustomsResponse;
12 import com.yohoufo.order.service.pay.alipay.bean.AlipayQueryResponse; 13 import com.yohoufo.order.service.pay.alipay.bean.AlipayQueryResponse;
13 import com.yohoufo.order.service.pay.alipay.bean.AlipayRefundResponse; 14 import com.yohoufo.order.service.pay.alipay.bean.AlipayRefundResponse;
14 import org.slf4j.Logger; 15 import org.slf4j.Logger;
@@ -38,6 +39,27 @@ public class AlipayCrossBorderService extends AbstractAlipayService { @@ -38,6 +39,27 @@ public class AlipayCrossBorderService extends AbstractAlipayService {
38 return "zfbgj@yoho.cn"; 39 return "zfbgj@yoho.cn";
39 } 40 }
40 41
  42 +
  43 + /**
  44 + * 商户在海关系统中的code
  45 + * @return
  46 + */
  47 + private String getMerchantCustomsCode(){
  48 + return "3201962889";
  49 + }
  50 +
  51 + private String getMerchantCustomsName(){
  52 + return "南京新与力文化传播有限公司";
  53 + }
  54 +
  55 + /**
  56 + * 萝岗海关
  57 + * @return
  58 + */
  59 + private String getCustomsPlace(){
  60 + return "5224";
  61 + }
  62 +
41 /** 63 /**
42 * OpenApi退款 64 * OpenApi退款
43 * @param refundBo 65 * @param refundBo
@@ -54,6 +76,22 @@ public class AlipayCrossBorderService extends AbstractAlipayService { @@ -54,6 +76,22 @@ public class AlipayCrossBorderService extends AbstractAlipayService {
54 } 76 }
55 77
56 78
  79 + public AlipayCustomsResponse customsOpenApi(long orderCode, String outRequestNo, String tradeNo, double amount){
  80 +
  81 + logger.info("enter customsOpenApi to {}, {}, {}, {}", orderCode, outRequestNo, tradeNo, amount);
  82 +
  83 + Map<String, String> customsParam = buildOpenApiCustoms(outRequestNo, tradeNo, amount);
  84 + String respTxt = sendOpenApiRequest(String.valueOf(orderCode), customsParam, AlipayConfig.CROSS_BORDER_OPENAPI_URL);
  85 +
  86 + AlipayCustomsResponse refundResponse = (AlipayCustomsResponse)XMLUtil.convertXmlStrToObject(AlipayRefundResponse.class, respTxt);
  87 +
  88 + logger.info("exit customsOpenApi, result {}", refundResponse);
  89 +
  90 + return refundResponse;
  91 +
  92 + }
  93 +
  94 +
57 public PayRefundBo refundOpenApiConvert(String respText, PayRefundBo bo) { 95 public PayRefundBo refundOpenApiConvert(String respText, PayRefundBo bo) {
58 AlipayRefundResponse refundResponse = (AlipayRefundResponse)XMLUtil.convertXmlStrToObject(AlipayRefundResponse.class, respText); 96 AlipayRefundResponse refundResponse = (AlipayRefundResponse)XMLUtil.convertXmlStrToObject(AlipayRefundResponse.class, respText);
59 97
@@ -98,6 +136,37 @@ public class AlipayCrossBorderService extends AbstractAlipayService { @@ -98,6 +136,37 @@ public class AlipayCrossBorderService extends AbstractAlipayService {
98 return params; 136 return params;
99 } 137 }
100 138
  139 +
  140 + /**
  141 + * 给海关推支付单
  142 + * @param outRequestNo
  143 + * @param tradeNo
  144 + * @param amount
  145 + * @return
  146 + */
  147 + private Map<String, String> buildOpenApiCustoms(String outRequestNo, String tradeNo, double amount){
  148 +
  149 + Map<String, String> params = new HashMap<>();
  150 +
  151 + params.put("service","alipay.acquire.customs");
  152 + params.put("partner", getPartnerId());
  153 + params.put("_input_charset", AlipayConfig.input_charset);
  154 + params.put("sign_type", "RSA");
  155 +
  156 + params.put("out_request_no", outRequestNo);
  157 + params.put("trade_no", tradeNo);
  158 +
  159 + params.put("merchant_customs_code", getMerchantCustomsCode());
  160 + params.put("amount", String.valueOf(amount));
  161 + params.put("customs_place", getCustomsPlace());
  162 + params.put("merchant_customs_name", getMerchantCustomsName());
  163 +
  164 + String preSignStr = getOpenApiSignString(params, true);
  165 + params.put("sign", helper().signWithRsa(preSignStr,AlipayConfig.input_charset));
  166 +
  167 + return params;
  168 + }
  169 +
101 /** 170 /**
102 * 查询支付结果 171 * 查询支付结果
103 * @param tradeNo 172 * @param tradeNo
  1 +package com.yohoufo.order.service.pay.alipay.bean;
  2 +
  3 +import lombok.ToString;
  4 +
  5 +import javax.xml.bind.annotation.XmlAccessType;
  6 +import javax.xml.bind.annotation.XmlAccessorType;
  7 +import javax.xml.bind.annotation.XmlRootElement;
  8 +
  9 +@XmlAccessorType(XmlAccessType.FIELD)
  10 +@XmlRootElement(name = "alipay")
  11 +@ToString
  12 +public class AlipayCustomsResponse {
  13 +
  14 + /**
  15 + * 是否成功
  16 + * T:成功, F:失败
  17 + */
  18 + private String is_success;
  19 +
  20 +
  21 + private String error;
  22 +
  23 + private String result_code;
  24 +
  25 + private String detail_error_code;
  26 +
  27 + private String detail_error_des;
  28 +
  29 + public String getResult_code() {
  30 + return result_code;
  31 + }
  32 +
  33 + public void setResult_code(String result_code) {
  34 + this.result_code = result_code;
  35 + }
  36 +
  37 + public String getDetail_error_code() {
  38 + return detail_error_code;
  39 + }
  40 +
  41 + public void setDetail_error_code(String detail_error_code) {
  42 + this.detail_error_code = detail_error_code;
  43 + }
  44 +
  45 + public String getDetail_error_des() {
  46 + return detail_error_des;
  47 + }
  48 +
  49 + public void setDetail_error_des(String detail_error_des) {
  50 + this.detail_error_des = detail_error_des;
  51 + }
  52 +
  53 + public String getError() {
  54 + return error;
  55 + }
  56 +
  57 + public void setError(String error) {
  58 + this.error = error;
  59 + }
  60 +
  61 + public String getIs_success() {
  62 + return is_success;
  63 + }
  64 +
  65 + public void setIs_success(String is_success) {
  66 + this.is_success = is_success;
  67 + }
  68 +}
@@ -4,13 +4,13 @@ import com.alibaba.fastjson.JSONObject; @@ -4,13 +4,13 @@ import com.alibaba.fastjson.JSONObject;
4 import com.yoho.error.ServiceError; 4 import com.yoho.error.ServiceError;
5 import com.yoho.error.exception.ServiceException; 5 import com.yoho.error.exception.ServiceException;
6 import com.yohobuy.ufo.model.order.bo.OrderInfo; 6 import com.yohobuy.ufo.model.order.bo.OrderInfo;
  7 +import com.yohobuy.ufo.model.order.bo.PaymentData;
7 import com.yohoufo.common.utils.DateUtil; 8 import com.yohoufo.common.utils.DateUtil;
8 import com.yohoufo.common.utils.TimeUtils; 9 import com.yohoufo.common.utils.TimeUtils;
9 import com.yohoufo.common.utils.YHMath; 10 import com.yohoufo.common.utils.YHMath;
10 import com.yohoufo.order.constants.RefundContant; 11 import com.yohoufo.order.constants.RefundContant;
11 import com.yohoufo.order.model.PayQueryBo; 12 import com.yohoufo.order.model.PayQueryBo;
12 import com.yohoufo.order.model.PayRefundBo; 13 import com.yohoufo.order.model.PayRefundBo;
13 -import com.yohoufo.order.model.PaymentData;  
14 import com.yohoufo.order.service.pay.AbstractPayService; 14 import com.yohoufo.order.service.pay.AbstractPayService;
15 import com.yohoufo.order.service.pay.unionpay.utils.AcpService; 15 import com.yohoufo.order.service.pay.unionpay.utils.AcpService;
16 import com.yohoufo.order.service.pay.unionpay.utils.SDKConfig; 16 import com.yohoufo.order.service.pay.unionpay.utils.SDKConfig;
@@ -6,6 +6,7 @@ import com.yoho.core.security.WechatException; @@ -6,6 +6,7 @@ import com.yoho.core.security.WechatException;
6 import com.yoho.core.security.WechatHelper; 6 import com.yoho.core.security.WechatHelper;
7 import com.yoho.error.ServiceError; 7 import com.yoho.error.ServiceError;
8 import com.yoho.error.exception.ServiceException; 8 import com.yoho.error.exception.ServiceException;
  9 +import com.yohobuy.ufo.model.order.bo.PaymentData;
9 import com.yohoufo.common.utils.DateUtil; 10 import com.yohoufo.common.utils.DateUtil;
10 import com.yohoufo.common.utils.HttpClient; 11 import com.yohoufo.common.utils.HttpClient;
11 import com.yohoufo.common.utils.TimeUtils; 12 import com.yohoufo.common.utils.TimeUtils;
@@ -15,7 +16,6 @@ import com.yohoufo.order.constants.RefundContant; @@ -15,7 +16,6 @@ import com.yohoufo.order.constants.RefundContant;
15 import com.yohobuy.ufo.model.order.bo.OrderInfo; 16 import com.yohobuy.ufo.model.order.bo.OrderInfo;
16 import com.yohoufo.order.model.PayQueryBo; 17 import com.yohoufo.order.model.PayQueryBo;
17 import com.yohoufo.order.model.PayRefundBo; 18 import com.yohoufo.order.model.PayRefundBo;
18 -import com.yohoufo.order.model.PaymentData;  
19 import com.yohoufo.order.service.PaymentSupportService; 19 import com.yohoufo.order.service.PaymentSupportService;
20 import com.yohoufo.order.service.pay.AbstractPayService; 20 import com.yohoufo.order.service.pay.AbstractPayService;
21 import com.yohobuy.ufo.model.order.bo.OutTradeNoMeta; 21 import com.yohobuy.ufo.model.order.bo.OutTradeNoMeta;