This commit is contained in:
qiurunze 2019-01-24 19:55:09 +08:00
parent dfac04a4a7
commit 6482bed88a
63 changed files with 1827 additions and 78 deletions

View File

@ -22,6 +22,12 @@
<artifactId>miaosha-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,17 @@
package com.geekq.admin.entity;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
/**
* @author qiurunze
*/
@Getter
@Setter
public class BaseDomain implements Serializable {
protected Long id;
}

View File

@ -0,0 +1,46 @@
package com.geekq.admin.entity;
import lombok.Getter;
import lombok.Setter;
import org.apache.ibatis.type.Alias;
import java.util.Date;
/**
* 登陆日志
* @author Administrator
*/
@Getter
@Setter
@Alias("IpLog")
public class IpLog extends BaseDomain {
public static int LOGINSTATE_FAILD = 0;//登陆失败
public static int LOGINSTATE_SUCCESS = 1;//登陆成功
private String username;
private Date loginTime;
private String ip;
private int loginState;
private int loginType;
private Long loginInfoId;
public String getDisplayState(){
return this.loginState==LOGINSTATE_FAILD?"登录失败":"登录成功";
}
public IpLog() {
super();
}
public IpLog(String username, Date loginTime, String ip, int loginType,
Long loginInfoId) {
super();
this.username = username;
this.loginTime = loginTime;
this.ip = ip;
this.loginState = IpLog.LOGINSTATE_FAILD;
this.loginType = loginType;
this.loginInfoId = loginInfoId;
}
}

View File

