Browse Source

增加支付日志

liweifan 3 năm trước cách đây
mục cha
commit
f6cbd57156

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java

@@ -271,7 +271,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
             OrderCreateRes createRes = createResult.getData();
             if (!createResult.getStatus() || null == createRes || !createRes.getRes()) {
                 log.info("订单[创建订单] Res:{}", JSONObject.toJSONString(createResult));
-                return HttpResponseResult.failed("订单商品信息获取失败");
+                return HttpResponseResult.failed(StringUtil.isEmpty(createResult.getMsg()) ? "订单商品信息获取失败" : createResult.getMsg());
             }
             createRes.setGoodType(info.getGoodType());
             //todo 优惠券优惠金额,暂时为0

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/StudentHomeVo.java

@@ -48,7 +48,7 @@ public class StudentHomeVo extends Student {
     private Date birthdate;
     @ApiModelProperty(value = "是否实名 0否 1是")
     private YesOrNoEnum isReal;
-    @ApiModelProperty(value = "学生 STUDENT 老师 TEACHER 系统用户 STSTEM")
+    @ApiModelProperty(value = "学生 STUDENT 老师 TEACHER 系统用户 SYSTEM")
     private String userType;
 
     public String getHeardUrl() {

+ 0 - 3
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/adapay/AdapayTemplate.java

@@ -65,8 +65,6 @@ public class AdapayTemplate implements PaymentTemplate {
                 + "/" + payment.getPayChannel().getCode()
                 + "/executePayment"
         );
-
-        log.info("汇付[创建支付对象] Req:{}", JSONObject.toJSONString(paymentMap));
         //调用sdk方法,创建支付,得到支付对象
         Map<String, Object> res;
         try {
@@ -178,7 +176,6 @@ public class AdapayTemplate implements PaymentTemplate {
     @Override
     public BaseResult<PaymentCallBack> analysisNotice(OpenEnum openType, PaymentClientEnum paymentClient, PayChannelEnum payChannel, MethodNameEnum methodName, HttpServletRequest request) {
         PaymentCallBack paymentCallBack = new PaymentCallBack();
-
         try {
             //验签传参data
             String data = request.getParameter("data");

+ 24 - 5
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/service/impl/PaymentClientImpl.java

@@ -1,5 +1,6 @@
 package com.yonge.toolset.payment.core.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.yonge.toolset.base.result.BaseResult;
 import com.yonge.toolset.payment.base.PaymentTemplate;
 import com.yonge.toolset.payment.base.enums.MethodNameEnum;
@@ -13,6 +14,8 @@ import com.yonge.toolset.payment.base.model.RefundBill;
 import com.yonge.toolset.payment.base.model.callback.PaymentCallBack;
 import com.yonge.toolset.payment.core.util.PaywayUtil;
 import com.yonge.toolset.payment.core.service.PaymentClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletRequest;
@@ -24,6 +27,8 @@ import java.util.Map;
  */
 @Service
 public class PaymentClientImpl implements PaymentClient {
+    private final static Logger log = LoggerFactory.getLogger(PaymentClientImpl.class);
+
     @Override
     public BaseResult<Map<String, Object>> getOpenAuthMsg(OpenAuth openAuth) {
         return PaywayUtil.getRealTemplate(openAuth.getOpenType(), openAuth.getPayChannel()).getOpenAuthMsg(openAuth);
@@ -31,26 +36,40 @@ public class PaymentClientImpl implements PaymentClient {
 
     @Override
     public BaseResult<Payment> executePayment(Payment payment) {
-        return PaywayUtil.getRealTemplate(payment.getOpenType(), payment.getPayChannel()).executePayment(payment);
+        log.info("支付-付款请求参数:{}", JSONObject.toJSONString(payment));
+        BaseResult<Payment> paymentBaseResult = PaywayUtil.getRealTemplate(payment.getOpenType(), payment.getPayChannel()).executePayment(payment);
+        log.info("支付-付款返回参数:{}", JSONObject.toJSONString(paymentBaseResult));
+        return paymentBaseResult;
     }
 
     @Override
     public BaseResult<Payment> queryPayment(Payment payment) {
-        return PaywayUtil.getRealTemplate(payment.getOpenType(), payment.getPayChannel()).queryPayment(payment);
+        log.info("支付-查询请求参数:{}", JSONObject.toJSONString(payment));
+        BaseResult<Payment> paymentBaseResult = PaywayUtil.getRealTemplate(payment.getOpenType(), payment.getPayChannel()).queryPayment(payment);
+        log.info("支付-查询返回参数:{}", JSONObject.toJSONString(paymentBaseResult));
+        return paymentBaseResult;
     }
 
     @Override
     public BaseResult<ClosePayment> closePayment(ClosePayment closePayment) {
-        return PaywayUtil.getRealTemplate(closePayment.getOpenType(), closePayment.getPayChannel()).closePayment(closePayment);
+        log.info("支付-关单请求参数:{}", JSONObject.toJSONString(closePayment));
+        BaseResult<ClosePayment> closePaymentBaseResult = PaywayUtil.getRealTemplate(closePayment.getOpenType(), closePayment.getPayChannel()).closePayment(closePayment);
+        log.info("支付-关单返回参数:{}", JSONObject.toJSONString(closePaymentBaseResult));
+        return closePaymentBaseResult;
     }
 
     @Override
     public BaseResult<RefundBill> refundPayment(RefundBill refundBill) {
-        return PaywayUtil.getRealTemplate(refundBill.getOpenType(), refundBill.getPayChannel()).refundPayment(refundBill);
+        log.info("支付-退款请求参数:{}", JSONObject.toJSONString(refundBill));
+        BaseResult<RefundBill> refundBillBaseResult = PaywayUtil.getRealTemplate(refundBill.getOpenType(), refundBill.getPayChannel()).refundPayment(refundBill);
+        log.info("支付-退款返回参数:{}", JSONObject.toJSONString(refundBillBaseResult));
+        return refundBillBaseResult;
     }
 
     @Override
     public BaseResult<PaymentCallBack> analysisNotice(OpenEnum openType, PaymentClientEnum paymentClient, PayChannelEnum payChannel, MethodNameEnum methodName, HttpServletRequest request) {
-        return PaywayUtil.getRealTemplate(openType, payChannel).analysisNotice(openType, paymentClient, payChannel, methodName, request);
+        BaseResult<PaymentCallBack> paymentCallBackBaseResult = PaywayUtil.getRealTemplate(openType, payChannel).analysisNotice(openType, paymentClient, payChannel, methodName, request);
+        log.info("支付-回调解析结果:{}", JSONObject.toJSONString(paymentCallBackBaseResult));
+        return paymentCallBackBaseResult;
     }
 }

+ 11 - 8
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/ali/OriginalAliAppTemplate.java

@@ -91,7 +91,7 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
         request.setBizContent(bizContent.toString());
         try {
             AlipayTradeAppPayResponse response = getAlipayClient(payment.getPaymentClient()).sdkExecute(request);
-            log.info("支付返回:{}", JSONObject.toJSONString(response));
+            log.info("支付宝-支付返回:{}", JSONObject.toJSONString(response));
 
             if (response.isSuccess()) {
                 payment.setId(response.getTradeNo());
@@ -101,7 +101,7 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
                 return BaseResult.failed(response.getMsg());
             }
         } catch (AlipayApiException e) {
-            log.error("调用支付宝App支付接口失败,err_code={} err_msg={}", e.getErrCode(), e.getErrMsg());
+            e.printStackTrace();
             return BaseResult.failed("交易失败");
         } catch (Exception e) {
             e.printStackTrace();
@@ -114,13 +114,15 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
         AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
 
         JSONObject bizContent = new JSONObject();
-        bizContent.put("trade_no", payment.getId());
+        if (!StringUtil.isEmpty(payment.getId())) {
+            bizContent.put("trade_no", payment.getId());
+        }
         bizContent.put("out_trade_no", payment.getPaymentNo());
 
         request.setBizContent(bizContent.toString());
         try {
             AlipayTradeQueryResponse response = getAlipayClient(payment.getPaymentClient()).execute(request);
-            log.info("查询返回:{}", JSONObject.toJSONString(response));
+            log.info("支付宝-查询返回:{}", JSONObject.toJSONString(response));
 
             if (response.isSuccess()) {
                 payment.setPayAmt(response.getPayAmount());
@@ -140,7 +142,7 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
                 return BaseResult.failed(response.getMsg() + ":" + response.getSubMsg());
             }
         } catch (AlipayApiException e) {
-            log.error("调用支付宝APP查询订单接口失败,err_code={} err_msg={}", e.getErrCode(), e.getErrMsg());
+            e.printStackTrace();
             return BaseResult.failed("查询失败");
         } catch (Exception e) {
             e.printStackTrace();
@@ -171,7 +173,7 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
                 return BaseResult.failed(response.getMsg() + ":" + response.getSubMsg());
             }
         } catch (AlipayApiException e) {
-            log.error("调用支付宝APP支付关单接口失败,err_code={} err_msg={}", e.getErrCode(), e.getErrMsg());
+            e.printStackTrace();
             return BaseResult.failed("关单失败");
         } catch (Exception e) {
             e.printStackTrace();
@@ -203,7 +205,7 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
                 return BaseResult.failed(response.getMsg() + ":" + response.getSubMsg());
             }
         } catch (AlipayApiException e) {
-            log.error("调用支付宝APP支付退款接口失败,err_code={} err_msg={}", e.getErrCode(), e.getErrMsg());
+            e.printStackTrace();
             return BaseResult.failed("退款失败");
         } catch (Exception e) {
             e.printStackTrace();
@@ -263,7 +265,6 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
                 refundPayment.setTradeTime(jsonParams.getDate("gmt_refund"));
                 paymentCallBack.setRefundPaymentCallBack(refundPayment);
             } else {
-
                 if ("TRADE_CLOSED".equals(trade_status)) {
                     //关单成功
                     paymentCallBack.setMethodName(MethodNameEnum.closePayment);
@@ -291,9 +292,11 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
             }
             return BaseResult.succeed(paymentCallBack);
         } catch (AlipayApiException e) {
+            e.printStackTrace();
             paymentCallBack.setResMsg("filed");
             return BaseResult.failed(HttpStatus.INTERNAL_SERVER_ERROR, paymentCallBack, "微信回调对象转换失败");
         } catch (Exception e) {
+            e.printStackTrace();
             paymentCallBack.setResMsg("filed");
             return BaseResult.failed(HttpStatus.INTERNAL_SERVER_ERROR, paymentCallBack, "解析异常");
         }