Commit e16407d2 authored by Java-刘 彧阳's avatar Java-刘 彧阳

init

parent 23ecf8ce
......@@ -6,6 +6,11 @@
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
......
package cn.gq.financial.app;
import cn.gq.financial.model.db.RepayDetailFinancial;
import cn.gq.financial.service.FinancialRepayDetailService;
import cn.gq.financial.utils.Constants;
import org.slf4j.Logger;
......@@ -17,13 +16,13 @@ public class RepayFinancialAPP {
private static final Logger LOGGER = LoggerFactory.getLogger(RepayFinancialAPP.class);
static final String CONFIG_LOCAL="applicationContext.xml";
static Integer month = 9;
static String SRC_BILL_PATH ="E:\\WX_BILL_BAITIAO";
static Integer month = 8;
static String SRC_BILL_PATH ="E:\\易宝白条-9月";
// static String SRC_BILL_PATH ="E:\\WX_BILL\\GBK";
static String payAprroach="微信";
static String payAprroach="易宝";
static String payAccount = "微信-白条账户";
static String payAccount = "易宝-白条账户";
private static ClassPathXmlApplicationContext context = null;
......
package cn.gq.financial.app.handler;
import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import cn.gq.financial.db.local.dao.FinancialRepayDetailMapper;
import cn.gq.financial.model.bill.YeepayBill;
import cn.gq.financial.model.db.RepayDetailFinancial;
import cn.gq.financial.service.FinancialRepayDetailService;
import cn.gq.financial.utils.Constants;
......@@ -22,7 +24,7 @@ import cn.gq.financial.utils.BillParsers;
@Component
public class RepayHandler {
static int ITEM_SIZE = 5000;
static int ITEM_SIZE = 10000;
@Autowired
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
......@@ -40,7 +42,13 @@ public class RepayHandler {
private CountDownLatch count = null;
public void repayBillDetailHandler(final String srcPaht,final Class<? extends Bill> clazz, String payAccount, Integer month) throws Exception {
List<Bill> bills = getBillsFromFile(srcPaht,clazz,payAccount,month);
// List<Bill> bills = getBillsFromFile(srcPaht,clazz,payAccount,month);
List<Bill> bills = new ArrayList<>();
YeepayBill bill = new YeepayBill();
bill.setOrderId("1469787374013");
bill.setIncome(new BigDecimal("830.04"));
bill.setBizType(YeepayBill.REPAY);
bills.add(bill);
if(!CollectionUtils.isEmpty(bills)){
asyncHandlerRepayData(clazz, bills);
count.await(); //等待所有线程结束
......@@ -75,7 +83,7 @@ public class RepayHandler {
}
}
private static List<Bill> getBillsFromFile(String srcPath,Class<? extends Bill> clazz, String payAccount, Integer month) throws Exception {
public static List<Bill> getBillsFromFile(String srcPath,Class<? extends Bill> clazz, String payAccount, Integer month) throws Exception {
File [] billFiles = getFiles(srcPath);
List<Bill> bills = new ArrayList<Bill>();
for (int i = 0; i < billFiles.length; i++) {
......
......@@ -40,8 +40,6 @@ public class RepayHandlerAsync implements Runnable {
private FinancialRepayDetailService financialRepayDetailService;
static BigDecimal MINUS_ONE = new BigDecimal("-1");
public RepayHandlerAsync(List<Bill> bills, Class<? extends Bill> clazz, PaycenterService paycenterService,BizRepayDetailService bizRepayDetailService,
CountDownLatch count, FinancialRepayDetailMapper repayDetailMapper,FinancialRepayDetailService financialRepayDetailService) {
super();
......@@ -105,15 +103,15 @@ public class RepayHandlerAsync implements Runnable {
detail.setPayAccount(bill.getPayAccount());
detail.setMonth(bill.getMonth());
if(1== detail.getActivityRelief().compareTo(BigDecimal.ZERO)){
detail.setActivityRelief(detail.getActivityRelief().multiply(MINUS_ONE));
detail.setActivityRelief(detail.getActivityRelief().multiply(Constants.MINUS_ONE));
}
if(1 == detail.getCollectionRelief().compareTo(BigDecimal.ZERO)){
detail.setCollectionRelief(detail.getCollectionRelief().multiply(MINUS_ONE));
detail.setCollectionRelief(detail.getCollectionRelief().multiply(Constants.MINUS_ONE));
}
total = total.add(detail.getCurrentRepayment());
}
list.get(0).setPayApproachPoundage(bill.getPoundage());
BigDecimal subtract = total.subtract(bill.getIncome());
BigDecimal subtract = bill.getIncome().subtract(total);
if(1 == subtract.compareTo(BigDecimal.ZERO)){
//多收了放逾期
list.get(0).setOverdueFee(list.get(0).getOverdueFee().add(subtract));
......@@ -121,9 +119,10 @@ public class RepayHandlerAsync implements Runnable {
}
if(-1 == subtract.compareTo(BigDecimal.ZERO)){
//少收放红包减免
list.get(0).setActivityRelief(list.get(0).getActivityRelief().add(subtract));
list.get(0).setCollectionRelief(list.get(0).getCollectionRelief().add(subtract));
list.get(0).setRemark("少收:"+subtract);
}
list.get(0).setCurrentRepayment(list.get(0).getCurrentRepayment().add(subtract));
}else{
LOGGER.info("还款明细丢失,orderId-->{}",orderId);
}
......
package cn.gq.financial.checkout;
import cn.gq.financial.app.handler.RepayHandler;
import cn.gq.financial.model.bill.Bill;
import cn.gq.financial.model.bill.UMPayBill;
import cn.gq.financial.model.bill.WXBill;
import cn.gq.financial.model.bill.YeepayBill;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Created by ocean on 2016/9/26.
*/
public class TotalAmountCheck {
static String [] lost = {
"1470995273554",
"1470995273550",
"1470995273567"
};
static Set<String> lostSet = new HashSet<>();
static String payAprroach="微信";
static String payAccount = "微信-白条账户";
static Integer month = 9;
static String SRC_BILL_PATH ="E:\\WX_BILL_BAITIAO";
static Class<? extends Bill> clazz = null;
static {
for (String lostId :lost){
lostSet.add(lostId);
}
switch (payAprroach) {
case "微信":
clazz = WXBill.class;
break;
case "易宝":
clazz = YeepayBill.class;
break;
case "联动":
clazz = UMPayBill.class;
break;
}
}
public static void main(String args[]) throws Exception {
List<Bill> bills = RepayHandler.getBillsFromFile(SRC_BILL_PATH, clazz, payAccount, month);
BigDecimal total = new BigDecimal(0);
for (int i = 0; i < bills.size(); i++) {
if(!lostSet.contains(bills.get(i).getOrderId())) {
total = total.add(bills.get(i).getIncome());
}else {
System.out.println(bills.get(i).getOrderId().concat("--").concat(bills.get(i).getIncome().toString()));
}
}
System.out.println(total);
}
}
package cn.gq.financial.model.db;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class RepayDetailFinancial {
private Long id;
......@@ -77,300 +80,4 @@ public class RepayDetailFinancial {
private String phoneMerchant; //3C产品商家
private String productName3C;
public String getPhoneMerchant() {
return phoneMerchant;
}
public void setPhoneMerchant(String phoneMerchant) {
this.phoneMerchant = phoneMerchant;
}
public String getProductName3C() {
return productName3C;
}
public void setProductName3C(String productName3C) {
this.productName3C = productName3C;
}
public Integer getMonth() {
return month;
}
public void setMonth(Integer month) {
this.month = month;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getBizType() {
return bizType;
}
public void setBizType(String bizType) {
this.bizType = bizType;
}
public String getPayAccount() {
return payAccount;
}
public void setPayAccount(String payAccount) {
this.payAccount = payAccount;
}
public Long getRepaymentPlanId() {
return repaymentPlanId;
}
public void setRepaymentPlanId(Long repaymentPlanId) {
this.repaymentPlanId = repaymentPlanId;
}
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public String getLhpSeriaNo() {
return lhpSeriaNo;
}
public void setLhpSeriaNo(String lhpSeriaNo) {
this.lhpSeriaNo = lhpSeriaNo;
}
public String getCustomerFrom() {
return customerFrom;
}
public void setCustomerFrom(String customerFrom) {
this.customerFrom = customerFrom;
}
public String getFundingCorpName() {
return fundingCorpName;
}
public void setFundingCorpName(String fundingCorpName) {
this.fundingCorpName = fundingCorpName;
}
public String getContractNo() {
return contractNo;
}
public void setContractNo(String contractNo) {
this.contractNo = contractNo;
}
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 Date getLoanPaidAt() {
return loanPaidAt;
}
public void setLoanPaidAt(Date loanPaidAt) {
this.loanPaidAt = loanPaidAt;
}
public BigDecimal getShouldLoanAmount() {
return shouldLoanAmount;
}
public void setShouldLoanAmount(BigDecimal shouldLoanAmount) {
this.shouldLoanAmount = shouldLoanAmount;
}
public BigDecimal getRealLoanAmount() {
return realLoanAmount;
}
public void setRealLoanAmount(BigDecimal realLoanAmount) {
this.realLoanAmount = realLoanAmount;
}
public Integer getContractTerm() {
return contractTerm;
}
public void setContractTerm(Integer contractTerm) {
this.contractTerm = contractTerm;
}
public Integer getTermNo() {
return termNo;
}
public void setTermNo(Integer termNo) {
this.termNo = termNo;
}
public Date getDeadline() {
return deadline;
}
public void setDeadline(Date deadline) {
this.deadline = deadline;
}
public BigDecimal getRequiredRepayment() {
return requiredRepayment;
}
public void setRequiredRepayment(BigDecimal requiredRepayment) {
this.requiredRepayment = requiredRepayment;
}
public Date getRepaidAt() {
return repaidAt;
}
public void setRepaidAt(Date repaidAt) {
this.repaidAt = repaidAt;
}
public BigDecimal getPrincipalAmount() {
return principalAmount;
}
public void setPrincipalAmount(BigDecimal principalAmount) {
this.principalAmount = principalAmount;
}
public BigDecimal getInterest() {
return interest;
}
public void setInterest(BigDecimal interest) {
this.interest = interest;
}
public BigDecimal getOverdueFee() {
return overdueFee;
}
public void setOverdueFee(BigDecimal overdueFee) {
this.overdueFee = overdueFee;
}
public BigDecimal getSelfManexpense() {
return selfManexpense;
}
public void setSelfManexpense(BigDecimal selfManexpense) {
this.selfManexpense = selfManexpense;
}
public BigDecimal getActivityRelief() {
return activityRelief;
}
public void setActivityRelief(BigDecimal activityRelief) {
this.activityRelief = activityRelief;
}
public BigDecimal getCollectionRelief() {
return collectionRelief;
}
public void setCollectionRelief(BigDecimal collectionRelief) {
this.collectionRelief = collectionRelief;
}
public BigDecimal getCurrentRepayment() {
return currentRepayment;
}
public void setCurrentRepayment(BigDecimal currentRepayment) {
this.currentRepayment = currentRepayment;
}
public BigDecimal getPayApproachPoundage() {
return payApproachPoundage;
}
public void setPayApproachPoundage(BigDecimal payApproachPoundage) {
this.payApproachPoundage = payApproachPoundage;
}
public String getFinancialMerchant() {
return financialMerchant;
}
public void setFinancialMerchant(String financialMerchant) {
this.financialMerchant = financialMerchant;
}
public String getActuallyFundingCorp() {
return actuallyFundingCorp;
}
public void setActuallyFundingCorp(String actuallyFundingCorp) {
this.actuallyFundingCorp = actuallyFundingCorp;
}
public String getPayCenterOrderNo() {
return payCenterOrderNo;
}
public void setPayCenterOrderNo(String payCenterOrderNo) {
this.payCenterOrderNo = payCenterOrderNo;
}
public Long getLoanApplicationHistoryId() {
return loanApplicationHistoryId;
}
public void setLoanApplicationHistoryId(Long loanApplicationHistoryId) {
this.loanApplicationHistoryId = loanApplicationHistoryId;
}
public Date getContractCreateAt() {
return contractCreateAt;
}
public void setContractCreateAt(Date contractCreateAt) {
this.contractCreateAt = contractCreateAt;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
......@@ -81,6 +81,9 @@ public class BaitiaoOfflineDetailService implements DetailService {
detail.setSelfManexpense(new BigDecimal(entity.getServiceFeePerTerm()));
detail.setFundingCorpName(entity.getFundingCorp());
detail.setActuallyFundingCorp(entity.getDebtFundingCorp());
BigDecimal curr = detail.getPrincipalAmount().add(detail.getInterest()).add(detail.getOverdueFee()).add(detail.getSelfManexpense()).subtract(detail.getCollectionRelief()).subtract(detail.getActivityRelief());
detail.setCurrentRepayment(curr);
return detail;
}
......
package cn.gq.financial.service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
......@@ -7,6 +8,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import cn.gq.financial.utils.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -99,13 +101,19 @@ public class BaitiaoOnlineDetailService implements DetailService {
detail.setInterest(entity.getInterestAmount());
detail.setOverdueFee(entity.getOverdueFee());
if(null != entity.getReduceAmount()){
detail.setCollectionRelief(entity.getReduceAmount());
if(1 == BigDecimal.ZERO.compareTo(entity.getReduceAmount())) {
detail.setCollectionRelief(entity.getReduceAmount().multiply(Constants.MINUS_ONE));
}else {
detail.setCurrentRepayment(entity.getReduceAmount());
}
}
detail.setCurrentRepayment(entity.getCurrentRepayment());
// detail.setCurrentRepayment(entity.getCurrentRepayment());
detail.setPayCenterOrderNo(entity.getPayCenterOrderNo());
detail.setContractCreateAt(entity.getOrderTime());
detail.setProductName3C(entity.getProductName3C()); //3c产品名称
detail.setPhoneMerchant(entity.getPhoneMerchant()); //3c的商家
BigDecimal curr = detail.getPrincipalAmount().add(detail.getInterest()).add(detail.getOverdueFee()).add(detail.getSelfManexpense()).subtract(detail.getCollectionRelief()).subtract(detail.getActivityRelief());
detail.setCurrentRepayment(curr);
return detail;
}
......
......@@ -15,6 +15,7 @@ import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
......@@ -176,16 +177,23 @@ public class BillParsers {
if(StringUtils.isNotBlank(row.getCell(4).getStringCellValue())){
bill.setOrderId(row.getCell(4).getStringCellValue().trim());
}
row.getCell(5).setCellType(Cell.CELL_TYPE_STRING);
if(StringUtils.isNotBlank(row.getCell(5).getStringCellValue())){
bill.setIncome(new BigDecimal(row.getCell(5).getStringCellValue()));
}
row.getCell(6).setCellType(Cell.CELL_TYPE_STRING);
if(StringUtils.isNotBlank(row.getCell(6).getStringCellValue())){
bill.setCost(new BigDecimal(row.getCell(6).getStringCellValue()));
}
if(StringUtils.isNotBlank(row.getCell(7).getStringCellValue())){
bill.setPoundage(new BigDecimal(row.getCell(7).getStringCellValue()));
if(null != row.getCell(7)) {
row.getCell(7).setCellType(Cell.CELL_TYPE_STRING);
if (StringUtils.isNotBlank(row.getCell(7).getStringCellValue())) {
bill.setPoundage(new BigDecimal(row.getCell(7).getStringCellValue()));
}
}
if(null != row.getCell(10)) {
bill.setRemak(row.getCell(10).getStringCellValue());
}
bill.setRemak(row.getCell(10).getStringCellValue());
return bill;
}
......
package cn.gq.financial.utils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
......@@ -10,4 +11,6 @@ public class Constants {
public static List<RepayDetailFinancial> result = Collections.synchronizedList(new ArrayList<RepayDetailFinancial>());
public static final BigDecimal MINUS_ONE = new BigDecimal("-1");
}
......@@ -51,7 +51,7 @@ public class HttpUtils {
// 设置连接池
connMgr = new PoolingHttpClientConnectionManager();
// 设置连接池大小
connMgr.setMaxTotal(100);
connMgr.setMaxTotal(5000);
connMgr.setDefaultMaxPerRoute(connMgr.getMaxTotal());
RequestConfig.Builder configBuilder = RequestConfig.custom();
......
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