数据
This commit is contained in:
@@ -44,6 +44,10 @@ public class Account implements Serializable {
|
||||
* 充值彩贝总额
|
||||
*/
|
||||
private Long totalBuyCoin;
|
||||
/**
|
||||
* 第四方充值总额
|
||||
*/
|
||||
private BigDecimal totalTrdMoney;
|
||||
/**
|
||||
* 聊天收入
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ruoyi.cai.dto.app.vo.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class OrderPayStatusResp {
|
||||
|
||||
private String orderNo;
|
||||
private BigDecimal amount;
|
||||
private Integer payStatus;
|
||||
}
|
||||
@@ -14,6 +14,8 @@ public class SettingGoodsVo {
|
||||
private Integer hasWechatPay = 1;
|
||||
@Schema(description = "支付宝是否放在第一个 1-是 0-否")
|
||||
private Integer alipayFirst = 1;
|
||||
@Schema(description = "是否使用第四方支付 1-是 0-否")
|
||||
private Integer useTrdPay = 1;
|
||||
@Schema(description = "支付设置")
|
||||
private List<Goods> goods;
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ public enum SystemConfigEnum {
|
||||
OPEN_USER_CHAT_COUNT("0", "开启用户主动消息统计",SystemConfigGroupEnum.SYSTEM,new BooleanSystemConfigCheck()),
|
||||
IM_FILTER_PLUS("0", "IM拦截配置(勿动,开发配置)",SystemConfigGroupEnum.SYSTEM),
|
||||
COS_DOMAIN("http://ap-shanghai.myqcloud.com/", "文件系统域名前缀",SystemConfigGroupEnum.SYSTEM),
|
||||
PAY_LIMIT("200", "原生支付的阈值(元)",SystemConfigGroupEnum.SYSTEM, new NumberSystemConfigCheck()),
|
||||
SYSTEM_CUSTOMER_SERVICE("2,4", "系统客服",SystemConfigGroupEnum.SYSTEM),
|
||||
PRIVACY_AGREEMENT("/#/agreement/privacy", "隐私协议地址",SystemConfigGroupEnum.SYSTEM),
|
||||
USER_AGREEMENT("/#/agreement/user", "用户协议地址",SystemConfigGroupEnum.SYSTEM),
|
||||
|
||||
@@ -38,4 +38,9 @@ public class AccountTotalManager {
|
||||
log.info("开始收入统计 充值: userId={},price={},rechargeCoin={}, businessLogId={}", userId, price, rechargeCoin,consumeLogId);
|
||||
accountMapper.incsPayTotal(userId, rechargeCoin, price);
|
||||
}
|
||||
|
||||
public void incsTrdPayIncomeCoin(Long userId, BigDecimal price) {
|
||||
log.info("开始第四方支付统计 充值: userId={},price={}", userId, price);
|
||||
accountMapper.incsTrdPayTotal(userId, price);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,8 +177,11 @@ public class ConsumerManager {
|
||||
log.error("RabbitMq 发送失败, 充值分销流程流转失败!",e);
|
||||
}
|
||||
try {
|
||||
// 记录用户的消费统计
|
||||
// 记录用户的消费金额统计
|
||||
accountTotalManager.incsPayIncomeCoin(resp.getUserId(), resp.getRechargeCoin(),resp.getPrice(), resp.getConsumeLogId());
|
||||
if(PayTypeEnum.TRD == payTypeEnum){
|
||||
accountTotalManager.incsTrdPayIncomeCoin(resp.getUserId(), resp.getPrice());
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("主播消费记录失败-充值",e);
|
||||
}
|
||||
|
||||
@@ -37,5 +37,5 @@ public interface AccountMapper extends BaseMapper<Account> {
|
||||
|
||||
void incsPayTotal(@Param("userId") Long userId, @Param("rechargeCoin") Long rechargeCoin, @Param("price") BigDecimal price);
|
||||
|
||||
void incsTrdPayTotal(@Param("userId") Long userId, @Param("rechargeCoin") Long rechargeCoin, @Param("price") BigDecimal price);
|
||||
void incsTrdPayTotal(@Param("userId") Long userId, @Param("price") BigDecimal price);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.ruoyi.cai.domain.PayConfig;
|
||||
import com.ruoyi.cai.domain.RechargeOrder;
|
||||
import com.ruoyi.cai.domain.VipOrder;
|
||||
import com.ruoyi.cai.dto.ConsumeResp;
|
||||
import com.ruoyi.cai.dto.app.vo.pay.OrderPayStatusResp;
|
||||
import com.ruoyi.cai.dto.commom.consumer.RechargeConsumerResp;
|
||||
import com.ruoyi.cai.manager.AwardManager;
|
||||
import com.ruoyi.cai.manager.ConsumerManager;
|
||||
@@ -235,4 +236,36 @@ public class PayManager {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public OrderPayStatusResp getOrderPayStatus(String orderNo) {
|
||||
OrderTypeEnum orderTypeEnum = OrderNoUtil.getType(orderNo);
|
||||
if(orderTypeEnum == null){
|
||||
log.error("订单类型有误!orderNo={}",orderNo);
|
||||
return null;
|
||||
}
|
||||
OrderPayStatusResp resp = null;
|
||||
switch (orderTypeEnum) {
|
||||
case VIP_ORDER_SUB:
|
||||
VipOrder vipOrder = vipOrderService.getByOrderNo(orderNo);
|
||||
if(vipOrder != null){
|
||||
resp = new OrderPayStatusResp();
|
||||
resp.setOrderNo(vipOrder.getOrderNo());
|
||||
resp.setAmount(vipOrder.getPrice());
|
||||
resp.setPayStatus(vipOrder.getPayStatus());
|
||||
}
|
||||
break;
|
||||
case RECHARGE_ORDER_SUB:
|
||||
RechargeOrder rechargeOrder = rechargeOrderService.getByOrderNo(orderNo);
|
||||
if(rechargeOrder != null){
|
||||
resp = new OrderPayStatusResp();
|
||||
resp.setOrderNo(rechargeOrder.getOrderNo());
|
||||
resp.setAmount(rechargeOrder.getPrice());
|
||||
resp.setPayStatus(rechargeOrder.getPayStatus());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
|
||||
10
ruoyi-cai/src/main/java/com/ruoyi/cai/pay/UsePayResp.java
Normal file
10
ruoyi-cai/src/main/java/com/ruoyi/cai/pay/UsePayResp.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.ruoyi.cai.pay;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UsePayResp {
|
||||
@Schema(description = "1-原生接口 2-第四方接口")
|
||||
private Integer payType;
|
||||
}
|
||||
@@ -4,7 +4,13 @@ package com.ruoyi.cai.trdpay;
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.cai.domain.Account;
|
||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||
import com.ruoyi.cai.manager.SystemConfigManager;
|
||||
import com.ruoyi.cai.pay.PayManager;
|
||||
import com.ruoyi.cai.pay.PayOrderInfoDTO;
|
||||
import com.ruoyi.cai.pay.PayTypeEnum;
|
||||
import com.ruoyi.cai.service.AccountService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -29,6 +35,7 @@ import java.util.stream.Collectors;
|
||||
public class TrdPayManager {
|
||||
|
||||
private final String CREATE_ORDER_URL = "http://pay.jpay.one/api/pay/create_order";
|
||||
private final String QUERY_ORDER_URL = "http://pay.jpay.one/api/pay/query_order";
|
||||
|
||||
private static final String NOTIFY_ALI_URL = "/api/pay/trd/notify";
|
||||
|
||||
@@ -60,6 +67,63 @@ public class TrdPayManager {
|
||||
return createOrder(payOrderInfoDTO,trdPayProperties.getAliProductId());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
@Autowired
|
||||
private SystemConfigManager systemConfigManager;
|
||||
|
||||
public boolean useTrdPay(Long userId){
|
||||
Account account = accountService.getByUserId(userId);
|
||||
if(account == null){
|
||||
return true;
|
||||
}
|
||||
BigDecimal payLimit = systemConfigManager.getSystemConfigOfBigDecimal(SystemConfigEnum.PAY_LIMIT);
|
||||
if(payLimit == null || payLimit.compareTo(BigDecimal.ZERO) == 0){
|
||||
return false;
|
||||
}
|
||||
if(account.getTotalTrdMoney().compareTo(payLimit) >= 0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private PayManager payManager;
|
||||
|
||||
public JSONObject resetOrder(String orderNo){
|
||||
JSONObject jsonObject = queryOrder(orderNo);
|
||||
Integer status = jsonObject.getInteger("status");
|
||||
if(status != null && status.equals(2)){
|
||||
String mchOrderNo = jsonObject.getString("mchOrderNo");
|
||||
String payOrderId = jsonObject.getString("payOrderId");
|
||||
String productId = jsonObject.getString("productId");
|
||||
Map<String,String> objectJson = new HashMap<>();
|
||||
for (String key : jsonObject.keySet()) {
|
||||
objectJson.put(key, jsonObject.getString(key));
|
||||
}
|
||||
payManager.callBack(mchOrderNo,payOrderId,objectJson,productId, PayTypeEnum.TRD);
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
public JSONObject queryOrder(String orderNo){
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("mchId", trdPayProperties.getMchId());
|
||||
params.put("mchOrderNo", orderNo);
|
||||
String para = createParams(params);
|
||||
String url = QUERY_ORDER_URL + "?" + para;
|
||||
String body = restTemplate.getForEntity(url, String.class).getBody();
|
||||
JSONObject jsonObject = JSON.parseObject(body);
|
||||
if(jsonObject == null){
|
||||
log.error("第三方支付查询失败 返回数据为空");
|
||||
throw new ServiceException("调用支付失败");
|
||||
}
|
||||
if(!"SUCCESS".equals(jsonObject.getString("retCode"))){
|
||||
log.info("第三方支付查询失败 第三方支付查询失败 url={}, body={}",url, body);
|
||||
throw new ServiceException("调用支付失败");
|
||||
}
|
||||
log.info("第三方支付成功 URL={}, body={}",url, body);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
|
||||
public JSONObject createOrder(PayOrderInfoDTO payOrderInfoDTO,String productId){
|
||||
|
||||
Reference in New Issue
Block a user