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

Commit 82bf9d4f authored by 胡佳晨's avatar 胡佳晨

微信回调 提交

parent 65549cfe
...@@ -15,6 +15,9 @@ public class DragonConstant { ...@@ -15,6 +15,9 @@ public class DragonConstant {
public static final String REFUND_TYPE_JS_WEPAY="JSWEPAY";//,"微信内网页、微信公众号"), public static final String REFUND_TYPE_JS_WEPAY="JSWEPAY";//,"微信内网页、微信公众号"),
public static final String REFUND_TYPE_APPLET_WEPAY="APPLETWEPAY";//,"微信小程序"); public static final String REFUND_TYPE_APPLET_WEPAY="APPLETWEPAY";//,"微信小程序");
public static final String REFUND_REDIS_KET="dragon:refund:refundCode:";// 订单号对应回调地址
public enum PayChannelEnum{ public enum PayChannelEnum{
ALIPAY("alipay","支付宝"), ALIPAY("alipay","支付宝"),
WEPAY ("wepay","微信"), WEPAY ("wepay","微信"),
......
package com.liquidnet.service.dragon.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class NotifyUrlDto implements Serializable {
private Integer status;
// private String orderCode;
// private String code;
// private String type;
// private String price;
// private String paymentType;
// private String paymentAt;
// private String paymentId;
private String orderRefundCode;
private String refundCode;
private String refundPrice;
// private String refundReason;
// private String refundType;
private String refundId;
private String refundAt;
private String refundError;
}
...@@ -3,12 +3,12 @@ package com.liquidnet.service.dragon.service; ...@@ -3,12 +3,12 @@ package com.liquidnet.service.dragon.service;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.dto.DragonRefundAppDto; import com.liquidnet.service.dragon.dto.DragonRefundAppDto;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal; import java.math.BigDecimal;
public interface IDragonOrderRefundsService { public interface IDragonOrderRefundsService {
void sendRedisQueue();
/** /**
* *
* @param tradeNo => refundCode * @param tradeNo => refundCode
...@@ -20,7 +20,8 @@ public interface IDragonOrderRefundsService { ...@@ -20,7 +20,8 @@ public interface IDragonOrderRefundsService {
*/ */
ResponseDto<DragonRefundAppDto> dragonRefund(String orderCode, String tradeNo, String outTradeNo, String reason, String returnUrl, BigDecimal price, String paymentType,String paymentId,BigDecimal priceTotal); ResponseDto<DragonRefundAppDto> dragonRefund(String orderCode, String tradeNo, String outTradeNo, String reason, String returnUrl, BigDecimal price, String paymentType,String paymentId,BigDecimal priceTotal);
ResponseDto<DragonRefundAppDto> wePayRefundCallBack(); String wePayRefundCallBack(HttpServletRequest request , HttpServletResponse response);
} }
...@@ -23,12 +23,11 @@ liquidnet: ...@@ -23,12 +23,11 @@ liquidnet:
sslEnabled: false sslEnabled: false
database: dev_ln_scene database: dev_ln_scene
dragon: dragon:
url: https://devdragon.zhengzai.tv/dragon
alipay: alipay:
gataway-url: https://openapi.alipay.com/gateway.do gataway-url: https://openapi.alipay.com/gateway.do
notify-url: https://testdragon.zhengzai.tv/dragon/notify/alipay
wepay: wepay:
gataway-url: https://openapi.alipay.com/gateway.do gataway-url: https://openapi.alipay.com/gateway.do
notify-url: https://testdragon.zhengzai.tv/dragon/notify/wepay
merchantId: 1551961491 merchantId: 1551961491
appId: wx3498304dda39c5a1 appId: wx3498304dda39c5a1
parentKey: itIuO65O9yKmemOu3S8g1S4orqvCGwXK parentKey: itIuO65O9yKmemOu3S8g1S4orqvCGwXK
......
package com.liquidnet.service.dragon.channel.wepay.resp;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.Data;
@Data
@XStreamAlias("xml")
public class WePayRefundReturnCallBackDto {
@XStreamAlias("return_code")
private String returnCode;
@XStreamAlias("return_msg")
private String returnMsg;
@XStreamAlias("appid")
private String appId;
@XStreamAlias("mch_id")
private String mchId;
@XStreamAlias("nonce_str")
private String nonceStr;
@XStreamAlias("req_info")
private String reqInfo;
}
package com.liquidnet.service.dragon.channel.wepay.resp;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.Data;
@Data
@XStreamAlias("xml")
public class WePayRefundReturnCallBackInfoDto {
@XStreamAlias("out_refund_no")
private String outRefundNo;
@XStreamAlias("out_trade_no")
private String outTradeNo;
@XStreamAlias("refund_account")
private String refundAccount;
@XStreamAlias("refund_fee")
private String refundFee;
@XStreamAlias("refund_id")
private String refundId;
@XStreamAlias("refund_recv_accout")
private String refundRecvAccout;
@XStreamAlias("refund_request_source")
private String refundRequestSource;
@XStreamAlias("refund_status")
private String refundStatus;
@XStreamAlias("settlement_refund_fee")
private String settlementRefundFee;
@XStreamAlias("settlement_total_fee")
private String settlementTotalFee;
@XStreamAlias("success_time")
private String successTime;
@XStreamAlias("total_fee")
private String totalFee;
@XStreamAlias("transaction_id")
private String transactionId;
}
...@@ -8,6 +8,8 @@ import io.swagger.annotations.ApiResponse; ...@@ -8,6 +8,8 @@ import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -18,21 +20,6 @@ public class RefundController { ...@@ -18,21 +20,6 @@ public class RefundController {
@Autowired @Autowired
IDragonOrderRefundsService orderRefundsService; IDragonOrderRefundsService orderRefundsService;
@PostMapping("preTest")
@ApiOperation("微信退款")
@ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<String> checkCanOrder() {
orderRefundsService.sendRedisQueue();
return ResponseDto.success();
}
@PostMapping("refundAliPay")
@ApiOperation("支付宝退款")
@ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<String> refundAliPay() {
return ResponseDto.success();
}
@PostMapping("refundSingle") @PostMapping("refundSingle")
@ApiOperation("单条退款") @ApiOperation("单条退款")
@ApiResponse(code = 200, message = "接口返回对象参数") @ApiResponse(code = 200, message = "接口返回对象参数")
...@@ -47,4 +34,14 @@ public class RefundController { ...@@ -47,4 +34,14 @@ public class RefundController {
@RequestParam(value = "paymentId") @NotNull(message = "支付订单号不能为空") String paymentId) { @RequestParam(value = "paymentId") @NotNull(message = "支付订单号不能为空") String paymentId) {
return orderRefundsService.dragonRefund(orderCode, code, orderRefundCode, reason, returnUrl, price, paymentType, paymentId, priceTotal); return orderRefundsService.dragonRefund(orderCode, code, orderRefundCode, reason, returnUrl, price, paymentType, paymentId, priceTotal);
} }
@PostMapping("callBack/wepay")
@ApiOperation("单条退款")
@ApiResponse(code = 200, message = "接口返回对象参数")
public String refundSingle(
@RequestParam(value = "request") HttpServletRequest request,
@RequestParam(value = "response") HttpServletResponse response) {
return orderRefundsService.wePayRefundCallBack(request, response);
}
} }
...@@ -3,13 +3,18 @@ package com.liquidnet.service.dragon.service.impl; ...@@ -3,13 +3,18 @@ package com.liquidnet.service.dragon.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alipay.api.request.AlipayTradeRefundRequest; import com.alipay.api.request.AlipayTradeRefundRequest;
import com.alipay.api.response.AlipayTradeRefundResponse; import com.alipay.api.response.AlipayTradeRefundResponse;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.DateUtil; import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.HttpUtil;
import com.liquidnet.commons.lang.util.IDGenerator; import com.liquidnet.commons.lang.util.IDGenerator;
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.wepay.resp.WePayRefundReturnCallBackDto;
import com.liquidnet.service.dragon.channel.wepay.resp.WePayRefundReturnCallBackInfoDto;
import com.liquidnet.service.dragon.constant.DragonConstant; import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.dto.DragonRefundAppDto; import com.liquidnet.service.dragon.dto.DragonRefundAppDto;
import com.liquidnet.service.dragon.dto.DragonRefundChannelDto; import com.liquidnet.service.dragon.dto.DragonRefundChannelDto;
import com.liquidnet.service.dragon.dto.NotifyUrlDto;
import com.liquidnet.service.dragon.dto.RefundContentDto; import com.liquidnet.service.dragon.dto.RefundContentDto;
import com.liquidnet.service.dragon.channel.wepay.resp.WePayRefundReturnDto; import com.liquidnet.service.dragon.channel.wepay.resp.WePayRefundReturnDto;
import com.liquidnet.service.dragon.service.IDragonOrderRefundsService; import com.liquidnet.service.dragon.service.IDragonOrderRefundsService;
...@@ -23,11 +28,18 @@ import org.apache.http.client.methods.HttpPost; ...@@ -23,11 +28,18 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.connection.stream.MapRecord; import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.StreamRecords; import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
...@@ -38,45 +50,46 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -38,45 +50,46 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
@Autowired @Autowired
StringRedisTemplate stringRedisTemplate; StringRedisTemplate stringRedisTemplate;
@Autowired
@Override RedisUtil redisUtil;
public void sendRedisQueue() { @Value("${liquidnet.dragon.url}")
} private String url;
@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 {
LocalDateTime nowTime = LocalDateTime.now(); LocalDateTime nowTime = LocalDateTime.now();
String refundCode = IDGenerator.refundCode(); String refundCode = IDGenerator.refundCode();
String orderRefundId = IDGenerator.nextSnowId();
//创建退款单 //创建退款单
boolean insertResult = sendMySqlRedis( boolean insertResult = sendMySqlRedis(
SqlMapping.get("dragon_order_refund.insert"), SqlMapping.get("dragon_order_refund.insert"),
new Object[]{orderRefundId, refundCode, orderRefundCode, price, reason, notifyUrl, paymentType, nowTime, nowTime} new Object[]{orderRefundCode, refundCode, orderRefundCode, price, reason, notifyUrl, paymentType, nowTime, nowTime}
); );
redisUtil.set(DragonConstant.REFUND_REDIS_KET + orderRefundCode, notifyUrl);
DragonRefundChannelDto dto = null; DragonRefundChannelDto dto = null;
String localWePayCallBackUrl = url+"/refund/callBack/wepay";
if (insertResult) { if (insertResult) {
switch (paymentType) { switch (paymentType) {
case DragonConstant.REFUND_TYPE_APP_ALIPAY: case DragonConstant.REFUND_TYPE_APP_ALIPAY:
dto = aliPayRefund(orderRefundId, orderRefundCode, code, reason, price, paymentId, paymentType, nowTime); dto = aliPayRefund(orderRefundCode, orderRefundCode, code, reason, price, paymentId, paymentType, nowTime);
break; break;
case DragonConstant.REFUND_TYPE_WAP_ALIPAY: case DragonConstant.REFUND_TYPE_WAP_ALIPAY:
dto = aliPayRefund(orderRefundId, orderRefundCode, code, reason, price, paymentId, paymentType, nowTime); dto = aliPayRefund(orderRefundCode, orderRefundCode, code, reason, price, paymentId, paymentType, nowTime);
break; break;
case DragonConstant.REFUND_TYPE_WEB_ALIPAY: case DragonConstant.REFUND_TYPE_WEB_ALIPAY:
dto = aliPayRefund(orderRefundId, orderRefundCode, code, reason, price, paymentId, paymentType, nowTime); dto = aliPayRefund(orderRefundCode, orderRefundCode, code, reason, price, paymentId, paymentType, nowTime);
break; break;
case DragonConstant.REFUND_TYPE_APP_WEPAY: case DragonConstant.REFUND_TYPE_APP_WEPAY:
dto = weyPayRefund(orderRefundId, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, notifyUrl, nowTime); dto = weyPayRefund(orderRefundCode, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, localWePayCallBackUrl, nowTime);
break; break;
case DragonConstant.REFUND_TYPE_WAP_WEPAY: case DragonConstant.REFUND_TYPE_WAP_WEPAY:
dto = weyPayRefund(orderRefundId, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, notifyUrl, nowTime); dto = weyPayRefund(orderRefundCode, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, localWePayCallBackUrl, nowTime);
break; break;
case DragonConstant.REFUND_TYPE_WEB_WEPAY: case DragonConstant.REFUND_TYPE_WEB_WEPAY:
dto = weyPayRefund(orderRefundId, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, notifyUrl, nowTime); dto = weyPayRefund(orderRefundCode, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, localWePayCallBackUrl, nowTime);
break; break;
case DragonConstant.REFUND_TYPE_JS_WEPAY: case DragonConstant.REFUND_TYPE_JS_WEPAY:
dto = weyPayRefund(orderRefundId, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, notifyUrl, nowTime); dto = weyPayRefund(orderRefundCode, orderRefundCode, code, reason, price, priceTotal, paymentId, paymentType, localWePayCallBackUrl, nowTime);
break; break;
} }
...@@ -109,11 +122,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -109,11 +122,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
} }
} }
@Override //微信退款接口
public ResponseDto<DragonRefundAppDto> wePayRefundCallBack() {
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 {
String refundStatus = DragonConstant.RefundStatusEnum.STATUS_ERROR.getCode(); String refundStatus = DragonConstant.RefundStatusEnum.STATUS_ERROR.getCode();
...@@ -155,7 +164,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -155,7 +164,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
// 修改退款订单 // 修改退款订单
sendMySqlRedis( sendMySqlRedis(
SqlMapping.get("dragon_order_refund_error.update"), SqlMapping.get("dragon_order_refund_error.update"),
new Object[]{nowTime, refundError, refundStatus, orderRefundId} new Object[]{nowTime, refundError, refundStatus, refundCode}
); );
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -187,7 +196,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -187,7 +196,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
} }
sendMySqlRedis( sendMySqlRedis(
SqlMapping.get("dragon_order_refund_success.update"), SqlMapping.get("dragon_order_refund_success.update"),
new Object[]{nowTime, null, refundStatus, orderRefundId} new Object[]{nowTime, null, refundStatus, refundCode}
); );
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -219,6 +228,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -219,6 +228,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
} }
} }
//支付宝退款接口
public DragonRefundChannelDto aliPayRefund(String orderRefundId, String refundCode, String code, String reason, BigDecimal price, String paymentId, String paymentType, LocalDateTime nowTime) { public DragonRefundChannelDto aliPayRefund(String orderRefundId, String refundCode, String code, String reason, BigDecimal price, String paymentId, String paymentType, LocalDateTime nowTime) {
String refundStatus; String refundStatus;
DragonRefundChannelDto channelDto = new DragonRefundChannelDto(); DragonRefundChannelDto channelDto = new DragonRefundChannelDto();
...@@ -244,7 +254,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -244,7 +254,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
// 修改退款订单 // 修改退款订单
sendMySqlRedis( sendMySqlRedis(
SqlMapping.get("dragon_order_refund_error.update"), SqlMapping.get("dragon_order_refund_error.update"),
new Object[]{nowTime, refundError, refundStatus, orderRefundId} new Object[]{nowTime, refundError, refundStatus, refundCode}
); );
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -280,7 +290,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -280,7 +290,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
} }
sendMySqlRedis( sendMySqlRedis(
SqlMapping.get("dragon_order_refund_success.update"), SqlMapping.get("dragon_order_refund_success.update"),
new Object[]{nowTime, refundAt, refundStatus, orderRefundId} new Object[]{nowTime, refundAt, refundStatus, refundCode}
); );
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -306,6 +316,80 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -306,6 +316,80 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
} }
} }
@Override
public String wePayRefundCallBack(HttpServletRequest request, HttpServletResponse response) {
InputStream inStream;
ByteArrayOutputStream outSteam;
LocalDateTime nowTime = LocalDateTime.now();
try {
inStream = request.getInputStream();
outSteam = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = inStream.read(buffer)) != -1) {
outSteam.write(buffer, 0, len);
}
// 获取微信调用我们notify_url的返回信息
String jsonStr = new String(outSteam.toByteArray(), "utf-8");
outSteam.close();
inStream.close();
log.info("JSON = " + jsonStr);
WePayRefundReturnCallBackDto callBackDto = XmlUtil.toBean(jsonStr, WePayRefundReturnCallBackDto.class);
log.info("DATA = " + callBackDto);
if (callBackDto.getReturnCode().equalsIgnoreCase("SUCCESS")) {
String reqInfo = PayWepayUtils.getInstance().unCodeReqInfo(callBackDto.getReqInfo());
WePayRefundReturnCallBackInfoDto info = XmlUtil.toBean(reqInfo, WePayRefundReturnCallBackInfoDto.class);
String outRefundNo = info.getOutRefundNo();
String refundAt = info.getSuccessTime();
try {
sendMySqlRedis(
SqlMapping.get("dragon_order_refund_log.insert"),
new Object[]{outRefundNo, info.getRefundRequestSource(), JSON.toJSONString(info), nowTime, nowTime}
);
sendMySqlRedis(
SqlMapping.get("dragon_order_refund_success.update"),
new Object[]{nowTime, refundAt, DragonConstant.RefundStatusEnum.STATUS_REFUNDED.getCode(), outRefundNo}
);
NotifyUrlDto dto = new NotifyUrlDto();
if(info.getRefundStatus().equalsIgnoreCase("SUCCESS")){
dto.setStatus(1);
}else{
dto.setStatus(0);
}
// dto.setOrderCode();
// dto.setCode();
// dto.setType();
// dto.setPrice();
// dto.setPaymentType();
// dto.setPaymentId();
// dto.setPaymentAt();
dto.setOrderRefundCode(info.getOutRefundNo());
dto.setRefundCode(info.getOutTradeNo());
dto.setRefundPrice(info.getRefundFee());
// dto.setRefundReason();
dto.setRefundId(info.getRefundId());
// dto.setRefundType(info.getrefund);
dto.setRefundAt(refundAt);
dto.setRefundError(callBackDto.getReturnMsg());
sendNotifyUrl(dto);
return "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
} catch (Exception e) {
e.printStackTrace();
log.error("");
return "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[ERROR]]></return_msg></xml>";
}
} else {
return "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[ERROR]]></return_msg></xml>";
}
} catch (Exception e) {
e.printStackTrace();
log.error("");
return "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[ERROR]]></return_msg></xml>";
}
}
/** /**
* 给 REDIS 队列发送消息 数据库相关 * 给 REDIS 队列发送消息 数据库相关
* *
...@@ -331,4 +415,29 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -331,4 +415,29 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
return false; return false;
} }
} }
private void sendNotifyUrl(NotifyUrlDto notifyUrlDto){
LocalDateTime nowTime = LocalDateTime.now();
MultiValueMap<String, String> params = new LinkedMultiValueMap();
params.add("orderRefundCode",notifyUrlDto.getOrderRefundCode());
params.add("refundAt",notifyUrlDto.getRefundAt());
params.add("refundCode",notifyUrlDto.getRefundCode());
params.add("refundError",notifyUrlDto.getRefundError());
params.add("refundId",notifyUrlDto.getRefundId());
params.add("refundPrice",notifyUrlDto.getRefundPrice());
params.add("status",notifyUrlDto.getStatus().toString());
String response = HttpUtil.post((String) redisUtil.get(DragonConstant.REFUND_REDIS_KET+notifyUrlDto.getOrderRefundCode()), params);
if(response.equals("success")){
sendMySqlRedis(
SqlMapping.get("dragon_order_refund_call_back.update"),
new Object[]{nowTime, DateUtil.Formatter.yyyyMMddHHmmss.format(nowTime), DragonConstant.RefundStatusEnum.STATUS_SUCCESS.getCode(), notifyUrlDto.getRefundCode()}
);
}else{
sendMySqlRedis(
SqlMapping.get("dragon_order_refund_call_back.update"),
new Object[]{nowTime, DateUtil.Formatter.yyyyMMddHHmmss.format(nowTime), DragonConstant.RefundStatusEnum.STATUS_FAIL.getCode(), notifyUrlDto.getRefundCode()}
);
}
}
} }
...@@ -7,12 +7,16 @@ import org.apache.http.conn.ssl.SSLConnectionSocketFactory; ...@@ -7,12 +7,16 @@ import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts; import org.apache.http.ssl.SSLContexts;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.security.KeyStore; import java.security.KeyStore;
import java.security.Security;
import java.util.*; import java.util.*;
public class PayWepayUtils { public class PayWepayUtils {
...@@ -118,4 +122,29 @@ public class PayWepayUtils { ...@@ -118,4 +122,29 @@ public class PayWepayUtils {
sb.append("</xml>"); sb.append("</xml>");
return sb.toString(); return sb.toString();
} }
public String unCodeReqInfo(String reqInfo) {
try {
Cipher cipher ;
String key = MD5Utils.md5(parentKey);
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "AES");
Security.addProvider(new BouncyCastleProvider());
cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
Base64.Decoder decoder = Base64.getDecoder();
byte[] base64ByteArr = decoder.decode(reqInfo);
String result = new String(cipher.doFinal(base64ByteArr));
return result;
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
// public static void main(String[] args) {
// PayWepayUtils a = new PayWepayUtils();
// System.out.println(a.unCodeReqInfo());
// }
} }
# ------------------------创建退款订单---------------------------- # ------------------------创建退款订单----------------------------
dragon_order_refund.insert=INSERT INTO `dragon_order_refunds`(`order_refund_id`,`code` ,`order_refund_code` ,`price` ,`reason` ,`notify_url` ,`refund_type`,`created_at`,`updated_at`)VALUES(?,?,?,?,?,?,?,?,?); dragon_order_refund.insert=INSERT INTO `dragon_order_refunds`(`order_refund_id`,`code` ,`order_refund_code` ,`price` ,`reason` ,`notify_url` ,`refund_type`,`created_at`,`updated_at`)VALUES(?,?,?,?,?,?,?,?,?);
# ------------------------修改退款订单---------------------------- # ------------------------修改退款订单----------------------------
dragon_order_refund_error.update=UPDATE `dragon_order_refunds` SET updated_at = ? , refund_error=? , status=? WHERE order_refund_id = ? dragon_order_refund_error.update=UPDATE `dragon_order_refunds` SET updated_at = ? , refund_error=? , status=? WHERE order_refund_code = ?
dragon_order_refund_success.update=UPDATE `dragon_order_refunds` SET updated_at = ? , refund_at=? , status=? WHERE order_refund_id = ? dragon_order_refund_success.update=UPDATE `dragon_order_refunds` SET updated_at = ? , refund_at=? , status=? WHERE order_refund_code = ?
dragon_order_refund_call_back.update=UPDATE `dragon_order_refunds` SET updated_at = ? , finished_at=? , status=? WHERE order_refund_code = ?
# ------------------------创建退款订单日志---------------------------- # ------------------------创建退款订单日志----------------------------
dragon_order_refund_log.insert=INSERT INTO `dragon_order_refunds`(`order_refund_id` ,`refund_type` ,`content`,`created_at`,`updated_at`)VALUES(?,?,?,?,?); dragon_order_refund_log.insert=INSERT INTO `dragon_order_refunds`(`order_refund_id` ,`refund_type` ,`content`,`created_at`,`updated_at`)VALUES(?,?,?,?,?);
dragon_orders.insert=INSERT INTO DRAGON_ORDERS (ID, STATUS, CODE, TYPE, PRICE, NAME, DETAIL, ORDER_CODE, CLIENT_IP, NOTIFY_URL, PAYMENT_TYPE,PAYMENT_ID, PAYMENT_AT, FINISHED_AT, CREATED_AT, UPDATED_AT, DELETED_AT)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) dragon_orders.insert=INSERT INTO DRAGON_ORDERS (ID, STATUS, CODE, TYPE, PRICE, NAME, DETAIL, ORDER_CODE, CLIENT_IP, NOTIFY_URL, PAYMENT_TYPE,PAYMENT_ID, PAYMENT_AT, FINISHED_AT, CREATED_AT, UPDATED_AT, DELETED_AT)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
dragon_order_logs.insert=INSERT INTO DRAGON_ORDER_LOGS (ID, ORDER_ID, PAYMENT_TYPE, CONTENT, CREATED_AT, UPDATED_AT, DELETED_AT) VALUES(?,?,?,?,?,?,?) dragon_order_logs.insert=INSERT INTO DRAGON_ORDER_LOGS (ID, ORDER_ID, PAYMENT_TYPE, CONTENT, CREATED_AT, UPDATED_AT, DELETED_AT) VALUES(?,?,?,?,?,?,?)
......
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