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

Commit 6f464d87 authored by jiangxiulong's avatar jiangxiulong

Merge remote-tracking branch 'origin/dev' into dev

parents a8339e23 ed91cd53
...@@ -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;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: DragonPayNotifyReqDto
* @Package com.liquidnet.service.dragon.dto
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/13 12:26
*/
@Data
public class DragonPayNotifyReqDto {
//notify_id
private String notify_type;
//notify_id
private String notify_id;
private String notify_time;
private String sign_type;
private String sign;
private String charge_amount;
private String charge_flags;
private String settlement_id;
private String notify_action_type;
private String current_seller_received_amount;
private String seller_received_total_amount;
private String total_from_seller_fee;
private String ff_current_period;
private String mdiscount_amount;
private String discount_amount;
private String hb_fq_pay_info;
private String receipt_currency_type;
}
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);
} }
...@@ -3,12 +3,13 @@ package com.liquidnet.service.dragon.service; ...@@ -3,12 +3,13 @@ package com.liquidnet.service.dragon.service;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto; import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto; import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import com.liquidnet.service.dragon.dto.DragonRefundAppDto;
import java.math.BigDecimal; import javax.servlet.http.HttpServletRequest;
public interface IDragonOrdersService { public interface IDragonOrdersService {
void sendRedisQueue(); void sendRedisQueue();
ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto); ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto);
void dragonNotify(HttpServletRequest request,String payType,String deviceFrom);
} }
...@@ -10,8 +10,8 @@ public class MQConst { ...@@ -10,8 +10,8 @@ public class MQConst {
public static final String EX_LNS_SMS_SENDER = "lns.sms.sender"; public static final String EX_LNS_SMS_SENDER = "lns.sms.sender";
// 验证码 // 验证码
public static final String RK_SMS_CODE = "sms.code"; // public static final String RK_SMS_CODE = "sms.code";
public static final String QUEUES_SMS_CODE = "queue.sms.code"; // public static final String QUEUES_SMS_CODE = "queue.sms.code";
// 通知 // 通知
public static final String RK_SMS_NOTICE = "sms.notice"; public static final String RK_SMS_NOTICE = "sms.notice";
public static final String QUEUES_SMS_NOTICE = "queue.sms.notice"; public static final String QUEUES_SMS_NOTICE = "queue.sms.notice";
......
...@@ -6,7 +6,21 @@ public class SmsEnum { ...@@ -6,7 +6,21 @@ public class SmsEnum {
* 短信签名 * 短信签名
*/ */
public enum ADSignName { public enum ADSignName {
摩登天空,正在现场,新血计划,摩登小家伙,五百里Live; M01("摩登天空"),
M02("正在现场"),
M03("新血计划"),
M04("摩登小家伙"),
M05("五百里Live")
;
private final String val;
ADSignName(String val) {
this.val = val;
}
public String getVal() {
return val;
}
} }
/** /**
...@@ -21,10 +35,20 @@ public class SmsEnum { ...@@ -21,10 +35,20 @@ public class SmsEnum {
*/ */
SMS_109535335, SMS_109535335,
/** /**
* 短信通知:票务 - 用户购票成功后短信通知 * 短信通知:快递票购票成功通知
* - 尊敬的${userName},您已成功购买${aName},演出时间${time},地点${siteName},此短信不作为入场凭证。您可以登录“正在现场”app查询您的订单及入场方式。也可点此http://ticket.zhengzai.tv${url} * - 您已成功购买${name}门票。可至个人中心查看订单,个人中心地址:http://t.cn/ExMlr1B。演出${time}开始。请注意查收快递并保管门票,现场持票入场。咨询电话:4001680650。
*/
SMS_181490473,
/**
* 购票成功通知短信
* - 您已成功购买${name}门票。可至个人中心查看订单(http://t.cn/ExMlr1B)。演出${time}开始。咨询电话:4001680650。
*/
SMS_171358560,
/**
* 身份证电子票购票成功通知
* - 您已成功购买${name}门票。可至个人中心查看订单,个人中心地址:http://t.cn/ExMlr1B。演出${time}开始。请持购票人身份证到现场取票。咨询电话:4001680650。
*/ */
SMS_107075073, SMS_181500419,
; ;
} }
} }
...@@ -30,6 +30,8 @@ public class SmsProcessor { ...@@ -30,6 +30,8 @@ public class SmsProcessor {
aliyunDysmsAcsClient = new Client(config); aliyunDysmsAcsClient = new Client(config);
} }
/* ================================================================== | aliyun dysms */
/** /**
* AliyunDysms.send * AliyunDysms.send
* - link: https://help.aliyun.com/document_detail/101414.htm?spm=a2c4g.11186623.2.8.302f56958lnARh#t83759.html * - link: https://help.aliyun.com/document_detail/101414.htm?spm=a2c4g.11186623.2.8.302f56958lnARh#t83759.html
...@@ -38,30 +40,15 @@ public class SmsProcessor { ...@@ -38,30 +40,15 @@ public class SmsProcessor {
* @param signName 短信签名名称 * @param signName 短信签名名称
* @param templateCode 短信模板ID * @param templateCode 短信模板ID
* @param templateParam 短信模板变量对应的实际值,JSON格式(建议使用com.liquidnet.commons.lang.util.JsonUtils.OM().createObjectNode()) * @param templateParam 短信模板变量对应的实际值,JSON格式(建议使用com.liquidnet.commons.lang.util.JsonUtils.OM().createObjectNode())
* @return boolean * @return SendSmsResponse
*/ */
public boolean aliyunDysmsSend(String phoneNumber, String signName, String templateCode, String templateParam) { private SendSmsResponse aliyunDysmsSend(String phoneNumber, String signName, String templateCode, String templateParam) throws Exception {
SendSmsRequest smsRequest = new SendSmsRequest() SendSmsRequest smsRequest = new SendSmsRequest()
.setPhoneNumbers(phoneNumber) .setPhoneNumbers(phoneNumber)
.setSignName(signName) .setSignName(signName)
.setTemplateCode(templateCode) .setTemplateCode(templateCode)
.setTemplateParam(templateParam); .setTemplateParam(templateParam);
try { return aliyunDysmsAcsClient.sendSms(smsRequest);
SendSmsResponse smsResponse = aliyunDysmsAcsClient.sendSms(smsRequest);
SendSmsResponseBody smsResponseBody = smsResponse.getBody();
boolean isSucc = null != smsResponseBody && "OK".equalsIgnoreCase(smsResponseBody.getCode());
if (!isSucc) {
log.warn("###短信服务发送失败[{}]", JsonUtils.toJson(smsResponse));
}
return isSucc;
} catch (Exception e) {
log.error("API处理异常", e);
}
return false;
} }
/** /**
...@@ -73,30 +60,37 @@ public class SmsProcessor { ...@@ -73,30 +60,37 @@ public class SmsProcessor {
* @param signNameJson 短信签名名称,JSON数组格式(建议使用com.liquidnet.commons.lang.util.JsonUtils.OM().createArrayNode()) * @param signNameJson 短信签名名称,JSON数组格式(建议使用com.liquidnet.commons.lang.util.JsonUtils.OM().createArrayNode())
* @param templateCode 短信模板CODE * @param templateCode 短信模板CODE
* @param templateParamJson 短信模板变量对应的实际值,JSON格式(建议使用com.liquidnet.commons.lang.util.JsonUtils.OM().createObjectNode()) * @param templateParamJson 短信模板变量对应的实际值,JSON格式(建议使用com.liquidnet.commons.lang.util.JsonUtils.OM().createObjectNode())
* @return boolean * @return SendBatchSmsResponse
*/ */
public boolean aliyunDysmsSendBatch(String phoneNumberJson, String signNameJson, String templateCode, String templateParamJson) { private SendBatchSmsResponse aliyunDysmsSendBatch(String phoneNumberJson, String signNameJson, String templateCode, String templateParamJson) throws Exception {
SendBatchSmsRequest batchSmsRequest = new SendBatchSmsRequest() SendBatchSmsRequest batchSmsRequest = new SendBatchSmsRequest()
.setPhoneNumberJson(phoneNumberJson) .setPhoneNumberJson(phoneNumberJson)
.setSignNameJson(signNameJson) .setSignNameJson(signNameJson)
.setTemplateCode(templateCode) .setTemplateCode(templateCode)
.setTemplateParamJson(templateParamJson); .setTemplateParamJson(templateParamJson);
return aliyunDysmsAcsClient.sendBatchSms(batchSmsRequest);
}
/* ================================================================== | sender */
public boolean send(String phoneNumber, String signName, String templateCode, String templateParam) {
try { try {
SendBatchSmsResponse batchSmsResponse = aliyunDysmsAcsClient.sendBatchSms(batchSmsRequest); SendSmsResponse smsResponse = this.aliyunDysmsSend(phoneNumber, signName, templateCode, templateParam);
log.info(JsonUtils.toJson(batchSmsResponse));
SendBatchSmsResponseBody batchSmsResponseBody = batchSmsResponse.getBody(); SendSmsResponseBody smsResponseBody = smsResponse.getBody();
boolean isSucc = null != batchSmsResponseBody && "OK".equalsIgnoreCase(batchSmsResponseBody.getCode()); boolean isSucc = null != smsResponseBody && "OK".equalsIgnoreCase(smsResponseBody.getCode());
if (!isSucc) { if (!isSucc) {
log.warn("###短信服务发送失败[{}]", JsonUtils.toJson(batchSmsResponse)); log.warn("###发送短信API处理失败[{}]", JsonUtils.toJson(smsResponse));
} }
return isSucc; return isSucc;
} catch (Exception e) { } catch (Exception e) {
log.error("API处理异常", e); log.error("发送短信API处理异常", e);
} }
return false; return false;
} }
/* ================================================================== | */
} }
...@@ -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
......
...@@ -5,13 +5,11 @@ import com.aliyuncs.dypnsapi.model.v20170525.GetMobileRequest; ...@@ -5,13 +5,11 @@ import com.aliyuncs.dypnsapi.model.v20170525.GetMobileRequest;
import com.aliyuncs.dypnsapi.model.v20170525.GetMobileResponse; import com.aliyuncs.dypnsapi.model.v20170525.GetMobileResponse;
import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ClientException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport; import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.common.cache.redis.util.RedisUtil; import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.common.cache.redisson.util.RedisLockUtil; import com.liquidnet.common.cache.redisson.util.RedisLockUtil;
import com.liquidnet.common.mq.constant.MQConst;
import com.liquidnet.common.sms.constant.SmsEnum; import com.liquidnet.common.sms.constant.SmsEnum;
import com.liquidnet.common.sms.processor.SmsProcessor; import com.liquidnet.common.sms.processor.SmsProcessor;
import com.liquidnet.commons.lang.constant.LnsEnum; import com.liquidnet.commons.lang.constant.LnsEnum;
...@@ -25,7 +23,6 @@ import com.liquidnet.service.adam.service.AdamRdmService; ...@@ -25,7 +23,6 @@ import com.liquidnet.service.adam.service.AdamRdmService;
import com.liquidnet.service.adam.service.IAdamUserService; import com.liquidnet.service.adam.service.IAdamUserService;
import com.liquidnet.service.base.ErrorMapping; import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SmsMessage;
import com.liquidnet.service.base.UserPathDto; import com.liquidnet.service.base.UserPathDto;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -76,8 +73,8 @@ public class AdamLoginController { ...@@ -76,8 +73,8 @@ public class AdamLoginController {
IAdamUserService adamUserService; IAdamUserService adamUserService;
@Autowired @Autowired
RabbitTemplate rabbitTemplate; RabbitTemplate rabbitTemplate;
// @Autowired @Autowired
// SmsProcessor smsProcessor; SmsProcessor smsProcessor;
@Value("${liquidnet.reviewer.app-login.mobile}") @Value("${liquidnet.reviewer.app-login.mobile}")
private String reviewMobile; private String reviewMobile;
...@@ -170,12 +167,19 @@ public class AdamLoginController { ...@@ -170,12 +167,19 @@ public class AdamLoginController {
// } // }
String smsCode = RandomStringUtils.randomNumeric(6); String smsCode = RandomStringUtils.randomNumeric(6);
SmsMessage smsMessage = SmsMessage.builder().setPhone(mobile).setSignName(SmsEnum.ADSignName.正在现场.name()) // SmsMessage smsMessage = SmsMessage.builder().setPhone(mobile).setSignName(SmsEnum.ADSignName.正在现场.name())
.setTemplateCode(SmsEnum.ADTemplate.SMS_109535335.name()) // .setTemplateCode(SmsEnum.ADTemplate.SMS_109535335.name())
.setTemplateParam("code", smsCode); // .setTemplateParam("code", smsCode);
rabbitTemplate.convertAndSend(MQConst.EX_LNS_SMS_SENDER, MQConst.RK_SMS_CODE, smsMessage.toJson()); // rabbitTemplate.convertAndSend(MQConst.EX_LNS_SMS_SENDER, MQConst.RK_SMS_CODE, smsMessage.toJson());
ObjectNode msgNode = JsonUtils.OM().createObjectNode();
msgNode.put("code", smsCode);
boolean sendRst = smsProcessor.send(mobile, SmsEnum.ADSignName.M02.getVal(), SmsEnum.ADTemplate.SMS_109535335.name(), msgNode.asText());
if (sendRst) {
adamRdmService.setSmsCodeByMobile(mobile, smsCode); adamRdmService.setSmsCodeByMobile(mobile, smsCode);
return ResponseDto.success(); return ResponseDto.success();
}
return ResponseDto.failure(ErrorMapping.get("10002"));
} else { } else {
return ResponseDto.failure(ErrorMapping.get("10000")); return ResponseDto.failure(ErrorMapping.get("10000"));
} }
......
...@@ -38,7 +38,7 @@ public class ConsumerAdamSmsProcessor { ...@@ -38,7 +38,7 @@ public class ConsumerAdamSmsProcessor {
log.debug("CONSUMER SMS ==> Preparing:{}", msgBody); log.debug("CONSUMER SMS ==> Preparing:{}", msgBody);
try { try {
SmsMessage smsMessage = JsonUtils.fromJson(msgBody, SmsMessage.class); SmsMessage smsMessage = JsonUtils.fromJson(msgBody, SmsMessage.class);
boolean result = smsProcessor.aliyunDysmsSend(smsMessage.getPhone(), smsMessage.getSignName(), smsMessage.getTemplateCode(), smsMessage.getTemplateParam().toString()); boolean result = smsProcessor.send(smsMessage.getPhone(), smsMessage.getSignName(), smsMessage.getTemplateCode(), smsMessage.getTemplateParam().toString());
log.debug("CONSUMER SMS result of execution:{}", result); log.debug("CONSUMER SMS result of execution:{}", result);
if (result) { if (result) {
channel.basicAck(deliveryTag, false); channel.basicAck(deliveryTag, false);
...@@ -53,17 +53,17 @@ public class ConsumerAdamSmsProcessor { ...@@ -53,17 +53,17 @@ public class ConsumerAdamSmsProcessor {
/* ================================================================== | 短信验证码 */ /* ================================================================== | 短信验证码 */
@RabbitListener( // @RabbitListener(
bindings = @QueueBinding( // bindings = @QueueBinding(
exchange = @Exchange(MQConst.EX_LNS_SMS_SENDER), // exchange = @Exchange(MQConst.EX_LNS_SMS_SENDER),
key = MQConst.RK_SMS_CODE, // key = MQConst.RK_SMS_CODE,
value = @Queue(MQConst.QUEUES_SMS_CODE) // value = @Queue(MQConst.QUEUES_SMS_CODE)
), // ),
concurrency = "25" // concurrency = "25"
) // )
public void consumerSqlForSmsCode(Message msg, Channel channel) { // public void consumerSqlForSmsCode(Message msg, Channel channel) {
this.consumerSmsSendHandler(msg, channel); // this.consumerSmsSendHandler(msg, channel);
} // }
/* ================================================================== | 短信通知 */ /* ================================================================== | 短信通知 */
......
...@@ -38,7 +38,7 @@ public class ConsumerKylinSmsProcessor { ...@@ -38,7 +38,7 @@ public class ConsumerKylinSmsProcessor {
log.debug("CONSUMER SMS ==> Preparing:{}", msgBody); log.debug("CONSUMER SMS ==> Preparing:{}", msgBody);
try { try {
SmsMessage smsMessage = JsonUtils.fromJson(msgBody, SmsMessage.class); SmsMessage smsMessage = JsonUtils.fromJson(msgBody, SmsMessage.class);
boolean result = smsProcessor.aliyunDysmsSend(smsMessage.getPhone(), smsMessage.getSignName(), smsMessage.getTemplateCode(), smsMessage.getTemplateParam().toString()); boolean result = smsProcessor.send(smsMessage.getPhone(), smsMessage.getSignName(), smsMessage.getTemplateCode(), smsMessage.getTemplateParam().toString());
log.debug("CONSUMER SMS result of execution:{}", result); log.debug("CONSUMER SMS result of execution:{}", result);
if (result) { if (result) {
channel.basicAck(deliveryTag, false); channel.basicAck(deliveryTag, false);
...@@ -53,17 +53,17 @@ public class ConsumerKylinSmsProcessor { ...@@ -53,17 +53,17 @@ public class ConsumerKylinSmsProcessor {
/* ================================================================== | 短信验证码 */ /* ================================================================== | 短信验证码 */
@RabbitListener( // @RabbitListener(
bindings = @QueueBinding( // bindings = @QueueBinding(
exchange = @Exchange(MQConst.EX_LNS_SMS_SENDER), // exchange = @Exchange(MQConst.EX_LNS_SMS_SENDER),
key = MQConst.RK_SMS_CODE, // key = MQConst.RK_SMS_CODE,
value = @Queue(MQConst.QUEUES_SMS_CODE) // value = @Queue(MQConst.QUEUES_SMS_CODE)
), // ),
concurrency = "25" // concurrency = "25"
) // )
public void consumerSqlForSmsCode(Message msg, Channel channel) { // public void consumerSqlForSmsCode(Message msg, Channel channel) {
this.consumerSmsSendHandler(msg, channel); // this.consumerSmsSendHandler(msg, channel);
} // }
/* ================================================================== | 短信通知 */ /* ================================================================== | 短信通知 */
......
...@@ -29,7 +29,7 @@ public class AlipayStrategyAppImpl extends AbstractAlipayStrategy { ...@@ -29,7 +29,7 @@ public class AlipayStrategyAppImpl extends AbstractAlipayStrategy {
@Value("${liquidnet.dragon.alipay.gataway-url}") @Value("${liquidnet.dragon.alipay.gataway-url}")
private String alipayGatewayUrl; private String alipayGatewayUrl;
@Value("${liquidnet.dragon.alipay.notify-url}") @Value("${liquidnet.dragon.url}")
private String notifyUrl; private String notifyUrl;
@Autowired @Autowired
...@@ -47,7 +47,7 @@ public class AlipayStrategyAppImpl extends AbstractAlipayStrategy { ...@@ -47,7 +47,7 @@ public class AlipayStrategyAppImpl extends AbstractAlipayStrategy {
@Override @Override
protected String getNotifyUrl() { protected String getNotifyUrl() {
// notifyUrl = "/notify/app/alipay/1"; // notifyUrl = "/notify/app/alipay/1";
return notifyUrl + "/app"; return notifyUrl + "/notify/alipay/app";
} }
@Override @Override
......
...@@ -29,7 +29,7 @@ public class AlipayStrategyWapImpl extends AbstractAlipayStrategy { ...@@ -29,7 +29,7 @@ public class AlipayStrategyWapImpl extends AbstractAlipayStrategy {
@Value("${liquidnet.dragon.alipay.gataway-url}") @Value("${liquidnet.dragon.alipay.gataway-url}")
private String alipayGatewayUrl; private String alipayGatewayUrl;
@Value("${liquidnet.dragon.alipay.notify-url}") @Value("${liquidnet.dragon.url}")
private String notifyUrl; private String notifyUrl;
@Autowired @Autowired
...@@ -47,7 +47,7 @@ public class AlipayStrategyWapImpl extends AbstractAlipayStrategy { ...@@ -47,7 +47,7 @@ public class AlipayStrategyWapImpl extends AbstractAlipayStrategy {
@Override @Override
protected String getNotifyUrl() { protected String getNotifyUrl() {
// notifyUrl = "/notify/wap/alipay/1"; // notifyUrl = "/notify/wap/alipay/1";
return notifyUrl + "/wap"; return notifyUrl + "/notify/alipay/wap";
} }
@Override @Override
......
...@@ -27,9 +27,7 @@ import com.liquidnet.service.dragon.channel.alipay.sign.MD5; ...@@ -27,9 +27,7 @@ import com.liquidnet.service.dragon.channel.alipay.sign.MD5;
import com.liquidnet.service.dragon.utils.PayAlipayUtils; import com.liquidnet.service.dragon.utils.PayAlipayUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.Map; import java.util.*;
import java.util.SortedMap;
import java.util.TreeMap;
@Slf4j @Slf4j
public class AlipayUtil { public class AlipayUtil {
...@@ -150,5 +148,22 @@ public class AlipayUtil { ...@@ -150,5 +148,22 @@ public class AlipayUtil {
} }
return MD5.sign(signBuilder.substring(0, signBuilder.length() - 1), key, "UTF-8"); return MD5.sign(signBuilder.substring(0, signBuilder.length() - 1), key, "UTF-8");
} }
public static Map<String , String> parseNotifyMsg(Map<String, String[]> requestParams){
Map<String,String> params = new HashMap<String,String>();
for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
String name = (String) iter.next();
String[] values = requestParams.get(name);
String valueStr = "";
for (int i = 0; i < values.length; i++) {
valueStr = (i == values.length - 1) ? valueStr + values[i]
: valueStr + values[i] + ",";
}
params.put(name, valueStr);
}
return params;
}
} }
...@@ -4,6 +4,8 @@ import com.liquidnet.service.base.ResponseDto; ...@@ -4,6 +4,8 @@ import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto; import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto; import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import javax.servlet.http.HttpServletRequest;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
...@@ -16,4 +18,6 @@ import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto; ...@@ -16,4 +18,6 @@ import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
*/ */
public interface IPayChannelStrategy { public interface IPayChannelStrategy {
ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto); ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto);
void dragonNotify(HttpServletRequest request,String payType,String deviceFrom);
} }
package com.liquidnet.service.dragon.channel.strategy.impl; package com.liquidnet.service.dragon.channel.strategy.impl;
import com.alibaba.fastjson.JSON;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.channel.alipay.strategy.AlipayStrategyContext; import com.liquidnet.service.dragon.channel.alipay.strategy.AlipayStrategyContext;
import com.liquidnet.service.dragon.channel.alipay.util.AlipayUtil;
import com.liquidnet.service.dragon.channel.strategy.IPayChannelStrategy; import com.liquidnet.service.dragon.channel.strategy.IPayChannelStrategy;
import com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler; import com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler;
import com.liquidnet.service.dragon.constant.DragonConstant; import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto; import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto; import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/** /**
* @author AnJiabin <jiabin.an@lightnet.io> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
* @Description: currencyCloud * @Description: TODO
* @class: CurrencyCloudGetFundDataStrategyImpl * @class: PayChannelStrategyAlipayImpl
* @Package com.liquidnet.service.reconciliation.strategy.transtype.impl * @Package com.liquidnet.service.dragon.channel.strategy.impl
* @Copyright: LightNet @ Copyright (c) 2020 * @Copyright: LightNet @ Copyright (c) 2021
* @date 2020/10/27 14:58 * @date 2021/7/13 13:06
*/ */
@Slf4j
@Component @Component
@StrategyPayChannelHandler(DragonConstant.PayChannelEnum.ALIPAY) @StrategyPayChannelHandler(DragonConstant.PayChannelEnum.ALIPAY)
public class PayChannelStrategyAlipayImpl implements IPayChannelStrategy { public class PayChannelStrategyAlipayImpl implements IPayChannelStrategy {
...@@ -29,4 +37,13 @@ public class PayChannelStrategyAlipayImpl implements IPayChannelStrategy { ...@@ -29,4 +37,13 @@ public class PayChannelStrategyAlipayImpl implements IPayChannelStrategy {
public ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto) { public ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto) {
return alipayStrategyContext.getStrategy(dragonPayBaseReqDto.getDeviceFrom()).dragonPay(dragonPayBaseReqDto); return alipayStrategyContext.getStrategy(dragonPayBaseReqDto.getDeviceFrom()).dragonPay(dragonPayBaseReqDto);
} }
@Override
public void dragonNotify(HttpServletRequest request,String payType,String deviceFrom) {
Map<String, String[]> requestParams = request.getParameterMap();
Map<String, String> notifyMap = new HashMap<String, String>();
notifyMap = AlipayUtil.parseNotifyMsg(requestParams);
log.info("dragonNotify-->alipay json : {}", JSON.toJSONString(notifyMap));
}
} }
...@@ -6,20 +6,21 @@ import com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChann ...@@ -6,20 +6,21 @@ import com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChann
import com.liquidnet.service.dragon.constant.DragonConstant; import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto; import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto; import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import javax.servlet.http.HttpServletRequest;
import java.util.List;
/** /**
* @author AnJiabin <jiabin.an@lightnet.io> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
* @Description: liquidnet-wallet * @Description: TODO
* @class: LiquidnetWalletGetFundDataStrategyImpl * @class: PayChannelStrategyApplepayImpl
* @Package com.liquidnet.service.reconciliation.strategy.transtype.impl * @Package com.liquidnet.service.dragon.channel.strategy.impl
* @Copyright: LightNet @ Copyright (c) 2020 * @Copyright: LightNet @ Copyright (c) 2021
* @date 2020/10/27 14:58 * @date 2021/7/13 13:06
*/ */
@Slf4j
@Component @Component
@StrategyPayChannelHandler(DragonConstant.PayChannelEnum.APPLEPAY) @StrategyPayChannelHandler(DragonConstant.PayChannelEnum.APPLEPAY)
public class PayChannelStrategyApplepayImpl implements IPayChannelStrategy { public class PayChannelStrategyApplepayImpl implements IPayChannelStrategy {
...@@ -28,4 +29,9 @@ public class PayChannelStrategyApplepayImpl implements IPayChannelStrategy { ...@@ -28,4 +29,9 @@ public class PayChannelStrategyApplepayImpl implements IPayChannelStrategy {
public ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto) { public ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto) {
return null; return null;
} }
@Override
public void dragonNotify(HttpServletRequest request,String payType,String deviceFrom) {
}
} }
package com.liquidnet.service.dragon.channel.strategy.impl; package com.liquidnet.service.dragon.channel.strategy.impl;
import com.alibaba.fastjson.JSON;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.channel.strategy.IPayChannelStrategy; import com.liquidnet.service.dragon.channel.strategy.IPayChannelStrategy;
import com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler; import com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler;
import com.liquidnet.service.dragon.channel.wepay.strategy.WepayStrategyContext; import com.liquidnet.service.dragon.channel.wepay.strategy.WepayStrategyContext;
import com.liquidnet.service.dragon.channel.wepay.util.WepayUtil;
import com.liquidnet.service.dragon.constant.DragonConstant; import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto; import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto; import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
/** /**
* @author AnJiabin <jiabin.an@lightnet.io> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
* @Description: liquidnet-wallet * @Description: TODO
* @class: LiquidnetWalletGetFundDataStrategyImpl * @class: PayChannelStrategyWepayImpl
* @Package com.liquidnet.service.reconciliation.strategy.transtype.impl * @Package com.liquidnet.service.dragon.channel.strategy.impl
* @Copyright: LightNet @ Copyright (c) 2020 * @Copyright: LightNet @ Copyright (c) 2021
* @date 2020/10/27 14:58 * @date 2021/7/13 13:06
*/ */
@Slf4j
@Component @Component
@StrategyPayChannelHandler(DragonConstant.PayChannelEnum.WEPAY) @StrategyPayChannelHandler(DragonConstant.PayChannelEnum.WEPAY)
public class PayChannelStrategyWepayImpl implements IPayChannelStrategy { public class PayChannelStrategyWepayImpl implements IPayChannelStrategy {
...@@ -29,4 +39,20 @@ public class PayChannelStrategyWepayImpl implements IPayChannelStrategy { ...@@ -29,4 +39,20 @@ public class PayChannelStrategyWepayImpl implements IPayChannelStrategy {
public ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto) { public ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto) {
return wepayStrategyContext.getStrategy(dragonPayBaseReqDto.getDeviceFrom()).dragonPay(dragonPayBaseReqDto); return wepayStrategyContext.getStrategy(dragonPayBaseReqDto.getDeviceFrom()).dragonPay(dragonPayBaseReqDto);
} }
@Override
public void dragonNotify(HttpServletRequest request,String payType,String deviceFrom) {
try {
InputStream inputStream = request.getInputStream();// 从request中取得输入流
Map<String, String> notifyMap = new HashMap<String, String>();
try {
notifyMap = WepayUtil.parseXml(inputStream);
log.info("dragonNotify-->wepay json : {}", JSON.toJSONString(notifyMap));
} catch (Exception e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
} }
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;
}
...@@ -106,8 +106,8 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy { ...@@ -106,8 +106,8 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
parameters.put("body", dragonPayBaseReqDto.getName()); parameters.put("body", dragonPayBaseReqDto.getName());
parameters.put("detail", dragonPayBaseReqDto.getDetail()); parameters.put("detail", dragonPayBaseReqDto.getDetail());
parameters.put("out_trade_no", dragonPayBaseReqDto.getCode()); parameters.put("out_trade_no", dragonPayBaseReqDto.getCode());
parameters.put("time_expire", "20210908103456"); parameters.put("time_expire", "203110908103456");
parameters.put("notify_url", dragonPayBaseReqDto.getNotifyUrl()); parameters.put("notify_url", this.getNotifyUrl());
return parameters; return parameters;
}; };
...@@ -128,4 +128,9 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy { ...@@ -128,4 +128,9 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
* @return * @return
*/ */
protected abstract String getRequestUrl(); protected abstract String getRequestUrl();
/**
* 设置notifyUrl
*/
protected abstract String getNotifyUrl();
} }
...@@ -5,6 +5,7 @@ import com.liquidnet.service.dragon.channel.wepay.strategy.annotation.StrategyWe ...@@ -5,6 +5,7 @@ import com.liquidnet.service.dragon.channel.wepay.strategy.annotation.StrategyWe
import com.liquidnet.service.dragon.constant.DragonConstant; import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto; import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.SortedMap; import java.util.SortedMap;
...@@ -22,6 +23,9 @@ import java.util.SortedMap; ...@@ -22,6 +23,9 @@ import java.util.SortedMap;
@Component @Component
@StrategyWepayHandler(DragonConstant.DeviceFromEnum.APP) @StrategyWepayHandler(DragonConstant.DeviceFromEnum.APP)
public class WepayStrategyAppImpl extends AbstractWepayStrategy { public class WepayStrategyAppImpl extends AbstractWepayStrategy {
@Value("${liquidnet.dragon.url}")
private String notifyUrl;
@Override @Override
SortedMap<String, Object> appendRequestParam(SortedMap<String, Object> requestMap) { SortedMap<String, Object> appendRequestParam(SortedMap<String, Object> requestMap) {
requestMap.put("trade_type", "APP"); requestMap.put("trade_type", "APP");
...@@ -38,4 +42,9 @@ public class WepayStrategyAppImpl extends AbstractWepayStrategy { ...@@ -38,4 +42,9 @@ public class WepayStrategyAppImpl extends AbstractWepayStrategy {
protected String getRequestUrl() { protected String getRequestUrl() {
return "https://api.mch.weixin.qq.com/pay/unifiedorder"; return "https://api.mch.weixin.qq.com/pay/unifiedorder";
} }
@Override
protected String getNotifyUrl() {
return notifyUrl + "/notify/wepay/app";
}
} }
...@@ -5,6 +5,7 @@ import com.liquidnet.service.dragon.channel.wepay.strategy.annotation.StrategyWe ...@@ -5,6 +5,7 @@ import com.liquidnet.service.dragon.channel.wepay.strategy.annotation.StrategyWe
import com.liquidnet.service.dragon.constant.DragonConstant; import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto; import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.SortedMap; import java.util.SortedMap;
...@@ -22,6 +23,9 @@ import java.util.SortedMap; ...@@ -22,6 +23,9 @@ import java.util.SortedMap;
@Component @Component
@StrategyWepayHandler(DragonConstant.DeviceFromEnum.APPLET) @StrategyWepayHandler(DragonConstant.DeviceFromEnum.APPLET)
public class WepayStrategyAppletImpl extends AbstractWepayStrategy{ public class WepayStrategyAppletImpl extends AbstractWepayStrategy{
@Value("${liquidnet.dragon.url}")
private String notifyUrl;
@Override @Override
SortedMap<String, Object> appendRequestParam(SortedMap<String, Object> requestMap) { SortedMap<String, Object> appendRequestParam(SortedMap<String, Object> requestMap) {
requestMap.put("trade_type", "JSAPI"); requestMap.put("trade_type", "JSAPI");
...@@ -39,4 +43,9 @@ public class WepayStrategyAppletImpl extends AbstractWepayStrategy{ ...@@ -39,4 +43,9 @@ public class WepayStrategyAppletImpl extends AbstractWepayStrategy{
protected String getRequestUrl() { protected String getRequestUrl() {
return "https://api.mch.weixin.qq.com/pay/unifiedorder"; return "https://api.mch.weixin.qq.com/pay/unifiedorder";
} }
@Override
protected String getNotifyUrl() {
return notifyUrl + "/notify/wepay/applet";
}
} }
...@@ -5,6 +5,7 @@ import com.liquidnet.service.dragon.channel.wepay.strategy.annotation.StrategyWe ...@@ -5,6 +5,7 @@ import com.liquidnet.service.dragon.channel.wepay.strategy.annotation.StrategyWe
import com.liquidnet.service.dragon.constant.DragonConstant; import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto; import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.SortedMap; import java.util.SortedMap;
...@@ -22,6 +23,9 @@ import java.util.SortedMap; ...@@ -22,6 +23,9 @@ import java.util.SortedMap;
@Component @Component
@StrategyWepayHandler(DragonConstant.DeviceFromEnum.JS) @StrategyWepayHandler(DragonConstant.DeviceFromEnum.JS)
public class WepayStrategyJsImpl extends AbstractWepayStrategy{ public class WepayStrategyJsImpl extends AbstractWepayStrategy{
@Value("${liquidnet.dragon.url}")
private String notifyUrl;
@Override @Override
SortedMap<String, Object> appendRequestParam(SortedMap<String, Object> requestMap) { SortedMap<String, Object> appendRequestParam(SortedMap<String, Object> requestMap) {
requestMap.put("trade_type", "JSAPI"); requestMap.put("trade_type", "JSAPI");
...@@ -39,4 +43,9 @@ public class WepayStrategyJsImpl extends AbstractWepayStrategy{ ...@@ -39,4 +43,9 @@ public class WepayStrategyJsImpl extends AbstractWepayStrategy{
protected String getRequestUrl() { protected String getRequestUrl() {
return "https://api.mch.weixin.qq.com/pay/unifiedorder"; return "https://api.mch.weixin.qq.com/pay/unifiedorder";
} }
@Override
protected String getNotifyUrl() {
return notifyUrl + "/notify/wepay/js";
}
} }
...@@ -5,6 +5,7 @@ import com.liquidnet.service.dragon.channel.wepay.strategy.annotation.StrategyWe ...@@ -5,6 +5,7 @@ import com.liquidnet.service.dragon.channel.wepay.strategy.annotation.StrategyWe
import com.liquidnet.service.dragon.constant.DragonConstant; import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto; import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.SortedMap; import java.util.SortedMap;
...@@ -22,6 +23,9 @@ import java.util.SortedMap; ...@@ -22,6 +23,9 @@ import java.util.SortedMap;
@Component @Component
@StrategyWepayHandler(DragonConstant.DeviceFromEnum.WAP) @StrategyWepayHandler(DragonConstant.DeviceFromEnum.WAP)
public class WepayStrategyWapImpl extends AbstractWepayStrategy{ public class WepayStrategyWapImpl extends AbstractWepayStrategy{
@Value("${liquidnet.dragon.url}")
private String notifyUrl;
@Override @Override
SortedMap<String, Object> appendRequestParam(SortedMap<String, Object> requestMap) { SortedMap<String, Object> appendRequestParam(SortedMap<String, Object> requestMap) {
requestMap.put("trade_type", "MWEB"); requestMap.put("trade_type", "MWEB");
...@@ -38,4 +42,9 @@ public class WepayStrategyWapImpl extends AbstractWepayStrategy{ ...@@ -38,4 +42,9 @@ public class WepayStrategyWapImpl extends AbstractWepayStrategy{
protected String getRequestUrl() { protected String getRequestUrl() {
return "https://api.mch.weixin.qq.com/pay/unifiedorder"; return "https://api.mch.weixin.qq.com/pay/unifiedorder";
} }
@Override
protected String getNotifyUrl() {
return notifyUrl + "/notify/wepay/wap";
}
} }
package com.liquidnet.service.dragon.controller; package com.liquidnet.service.dragon.controller;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.dragon.service.IDragonOrdersService;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotNull; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
...@@ -23,34 +24,21 @@ import javax.validation.constraints.NotNull; ...@@ -23,34 +24,21 @@ import javax.validation.constraints.NotNull;
* @date 2021/7/11 23:35 * @date 2021/7/11 23:35
*/ */
@RestController @RestController
@RequestMapping("pay") @RequestMapping("notify")
public class PayNotifyController { public class PayNotifyController {
@Autowired
private IDragonOrdersService dragonOrdersService;
/** /**
* 支付宝支付回调 * 支付宝支付回调
* @return * @return
*/ */
@PostMapping("/notify/alipay") @PostMapping("/{payType}/{deviceFrom}")
@ApiOperation("支付宝支付回调") @ApiOperation("支付宝支付回调")
@ApiResponse(code = 200, message = "接口返回对象参数") @ApiResponse(code = 200, message = "接口返回对象参数")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "payType", value = "支付类型:alipay,wepay,iappay", example = "alipay") @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "payType", value = "支付类型:alipay,wepay,iappay", example = "alipay")
}) })
public ResponseDto<DragonPayBaseRespDto> notifyAlipay( public void dragonNotify(@PathVariable("payType") String payType,@PathVariable("deviceFrom") String deviceFrom,HttpServletRequest request, HttpServletResponse respone) throws Exception {
@RequestParam(value = "payType") @NotNull(message = "支付类型不能为空") String payType){ dragonOrdersService.dragonNotify(request,payType,deviceFrom);
return null;
}
/**
* 微信支付回调
* @return
*/
@PostMapping("/notify/wepay")
@ApiOperation("支付宝支付回调")
@ApiResponse(code = 200, message = "接口返回对象参数")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "payType", value = "支付类型:alipay,wepay,iappay", example = "alipay")
})
public ResponseDto<DragonPayBaseRespDto> notifyWepay(
@RequestParam(value = "payType") @NotNull(message = "支付类型不能为空") String payType){
return null;
} }
} }
...@@ -3,14 +3,18 @@ package com.liquidnet.service.dragon.controller; ...@@ -3,14 +3,18 @@ package com.liquidnet.service.dragon.controller;
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 com.liquidnet.service.dragon.service.IDragonOrderRefundsService; import com.liquidnet.service.dragon.service.IDragonOrderRefundsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse; 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;
@Api(tags = "退款")
@RestController @RestController
@RequestMapping("refund") @RequestMapping("refund")
public class RefundController { public class RefundController {
...@@ -18,21 +22,6 @@ public class RefundController { ...@@ -18,21 +22,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 +36,14 @@ public class RefundController { ...@@ -47,4 +36,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(
HttpServletRequest request,
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();
...@@ -126,13 +135,15 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -126,13 +135,15 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
parameters.put("nonce_str", nonceStr); parameters.put("nonce_str", nonceStr);
parameters.put("out_refund_no", refundCode); parameters.put("out_refund_no", refundCode);
parameters.put("out_trade_no", code); parameters.put("out_trade_no", code);
parameters.put("refund_fee", price.doubleValue() * 100); parameters.put("refund_fee", (int)(price.doubleValue() * 100)+"");
parameters.put("total_fee", priceTotal.doubleValue() * 100); parameters.put("total_fee", (int)(priceTotal.doubleValue() * 100)+"");
parameters.put("notify_url", notifyUrl); parameters.put("notify_url", notifyUrl);
parameters.put("refund_desc", reason); parameters.put("refund_desc", reason);
parameters.put("refund_account", "REFUND_SOURCE_RECHARGE_FUNDS");
String sign = PayWepayUtils.getInstance().createSign(parameters); String sign = PayWepayUtils.getInstance().createSign(parameters);
parameters.put("sign", sign); parameters.put("sign", sign);
String data = PayWepayUtils.getInstance().getRequestXml(parameters); String data = PayWepayUtils.getInstance().getRequestXml(parameters);
log.debug("XMLSTRING = " + data);
try { try {
HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund");
httpost.setEntity(new StringEntity(data, "UTF-8")); httpost.setEntity(new StringEntity(data, "UTF-8"));
...@@ -141,9 +152,10 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -141,9 +152,10 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
entity.getContent(); entity.getContent();
String jsonStr = EntityUtils.toString(entity, "UTF-8"); String jsonStr = EntityUtils.toString(entity, "UTF-8");
log.debug("JSONSTR = " + jsonStr);
WePayRefundReturnDto wePayRefundReturnDto = XmlUtil.toBean(jsonStr, WePayRefundReturnDto.class); WePayRefundReturnDto wePayRefundReturnDto = XmlUtil.toBean(jsonStr, WePayRefundReturnDto.class);
log.debug("BEAN = " + wePayRefundReturnDto);
if (!wePayRefundReturnDto.getResultCode().equalsIgnoreCase("SUCCESS") || wePayRefundReturnDto.getResultCode() == null) { if (!wePayRefundReturnDto.getReturnCode().equalsIgnoreCase("SUCCESS") || wePayRefundReturnDto.getReturnCode() == null) {
try { try {
String refundError = ""; String refundError = "";
refundStatus = DragonConstant.RefundStatusEnum.STATUS_ERROR.getCode(); refundStatus = DragonConstant.RefundStatusEnum.STATUS_ERROR.getCode();
...@@ -155,7 +167,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -155,7 +167,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();
...@@ -182,12 +194,12 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -182,12 +194,12 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
new Object[]{orderRefundId, paymentType, data, nowTime, nowTime} new Object[]{orderRefundId, paymentType, data, nowTime, nowTime}
); );
try { try {
if (wePayRefundReturnDto.getResultCode().equalsIgnoreCase("SUCCESS")) { if (wePayRefundReturnDto.getReturnCode().equalsIgnoreCase("SUCCESS")) {
refundStatus = DragonConstant.RefundStatusEnum.STATUS_REFUNDED.getCode(); refundStatus = DragonConstant.RefundStatusEnum.STATUS_REFUNDED.getCode();
} }
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 +231,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -219,6 +231,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 +257,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -244,7 +257,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 +293,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -280,7 +293,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 +319,81 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -306,6 +319,81 @@ 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.debug("JSON = " + jsonStr);
WePayRefundReturnCallBackDto callBackDto = XmlUtil.toBean(jsonStr, WePayRefundReturnCallBackDto.class);
log.debug("DATA = " + 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 {
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 +419,29 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService ...@@ -331,4 +419,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()}
);
}
}
} }
...@@ -13,6 +13,7 @@ import org.springframework.data.redis.connection.stream.StreamRecords; ...@@ -13,6 +13,7 @@ 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 javax.servlet.http.HttpServletRequest;
import java.util.HashMap; import java.util.HashMap;
@Slf4j @Slf4j
...@@ -42,4 +43,9 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService { ...@@ -42,4 +43,9 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
dragonPayBaseReqDto.setCode(IDGenerator.payCode()); dragonPayBaseReqDto.setCode(IDGenerator.payCode());
return payChannelStrategyContext.getStrategy(dragonPayBaseReqDto.getPayType()).dragonPay(dragonPayBaseReqDto); return payChannelStrategyContext.getStrategy(dragonPayBaseReqDto.getPayType()).dragonPay(dragonPayBaseReqDto);
} }
@Override
public void dragonNotify(HttpServletRequest request,String payType,String deviceFrom) {
payChannelStrategyContext.getStrategy(payType).dragonNotify(request,payType,deviceFrom);
}
} }
...@@ -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,24 @@ public class PayWepayUtils { ...@@ -118,4 +122,24 @@ 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 "";
}
}
} }
# ------------------------创建退款订单---------------------------- # ------------------------创建退款订单----------------------------
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(?,?,?,?,?,?,?)
......
...@@ -41,6 +41,11 @@ ...@@ -41,6 +41,11 @@
<artifactId>liquidnet-service-adam-api</artifactId> <artifactId>liquidnet-service-adam-api</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-common-sms</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- other --> <!-- other -->
<dependency> <dependency>
......
...@@ -3,13 +3,11 @@ package com.liquidnet.service.order.service.impl; ...@@ -3,13 +3,11 @@ package com.liquidnet.service.order.service.impl;
import com.liquidnet.common.cache.redis.util.RedisUtil; import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.common.cache.redisson.util.RedisLockUtil; import com.liquidnet.common.cache.redisson.util.RedisLockUtil;
import com.liquidnet.common.mq.constant.MQConst; import com.liquidnet.common.mq.constant.MQConst;
import com.liquidnet.common.sms.constant.SmsEnum;
import com.liquidnet.commons.lang.util.*; import com.liquidnet.commons.lang.util.*;
import com.liquidnet.service.adam.dto.vo.AdamAddressesVo; import com.liquidnet.service.adam.dto.vo.AdamAddressesVo;
import com.liquidnet.service.adam.dto.vo.AdamEntersVo; import com.liquidnet.service.adam.dto.vo.AdamEntersVo;
import com.liquidnet.service.base.ErrorMapping; import com.liquidnet.service.base.*;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.UserPathDto;
import com.liquidnet.service.kylin.constant.KylinRedisConst; import com.liquidnet.service.kylin.constant.KylinRedisConst;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst; import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dto.param.PayAgainParam; import com.liquidnet.service.kylin.dto.param.PayAgainParam;
...@@ -17,8 +15,6 @@ import com.liquidnet.service.kylin.dto.param.PayOrderParam; ...@@ -17,8 +15,6 @@ import com.liquidnet.service.kylin.dto.param.PayOrderParam;
import com.liquidnet.service.kylin.dto.param.SyncOrderParam; import com.liquidnet.service.kylin.dto.param.SyncOrderParam;
import com.liquidnet.service.kylin.dto.vo.middle.KylinTicketTimesVo; import com.liquidnet.service.kylin.dto.vo.middle.KylinTicketTimesVo;
import com.liquidnet.service.kylin.dto.vo.middle.KylinTicketVo; import com.liquidnet.service.kylin.dto.vo.middle.KylinTicketVo;
import com.liquidnet.service.kylin.dto.vo.middle.message.MessageConfigVo;
import com.liquidnet.service.kylin.dto.vo.middle.message.MessageDataVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketEntitiesVo; import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketEntitiesVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketVo; import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinPerformanceVo; import com.liquidnet.service.kylin.dto.vo.mongo.KylinPerformanceVo;
...@@ -839,20 +835,35 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ ...@@ -839,20 +835,35 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
} }
} }
MessageDataVo dataVo = new MessageDataVo(); // MessageDataVo dataVo = new MessageDataVo();
dataVo.setName(orderTicketData.getPerformanceTitle()); // dataVo.setName(orderTicketData.getPerformanceTitle());
String time1 = DateUtil.format(DateUtil.Formatter.yyyyMMddHHmmss.parse(ticketData.getUseStart()), DateUtil.Formatter.yyyy_MM_dd); String time1 = DateUtil.format(DateUtil.Formatter.yyyyMMddHHmmss.parse(ticketData.getUseStart()), DateUtil.Formatter.yyyy_MM_dd);
String time2 = DateUtil.format(DateUtil.Formatter.yyyyMMddHHmmss.parse(performanceData.getTimeStart()), DateUtil.Formatter.HHmm); String time2 = DateUtil.format(DateUtil.Formatter.yyyyMMddHHmmss.parse(performanceData.getTimeStart()), DateUtil.Formatter.HHmm);
dataVo.setTime(time1 + " " + time2); // dataVo.setTime(time1 + " " + time2);
MessageConfigVo configVo = new MessageConfigVo(); // MessageConfigVo configVo = new MessageConfigVo();
configVo.setStatus(true); // configVo.setStatus(true);
SmsEnum.ADTemplate adTemplate = null;
if (orderTicketData.getGetTicketType().equals("express")) { if (orderTicketData.getGetTicketType().equals("express")) {
configVo.setId("SMS_181490473"); // configVo.setId("SMS_181490473");
adTemplate = SmsEnum.ADTemplate.SMS_181490473;
} else if (orderTicketData.getGetTicketType().equals("electronic")) { } else if (orderTicketData.getGetTicketType().equals("electronic")) {
configVo.setId(ticketData.getIsShowCode() == 1 ? "SMS_171358560" : "SMS_181500419"); // configVo.setId(ticketData.getIsShowCode() == 1 ? "SMS_171358560" : "SMS_181500419");
adTemplate = ticketData.getIsShowCode() == 1 ? SmsEnum.ADTemplate.SMS_171358560 : SmsEnum.ADTemplate.SMS_181500419;
}
// otherUtils.sendMessage(orderTicketData.getUserMobile(), dataVo, configVo, 1);
if (null != adTemplate) {
rabbitTemplate.convertAndSend(MQConst.EX_LNS_SMS_SENDER, MQConst.RK_SMS_NOTICE,
SmsMessage.builder().setPhone(orderTicketData.getUserMobile())
.setSignName(SmsEnum.ADSignName.M02.getVal())
.setTemplateCode(adTemplate.name())
.setTemplateParam("name", orderTicketData.getPerformanceTitle())
.setTemplateParam("time", time1 + " " + time2).toJson()
);
} }
otherUtils.sendMessage(orderTicketData.getUserMobile(), dataVo, configVo, 1);
// 大麦回调 // 大麦回调
sycDamaiOrder(orderTickets.getOrderTicketsId()); sycDamaiOrder(orderTickets.getOrderTicketsId());
......
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