Commit 0d9cd283 authored by Administrator's avatar Administrator

创建项目

parent cc4eca1e
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
<mapping class="cn.quant.baa.pay.jpa.entity.AccountEntity"/> <mapping class="cn.quant.baa.pay.jpa.entity.AccountEntity"/>
<mapping class="cn.quant.baa.pay.jpa.entity.PayHistoryEntity"/> <mapping class="cn.quant.baa.pay.jpa.entity.PayHistoryEntity"/>
<mapping class="cn.quant.baa.pay.jpa.entity.PayGoodsDetailEntity"/> <mapping class="cn.quant.baa.pay.jpa.entity.PayGoodsDetailEntity"/>
<mapping class="cn.quant.baa.pay.jpa.entity.StatusCodeEntity"/>
<!-- Drop and re-create the database schema on startup --> <!-- Drop and re-create the database schema on startup -->
<!-- <!--
......
...@@ -4,6 +4,7 @@ import cn.quant.baa.pay.acquirer.AcquirerProperties; ...@@ -4,6 +4,7 @@ import cn.quant.baa.pay.acquirer.AcquirerProperties;
import cn.quant.baa.pay.acquirer.MerchantAcquirer; import cn.quant.baa.pay.acquirer.MerchantAcquirer;
import cn.quant.baa.pay.jpa.entity.PayHistoryEntity; import cn.quant.baa.pay.jpa.entity.PayHistoryEntity;
import cn.quant.baa.pay.model.web.*; import cn.quant.baa.pay.model.web.*;
import cn.quant.spring.util.StringUtils;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
......
...@@ -10,8 +10,6 @@ import org.springframework.context.annotation.Configuration; ...@@ -10,8 +10,6 @@ import org.springframework.context.annotation.Configuration;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static cn.quant.baa.pay.Constant.NAMESPACE_LOCAL_CACHE_TRANSACTION;
/** /**
* Created by Administrator on 2021/8/23 0023. * Created by Administrator on 2021/8/23 0023.
*/ */
...@@ -19,23 +17,42 @@ import static cn.quant.baa.pay.Constant.NAMESPACE_LOCAL_CACHE_TRANSACTION; ...@@ -19,23 +17,42 @@ import static cn.quant.baa.pay.Constant.NAMESPACE_LOCAL_CACHE_TRANSACTION;
@EnableCaching @EnableCaching
public class LocalCacheConfiguration { public class LocalCacheConfiguration {
@Value("${quant.baapay.local-cache-expire.time}") public final static String LOCAL_CACHE_ACQUIRER = "LOCAL_CACHE_ACQUIRER";
private Integer expireTime; public final static String LOCAL_CACHE_PROFILE = "LOCAL_CACHE_PROFILE";
public final static String LOCAL_CACHE_MANAGER = "localCacheManager";
@Value("${quant.baapay.acquirer.local-cache-expire.time}")
private Integer acquirerExpireTime;
@Value("${quant.baapay.acquirer.local-cache-expire.unit}")
private TimeUnit acquirerExpireUnit;
@Value("${quant.baapay.acquirer.local-cache-expire.size}")
private Integer acquirerExpireSize;
@Value("${quant.baapay.local-cache-expire.unit}") @Value("${quant.baapay.profile.local-cache-expire.time}")
private TimeUnit expireUnit; private Integer profileExpireTime;
@Value("${quant.baapay.local-cache-expire.size}") @Value("${quant.baapay.profile.local-cache-expire.unit}")
private Integer expireSize; private TimeUnit profileExpireUnit;
@Bean @Value("${quant.baapay.profile.local-cache-expire.size}")
public CacheManager profileCacheManager() { private Integer profileExpireSize;
@Bean(value = LOCAL_CACHE_MANAGER)
public CacheManager localCacheManager() {
//TODO:reload cached data //TODO:reload cached data
CaffeineCacheManager cacheManager = new CaffeineCacheManager(); CaffeineCacheManager cacheManager = new CaffeineCacheManager();
cacheManager.registerCustomCache("LOCAL_PROFILE", cacheManager.registerCustomCache(LOCAL_CACHE_ACQUIRER,
Caffeine.newBuilder()
.expireAfterWrite(acquirerExpireTime, acquirerExpireUnit)
.maximumSize(acquirerExpireSize == null ? 500 : acquirerExpireSize)
.build());
cacheManager.registerCustomCache(LOCAL_CACHE_PROFILE,
Caffeine.newBuilder() Caffeine.newBuilder()
.expireAfterWrite(expireTime, expireUnit) .expireAfterWrite(profileExpireTime, profileExpireUnit)
.maximumSize(expireSize == null ? 500 : expireSize) .maximumSize(profileExpireSize == null ? 500 : profileExpireSize)
.build()); .build());
return cacheManager; return cacheManager;
} }
......
...@@ -268,8 +268,8 @@ public class AccountEntity extends DescribablePartitionEntity implements Seriali ...@@ -268,8 +268,8 @@ public class AccountEntity extends DescribablePartitionEntity implements Seriali
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return ids.persistenceKey(); return ids.getPersistentKey();
} }
@Override @Override
......
...@@ -40,7 +40,7 @@ public class AccountIds extends EntityPrimaryIds implements Serializable { ...@@ -40,7 +40,7 @@ public class AccountIds extends EntityPrimaryIds implements Serializable {
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return StringUtils.toDelimitedString(CLASS_NAME, institutionId, accountRefNo); return StringUtils.toDelimitedString(CLASS_NAME, institutionId, accountRefNo);
} }
......
...@@ -88,7 +88,7 @@ public class CustomerEntity extends DescribablePartitionEntity implements Serial ...@@ -88,7 +88,7 @@ public class CustomerEntity extends DescribablePartitionEntity implements Serial
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return StringUtils.toDelimitedString(CLASS_NAME, customerId); return StringUtils.toDelimitedString(CLASS_NAME, customerId);
} }
......
...@@ -51,8 +51,8 @@ public class DictionaryEntity extends OptimisticEntity implements Serializable { ...@@ -51,8 +51,8 @@ public class DictionaryEntity extends OptimisticEntity implements Serializable {
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return ids.persistenceKey(); return ids.getPersistentKey();
} }
@Override @Override
......
...@@ -44,7 +44,7 @@ public class DictionaryIds extends EntityPrimaryIds implements Serializable { ...@@ -44,7 +44,7 @@ public class DictionaryIds extends EntityPrimaryIds implements Serializable {
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return StringUtils.toDelimitedString(CLASS_NAME, type, code); return StringUtils.toDelimitedString(CLASS_NAME, type, code);
} }
......
...@@ -75,7 +75,7 @@ public class MchChannelEntity extends DescriptionEntity implements Serializable ...@@ -75,7 +75,7 @@ public class MchChannelEntity extends DescriptionEntity implements Serializable
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return StringUtils.toDelimitedString(CLASS_NAME, id); return StringUtils.toDelimitedString(CLASS_NAME, id);
} }
......
...@@ -161,8 +161,8 @@ public class PayAccountEntity extends OptimisticEntity implements Serializable { ...@@ -161,8 +161,8 @@ public class PayAccountEntity extends OptimisticEntity implements Serializable {
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return ids.persistenceKey(); return ids.getPersistentKey();
} }
@Override @Override
......
...@@ -41,7 +41,7 @@ public class PayAccountIds extends EntityPrimaryIds implements Serializable { ...@@ -41,7 +41,7 @@ public class PayAccountIds extends EntityPrimaryIds implements Serializable {
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return StringUtils.toDelimitedString(CLASS_NAME, payChanCode, payAcctId); return StringUtils.toDelimitedString(CLASS_NAME, payChanCode, payAcctId);
} }
......
...@@ -115,7 +115,7 @@ public class PayAppEntity extends OptimisticEntity implements Serializable { ...@@ -115,7 +115,7 @@ public class PayAppEntity extends OptimisticEntity implements Serializable {
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return StringUtils.toDelimitedString(CLASS_NAME, payAppId); return StringUtils.toDelimitedString(CLASS_NAME, payAppId);
} }
......
...@@ -106,8 +106,8 @@ public class PayFeatureEntity extends DescriptionEntity implements Serializable ...@@ -106,8 +106,8 @@ public class PayFeatureEntity extends DescriptionEntity implements Serializable
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return ids.persistenceKey(); return ids.getPersistentKey();
} }
@Override @Override
......
...@@ -46,7 +46,7 @@ public class PayFeatureIds extends EntityPrimaryIds implements Serializable { ...@@ -46,7 +46,7 @@ public class PayFeatureIds extends EntityPrimaryIds implements Serializable {
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return StringUtils.toDelimitedString(CLASS_NAME, payChanCode, accessCode); return StringUtils.toDelimitedString(CLASS_NAME, payChanCode, accessCode);
} }
......
...@@ -122,7 +122,7 @@ public class PayGoodsDetailEntity extends PartitionEntity implements Serializabl ...@@ -122,7 +122,7 @@ public class PayGoodsDetailEntity extends PartitionEntity implements Serializabl
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return StringUtils.toDelimitedString(CLASS_NAME, goodsId); return StringUtils.toDelimitedString(CLASS_NAME, goodsId);
} }
......
...@@ -404,8 +404,8 @@ public class PayHistoryEntity extends DescribablePartitionEntity implements Seri ...@@ -404,8 +404,8 @@ public class PayHistoryEntity extends DescribablePartitionEntity implements Seri
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return ids.persistenceKey(); return ids.getPersistentKey();
} }
@Override @Override
......
...@@ -50,7 +50,7 @@ public class PayHistoryIds extends EntityPrimaryIds implements Serializable { ...@@ -50,7 +50,7 @@ public class PayHistoryIds extends EntityPrimaryIds implements Serializable {
} }
@Override @Override
public String persistenceKey() { public String getPersistentKey() {
return StringUtils.toDelimitedString(CLASS_NAME, institutionId, productId, externalOrderNo); return StringUtils.toDelimitedString(CLASS_NAME, institutionId, productId, externalOrderNo);
} }
......
package cn.quant.baa.pay.jpa.entity;
import cn.quant.spring.data.jpa.entity.DescriptionEntity;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.Objects;
/**
* Created by Administrator on 2021/9/13 0013.
*/
@Entity
@Table(name = "status_code")
public class StatusCodeEntity extends DescriptionEntity{
@EmbeddedId
private StatusCodeIds ids;
@Column(name = "PRIORITY", nullable = false)
private Integer priority;
@Column(name = "CODE_TYPE", nullable = false, length = 4)
private String codeType;
@Column(name = "POSTING_CODE", nullable = false, length = 4)
private String postingCode;
@Type(type = "yes_no")
@Column(name = "SEND_NOTICE_FLAG", nullable = false, length = 1)
private Boolean sendNoticeFlag;
@Column(name = "REGR_CODE", nullable = true, length = 4)
private String regrCode;
@Column(name = "FAILED_CODE", nullable = false, length = 4)
private String failedCode;
@Column(name = "NEXT_CODE", nullable = true, length = 4)
private String nextCode;
@Column(name = "MESSAGE_CODE", nullable = true, length = 4)
private String messageCode;
public StatusCodeIds getIds() {
return ids;
}
public void setIds(StatusCodeIds ids) {
this.ids = ids;
}
public Integer getPriority() {
return priority;
}
public void setPriority(Integer priority) {
this.priority = priority;
}
public String getCodeType() {
return codeType;
}
public void setCodeType(String codeType) {
this.codeType = codeType;
}
public String getPostingCode() {
return postingCode;
}
public void setPostingCode(String postingCode) {
this.postingCode = postingCode;
}
public Boolean getSendNoticeFlag() {
return sendNoticeFlag;
}
public void setSendNoticeFlag(Boolean sendNoticeFlag) {
this.sendNoticeFlag = sendNoticeFlag;
}
public String getRegrCode() {
return regrCode;
}
public void setRegrCode(String regrCode) {
this.regrCode = regrCode;
}
public String getFailedCode() {
return failedCode;
}
public void setFailedCode(String failedCode) {
this.failedCode = failedCode;
}
public String getNextCode() {
return nextCode;
}
public void setNextCode(String nextCode) {
this.nextCode = nextCode;
}
public String getMessageCode() {
return messageCode;
}
public void setMessageCode(String messageCode) {
this.messageCode = messageCode;
}
@Override
public String getPersistentKey() {
return ids.getPersistentKey();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
StatusCodeEntity that = (StatusCodeEntity) o;
return Objects.equals(ids, that.ids);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("StatusCodeEntity{");
sb.append("ids=").append(ids);
sb.append(", priority=").append(priority);
sb.append(", codeType='").append(codeType).append('\'');
sb.append(", postingCode='").append(postingCode).append('\'');
sb.append(", sendNoticeFlag=").append(sendNoticeFlag);
sb.append(", regrCode='").append(regrCode).append('\'');
sb.append(", failedCode='").append(failedCode).append('\'');
sb.append(", nextCode='").append(nextCode).append('\'');
sb.append(", messageCode='").append(messageCode).append('\'');
sb.append(',').append(super.toString());
sb.append('}');
return sb.toString();
}
}
package cn.quant.baa.pay.jpa.entity;
import cn.quant.spring.data.jpa.entity.EntityPrimaryIds;
import cn.quant.spring.util.StringUtils;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.io.Serializable;
import java.util.Objects;
/**
* Created by Administrator on 2021/9/13 0013.
*/
@Embeddable
public class StatusCodeIds extends EntityPrimaryIds implements Serializable {
public final static String CLASS_NAME = StatusCodeEntity.class.getSimpleName();
private static final long serialVersionUID = 6497603433019425612L;
@Column(name = "INSTITUTION_ID", nullable = false, updatable = false, length = 4)
private String institutionId;
@Column(name = "ENTITY", nullable = false, updatable = false, length = 4)
private String entity;
@Column(name = "CODE", nullable = false, updatable = false, length = 4)
private String code;
public String getInstitutionId() {
return institutionId;
}
public void setInstitutionId(String institutionId) {
this.institutionId = institutionId;
}
public String getEntity() {
return entity;
}
public void setEntity(String entity) {
this.entity = entity;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Override
public String getPersistentKey() {
return StringUtils.toDelimitedString(CLASS_NAME, institutionId, entity, code);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
StatusCodeIds that = (StatusCodeIds) o;
return Objects.equals(institutionId, that.institutionId) &&
Objects.equals(entity, that.entity) &&
Objects.equals(code, that.code);
}
@Override
public int hashCode() {
return Objects.hash(CLASS_NAME, institutionId, entity, code);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("StatusCodeIds{");
sb.append("institutionId='").append(institutionId).append('\'');
sb.append(", entity='").append(entity).append('\'');
sb.append(", code='").append(code).append('\'');
sb.append(',').append(super.toString());
sb.append('}');
return sb.toString();
}
}
package cn.quant.baa.pay.jpa.repository;
import cn.quant.baa.pay.jpa.entity.AccountEntity;
import cn.quant.baa.pay.jpa.entity.AccountIds;
import cn.quant.baa.pay.jpa.entity.StatusCodeEntity;
import cn.quant.baa.pay.jpa.entity.StatusCodeIds;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
/**
* Created by Administrator on 2021/8/22 0022.
*/
@Repository
public interface StatusCodeRepository extends JpaRepository<StatusCodeEntity, StatusCodeIds> {
}
package cn.quant.baa.pay.model;
import java.io.Serializable;
/**
* Created by Administrator on 2021/9/13 0013.
*/
public class StatusCodeDTO implements Serializable{
private static final long serialVersionUID = 952357481570545998L;
private String institutionId;
private String entity;
private String code;
private Integer priority;
private String codeType;
private String postingCode;
private Boolean sendNoticeFlag;
private String regrCode;
private String failedCode;
private String nextCode;
private String messageCode;
public String getInstitutionId() {
return institutionId;
}
public void setInstitutionId(String institutionId) {
this.institutionId = institutionId;
}
public String getEntity() {
return entity;
}
public void setEntity(String entity) {
this.entity = entity;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getPriority() {
return priority;
}
public void setPriority(Integer priority) {
this.priority = priority;
}
public String getCodeType() {
return codeType;
}
public void setCodeType(String codeType) {
this.codeType = codeType;
}
public String getPostingCode() {
return postingCode;
}
public void setPostingCode(String postingCode) {
this.postingCode = postingCode;
}
public Boolean getSendNoticeFlag() {
return sendNoticeFlag;
}
public void setSendNoticeFlag(Boolean sendNoticeFlag) {
this.sendNoticeFlag = sendNoticeFlag;
}
public String getRegrCode() {
return regrCode;
}
public void setRegrCode(String regrCode) {
this.regrCode = regrCode;
}
public String getFailedCode() {
return failedCode;
}
public void setFailedCode(String failedCode) {
this.failedCode = failedCode;
}
public String getNextCode() {
return nextCode;
}
public void setNextCode(String nextCode) {
this.nextCode = nextCode;
}
public String getMessageCode() {
return messageCode;
}
public void setMessageCode(String messageCode) {
this.messageCode = messageCode;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("StatusCodeDTO{");
sb.append("institutionId='").append(institutionId).append('\'');
sb.append(", entity='").append(entity).append('\'');
sb.append(", code='").append(code).append('\'');
sb.append(", priority=").append(priority);
sb.append(", codeType='").append(codeType).append('\'');
sb.append(", postingCode='").append(postingCode).append('\'');
sb.append(", sendNoticeFlag=").append(sendNoticeFlag);
sb.append(", regrCode='").append(regrCode).append('\'');
sb.append(", failedCode='").append(failedCode).append('\'');
sb.append(", nextCode='").append(nextCode).append('\'');
sb.append(", messageCode='").append(messageCode).append('\'');
sb.append('}');
return sb.toString();
}
}
package cn.quant.baa.pay.model.web; package cn.quant.baa.pay.model.web;
import cn.quant.baa.pay.model.BusinessRequest;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.io.Serializable; import java.io.Serializable;
...@@ -11,7 +13,7 @@ import java.io.Serializable; ...@@ -11,7 +13,7 @@ import java.io.Serializable;
* Time: 上午11:05 * Time: 上午11:05
* Description: No Description * Description: No Description
*/ */
public class CheckRefundRequestData implements Serializable { public class CheckRefundRequestData extends BusinessRequest implements Serializable {
private static final long serialVersionUID = 4652001398076281697L; private static final long serialVersionUID = 4652001398076281697L;
......
package cn.quant.baa.pay.model.web; package cn.quant.baa.pay.model.web;
import cn.quant.spring.data.jpa.repository.PersistentKey;
import cn.quant.spring.util.StringUtils;
import java.io.Serializable; import java.io.Serializable;
/** /**
* Created by Administrator on 2021/8/23 0023. * Created by Administrator on 2021/8/23 0023.
*/ */
public class MerchantChannelRequestData implements Serializable { public class MerchantChannelRequestData implements PersistentKey, Serializable {
private static final long serialVersionUID = 5193795607930304626L; private static final long serialVersionUID = 5193795607930304626L;
private String chanId; private String chanId;
...@@ -48,8 +51,8 @@ public class MerchantChannelRequestData implements Serializable { ...@@ -48,8 +51,8 @@ public class MerchantChannelRequestData implements Serializable {
this.access = access; this.access = access;
} }
public String persistenceKey() { public String getPersistentKey() {
return mchId + "$" + (channel == null || channel.trim().length() == 0 ? "*" : channel); return StringUtils.toDelimitedString(mchId, channel, access);
} }
@Override @Override
......
package cn.quant.baa.pay.service; package cn.quant.baa.pay.service;
import cn.quant.baa.pay.acquirer.AcquirerConfiguration;
import cn.quant.baa.pay.acquirer.AcquirerProperties; import cn.quant.baa.pay.acquirer.AcquirerProperties;
import cn.quant.baa.pay.config.LocalCacheConfiguration;
import cn.quant.baa.pay.model.web.MerchantAcquirerProperties; import cn.quant.baa.pay.model.web.MerchantAcquirerProperties;
import cn.quant.baa.pay.model.web.MerchantChannelResponseData;
import cn.quant.baa.pay.model.web.MerchantChannelRequestData; import cn.quant.baa.pay.model.web.MerchantChannelRequestData;
import cn.quant.baa.pay.acquirer.AcquirerConfiguration; import cn.quant.baa.pay.model.web.MerchantChannelResponseData;
import cn.quant.baa.pay.model.ModelBuilder;
import cn.quant.spring.util.StringUtils; import cn.quant.spring.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -18,17 +19,20 @@ import java.util.Map; ...@@ -18,17 +19,20 @@ import java.util.Map;
* Created by Administrator on 2021/8/23 0023. * Created by Administrator on 2021/8/23 0023.
*/ */
@Service @Service
public class MerchantService { public class MerchantStorageService {
@Autowired @Autowired
private AcquirerConfiguration acquirerConfiguration; private AcquirerConfiguration acquirerConfiguration;
@Autowired @Autowired
private ModelBuilder modelBuilder; private ModelBuilder modelBuilder;
@Autowired
private CacheManager cacheManager;
// @Cacheable(cacheManager = "profileCacheManager" @Cacheable(cacheManager = LocalCacheConfiguration.LOCAL_CACHE_MANAGER
// , cacheNames = "LOCAL_PROFILE" , cacheNames = LocalCacheConfiguration.LOCAL_CACHE_ACQUIRER
// , key = "#requestData.persistenceKey()") , key = "'MerchantChannel$'+#requestData.getPersistentKey()")
public Map<String, MerchantChannelResponseData> getChannels(MerchantChannelRequestData requestData) { public Map<String, MerchantChannelResponseData> getChannels(MerchantChannelRequestData requestData) {
String mchId = requestData.getMchId(); String mchId = requestData.getMchId();
String channel = requestData.getChannel(); String channel = requestData.getChannel();
...@@ -44,13 +48,9 @@ public class MerchantService { ...@@ -44,13 +48,9 @@ public class MerchantService {
return response; return response;
} }
public MerchantAcquirerProperties getChannel(MerchantChannelRequestData requestData) { @Cacheable(cacheManager = LocalCacheConfiguration.LOCAL_CACHE_MANAGER
return getChannel(Long.parseLong(requestData.getChanId())); , cacheNames = LocalCacheConfiguration.LOCAL_CACHE_ACQUIRER
} , key = "'MerchantChannel$'+#id")
@Cacheable(cacheManager = "profileCacheManager"
, cacheNames = "LOCAL_PROFILE"
, key = "#id")
public MerchantAcquirerProperties getChannel(Long id) { public MerchantAcquirerProperties getChannel(Long id) {
AcquirerProperties profile = acquirerConfiguration.get(id); AcquirerProperties profile = acquirerConfiguration.get(id);
return modelBuilder.toModel(profile); return modelBuilder.toModel(profile);
......
package cn.quant.baa.pay.model; package cn.quant.baa.pay.service;
import cn.quant.baa.pay.acquirer.AcquirerProperties; import cn.quant.baa.pay.acquirer.AcquirerProperties;
import cn.quant.baa.pay.config.DictionaryViewer; import cn.quant.baa.pay.config.DictionaryViewer;
import cn.quant.baa.pay.dict.DictType; import cn.quant.baa.pay.dict.DictType;
import cn.quant.baa.pay.model.DictionaryItem;
import cn.quant.baa.pay.model.web.MerchantAcquirerProperties; import cn.quant.baa.pay.model.web.MerchantAcquirerProperties;
import cn.quant.baa.pay.model.web.MerchantChannelResponseData; import cn.quant.baa.pay.model.web.MerchantChannelResponseData;
import cn.quant.spring.NotSupportedException; import cn.quant.spring.NotSupportedException;
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
<include>**/*.xml</include> <include>**/*.xml</include>
<include>**/*.properties</include> <include>**/*.properties</include>
<include>**/*.txt</include> <include>**/*.txt</include>
<include>**/*.html</include>
</includes> </includes>
</resource> </resource>
<resource> <resource>
......
...@@ -7,7 +7,7 @@ import cn.quant.baa.pay.annotation.BusinessMapping; ...@@ -7,7 +7,7 @@ import cn.quant.baa.pay.annotation.BusinessMapping;
import cn.quant.baa.pay.context.TransactionSession; import cn.quant.baa.pay.context.TransactionSession;
import cn.quant.baa.pay.util.AssertUtils; import cn.quant.baa.pay.util.AssertUtils;
import cn.quant.baa.pay.model.BusinessRequest; import cn.quant.baa.pay.model.BusinessRequest;
import cn.quant.baa.pay.service.MerchantService; import cn.quant.baa.pay.service.MerchantStorageService;
import cn.quant.spring.http.HttpResponseData; import cn.quant.spring.http.HttpResponseData;
import cn.quant.spring.rest.AbstractController; import cn.quant.spring.rest.AbstractController;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -27,7 +27,7 @@ import static cn.quant.baa.pay.dict.MessageEnum.*; ...@@ -27,7 +27,7 @@ import static cn.quant.baa.pay.dict.MessageEnum.*;
public class MerchantController extends AbstractController { public class MerchantController extends AbstractController {
@Autowired @Autowired
private MerchantService merchantService; private MerchantStorageService merchantStorageService;
@Autowired @Autowired
private CacheManager cacheManager; private CacheManager cacheManager;
...@@ -45,8 +45,8 @@ public class MerchantController extends AbstractController { ...@@ -45,8 +45,8 @@ public class MerchantController extends AbstractController {
} }
Map<String, MerchantChannelResponseData> channels = merchantService.getChannels(data); Map<String, MerchantChannelResponseData> channels = merchantStorageService.getChannels(data);
ResponseEntity<HttpResponseData> entity = succeed(session.getRequestId(), channels); ResponseEntity<HttpResponseData> entity = succeed(requestId, channels);
return entity; return entity;
} }
...@@ -62,9 +62,8 @@ public class MerchantController extends AbstractController { ...@@ -62,9 +62,8 @@ public class MerchantController extends AbstractController {
AssertUtils.throwMessage(EMPTY_REQ_DATA); AssertUtils.throwMessage(EMPTY_REQ_DATA);
} }
MerchantAcquirerProperties channel = merchantStorageService.getChannel(Long.parseLong(data.getChanId()));
MerchantAcquirerProperties channel = merchantService.getChannel(data); ResponseEntity<HttpResponseData> entity = succeed(requestId, channel);
ResponseEntity<HttpResponseData> entity = succeed(session.getRequestId(), channel);
return entity; return entity;
} }
} }
package cn.quant.baa.pay.rest; package cn.quant.baa.pay.rest;
import cn.quant.baa.pay.annotation.BusinessMapping; import cn.quant.baa.pay.annotation.BusinessMapping;
import cn.quant.baa.pay.component.Sequencer;
import cn.quant.baa.pay.context.TransactionSession; import cn.quant.baa.pay.context.TransactionSession;
import cn.quant.baa.pay.model.BusinessRequest; import cn.quant.baa.pay.model.BusinessRequest;
import cn.quant.baa.pay.model.web.CheckPayRequestData; import cn.quant.baa.pay.model.web.CheckPayRequestData;
import cn.quant.baa.pay.model.web.CheckRefundRequestData; import cn.quant.baa.pay.model.web.CheckRefundRequestData;
import cn.quant.baa.pay.model.web.PayRequestData; import cn.quant.baa.pay.model.web.PayRequestData;
import cn.quant.baa.pay.service.TransactionService; import cn.quant.baa.pay.service.TransactionService;
import cn.quant.spring.context.ServerApplicationContext;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
...@@ -41,6 +43,12 @@ public class PayTestController { ...@@ -41,6 +43,12 @@ public class PayTestController {
@Autowired @Autowired
private TransactionService transactionService; private TransactionService transactionService;
@Autowired
private ServerApplicationContext serverApplicationContext;
@Autowired
private Sequencer sequencer;
@GetMapping("") @GetMapping("")
public String getPay(Model model) { public String getPay(Model model) {
return "pay/index"; return "pay/index";
...@@ -63,6 +71,7 @@ public class PayTestController { ...@@ -63,6 +71,7 @@ public class PayTestController {
@RequestMapping("checkRefund") @RequestMapping("checkRefund")
public String checkRefund(CheckRefundRequestData data, Model model, HttpServletRequest servletRequest) { public String checkRefund(CheckRefundRequestData data, Model model, HttpServletRequest servletRequest) {
String res = ""; String res = "";
if (servletRequest.getMethod().equals("POST")) { if (servletRequest.getMethod().equals("POST")) {
res = transactionService.checkRefund(data).toString(); res = transactionService.checkRefund(data).toString();
......
package cn.quant.baa.pay.service; package cn.quant.baa.pay.service;
import cn.quant.baa.pay.acquirer.Acquirer;
import cn.quant.baa.pay.acquirer.AcquirerConfiguration; import cn.quant.baa.pay.acquirer.AcquirerConfiguration;
import cn.quant.baa.pay.acquirer.AcquirerProperties;
import cn.quant.baa.pay.acquirer.MerchantAcquirer; import cn.quant.baa.pay.acquirer.MerchantAcquirer;
import cn.quant.baa.pay.context.TransactionSession; import cn.quant.baa.pay.context.TransactionSession;
import cn.quant.baa.pay.jpa.entity.*; import cn.quant.baa.pay.jpa.entity.*;
import cn.quant.baa.pay.model.web.*; import cn.quant.baa.pay.model.web.*;
import cn.quant.baa.pay.util.AssertUtils; import cn.quant.baa.pay.util.AssertUtils;
import cn.quant.baa.pay.acquirer.AcquirerProperties;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -44,9 +43,8 @@ public class TransactionService extends BusinessService { ...@@ -44,9 +43,8 @@ public class TransactionService extends BusinessService {
} }
@Transactional @Transactional
public TransactionSession payHistory(PayRequestData data){ public TransactionSession payHistory(PayRequestData data) {
validate(data); validate(data);
......
...@@ -30,6 +30,10 @@ spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect ...@@ -30,6 +30,10 @@ spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.database=MYSQL spring.jpa.database=MYSQL
quant.baapay.local-cache-expire.time=6000 quant.baapay.acquirer.local-cache-expire.time=6000
quant.baapay.local-cache-expire.unit=SECONDS quant.baapay.acquirer.local-cache-expire.unit=SECONDS
quant.baapay.local-cache-expire.size=1000 quant.baapay.acquirer.local-cache-expire.size=1000
\ No newline at end of file
quant.baapay.profile.local-cache-expire.time=6000
quant.baapay.profile.local-cache-expire.unit=SECONDS
quant.baapay.profile.local-cache-expire.size=1000
\ No newline at end of file
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