From d4c3427bbd111f4a005c77a9cc1f131b455fc6cf Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期一, 30 十月 2023 11:30:40 +0800
Subject: [PATCH] 新增加腾讯地图工具类

---
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java |   61 +++++++++++++++++++++++++++---
 1 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
index d1ba142..76a6a30 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
@@ -36,6 +36,9 @@
 import com.ruoyi.shop.service.task.ShopTaskService;
 import com.ruoyi.shop.util.HuiFuTianXiaUtil;
 import com.ruoyi.shop.util.WechatPayUtils;
+import com.ruoyi.shop.util.map.MapUtil;
+import com.ruoyi.shop.util.map.vo.TencentDistanceMatrix;
+import com.ruoyi.shop.util.map.vo.TencentDistanceMatrixElements;
 import com.ruoyi.system.api.constant.AppErrorConstant;
 import com.ruoyi.system.api.constant.SecurityConstant;
 import com.ruoyi.system.api.domain.dto.*;
@@ -759,8 +762,31 @@
             //获取绑定商户
             shop = this.getById(member.getRelationShopId());
         }else if(StringUtils.isNotBlank(appNearbyShopDto.getLatitude())&&StringUtils.isNotBlank(appNearbyShopDto.getLongitude())){
-            AppNearShopVo appNearShopVo = shopMapper.getNearbyShop(appNearbyShopDto);
-            shop = this.getById(appNearShopVo.getShopId());
+            List<AppNearShopVo> appNearShopVos = shopMapper.getNearbyShops(appNearbyShopDto);
+            if(appNearShopVos.size() > 0){
+                StringBuffer to = new StringBuffer();
+                for (AppNearShopVo appNearShopVo : appNearShopVos) {
+                    to.append(appNearShopVo.getLatitude() + "," + appNearShopVo.getLongitude() + ";");
+                }
+                String form = appNearbyShopDto.getLatitude() + "," + appNearbyShopDto.getLongitude();
+                R<List<TencentDistanceMatrix>> r = MapUtil.tencentDistanceMatrix(form, to.substring(0, to.length() - 1), "walking");
+                if(r.getCode() != 200){
+                    throw new ServiceException(r.getMsg());
+                }
+                List<TencentDistanceMatrix> data = r.getData();
+                //存储最短距离
+                BigDecimal dis = new BigDecimal(0);
+                AppNearShopVo appNearShopVo = null;
+                List<TencentDistanceMatrixElements> elements = data.get(0).getElements();
+                for (int i = 0; i < elements.size(); i++) {
+                    TencentDistanceMatrixElements matrix = elements.get(i);
+                    if(dis.compareTo(BigDecimal.ZERO) == 0 || dis.compareTo(new BigDecimal(matrix.getDistance())) > 0){
+                        dis = new BigDecimal(matrix.getDistance());
+                        appNearShopVo = appNearShopVos.get(i);
+                    }
+                }
+                shop = this.getById(appNearShopVo.getShopId());
+            }
         }else{
             return appNearbyShopVo;
         }
@@ -1140,24 +1166,28 @@
 
     /**
      * 商户进件异步通知
-     * @param jsonObject
      * @return
      */
     @Override
-    public R<String> merchantBasicdataNotify(JSONObject jsonObject) {
-        R<MerchantBasicdataVo> merchantBasicdataVoR = HuiFuTianXiaUtil.merchantBasicDataNotify(jsonObject);
+    public R<String> merchantBasicdataNotify(MerchantBasicDataNotifyDto dto) {
+        R<MerchantBasicdataVo> merchantBasicdataVoR = HuiFuTianXiaUtil.merchantBasicDataNotify(dto);
         if(merchantBasicdataVoR.getCode() != 200){
             return R.fail(merchantBasicdataVoR.getMsg());
         }
         MerchantBasicdataVo data = merchantBasicdataVoR.getData();
         ShopAuthenticationHftx shopAuthenticationHftx = shopAuthenticationHftxService.getOne(new QueryWrapper<ShopAuthenticationHftx>().eq("req_seq_id", data.getReqSeqId()));
-        if(!org.springframework.util.StringUtils.hasLength(shopAuthenticationHftx.getAuditStatus())){
+        if("U".equals(shopAuthenticationHftx.getAuditStatus())){
             shopAuthenticationHftx.setAuditStatus(data.getAuditStatus());
             shopAuthenticationHftx.setAuditDesc(data.getAuditDesc());
             shopAuthenticationHftx.setHuifuId(data.getHuifuId());
             shopAuthenticationHftx.setTokenNo(data.getTokenNo());
             shopAuthenticationHftx.setApplyNo(data.getApplyNo());
             shopAuthenticationHftxService.updateById(shopAuthenticationHftx);
+            if("Y".equals(data.getAuditStatus())){
+                Shop shop = this.getByShopId(shopAuthenticationHftx.getShopId());
+                shop.setShopStatus(1);
+                this.updateById(shop);
+            }
         }
         return R.ok(data.getReqSeqId());
     }
@@ -1575,6 +1605,23 @@
         List<ShopAuthentication> list = shopAuthenticationService.getShopAuthNeedUpdateStatus();
         log.info("定时检查微信二级商户"+list.toString());
         list.forEach(item -> queryApplyStatusByApplymentId(item.getApplymentId(), item.getShopId()));
+
+        List<ShopAuthenticationHftx> list1 = shopAuthenticationHftxService.list(new QueryWrapper<ShopAuthenticationHftx>().eq("audit_status", "U").eq("is_delete", 0));
+        for (ShopAuthenticationHftx shopAuthenticationHftx : list1) {
+            R<MerchantBasicdataVo> r = HuiFuTianXiaUtil.queryMerchantBasicdata(IdUtils.simpleUUID(), shopAuthenticationHftx.getHuifuId());
+            if(r.getCode() == 200){
+                MerchantBasicdataVo data = r.getData();
+                if(org.springframework.util.StringUtils.hasLength(data.getTokenNo())){
+                    shopAuthenticationHftx.setTokenNo(data.getTokenNo());
+                    shopAuthenticationHftx.setAuditStatus("Y");
+                    shopAuthenticationHftx.setAuditDesc("成功");
+                    Shop shop = this.getByShopId(shopAuthenticationHftx.getShopId());
+                    shop.setShopStatus(1);
+                    this.updateById(shop);
+                    shopAuthenticationHftxService.updateById(shopAuthenticationHftx);
+                }
+            }
+        }
     }
 
     /**
@@ -1789,6 +1836,6 @@
         String endTime = merchantBasicdataSettlementDto.getEndTime();
         Integer pageNum = merchantBasicdataSettlementDto.getPageNum();
         Integer pageSize = merchantBasicdataSettlementDto.getPageSize();
-        return HuiFuTianXiaUtil.getMerchantBasicdataSettlement(IdUtils.randomUUID(), huifuId, startTime, endTime, pageNum.toString(), pageSize.toString());
+        return HuiFuTianXiaUtil.getMerchantBasicdataSettlement(IdUtils.simpleUUID(), huifuId, startTime, endTime, pageNum.toString(), pageSize.toString());
     }
 }

--
Gitblit v1.7.1