提交实物代码

dev-discount
袁野 2 years ago
parent 0d230f5520
commit 2755f1dc63
  1. 14
      hai-service/src/main/java/com/hai/order/utils/OrderUtil.java
  2. 8
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java

@ -51,11 +51,15 @@ public class OrderUtil {
* @return * @return
* @throws Exception * @throws Exception
*/ */
public static String generateOrderNo() throws Exception { public static String generateOrderNo(){
// 5位随机数 + 1位线程生成数 try {
String randomNum = (new Random().nextInt(8999) + 1000) + IDGenerator.nextId(1); // 5位随机数 + 1位线程生成数
// 生成订单号 String randomNum = (new Random().nextInt(8999) + 1000) + IDGenerator.nextId(1);
return DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + randomNum; // 生成订单号
return DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + randomNum;
} catch (Exception e) {
return null;
}
} }
/** /**

@ -409,6 +409,10 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
String key = "recharge_" + outRechargeOrder.getId(); String key = "recharge_" + outRechargeOrder.getId();
if (outRechargeOrderService.rechargeOrderAbnormal(outRechargeOrder)) {
return;
}
try { try {
// 分布式锁占坑 // 分布式锁占坑
@ -550,6 +554,10 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Override @Override
public void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) { public void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) {
if (rechargeOrderAbnormal(outRechargeOrder)) {
return;
}
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
object.put("rechargePrice" , outRechargeOrder.getRechargePrice()); object.put("rechargePrice" , outRechargeOrder.getRechargePrice());
object.put("rechargeMobile" , outRechargeOrder.getRechargeContent()); object.put("rechargeMobile" , outRechargeOrder.getRechargeContent());

Loading…
Cancel
Save