2 Commits 6df3e1beb0 ... 79804c32d4

Tác giả SHA1 Thông báo Ngày
  qzy 79804c32d4 Merge branch 'feature/asyncOrder' of http://git.aseanbusiness.cn/qzyReal/market-server into feature/asyncOrder 2 tuần trước cách đây
  qzy c3ac993645 银行扣款 2 tuần trước cách đây

+ 3 - 2
sp-core/sp-base/src/main/java/com/pj/current/config/SystemObject.java

@@ -1,5 +1,6 @@
 package com.pj.current.config;
 
+import cn.hutool.core.util.RandomUtil;
 import com.pj.common.core.utils.DateUtils;
 import com.pj.sms.factory.SmsFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -63,8 +64,8 @@ public class SystemObject {
     // ===================================== 生成订单号工具类 ===================================================
 
     public static String getREFcode(String rex, Date date) {
-        int randomNum = new Random().nextInt(9000) + 1000;
-        return rex.concat(DateUtils.parseDateToStr("yyMMddHHmmss", date)).concat(String.valueOf(randomNum));
+        return rex.concat(DateUtils.parseDateToStr("yyMMddHHmmss", date))
+                .concat(RandomUtil.randomNumbers(3)+"0");
     }
 
 }

+ 8 - 2
sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlementService.java

@@ -1,12 +1,14 @@
 package com.pj.ht_trade_settlement;
 
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.RandomUtil;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.log.StaticLog;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pj.api.dto.*;
+import com.pj.common.core.utils.DateUtils;
 import com.pj.current.config.SystemObject;
 import com.pj.enummj.*;
 import com.pj.tb_goods.TbGoods;
@@ -143,14 +145,18 @@ public class HtTradeSettlementService extends ServiceImpl<HtTradeSettlementMappe
         Date applyTime = new Date(Long.parseLong(tradeSettlementDto.getDeclTime()));
         htTradeSettlement.setDeclTime(DateUtil.format(applyTime, "yyyy-MM-dd HH:mm:ss")).setFinishStatus(0);
         BigDecimal totalPrice = BigDecimal.ZERO;
+        Date now = new Date();
+        String dateStr = DateUtils.parseDateToStr("yyMMddHHmm", now);
         for (BordersListDto item : bordersListDtoList) {//开始创建边民订单
             totalPrice = totalPrice.add(BigDecimal.valueOf(item.getBuyAmount()));
             TbOrder tbOrder = new TbOrder();
             //航通字段
             BeanUtils.copyProperties(item, tbOrder);
+            String tradeNo = "YJSCDD".concat(dateStr)
+                    .concat(RandomUtil.randomNumbers(5) + "0");
             tbOrder.setSaleMainId(htTradeSettlement.getId());
-            tbOrder.setCreateTime(new Date()).setPreNo(item.getPreNo())
-                    .setTradeNo(SystemObject.getREFcode("YJSCDD", new Date()))
+            tbOrder.setCreateTime(now).setPreNo(item.getPreNo())
+                    .setTradeNo(tradeNo)
                     .setTradeAreaId(tbTradeArea.getId()).setTradeAreaName(tbTradeArea.getName());
             tbOrder.setTotalWeight(item.getGrossWt()).setTotalPrice(item.getBuyAmount());
 

+ 17 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderService.java

@@ -769,8 +769,14 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         Integer deductionCount = tbOrder.getDeductionCount() + 1;
         if (tbOrder.getRefundStatus() != 0) {
             String tradeNo = tbOrder.getTradeNo();
-            tradeNo = StrUtil.subBefore(tradeNo, "_", false);
-            tbOrder.setTradeNo(tradeNo + "_" + deductionCount);
+            int len = tradeNo.length();
+            if (StrUtil.contains(tradeNo, "_")) {
+                tradeNo = tradeNo.substring(0, tradeNo.lastIndexOf("_"));
+            } else {
+                tradeNo = tradeNo.substring(0, len - 1);
+            }
+            tradeNo = tradeNo + deductionCount;
+            tbOrder.setTradeNo(tradeNo);
         }
         PaymentDto paymentDto = this.getPaymentData(tbOrder);
         StaticLog.info("\n---订单补扣款---sendSXB010——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
@@ -782,6 +788,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         return super.updateById(tbOrder);
     }
 
+
     /**
      * 订单补扣款——按车,并且未扣款
      */
@@ -797,8 +804,14 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
                 Integer deductionCount = tbOrder.getDeductionCount() + 1;
                 if (tbOrder.getRefundStatus() != 0) {
                     String tradeNo = tbOrder.getTradeNo();
-                    tradeNo = StrUtil.subBefore(tradeNo, "_", false);
-                    tbOrder.setTradeNo(tradeNo + "_" + deductionCount);
+                    int len = tradeNo.length();
+                    if (StrUtil.contains(tradeNo, "_")) {
+                        tradeNo = tradeNo.substring(0, tradeNo.lastIndexOf("_"));
+                    } else {
+                        tradeNo = tradeNo.substring(0, len - 1);
+                    }
+                    tradeNo = tradeNo + deductionCount;
+                    tbOrder.setTradeNo(tradeNo);
                 }
                 PaymentDto paymentDto = this.getPaymentData(tbOrder);
                 StaticLog.info("\n---订单补扣款——按车---sendSXB010——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));

+ 1 - 0
sp-service/payment-server/src/main/java/com/pj/bank_info/BankInfoController.java

@@ -92,6 +92,7 @@ public class BankInfoController {
         String source = so.getString("source");
         if (StrUtil.isNotEmpty(source)) {
             source = StrUtil.subBefore(source, "_", false);
+            source = source.substring(0, source.length() - 1);
             so.put("source", source);
         }
         List<BankInfo> list = bankInfoService.getList(so.startPage());