init
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.cai.pay;
|
||||
|
||||
import com.alipay.api.domain.AppItemDataDiffVO;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ijpay.alipay.AliPayApiConfig;
|
||||
import com.ijpay.alipay.AliPayApiConfigKit;
|
||||
@@ -12,14 +11,14 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class PayConfigManager {
|
||||
private static final Map<Long,PayConfig> PAY_CONFIGS_MAP = new HashMap<>();
|
||||
private static final Map<Long,PayConfig> PAY_CONFIGS_MAP = new ConcurrentHashMap<>();
|
||||
@Autowired
|
||||
private PayConfigService payConfigService;
|
||||
|
||||
@@ -31,6 +30,10 @@ public class PayConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<PayConfig> getAllPayConfig(){
|
||||
return PAY_CONFIGS_MAP.values();
|
||||
}
|
||||
|
||||
// 1支付宝2微信
|
||||
public void addPayConfig(PayConfig payConfig) {
|
||||
PAY_CONFIGS_MAP.put(payConfig.getId(),payConfig);
|
||||
@@ -96,11 +99,22 @@ public class PayConfigManager {
|
||||
}
|
||||
|
||||
public PayConfig getAliConfigByAppId(String appId) {
|
||||
this.getWxConfigByMchId(appId);
|
||||
Collection<PayConfig> values = PAY_CONFIGS_MAP.values();
|
||||
for (PayConfig value : values) {
|
||||
if(value.getAppid() != null && value.getAppid().equals(appId)){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PayConfig getWxConfigByMchId(String mchId) {
|
||||
Collection<PayConfig> values = PAY_CONFIGS_MAP.values();
|
||||
for (PayConfig value : values) {
|
||||
if(value.getWxMcid() != null && value.getWxMcid().equals(mchId)){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi.cai.pay;
|
||||
import com.ruoyi.cai.dto.ConsumeResp;
|
||||
import com.ruoyi.cai.manager.AwardManager;
|
||||
import com.ruoyi.cai.manager.ConsumerManager;
|
||||
import com.ruoyi.cai.service.PayTotalService;
|
||||
import com.ruoyi.cai.service.VipOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,6 +21,8 @@ public class PayManager {
|
||||
private ConsumerManager consumerManager;
|
||||
@Autowired
|
||||
private AwardManager awardManager;
|
||||
@Autowired
|
||||
private PayTotalService payTotalService;
|
||||
|
||||
public void callBack(String orderNo){
|
||||
callBack(orderNo,null,null,null,null);
|
||||
@@ -35,14 +38,18 @@ public class PayManager {
|
||||
case VIP_ORDER_SUB:
|
||||
ConsumeResp vipResp = vipOrderService.orderSuccess(orderNo,params,appId,payTypeEnum);
|
||||
if(vipResp.isSuccess()){
|
||||
// 记录数据 TODO
|
||||
if(appId != null){
|
||||
payTotalService.incsPrice(payTypeEnum,appId,vipResp.getPrice());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RECHARGE_ORDER_SUB:
|
||||
ConsumeResp resp = consumerManager.rechargeOrderSuccess(orderNo,params,appId,payTypeEnum);
|
||||
if(resp.isSuccess()){
|
||||
awardManager.giveFastPayAsync(resp.getUserId(), resp.getTraceId());
|
||||
// 记录数据 TODO
|
||||
if(appId != null){
|
||||
payTotalService.incsPrice(payTypeEnum,appId,resp.getPrice());
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user