mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-13 11:49:49 +08:00
update运营商VIP
This commit is contained in:
@@ -4,8 +4,6 @@ import com.google.common.collect.Sets;
|
|||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
import com.jsowell.common.util.RandomUtil;
|
import com.jsowell.common.util.RandomUtil;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,13 +51,7 @@ public class IdUtils {
|
|||||||
/**
|
/**
|
||||||
* 通过UUID生成16位唯一订单号
|
* 通过UUID生成16位唯一订单号
|
||||||
*/
|
*/
|
||||||
public static String get16UUID(){
|
public static String get16UUID(String prefix) {
|
||||||
// 1.开头两位,标识业务代码或机器代码(可变参数)
|
|
||||||
String machineId = "89";
|
|
||||||
// 2.中间四位整数,标识日期
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
|
|
||||||
String dayTime = sdf.format(new Date());
|
|
||||||
|
|
||||||
// 2.生成四位随机整数
|
// 2.生成四位随机整数
|
||||||
int valueOf = (int) ((Math.random() * 9 + 1) * 1000);
|
int valueOf = (int) ((Math.random() * 9 + 1) * 1000);
|
||||||
|
|
||||||
@@ -69,15 +61,15 @@ public class IdUtils {
|
|||||||
if (hashCode < 0) {
|
if (hashCode < 0) {
|
||||||
hashCode = -hashCode;
|
hashCode = -hashCode;
|
||||||
}
|
}
|
||||||
// 5.算法处理: 0-代表前面补充0; 10-代表长度为10; d-代表参数为正数型
|
// 5.算法处理: 开头两位,标识业务代码或机器代码(可变参数) 0-代表前面补充0; 10-代表长度为10; d-代表参数为正数型
|
||||||
String value = machineId + valueOf + String.format("%010d", hashCode);
|
String value = prefix + valueOf + String.format("%010d", hashCode);
|
||||||
// System.out.println(value);
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成交易流水号
|
* 生成交易流水号
|
||||||
|
*
|
||||||
* @param pileSn 桩编号 例如:32010600019236
|
* @param pileSn 桩编号 例如:32010600019236
|
||||||
* @param connectorCode 枪口号 例如:01
|
* @param connectorCode 枪口号 例如:01
|
||||||
*/
|
*/
|
||||||
@@ -88,6 +80,7 @@ public class IdUtils {
|
|||||||
/**
|
/**
|
||||||
* 生成交易流水号
|
* 生成交易流水号
|
||||||
* 生成规则为 格式桩号(7bytes) +枪号(1byte) +年月日时分秒(6bytes) +自 增序号(2bytes);
|
* 生成规则为 格式桩号(7bytes) +枪号(1byte) +年月日时分秒(6bytes) +自 增序号(2bytes);
|
||||||
|
*
|
||||||
* @param pileConnectorCode 为已经拼好的充电桩枪口号 例如:3201060001923601
|
* @param pileConnectorCode 为已经拼好的充电桩枪口号 例如:3201060001923601
|
||||||
* @return 交易流水号 例如:32010600019236012001061803423060 88000000000001012211301501294274
|
* @return 交易流水号 例如:32010600019236012001061803423060 88000000000001012211301501294274
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -175,6 +175,21 @@ public class MemberBasicInfoServiceImpl implements IMemberBasicInfoService {
|
|||||||
return memberBasicInfoMapper.selectInfoByMemberId(memberId);
|
return memberBasicInfoMapper.selectInfoByMemberId(memberId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成钱包卡号WalletCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String generateWalletCode() {
|
||||||
|
while (true) {
|
||||||
|
String walletCode = IdUtils.get16UUID("89");
|
||||||
|
// 通过walletCode查询是否已经存在
|
||||||
|
MemberWalletInfo memberWalletInfo = memberWalletInfoService.selectByWalletCode(walletCode);
|
||||||
|
if (memberWalletInfo == null) {
|
||||||
|
return walletCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户余额 唯一方法
|
* 修改用户余额 唯一方法
|
||||||
* 接收的金额都是正数,通过操作类型判断 充值还是扣减
|
* 接收的金额都是正数,通过操作类型判断 充值还是扣减
|
||||||
@@ -201,7 +216,7 @@ public class MemberBasicInfoServiceImpl implements IMemberBasicInfoService {
|
|||||||
log.warn("根据会员id:{}, 目标运营商id:{}, 查询会员信息为空, 新建会员钱包", memberId, targetMerchantId);
|
log.warn("根据会员id:{}, 目标运营商id:{}, 查询会员信息为空, 新建会员钱包", memberId, targetMerchantId);
|
||||||
// 如果查询到钱包为空,就新建一个该运营商的钱包
|
// 如果查询到钱包为空,就新建一个该运营商的钱包
|
||||||
walletInfo = MemberWalletInfo.builder()
|
walletInfo = MemberWalletInfo.builder()
|
||||||
.walletCode(IdUtils.get16UUID())
|
.walletCode(generateWalletCode())
|
||||||
.memberId(memberId)
|
.memberId(memberId)
|
||||||
.merchantId(targetMerchantId)
|
.merchantId(targetMerchantId)
|
||||||
.giftBalance(BigDecimal.ZERO)
|
.giftBalance(BigDecimal.ZERO)
|
||||||
@@ -299,8 +314,8 @@ public class MemberBasicInfoServiceImpl implements IMemberBasicInfoService {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Set<String> set = Sets.newHashSet();
|
Set<String> set = Sets.newHashSet();
|
||||||
for (int i = 0; i < 10000000; i++) {
|
for (int i = 0; i < 85; i++) {
|
||||||
String s = IdUtils.get16UUID();
|
String s = IdUtils.get16UUID("89");
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
set.add(s);
|
set.add(s);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user