zhaoyun 2 mesiacov pred
rodič
commit
d76b5c3dfa

+ 9 - 1
ydd_mer_java/crmeb-service/src/main/java/com/zbkj/service/service/MerchantService.java

@@ -3,6 +3,7 @@ package com.zbkj.service.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.github.pagehelper.PageInfo;
 import com.zbkj.common.model.merchant.Merchant;
+import com.zbkj.common.query.IndexMerchantQuery;
 import com.zbkj.common.request.*;
 import com.zbkj.common.request.merchant.*;
 import com.zbkj.common.response.*;
@@ -294,7 +295,7 @@ public interface MerchantService extends IService<Merchant> {
      * 首页商户列表
      * @param recomdProdsNum 店铺街推荐商品数量
      */
-    List<IndexMerchantResponse> findIndexList(Integer recomdProdsNum);
+    List<IndexMerchantResponse> findIndexList(IndexMerchantQuery indexMerchantQuery, Integer recomdProdsNum);
 
     /**
      * 通过商户id列表获取商户名map
@@ -358,4 +359,11 @@ public interface MerchantService extends IService<Merchant> {
      * @return 对应的商户列表
      */
     List<Merchant> getMerchantListByType(Integer CategoryId);
+
+
+    /**
+     * 首页商户推荐商品列表
+     * @param recomdProdsNum 店铺街推荐商品数量
+     */
+    List<ProMerchantProductResponse> findProIndexList( Integer recomdProdsNum);
 }

+ 40 - 14
ydd_mer_java/crmeb-service/src/main/java/com/zbkj/service/service/impl/MerchantServiceImpl.java

@@ -27,15 +27,13 @@ import com.zbkj.common.model.page.PageDiy;
 import com.zbkj.common.model.system.GroupConfig;
 import com.zbkj.common.model.system.SystemNotification;
 import com.zbkj.common.page.CommonPage;
+import com.zbkj.common.query.IndexMerchantQuery;
 import com.zbkj.common.request.PageParamRequest;
 import com.zbkj.common.request.merchant.*;
 import com.zbkj.common.response.*;
 import com.zbkj.common.result.CommonResultCode;
 import com.zbkj.common.result.MerchantResultCode;
-import com.zbkj.common.utils.CrmebDateUtil;
-import com.zbkj.common.utils.CrmebUtil;
-import com.zbkj.common.utils.RedisUtil;
-import com.zbkj.common.utils.SecurityUtil;
+import com.zbkj.common.utils.*;
 import com.zbkj.common.vo.DateLimitUtilVo;
 import com.zbkj.common.vo.LoginUserVo;
 import com.zbkj.common.vo.MerchantConfigInfoVo;
@@ -51,10 +49,7 @@ import org.springframework.transaction.support.TransactionTemplate;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -1091,7 +1086,7 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantDao, Merchant> impl
      * 首页商户列表
      */
     @Override
-    public List<IndexMerchantResponse> findIndexList(Integer recomdProdsNum) {
+    public List<IndexMerchantResponse> findIndexList(IndexMerchantQuery indexMerchantQuery, Integer recomdProdsNum) {
         LambdaQueryWrapper<Merchant> lqw = Wrappers.lambdaQuery();
         lqw.eq(Merchant::getIsSwitch, true);
         lqw.eq(Merchant::getIsDel, false);
@@ -1101,13 +1096,28 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantDao, Merchant> impl
         return merchantList.stream().map(mer -> {
             IndexMerchantResponse response = new IndexMerchantResponse();
             BeanUtils.copyProperties(mer, response);
-            // 根据商户再获取三条商户对应的3条推荐商品 适用于DIY样式
-            response.setProList(productService.getRecommendedProductsByMerId(mer.getId(), 3));
+            // 根据商户再获取1条商户对应的1条推荐商品 适用于DIY样式
+            //response.setProList(productService.getRecommendedProductsByMerId(mer.getId(), 1));
             // 店铺关注人数
-            response.setFollowerNum(userMerchantCollectService.getCountByMerId(mer.getId()));
+            //response.setFollowerNum(userMerchantCollectService.getCountByMerId(mer.getId()));
+            if(indexMerchantQuery.getLatitude()!=null && indexMerchantQuery.getLongitude()!=null) {
+                Double distance = GeoUtils.haversineDistance(indexMerchantQuery.getLatitude(), indexMerchantQuery.getLongitude(), Double.parseDouble(mer.getLatitude()), Double.parseDouble(mer.getLongitude()));
 
-            response.setPcLogo(mer.getPcLogo());
-            response.setPcGoodStoreCoverImage(mer.getPcGoodStoreCoverImage());
+                response.setDistance(distance.intValue() + "km");//距离
+                response.setDeliverTime(DistanceCalculator.distanceToTimeInMinutes(distance, DistanceCalculator.AVERAGE_SPEED));//时间
+            }
+            response.setPerCapita(Double.parseDouble("15"));//人均费用
+            response.setDistCosts(Double.parseDouble("15"));//起送费用
+            response.setScore(mer.getStarLevel()+"分");//评分
+            response.setSalesVolume(200);//销售量
+            response.setIsFreeDeliverFee(true);
+            response.setFreeDeliverFee(Double.parseDouble("3"));
+            List<String> discountLabel =new ArrayList<>();
+            discountLabel.add("首单立减5元");
+            discountLabel.add("减配送费");
+            response.setDiscountLabel(discountLabel);//优惠标签
+            response.setPcLogo(mer.getPcLogo());//商户头像logo
+            //response.setPcGoodStoreCoverImage(mer.getPcGoodStoreCoverImage());
             return response;
         }).collect(Collectors.toList());
     }
@@ -1302,6 +1312,22 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantDao, Merchant> impl
         return Collections.emptyList();
     }
 
+    @Override
+    public List<ProMerchantProductResponse> findProIndexList(Integer recomdProdsNum) {
+        List<ProMerchantProductResponse> merchantProductResponseList=new ArrayList<>();
+        LambdaQueryWrapper<Merchant> lqw = Wrappers.lambdaQuery();
+        lqw.eq(Merchant::getIsSwitch, true);
+        lqw.eq(Merchant::getIsDel, false);
+        lqw.orderByDesc(Merchant::getIsRecommend, Merchant::getSort, Merchant::getId);
+        lqw.last(" limit " + recomdProdsNum);
+        List<Merchant> merchantList = dao.selectList(lqw);
+        for(Merchant mer:merchantList){
+             // 根据商户再获取1条商户对应的1条推荐商品 适用于DIY样;
+             merchantProductResponseList.addAll(productService.getRecommendedProductsByMerId(mer.getId(), 1));
+        }
+        return merchantProductResponseList;
+    }
+
     /**
      * 检查商户手机号是否重复
      *

+ 2 - 1
ydd_mer_java/crmeb-service/src/main/java/com/zbkj/service/service/impl/ProductServiceImpl.java

@@ -1701,7 +1701,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductDao, Product>
     public List<ProMerchantProductResponse> getRecommendedProductsByMerId(Integer merId, Integer num) {
         LambdaQueryWrapper<Product> lqw = Wrappers.lambdaQuery();
         lqw.select(Product::getId, Product::getMerId, Product::getImage, Product::getName,
-                Product::getPrice, Product::getSales, Product::getFicti, Product::getStock);
+                Product::getPrice, Product::getSales, Product::getFicti, Product::getStock,
+                Product::getIntro);
         lqw.eq(Product::getMerId, merId);
         getForSaleWhere(lqw);
         lqw.orderByDesc(Product::getSort);