Commit 584e46f2 authored by liaoanyuan's avatar liaoanyuan

生成卡片接口密码和卡号格式修改

parent a00582a3
...@@ -5,14 +5,20 @@ import cn.hutool.core.lang.UUID; ...@@ -5,14 +5,20 @@ import cn.hutool.core.lang.UUID;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigInteger; import java.math.BigInteger;
/**
* 生成充值卡子卡卡号工具类
*/
public class CardNumberUtil implements Serializable { public class CardNumberUtil implements Serializable {
private static final long serialVersionUID = -9056417839913098262L; private static final long serialVersionUID = -9056417839913098262L;
//字符串长度
static final int LENGTH= 11;
public static String cardNumber() { public static String cardNumber() {
//添加十一位数字生成卡号 //添加十一位数字生成卡号
String uuid = String.format("%040d", new BigInteger(UUID.randomUUID().toString().replace("-", ""), 16)); String uuid = String.format("%040d", new BigInteger(UUID.randomUUID().toString().replace("-", ""), 16));
return uuid.toString().substring(0,11); return uuid.toString().substring(0,LENGTH);
} }
} }
...@@ -3,19 +3,28 @@ package cn.wisenergy.common.utils; ...@@ -3,19 +3,28 @@ package cn.wisenergy.common.utils;
import java.util.Random; import java.util.Random;
/** /**
* 生成充值卡子卡秘钥工具类
* @author 86187 * @author 86187
*/ */
public class SecretkeyUtil { public class SecretkeyUtil {
//字符串长度
static final int LENGTH= 16;
//开头数字最小长度
static final int MIN_LENGTH_OF_NUMBER= 4;
//字母拼接最大位置
static final int MAX_LENGTH_OF_STRING=11;
public static String getSecretkey(){ public static String getSecretkey(){
char[] chars={'a','b','c','d','e','f','g','h','l','j','k','i','m','n','o','p','q','r','s','t','y','u','w','x','v','z'}; char[] chars={'a','b','c','d','e','f','g','h','l','j','k','i','m','n','o','p','q','r','s','t','y','u','w','x','v','z'};
StringBuilder stringBuilder=new StringBuilder(8); StringBuilder stringBuilder=new StringBuilder(16);
Random random = new Random(); Random random = new Random();
int i1 =random.nextInt(4)+2; int i1 =random.nextInt(4)+MIN_LENGTH_OF_NUMBER;
for (int i = 0; i <i1; i++) { for (int i = 0; i <i1; i++) {
stringBuilder.append(random.nextInt(9)); stringBuilder.append(random.nextInt(9));
} }
while (i1<7) { while (i1<MAX_LENGTH_OF_STRING) {
int i2 =random.nextInt(25); int i2 =random.nextInt(25);
if (i2 < 26) { if (i2 < 26) {
stringBuilder.append(chars[i2]); stringBuilder.append(chars[i2]);
...@@ -23,7 +32,10 @@ public class SecretkeyUtil { ...@@ -23,7 +32,10 @@ public class SecretkeyUtil {
} }
} }
stringBuilder.append(random.nextInt(9)); for (int i = MAX_LENGTH_OF_STRING; i <LENGTH ; i++) {
return Md5Util.digestMD5(stringBuilder.toString()); stringBuilder.append(random.nextInt(9));
}
return stringBuilder.toString();
} }
} }
...@@ -16,5 +16,5 @@ public interface PayRecordMapper extends BaseMapper<PayRecord> { ...@@ -16,5 +16,5 @@ public interface PayRecordMapper extends BaseMapper<PayRecord> {
int count(Map<String,Object> map); int count(Map<String,Object> map);
PayRecord getById(@Param("userId") Integer userId); List<PayRecord> getById(@Param("userId") Integer userId);
} }
...@@ -39,24 +39,24 @@ ...@@ -39,24 +39,24 @@
</sql> </sql>
<sql id="updateCondition"> <sql id="updateCondition">
<if test="password != null">banth_number =#{banthNumber},</if> <if test="banthNumber != null">banth_number =#{banthNumber},</if>
<if test="password != null">card_number =#{cardNumber},</if> <if test="cardNumber != null">card_number =#{cardNumber},</if>
<if test="phone != null">`limit` =#{limit},</if> <if test="limit != null">`limit` =#{limit},</if>
<if test="headImage != null">secret_key =#{secretKey},</if> <if test="secretKey != null">secret_key =#{secretKey},</if>
<if test="sex != null">money =#{money},</if> <if test="money != null">money =#{money},</if>
<if test="school != null">`status` =#{status},</if> <if test="status != null">`status` =#{status},</if>
<if test="examType != null">is_delete = #{isDelete},</if> <if test="isDelete != null">is_delete = #{isDelete},</if>
update_time =now() update_time =now()
</sql> </sql>
<sql id="criteria"> <sql id="criteria">
<if test="password != null"> and batch_number =#{batchNumber}</if> <if test="batchNumber != null"> and batch_number =#{batchNumber}</if>
<if test="password != null">and card_number =#{cardNumber},</if> <if test="cardNumber != null">and card_number =#{cardNumber},</if>
<if test="phone != null">and `limit` =#{limit}</if> <if test="limit != null">and `limit` =#{limit}</if>
<if test="headImage != null"> and secret_key =#{secretKey}</if> <if test="secretKey != null"> and secret_key =#{secretKey}</if>
<if test="sex != null">and money =#{money}</if> <if test="money != null">and money =#{money}</if>
<if test="school != null">and `status` =#{status}</if> <if test="status != null">and `status` =#{status}</if>
<if test="examType != null">and is_delete = #{isDelete}</if> <if test="isDelete != null">and is_delete = #{isDelete}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if> <if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if> <if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
</sql> </sql>
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
<where> <where>
user_id=#{userId} user_id=#{userId}
and and
type=1 type=2
order by update_time desc order by update_time desc
limit 0,1 limit 0,1
</where> </where>
......
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
</select> </select>
<select id="getById" resultMap="advertisingMap"> <select id="getById" resultMap="advertisingMap">
select money select <include refid="cols_all"/>
from <include refid="table"/> from <include refid="table"/>
<where> <where>
user_id=#{userId} user_id=#{userId}
......
...@@ -7,7 +7,7 @@ public interface AccountSerivce { ...@@ -7,7 +7,7 @@ public interface AccountSerivce {
/** /**
* 查询管理员信息 * 查询管理员信息
* @param userName,password 查询参数 * @param userName,password 查询参数
* @return * @return 管理员信息
*/ */
R<AccountDto> getAccountInfo(String userName, String password); R<AccountDto> getAccountInfo(String userName, String password);
} }
...@@ -19,7 +19,7 @@ public interface BannerService { ...@@ -19,7 +19,7 @@ public interface BannerService {
* 添加广告 * 添加广告
* *
* @param advertising 广告信息 * @param advertising 广告信息
* @return 广告信息 * @return true 成功 false 失败
*/ */
R<Boolean> add(Banner advertising); R<Boolean> add(Banner advertising);
......
...@@ -11,29 +11,30 @@ import java.util.List; ...@@ -11,29 +11,30 @@ import java.util.List;
public interface RefillCardService { public interface RefillCardService {
/** /**
* 添加充值卡 * 添加充值卡
* @param refillCard * @param refillCard 充值卡信息
* @return * @return true 成功 false 失败
*/ */
R<Boolean> add(RefillCard refillCard); R<Boolean> add(RefillCard refillCard);
/** /**
* 改变激活状态 * 改变激活状态
* @param batchNumber * @param batchNumber 充值卡批次号
* @return * @return true 成功 false 失败
*/ */
R<Boolean> update(String batchNumber); R<Boolean> update(String batchNumber);
/** /**
* 查询充值卡信息 * 查询充值卡信息
* @param pageNo * @param pageNo 当前页数
* @param pageSize * @param pageSize 每页显示条数
* @return * @return 充值卡信息结果集
*/ */
R<PageInfo<RefillCardDto>> getList(Integer pageNo, Integer pageSize); R<PageInfo<RefillCardDto>> getList(Integer pageNo, Integer pageSize);
/** /**
* 生成卡片 * 生成卡片
* @return * @param id :充值卡id
* @return true 成功 false 失败
*/ */
R<Boolean> createCard(Integer id); R<Boolean> createCard(Integer id);
} }
...@@ -124,7 +124,7 @@ public class RefillCardServiceImpl implements RefillCardService { ...@@ -124,7 +124,7 @@ public class RefillCardServiceImpl implements RefillCardService {
cardInfo.setIsDelete(0); cardInfo.setIsDelete(0);
cardInfo.setMoney("10"); cardInfo.setMoney("10");
cardInfo.setStatus(0); cardInfo.setStatus(0);
cardInfo.setLimit(0); cardInfo.setLimit(3);
cardInfo.setSecretKey(SecretkeyUtil.getSecretkey()); cardInfo.setSecretKey(SecretkeyUtil.getSecretkey());
cardInfo.setCardNumber(CardNumberUtil.cardNumber()); cardInfo.setCardNumber(CardNumberUtil.cardNumber());
cardInfos.add(cardInfo); cardInfos.add(cardInfo);
......
...@@ -74,7 +74,13 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U ...@@ -74,7 +74,13 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
ScoreInfo scoreInfo = scoreInfoMapper.getById(user.getId()); ScoreInfo scoreInfo = scoreInfoMapper.getById(user.getId());
LoginRecord loginRecord = loginRecordMapper.getById(user.getId()); LoginRecord loginRecord = loginRecordMapper.getById(user.getId());
UserLimit userLimit = userLimitMapper.getById(user.getId()); UserLimit userLimit = userLimitMapper.getById(user.getId());
PayRecord byId = payRecordMapper.getById(user.getId()); List<PayRecord> byId = payRecordMapper.getById(user.getId());
//计算累计充值金额
Integer sumMoney=0;
for (PayRecord payRecord : byId) {
sumMoney+=Integer.valueOf(payRecord.getMoney());
}
//将消息进行同步 //将消息进行同步
BeanUtils.copyProperties(user, userInfoDto); BeanUtils.copyProperties(user, userInfoDto);
...@@ -84,7 +90,7 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U ...@@ -84,7 +90,7 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
userInfoDto.setRegisterTime(user.getCreateTime()); userInfoDto.setRegisterTime(user.getCreateTime());
userInfoDto.setLastLoginTime(loginRecord.getUpdateTime()); userInfoDto.setLastLoginTime(loginRecord.getUpdateTime());
userInfoDto.setQueryLimit(userLimit.getUsableLimit()); userInfoDto.setQueryLimit(userLimit.getUsableLimit());
userInfoDto.setMoneyAmount(byId.getMoney()); userInfoDto.setMoneyAmount(sumMoney.toString());
userInfoDto.setIp(loginRecord.getIp()); userInfoDto.setIp(loginRecord.getIp());
list.add(userInfoDto); list.add(userInfoDto);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment