Commit 9afcab2a authored by Java-刘 彧阳's avatar Java-刘 彧阳

资金方给财务同步消息的SDK

parent 5ce33830
......@@ -10,7 +10,7 @@
<packaging>jar</packaging>
<name>sdk:fs</name>
<description>信用钱包短信SDK</description>
<description>财务同步数据用SDK</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.rabbitmq:amqp-client:3.6.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.3.1" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -3,7 +3,6 @@ package cn.quantgroup.fs;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConfirmListener;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
......
package cn.quantgroup.fs;
import cn.quantgroup.fs.enums.LoanStatus;
import cn.quantgroup.fs.enums.MsgType;
import java.math.BigDecimal;
import java.util.List;
/**
* Created by ocean on 2016/7/25.
*/
public class LoanInfo {
private Long loanId; //loan_application_history.id
private Long loanManifestId; //loan_application_manifest_history.id
private Long fundingCorpId; //资金方id
private String fundingCorpName; // 资金方名称
private Long pushLoanTime; //量化派推送给资金方的时间
private Long userId; //放款的客户的id
private String userName; //客户姓名
private String userIdNo; //用户身份证
private String userPhone; //用户手机号
private String userBankCardNo; //用户银行卡号
private BigDecimal loanAmount; //放款金额
private LoanStatus loanStatus; //放款状态
private Integer contractTerm; //还款分期总数(共多少期还款)
private List<RepayPlan> repayPlans; //对应的还款计划
private MsgType msgType; //消息类型
private String source;
public Long getLoanId() {
return loanId;
}
public void setLoanId(Long loanId) {
this.loanId = loanId;
}
public Long getLoanManifestId() {
return loanManifestId;
}
public void setLoanManifestId(Long loanManifestId) {
this.loanManifestId = loanManifestId;
}
public Long getFundingCorpId() {
return fundingCorpId;
}
public void setFundingCorpId(Long fundingCorpId) {
this.fundingCorpId = fundingCorpId;
}
public String getFundingCorpName() {
return fundingCorpName;
}
public void setFundingCorpName(String fundingCorpName) {
this.fundingCorpName = fundingCorpName;
}
public Long getPushLoanTime() {
return pushLoanTime;
}
public void setPushLoanTime(Long pushLoanTime) {
this.pushLoanTime = pushLoanTime;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserIdNo() {
return userIdNo;
}
public void setUserIdNo(String userIdNo) {
this.userIdNo = userIdNo;
}
public String getUserPhone() {
return userPhone;
}
public void setUserPhone(String userPhone) {
this.userPhone = userPhone;
}
public String getUserBankCardNo() {
return userBankCardNo;
}
public void setUserBankCardNo(String userBankCardNo) {
this.userBankCardNo = userBankCardNo;
}
public BigDecimal getLoanAmount() {
return loanAmount;
}
public void setLoanAmount(BigDecimal loanAmount) {
this.loanAmount = loanAmount;
}
public LoanStatus getLoanStatus() {
return loanStatus;
}
public void setLoanStatus(LoanStatus loanStatus) {
this.loanStatus = loanStatus;
}
public Integer getContractTerm() {
return contractTerm;
}
public void setContractTerm(Integer contractTerm) {
this.contractTerm = contractTerm;
}
public List<RepayPlan> getRepayPlans() {
return repayPlans;
}
public void setRepayPlans(List<RepayPlan> repayPlans) {
this.repayPlans = repayPlans;
}
public MsgType getMsgType() {
return msgType;
}
public void setMsgType(MsgType msgType) {
this.msgType = msgType;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
}
package cn.quantgroup.fs;
import com.google.gson.Gson;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConfirmListener;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;
/**
* Created by ocean on 2016/7/25.
*/
public class LoanInfoSender {
private ChannelPool channelPool;
private String exchangeName;
private static final Gson GSON = new Gson();
private String source;
private static final AMQP.BasicProperties PROPERTIES = new AMQP.BasicProperties.Builder().
contentType("text/plain").contentEncoding("utf8").
deliveryMode(1).expiration("240000").build();
public LoanInfoSender() {
this(null);
}
public LoanInfoSender(ConfirmListener confirmListener) {
PropertyHolder propertyHolder = new PropertyHolder();
exchangeName = propertyHolder.getProperty("fs.rabbitmq.exchange-name");
channelPool = new ChannelPool(confirmListener);
boolean needBreak = false;
try {
Enumeration<NetworkInterface> enumeration = NetworkInterface.getNetworkInterfaces();
while (enumeration.hasMoreElements()) {
NetworkInterface networkInterface = enumeration.nextElement();
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
if (inetAddress.isSiteLocalAddress() && inetAddress.getHostAddress() != null && !inetAddress.getHostAddress().startsWith("127")) {
this.source = inetAddress.getHostAddress();
needBreak = true;
break;
}
}
if (needBreak) {
break;
}
}
} catch (SocketException e) {
this.source = "unknown source";
}
if (null == source) {
source = "unknown source";
}
}
/**
* �����ʽ𷽷ſ���Ϣ
* @param message
* @throws Exception
*/
public void sendLoanInfo(LoanInfo message) throws Exception {
if (message == null ) {
return;
}
message.setSource(source);
String messageStr = GSON.toJson(message);
Channel channel = null;
try {
channel = channelPool.borrowObject();
channel.basicPublish(exchangeName, "loan_info", false, false,
PROPERTIES, messageStr.getBytes("utf8"));
} finally {
if (channel != null) {
channelPool.returnObject(channel);
}
}
}
}
package cn.quantgroup.fs;
import java.math.BigDecimal;
/**
* Created by ocean on 2016/7/26.
*/
public class RepayPlan {
private Long repayMentPlanId; //对应还款计划id
private Integer termNo; //当前第几期数
private Long deadLine; //本期还款期限
private BigDecimal principal; //本期应还本金
private BigDecimal interest; //本期应还利息
private BigDecimal serviceFeePerTerm; //(量化派)服务费
private BigDecimal fundingCorpServiceFee; //(资金方)服务费
private BigDecimal requiredRepayment; //应还合计
public Long getRepayMentPlanId() {
return repayMentPlanId;
}
public void setRepayMentPlanId(Long repayMentPlanId) {
this.repayMentPlanId = repayMentPlanId;
}
public Integer getTermNo() {
return termNo;
}
public void setTermNo(Integer termNo) {
this.termNo = termNo;
}
public Long getDeadLine() {
return deadLine;
}
public void setDeadLine(Long deadLine) {
this.deadLine = deadLine;
}
public BigDecimal getPrincipal() {
return principal;
}
public void setPrincipal(BigDecimal principal) {
this.principal = principal;
}
public BigDecimal getInterest() {
return interest;
}
public void setInterest(BigDecimal interest) {
this.interest = interest;
}
public BigDecimal getServiceFeePerTerm() {
return serviceFeePerTerm;
}
public void setServiceFeePerTerm(BigDecimal serviceFeePerTerm) {
this.serviceFeePerTerm = serviceFeePerTerm;
}
public BigDecimal getFundingCorpServiceFee() {
return fundingCorpServiceFee;
}
public void setFundingCorpServiceFee(BigDecimal fundingCorpServiceFee) {
this.fundingCorpServiceFee = fundingCorpServiceFee;
}
public BigDecimal getRequiredRepayment() {
return requiredRepayment;
}
public void setRequiredRepayment(BigDecimal requiredRepayment) {
this.requiredRepayment = requiredRepayment;
}
}
package cn.quantgroup.fs.enums;
/**
* Created by ocean on 2016/7/25.
*/
public enum LoanStatus {
WAITING,SUCCESS,FAIL;
}
package cn.quantgroup.fs.enums;
/**
* Created by ocean on 2016/7/25.
*/
public enum MsgType {
REQUEST_NOTIFY,CALLBACK_NOTIFY;
}
......@@ -2,5 +2,5 @@ fs.rabbitmq.host=192.168.192.243
fs.rabbitmq.port=5672
fs.rabbitmq.user=rabbit_admin
fs.rabbitmq.password=abc1234
fs.rabbitmq.exchange-name=fs-control
fs.rabbitmq.vhost=fs
\ No newline at end of file
fs.rabbitmq.exchange-name=fs
fs.rabbitmq.vhost=financial_system
\ No newline at end of file
fs.rabbitmq.host=192.168.192.243
fs.rabbitmq.port=5672
fs.rabbitmq.host=172.168.20.144
fs.rabbitmq.port=56720
fs.rabbitmq.user=rabbit_admin
fs.rabbitmq.password=abc1234
fs.rabbitmq.exchange-name=fs-control
fs.rabbitmq.vhost=fs
\ No newline at end of file
fs.rabbitmq.exchange-name=fs
fs.rabbitmq.vhost=financial_system
\ 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