mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-19 06:39:50 +08:00
Merge branch 'dev' of http://192.168.2.2:8099/jsowell/jsowell-charger-web into dev
This commit is contained in:
@@ -330,10 +330,12 @@ public class OrderService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String saveOrder2Database(GenerateOrderDTO dto) {
|
private String saveOrder2Database(GenerateOrderDTO dto) {
|
||||||
String orderCode = IdUtils.generateOrderCode(dto.getPileSn(), dto.getConnectorCode());
|
String orderCode = IdUtils.getOrderCode();
|
||||||
|
String transactionCode = IdUtils.generateTransactionCode(dto.getPileSn(), dto.getConnectorCode());
|
||||||
// 订单基本信息
|
// 订单基本信息
|
||||||
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
|
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
|
||||||
.orderCode(orderCode)
|
.orderCode(orderCode)
|
||||||
|
.transactionCode(transactionCode)
|
||||||
.orderStatus(OrderStatusEnum.NOT_START.getValue())
|
.orderStatus(OrderStatusEnum.NOT_START.getValue())
|
||||||
.memberId(dto.getMemberId())
|
.memberId(dto.getMemberId())
|
||||||
.stationId(dto.getPileConnector().getStationId())
|
.stationId(dto.getPileConnector().getStationId())
|
||||||
|
|||||||
@@ -50,21 +50,20 @@ public class IdUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成交易流水号
|
* 生成交易流水号
|
||||||
*
|
|
||||||
* @param pileSn 桩编号 例如:32010600019236
|
* @param pileSn 桩编号 例如:32010600019236
|
||||||
* @param connectorCode 枪口号 例如:01
|
* @param connectorCode 枪口号 例如:01
|
||||||
*/
|
*/
|
||||||
public static String generateOrderCode(String pileSn, String connectorCode) {
|
public static String generateTransactionCode(String pileSn, String connectorCode) {
|
||||||
return generateOrderCode(pileSn + connectorCode);
|
return generateTransactionCode(pileSn + connectorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成交易流水号
|
* 生成交易流水号
|
||||||
* 生成规则为 格式桩号(7bytes) +枪号(1byte) +年月日时分秒(6bytes) +自 增序号(2bytes);
|
* 生成规则为 格式桩号(7bytes) +枪号(1byte) +年月日时分秒(6bytes) +自 增序号(2bytes);
|
||||||
* @param pileConnectorCode 为已经拼好的充电桩枪口号 例如:3201060001923601
|
* @param pileConnectorCode 为已经拼好的充电桩枪口号 例如:3201060001923601
|
||||||
* @return 交易流水号 例如:32010600019236012001061803423060
|
* @return 交易流水号 例如:32010600019236012001061803423060 88000000000001012211301501294274
|
||||||
*/
|
*/
|
||||||
public static String generateOrderCode(String pileConnectorCode) {
|
public static String generateTransactionCode(String pileConnectorCode) {
|
||||||
String timeNow = DateUtils.dateTimeNow(DateUtils.YYMMDDHHMMSS);
|
String timeNow = DateUtils.dateTimeNow(DateUtils.YYMMDDHHMMSS);
|
||||||
//随机生成一个四位整数
|
//随机生成一个四位整数
|
||||||
String randomNumber = RandomUtil.getRandomNumber(4);
|
String randomNumber = RandomUtil.getRandomNumber(4);
|
||||||
@@ -73,15 +72,29 @@ public class IdUtils {
|
|||||||
|
|
||||||
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 < 1000; i++) {
|
for (int i = 0; i < 1000000; i++) {
|
||||||
// String s = System.currentTimeMillis() + RandomUtil.getRandomNumber(6);
|
String id = getOrderCode();
|
||||||
String id = SnowflakeIdWorker.getSnowflakeId();
|
|
||||||
set.add(id);
|
set.add(id);
|
||||||
System.out.println(id);
|
System.out.println(id);
|
||||||
}
|
}
|
||||||
System.out.println("set size = " + set.size());
|
System.out.println("set size = " + set.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成12位orderCode
|
||||||
|
*/
|
||||||
|
public static String getOrderCode() {
|
||||||
|
long id = Long.parseLong(SnowflakeIdWorker.getSnowflakeId());
|
||||||
|
StringBuilder sb = new StringBuilder(id + "");
|
||||||
|
StringBuilder reverse = sb.reverse();//将id翻转:我们发现id很长,且高位很长部分是一样的数
|
||||||
|
id = new Long(reverse.toString()) / 1000;//切去部分长度
|
||||||
|
while (id > 100000000000L) {
|
||||||
|
id /= 10;
|
||||||
|
}
|
||||||
|
// Integer num = Integer.parseInt(id + "");
|
||||||
|
return "C" + id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成八位会员id
|
* 生成八位会员id
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ public class SnowflakeIdWorker {
|
|||||||
//判断生成的记录是否有重复记录
|
//判断生成的记录是否有重复记录
|
||||||
long beginTime = System.currentTimeMillis();
|
long beginTime = System.currentTimeMillis();
|
||||||
Map<String, String> map = new ConcurrentHashMap<>();
|
Map<String, String> map = new ConcurrentHashMap<>();
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
for (int s = 0; s < 20000; s++) {
|
for (int s = 0; s < 20000; s++) {
|
||||||
String snowFlakeId = SnowflakeIdWorker.getSnowflakeId();
|
String snowFlakeId = SnowflakeIdWorker.getSnowflakeId();
|
||||||
@@ -229,7 +229,7 @@ public class SnowflakeIdWorker {
|
|||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
Thread.sleep(3000);
|
// Thread.sleep(3000);
|
||||||
log.info("map.size():{}", map.size());
|
log.info("map.size():{}", map.size());
|
||||||
log.info("耗时:" + (System.currentTimeMillis() - beginTime));
|
log.info("耗时:" + (System.currentTimeMillis() - beginTime));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
|
|||||||
|
|
||||||
// 应答
|
// 应答
|
||||||
// 交易流水号
|
// 交易流水号
|
||||||
String serialNum = IdUtils.generateOrderCode(pileSn, connectorCode);
|
String serialNum = IdUtils.generateTransactionCode(pileSn, connectorCode);
|
||||||
byte[] serialNumByteArr = BytesUtil.str2Bcd(serialNum);
|
byte[] serialNumByteArr = BytesUtil.str2Bcd(serialNum);
|
||||||
|
|
||||||
// 逻辑卡号
|
// 逻辑卡号
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ public class OrderBasicInfo extends BaseEntity {
|
|||||||
@Excel(name = "订单编号")
|
@Excel(name = "订单编号")
|
||||||
private String orderCode;
|
private String orderCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交易流水号
|
||||||
|
*/
|
||||||
|
private String transactionCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单状态(0-待支付;1-充电中;2-待结算;3-待补缴;4-异常;5-可疑;6-订单完成)
|
* 订单状态(0-待支付;1-充电中;2-待结算;3-待补缴;4-异常;5-可疑;6-订单完成)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import com.jsowell.common.enums.sim.SimCardStatusCorrespondEnum;
|
|||||||
import com.jsowell.common.enums.sim.SimSupplierEnum;
|
import com.jsowell.common.enums.sim.SimSupplierEnum;
|
||||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||||
import com.jsowell.common.exception.BusinessException;
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.util.RandomUtil;
|
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.common.util.http.HttpUtils;
|
import com.jsowell.common.util.http.HttpUtils;
|
||||||
import com.jsowell.common.util.id.IdUtils;
|
import com.jsowell.common.util.id.IdUtils;
|
||||||
@@ -436,7 +435,7 @@ public class SimCardService {
|
|||||||
param.put("name", WuLianSimRenew);
|
param.put("name", WuLianSimRenew);
|
||||||
param.put("msisdn", data.getMsisdn());
|
param.put("msisdn", data.getMsisdn());
|
||||||
param.put("packageId", data.getPackageId()); // 套餐id
|
param.put("packageId", data.getPackageId()); // 套餐id
|
||||||
param.put("outOrderNo", IdUtils.generateOrderCode(data.getMsisdn())); // 外部业务订单号
|
param.put("outOrderNo", IdUtils.generateTransactionCode(data.getMsisdn())); // 外部业务订单号
|
||||||
param.put("period", cycleNumber); // 续费周期
|
param.put("period", cycleNumber); // 续费周期
|
||||||
|
|
||||||
String result = HttpUtils.sendPostContentType(wuLianGetWay, param.toJSONString(), "application/json");
|
String result = HttpUtils.sendPostContentType(wuLianGetWay, param.toJSONString(), "application/json");
|
||||||
|
|||||||
@@ -659,6 +659,8 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
|||||||
OrderAbnormalRecord record = new OrderAbnormalRecord();
|
OrderAbnormalRecord record = new OrderAbnormalRecord();
|
||||||
BeanUtils.copyBeanProp(record, data);
|
BeanUtils.copyBeanProp(record, data);
|
||||||
orderAbnormalRecordService.insertOrderAbnormalRecord(record);
|
orderAbnormalRecordService.insertOrderAbnormalRecord(record);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -265,6 +265,9 @@
|
|||||||
<if test="orderCode != null">
|
<if test="orderCode != null">
|
||||||
order_code,
|
order_code,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="transactionCode != null">
|
||||||
|
transaction_code,
|
||||||
|
</if>
|
||||||
<if test="orderStatus != null">
|
<if test="orderStatus != null">
|
||||||
order_status,
|
order_status,
|
||||||
</if>
|
</if>
|
||||||
@@ -342,6 +345,9 @@
|
|||||||
<if test="orderCode != null">
|
<if test="orderCode != null">
|
||||||
#{orderCode},
|
#{orderCode},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="transactionCode != null">
|
||||||
|
#{transactionCode},
|
||||||
|
</if>
|
||||||
<if test="orderStatus != null">
|
<if test="orderStatus != null">
|
||||||
#{orderStatus},
|
#{orderStatus},
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
Reference in New Issue
Block a user