Merge remote-tracking branch 'origin/dev/dev' into dev/dev
# Conflicts: # src/main/java/com/ai/da/mapper/primary/entity/BaseEntity.java # src/main/java/com/ai/da/mapper/primary/entity/OrderInfo.java # src/main/java/com/ai/da/mapper/primary/entity/PaymentInfo.java # src/main/java/com/ai/da/mapper/primary/entity/Product.java # src/main/java/com/ai/da/mapper/primary/entity/RefundInfo.java # src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java
This commit is contained in:
@@ -16,7 +16,9 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
public class MQConfig {
|
||||
|
||||
public static final String GENERATE_EXCHANGE_FANOUT = "generate-exchange";
|
||||
public static final String GENERATE_QUEUE = "generate-queue-prod";
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-prod";
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-test";
|
||||
public static final String GENERATE_QUEUE = "generate-queue-dev";
|
||||
|
||||
public MQConfig() {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.ai.da.common.config;
|
||||
|
||||
import com.alipay.api.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Configuration
|
||||
//加载配置文件
|
||||
@PropertySource("classpath:alipay-sandbox.properties")
|
||||
public class AlipayClientConfig {
|
||||
|
||||
@Resource
|
||||
private Environment config;
|
||||
|
||||
@Bean
|
||||
public AlipayClient alipayClient() throws AlipayApiException {
|
||||
|
||||
AlipayConfig alipayConfig = new AlipayConfig();
|
||||
|
||||
//设置网关地址
|
||||
alipayConfig.setServerUrl(config.getProperty("alipay.gateway-url"));
|
||||
//设置应用Id
|
||||
alipayConfig.setAppId(config.getProperty("alipay.app-id"));
|
||||
//设置应用私钥
|
||||
alipayConfig.setPrivateKey(config.getProperty("alipay.merchant-private-key"));
|
||||
//设置请求格式,固定值json
|
||||
alipayConfig.setFormat(AlipayConstants.FORMAT_JSON);
|
||||
//设置字符集
|
||||
alipayConfig.setCharset(AlipayConstants.CHARSET_UTF8);
|
||||
//设置支付宝公钥
|
||||
alipayConfig.setAlipayPublicKey(config.getProperty("alipay.alipay-public-key"));
|
||||
//设置签名类型
|
||||
alipayConfig.setSignType(AlipayConstants.SIGN_TYPE_RSA2);
|
||||
//构造client
|
||||
AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);
|
||||
|
||||
return alipayClient;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.ai.da.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum AliPayTradeStateEnum {
|
||||
|
||||
/**
|
||||
* 支付成功
|
||||
*/
|
||||
SUCCESS("TRADE_SUCCESS"),
|
||||
|
||||
/**
|
||||
* 未支付
|
||||
*/
|
||||
NOTPAY("WAIT_BUYER_PAY"),
|
||||
|
||||
/**
|
||||
* 已关闭
|
||||
*/
|
||||
CLOSED("TRADE_CLOSED"),
|
||||
|
||||
/**
|
||||
* 退款成功
|
||||
*/
|
||||
REFUND_SUCCESS("REFUND_SUCCESS"),
|
||||
|
||||
/**
|
||||
* 退款失败
|
||||
*/
|
||||
REFUND_ERROR("REFUND_ERROR");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String type;
|
||||
}
|
||||
49
src/main/java/com/ai/da/common/enums/OrderStatusEnum.java
Normal file
49
src/main/java/com/ai/da/common/enums/OrderStatusEnum.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.ai.da.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum OrderStatusEnum {
|
||||
/**
|
||||
* 未支付
|
||||
*/
|
||||
NOT_PAY("未支付"),
|
||||
|
||||
|
||||
/**
|
||||
* 支付成功
|
||||
*/
|
||||
SUCCESS("支付成功"),
|
||||
|
||||
/**
|
||||
* 已关闭
|
||||
*/
|
||||
CLOSED("超时已关闭"),
|
||||
|
||||
/**
|
||||
* 已取消
|
||||
*/
|
||||
CANCEL("用户已取消"),
|
||||
|
||||
/**
|
||||
* 退款中
|
||||
*/
|
||||
REFUND_PROCESSING("退款中"),
|
||||
|
||||
/**
|
||||
* 已退款
|
||||
*/
|
||||
REFUND_SUCCESS("已退款"),
|
||||
|
||||
/**
|
||||
* 退款异常
|
||||
*/
|
||||
REFUND_ABNORMAL("退款异常");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String type;
|
||||
}
|
||||
24
src/main/java/com/ai/da/common/enums/PayTypeEnum.java
Normal file
24
src/main/java/com/ai/da/common/enums/PayTypeEnum.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.ai.da.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum PayTypeEnum {
|
||||
/**
|
||||
* 微信
|
||||
*/
|
||||
WXPAY("微信"),
|
||||
|
||||
|
||||
/**
|
||||
* 支付宝
|
||||
*/
|
||||
ALIPAY("支付宝");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String type;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
||||
"/api/third/party/addUser","/api/third/party/addTrialUser", "/api/third/party/editUser", "/api/element/initDefaultSysFile",
|
||||
"/api/third/party/addNoLoginRequiredNew","/api/third/party/deleteNoLoginRequiredNew",
|
||||
"/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl",
|
||||
"/api/python/chatStream",
|
||||
// "/api/python/chatStream",
|
||||
"/api/python/flush",
|
||||
"/api/account/healthy"
|
||||
);
|
||||
|
||||
42
src/main/java/com/ai/da/common/task/AliPayTask.java
Normal file
42
src/main/java/com/ai/da/common/task/AliPayTask.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.ai.da.common.task;
|
||||
|
||||
import com.ai.da.mapper.entity.OrderInfo;
|
||||
import com.ai.da.common.enums.PayTypeEnum;
|
||||
import com.ai.da.service.AliPayService;
|
||||
import com.ai.da.service.OrderInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AliPayTask {
|
||||
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
@Resource
|
||||
private AliPayService aliPayService;
|
||||
|
||||
/**
|
||||
* 从第0秒开始每隔30秒执行1次,查询创建超过5分钟,并且未支付的订单
|
||||
*/
|
||||
@Scheduled(cron = "0/30 * * * * ?")
|
||||
public void orderConfirm(){
|
||||
|
||||
log.info("orderConfirm 被执行......");
|
||||
|
||||
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(1, PayTypeEnum.ALIPAY.getType());
|
||||
|
||||
for (OrderInfo orderInfo : orderInfoList) {
|
||||
String orderNo = orderInfo.getOrderNo();
|
||||
log.warn("超时订单 ===> {}", orderNo);
|
||||
|
||||
//核实订单状态:调用支付宝查单接口
|
||||
aliPayService.checkOrderStatus(orderNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/main/java/com/ai/da/common/utils/OrderNoUtils.java
Normal file
46
src/main/java/com/ai/da/common/utils/OrderNoUtils.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 订单号工具类
|
||||
*
|
||||
* @author qy
|
||||
* @since 1.0
|
||||
*/
|
||||
public class OrderNoUtils {
|
||||
|
||||
/**
|
||||
* 获取订单编号
|
||||
* @return
|
||||
*/
|
||||
public static String getOrderNo() {
|
||||
return "ORDER_" + getNo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取退款单编号
|
||||
* @return
|
||||
*/
|
||||
public static String getRefundNo() {
|
||||
return "REFUND_" + getNo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编号
|
||||
* @return
|
||||
*/
|
||||
public static String getNo() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String newDate = sdf.format(new Date());
|
||||
String result = "";
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
result += random.nextInt(10);
|
||||
}
|
||||
return newDate + result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user