licailing 5 лет назад
Родитель
Сommit
7cdc51d52a

+ 2 - 0
src/main/java/com/izouma/dingdong/domain/backstage/Category.java

@@ -29,6 +29,8 @@ public class Category extends BaseEntity implements Serializable {
 
     private Long parent;
 
+    private String icon;
+
     private Boolean active = true;
 
     @OneToMany

+ 1 - 0
src/main/java/com/izouma/dingdong/domain/backstage/TimeTag.java

@@ -21,4 +21,5 @@ public class TimeTag extends BaseEntity implements Serializable {
     private String name;
     private LocalTime startTime;
     private LocalTime endTime;
+    private String icon;
 }

+ 5 - 0
src/main/java/com/izouma/dingdong/repo/OrderGoodsSpecRepo.java

@@ -22,4 +22,9 @@ public interface OrderGoodsSpecRepo extends JpaRepository<OrderGoodsSpec, Long>,
     @Transactional
     void deleteById(Long id);
 
+    @Query("update OrderGoodsSpec t set t.enabled = false where t.shoppingCartId = ?1 and t.orderInfoId is null")
+    @Modifying
+    @Transactional
+    void deleteAllByShoppingCartIdAndOrderInfoIdIsNull(Long shoppingCartId);
+
 }

+ 5 - 0
src/main/java/com/izouma/dingdong/repo/user/ShoppingCartRepo.java

@@ -21,4 +21,9 @@ public interface ShoppingCartRepo extends JpaRepository<ShoppingCart, Long>, Jpa
     @Modifying
     @Transactional
     void deleteById(Long id);
+
+    @Query("update ShoppingCart t set t.enabled = false where t.userId = ?1")
+    @Modifying
+    @Transactional
+    void deleteAllByUserId(Long userId);
 }

+ 11 - 3
src/main/java/com/izouma/dingdong/service/AppraisalService.java

