panhui před 5 roky
rodič
revize
9369089c4c

+ 14 - 1
src/main/java/com/izouma/dingdong/service/backstage/PromoteService.java

@@ -1,13 +1,26 @@
 package com.izouma.dingdong.service.backstage;
 
+import com.izouma.dingdong.domain.merchant.Merchant;
 import com.izouma.dingdong.repo.backstage.PromoteRepo;
+import com.izouma.dingdong.repo.merchant.MerchantRepo;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+
 @Service
 @AllArgsConstructor
 public class PromoteService {
 
-    private PromoteRepo promoteRepo;
+    private PromoteRepo  promoteRepo;
+    private MerchantRepo merchantRepo;
 
+    public void all() {
+        promoteRepo.findAll().forEach(promote -> {
+            Merchant merchant = merchantRepo.findById(promote.getMerchantId()).orElse(null);
+            if (merchant == null) {
+                promote.setEnabled(false);
+                promoteRepo.save(promote);
+            }
+        });
+    }
 }

+ 13 - 10
src/main/java/com/izouma/dingdong/service/merchant/MerchantSettingsService.java

@@ -23,6 +23,7 @@ import com.izouma.dingdong.repo.backstage.*;
 import com.izouma.dingdong.repo.merchant.*;
 import com.izouma.dingdong.repo.user.UserCouponRepo;
 import com.izouma.dingdong.service.backstage.CategoryService;
+import com.izouma.dingdong.service.backstage.PromoteService;
 import com.izouma.dingdong.utils.MapUtils;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
@@ -59,6 +60,7 @@ public class MerchantSettingsService {
     private UserCouponRepo             userCouponRepo;
     private PriorityRepo               priorityRepo;
     private SalesRepo                  salesRepo;
+    private PromoteService             promoteService;
 
     /*
     时间标签类商家列表
@@ -161,12 +163,13 @@ public class MerchantSettingsService {
 
         //优惠专区
         //主推荐位 2个
-        List<Promote> promote1 = promoteRepo.findAllByAction(1)
-                .stream().filter(p ->
-                        //距离小于3000米
-                        MapUtils.distance(p.getMerchant().getLongitude(), p.getMerchant()
-                                .getLatitude(), longitude, latitude) < 3000
-                ).collect(Collectors.toList());
+        promoteService.all();
+        List<Promote> promote1 = promoteRepo.findAllByAction(1);
+        promote1.stream().filter(p ->
+                //距离小于3000米
+                MapUtils.distance(p.getMerchant().getLongitude(), p.getMerchant()
+                        .getLatitude(), longitude, latitude) < 3000
+        ).collect(Collectors.toList());
         if (promote1.size() > 2) {
             promote1 = promote1.subList(0, 2);
         }
@@ -482,10 +485,10 @@ public class MerchantSettingsService {
             );
             //商品名称匹配出商家
             goods.forEach(g ->
-                merchantRepo.findById(g.getMerchantId()).ifPresent(m -> {
-                    if (ApplyStatus.PASS.equals(m.getStatus()))
-                        merchants.add(m);
-                })
+                    merchantRepo.findById(g.getMerchantId()).ifPresent(m -> {
+                        if (ApplyStatus.PASS.equals(m.getStatus()))
+                            merchants.add(m);
+                    })
             );
         }
 

+ 32 - 32
src/main/map/src/views/ChooseLocation.vue

@@ -1,33 +1,33 @@
-<template>
-    <iframe id="iframe" ref="iframe" frameborder="0" scrolling="no"> </iframe>
-</template>
-<script>
-window.addEventListener(
-    'message',
-    function(event) {
-        if (event.origin === 'https://3gimg.qq.com') {
-            var loc = event.data;
-            if (window.ReactNativeWebView) {
-                window.ReactNativeWebView.postMessage(JSON.stringify(loc));
-            }
-        }
-    },
-    false,
-);
-export default {
-		mounted(){
-				window.setLocation=this.setLocation
-		},
-		methods:{
-			setLocation(location){
-				this.$refs.iframe.src='https://apis.map.qq.com/tools/locpicker?search=1&type=1&zoom=18&key=GLFBZ-ZR2W6-76XSA-MF7CQ-GDJ6Z-6FB5K&referer=Dingdong&coord=' +location
-			}
-		}
-};
-</script>
-<style lang='less' scoped>
-#iframe {
-    width: 100vw;
-    height: 100vh;
-}
+<template>
+    <iframe id="iframe" ref="iframe" frameborder="0" scrolling="no"> </iframe>
+</template>
+<script>
+window.addEventListener(
+    'message',
+    function(event) {
+        if (event.origin === 'https://3gimg.qq.com') {
+            var loc = event.data;
+            if (window.ReactNativeWebView) {
+                window.ReactNativeWebView.postMessage(JSON.stringify(loc));
+            }
+        }
+    },
+    false,
+);
+export default {
+		mounted(){
+				window.setLocation=this.setLocation
+		},
+		methods:{
+			setLocation(location){
+				this.$refs.iframe.src='https://apis.map.qq.com/tools/locpicker?search=1&type=1&zoom=18&key=GLFBZ-ZR2W6-76XSA-MF7CQ-GDJ6Z-6FB5K&referer=Dingdong&coord=' +location
+			}
+		}
+};
+</script>
+<style lang='less' scoped>
+#iframe {
+    width: 100vw;
+    height: 100vh;
+}
 </style>