一般项目开发流程
- 公司领导层做出决策;
- 产品经理根据领导决策勾勒产品需求原型;
- 产品+设计+技术+测试 需求评审讨论;
- 评审讨论调整后进入设计阶段,视觉设计+页面设计
- 技术团队技术架构+技术选型+存储+服务器+运维等
项目技术选型及开发工具
数据库表设计:
项目结构:
父工程就一个pom文件
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bjpowernode.p2p</groupId>
<artifactId>p2p-parent</artifactId>
<version>1.0.0</version>
<!--父工程的packaging标签值必须为pom-->
<packaging>pom</packaging>
<properties>
<!--自定义标称名称-->
<spring-version>4.3.9.RELEASE</spring-version>
<servlet-api-version>3.1.0</servlet-api-version>
<jstl-api-version>1.2</jstl-api-version>
<taglibs-standard-version>1.2.1</taglibs-standard-version>
<mysql-connector-java-version>5.1.43</mysql-connector-java-version>
<druid-version>1.1.1</druid-version>
<mybatis-version>3.4.1</mybatis-version>
<mybatis-spring-version>1.3.0</mybatis-spring-version>
<aspectjweaver-version>1.8.9</aspectjweaver-version>
<zkclient-version>0.10</zkclient-version>
<log4j-version>2.3</log4j-version>
<spring-data-redis-version>1.8.4.RELEASE</spring-data-redis-version>
<jedis-versino>2.9.0</jedis-versino>
<dubbo-version>2.6.0</dubbo-version>
<commons-lang3-version>3.4</commons-lang3-version>
<jackson-version>2.7.3</jackson-version>
<commons-io-version>2.5</commons-io-version>
<httpclient-version>4.5.2</httpclient-version>
<fastjson-version>1.2.36</fastjson-version>
</properties>
<dependencyManagement>
<dependencies>
<!--dataservice工程依赖-->
<!-- Spring框架依赖的JAR配置 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring-version}</version>
</dependency>
<!-- servlet及jstl标签库依赖的JAR配置 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet-api-version}</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
<version>${jstl-api-version}</version>
</dependency>
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-spec</artifactId>
<version>${taglibs-standard-version}</version>
</dependency>
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-impl</artifactId>
<version>${taglibs-standard-version}</version>
</dependency>
<!-- MySQL数据库连接驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java-version}</version>
</dependency>
<!-- JDBC数据源连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid-version}</version>
</dependency>
<!-- MyBatis框架依赖 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis-version}</version>
</dependency>
<!-- MyBatis与Spring整合依赖 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis-spring-version}</version>
</dependency>
<!-- Spring AOP支持start -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectjweaver-version}</version>
</dependency>
<!-- zookeeper客户端依赖 -->
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>${zkclient-version}</version>
</dependency>
<!-- Log4j2依赖的JAR配置 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j-version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j-version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>${log4j-version}</version>
</dependency>
<!-- spring-data-redis依赖的JAR配置 -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>${spring-data-redis-version}</version>
</dependency>
<!-- jedis依赖的JAR配置 -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis-versino}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo-version}</version>
<!--排除依赖冲突项-->
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 加载apache commons包start -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3-version}</version>
</dependency>
<!-- 加载jackson包 -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-version}</version>
</dependency>
<!-- 文件IO操作包start -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io-version}</version>
</dependency>
<!-- httpclient4.5操作包start -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient-version}</version>
</dependency>
<!-- 阿里巴巴json解析包start -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson-version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<!-- 编译插件 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<!-- 插件的版本 -->
<version>3.5.1</version>
<!-- 编译级别 -->
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- 编码格式 -->
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
p2p-dataservice —服务提供者
pom文件
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>p2p-parent</artifactId>
<groupId>com.bjpowernode.p2p</groupId>
<version>1.0.0</version>
<relativePath>../p2p-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>p2p-dataservice</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
</dependency>
<!-- servlet及jstl标签库依赖的JAR配置 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-impl</artifactId>
</dependency>
<!-- MySQL数据库连接驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- JDBC数据源连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
<!-- MyBatis框架依赖 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<!-- MyBatis与Spring整合依赖 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</dependency>
<!-- Spring AOP支持start -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<!-- zookeeper客户端依赖 -->
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
</dependency>
<!-- Log4j2依赖的JAR配置 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
</dependency>
<!-- spring-data-redis依赖的JAR配置 -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
<!-- jedis依赖的JAR配置 -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!--dubbo2.6.0-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<!--P2P的接口工程-->
<dependency>
<groupId>com.bjpowernode.p2p</groupId>
<artifactId>p2p-exterface</artifactId>
<version>1.0.0</version>
</dependency>
<!--p2p-common公共工程-->
<dependency>
<groupId>com.bjpowernode.p2p</groupId>
<artifactId>p2p-common</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<!--手动指定资源文件夹位置-->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.*</include>
</includes>
</resource>
</resources>
</build>
</project>
java文件 -------service层
package com.bjpowernode.p2p.service.loan;
import com.bjpowernode.p2p.common.constant.Constants;
import com.bjpowernode.p2p.mapper.loan.BidInfoMapper;
import com.bjpowernode.p2p.mapper.loan.LoanInfoMapper;
import com.bjpowernode.p2p.mapper.user.FinanceAccountMapper;
import com.bjpowernode.p2p.model.loan.BidInfo;
import com.bjpowernode.p2p.model.loan.LoanInfo;
import com.bjpowernode.p2p.model.vo.BidUserTop;
import com.bjpowernode.p2p.model.vo.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* ClassName:BidInfoServiceImpl
* Package:com.bjpowernode.p2p.service.loan
* Description:
*
* @date:2018/9/17 15:13
* @author:guoxin@bjpowernode.com
*/
@Service("bidInfoServiceImpl")
public class BidInfoServiceImpl implements BidInfoService {
@Autowired
private BidInfoMapper bidInfoMapper;
@Autowired
private LoanInfoMapper loanInfoMapper;
@Autowired
private FinanceAccountMapper financeAccountMapper;
@Autowired
private RedisTemplate<Object,Object> redisTemplate;
@Override
public Double queryAllBidMoney() {
//获取指定key的操作对象
BoundValueOperations<Object, Object> boundValueOps = redisTemplate.boundValueOps(Constants.ALL_BID_MONEY);
//获取指定key的value值
Double allBidMoney = (Double) boundValueOps.get();
//判断是否有值
if (null == allBidMoney) {
//去数据库查询
allBidMoney = bidInfoMapper.selectAllBidMoney();
//存放到redis缓存中
boundValueOps.set(allBidMoney,15, TimeUnit.MINUTES);
}
return allBidMoney;
}
@Override
public List<BidInfo> queryBidInfoListByLoanId(Integer loanId) {
return bidInfoMapper.selectBidInfoListByLoanId(loanId);
}
@Override
public ResultObject invest(Map<String, Object> paramMap) {
ResultObject resultObject = new ResultObject();
resultObject.setErrorCode(Constants.SUCCESS);
//超卖现象:实际销售的数量超过了原有销售数量
//使用数据库乐观锁解决超卖
//获取产品的版本号
LoanInfo loanInfo = loanInfoMapper.selectByPrimaryKey((Integer) paramMap.get("loanId"));
paramMap.put("version",loanInfo.getVersion());
//更新产品剩余可投金额
int updateLeftProductMoneyCount = loanInfoMapper.updateLeftProductMoneyByLoanId(paramMap);
if (updateLeftProductMoneyCount > 0) {
//更新帐户可用余额
int updateFinanceAccountCount = financeAccountMapper.updateFinanceAccountByBid(paramMap);
if (updateFinanceAccountCount > 0) {
//新增投资记录
BidInfo bidInfo = new BidInfo();
//用户标识
bidInfo.setUid((Integer) paramMap.get("uid"));
//产品标识
bidInfo.setLoanId((Integer) paramMap.get("loanId"));
//投资金额
bidInfo.setBidMoney((Double) paramMap.get("bidMoney"));
//投资时间
bidInfo.setBidTime(new Date());
//投资状态
bidInfo.setBidStatus(1);
int insertBidCount = bidInfoMapper.insertSelective(bidInfo);
if (insertBidCount > 0) {
//再次查看产品的剩余可投金额是否为0
LoanInfo loanDetail = loanInfoMapper.selectByPrimaryKey((Integer) paramMap.get("loanId"));
//为0:更新产品的状态及满标时间
if (0 == loanDetail.getLeftProductMoney()) {
//更新产品的状态及满标时间
LoanInfo updateLoanInfo = new LoanInfo();
updateLoanInfo.setId(loanDetail.getId());
updateLoanInfo.setProductFullTime(new Date());
updateLoanInfo.setProductStatus(1);//0未满标,1已满标,2满标且生成收益讲
int updateLoanInfoCount = loanInfoMapper.updateByPrimaryKeySelective(updateLoanInfo);
if (updateLoanInfoCount < 0) {
resultObject.setErrorCode(Constants.FAIL);
}
}
String phone = (String) paramMap.get("phone");
//将用户的投资金额存放到redis缓存中
redisTemplate.opsForZSet().incrementScore(Constants.INVEST_TOP, phone,(Double) paramMap.get("bidMoney"));
} else {
resultObject.setErrorCode(Constants.FAIL);
}
} else {
resultObject.setErrorCode(Constants.FAIL);
}
} else {
resultObject.setErrorCode(Constants.FAIL);
}
return resultObject;
}
@Override
public List<BidUserTop> queryBidUserTop() {
List<BidUserTop> bidUserTopList = new ArrayList<BidUserTop>();
Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisTemplate.opsForZSet().reverseRangeWithScores(Constants.INVEST_TOP, 0, 9);
Iterator<ZSetOperations.TypedTuple<Object>> iterator = typedTuples.iterator();
while (iterator.hasNext()) {
ZSetOperations.TypedTuple<Object> next = iterator.next();
String phone = (String) next.getValue();
Double score = next.getScore();
BidUserTop bidUserTop = new BidUserTop();
bidUserTop.setPhone(phone);
bidUserTop.setScore(score);
bidUserTopList.add(bidUserTop);
}
return bidUserTopList;
}
}
package com.bjpowernode.p2p.service.loan;
import com.bjpowernode.p2p.common.constant.Constants;
import com.bjpowernode.p2p.common.util.DateUtils;
import com.bjpowernode.p2p.mapper.loan.BidInfoMapper;
import com.bjpowernode.p2p.mapper.loan.IncomeRecordMapper;
import com.bjpowernode.p2p.mapper.loan.LoanInfoMapper;
import com.bjpowernode.p2p.mapper.user.FinanceAccountMapper;
import com.bjpowernode.p2p.model.loan.BidInfo;
import com.bjpowernode.p2p.model.loan.IncomeRecord;
import com.bjpowernode.p2p.model.loan.LoanInfo;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* ClassName:IncomeRecordServiceImpl
* Package:com.bjpowernode.p2p.service.loan
* Description:
*
* @date:2018/9/25 9:29
* @author:guoxin@bjpowernode.com
*/
@Service("incomeRecordServiceImpl")
public class IncomeRecordServiceImpl implements IncomeRecordService {
private Logger logger = LogManager.getLogger(IncomeRecordServiceImpl.class);
@Autowired
private LoanInfoMapper loanInfoMapper;
@Autowired
private BidInfoMapper bidInfoMapper;
@Autowired
private IncomeRecordMapper incomeRecordMapper;
@Autowired
private FinanceAccountMapper financeAccountMapper;
@Override
public void generateIncomePlan() {
//查询产品状态为1已满标的产品 -> 返回List<已满标产品>
List<LoanInfo> loanInfoList = loanInfoMapper.selectLoanInfoByProductStatus(1);
//循环遍历,获取到每一个已满标产品
for (LoanInfo loanInfo:loanInfoList) {
//产品类型
Integer productType = loanInfo.getProductType();
//产品满标时间
Date productFullTime = loanInfo.getProductFullTime();
//产品周期
Integer cycle = loanInfo.getCycle();
//产品利率
Double rate = loanInfo.getRate();
//获取当前已满标产品的所有投资记录 -> 返回List<投资记录>
List<BidInfo> bidInfoList = bidInfoMapper.selectBidInfoByLoanId(loanInfo.getId());
//循环遍历投资记录List,获取到每一条的记录
for (BidInfo bidInfo:bidInfoList) {
Double bidMoney = bidInfo.getBidMoney();
//将当前投资记录生成对应的收益记录
IncomeRecord incomeRecord = new IncomeRecord();
//用户标识
incomeRecord.setUid(bidInfo.getUid());
//产品标识
incomeRecord.setLoanId(bidInfo.getLoanId());
//投资记录标识
incomeRecord.setBidId(bidInfo.getId());
//投资金额
incomeRecord.setBidMoney(bidInfo.getBidMoney());
//收益状态:0未返还,1已返还
incomeRecord.setIncomeStatus(0);
//收益时间 = 产品满标时间 + 产品的周期(周期为天|月)
Date incomeDate = null;
//收益金额 = 投资金额 * 日利率 * 投资天数
Double incomeMoney = null;
//判断产品的类型
if (Constants.PRODUCT_TYPE_X == productType) {
//新手宝产品(Date) = productFullTime(Date) + cycle(Integer)天;
incomeDate = DateUtils.getDateByAddDays(productFullTime,cycle);
incomeMoney = bidMoney * (rate / 100 / 365) * cycle;
} else {
//优选和散标(Date) = productFullTime(Date) + cycle(Integer)月;
incomeDate = DateUtils.getDateByAddMonthes(productFullTime,cycle);
incomeMoney = bidMoney * (rate / 100 / 365) * cycle * 30;
}
incomeMoney = Math.round(incomeMoney * Math.pow(10,2)) / Math.pow(10,2);
//收益日期
incomeRecord.setIncomeDate(incomeDate);
//收益金额
incomeRecord.setIncomeMoney(incomeMoney);
int insertCount = incomeRecordMapper.insertSelective(incomeRecord);
if (insertCount > 0) {
logger.info("用户标识为" + bidInfo.getUid() + ",投资记录标识为" + bidInfo.getId() + ",生成收益计划成功");
} else {
logger.info("用户标识为" + bidInfo.getUid() + ",投资记录标识为" + bidInfo.getId() + ",生成收益计划失败");
}
}
//将当前循环遍历的产品状态更新为2满标且生成收益记录
LoanInfo updateLoanInfo = new LoanInfo();
updateLoanInfo.setId(loanInfo.getId());
updateLoanInfo.setProductStatus(2);
int updateLoanInfoCount = loanInfoMapper.updateByPrimaryKeySelective(updateLoanInfo);
if (updateLoanInfoCount > 0) {
logger.info("产品标识为" + loanInfo.getId() + "修改状态为满标且成功收益计划成功");
} else {
logger.info("产品标识为" + loanInfo.getId() + "修改状态为满标且成功收益计划失败");
}
}
}
@Override
public void generateIncomeBack() {
//收益记录状态为0且收益时间与当前时间相同的收益记录 -> 返回List<收益记录>
List<IncomeRecord> incomeRecordList = incomeRecordMapper.selectIncomeRecordByIncomeStatus(0);
//循环遍历收益记录
for (IncomeRecord incomeRecord:incomeRecordList) {
//准备参数
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("uid",incomeRecord.getUid());
paramMap.put("bidMoney",incomeRecord.getBidMoney());
paramMap.put("incomeMoney",incomeRecord.getIncomeMoney());
//将当前收益记录的投资金额和收益金额返还给当前的用户,更新当前帐户的可用余额
int updateFinanceAccountCount = financeAccountMapper.updateFinanceAccountByIncomeBack(paramMap);
if (updateFinanceAccountCount > 0) {
//将当前的收益记录的状态更新为1已返还
IncomeRecord updateIncomeRecord = new IncomeRecord();
updateIncomeRecord.setId(incomeRecord.getId());
updateIncomeRecord.setIncomeStatus(1);
int updateIncomeCount = incomeRecordMapper.updateByPrimaryKeySelective(updateIncomeRecord);
if (updateIncomeCount > 0) {
logger.info("用户标识为" + incomeRecord.getUid() + ",收益记录标识为" + incomeRecord.getId() + "收益返还成功");
} else {
logger.info("用户标识为" + incomeRecord.getUid() + ",收益记录标识为" + incomeRecord.getId() + "收益返还失败");
}
} else {
logger.info("用户标识为" + incomeRecord.getUid() + ",收益记录标识为" + incomeRecord.getId() + "收益返还失败");
}
}
}
}
package com.bjpowernode.p2p.service.loan;
import com.bjpowernode.p2p.common.constant.Constants;
import com.bjpowernode.p2p.mapper.loan.LoanInfoMapper;
import com.bjpowernode.p2p.model.loan.LoanInfo;
import com.bjpowernode.p2p.model.vo.PaginatinoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* ClassName:LoanInfoServiceImpl
* Package:com.bjpowernode.p2p.service.loan
* Description:
*
* @date:2018/9/17 12:01
* @author:guoxin@bjpowernode.com
*/
@Service("loanInfoServiceImpl")
public class LoanInfoServiceImpl implements LoanInfoService {
@Autowired
private LoanInfoMapper loanInfoMapper;
@Autowired
private RedisTemplate<Object,Object> redisTemplate;
@Override
public Double queryHistoryAverageRate() {
//先去redis缓存中获取该,有:直接使用,没有:去数据库查询并存放到redis缓存中
//修改key值的序列化方式
redisTemplate.setKeySerializer(new StringRedisSerializer());
//获取操作key=value的数据类型的redis的操作对象,并获取指定key的value值
Double historyAverageRate = (Double) redisTemplate.opsForValue().get(Constants.HISTORY_AVERAGE_RATE);
//判断是否有值
if (null == historyAverageRate) {
//没有值:去数据库查询
historyAverageRate = loanInfoMapper.selectHistoryAverageRate();
//将该值存放到redis缓存中
redisTemplate.opsForValue().set(Constants.HISTORY_AVERAGE_RATE,historyAverageRate,15, TimeUnit.SECONDS);
}
return historyAverageRate;
}
@Override
public List<LoanInfo> queryLoanInfoListByProductType(Map<String, Object> paramMap) {
return loanInfoMapper.selectLoanInfoByPage(paramMap);
}
@Override
public PaginatinoVO<LoanInfo> queryLoanInfoByPage(Map<String, Object> paramMap) {
PaginatinoVO<LoanInfo> paginatinoVO = new PaginatinoVO<>();
Long total = loanInfoMapper.selectTotal(paramMap);
//查询总记录数
paginatinoVO.setTotal(total);
List<LoanInfo> loanInfoList = loanInfoMapper.selectLoanInfoByPage(paramMap);
//查询显示数据
paginatinoVO.setDataList(loanInfoList);
return paginatinoVO;
}
@Override
public LoanInfo queryLoanInfoById(Integer id) {
return loanInfoMapper.selectByPrimaryKey(id);
}
}
package com.bjpowernode.p2p.service.loan;
import com.bjpowernode.p2p.common.constant.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
/**
* ClassName:OnlyNumberServiceImpl
* Package:com.bjpowernode.p2p.service.loan
* Description:
*
* @date:2018/9/26 10:58
* @author:guoxin@bjpowernode.com
*/
@Service("onlyNumberServiceImpl")
public class OnlyNumberServiceImpl implements OnlyNumberService {
@Autowired
private RedisTemplate<Object,Object> redisTemplate;
@Override
public Long getOnlyNumber() {
return redisTemplate.opsForValue().increment(Constants.ONLY_NUMBER,1);
}
}
package com.bjpowernode.p2p.service.loan;
import com.bjpowernode.p2p.mapper.loan.RechargeRecordMapper;
import com.bjpowernode.p2p.mapper.user.FinanceAccountMapper;
import com.bjpowernode.p2p.model.loan.RechargeRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* ClassName:RechargeRecordServiceImpl
* Package:com.bjpowernode.p2p.service.loan
* Description:
*
* @date:2018/9/26 11:03
* @author:guoxin@bjpowernode.com
*/
@Service("rechargeRecordServiceImpl")
public class RechargeRecordServiceImpl implements RechargeRecordService {
@Autowired
private RechargeRecordMapper rechargeRecordMapper;
@Autowired
private FinanceAccountMapper financeAccountMapper;
@Override
public int addRechargeRecord(RechargeRecord rechargeRecord) {
return rechargeRecordMapper.insertSelective(rechargeRecord);
}
@Override
public int modifyRechargeRecordByRechargeNo(RechargeRecord rechargeRecord) {
return rechargeRecordMapper.updateRechargeRecordByRechargeNo(rechargeRecord);
}
@Override
public int recharge(Map<String, Object> paramMap) {
//更新帐户可用余额
int updateFinanceCount = financeAccountMapper.updateFinanceAccountByRecharge(paramMap);
if (updateFinanceCount > 0) {
//更新充值记录的状态
RechargeRecord rechargeRecord = new RechargeRecord();
rechargeRecord.setRechargeNo((String) paramMap.get("rechargeNo"));
rechargeRecord.setRechargeStatus("1");
int rechargeRecordByRechargeNo = rechargeRecordMapper.updateRechargeRecordByRechargeNo(rechargeRecord);
if (rechargeRecordByRechargeNo < 0) {
return 0;
}
} else {
return 0;
}
return 1;
}
}
package com.bjpowernode.p2p.service.user;
import com.bjpowernode.p2p.mapper.user.FinanceAccountMapper;
import com.bjpowernode.p2p.model.user.FinanceAccount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* ClassName:FinanceAccountServiceImpl
* Package:com.bjpowernode.p2p.service.user
* Description:
*
* @date:2018/9/20 16:47
* @author:guoxin@bjpowernode.com
*/
@Service("financeAccountServiceImpl")
public class FinanceAccountServiceImpl implements FinanceAccountService {
@Autowired
private FinanceAccountMapper financeAccountMapper;
@Override
public FinanceAccount queryFinanceAccountByUid(Integer uid) {
return financeAccountMapper.selectFinanceAccountByUid(uid);
}
}
package com.bjpowernode.p2p.service.user;
import com.bjpowernode.p2p.common.constant.Constants;
import com.bjpowernode.p2p.mapper.user.FinanceAccountMapper;
import com.bjpowernode.p2p.mapper.user.UserMapper;
import com.bjpowernode.p2p.model.user.FinanceAccount;
import com.bjpowernode.p2p.model.user.User;
import com.bjpowernode.p2p.model.vo.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.concurrent.TimeUnit;
/**
* ClassName:UserServiceImpl
* Package:com.bjpowernode.p2p.service.user
* Description:
*
* @date:2018/9/17 14:52
* @author:guoxin@bjpowernode.com
*/
@Service("userServiceImpl")
public class UserServiceImpl implements UserService {
@Autowired
private UserMapper userMapper;
@Autowired
private FinanceAccountMapper financeAccountMapper;
@Autowired
private RedisTemplate<Object,Object> redisTemplate;
@Override
public Long queryAllUserCount() {
//首先去redis缓存中查询,有:直接用
//修改redis中key值的序列化方式
redisTemplate.setKeySerializer(new StringRedisSerializer());
//获取指定操作某一个key的操作对象
BoundValueOperations<Object, Object> boundValueOps = redisTemplate.boundValueOps(Constants.ALL_USER_COUNT);
//获取指定key的value值
Long allUserCount = (Long) boundValueOps.get();
//判断是否有值
if (null == allUserCount) {
//去数据库查询
allUserCount = userMapper.selectAllUserCount();
//将该值存放到redis缓存中
boundValueOps.set(allUserCount,15, TimeUnit.SECONDS);
}
return allUserCount;
}
@Override
public User queryUserByPhone(String phone) {
return userMapper.selectUserByPhone(phone);
}
@Override
public ResultObject register(String phone, String loginPassword) {
ResultObject resultObject = new ResultObject();
resultObject.setErrorCode(Constants.SUCCESS);
//新增用户
User user = new User();
user.setPhone(phone);
user.setLoginPassword(loginPassword);
user.setAddTime(new Date());
user.setLastLoginTime(new Date());
int insertUserCount = userMapper.insertSelective(user);
if (insertUserCount > 0) {
User userInfo = userMapper.selectUserByPhone(phone);
//新增帐户
FinanceAccount financeAccount = new FinanceAccount();
financeAccount.setUid(userInfo.getId());
financeAccount.setAvailableMoney(888.0);
int insertFinanceCount = financeAccountMapper.insertSelective(financeAccount);
if (insertFinanceCount < 0) {
resultObject.setErrorCode(Constants.FAIL);
}
} else {
resultObject.setErrorCode(Constants.FAIL);
}
return resultObject;
}
@Override
public int modifyUserById(User user) {
return userMapper.updateByPrimaryKeySelective(user);
}
@Override
public User login(String phone, String loginPassword) {
//1.根据用户手机号和登录密码查询用户信息
User user = userMapper.selectUserByPhoneAndLoginPassword(phone,loginPassword);
//判断用户是否存在
if (null != user) {
//2.更新用户的登录时间
User updateUser = new User();
updateUser.setId(user.getId());
updateUser.setLastLoginTime(new Date());
userMapper.updateByPrimaryKeySelective(updateUser);
}
return user;
}
}
mapper层
package com.bjpowernode.p2p.mapper.loan;
import com.bjpowernode.p2p.model.loan.BidInfo;
import java.util.List;
public interface BidInfoMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_bid_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_bid_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int insert(BidInfo record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_bid_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int insertSelective(BidInfo record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_bid_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
BidInfo selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_bid_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKeySelective(BidInfo record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_bid_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKey(BidInfo record);
/**
* 获取平台累计投资金额
* @return
*/
Double selectAllBidMoney();
/**
* 根据产品标识获取产品的所有投资记录(包含用户信息)
* @param loanId
* @return
*/
List<BidInfo> selectBidInfoListByLoanId(Integer loanId);
/**
* 根据产品标识获取产品的所有投资记录
*/
List<BidInfo> selectBidInfoByLoanId(Integer loanId);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bjpowernode.p2p.mapper.loan.BidInfoMapper">
<resultMap id="BaseResultMap" type="com.bjpowernode.p2p.model.loan.BidInfo">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="loan_id" property="loanId" jdbcType="INTEGER"/>
<result column="uid" property="uid" jdbcType="INTEGER"/>
<result column="bid_money" property="bidMoney" jdbcType="DOUBLE"/>
<result column="bid_time" property="bidTime" jdbcType="TIMESTAMP"/>
<result column="bid_status" property="bidStatus" jdbcType="INTEGER"/>
</resultMap>
<!--投资记录与用户的关系:一对一-->
<resultMap id="BidUserBaseResultMap" type="com.bjpowernode.p2p.model.loan.BidInfo">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="loan_id" property="loanId" jdbcType="INTEGER"/>
<result column="uid" property="uid" jdbcType="INTEGER"/>
<result column="bid_money" property="bidMoney" jdbcType="DOUBLE"/>
<result column="bid_time" property="bidTime" jdbcType="TIMESTAMP"/>
<result column="bid_status" property="bidStatus" jdbcType="INTEGER"/>
<association property="user" javaType="com.bjpowernode.p2p.model.user.User">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="login_password" property="loginPassword" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="id_card" property="idCard" jdbcType="VARCHAR"/>
<result column="add_time" property="addTime" jdbcType="TIMESTAMP"/>
<result column="last_login_time" property="lastLoginTime" jdbcType="TIMESTAMP"/>
<result column="header_image" property="headerImage" jdbcType="VARCHAR"/>
</association>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
id, loan_id, uid, bid_money, bid_time, bid_status
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
select
<include refid="Base_Column_List"/>
from b_bid_info
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
delete from b_bid_info
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bjpowernode.p2p.model.loan.BidInfo">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
insert into b_bid_info (id, loan_id, uid,
bid_money, bid_time, bid_status
)
values (#{id,jdbcType=INTEGER}, #{loanId,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER},
#{bidMoney,jdbcType=DOUBLE}, #{bidTime,jdbcType=TIMESTAMP}, #{bidStatus,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.bjpowernode.p2p.model.loan.BidInfo">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
insert into b_bid_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="loanId != null">
loan_id,
</if>
<if test="uid != null">
uid,
</if>
<if test="bidMoney != null">
bid_money,
</if>
<if test="bidTime != null">
bid_time,
</if>
<if test="bidStatus != null">
bid_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="loanId != null">
#{loanId,jdbcType=INTEGER},
</if>
<if test="uid != null">
#{uid,jdbcType=INTEGER},
</if>
<if test="bidMoney != null">
#{bidMoney,jdbcType=DOUBLE},
</if>
<if test="bidTime != null">
#{bidTime,jdbcType=TIMESTAMP},
</if>
<if test="bidStatus != null">
#{bidStatus,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bjpowernode.p2p.model.loan.BidInfo">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update b_bid_info
<set>
<if test="loanId != null">
loan_id = #{loanId,jdbcType=INTEGER},
</if>
<if test="uid != null">
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="bidMoney != null">
bid_money = #{bidMoney,jdbcType=DOUBLE},
</if>
<if test="bidTime != null">
bid_time = #{bidTime,jdbcType=TIMESTAMP},
</if>
<if test="bidStatus != null">
bid_status = #{bidStatus,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.bjpowernode.p2p.model.loan.BidInfo">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update b_bid_info
set loan_id = #{loanId,jdbcType=INTEGER},
uid = #{uid,jdbcType=INTEGER},
bid_money = #{bidMoney,jdbcType=DOUBLE},
bid_time = #{bidTime,jdbcType=TIMESTAMP},
bid_status = #{bidStatus,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<!--获取平台累计投资金额-->
<select id="selectAllBidMoney" resultType="java.lang.Double">
select sum(bid_money) from b_bid_info
</select>
<!--根据产品标识获取产品的所有投资记录(包含用户信息)-->
<select id="selectBidInfoListByLoanId" resultMap="BidUserBaseResultMap">
select
a.*,b.*
from
b_bid_info a
left join
u_user b
on
a.uid = b.id
where
loan_id = #{loanId}
order by
a.bid_time desc
</select>
<!--根据产品标识获取产品的所有投资记录-->
<select id="selectBidInfoByLoanId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
b_bid_info
where
loan_id = #{loanId}
</select>
</mapper>
package com.bjpowernode.p2p.mapper.loan;
import com.bjpowernode.p2p.model.loan.IncomeRecord;
import java.util.List;
public interface IncomeRecordMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_income_record
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_income_record
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int insert(IncomeRecord record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_income_record
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int insertSelective(IncomeRecord record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_income_record
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
IncomeRecord selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_income_record
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKeySelective(IncomeRecord record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_income_record
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKey(IncomeRecord record);
/**
* 根据收益状态与收益时间获取收益记录
* @param incomeStatus
* @return
*/
List<IncomeRecord> selectIncomeRecordByIncomeStatus(Integer incomeStatus);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bjpowernode.p2p.mapper.loan.IncomeRecordMapper">
<resultMap id="BaseResultMap" type="com.bjpowernode.p2p.model.loan.IncomeRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="uid" property="uid" jdbcType="INTEGER"/>
<result column="loan_id" property="loanId" jdbcType="INTEGER"/>
<result column="bid_id" property="bidId" jdbcType="INTEGER"/>
<result column="bid_money" property="bidMoney" jdbcType="DOUBLE"/>
<result column="income_date" property="incomeDate" jdbcType="DATE"/>
<result column="income_money" property="incomeMoney" jdbcType="DOUBLE"/>
<result column="income_status" property="incomeStatus" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
id, uid, loan_id, bid_id, bid_money, income_date, income_money, income_status
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
select
<include refid="Base_Column_List"/>
from b_income_record
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
delete from b_income_record
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bjpowernode.p2p.model.loan.IncomeRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
insert into b_income_record (id, uid, loan_id,
bid_id, bid_money, income_date,
income_money, income_status)
values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, #{loanId,jdbcType=INTEGER},
#{bidId,jdbcType=INTEGER}, #{bidMoney,jdbcType=DOUBLE}, #{incomeDate,jdbcType=DATE},
#{incomeMoney,jdbcType=DOUBLE}, #{incomeStatus,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.bjpowernode.p2p.model.loan.IncomeRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
insert into b_income_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="uid != null">
uid,
</if>
<if test="loanId != null">
loan_id,
</if>
<if test="bidId != null">
bid_id,
</if>
<if test="bidMoney != null">
bid_money,
</if>
<if test="incomeDate != null">
income_date,
</if>
<if test="incomeMoney != null">
income_money,
</if>
<if test="incomeStatus != null">
income_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="uid != null">
#{uid,jdbcType=INTEGER},
</if>
<if test="loanId != null">
#{loanId,jdbcType=INTEGER},
</if>
<if test="bidId != null">
#{bidId,jdbcType=INTEGER},
</if>
<if test="bidMoney != null">
#{bidMoney,jdbcType=DOUBLE},
</if>
<if test="incomeDate != null">
#{incomeDate,jdbcType=DATE},
</if>
<if test="incomeMoney != null">
#{incomeMoney,jdbcType=DOUBLE},
</if>
<if test="incomeStatus != null">
#{incomeStatus,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bjpowernode.p2p.model.loan.IncomeRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update b_income_record
<set>
<if test="uid != null">
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="loanId != null">
loan_id = #{loanId,jdbcType=INTEGER},
</if>
<if test="bidId != null">
bid_id = #{bidId,jdbcType=INTEGER},
</if>
<if test="bidMoney != null">
bid_money = #{bidMoney,jdbcType=DOUBLE},
</if>
<if test="incomeDate != null">
income_date = #{incomeDate,jdbcType=DATE},
</if>
<if test="incomeMoney != null">
income_money = #{incomeMoney,jdbcType=DOUBLE},
</if>
<if test="incomeStatus != null">
income_status = #{incomeStatus,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.bjpowernode.p2p.model.loan.IncomeRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update b_income_record
set uid = #{uid,jdbcType=INTEGER},
loan_id = #{loanId,jdbcType=INTEGER},
bid_id = #{bidId,jdbcType=INTEGER},
bid_money = #{bidMoney,jdbcType=DOUBLE},
income_date = #{incomeDate,jdbcType=DATE},
income_money = #{incomeMoney,jdbcType=DOUBLE},
income_status = #{incomeStatus,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<!--根据收益状态与收益时间获取收益记录-->
<select id="selectIncomeRecordByIncomeStatus" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from b_income_record where income_date = curdate() and income_status = #{incomeStatus}
</select>
</mapper>
package com.bjpowernode.p2p.mapper.loan;
import com.bjpowernode.p2p.model.loan.LoanInfo;
import java.util.List;
import java.util.Map;
public interface LoanInfoMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_loan_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_loan_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int insert(LoanInfo record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_loan_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int insertSelective(LoanInfo record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_loan_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
LoanInfo selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_loan_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKeySelective(LoanInfo record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_loan_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKeyWithBLOBs(LoanInfo record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_loan_info
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKey(LoanInfo record);
/**
* 历史平均年化收益率
* @return
*/
Double selectHistoryAverageRate();
/**
* 分页查询产品信息列表
* @param paramMap
* @return
*/
List<LoanInfo> selectLoanInfoByPage(Map<String, Object> paramMap);
/**
* 根据产品类型获取产品的总记录数
* @param paramMap
* @return
*/
Long selectTotal(Map<String, Object> paramMap);
/**
* 更新产品的剩余可投金额
* @param paramMap
* @return
*/
int updateLeftProductMoneyByLoanId(Map<String, Object> paramMap);
/**
* 根据产品的状态获取产品信息列表
* @param productStatus
* @return
*/
List<LoanInfo> selectLoanInfoByProductStatus(Integer productStatus);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bjpowernode.p2p.mapper.loan.LoanInfoMapper">
<resultMap id="BaseResultMap" type="com.bjpowernode.p2p.model.loan.LoanInfo">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="product_name" property="productName" jdbcType="VARCHAR"/>
<result column="rate" property="rate" jdbcType="DOUBLE"/>
<result column="cycle" property="cycle" jdbcType="INTEGER"/>
<result column="release_time" property="releaseTime" jdbcType="DATE"/>
<result column="product_type" property="productType" jdbcType="INTEGER"/>
<result column="product_no" property="productNo" jdbcType="VARCHAR"/>
<result column="product_money" property="productMoney" jdbcType="DOUBLE"/>
<result column="left_product_money" property="leftProductMoney" jdbcType="DOUBLE"/>
<result column="bid_min_limit" property="bidMinLimit" jdbcType="DOUBLE"/>
<result column="bid_max_limit" property="bidMaxLimit" jdbcType="DOUBLE"/>
<result column="product_status" property="productStatus" jdbcType="INTEGER"/>
<result column="product_full_time" property="productFullTime" jdbcType="TIMESTAMP"/>
<result column="product_desc" property="productDesc" jdbcType="LONGVARCHAR"/>
<result column="version" property="version" jdbcType="INTEGER"/>
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.bjpowernode.p2p.model.loan.LoanInfo" extends="BaseResultMap">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
id, product_name, rate, cycle, release_time, product_type, product_no, product_money,
left_product_money, bid_min_limit, bid_max_limit, product_status, product_full_time,
product_desc,version
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
select
<include refid="Base_Column_List"/>
from b_loan_info
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
delete from b_loan_info
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bjpowernode.p2p.model.loan.LoanInfo">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
insert into b_loan_info (id, product_name, rate,
cycle, release_time, product_type,
product_no, product_money, left_product_money,
bid_min_limit, bid_max_limit, product_status,
product_full_time, version, product_desc
)
values (#{id,jdbcType=INTEGER}, #{productName,jdbcType=VARCHAR}, #{rate,jdbcType=DOUBLE},
#{cycle,jdbcType=INTEGER}, #{releaseTime,jdbcType=DATE}, #{productType,jdbcType=INTEGER},
#{productNo,jdbcType=VARCHAR}, #{productMoney,jdbcType=DOUBLE}, #{leftProductMoney,jdbcType=DOUBLE},
#{bidMinLimit,jdbcType=DOUBLE}, #{bidMaxLimit,jdbcType=DOUBLE}, #{productStatus,jdbcType=INTEGER},
#{productFullTime,jdbcType=TIMESTAMP}, #{version,jdbcType=INTEGER}, #{productDesc,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.bjpowernode.p2p.model.loan.LoanInfo">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
insert into b_loan_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="productName != null">
product_name,
</if>
<if test="rate != null">
rate,
</if>
<if test="cycle != null">
cycle,
</if>
<if test="releaseTime != null">
release_time,
</if>
<if test="productType != null">
product_type,
</if>
<if test="productNo != null">
product_no,
</if>
<if test="productMoney != null">
product_money,
</if>
<if test="leftProductMoney != null">
left_product_money,
</if>
<if test="bidMinLimit != null">
bid_min_limit,
</if>
<if test="bidMaxLimit != null">
bid_max_limit,
</if>
<if test="productStatus != null">
product_status,
</if>
<if test="productFullTime != null">
product_full_time,
</if>
<if test="version != null">
version,
</if>
<if test="productDesc != null">
product_desc,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="productName != null">
#{productName,jdbcType=VARCHAR},
</if>
<if test="rate != null">
#{rate,jdbcType=DOUBLE},
</if>
<if test="cycle != null">
#{cycle,jdbcType=INTEGER},
</if>
<if test="releaseTime != null">
#{releaseTime,jdbcType=DATE},
</if>
<if test="productType != null">
#{productType,jdbcType=INTEGER},
</if>
<if test="productNo != null">
#{productNo,jdbcType=VARCHAR},
</if>
<if test="productMoney != null">
#{productMoney,jdbcType=DOUBLE},
</if>
<if test="leftProductMoney != null">
#{leftProductMoney,jdbcType=DOUBLE},
</if>
<if test="bidMinLimit != null">
#{bidMinLimit,jdbcType=DOUBLE},
</if>
<if test="bidMaxLimit != null">
#{bidMaxLimit,jdbcType=DOUBLE},
</if>
<if test="productStatus != null">
#{productStatus,jdbcType=INTEGER},
</if>
<if test="productFullTime != null">
#{productFullTime,jdbcType=TIMESTAMP},
</if>
<if test="version != null">
#{version,jdbcType=INTEGER},
</if>
<if test="productDesc != null">
#{productDesc,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bjpowernode.p2p.model.loan.LoanInfo">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update b_loan_info
<set>
<if test="productName != null">
product_name = #{productName,jdbcType=VARCHAR},
</if>
<if test="rate != null">
rate = #{rate,jdbcType=DOUBLE},
</if>
<if test="cycle != null">
cycle = #{cycle,jdbcType=INTEGER},
</if>
<if test="releaseTime != null">
release_time = #{releaseTime,jdbcType=DATE},
</if>
<if test="productType != null">
product_type = #{productType,jdbcType=INTEGER},
</if>
<if test="productNo != null">
product_no = #{productNo,jdbcType=VARCHAR},
</if>
<if test="productMoney != null">
product_money = #{productMoney,jdbcType=DOUBLE},
</if>
<if test="leftProductMoney != null">
left_product_money = #{leftProductMoney,jdbcType=DOUBLE},
</if>
<if test="bidMinLimit != null">
bid_min_limit = #{bidMinLimit,jdbcType=DOUBLE},
</if>
<if test="bidMaxLimit != null">
bid_max_limit = #{bidMaxLimit,jdbcType=DOUBLE},
</if>
<if test="productStatus != null">
product_status = #{productStatus,jdbcType=INTEGER},
</if>
<if test="productFullTime != null">
product_full_time = #{productFullTime,jdbcType=TIMESTAMP},
</if>
<if test="version != null">
version = #{version,jdbcType=INTEGER},
</if>
<if test="productDesc != null">
product_desc = #{productDesc,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.bjpowernode.p2p.model.loan.LoanInfo">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update b_loan_info
set product_name = #{productName,jdbcType=VARCHAR},
rate = #{rate,jdbcType=DOUBLE},
cycle = #{cycle,jdbcType=INTEGER},
release_time = #{releaseTime,jdbcType=DATE},
product_type = #{productType,jdbcType=INTEGER},
product_no = #{productNo,jdbcType=VARCHAR},
product_money = #{productMoney,jdbcType=DOUBLE},
left_product_money = #{leftProductMoney,jdbcType=DOUBLE},
bid_min_limit = #{bidMinLimit,jdbcType=DOUBLE},
bid_max_limit = #{bidMaxLimit,jdbcType=DOUBLE},
product_status = #{productStatus,jdbcType=INTEGER},
product_full_time = #{productFullTime,jdbcType=TIMESTAMP},
version = #{version,jdbcType=INTEGER},
product_desc = #{productDesc,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.bjpowernode.p2p.model.loan.LoanInfo">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update b_loan_info
set product_name = #{productName,jdbcType=VARCHAR},
rate = #{rate,jdbcType=DOUBLE},
cycle = #{cycle,jdbcType=INTEGER},
release_time = #{releaseTime,jdbcType=DATE},
product_type = #{productType,jdbcType=INTEGER},
product_no = #{productNo,jdbcType=VARCHAR},
product_money = #{productMoney,jdbcType=DOUBLE},
left_product_money = #{leftProductMoney,jdbcType=DOUBLE},
bid_min_limit = #{bidMinLimit,jdbcType=DOUBLE},
bid_max_limit = #{bidMaxLimit,jdbcType=DOUBLE},
product_status = #{productStatus,jdbcType=INTEGER},
product_full_time = #{productFullTime,jdbcType=TIMESTAMP},
version = #{version,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<!--获取平台历史平均年化收益率-->
<select id="selectHistoryAverageRate" resultType="java.lang.Double">
select cast(avg(rate) as DECIMAL(10,2)) from b_loan_info
</select>
<!--分页查询产品信息列表-->
<select id="selectLoanInfoByPage" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
b_loan_info
<where>
<if test="productType != null">
product_type = #{productType}
</if>
</where>
order by
release_time desc
limit #{currentPage},#{pageSize}
</select>
<!--根据产品类型获取产品的总记录数-->
<select id="selectTotal" resultType="java.lang.Long">
select
count(*)
from
b_loan_info
<where>
<if test="productType != null">
product_type = #{productType}
</if>
</where>
</select>
<!--更新产品的剩余可投金额-->
<update id="updateLeftProductMoneyByLoanId">
update
b_loan_info
set
left_product_money = left_product_money - #{bidMoney},
version = version+1
where
id = #{loanId} and version = #{version} and (left_product_money - #{bidMoney}) >= 0
</update>
<!--根据产品的状态获取产品信息列表-->
<select id="selectLoanInfoByProductStatus" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
b_loan_info
where
product_status = #{productStatus}
</select>
</mapper>
package com.bjpowernode.p2p.mapper.loan;
import com.bjpowernode.p2p.model.loan.RechargeRecord;
public interface RechargeRecordMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_recharge_record
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_recharge_record
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int insert(RechargeRecord record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_recharge_record
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int insertSelective(RechargeRecord record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_recharge_record
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
RechargeRecord selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_recharge_record
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKeySelective(RechargeRecord record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table b_recharge_record
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKey(RechargeRecord record);
/**
* 根据充值订单号更新充值记录
* @param rechargeRecord
* @return
*/
int updateRechargeRecordByRechargeNo(RechargeRecord rechargeRecord);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bjpowernode.p2p.mapper.loan.RechargeRecordMapper">
<resultMap id="BaseResultMap" type="com.bjpowernode.p2p.model.loan.RechargeRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="uid" property="uid" jdbcType="INTEGER"/>
<result column="recharge_no" property="rechargeNo" jdbcType="VARCHAR"/>
<result column="recharge_status" property="rechargeStatus" jdbcType="VARCHAR"/>
<result column="recharge_money" property="rechargeMoney" jdbcType="DOUBLE"/>
<result column="recharge_time" property="rechargeTime" jdbcType="TIMESTAMP"/>
<result column="recharge_desc" property="rechargeDesc" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
id, uid, recharge_no, recharge_status, recharge_money, recharge_time, recharge_desc
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
select
<include refid="Base_Column_List"/>
from b_recharge_record
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
delete from b_recharge_record
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bjpowernode.p2p.model.loan.RechargeRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
insert into b_recharge_record (id, uid, recharge_no,
recharge_status, recharge_money, recharge_time,
recharge_desc)
values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, #{rechargeNo,jdbcType=VARCHAR},
#{rechargeStatus,jdbcType=VARCHAR}, #{rechargeMoney,jdbcType=DOUBLE}, #{rechargeTime,jdbcType=TIMESTAMP},
#{rechargeDesc,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.bjpowernode.p2p.model.loan.RechargeRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
insert into b_recharge_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="uid != null">
uid,
</if>
<if test="rechargeNo != null">
recharge_no,
</if>
<if test="rechargeStatus != null">
recharge_status,
</if>
<if test="rechargeMoney != null">
recharge_money,
</if>
<if test="rechargeTime != null">
recharge_time,
</if>
<if test="rechargeDesc != null">
recharge_desc,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="uid != null">
#{uid,jdbcType=INTEGER},
</if>
<if test="rechargeNo != null">
#{rechargeNo,jdbcType=VARCHAR},
</if>
<if test="rechargeStatus != null">
#{rechargeStatus,jdbcType=VARCHAR},
</if>
<if test="rechargeMoney != null">
#{rechargeMoney,jdbcType=DOUBLE},
</if>
<if test="rechargeTime != null">
#{rechargeTime,jdbcType=TIMESTAMP},
</if>
<if test="rechargeDesc != null">
#{rechargeDesc,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bjpowernode.p2p.model.loan.RechargeRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update b_recharge_record
<set>
<if test="uid != null">
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="rechargeNo != null">
recharge_no = #{rechargeNo,jdbcType=VARCHAR},
</if>
<if test="rechargeStatus != null">
recharge_status = #{rechargeStatus,jdbcType=VARCHAR},
</if>
<if test="rechargeMoney != null">
recharge_money = #{rechargeMoney,jdbcType=DOUBLE},
</if>
<if test="rechargeTime != null">
recharge_time = #{rechargeTime,jdbcType=TIMESTAMP},
</if>
<if test="rechargeDesc != null">
recharge_desc = #{rechargeDesc,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.bjpowernode.p2p.model.loan.RechargeRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update b_recharge_record
set uid = #{uid,jdbcType=INTEGER},
recharge_no = #{rechargeNo,jdbcType=VARCHAR},
recharge_status = #{rechargeStatus,jdbcType=VARCHAR},
recharge_money = #{rechargeMoney,jdbcType=DOUBLE},
recharge_time = #{rechargeTime,jdbcType=TIMESTAMP},
recharge_desc = #{rechargeDesc,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<!--根据充值订单号更新充值记录-->
<update id="updateRechargeRecordByRechargeNo">
update
b_recharge_record
<set>
<if test="rechargeStatus != null">
recharge_status = #{rechargeStatus,jdbcType=VARCHAR},
</if>
<if test="rechargeMoney != null">
recharge_money = #{rechargeMoney,jdbcType=DOUBLE},
</if>
<if test="rechargeTime != null">
recharge_time = #{rechargeTime,jdbcType=TIMESTAMP},
</if>
<if test="rechargeDesc != null">
recharge_desc = #{rechargeDesc,jdbcType=VARCHAR},
</if>
</set>
where
recharge_no= #{rechargeNo,jdbcType=INTEGER}
</update>
</mapper>
package com.bjpowernode.p2p.mapper.user;
import com.bjpowernode.p2p.model.user.FinanceAccount;
import java.util.Map;
public interface FinanceAccountMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table u_finance_account
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table u_finance_account
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int insert(FinanceAccount record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table u_finance_account
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int insertSelective(FinanceAccount record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table u_finance_account
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
FinanceAccount selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table u_finance_account
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKeySelective(FinanceAccount record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table u_finance_account
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKey(FinanceAccount record);
/**
* 根据用户标识获取帐户信息
* @param uid
* @return
*/
FinanceAccount selectFinanceAccountByUid(Integer uid);
/**
* 用户投资:更新帐户可用余额
* @param paramMap
* @return
*/
int updateFinanceAccountByBid(Map<String, Object> paramMap);
/**
* 收益返还:更新帐户可用余额
* @param paramMap
* @return
*/
int updateFinanceAccountByIncomeBack(Map<String, Object> paramMap);
/**
* 用户充值:更新帐户可用余额
* @param paramMap
* @return
*/
int updateFinanceAccountByRecharge(Map<String, Object> paramMap);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bjpowernode.p2p.mapper.user.FinanceAccountMapper">
<resultMap id="BaseResultMap" type="com.bjpowernode.p2p.model.user.FinanceAccount">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="uid" property="uid" jdbcType="INTEGER"/>
<result column="available_money" property="availableMoney" jdbcType="DOUBLE"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
id, uid, available_money
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
select
<include refid="Base_Column_List"/>
from u_finance_account
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
delete from u_finance_account
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bjpowernode.p2p.model.user.FinanceAccount">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
insert into u_finance_account (id, uid, available_money
)
values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, #{availableMoney,jdbcType=DOUBLE}
)
</insert>
<insert id="insertSelective" parameterType="com.bjpowernode.p2p.model.user.FinanceAccount">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
insert into u_finance_account
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="uid != null">
uid,
</if>
<if test="availableMoney != null">
available_money,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="uid != null">
#{uid,jdbcType=INTEGER},
</if>
<if test="availableMoney != null">
#{availableMoney,jdbcType=DOUBLE},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bjpowernode.p2p.model.user.FinanceAccount">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update u_finance_account
<set>
<if test="uid != null">
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="availableMoney != null">
available_money = #{availableMoney,jdbcType=DOUBLE},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.bjpowernode.p2p.model.user.FinanceAccount">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update u_finance_account
set uid = #{uid,jdbcType=INTEGER},
available_money = #{availableMoney,jdbcType=DOUBLE}
where id = #{id,jdbcType=INTEGER}
</update>
<!--根据用户标识获取帐户信息-->
<select id="selectFinanceAccountByUid" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
u_finance_account
where
uid = #{uid}
</select>
<!--用户投资:更新帐户可用余额-->
<update id="updateFinanceAccountByBid">
update
u_finance_account
set
available_money = available_money - #{bidMoney}
where
uid = #{uid} and (available_money - #{bidMoney}) >= 0
</update>
<!--收益返还:更新帐户可用余额-->
<update id="updateFinanceAccountByIncomeBack">
update
u_finance_account
set
available_money = available_money + #{bidMoney} + #{incomeMoney}
where
uid = #{uid}
</update>
<!--用户充值:更新帐户可用余额-->
<update id="updateFinanceAccountByRecharge">
update
u_finance_account
set
available_money = available_money + #{rechargeMoney}
where
uid = #{uid}
</update>
</mapper>
package com.bjpowernode.p2p.mapper.user;
import com.bjpowernode.p2p.model.user.User;
public interface UserMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table u_user
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table u_user
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int insert(User record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table u_user
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int insertSelective(User record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table u_user
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
User selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table u_user
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKeySelective(User record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table u_user
*
* @mbggenerated Mon Sep 17 09:12:20 CST 2018
*/
int updateByPrimaryKey(User record);
/**
* 获取平台注册总人数
* @return
*/
Long selectAllUserCount();
/**
* 根据手机号查询用户信息
* @param phone
* @return
*/
User selectUserByPhone(String phone);
/**
* 根据用户的手机号和密码查询用户信息
* @param phone
* @param loginPassword
* @return
*/
User selectUserByPhoneAndLoginPassword(String phone, String loginPassword);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bjpowernode.p2p.mapper.user.UserMapper">
<resultMap id="BaseResultMap" type="com.bjpowernode.p2p.model.user.User">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="login_password" property="loginPassword" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="id_card" property="idCard" jdbcType="VARCHAR"/>
<result column="add_time" property="addTime" jdbcType="TIMESTAMP"/>
<result column="last_login_time" property="lastLoginTime" jdbcType="TIMESTAMP"/>
<result column="header_image" property="headerImage" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
id, phone, login_password, name, id_card, add_time, last_login_time, header_image
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
select
<include refid="Base_Column_List"/>
from u_user
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
delete from u_user
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bjpowernode.p2p.model.user.User">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
insert into u_user (id, phone, login_password,
name, id_card, add_time,
last_login_time, header_image)
values (#{id,jdbcType=INTEGER}, #{phone,jdbcType=VARCHAR}, #{loginPassword,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{idCard,jdbcType=VARCHAR}, #{addTime,jdbcType=TIMESTAMP},
#{lastLoginTime,jdbcType=TIMESTAMP}, #{headerImage,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.bjpowernode.p2p.model.user.User">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
insert into u_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="phone != null">
phone,
</if>
<if test="loginPassword != null">
login_password,
</if>
<if test="name != null">
name,
</if>
<if test="idCard != null">
id_card,
</if>
<if test="addTime != null">
add_time,
</if>
<if test="lastLoginTime != null">
last_login_time,
</if>
<if test="headerImage != null">
header_image,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="phone != null">
#{phone,jdbcType=VARCHAR},
</if>
<if test="loginPassword != null">
#{loginPassword,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="idCard != null">
#{idCard,jdbcType=VARCHAR},
</if>
<if test="addTime != null">
#{addTime,jdbcType=TIMESTAMP},
</if>
<if test="lastLoginTime != null">
#{lastLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="headerImage != null">
#{headerImage,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bjpowernode.p2p.model.user.User">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update u_user
<set>
<if test="phone != null">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="loginPassword != null">
login_password = #{loginPassword,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="idCard != null">
id_card = #{idCard,jdbcType=VARCHAR},
</if>
<if test="addTime != null">
add_time = #{addTime,jdbcType=TIMESTAMP},
</if>
<if test="lastLoginTime != null">
last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="headerImage != null">
header_image = #{headerImage,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.bjpowernode.p2p.model.user.User">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 17 09:12:20 CST 2018.
-->
update u_user
set phone = #{phone,jdbcType=VARCHAR},
login_password = #{loginPassword,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
id_card = #{idCard,jdbcType=VARCHAR},
add_time = #{addTime,jdbcType=TIMESTAMP},
last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
header_image = #{headerImage,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<!--获取平台注册总人数-->
<select id="selectAllUserCount" resultType="java.lang.Long">
select count(*) from u_user
</select>
<!--根据手机号查询用户信息-->
<select id="selectUserByPhone" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
u_user
where
phone = #{phone}
</select>
<!--根据用户的手机号和密码查询用户信息-->
<select id="selectUserByPhoneAndLoginPassword" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
u_user
where
login_password = #{1} and phone = #{0}
</select>
</mapper>
创建多线程的测试类
package com.bjpowernode.p2p.test;
import com.bjpowernode.p2p.service.loan.BidInfoService;
import com.bjpowernode.p2p.service.user.UserService;
import org.apache.logging.log4j.core.util.Cancellable;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* ClassName:Test
* Package:com.bjpowernode.p2p.test
* Description:
*
* @date:2018/9/18 15:32
* @author:guoxin@bjpowernode.com
*/
public class Test {
public static void main(String[] args) {
//获取spring容器
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
//获取指定的bean
BidInfoService bidInfoService = (BidInfoService) context.getBean("bidInfoServiceImpl");
//创建一个固定的线程
ExecutorService executorService = Executors.newFixedThreadPool(100);
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("uid",1);
paramMap.put("loanId",3);
paramMap.put("bidMoney",1.0);
for (int i = 0 ; i < 1000; i++) {
executorService.submit(new Callable() {
@Override
public Object call() throws Exception {
return bidInfoService.invest(paramMap);
}
});
}
executorService.shutdown();
}
}
resources文件 ---------->applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 加载系统配置文件 -->
<context:property-placeholder location="classpath:*.properties" />
<!-- 扫描注解 -->
<context:component-scan base-package="com.bjpowernode.p2p.service" />
<!-- 导入数据相关配置 -->
<import resource="applicationContext-datasource.xml" />
<!-- 导入redis配置 -->
<import resource="applicationContext-redis.xml" />
<!-- 导入服务提供者配置 -->
<import resource="applicationContext-dubbo-provider.xml" />
</beans>
applicationContext-datasource.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 配置数据库连接,阿里数据源druid连接池 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<property name="url" value="jdbc:mysql://rm-uf6512m4812a9s234vo.mysql.rds.aliyuncs.com:3306/p2p?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC" />
<property name="username" value="jd_db_123" />
<property name="password" value="Jd123!@#" />
</bean>
<!-- MyBatis sqlSessionFactory 配置 mybatis -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis-configuration.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
<!-- scan for mappers and let them be autowired -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.bjpowernode.p2p.mapper" />
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>
<!-- 事务相关控制 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 对业务层所有方法添加事务,除了以get、find、select开始的 -->
<tx:method name="*" isolation="DEFAULT" propagation="REQUIRED" rollback-for="java.lang.Exception" />
<!-- 查询操作没有必要开启事务,给只读事务添加一个属性read-only -->
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="select*" read-only="true" />
<tx:method name="query*" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- Service层事务控制 -->
<aop:config>
<!-- * 20200426被删掉 service.*.*-->
<aop:pointcut id="pointcut" expression="execution(* com.bjpowernode.p2p.service.*.*.*(..))" />
<aop:advisor pointcut-ref="pointcut" advice-ref="txAdvice" />
</aop:config>
</beans>
applicationContext-dubbo-provider.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 服务提供者:应用名称 -->
<dubbo:application name="dataservice"/>
<!-- 配置zookeeper注册中心 -->
<dubbo:registry protocol="zookeeper" address="47.101.55.220:2181"/>
<!--产品业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.loan.LoanInfoService" ref="loanInfoServiceImpl" version="1.0.0" timeout="15000"></dubbo:service>
<!--用户业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.user.UserService" ref="userServiceImpl" version="1.0.0" timeout="15000"></dubbo:service>
<!--投资业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.loan.BidInfoService" ref="bidInfoServiceImpl" version="1.0.0" timeout="15000"></dubbo:service>
<!--帐户业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.user.FinanceAccountService" ref="financeAccountServiceImpl" version="1.0.0" timeout="15000"></dubbo:service>
<!--收益业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.loan.IncomeRecordService" ref="incomeRecordServiceImpl" version="1.0.0" timeout="15000"></dubbo:service>
<!--充值业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.loan.RechargeRecordService" ref="rechargeRecordServiceImpl" version="1.0.0" timeout="15000"></dubbo:service>
<!--唯一数字业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.loan.OnlyNumberService" ref="onlyNumberServiceImpl" version="1.0.0" timeout="15000"></dubbo:service>
</beans>
applicationContext-redis.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd ">
<!-- jedis Connection Factory -->
<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:usePool="${redis.usePool}"
p:hostName="${redis.hostName}"
p:port="${redis.port}"
p:timeout="${redis.timeout}"
/>
<!-- p:password="${redis.password}"redis密码被删 2020 0426 -->
<!-- redis template definition -->
<bean id="redisTemplate"
class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="jedisConnectionFactory"/>
</bean>
</beans>
log4j2.xml ----》很强大,可以打印出sql语句
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="debug">
<appenders>
<Console name="Console" target="SYSTEM_OUT">
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="ACCEPT"/>
<PatternLayout pattern="[dataservice] %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
</Console>
<RollingFile name="RollingFile" fileName="/opt/tomcat_dataservice/logs/dataservice.log"
filePattern="/opt/tomcat_dataservice/logs/$${date:yyyy-MM}/dataservice-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout
pattern="[dataservice] %d{yyyy-MM-dd 'at' HH:mm:ss z} %-5level %class{36} %L %M - %msg%xEx%n"/>
<SizeBasedTriggeringPolicy size="100MB"/>
</RollingFile>
</appenders>
<loggers>
<logger name="com.bjpowernode.p2p.mapper" level="debug"/>
<root level="debug">
<appender-ref ref="Console"/>
<appender-ref ref="RollingFile"/>
</root>
</loggers>
</configuration>
mybatis-configuration.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- log4j2与mybatis集成,目的是打印出sql语句 -->
<settings>
<setting name="logImpl" value="LOG4J2"/>
<setting name="logImpl" value="STDOUT_LOGGING"/>
</settings>
</configuration>
redis.properties
#redis config
redis.usePool=true
redis.hostName=47.101.55.220
redis.port=6379
redis.timeout=8000
#redis.password=123456
webapp资源目录
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="dataservice" version="3.0">
<display-name>dataservice application</display-name>
<!-- spring监听器加载applicationContext.xml配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- spring字符过滤器 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>