@@ -129,7 +129,13 @@ public class AppraisalService {
 
         List<Appraisal> appraisals1 = new ArrayList<>();
         switch (appraisalSort) {
-            //好评
+            //最新
+            case LATEST:
+                appraisals1.addAll(appraisals.stream().filter(
+                        a -> !a.getAppraiseTime().isBefore(LocalDateTime.now().plusMonths(1)))
+                        .collect(Collectors.toList()));
+                break;
+                //好评
             case PRAISE:
                 appraisals1.addAll(good);
                 appraisals1.addAll(bad);
@@ -141,8 +147,10 @@ public class AppraisalService {
                 break;
             //有图
             case HAVE_PIC:
-                List<Appraisal> pic = appraisals.stream().filter(a -> StrUtil.isNotBlank(a.getImg())).collect(Collectors.toList());
-                List<Appraisal> noPic = appraisals.stream().filter(a -> StrUtil.isBlank(a.getImg())).collect(Collectors.toList());
+                List<Appraisal> pic = appraisals.stream().filter(a -> StrUtil.isNotBlank(a.getImg()))
+                        .collect(Collectors.toList());
+                List<Appraisal> noPic = appraisals.stream().filter(a -> StrUtil.isBlank(a.getImg()))
+                        .collect(Collectors.toList());
                 appraisals1.addAll(pic);
                 appraisals1.addAll(noPic);
                 break;

+ 31 - 0
src/main/java/com/izouma/dingdong/service/merchant/GoodsSpecificationService.java

@@ -1,6 +1,7 @@
 package com.izouma.dingdong.service.merchant;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.izouma.dingdong.domain.merchant.GoodsSpecification;
 import com.izouma.dingdong.exception.BusinessException;
@@ -62,4 +63,34 @@ public class GoodsSpecificationService {
         return all;
     }
 
+    public List<GoodsSpecification> save(List<GoodsSpecification> specifications){
+        List<GoodsSpecification> all = new ArrayList<>();
+        specifications.forEach(s -> {
+            goodsRepo.findById(s.getGoodsId()).orElseThrow(new BusinessException("商品不存在"));
+            GoodsSpecification save;
+            if (s.getId() != null) {
+                GoodsSpecification specification = goodsSpecificationRepo.findById(s.getId()).orElseThrow(new BusinessException("无记录"));
+                ObjUtils.merge(specification, s);
+                save = goodsSpecificationRepo.save(specification);
+            } else {
+                save = goodsSpecificationRepo.save(s);
+            }
+            all.add(save);
+            if (CollUtil.isNotEmpty(s.getChildren())) {
+                s.getChildren().forEach(c -> {
+                    c.setParent(save.getId());
+                    if (c.getId() != null) {
+                        GoodsSpecification specification = goodsSpecificationRepo.findById(s.getId()).orElseThrow(new BusinessException("无记录"));
+                        ObjUtils.merge(specification, s);
+                        all.add(goodsSpecificationRepo.save(specification));
+                    } else {
+                        all.add(goodsSpecificationRepo.save(c));
+                    }
+                });
+            }
+        });
+
+        return all;
+    }
+
 }

+ 2 - 0
src/main/java/com/izouma/dingdong/service/merchant/MerchantSettingsService.java

@@ -128,6 +128,8 @@ public class MerchantSettingsService {
         //一级分类
         List<Category> categories = categoryRepo.findAllByParent((long) 1);
 
+        //时间标签
+
         //优惠专区
         //主推荐位 2个
         List<Promote> promote1 = promoteRepo.findAllByAction(1);

+ 7 - 0
src/main/java/com/izouma/dingdong/web/merchant/GoodsSpecificationController.java

@@ -91,5 +91,12 @@ public class GoodsSpecificationController extends BaseController {
         List<GoodsSpecification> specifications = JSONObject.parseArray(spec, GoodsSpecification.class);
         return goodsSpecificationService.saveAll(specifications);
     }
+
+    @PostMapping("/saveSpecs")
+    @ApiOperation("批量保存规格2")
+    public List<GoodsSpecification> saveSpecs(String spec) {
+        List<GoodsSpecification> specifications = JSONObject.parseArray(spec, GoodsSpecification.class);
+        return goodsSpecificationService.save(specifications);
+    }
 }
 

+ 6 - 0
src/main/java/com/izouma/dingdong/web/merchant/MerchantController.java

@@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/merchant")
@@ -123,5 +124,10 @@ public class MerchantController extends BaseController {
     }
 
 
+    @GetMapping("/index")
+    @ApiOperation("用户端首页部分信息")
+    public Map<String, Object> index(Double longitude, Double latitude) {
+        return merchantSettingsService.index(longitude, latitude);
+    }
 }
 

+ 12 - 0
src/main/java/com/izouma/dingdong/web/user/ShoppingCartController.java

@@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/shoppingCart")
@@ -98,5 +99,16 @@ public class ShoppingCartController extends BaseController {
         List<ShoppingCart> carts = shoppingCartRepo.findAllByUserId(SecurityUtils.getAuthenticatedUser().getId());
         return new PageImpl<>(carts, toPageRequest(pageQuery), pageQuery.getSize());
     }
+
+    //清除购物车
+    @GetMapping("/clearCart")
+    @ApiOperation("清除购物车")
+    public void clearCart() {
+        Long id = SecurityUtils.getAuthenticatedUser().getId();
+        List<Long> list = shoppingCartRepo.findAllByUserId(id).stream().map(ShoppingCart::getId)
+                .collect(Collectors.toList());
+        list.forEach(l -> orderGoodsSpecRepo.deleteAllByShoppingCartIdAndOrderInfoIdIsNull(l));
+        shoppingCartRepo.deleteAllByUserId(id);
+    }
 }
 

+ 15 - 11
src/main/vue/src/views/Categories.vue

@@ -15,17 +15,21 @@
 <!--                <el-form-item label="菜单地址" prop="path">-->
 <!--                    <el-input v-model="menu.path"></el-input>-->
 <!--                </el-form-item>-->
-<!--                <el-form-item prop="icon">-->
-<!--                    <template slot="label">图标-->
-<!--                        <a href="https://fontawesome.com/icons?d=gallery&s=brands,solid&m=free"-->
-<!--                           target="_blank"-->
-<!--                           class="available-icons">查看所有可用图标</a></template>-->
-<!--                    <el-input v-model="icon">-->
-<!--                        <template slot="append"><span ref="iconContainer"-->
-<!--                                                      style="font-size: 18px"><i-->
-<!--                                class="fas fa-"></i></span></template>-->
-<!--                    </el-input>-->
-<!--                </el-form-item>-->
+                <el-form-item prop="icon" label="图片">
+<!--                    <template slot="label">图片
+                        <a href="https://fontawesome.com/icons?d=gallery&s=brands,solid&m=free"
+                           target="_blank"
+                           class="available-icons">查看所有可用图标</a></template>-->
+                    <el-input v-model="icon">
+                        <template slot="append">
+                            <span ref="iconContainer" style="font-size: 10px">
+                                <el-button @click="">上传</el-button>
+                                <!--<i
+                                class="fas fa-"></i>-->
+                            </span>
+                        </template>
+                    </el-input>
+                </el-form-item>
             </el-form>
             <div slot="footer">
                 <el-button @click="dialogVisible = false">取消