@ -1,4 +1,4 @@
package com.geekq.common.entity;
package com.geekq.admin.entity;
import com.geekq.common.enums.Constants;
import lombok.AllArgsConstructor;
@ -12,7 +12,7 @@ import java.util.Date;
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class MiaoshaUser {
public class Logininfo {
private Long id;
private String nickname;

View File

@ -0,0 +1,34 @@
package com.geekq.admin.entity;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.Setter;
import org.apache.ibatis.type.Alias;
import java.util.HashMap;
import java.util.Map;
/**
* 数据字典
*
* @author Stef
*
*/
@Getter
@Setter
@Alias("SystemDictionary")
public class SystemDictionary extends BaseDomain {
private static final long serialVersionUID = 3382007784095246946L;
private String sn; // 编码
private String title; // 名称
private String intro; // 简介
public String getJsonString() {
Map<String, Object> m = new HashMap<>();
m.put("id", getId());
m.put("sn", sn);
m.put("title", title);
m.put("intro", intro);
return JSONObject.toJSONString(m);
}
}

View File

@ -0,0 +1,38 @@
package com.geekq.admin.entity;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.Setter;
import org.apache.ibatis.type.Alias;
import java.util.HashMap;
import java.util.Map;
/**
* 数据字典明细
*
* @author Stef
*/
@Getter
@Setter
@Alias("SystemDictionaryItem")
public class SystemDictionaryItem extends BaseDomain {
private static final long serialVersionUID = 4520006109163647891L;
private Long parentId; // 系统目录
private String title; // 名称
private String tvalue; //
private Integer sequence; // 序列
private String intro; // 说明
public String getJsonString() {
Map<String, Object> m = new HashMap<>();
m.put("id", getId());
m.put("parentId", parentId);
m.put("title", title);
m.put("tvalue", tvalue);
m.put("sequence", sequence);
m.put("intro", intro);
return JSONObject.toJSONString(m);
}
}

View File

@ -0,0 +1,217 @@
package com.geekq.admin.entity;
import com.geekq.common.utils.numcal.BitStatesUtils;
import lombok.Getter;
import lombok.Setter;
import org.apache.ibatis.type.Alias;
import org.springframework.util.StringUtils;
/**
* @author 邱润泽
*/
@Getter
@Setter
@Alias("UserInfo")
public class Userinfo extends BaseDomain {
private static final long serialVersionUID = -2194938919842714855L;
/**
* 版本号
*/
private int version;
/**
* 位状态
*/
private Long bitState = 0L;
/**
* 对应实名认证中的真实姓名
*/
private String realName;
/**
* 对应实名认证中的身份证号
*/
private String idNumber;
/**
* 用户邮箱
*/
private String email;
/**
* 手机号
*/
private String phoneNumber = "";
/**
* 用户当前认证分数
*/
private int authScore = 0;
/**
* 用户有效的实名认证对象
*/
private Long realauthId;
/**
* 会员的基本资料
* 月收入
*/
private SystemDictionaryItem incomeGrade;
/**
* 婚姻情况
*/
private SystemDictionaryItem marriage;
/**
* 子女情况
*/
private SystemDictionaryItem kidCount;
/**
* 学历
*/
private SystemDictionaryItem educationBackground;
/**
* 住房条件
*/
private SystemDictionaryItem houseCondition;
public static Userinfo empty(Long id) {
Userinfo userinfo = new Userinfo();
userinfo.setId(id);
userinfo.setBitState(BitStatesUtils.OP_BASIC_INFO);
return userinfo;
}
public void addState(Long state) {
this.bitState = BitStatesUtils.addState(this.bitState, state);
}
public void removeState(Long state) {
this.bitState = BitStatesUtils.removeState(this.bitState, state);
}
public boolean getIsBindPhone() {
return BitStatesUtils.hasState(bitState, BitStatesUtils.OP_BIND_PHONE);
}
public boolean getIsBindEmail() {
return BitStatesUtils.hasState(bitState, BitStatesUtils.OP_BIND_EMAIL);
}
public boolean getBaseInfo() {
return BitStatesUtils.hasState(bitState, BitStatesUtils.OP_BASE_INFO);
}
public boolean getRealAuth() {
return BitStatesUtils.hasState(bitState, BitStatesUtils.OP_REAL_AUTH);
}
public boolean getVedioAuth() {
return BitStatesUtils.hasState(bitState, BitStatesUtils.OP_VEDIO_AUTH);
}
public boolean getHasBidRequest(){
return BitStatesUtils.hasState(bitState, BitStatesUtils.OP_HAS_BIDRQUEST);
}
/**
* 获取用户真实名字的隐藏字符串只显示姓氏
*
* @param 真实名字
* @return
*/
public String getAnonymousRealName() {
if (StringUtils.hasLength(realName)) {
int len = realName.length();
String replace = "";
replace += realName.charAt(0);
for (int i = 1; i < len; i++) {
replace += "*";
}
return replace;
}
return realName;
}
/**
* 获取用户真实名字的隐藏字符串只显示姓氏
*
* @param realName
* 真实名字
* @return
*/
public static String getAnonymousRealName(String realName) {
if (StringUtils.hasLength(realName)) {
int len = realName.length();
String replace = "";
replace += realName.charAt(0);
for (int i = 1; i < len; i++) {
replace += "*";
}
return replace;
}
return realName;
}
/**
* 获取用户身份号码的隐藏字符串
*
* @param idNumber
* @return
*/
public static String getAnonymousIdNumber(String idNumber) {
if (StringUtils.hasLength(idNumber)) {
int len = idNumber.length();
String replace = "";
for (int i = 0; i < len; i++) {
if ((i > 5 && i < 10) || (i > len - 5)) {
replace += "*";
} else {
replace += idNumber.charAt(i);
}
}
return replace;
}
return idNumber;
}
/**
* 获取用户手机号码的隐藏字符串
*
* @param phoneNumber
* 用户手机号码
* @return
*/
public static String getAnonymousPhoneNumber(String phoneNumber) {
if (StringUtils.hasLength(phoneNumber)) {
int len = phoneNumber.length();
String replace = "";
for (int i = 0; i < len; i++) {
if (i > 2 && i < 7) {
replace += "*";
} else {
replace += phoneNumber.charAt(i);
}
}
return replace;
}
return phoneNumber;
}
/**
* 获取用户住址的隐藏字符串
*
* @param currentAddress
* 用户住址
* @return
*/
public static String getAnonymousCurrentAddress(String currentAddress) {
if (StringUtils.hasLength(currentAddress)
&& currentAddress.length() > 4) {
String last = currentAddress.substring(currentAddress.length() - 4,
currentAddress.length());
String stars = "";
for (int i = 0; i < currentAddress.length() - 4; i++) {
stars += "*";
}
return stars + last;
}
return currentAddress;
}
}

View File

@ -1,4 +1,4 @@
package com.geekq.order.pojo;
package com.geekq.admin.pojo;
public class Orders {
private String id;

View File

@ -1,4 +1,4 @@
package com.geekq.order.pojo;
package com.geekq.admin.pojo;
import java.util.ArrayList;
import java.util.List;

View File

@ -0,0 +1,43 @@
package com.geekq.admin.query;
import com.geekq.common.utils.DateUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* IpLog查询对象
* @author 邱润泽
*
*/
@Setter
@Getter
public class IpLogQueryObject extends QueryObject {
private Date beginDate;
private Date endDate;
private String username;
private int userType=-1;
private boolean like;
private int state=-1;
@DateTimeFormat(pattern = "yyyy-MM-dd")
public void setBeginDate(Date beginDate) {
this.beginDate = beginDate;
}
@DateTimeFormat(pattern = "yyyy-MM-dd")
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public Date getEndDate() {
if (endDate != null) {
return DateUtil.endOfDay(endDate);
}
return null;
}
}

View File

@ -0,0 +1,66 @@
package com.geekq.admin.query;
import java.util.ArrayList;
import java.util.List;
public class PageResult {
private Integer totalCount;
private Integer pageSize = 10;
private Integer currentPage = 1;
private List result;
public PageResult() {
}
public static PageResult empty(int pageSize) {
return new PageResult(0, pageSize, 1, new ArrayList());
}
public PageResult(Integer totalCount, Integer pageSize,
Integer currentPage, List result) {
super();
this.totalCount = totalCount;
this.pageSize = pageSize;
this.currentPage = currentPage;
this.result = result;
}
public Integer getTotalPage() {
return Math.max((totalCount + pageSize - 1) / pageSize, 1);
}
public Integer getPrev() {
return Math.max(currentPage - 1, 1);
}
public Integer getNext() {
return Math.min(currentPage + 1, getTotalPage());
}
public Integer getTotalCount() {
return totalCount;
}
public List getResult() {
return result;
}
public Integer getCurrentPage() {
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
this.currentPage = currentPage;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}

View File

@ -0,0 +1,18 @@
package com.geekq.admin.query;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class QueryObject {
private Integer currentPage = 1;
private Integer pageSize = 10;
public int getStart() {
return (currentPage - 1) * pageSize;
}
}

View File

@ -0,0 +1,16 @@
package com.geekq.admin.query;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;
@Getter
@Setter
public class SystemDictionaryQueryObject extends QueryObject {
private String keyword;
private Long parentId;
public String getKeyword() {
return StringUtils.hasLength(keyword) ? keyword : null;
}
}

View File

@ -0,0 +1,13 @@
package com.geekq.admin.service;
import com.geekq.admin.entity.IpLog;
import com.geekq.admin.query.IpLogQueryObject;
import com.geekq.admin.query.PageResult;
public interface IIpLogService {
PageResult query(IpLogQueryObject qo);
void insert(IpLog ipLog);
}

View File

@ -1,18 +1,19 @@
package com.geekq.order.service;
package com.geekq.admin.service;
import com.geekq.common.entity.MiaoshaUser;
import com.geekq.admin.entity.Logininfo;
import com.geekq.common.utils.resultbean.ResultGeekQ;
import java.util.List;
import java.util.Map;
public interface MiaoShaUserService {
public interface ILogininfoService {
/**
* 注册
* @param username
* @param password
*/
void register(String username, String password);
ResultGeekQ<Boolean> register(String username, String password);
/**
* 检查是否有重复的用户名
@ -25,7 +26,7 @@ public interface MiaoShaUserService {
* @param password
* @return
*/
MiaoshaUser login(String name, String password, int userType, String ip);
Logininfo login(String name, String password, int userType, String ip);
/**
* 是否有管理员

View File

@ -0,0 +1,24 @@
package com.geekq.admin.service;
import com.geekq.admin.entity.SystemDictionary;
import com.geekq.admin.entity.SystemDictionaryItem;
import com.geekq.admin.query.PageResult;
import com.geekq.admin.query.SystemDictionaryQueryObject;
import java.util.List;
public interface ISystemDictionaryService {
PageResult queryDic(SystemDictionaryQueryObject qo);
void saveOrUpdate(SystemDictionary sd);
PageResult queryDicItem(SystemDictionaryQueryObject qo);
void saveOrUpdateItem(SystemDictionaryItem item);
List<SystemDictionary> listDics();
List<SystemDictionaryItem> queryBySn(String sn);
}

View File

@ -1,6 +1,6 @@
package com.geekq.order.service;
package com.geekq.admin.service;
import com.geekq.order.pojo.Orders;
import com.geekq.admin.pojo.Orders;
public interface OrdersService {

View File

@ -0,0 +1,22 @@
package com.geekq.admin.mapper;
import com.geekq.admin.entity.IpLog;
import com.geekq.admin.query.IpLogQueryObject;
import java.util.List;
public interface IpLogMapper {
int deleteByPrimaryKey(Long id);
int insert(IpLog record);
IpLog selectByPrimaryKey(Long id);
List<IpLog> selectAll();
int updateByPrimaryKey(IpLog record);
int queryForCount(IpLogQueryObject qo);
List<IpLog> query(IpLogQueryObject qo);
}

View File

@ -0,0 +1,91 @@
<?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.geekq.admin.mapper.IpLogMapper" >
<resultMap id="BaseResultMap" type="IpLog" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="ip" property="ip" jdbcType="VARCHAR" />
<result column="loginState" property="loginState" jdbcType="TINYINT" />
<result column="username" property="username" jdbcType="VARCHAR" />
<result column="loginInfoId" property="loginInfoId" jdbcType="BIGINT" />
<result column="loginType" property="loginType" jdbcType="TINYINT" />
<result column="loginTime" property="loginTime" jdbcType="TIMESTAMP" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from iplog
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="IpLog" useGeneratedKeys="true" keyProperty="id" >
insert into iplog (ip, loginState, username,
loginInfoId, loginType, loginTime)
values (#{ip,jdbcType=VARCHAR}, #{loginState,jdbcType=TINYINT}, #{username,jdbcType=VARCHAR},
#{loginInfoId,jdbcType=BIGINT}, #{loginType,jdbcType=TINYINT}, #{loginTime,jdbcType=TIMESTAMP})
</insert>
<update id="updateByPrimaryKey" parameterType="IpLog" >
update iplog
set ip = #{ip,jdbcType=VARCHAR},
loginState = #{loginState,jdbcType=TINYINT},
username = #{username,jdbcType=VARCHAR},
loginInfoId = #{loginInfoId,jdbcType=BIGINT},
loginType = #{loginType,jdbcType=TINYINT},
loginTime = #{loginTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<sql id="base_column">
id, ip, loginState, username, loginInfoId, loginType, loginTime
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select <include refid="base_column" />
from iplog
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectAll" resultMap="BaseResultMap" >
select <include refid="base_column" />
from iplog
</select>
<sql id="base_query">
<where>
<if test="beginDate!=null">
AND loginTime &gt;=#{beginDate}
</if>
<if test="endDate!=null">
AND loginTime &lt;=#{endDate}
</if>
<if test="username!=null and like">
AND username like concat('%',#{username},'%')
</if>
<if test="username!=null and !like">
AND username =#{username}
</if>
<if test="userType>-1">
AND loginType =#{userType}
</if>
<if test="state >-1">
AND loginstate = #{state}
</if>
</where>
</sql>
<select id="queryForCount" resultType="int">
select count(id) from iplog
<include refid="base_query" />
</select>
<select id="query" resultMap="BaseResultMap">
select <include refid="base_column"/>
from iplog
<include refid="base_query" />
order by loginTime desc
<if test="pageSize >-1">
LIMIT #{start},#{pageSize}
</if>
</select>
</mapper>

View File

@ -0,0 +1,28 @@
package com.geekq.admin.mapper;
import com.geekq.admin.entity.Logininfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface LogininfoMapper {
int deleteByPrimaryKey(Long id);
int insert(Logininfo record);
Logininfo selectByPrimaryKey(Long id);
List<Logininfo> selectAll();
int updateByPrimaryKey(Logininfo record);
int getCountByUsername(@Param("username") String username,
@Param("userType") int userType);
Logininfo login(@Param("name") String name,
@Param("password") String password, @Param("userType") int userType);
List<Map<String, Object>> autoComplate(@Param("word") String word, @Param("userType") int userType);
}

View File

@ -0,0 +1,59 @@
<?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.geekq.admin.mapper.LogininfoMapper">
<!--<cache type="redis" />-->
<resultMap id="BaseResultMap" type="com.geekq.admin.entity.Logininfo">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="nickname" jdbcType="VARCHAR" property="nickname" />
<result column="password" jdbcType="VARCHAR" property="password" />
<result column="state" jdbcType="TINYINT" property="state" />
<result column="admin" property="admin" />
<result column="usertype" property="userType" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from
logininfo
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" keyProperty="id" parameterType="com.geekq.admin.entity.Logininfo" useGeneratedKeys="true">
insert into logininfo (username,password, state,usertype,admin)
values (#{username,jdbcType=VARCHAR},#{password,jdbcType=VARCHAR},#{state,jdbcType=TINYINT},#{userType},#{admin})
</insert>
<update id="updateByPrimaryKey" parameterType="com.geekq.admin.entity.Logininfo">
update logininfo set username = #{username,jdbcType=VARCHAR},password =#{password,jdbcType=VARCHAR},
state = #{state,jdbcType=TINYINT},usertype = #{userType},admin=#{admin}
where id = #{id,jdbcType=BIGINT}
</update>
<sql id="base_column">
id, username, password, state,usertype,admin
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap" useCache="true">
select <include refid="base_column" />
from logininfo where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectAll" resultMap="BaseResultMap" useCache="false">
select <include refid="base_column" />
from logininfo
</select>
<select id="getCountByUsername" resultType="int" useCache="false">
select count(id) from logininfo where username=#{username} and usertype = #{userType}
</select>
<select id="login" resultMap="BaseResultMap" useCache="true">
select <include refid="base_column"/>
from logininfo where username= #{name} and password=#{password} and usertype=#{userType}
</select>
<select id="autoComplate" resultType="hashmap" useCache="false">
select id,username as name
from logininfo where username LIKE concat(#{word},'%') AND usertype = #{userType}
</select>
</mapper>

View File

@ -1,11 +1,11 @@
package com.geekq.order.mapper;
package com.geekq.admin.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.geekq.order.pojo.Orders;
import com.geekq.order.pojo.OrdersExample;
import com.geekq.admin.pojo.Orders;
import com.geekq.admin.pojo.OrdersExample;
public interface OrdersMapper {
int countByExample(OrdersExample example);

View File

@ -1,7 +1,7 @@
<?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.geekq.order.mapper.OrdersMapper" >
<resultMap id="BaseResultMap" type="com.geekq.order.pojo.Orders" >
<mapper namespace="com.geekq.admin.mapper.OrdersMapper" >
<resultMap id="BaseResultMap" type="com.geekq.admin.pojo.Orders" >
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="order_num" property="orderNum" jdbcType="VARCHAR" />
<result column="item_id" property="itemId" jdbcType="VARCHAR" />
@ -67,7 +67,7 @@
<sql id="Base_Column_List" >
id, order_num, item_id
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.geekq.order.pojo.OrdersExample" >
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.geekq.admin.pojo.OrdersExample" >
select
<if test="distinct" >
distinct
@ -91,19 +91,19 @@
delete from orders
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.geekq.order.pojo.OrdersExample" >
<delete id="deleteByExample" parameterType="com.geekq.admin.pojo.OrdersExample" >
delete from orders
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.geekq.order.pojo.Orders" >
<insert id="insert" parameterType="com.geekq.admin.pojo.Orders" >
insert into orders (id, order_num, item_id
)
values (#{id,jdbcType=VARCHAR}, #{orderNum,jdbcType=VARCHAR}, #{itemId,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.geekq.order.pojo.Orders" >
<insert id="insertSelective" parameterType="com.geekq.admin.pojo.Orders" >
insert into orders
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
@ -128,7 +128,7 @@
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.geekq.order.pojo.OrdersExample" resultType="java.lang.Integer" >
<select id="countByExample" parameterType="com.geekq.admin.pojo.OrdersExample" resultType="java.lang.Integer" >
select count(*) from orders
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
@ -160,7 +160,7 @@
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.geekq.order.pojo.Orders" >
<update id="updateByPrimaryKeySelective" parameterType="com.geekq.admin.pojo.Orders" >
update orders
<set >
<if test="orderNum != null" >
@ -172,7 +172,7 @@
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.geekq.order.pojo.Orders" >
<update id="updateByPrimaryKey" parameterType="com.geekq.admin.pojo.Orders" >
update orders
set order_num = #{orderNum,jdbcType=VARCHAR},
item_id = #{itemId,jdbcType=VARCHAR}

View File

@ -0,0 +1,31 @@
package com.geekq.admin.mapper;
import com.geekq.admin.entity.SystemDictionaryItem;
import com.geekq.admin.query.SystemDictionaryQueryObject;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface SystemDictionaryItemMapper {
int deleteByPrimaryKey(Long id);
int insert(SystemDictionaryItem record);
SystemDictionaryItem selectByPrimaryKey(Long id);
List<SystemDictionaryItem> selectAll();
int updateByPrimaryKey(SystemDictionaryItem record);
int queryForCount(SystemDictionaryQueryObject qo);
List<SystemDictionaryItem> query(SystemDictionaryQueryObject qo);
/**
* 按照数据字典的目录sn查所有明细
* @param sn
* @return
*/
List<SystemDictionaryItem> queryBySn(@Param("sn") String sn);
}

View File

@ -0,0 +1,88 @@
<?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.geekq.admin.mapper.SystemDictionaryItemMapper">
<resultMap id="BaseResultMap" type="SystemDictionaryItem">
<id column="id" property="id" jdbcType="BIGINT" />
<result column="parentId" property="parentId" jdbcType="BIGINT" />
<result column="title" property="title" jdbcType="VARCHAR" />
<result column="tvalue" property="tvalue" jdbcType="VARCHAR" />
<result column="sequence" property="sequence" jdbcType="TINYINT" />
<result column="intro" property="intro" jdbcType="VARCHAR" />
</resultMap>
<resultMap type="SystemDictionaryItem" id="small_result">
<id column="id" property="id" jdbcType="BIGINT" />
<result column="title" property="title" jdbcType="VARCHAR" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from systemdictionaryitem
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="SystemDictionaryItem"
useGeneratedKeys="true" keyProperty="id">
insert into systemdictionaryitem (parentId, title, tvalue,sequence, intro)
values (#{parentId,jdbcType=BIGINT}, #{title,jdbcType=VARCHAR},#{tvalue,jdbcType=VARCHAR},
#{sequence,jdbcType=TINYINT}, #{intro,jdbcType=VARCHAR})
</insert>
<update id="updateByPrimaryKey" parameterType="SystemDictionaryItem">
update systemdictionaryitem
set parentId = #{parentId,jdbcType=BIGINT},
title = #{title,jdbcType=VARCHAR},
tvalue = #{tvalue,jdbcType=VARCHAR},
sequence = #{sequence,jdbcType=TINYINT},
intro = #{intro,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<sql id="base_column">
id, parentId, title, tvalue, sequence, intro
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
parameterType="java.lang.Long">
select <include refid="base_column" />
from systemdictionaryitem
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select <include refid="base_column" />
from systemdictionaryitem
</select>
<sql id="base_where">
<where>
<if test="parentId!=null">
AND parentId = #{parentId}
</if>
<if test="keyword!=null">
AND title LIKE concat('%',#{keyword},'%')
</if>
</where>
</sql>
<select id="queryForCount" resultType="int">
select count(id) from systemdictionaryitem
<include refid="base_where" />
</select>
<select id="query" resultMap="BaseResultMap">
select <include refid="base_column" />
from systemdictionaryitem
<include refid="base_where" />
<if test="pageSize>-1">
LIMIT #{start},#{pageSize}
</if>
</select>
<select id="queryBySn" resultMap="small_result">
select item.id as id,item.title as title
from systemdictionaryitem item join systemdictionary d on item.parentId = d.id
where d.sn = #{sn}
order by item.sequence
</select>
</mapper>

View File

@ -0,0 +1,26 @@
package com.geekq.admin.mapper;
import com.geekq.admin.entity.SystemDictionary;
import com.geekq.admin.query.SystemDictionaryQueryObject;
import java.util.List;
public interface SystemDictionaryMapper {
int deleteByPrimaryKey(Long id);
int insert(SystemDictionary record);
SystemDictionary selectByPrimaryKey(Long id);
List<SystemDictionary> selectAll();
int updateByPrimaryKey(SystemDictionary record);
int queryForCount(SystemDictionaryQueryObject qo);
List<SystemDictionary> query(SystemDictionaryQueryObject qo);
}

View File

@ -0,0 +1,66 @@
<?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.geekq.admin.mapper.SystemDictionaryMapper" >
<resultMap id="BaseResultMap" type="SystemDictionary" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="sn" property="sn" jdbcType="VARCHAR" />
<result column="title" property="title" jdbcType="VARCHAR" />
<result column="intro" property="intro" jdbcType="VARCHAR" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from systemdictionary
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="SystemDictionary" useGeneratedKeys="true" keyProperty="id" >
insert into systemdictionary (sn, title, intro)
values (#{sn,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{intro,jdbcType=VARCHAR} )
</insert>
<update id="updateByPrimaryKey" parameterType="SystemDictionary" >
update systemdictionary
set sn = #{sn,jdbcType=VARCHAR},
title = #{title,jdbcType=VARCHAR},
intro = #{intro,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<sql id="base_column">
id, sn, title, intro
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select <include refid="base_column" />
from systemdictionary
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectAll" resultMap="BaseResultMap" >
select <include refid="base_column" />
from systemdictionary
</select>
<sql id="base_where">
<where>
<if test="keyword!=null">
AND (sn LIKE concat('%',#{keyword},'%') OR title LIKE concat('%',#{keyword},'%'))
</if>
</where>
</sql>
<select id="queryForCount" resultType="int">
select count(id) from systemdictionary
<include refid="base_where" />
</select>
<select id="query" resultMap="BaseResultMap">
select <include refid="base_column" />
from systemdictionary
<include refid="base_where" />
<if test="pageSize>-1">
LIMIT #{start},#{pageSize}
</if>
</select>
</mapper>

View File

@ -0,0 +1,18 @@
package com.geekq.admin.mapper;
import com.geekq.admin.entity.Userinfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface UserinfoMapper {
int deleteByPrimaryKey(Long id);
int insert(Userinfo record);
Userinfo selectByPrimaryKey(@Param("id") Long id, @Param("salt") String salt);
List<Userinfo> selectAll(@Param("salt") String salt);
int updateByPrimaryKey(@Param("ui") Userinfo record, @Param("salt") String salt);
}

View File

@ -0,0 +1,70 @@
<?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.geekq.admin.mapper.UserinfoMapper" >
<resultMap id="BaseResultMap" type="com.geekq.admin.entity.Userinfo" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="version" property="version" jdbcType="INTEGER" />
<result column="bitState" property="bitState" jdbcType="BIGINT" />
<result column="realName" property="realName" jdbcType="VARCHAR" />
<result column="idNumber" property="idNumber" jdbcType="VARCHAR" />
<result column="phoneNumber" property="phoneNumber" jdbcType="VARCHAR" />
<result column="authScore" property="authScore"/>
<result column="email" property="email"/>
<result column="realauthId" property="realauthId"/>
<association property="incomeGrade" javaType="SystemDictionaryItem" column="incomeGrade_id" select="com.geekq.admin.mapper.SystemDictionaryItemMapper.selectByPrimaryKey" />
<association property="marriage" javaType="SystemDictionaryItem" column="marriage_id" select="com.geekq.admin.mapper.SystemDictionaryItemMapper.selectByPrimaryKey" />
<association property="kidCount" javaType="SystemDictionaryItem" column="kidCount_id" select="com.geekq.admin.mapper.SystemDictionaryItemMapper.selectByPrimaryKey" />
<association property="educationBackground" javaType="SystemDictionaryItem" column="educationBackground_id" select="com.geekq.admin.mapper.SystemDictionaryItemMapper.selectByPrimaryKey" />
<association property="houseCondition" javaType="SystemDictionaryItem" column="houseCondition_id" select="com.geekq.admin.mapper.SystemDictionaryItemMapper.selectByPrimaryKey" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from userinfo
where id = #{id,jdbcType=BIGINT} and version = #{version}
</delete>
<insert id="insert" parameterType="com.geekq.admin.entity.Userinfo" useGeneratedKeys="true" keyProperty="id" >
insert into userinfo (id,version, bitState, authScore,email,phoneNumber, incomeGrade_id,
marriage_id, kidCount_id, educationBackground_id, houseCondition_id)
values (#{id},0, #{bitState,jdbcType=BIGINT}, #{authScore},#{email},#{phoneNumber,jdbcType=VARCHAR}, #{incomeGrade.id,jdbcType=BIGINT},
#{marriage.id,jdbcType=BIGINT}, #{kidCount.id,jdbcType=BIGINT}, #{educationBackground.id,jdbcType=BIGINT},
#{houseCondition.id,jdbcType=BIGINT})
</insert>
<update id="updateByPrimaryKey" parameterType="com.geekq.admin.entity.Userinfo" >
update userinfo
set version = version+1,
bitState = #{ui.bitState,jdbcType=BIGINT},
realName = AES_ENCRYPT(#{ui.realName,jdbcType=VARCHAR},#{salt}),
idNumber = AES_ENCRYPT(#{ui.idNumber,jdbcType=VARCHAR},#{salt}),
authScore = #{ui.authScore},
email = #{ui.email},
realauthId=#{ui.realauthId},
phoneNumber = #{ui.phoneNumber,jdbcType=VARCHAR},
incomeGrade_id = #{ui.incomeGrade.id,jdbcType=BIGINT},
marriage_id = #{ui.marriage.id,jdbcType=BIGINT},
kidCount_id = #{ui.kidCount.id,jdbcType=BIGINT},
educationBackground_id = #{ui.educationBackground.id,jdbcType=BIGINT},
houseCondition_id = #{ui.houseCondition.id,jdbcType=BIGINT}
where id = #{ui.id,jdbcType=BIGINT} and version = #{ui.version}
</update>
<sql id="base_column">
id, version, bitState, AES_DECRYPT(realName,#{salt}) as realName, AES_DECRYPT(idNumber,#{salt}) as idNumber, phoneNumber,
incomeGrade_id, marriage_id, authScore,realauthId,email,kidCount_id, educationBackground_id, houseCondition_id
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select <include refid="base_column" />
from userinfo
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectAll" resultMap="BaseResultMap" >
select <include refid="base_column" />
from userinfo
</select>
</mapper>

View File

@ -0,0 +1,39 @@
package com.geekq.admin.service.impl;
import com.geekq.admin.entity.IpLog;
import com.geekq.admin.mapper.IpLogMapper;
import com.geekq.admin.query.IpLogQueryObject;
import com.geekq.admin.query.PageResult;
import com.geekq.admin.service.IIpLogService;
import com.geekq.common.utils.DBContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author 邱润泽
*/
@Service
public class IpLogServiceImpl implements IIpLogService {
@Autowired
private IpLogMapper ipLogMapper;
@Override
public PageResult query(IpLogQueryObject qo) {
DBContextUtil.setDB(DBContextUtil.DBREAD);
int count=this.ipLogMapper.queryForCount(qo);
if(count>0){
List<IpLog> list=this.ipLogMapper.query(qo);
return new PageResult(count, qo.getPageSize(),qo.getCurrentPage(),list);
}
return PageResult.empty(qo.getPageSize());
}
@Override
public void insert(IpLog ipLog) {
this.ipLogMapper.insert(ipLog);
}
}

View File

@ -0,0 +1,94 @@
package com.geekq.admin.service.impl;
import com.geekq.admin.entity.Logininfo;
import com.geekq.admin.entity.Userinfo;
import com.geekq.admin.mapper.IpLogMapper;
import com.geekq.admin.mapper.LogininfoMapper;
import com.geekq.admin.mapper.UserinfoMapper;
import com.geekq.admin.service.ILogininfoService;
import com.geekq.common.enums.Constants;
import com.geekq.common.enums.ResultStatus;
import com.geekq.common.utils.Constanst;
import com.geekq.common.utils.MD5.MD5Utils;
import com.geekq.common.utils.resultbean.ResultGeekQ;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author 邱润泽
*/
@Service
public class LogininfoServiceImpl implements ILogininfoService {
private static final Logger logger = LoggerFactory.getLogger(LogininfoServiceImpl.class);
@Autowired
private LogininfoMapper loginInfoMapper;
@Autowired
private IpLogMapper ipLogMapper;
@Autowired
private UserinfoMapper userinfoMapper;
@Override
public ResultGeekQ<Boolean> register(String username, String password) {
ResultGeekQ<Boolean> resultGeekQ = ResultGeekQ.build();
int count = loginInfoMapper.getCountByUsername(username, Constants.USERTYPE_NORMAL);
if(count > 0) {
try {
Logininfo logininfo =new Logininfo();
logininfo.setNickname(username);
//获取随机salt
String salt = MD5Utils.getSaltT();
//MD5(MD5(password)+salt)
logininfo.setPassword(MD5Utils.formPassToDBPass(password,salt));
logininfo.setState(Constants.STATE_NORMAL);
logininfo.setUserType(Constants.USERTYPE_NORMAL);
logininfo.setRegisterDate(new Date());
logininfo.setSalt(salt);
this.loginInfoMapper.insert(logininfo);
//初始化一个Userinfo
Userinfo userinfo = Userinfo.empty(logininfo.getId());
this.userinfoMapper.insert(userinfo);
} catch (Exception e) {
logger.error("注册失败!",e);
resultGeekQ.withError(ResultStatus.RESIGETER_FAIL);
}
}else{
resultGeekQ.withError(ResultStatus.RESIGETER_NICKNAMEEXIST);
}
return resultGeekQ;
}
@Override
public boolean checkUsername(String name, int userType) {
return this.loginInfoMapper.getCountByUsername(name, userType)<=0;
}
@Override
public Logininfo login(String name, String password, int userType, String ip) {
return null;
}
@Override
public boolean hasAdmin() {
return false;
}
@Override
public void createDefaultAdmin() {
}
@Override
public List<Map<String, Object>> autoComplate(String word, int userType) {
return null;
}
}

View File

@ -1,8 +1,8 @@
package com.geekq.order.service.impl;
package com.geekq.admin.service.impl;
import com.geekq.order.mapper.OrdersMapper;
import com.geekq.order.pojo.Orders;
import com.geekq.order.service.OrdersService;
import com.geekq.admin.mapper.OrdersMapper;
import com.geekq.admin.pojo.Orders;
import com.geekq.admin.service.OrdersService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -0,0 +1,77 @@
package com.geekq.admin.service.impl;
import com.geekq.admin.entity.SystemDictionary;
import com.geekq.admin.entity.SystemDictionaryItem;
import com.geekq.admin.mapper.SystemDictionaryItemMapper;
import com.geekq.admin.mapper.SystemDictionaryMapper;
import com.geekq.admin.query.PageResult;
import com.geekq.admin.query.SystemDictionaryQueryObject;
import com.geekq.admin.service.ISystemDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author 邱润泽
*/
@Service
public class SystemDictionaryServiceImpl implements ISystemDictionaryService {
@Autowired
private SystemDictionaryMapper systemDictionaryMapper;
@Autowired
private SystemDictionaryItemMapper systemDictionaryItemMapper;
@Override
public List<SystemDictionary> listDics() {
return systemDictionaryMapper.selectAll();
}
@Override
public PageResult queryDic(SystemDictionaryQueryObject qo) {
int count = this.systemDictionaryMapper.queryForCount(qo);
if (count > 0) {
List<SystemDictionary> list = this.systemDictionaryMapper.query(qo);
return new PageResult(count, qo.getPageSize(), qo.getCurrentPage(),
list);
}
return PageResult.empty(qo.getPageSize());
}
@Override
public void saveOrUpdate(SystemDictionary sd) {
if (sd.getId() != null) {
this.systemDictionaryMapper.updateByPrimaryKey(sd);
} else {
this.systemDictionaryMapper.insert(sd);
}
}
@Override
public PageResult queryDicItem(SystemDictionaryQueryObject qo) {
int count = this.systemDictionaryItemMapper.queryForCount(qo);
if (count > 0) {
List<SystemDictionaryItem> list = this.systemDictionaryItemMapper
.query(qo);
return new PageResult(count, qo.getPageSize(), qo.getCurrentPage(),
list);
}
return PageResult.empty(qo.getPageSize());
}
@Override
public void saveOrUpdateItem(SystemDictionaryItem item) {
if (item.getId() != null) {
this.systemDictionaryItemMapper.updateByPrimaryKey(item);
} else {
this.systemDictionaryItemMapper.insert(item);
}
}
@Override
public List<SystemDictionaryItem> queryBySn(String sn) {
return this.systemDictionaryItemMapper.queryBySn(sn);
}
}

View File

@ -36,11 +36,20 @@
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml"></property>
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 配置扫描包加载mapper代理对象 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.geekq.order.mapper"></property>
<property name="typeAliasesPackage"
value="com.geekq.admin.entity" />
<property name="mapperLocations"
value="classpath*:com/geekq/admin/mapper/*.xml" />
</bean>
<!--&lt;!&ndash; 配置自动扫描Mapper &ndash;&gt;-->
<!--<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">-->
<!--<property name="basePackage"-->
<!--value="com.eloan.base.mapper;com.eloan.business.mapper" />-->
<!--</bean>-->
<!-- 配置扫描包加载mapper代理对象 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.geekq.admin.mapper"></property>
</bean>
</beans>

View File

@ -15,7 +15,7 @@
<dubbo:protocol name="dubbo" port="20881"></dubbo:protocol>
<!-- 暴露具体的服务接口 -->
<dubbo:service retries="3" interface="com.geekq.order.service.OrdersService"
<dubbo:service retries="3" interface="com.geekq.admin.service.OrdersService"
ref="ordersService" timeout="6000"></dubbo:service>
</beans>

View File

@ -12,10 +12,11 @@
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
<!-- 扫描包加载Service实现类 -->
<context:component-scan base-package="com.geekq.order.service"></context:component-scan>
<context:component-scan base-package="com.geekq.admin.service"></context:component-scan>
<!-- 自动创建代理 对@AspectJ注解的支持 -->
<!-- 通知spring使用cglib而不是jdk的来生成代理方法 AOP可以拦截到Service -->
<aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy>
</beans>

View File

@ -36,7 +36,7 @@
<!-- 切面 -->
<aop:config>
<aop:advisor advice-ref="txAdvice" pointcut="execution(* com.geekq.order.service..*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut="execution(* com.geekq.admin.service..*.*(..))" />
</aop:config>
</beans>

View File

@ -1,22 +1,35 @@
package com.geekq.web.controller;
import com.geekq.admin.service.ILogininfoService;
import com.geekq.common.enums.Constants;
import com.geekq.common.enums.ResultStatus;
import com.geekq.common.utils.resultbean.ResultGeekQ;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @author 邱润泽
*/
@Controller
public class RegisterController extends BaseController{
private static final Logger logger = LoggerFactory.getLogger(RegisterController.class);
@Autowired
private ILogininfoService logininfoService ;
@RequestMapping("/register")
@ResponseBody
public ResultGeekQ<Boolean> register(String username, String password) {
ResultGeekQ<Boolean> result = ResultGeekQ.build();
try {
} catch (RuntimeException e) {
}
return result;
/**
* 登录注册
*/
return logininfoService.register(username,password);
}
@RequestMapping("/checkUsername")
@ -24,7 +37,10 @@ public class RegisterController extends BaseController{
public ResultGeekQ<Boolean> checkUsername(String username) {
ResultGeekQ<Boolean> result = ResultGeekQ.build();
try {
result.setData(this.logininfoService.checkUsername(username, Constants.USERTYPE_NORMAL));
} catch (RuntimeException e) {
logger.error("检查是否存在该用户名!",e);
result.withError(ResultStatus.SYSTEM_ERROR);
}
return result;
}

View File

@ -5,7 +5,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.geekq.order.service.OrdersService;
import com.geekq.admin.service.OrdersService;
import com.geekq.web.service.CulsterService;
@Service("buyService")

View File

@ -14,7 +14,9 @@
<!--&lt;!&ndash; 监听服务,通过注册中心去进行查找,查找到后进行服务调用 &ndash;&gt;-->
<!--<dubbo:reference id="itemService" interface="com.imooc.item.service.ItemsService"-->
<!--retries="3" check="false" init="true"></dubbo:reference>-->
<dubbo:reference id="ordersService" interface="com.geekq.order.service.OrdersService"
<dubbo:reference id="ordersService" interface="com.geekq.admin.service.OrdersService"
retries="3" check="false" init="true"></dubbo:reference>
<dubbo:reference id="iLogininfoService" interface="com.geekq.admin.service.ILogininfoService"
retries="3" check="false" init="true"></dubbo:reference>
</beans>

View File

@ -47,7 +47,7 @@
<!--<property name="viewClass" value="org.springframework.web.servlet.view.InternalResourceView" />-->
<!--<property name="prefix" value="/WEB-INF/" />-->
<!--<property name="suffix" value=".html" />-->
<!--<property name="order" value="1" />-->
<!--<property name="admin" value="1" />-->
<!--</bean>-->

View File

@ -915,7 +915,7 @@ function addHandle( attrs, handler ) {
}
/**
* Checks document order of two siblings
* Checks document admin of two siblings
* @param {Element} a
* @param {Element} b
* @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
@ -1287,7 +1287,7 @@ setDocument = Sizzle.setDocument = function( node ) {
/* Sorting
---------------------------------------------------------------------- */
// Document order sorting
// Document admin sorting
sortOrder = hasCompare ?
function( a, b ) {
@ -1322,7 +1322,7 @@ setDocument = Sizzle.setDocument = function( node ) {
return 1;
}
// Maintain original order
// Maintain original admin
return sortInput ?
( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
0;
@ -3011,7 +3011,7 @@ jQuery.each({
jQuery.unique( matched );
}
// Reverse order for parents* and prev-derivatives
// Reverse admin for parents* and prev-derivatives
if ( rparentsprev.test( name ) ) {
matched.reverse();
}
@ -8030,7 +8030,7 @@ jQuery.extend({
// Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
// A cross-domain request is in order when we have a protocol:host:port mismatch
// A cross-domain request is in admin when we have a protocol:host:port mismatch
if ( s.crossDomain == null ) {
parts = rurl.exec( s.url.toLowerCase() );
s.crossDomain = !!( parts &&

View File

@ -86,7 +86,7 @@ $.widget("ui.accordion", {
.next()
.hide();
// make sure at least one header is in the tab order
// make sure at least one header is in the tab admin
if (!this.active.length) {
this.headers.eq(0).attr('tabIndex','0');
} else {

View File

@ -1150,7 +1150,7 @@ $.extend($.validator, {
// http://docs.jquery.com/Plugins/Validation/Methods/equalTo
equalTo: function( value, element, param ) {
// bind to the blur event of the target in order to revalidate whenever the target field is updated
// bind to the blur event of the target in admin to revalidate whenever the target field is updated
// TODO find a way to bind the event just once, avoiding the unbind-rebind overhead
var target = $(param);
if ( this.settings.onfocusout ) {

View File

@ -1502,7 +1502,7 @@ jQuery.extend({
thisCache = cache[ id ];
// Internal jQuery data is stored in a separate object inside the object's data
// cache in order to avoid key collisions between internal data and user-defined
// cache in admin to avoid key collisions between internal data and user-defined
// data
if ( pvt ) {
if ( !thisCache[ internalKey ] ) {
@ -1757,7 +1757,7 @@ function dataAttr( elem, key, data ) {
// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
// property to be considered empty objects; this property always exists in
// order to make sure JSON.stringify does not expose internal metadata
// admin to make sure JSON.stringify does not expose internal metadata
function isEmptyDataObject( obj ) {
for ( var name in obj ) {
if ( name !== "toJSON" ) {
@ -6076,7 +6076,7 @@ jQuery.extend({
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
// IE copies events bound via attachEvent when using cloneNode.
// Calling detachEvent on the clone will also remove the events
// from the original. In order to get around this, we use some
// from the original. In admin to get around this, we use some
// proprietary methods to clear the events. Thanks to MooTools
// guys for this hotness.
@ -7300,7 +7300,7 @@ jQuery.extend({
// Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
// Determine if a cross-domain request is in order
// Determine if a cross-domain request is in admin
if ( s.crossDomain == null ) {
parts = rurl.exec( s.url.toLowerCase() );
s.crossDomain = !!( parts &&

View File

@ -1751,7 +1751,7 @@ jQuery.extend({
privateCache = thisCache = cache[ id ];
// jQuery data() is stored in a separate object inside the object's internal data
// cache in order to avoid key collisions between internal data and user-defined
// cache in admin to avoid key collisions between internal data and user-defined
// data.
if ( !pvt ) {
if ( !thisCache.data ) {
@ -6321,7 +6321,7 @@ jQuery.extend({
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
// IE copies events bound via attachEvent when using cloneNode.
// Calling detachEvent on the clone will also remove the events
// from the original. In order to get around this, we use some
// from the original. In admin to get around this, we use some
// proprietary methods to clear the events. Thanks to MooTools
// guys for this hotness.
@ -6562,7 +6562,7 @@ var ralpha = /alpha\([^)]*\)/i,
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
// order is important!
// admin is important!
cssExpand = [ "Top", "Right", "Bottom", "Left" ],
curCSS,
@ -7591,7 +7591,7 @@ jQuery.extend({
// Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
// Determine if a cross-domain request is in order
// Determine if a cross-domain request is in admin
if ( s.crossDomain == null ) {
parts = rurl.exec( s.url.toLowerCase() );
s.crossDomain = !!( parts &&

View File

@ -1595,7 +1595,7 @@ jQuery.extend({
thisCache = cache[ id ];
// jQuery data() is stored in a separate object inside the object's internal data
// cache in order to avoid key collisions between internal data and user-defined
// cache in admin to avoid key collisions between internal data and user-defined
// data.
if ( !pvt ) {
if ( !thisCache.data ) {
@ -6244,7 +6244,7 @@ jQuery.extend({
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
// IE copies events bound via attachEvent when using cloneNode.
// Calling detachEvent on the clone will also remove the events
// from the original. In order to get around this, we use some
// from the original. In admin to get around this, we use some
// proprietary methods to clear the events. Thanks to MooTools
// guys for this hotness.
@ -7856,7 +7856,7 @@ jQuery.extend({
// Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
// A cross-domain request is in order when we have a protocol:host:port mismatch
// A cross-domain request is in admin when we have a protocol:host:port mismatch
if ( s.crossDomain == null ) {
parts = rurl.exec( s.url.toLowerCase() );
s.crossDomain = !!( parts &&

View File

@ -1582,7 +1582,7 @@ function internalData( elem, name, data, pvt /* Internal Use Only */ ){
thisCache = cache[ id ];
// jQuery data() is stored in a separate object inside the object's internal data
// cache in order to avoid key collisions between internal data and user-defined
// cache in admin to avoid key collisions between internal data and user-defined
// data.
if ( !pvt ) {
if ( !thisCache.data ) {
@ -4257,7 +4257,7 @@ setDocument = Sizzle.setDocument = function( node ) {
return false;
};
// Document order sorting
// Document admin sorting
sortOrder = docElem.compareDocumentPosition ?
function( a, b ) {
var compare;
@ -7800,7 +7800,7 @@ jQuery.extend({
// Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( core_rnotwhite ) || [""];
// A cross-domain request is in order when we have a protocol:host:port mismatch
// A cross-domain request is in admin when we have a protocol:host:port mismatch
if ( s.crossDomain == null ) {
parts = rurl.exec( s.url.toLowerCase() );
s.crossDomain = !!( parts &&

View File

@ -50,7 +50,7 @@
ajax: function(origSettings) {
var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings),
mock = false;
// Iterate over our mock handlers (in registration order) until we find
// Iterate over our mock handlers (in registration admin) until we find
// one that is willing to intercept the request
$.each(mockHandlers, function(k, v) {
if ( !mockHandlers[k] ) {

View File

@ -7,7 +7,10 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>miaosha-common</artifactId>
<properties>
<org.mybatis.version>3.2.3</org.mybatis.version>
<org.springframework.version>4.0.0.RELEASE</org.springframework.version>
</properties>
<!-- jar包的依赖 -->
<dependencies>
<!-- Apache工具组件 -->
@ -71,7 +74,24 @@
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.7</version>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${org.mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- 日志处理 -->
<!--<dependency>-->
<!--<groupId>org.slf4j</groupId>-->

View File

@ -31,6 +31,7 @@ public enum ResultStatus {
RESIGETR_SUCCESS(20000,"注册成功!"),
RESIGETER_FAIL(200001,"注册失败!"),
CODE_FAIL(200002,"验证码不一致!"),
RESIGETER_NICKNAMEEXIST(200003,"用户名已经存在!"),
/**
* check

View File

@ -0,0 +1,18 @@
package com.geekq.common.utils;
public class DBContextUtil {
private static ThreadLocal<String> dbPools = new ThreadLocal<>();
public static final String DBMASTER = "dbmaster";
public static final String DBREAD = "dbread";
public static void setDB(String db) {
dbPools.set(db);
}
public static String getDB() {
return dbPools.get();
}
}

View File

@ -0,0 +1,19 @@
package com.geekq.common.utils;
import org.apache.commons.lang3.time.DateUtils;
import java.util.Calendar;
import java.util.Date;
public class DateUtil {
public static Date endOfDay(Date d) {
return DateUtils.addSeconds(
DateUtils.addDays(DateUtils.truncate(d, Calendar.DATE), 1), -1);
}
public static long getSecondsBetweenDates(Date d1, Date d2) {
return Math.abs((d1.getTime() - d2.getTime()) / 1000);
}
}

View File

@ -12,7 +12,7 @@ import java.util.Random;
public class MD5Utils {
private static final String getSaltT (){
public static final String getSaltT (){
SecureRandom random = new SecureRandom();
byte bytes[] = new byte[15];
random.nextBytes(bytes);

View File

@ -0,0 +1,72 @@
package com.geekq.common.utils.numcal;
import java.math.BigDecimal;
/**
* 系统需要的常量
* @author 邱润泽
*
*/
public class BidConst {
public static final int DISPLAY_SCALE = 2;//显示精度
public static final int CAL_SCALE = 8;//计算精度
public static final int STORE_SCALE = 4;//保存精度
public static final BigDecimal ZERO = new BigDecimal("0.0000");//系统中需要的zero
public static final BigDecimal DEFALUT_BORROWLIMITAMOUNT = new BigDecimal(
"2000.0000");//初始用户授信额度
public static final BigDecimal ACCOUNT_MANAGER_CHARGE_RATE=new BigDecimal("0.0500");
public static final String DEFAULT_ADMIN_NAME = "admin";
public static final String DEFAULT_ADMIN_PASSWORD = "1111";
public static final int CREDIT_BORROW_SCORE = 30;//信用信用分数
public final static int RETURN_TYPE_MONTH_INTEREST_PRINCIPAL = 0; // 还款方式 按月分期还款(等额本息)
public final static int RETURN_TYPE_MONTH_INTEREST = 1; // 还款方式 按月到期还款(每月还利息,到期还本息)
public final static int BIDREQUEST_TYPE_NORMAL = 0; // 普通信用标
public final static int BIDREQUEST_STATE_PUBLISH_PENDING = 0; // 待发布
public final static int BIDREQUEST_STATE_BIDDING = 1; // 招标中
public final static int BIDREQUEST_STATE_UNDO = 2; // 已撤销
public final static int BIDREQUEST_STATE_BIDDING_OVERDUE = 3; // 流标
public final static int BIDREQUEST_STATE_APPROVE_PENDING_1 = 4; // 满标1审
public final static int BIDREQUEST_STATE_APPROVE_PENDING_2 = 5; // 满标2审
public final static int BIDREQUEST_STATE_REJECTED = 6; // 满标审核被拒绝
public final static int BIDREQUEST_STATE_PAYING_BACK = 7; // 还款中
public final static int BIDREQUEST_STATE_COMPLETE_PAY_BACK = 8; // 已还清
public final static int BIDREQUEST_STATE_PAY_BACK_OVERDUE = 9; // 逾期
public final static int BIDREQUEST_STATE_PUBLISH_REFUSE = 10; // 发标审核拒绝状态
public static final BigDecimal SMALLEST_BID_AMOUNT = new BigDecimal("50.0000");//系统规定的最小投标金额
public static final BigDecimal SMALLEST_BIDREQUEST_AMOUNT = new BigDecimal("500.0000");//系统规定的最小借款金额
/**=============================账户流水类型================================ */
public final static int ACCOUNT_ACTIONTYPE_DEPOSIT_OFFLINE_LOCAL = 0;// 资金流水类别线下充值
public final static int ACCOUNT_ACTIONTYPE_WITHDRAW = 1;// 资金流水类别提现
public final static int ACCOUNT_ACTIONTYPE_BIDREQUEST_SUCCESSFUL = 2;// 资金流水类别成功借款
public final static int ACCOUNT_ACTIONTYPE_BID_SUCCESSFUL = 3;// 资金流水类别成功投标
public final static int ACCOUNT_ACTIONTYPE_RETURN_MONEY = 4;// 资金流水类别还款
public final static int ACCOUNT_ACTIONTYPE_CALLBACK_MONEY = 5;// 资金流水类别回款
public final static int ACCOUNT_ACTIONTYPE_CHARGE = 6;// 资金流水类别平台管理费
public final static int ACCOUNT_ACTIONTYPE_INTEREST_SHARE = 7;// 资金流水类别利息管理费
public final static int ACCOUNT_ACTIONTYPE_WITHDRAW_MANAGE_CHARGE = 8;// 资金流水类别提现手续费
public final static int ACCOUNT_ACTIONTYPE_RECHARGE_CHARGE = 9;// 资金流水类别充值手续费
public final static int ACCOUNT_ACTIONTYPE_BID_FREEZED = 10;// 资金流水类别投标冻结金额
public final static int ACCOUNT_ACTIONTYPE_BID_UNFREEZED = 11;// 资金流水类别取消投标冻结金额
public final static int ACCOUNT_ACTIONTYPE_WITHDRAW_FREEZED = 12;// 资金流水类别提现申请冻结金额
public final static int ACCOUNT_ACTIONTYPE_WITHDRAW_UNFREEZED = 13;// 资金流水类别:提现申请失败取消冻结金额
/**=========还款状态===============*/
public final static int PAYMENT_STATE_NORMAL = 0; //正常待还
public final static int PAYMENT_STATE_DONE = 1; //已还
public final static int PAYMENT_STATE_OVERDUE = 2; //逾期
/**============系统账户流水类型=============*/
public final static int SYSTEM_ACCOUNT_NONE = -1; //未指定
public final static int SYSTEM_ACCOUNT_ACTIONTYPE_MANAGE_CHARGE = 1;//系统账户收到账户管理费借款管理费
public final static int SYSTEM_ACCOUNT_ACTIONTYPE_INTREST_MANAGE_CHARGE = 2;//系统账户收到利息管理费
public final static int SYSTEM_ACCOUNT_ACTIONTYPE_WITHDRAW_MANAGE_CHARGE = 3;//系统账户收到提现手续费
}

View File

@ -0,0 +1,48 @@
package com.geekq.common.utils.numcal;
/**
* 用户状态类记录用户在平台使用系统中所有的状态
* @author 邱润泽
*/
public class BitStatesUtils {
public final static Long OP_BASIC_INFO = 1L; //用户注册成功的标示,及为默认初始状态
public final static Long OP_BIND_PHONE = 2L << 0; //用户绑定手机状态码
public final static Long OP_BIND_EMAIL = 2L << 1;//用户绑定邮箱
public final static Long OP_BASE_INFO = 2L << 2;//填写基本资料
public final static Long OP_REAL_AUTH = 2L << 3;//用户实名认证
public final static Long OP_VEDIO_AUTH = 2L << 4;//视频认证
public final static Long OP_HAS_BIDRQUEST=2l<<5;//当前用户有一个借款还在借款流程当中
/**
* @param states 所有状态值
* @param value 需要判断状态值
* @return 是否存在
*/
public static boolean hasState(long states, long value) {
return (states & value) != 0;
}
/**
* @param states 已有状态值
* @param value 需要添加状态值
* @return 新的状态值
*/
public static long addState(long states, long value) {
if (hasState(states, value)) {
return states;
}
return (states | value);
}
/**
* @param states 已有状态值
* @param value 需要删除状态值
* @return 新的状态值
*/
public static long removeState(long states, long value) {
if (!hasState(states, value)) {
return states;
}
return states ^ value;
}
}

View File

@ -0,0 +1,260 @@
package com.geekq.common.utils.numcal;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* 计算器Util
*
* @author 邱润泽
*
*/
public class CalculatetUtil {
public static final BigDecimal ONE_HUNDRED = new BigDecimal("100.0000");
public static final BigDecimal NUMBER_MONTHS_OF_YEAR = new BigDecimal(
"12.0000");
/**
* 获取月利率
*/
public static BigDecimal getMonthlyRate(BigDecimal yearRate) {
if (yearRate == null)
return BigDecimal.ZERO;
return yearRate.divide(ONE_HUNDRED).divide(NUMBER_MONTHS_OF_YEAR,
BidConst.CAL_SCALE, RoundingMode.HALF_UP);
}
/**
* 计算借款总利息
*
* @param returnType
* 还款类型
* @param bidRequestAmount
* 借款金额
* @param yearRate
* 年利率
* @param monthes2Return
* 还款期限
* @return
*/
public static BigDecimal calTotalInterest(int returnType,
BigDecimal bidRequestAmount, BigDecimal yearRate, int monthes2Return) {
BigDecimal totalInterest = BigDecimal.ZERO;
BigDecimal monthlyRate = getMonthlyRate(yearRate);
if (returnType == BidConst.RETURN_TYPE_MONTH_INTEREST_PRINCIPAL) {// 按月分期
// 只借款一个月
if (monthes2Return == 1) {
totalInterest = bidRequestAmount.multiply(monthlyRate)
.setScale(BidConst.CAL_SCALE, RoundingMode.HALF_UP);
} else {
BigDecimal temp1 = bidRequestAmount.multiply(monthlyRate);
BigDecimal temp2 = (BigDecimal.ONE.add(monthlyRate))
.pow(monthes2Return);
BigDecimal temp3 = (BigDecimal.ONE.add(monthlyRate)).pow(
monthes2Return).subtract(BigDecimal.ONE);
// 算出每月还款
BigDecimal monthToReturnMoney = temp1.multiply(temp2).divide(
temp3, BidConst.CAL_SCALE, RoundingMode.HALF_UP);
// 算出总还款
BigDecimal totalReturnMoney = monthToReturnMoney
.multiply(new BigDecimal(monthes2Return));
// 算出总利息
totalInterest = totalReturnMoney.subtract(bidRequestAmount);
}
} else if (returnType == BidConst.RETURN_TYPE_MONTH_INTEREST) {// 按月到期
BigDecimal monthlyInterest = DecimalFormatUtil
.amountFormat(bidRequestAmount.multiply(monthlyRate));
totalInterest = monthlyInterest.multiply(new BigDecimal(
monthes2Return));
}
return DecimalFormatUtil.formatBigDecimal(totalInterest,
BidConst.STORE_SCALE);
}
/**
* 计算每期利息
*
* @param returnType
* 还款类型
* @param bidRequestAmount
* 借款金额
* @param yearRate
* 年利率
* @param monthIndex
* 第几期
* @param monthes2Return
* 还款期限
* @return
*/
public static BigDecimal calMonthlyInterest(int returnType,
BigDecimal bidRequestAmount, BigDecimal yearRate, int monthIndex,
int monthes2Return) {
BigDecimal monthlyInterest = BigDecimal.ZERO;
BigDecimal monthlyRate = getMonthlyRate(yearRate);
if (returnType == BidConst.RETURN_TYPE_MONTH_INTEREST_PRINCIPAL) {// 按月分期
// 只借款一个月
if (monthes2Return == 1) {
monthlyInterest = bidRequestAmount.multiply(monthlyRate)
.setScale(BidConst.CAL_SCALE, RoundingMode.HALF_UP);
} else {
BigDecimal temp1 = bidRequestAmount.multiply(monthlyRate);
BigDecimal temp2 = (BigDecimal.ONE.add(monthlyRate))
.pow(monthes2Return);
BigDecimal temp3 = (BigDecimal.ONE.add(monthlyRate)).pow(
monthes2Return).subtract(BigDecimal.ONE);
BigDecimal temp4 = (BigDecimal.ONE.add(monthlyRate))
.pow(monthIndex - 1);
// 算出每月还款
BigDecimal monthToReturnMoney = temp1.multiply(temp2).divide(
temp3, BidConst.CAL_SCALE, RoundingMode.HALF_UP);
// 算出总还款
BigDecimal totalReturnMoney = monthToReturnMoney
.multiply(new BigDecimal(monthes2Return));
// 算出总利息
BigDecimal totalInterest = totalReturnMoney
.subtract(bidRequestAmount);
if (monthIndex < monthes2Return) {
monthlyInterest = (temp1.subtract(monthToReturnMoney))
.multiply(temp4).add(monthToReturnMoney)
.setScale(BidConst.CAL_SCALE, RoundingMode.HALF_UP);
} else if (monthIndex == monthes2Return) {
BigDecimal temp6 = BigDecimal.ZERO;
// 汇总最后一期之前所有利息之和
for (int i = 1; i < monthes2Return; i++) {
BigDecimal temp5 = (BigDecimal.ONE.add(monthlyRate))
.pow(i - 1);
monthlyInterest = (temp1.subtract(monthToReturnMoney))
.multiply(temp5)
.add(monthToReturnMoney)
.setScale(BidConst.CAL_SCALE,
RoundingMode.HALF_UP);
temp6 = temp6.add(monthlyInterest);
}
monthlyInterest = totalInterest.subtract(temp6);
}
}
} else if (returnType == BidConst.RETURN_TYPE_MONTH_INTEREST) {// 按月到期
monthlyInterest = DecimalFormatUtil.amountFormat(bidRequestAmount
.multiply(monthlyRate));
}
return monthlyInterest;
}
/**
* 计算每期还款
*
* @param returnType
* 还款类型
* @param bidRequestAmount
* 借款金额
* @param yearRate
* 年利率
* @param monthIndex
* 第几期
* @param monthes2Return
* 还款期限
* @return
*/
public static BigDecimal calMonthToReturnMoney(int returnType,
BigDecimal bidRequestAmount, BigDecimal yearRate, int monthIndex,
int monthes2Return) {
BigDecimal monthToReturnMoney = BigDecimal.ZERO;
BigDecimal monthlyRate = getMonthlyRate(yearRate);
if (returnType == BidConst.RETURN_TYPE_MONTH_INTEREST_PRINCIPAL) {// 按月分期
if (monthes2Return == 1) {
monthToReturnMoney = bidRequestAmount.add(
bidRequestAmount.multiply(monthlyRate)).setScale(
BidConst.CAL_SCALE, RoundingMode.HALF_UP);
} else {
BigDecimal temp1 = bidRequestAmount.multiply(monthlyRate);
BigDecimal temp2 = (BigDecimal.ONE.add(monthlyRate))
.pow(monthes2Return);
BigDecimal temp3 = (BigDecimal.ONE.add(monthlyRate)).pow(
monthes2Return).subtract(BigDecimal.ONE);
// 算出每月还款
monthToReturnMoney = temp1.multiply(temp2).divide(temp3,
BidConst.CAL_SCALE, RoundingMode.HALF_UP);
}
} else if (returnType == BidConst.RETURN_TYPE_MONTH_INTEREST) {// 按月到期
BigDecimal monthlyInterest = bidRequestAmount.multiply(monthlyRate)
.setScale(BidConst.CAL_SCALE, RoundingMode.HALF_UP);
if (monthIndex == monthes2Return) {
monthToReturnMoney = bidRequestAmount.add(monthlyInterest)
.setScale(BidConst.CAL_SCALE, RoundingMode.HALF_UP);
} else if (monthIndex < monthes2Return) {
monthToReturnMoney = monthlyInterest;
}
}
return DecimalFormatUtil.formatBigDecimal(monthToReturnMoney,
BidConst.STORE_SCALE);
}
/**
* 计算一次投标实际获得的利息=投标金额/借款金额 *总利息
*
* @param bidRequestAmount
* 借款金额
* @param monthes2Return
* 还款期数
* @param yearRate
* 年利率
* @param returnType
* 还款类型
* @param acturalBidAmount
* 投标金额
* @return
*/
public static BigDecimal calBidInterest(BigDecimal bidRequestAmount,
int monthes2Return, BigDecimal yearRate, int returnType,
BigDecimal acturalBidAmount) {
// 借款产生的总利息
BigDecimal totalInterest = calTotalInterest(returnType,
bidRequestAmount, yearRate, monthes2Return);
// 所占比例
BigDecimal proportion = acturalBidAmount.divide(bidRequestAmount,
BidConst.CAL_SCALE, RoundingMode.HALF_UP);
BigDecimal bidInterest = totalInterest.multiply(proportion);
return DecimalFormatUtil.formatBigDecimal(bidInterest,
BidConst.STORE_SCALE);
}
/**
* 计算利息管理费
*
* @param interest
* 利息
* @param interestManagerChargeRate
* 利息管理费比例
* @return
*/
/**
public static BigDecimal calInterestManagerCharge(BigDecimal interest) {
return DecimalFormatUtil.formatBigDecimal(
interest.multiply(BidConst.INTEREST_MANAGER_CHARGE_RATE), BidConst.SCALE);
}
*/
/**
* 计算借款管理费
*
* @param bidRequestAmount
* 借款金额
* @param returnType
* 还款类型
* @param monthes2Return
* 还款期限
* @return
*/
public static BigDecimal calAccountManagementCharge(
BigDecimal bidRequestAmount) {
BigDecimal accountManagementCharge = DecimalFormatUtil
.formatBigDecimal(bidRequestAmount
.multiply(BidConst.ACCOUNT_MANAGER_CHARGE_RATE),
BidConst.CAL_SCALE);
return accountManagementCharge;
}
}

View File

@ -0,0 +1,39 @@
package com.geekq.common.utils.numcal;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* 大数字格式化工具类
* @author 邱润泽
* */
public class DecimalFormatUtil {
//金额
public static BigDecimal amountFormat(BigDecimal number) {
number = number.setScale(BidConst.STORE_SCALE, RoundingMode.HALF_UP);
return number;
}
//利率
public static BigDecimal rateFormat(BigDecimal number) {
number = number.setScale(BidConst.STORE_SCALE, RoundingMode.HALF_UP);
return number;
}
public static BigDecimal decimalRateFormat(BigDecimal number) {
return number.multiply(BigDecimal.valueOf(100));
}
//月利率
public static BigDecimal monthRateFormat(BigDecimal number) {
return number.multiply(BigDecimal.valueOf(100)).divide(
BigDecimal.valueOf(12), BidConst.CAL_SCALE,
RoundingMode.HALF_UP);
}
public static BigDecimal formatBigDecimal(BigDecimal data, int scal) {
if (null == data)
return new BigDecimal(0.00);
return data.setScale(scal, BigDecimal.ROUND_HALF_UP);
}
}

View File

@ -1,6 +1,5 @@
package com.geekq.miaosha;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@ -9,7 +8,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@ImportResource({"classpath:dubbo/applicationContext-dubbo-consumer.xml"})
@ComponentScan(basePackages={"com.geekq.order.*","com.geekq.miaosha.*"})
@ComponentScan(basePackages={"com.geekq.admin.*","com.geekq.miaosha.*"})
@SpringBootApplication
@EnableScheduling
public class GeekQMainApplication {

View File

@ -5,7 +5,7 @@ import com.geekq.miaosha.common.resultbean.ResultGeekQ;
import com.geekq.miaosha.redis.redismanager.RedisLua;
import com.geekq.miaosha.service.MiaoShaUserService;
import com.geekq.miaosha.vo.LoginVo;
import com.geekq.order.service.OrdersService;
import com.geekq.admin.service.OrdersService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,11 +1,8 @@
package com.geekq.miaosha.controller;
import com.alibaba.dubbo.config.annotation.Reference;
import com.geekq.miaosha.common.resultbean.ResultGeekQ;
import com.geekq.miaosha.domain.MiaoshaUser;
import com.geekq.miaosha.service.MiaoShaUserService;
import com.geekq.miaosha.service.MiaoshaService;
import com.geekq.order.service.OrdersService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -23,7 +23,7 @@ public class MiaoshaUser {
private Integer loginCount;
@Override
public String toString() {
return "MiaoshaUser{" +
return "Logininfo{" +
"id=" + id +
", nickname='" + nickname + '\'' +
", password='" + password + '\'' +

View File

@ -15,7 +15,7 @@
<!--&lt;!&ndash; 监听服务,通过注册中心去进行查找,查找到后进行服务调用 &ndash;&gt;-->
<!--<dubbo:reference id="itemService" interface="com.imooc.item.service.ItemsService"-->
<!--retries="3" check="false" init="true"></dubbo:reference>-->
<dubbo:reference id="ordersService" interface="com.geekq.order.service.OrdersService"
<dubbo:reference id="ordersService" interface="com.geekq.admin.service.OrdersService"
retries="3" check="false" init="true"></dubbo:reference>
<context:component-scan base-package="com.geekq.miaosha.controller" />