From b141df9bf9764db8567efebed48006e12ab1f657 Mon Sep 17 00:00:00 2001
From: wzy <wzy19931122ai@163.com>
Date: Sun, 14 Aug 2022 15:52:45 +0800
Subject: [PATCH] fix:jhy 停止下单

---
 gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java |   47 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java b/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java
index 24719d6..af7e9f8 100644
--- a/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java
+++ b/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java
@@ -87,29 +87,37 @@
         jhyOrder.setOrderNo(orderNo);
         jhyOrder.setArea(addressInfo.getAddressArea());
 
-        StringBuffer address = new StringBuffer();
-        address.append(addressInfo.getDetailAddress());
-        if (StrUtil.isNotBlank(addressInfo.getTagName())) {
-            address.append(StrUtil.isNotBlank(addressInfo.getHouseName()) ? addressInfo.getHouseName() : "");
-            if (Constants.ADDRESS_TYPE_HOME.equals(addressInfo.getTagName())) {
-                address.append(StrUtil.isNotBlank(addressInfo.getHouseNumber()) ? addressInfo.getHouseNumber() : "");
-                address.append(StrUtil.isNotBlank(addressInfo.getUnitName()) ? addressInfo.getUnitName() : "");
-            }
-        }
+//        StringBuffer address = new StringBuffer();
+//        address.append(addressInfo.getDetailAddress());
+//        if (StrUtil.isNotBlank(addressInfo.getTagName())) {
+//            address.append(StrUtil.isNotBlank(addressInfo.getHouseName()) ? addressInfo.getHouseName() : "");
+//            if (Constants.ADDRESS_TYPE_HOME.equals(addressInfo.getTagName())) {
+//                address.append(StrUtil.isNotBlank(addressInfo.getHouseNumber()) ? addressInfo.getHouseNumber() : "");
+//                address.append(StrUtil.isNotBlank(addressInfo.getUnitName()) ? addressInfo.getUnitName() : "");
+//            }
+//        }
 
         List<JhyOrder> addressExist = jhyOrderMapper.selectJhyOrderListByStatus(StrUtil.split("1,2", ','), orderDto.getUserId());
         if (CollUtil.isNotEmpty(addressExist)) {
             for (JhyOrder order : addressExist) {
-                String orderAddr = order.getArea() + order.getAddress();
+                String orderAddr = order.getArea()
+                        + order.getAddress()
+                        + (StrUtil.isEmpty(order.getUnitName())?"":order.getUnitName())
+                        + (StrUtil.isEmpty(order.getHouseNumber())?"":order.getHouseNumber());
 
-                if (orderAddr.equals(addressInfo.getAddressArea() + address)) {
+                if (orderAddr.equals(addressInfo.getAddressArea()
+                        + addressInfo.getDetailAddress()
+                        + (StrUtil.isEmpty(addressInfo.getHouseName())?"":addressInfo.getHouseName())
+                        + (StrUtil.isEmpty(addressInfo.getUnitName())?"":addressInfo.getUnitName())
+                        + (StrUtil.isEmpty(addressInfo.getHouseNumber())?"":addressInfo.getHouseNumber()))) {
                     throw new RestException(-3, "同一地址仅能有一单在进行中");
                 }
             }
         }
 
-        jhyOrder.setAddress(address.toString());
-
+        jhyOrder.setAddress(addressInfo.getDetailAddress()+(StrUtil.isEmpty(addressInfo.getHouseName())?"":addressInfo.getHouseName()));
+        jhyOrder.setUnitName(StrUtil.isEmpty(addressInfo.getUnitName())?"":addressInfo.getUnitName());
+        jhyOrder.setHouseNumber(StrUtil.isEmpty(addressInfo.getHouseNumber())?"":addressInfo.getHouseNumber());
         jhyOrder.setUsername(addressInfo.getRelaName());
         jhyOrder.setPhone(addressInfo.getMobilePhone());
         jhyOrder.setLongitude(addressInfo.getLongitude());
@@ -148,7 +156,7 @@
 
         BigDecimal total = BigDecimal.ZERO;
         for (JhyOrderItems item : items) {
-            item.setPrice(item.getPrice().multiply(BigDecimal.valueOf(40)));
+            item.setPrice(item.getPrice().multiply(BigDecimal.valueOf(Constants.PRICE_SCORE_EXCHANGE)));
             total = total.add(StrUtil.isNotBlank(item.getScore()) ? new BigDecimal(item.getScore()) : BigDecimal.ZERO);
         }
 
@@ -158,6 +166,8 @@
         detailsVo.setLongitude(order.getLongitude());
         detailsVo.setLatitude(order.getLatitude());
         detailsVo.setAddress(order.getArea() + order.getAddress());
+        detailsVo.setUnitName(order.getUnitName());
+        detailsVo.setHouseNumber(order.getHouseNumber());
         detailsVo.setTotalPrice(total);
         detailsVo.setItems(items);
         return detailsVo;
@@ -226,7 +236,7 @@
                     orderItems.setItemType(item.getId());
                     orderItems.setTitle(environmentalInfo.getTitle());
                     orderItems.setPrice(new BigDecimal(environmentalInfo.getPrice()));
-                    BigDecimal total = orderItems.getPrice().multiply(BigDecimal.valueOf(40)).multiply(weight);
+                    BigDecimal total = orderItems.getPrice().multiply(BigDecimal.valueOf(Constants.PRICE_SCORE_EXCHANGE)).multiply(weight);
                     orderItems.setScore(total.setScale(0, BigDecimal.ROUND_DOWN).toString());
                     orderItems.setWeight(weight);
                     jhyOrderItemsMapper.insert(orderItems);
@@ -237,6 +247,7 @@
                 JhyOrder order = jhyOrderMapper.selectByPrimaryKey(confirmDto.getOrderId());
                 AccountInfo jhyAccount = accountMapper.selectAccountInfoByUserId(order.getJhyId());
                 BigDecimal collectScore = StrUtil.isNotBlank(jhyAccount.getCollectScore()) ? new BigDecimal(jhyAccount.getCollectScore()) : BigDecimal.ZERO;
+                log.info("===={}======{}====", collectScore, totalScore);
                 if (totalScore.compareTo(collectScore) > 0) {
                     throw new RestException(-3, "剩余积分不足");
                 }
@@ -279,6 +290,8 @@
                 distribService.distribRecord(order.getId(), order.getUserId());
                 // 推荐返利
                 distribService.inviteAddOrderScore(order.getUserId(), order.getId().toString());
+            } catch (RestException e) {
+                throw new RestException(e.getMessage());
             } catch (Exception e) {
                 log.error("异常", e);
                 throw new RestException("支付失败");
@@ -316,4 +329,8 @@
 
         return map;
     }
+
+    public List<JhyInfo> findJhyInfoInRange(Long addressId) {
+        return jhyInfoMapper.selectJhyInfoListInAddressRange(addressId);
+    }
 }

--
Gitblit v1.9.1