Commit 44ee3d87 by YG8999

微信退款

parent 9ecea2fe
......@@ -14,7 +14,13 @@ ruoyi:
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: char
# 微信相关配置
wechat:
appId: wxdd170b8783edf7a0
appSecret: 7339f117e85876a0dfe10ea1ed47340e
mchId: 1658895429
signKey: ZEKu56XCezuESfNEdM4zVZEN3cz2PuHz
certPath: /var/gxpt/wechat_ssl/apiclient_cert.p12
# 开发环境配置
server:
# 服务器的HTTP端口,默认为8080
......@@ -114,13 +120,13 @@ spring:
# redis 配置
redis:
# 地址
host: 127.0.0.1
host: 47.99.53.236
# 端口,默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password: 123456
password: Coujiao&031107
# 连接超时时间
timeout: 10s
lettuce:
......@@ -187,6 +193,10 @@ xss:
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
meituan:
developerId: 123456
signKey: abcdefghijklmnopqrstuvwxyz
appAuthToken: abcdefghijklmnopqrstuvwxyz
dianping:
appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
......
......@@ -288,7 +288,8 @@ public class RestTemplateUtil {
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(
sslContext,
new String[]{"TLSv1"},
// new String[]{"TLSv1"},
null,
null,
new DefaultHostnameVerifier());
......
......@@ -18,8 +18,9 @@ ruoyi:
wechat:
appId: wxdd170b8783edf7a0
appSecret: 7339f117e85876a0dfe10ea1ed47340e
mchId: 0
signKey: 0
mchId: 1658895429
signKey: ZEKu56XCezuESfNEdM4zVZEN3cz2PuHz
certPath: /var/gxpt/wechat_ssl/apiclient_cert.p12
# 开发环境配置
server:
# 服务器的HTTP端口,默认为8080
......@@ -116,13 +117,13 @@ spring:
# redis 配置
redis:
# 地址
host: 127.0.0.1
host: 47.99.53.236
# 端口,默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password: 123456
password: Coujiao&031107
# 连接超时时间
timeout: 10s
lettuce:
......@@ -189,7 +190,13 @@ xss:
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
meituan:
developerId: 123456
signKey: abcdefghijklmnopqrstuvwxyz
appAuthToken: abcdefghijklmnopqrstuvwxyz
dianping:
appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
authCode: 6be3e11e19d0b3595046cc2cefbf05da790be35d
#订单
order:
allow-refund-time: 3600
......@@ -20,7 +20,7 @@ wechat:
appSecret: 7339f117e85876a0dfe10ea1ed47340e
mchId: 1658895429
signKey: ZEKu56XCezuESfNEdM4zVZEN3cz2PuHz
certPath: /var/gxpt/wechat_ssl/apiclient_cert.p12
certPath: /Users/project/pseer/apiclient_cert.p12
# 开发环境配置
server:
# 服务器的HTTP端口,默认为8080
......@@ -144,6 +144,12 @@ spring:
defaultTopic: "ydlink/#"
completion-timeout: 15000
is-subscribe-topic: false
sms:
url: "http://121.36.230.249:7862/smsv2"
username: "799243"
password: "RjaI8uA"
extno: "10690"
signature: "【凑角】"
# token配置
token:
......@@ -192,3 +198,6 @@ meituan:
dianping:
appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
#订单
order:
allow-refund-time: 3600
package share.system.mqtt;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Singleton;
import java.util.Date;
/**
* 雪花算法工具类
*/
......@@ -68,6 +73,18 @@ public class SnowFlakeUtil {
return Singleton.get(SnowFlakeUtil.class, new Object[]{1L, 1L}).nextId();
}
public static void main(String[] args) {
String dateStr1 = "2017-03-01 22:33:23";
Date date1 = DateUtil.parse(dateStr1);
String dateStr2 = "2023-11-18 13:03:23";
Date date2 = DateUtil.parse(dateStr2);
long between = cn.hutool.core.date.DateUtil.between(cn.hutool.core.date.DateUtil.date(),
date2, DateUnit.SECOND);
System.out.println(between);
}
}
......@@ -10,6 +10,7 @@ import lombok.experimental.Accessors;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
/**
......@@ -19,7 +20,7 @@ import java.math.BigDecimal;
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="OrderRefundRequest对象", description="订单退款")
public class OrderRefundRequest {
public class OrderRefundRequest implements Serializable {
private static final long serialVersionUID=1L;
@ApiModelProperty(value = "订单编号")
......
......@@ -236,7 +236,7 @@ public class CallbackServiceImpl implements CallbackService {
return refundRecord.getStr("returnXml");
}
sOrder.setStatus(OrderStatusEnum.CANCEL.getCode());
sOrder.setRefundStatus(RefundStatusEnum.INREFUND.getCode());
sOrder.setRefundStatus(RefundStatusEnum.REFUNDED.getCode());
boolean update = sOrderService.updateById(sOrder);
if (update) {
// 退款task
......@@ -313,10 +313,10 @@ public class CallbackServiceImpl implements CallbackService {
throw new BaseException("pay_weixin_appid或pay_routine_appid不能都为空");
}
if (StrUtil.isNotBlank(publicAppid) && appid.equals(publicAppid)) {
signKey = weChatConfig.getSignKey();
signKey = weChatConfig.getPublicSignKey();
}
if (StrUtil.isNotBlank(miniAppid) && appid.equals(miniAppid)) {
signKey = weChatConfig.getPublicSignKey();
signKey = weChatConfig.getSignKey();
}
return signKey;
}
......
......@@ -181,7 +181,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
long between = cn.hutool.core.date.DateUtil.between(nowTime,
startTime, DateUnit.SECOND);
if (between > allowRefundTime) {
if (between > allowRefundTime && RefundStatusEnum.UNREFUND.getCode().equals(order.getRefundStatus())) {
return Boolean.TRUE;
}
}
......@@ -418,7 +418,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
//退款
if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getValue()) && request.getAmount().compareTo(BigDecimal.ZERO) > 0) {
if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getCode()) && request.getAmount().compareTo(BigDecimal.ZERO) > 0) {
try {
orderRefundService.refund(request, sOrder);
} catch (Exception e) {
......@@ -447,7 +447,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
sOrder.setRefundReason(request.getRefundReason());
updateById(sOrder);
//微信退款
if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getValue()) && request.getAmount().compareTo(BigDecimal.ZERO) == 0) {
if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getCode()) && request.getAmount().compareTo(BigDecimal.ZERO) == 0) {
// 退款task
redisUtil.lPush(Constants.ORDER_TASK_REDIS_KEY_AFTER_REFUND_BY_USER, sOrder.getId());
}
......@@ -575,22 +575,40 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
/**
* 小程序申请退款
* @param request
* @return
*/
@Override
public boolean autoRefund(OrderRefundRequest request) {
SOrder sOrder = getInfoException(request.getOrderNo());
if (!YesNoEnum.yes.getIndex().equals(sOrder.getPayStatus())) {
throw new BaseException("未支付无法退款");
}
if (sOrder.getRefundPrice().add(request.getAmount()).compareTo(sOrder.getPayPrice()) > 0) {
if (request.getAmount().compareTo(sOrder.getPayPrice()) > 0) {
throw new BaseException("退款金额大于支付金额,请修改退款金额");
}
if (request.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
if (sOrder.getPayPrice().compareTo(BigDecimal.ZERO) != 0) {
throw new BaseException("退款金额不能为0,请修改退款金额");
// if (request.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
// if (sOrder.getPayPrice().compareTo(BigDecimal.ZERO) != 0) {
// throw new BaseException("退款金额不能为0,请修改退款金额");
// }
// }
// 是否满足退款
boolean isRefunds;
if (ObjectUtil.isNotNull(sOrder.getCouponId())) {
SConsumerCoupon coupon = consumerCouponService.getById(sOrder.getCouponId());
// 判断是否可以退款
isRefunds = isRefund(sOrder, coupon);
} else {
// 判断是否可以退款
isRefunds = isRefund(sOrder, null);
}
if (!isRefunds) {
throw new BaseException("不满足订单退款规则");
}
//退款
if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getValue()) && request.getAmount().compareTo(BigDecimal.ZERO) > 0) {
if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getCode()) && request.getAmount().compareTo(BigDecimal.ZERO) > 0) {
try {
orderRefundService.refund(request, sOrder);
} catch (Exception e) {
......@@ -606,7 +624,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
sOrder.setRefundReason(request.getRefundReason());
updateById(sOrder);
//微信退款
if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getValue()) && request.getAmount().compareTo(BigDecimal.ZERO) == 0) {
if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getCode()) && request.getAmount().compareTo(BigDecimal.ZERO) == 0) {
// 退款task, 定时任务退优惠券
redisUtil.lPush(Constants.ORDER_TASK_REDIS_KEY_AFTER_REFUND_BY_USER, sOrder.getId());
}
......
......@@ -595,10 +595,11 @@ public class WechatNewServiceImpl implements WechatNewService {
public WxRefundResponseVo payRefund(WxRefundVo wxRefundVo, String path) {
String xmlStr = XmlUtil.objectToXml(wxRefundVo);
String url = WeChatConstants.PAY_API_URL + WeChatConstants.PAY_REFUND_API_URI_WECHAT;
HashMap<String, Object> map = CollUtil.newHashMap();
HashMap<String, Object> map;
String xml = "";
try {
xml = restTemplateUtil.postWXRefundXml(url, xmlStr, wxRefundVo.getMch_id(), path);
map = XmlUtil.xmlToMap(xml);
} catch (Exception e) {
e.printStackTrace();
......
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