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

Commit 6c736be2 authored by 胡佳晨's avatar 胡佳晨

增加 微信小程序退款

parent f5c38cca
......@@ -199,7 +199,7 @@
<if test="status=='0'">
AND ps.STATUS = #{status}
</if>
<if test="merchantId!='1'">
<if test="merchantId != 1">
AND pr.merchant_id = #{merchantId}
</if>
</where>
......
......@@ -94,32 +94,35 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
case DragonConstant.REFUND_TYPE_JS_WEPAY:
dto = weyPayRefund(code, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, localWePayCallBackUrl, nowTime);
break;
case DragonConstant.REFUND_TYPE_APPLET_WEPAY:
dto = weyPayRefund(code, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, localWePayCallBackUrl, nowTime);
break;
}
log.info("dto = "+ JSON.toJSONString(dto));
if (dto.getResult().equalsIgnoreCase("refunding")) {
log.info("");
} else if (dto.getResult().equalsIgnoreCase("refunded")) {
//调用回调
log.info("");
} else if (dto.getResult().equalsIgnoreCase("error")) {
//调用回调
log.error("");
return ResponseDto.failure("退款失败:" + dto.getMessage());
} else if (dto.getResult().equalsIgnoreCase("exception")) {
log.error("");
}
DragonRefundAppDto refundAppDto = new DragonRefundAppDto();
refundAppDto.setOrderCode(orderCode);
refundAppDto.setCode(code);
refundAppDto.setOrderRefundCode(orderRefundCode);
refundAppDto.setRefundCode(refundCode);
log.info("refundAppDto = "+ JSON.toJSONString(refundAppDto));
return ResponseDto.success(refundAppDto);
} else {
return ResponseDto.failure("退款失败");
}
} catch (Exception e) {
e.printStackTrace();
log.error("");
log.info("orderCode = "+ orderCode+"",e);
return ResponseDto.failure("退款失败:" + e.getMessage());
}
}
......@@ -155,7 +158,6 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
String sign = PayWepayUtils.getInstance().createSign(parameters);
parameters.put("sign", sign);
String data = PayWepayUtils.getInstance().getRequestXml(parameters);
log.debug("XMLSTRING = " + data);
try {
HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund");
httpost.setEntity(new StringEntity(data, "UTF-8"));
......@@ -164,7 +166,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
HttpEntity entity = response.getEntity();
entity.getContent();
String jsonStr = EntityUtils.toString(entity, "UTF-8");
log.debug("JSONSTR = " + jsonStr);
log.info("JSONSTR = " + jsonStr);
WePayRefundReturnDto wePayRefundReturnDto = XmlUtil.toBean(jsonStr, WePayRefundReturnDto.class);
if (wePayRefundReturnDto.getErrCodeDes() != null) {
channelDto.setResult("error");
......@@ -174,7 +176,6 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
channelDto.setContent(contentDto);
return channelDto;
}
log.debug("BEAN = " + wePayRefundReturnDto);
if (!wePayRefundReturnDto.getReturnCode().equalsIgnoreCase("SUCCESS") || wePayRefundReturnDto.getReturnCode() == null) {
try {
String refundError = "";
......@@ -323,7 +324,6 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
);
} catch (Exception e) {
e.printStackTrace();
log.error("");
channelDto.setResult("exception");
channelDto.setMessage("update order refund with db error: " + e.getMessage());
contentDto.setRequest(JSON.toJSONString(response.getParams()));
......@@ -361,17 +361,14 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
String jsonStr = new String(outSteam.toByteArray(), "utf-8");
outSteam.close();
inStream.close();
log.debug("JSON = " + jsonStr);
WePayRefundReturnCallBackDto callBackDto = XmlUtil.toBean(jsonStr, WePayRefundReturnCallBackDto.class);
log.debug("DATA = " + callBackDto);
log.info("callBackDto = " + callBackDto);
if (callBackDto.getReturnCode().equalsIgnoreCase("SUCCESS")) {
String reqInfo = PayWepayUtils.getInstance().unCodeReqInfo(callBackDto.getReqInfo());
log.debug("REQINFO = " + reqInfo);
WePayRefundReturnCallBackInfoDto info = XmlUtil.toBean(reqInfo, WePayRefundReturnCallBackInfoDto.class);
String outRefundNo = info.getOutRefundNo();
String refundAt = info.getSuccessTime();
try {
NotifyUrlDto dto = new NotifyUrlDto();
if (info.getRefundStatus().equalsIgnoreCase("SUCCESS")) {
dto.setStatus(1);
......@@ -383,7 +380,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
dto.setRefundPrice(new BigDecimal(info.getRefundFee()).divide(BigDecimal.valueOf(100)).toString());
dto.setRefundAt(refundAt);
dto.setRefundError(callBackDto.getReturnMsg());
log.debug("SEND WEPAY NOTIFTURL = " + JSON.toJSONString(dto));
log.info("SEND WEPAY NOTIFTURL = " + JSON.toJSONString(dto));
sendNotifyUrl(dto,null);
mqHandleUtil.sendMySqlRedis(
......@@ -481,7 +478,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
"\"trade_no\":\"" + callBackDto.getTradeNo() + "\"," +
"\"out_request_no\":\"" + callBackDto.getOutBizNo() + "\"}"); //设置业务参数
AlipayTradeFastpayRefundQueryResponse response = PayAlipayUtils.getInstance().getHttpClient().execute(request);
log.debug("AlipayTradeFastpayRefundQueryRequest -> data = " + JSON.toJSONString(response));
log.info("AlipayTradeFastpayRefundQueryRequest -> data = " + JSON.toJSONString(response));
if (response.isSuccess()) {
try {
......@@ -497,7 +494,6 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
dto.setRefundAt(callBackDto.getGmtRefund());
dto.setRefundPrice(response.getRefundAmount());
dto.setRefundError("");
log.debug("SEND ALIPAY NOTIFTURL = " + JSON.toJSONString(dto));
sendNotifyUrl(dto,null);
mqHandleUtil.sendMySqlRedis(
......
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