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

Commit 6f327900 authored by zhengfuxin's avatar zhengfuxin

修改bug

parent e494e1b2
...@@ -75,6 +75,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -75,6 +75,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
dataUtils.setRefundNotifyUrl(orderRefundCode, notifyUrl); dataUtils.setRefundNotifyUrl(orderRefundCode, notifyUrl);
DragonRefundChannelDto dto = null; DragonRefundChannelDto dto = null;
String localWePayCallBackUrl = url + "/refund/callBack/wepay"; String localWePayCallBackUrl = url + "/refund/callBack/wepay";
String localDouYinCallBackUrl = url + "/refund/callBack/douyinpay";
if (insertResult) { if (insertResult) {
switch (paymentType) { switch (paymentType) {
case DragonConstant.REFUND_TYPE_APP_ALIPAY: case DragonConstant.REFUND_TYPE_APP_ALIPAY:
...@@ -101,6 +102,9 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -101,6 +102,9 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
case DragonConstant.REFUND_TYPE_APPLET_WEPAY: case DragonConstant.REFUND_TYPE_APPLET_WEPAY:
dto = weyPayRefund(code, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, localWePayCallBackUrl, nowTime); dto = weyPayRefund(code, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, localWePayCallBackUrl, nowTime);
break; break;
case DragonConstant.REFUND_TYPE_APPLET_DOUYIN:
dto = douYinRefund(code, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, localDouYinCallBackUrl, nowTime);
break;
} }
log.info("dto = " + JSON.toJSONString(dto)); log.info("dto = " + JSON.toJSONString(dto));
...@@ -132,7 +136,111 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -132,7 +136,111 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
return ResponseDto.failure("退款失败:" + e.getMessage()); return ResponseDto.failure("退款失败:" + e.getMessage());
} }
} }
/**
* @author zhangfuxin
* @Description: 抖音退款接口
* @date 2021/11/10 下午3:22
*/
public DragonRefundChannelDto douYinRefund(String orderRefundId, String refundCode, String code, String reason, BigDecimal price, BigDecimal priceTotal, String paymentId, String paymentType, String notifyUrl, LocalDateTime nowTime) {
try {
String refundStatus = DragonConstant.RefundStatusEnum.STATUS_ERROR.getCode();
DragonRefundChannelDto channelDto = new DragonRefundChannelDto();
RefundContentDto contentDto = new RefundContentDto();
SortedMap<String, Object> parameters = new TreeMap<>();
parameters.put("app_id",PayDouYinpayUtils.getInstance().getAPP_ID());
parameters.put("out_order_no",code);
parameters.put("out_refund_no",refundCode);
parameters.put("refund_amount",(int) (price.doubleValue() * 100));
parameters.put("reason",reason);
parameters.put("notify_url",notifyUrl);
String sign = PayDouYinpayUtils.getInstance().createSign(parameters);
parameters.put("sign",sign);
String data = JSON.toJSONString(parameters);
String refundError = "";
try {
log.info("调用抖音退款:{}",data);
HttpPost httpost = new HttpPost("https://developer.toutiao.com/api/apps/ecpay/v1/create_refund");
httpost.setEntity(new StringEntity(data, "UTF-8"));
CloseableHttpResponse response = PayDouYinpayUtils.getInstance().getHttpClient().execute(httpost);
try {
HttpEntity entity = response.getEntity();
entity.getContent();
String jsonStr = EntityUtils.toString(entity, "UTF-8");
log.info("douYinRefund 返参{}", jsonStr);
Map result=JSON.parseObject(jsonStr, HashMap.class);
//
if(!result.get("err_no").toString().equals("0")){
try {
refundStatus = DragonConstant.RefundStatusEnum.STATUS_ERROR.getCode();
refundError = result.get("err_tips").toString();
// 修改退款订单
mqHandleUtil.sendMySqlRedis(
SqlMapping.get("dragon_order_refund_error.update"),
new Object[]{nowTime, refundError, refundStatus, code},
DragonConstant.MysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode()
);
} catch (Exception e) {
e.printStackTrace();
//保存错误信息
log.error("");
channelDto.setResult("exception");
channelDto.setMessage("update order refund with db error: " + e.getMessage());
contentDto.setRequest(data);
contentDto.setResponse(jsonStr);
channelDto.setContent(contentDto);
return channelDto;
}
channelDto.setResult("error");
channelDto.setMessage(refundError);
contentDto.setRequest(data);
contentDto.setResponse(jsonStr);
channelDto.setContent(contentDto);
return channelDto;
}
// 创建退款日志
mqHandleUtil.sendMySqlRedis(
SqlMapping.get("dragon_order_refund_log.insert"),
new Object[]{orderRefundId, paymentType, data, nowTime, nowTime},
DragonConstant.MysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode()
);
try {
if (result.get("err_no").toString().equals("0")) {
refundStatus = DragonConstant.RefundStatusEnum.STATUS_REFUNDED.getCode();
}
mqHandleUtil.sendMySqlRedis(
SqlMapping.get("dragon_order_refund_success.update"),
new Object[]{nowTime, null, refundStatus, code},
DragonConstant.MysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode()
);
} catch (Exception e) {
e.printStackTrace();
log.error("");
channelDto.setResult("exception");
channelDto.setMessage("update order refund with db error: " + e.getMessage());
contentDto.setRequest(data);
contentDto.setResponse(jsonStr);
channelDto.setContent(contentDto);
return channelDto;
}
channelDto.setResult("refunded");
channelDto.setMessage(paymentType + " refund info: ");
contentDto.setRequest(data);
contentDto.setResponse(jsonStr);
channelDto.setContent(contentDto);
EntityUtils.consume(entity);
return channelDto;
} finally {
response.close();
}
} finally {
// PayWepayUtils.getInstance().getHttpClient().close();
}
}catch (Exception e) {
e.printStackTrace();
log.error("");
return null;
}
}
//微信退款接口 //微信退款接口
public DragonRefundChannelDto weyPayRefund(String orderRefundId, String refundCode, String code, String reason, BigDecimal price, BigDecimal priceTotal, String paymentId, String paymentType, String notifyUrl, LocalDateTime nowTime) { public DragonRefundChannelDto weyPayRefund(String orderRefundId, String refundCode, String code, String reason, BigDecimal price, BigDecimal priceTotal, String paymentId, String paymentType, String notifyUrl, LocalDateTime nowTime) {
try { try {
......
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