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

Commit 67294442 authored by zhengfuxin's avatar zhengfuxin

银联退款回调

parent aca6d629
...@@ -11,9 +11,11 @@ import com.liquidnet.commons.lang.util.IDGenerator; ...@@ -11,9 +11,11 @@ import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.JsonUtils; import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping; import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.dragon.channel.unionpay.biz.UnionpayBiz;
import com.liquidnet.service.dragon.channel.unionpay.constant.UnionpayConstant; import com.liquidnet.service.dragon.channel.unionpay.constant.UnionpayConstant;
import com.liquidnet.service.dragon.channel.unionpay.sdk.AcpService; import com.liquidnet.service.dragon.channel.unionpay.sdk.AcpService;
import com.liquidnet.service.dragon.channel.unionpay.sdk.SDKConfig; import com.liquidnet.service.dragon.channel.unionpay.sdk.SDKConfig;
import com.liquidnet.service.dragon.channel.unionpay.sdk.SDKConstants;
import com.liquidnet.service.dragon.channel.wepay.resp.AliPayRefundReturnCallBackDto; import com.liquidnet.service.dragon.channel.wepay.resp.AliPayRefundReturnCallBackDto;
import com.liquidnet.service.dragon.channel.wepay.resp.WePayRefundReturnCallBackDto; import com.liquidnet.service.dragon.channel.wepay.resp.WePayRefundReturnCallBackDto;
import com.liquidnet.service.dragon.channel.wepay.resp.WePayRefundReturnCallBackInfoDto; import com.liquidnet.service.dragon.channel.wepay.resp.WePayRefundReturnCallBackInfoDto;
...@@ -67,7 +69,8 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -67,7 +69,8 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
//银联 商户号码 //银联 商户号码
@Value("${liquidnet.dragon.unionpay.merchantId}") @Value("${liquidnet.dragon.unionpay.merchantId}")
private String unionMerchantId; private String unionMerchantId;
@Autowired
private UnionpayBiz unionpayBiz;
@Override @Override
public ResponseDto<DragonRefundAppDto> dragonRefund(String orderCode, String code, String orderRefundCode, String reason, String notifyUrl, BigDecimal price, String paymentType, String paymentId, BigDecimal priceTotal) { public ResponseDto<DragonRefundAppDto> dragonRefund(String orderCode, String code, String orderRefundCode, String reason, String notifyUrl, BigDecimal price, String paymentType, String paymentId, BigDecimal priceTotal) {
try { try {
...@@ -152,7 +155,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -152,7 +155,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
data.put("signMethod", sdkConfig.getSignMethod()); //签名方法 data.put("signMethod", sdkConfig.getSignMethod()); //签名方法
data.put("txnType", "04"); //交易类型 04-退货 data.put("txnType", "04"); //交易类型 04-退货
data.put("txnSubType", "00"); //交易子类型 默认00 data.put("txnSubType", "00"); //交易子类型 默认00
data.put("bizType", "000201"); //业务类型 data.put("bizType", "0201"); //业务类型
data.put("channelType", "08"); //渠道类型,07-PC,08-手机 data.put("channelType", "08"); //渠道类型,07-PC,08-手机
/***商户接入参数***/ /***商户接入参数***/
data.put("merId", unionMerchantId); //商户号码,请改成自己申请的商户号或者open上注册得来的777商户号测试 data.put("merId", unionMerchantId); //商户号码,请改成自己申请的商户号或者open上注册得来的777商户号测试
...@@ -476,7 +479,56 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -476,7 +479,56 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
return null; return null;
} }
} }
/**
* @author zhangfuxin
* @Description: 银联退款回调
* @date 2021/11/18 下午1:32
*/
public String unionRefundCallBack(HttpServletRequest request, HttpServletResponse response) {
try {
LocalDateTime nowTime = LocalDateTime.now();
String encoding = request.getParameter(SDKConstants.param_encoding);
Map<String , String> notifyMap = unionpayBiz.parseNotifyMsg(request);
log.info("银联退款回调{}",JSON.toJSONString(notifyMap));
if (!acpService.validate(notifyMap, encoding)) {
//验签失败,需解决验签问题
log.error("银联回调,验签失败。");
} else {
String orderId =notifyMap.get("orderId"); //获取后台通知的数据,其他字段也可用类似方式获取
String respCode = notifyMap.get("respCode");
NotifyUrlDto dto = new NotifyUrlDto();
//成功
if(respCode.equals("00")||respCode.equals("A6")){
dto.setStatus(1);
}else{
dto.setStatus(0);
}
//商户订单号 商户退款单号
dto.setOrderRefundCode(orderId);
//银联无这个
dto.setRefundCode("");
dto.setRefundPrice(new BigDecimal(notifyMap.get("settleAmt")).divide(BigDecimal.valueOf(100)).toString());
dto.setRefundAt(notifyMap.get("traceTime"));
// 应答信息
dto.setRefundError(notifyMap.get("respMsg"));
log.info("SEND WEPAY NOTIFTURL = " + JSON.toJSONString(dto));
sendNotifyUrl(dto, null);
mqHandleUtil.sendMySqlRedis(
SqlMapping.get("dragon_order_refund_log.insert"),
new Object[]{orderId, "", JSON.toJSONString(notifyMap), nowTime, nowTime},
DragonConstant.MysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode()
);
mqHandleUtil.sendMySqlRedis(
SqlMapping.get("dragon_order_refund_success.update"),
new Object[]{nowTime, notifyMap.get("traceTime"), DragonConstant.RefundStatusEnum.STATUS_REFUNDED.getCode(), orderId},
DragonConstant.MysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode()
);
}
}catch (Exception e){
e.printStackTrace();
}
return "ok";
}
@Override @Override
public String wePayRefundCallBack(HttpServletRequest request, HttpServletResponse response) { public String wePayRefundCallBack(HttpServletRequest request, HttpServletResponse response) {
InputStream inStream; InputStream inStream;
......
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