소스 검색

fix some bug

Mr.qian 2 주 전
부모
커밋
c3ca45d1b8

+ 92 - 85
mall-service/src/main/java/com/txz/mall/controller/appcontroller/AppCombinationController.java

@@ -35,86 +35,86 @@ import java.util.stream.Collectors;
 @RestController
 @RequestMapping("/app/combination")
 public class AppCombinationController {
-
+    
     private static Logger log = LoggerFactory.getLogger(AppCombinationController.class);
-
+    
     @Resource
     private StoreCombinationService storeCombinationService;
     @Resource
     private StoreOrderService storeOrderService;
     @Resource
     private OrderServiceBusiness orderServiceBusiness;
-
-//    @PostMapping("/add")
-//    @ApiOperation(value = "拼团商品表新增")
-//    public Result add(@RequestBody StoreCombination storeCombination) {
-//        if (storeCombination == null) {
-//            return Result.fail(ResultCode.OBJECT_IS_NULL);
-//        }
-//        try {
-//            storeCombination.setCreateTime(new Date());
-////            storeCombination.setCreateUserId(userId);
-//            storeCombinationService.save(storeCombination);
-//        } catch (Exception e) {
-//            log.error("新增对象操作异常e:{}", e);
-//            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
-//        }
-//        return Result.success();
-//    }
-
-//    @DeleteMapping("/delete")
-//    @ApiOperation(value = "拼团商品表删除")
-//    public Result delete(@RequestParam Long id) {
-//        if (id == null) {
-//            return Result.fail(ResultCode.ID_IS_NULL);
-//        }
-//        StoreCombination combination = storeCombinationService.findById(id);
-//        if (combination == null) {
-//            return Result.fail(ResultCode.OBJECT_IS_NULL);
-//        }
-//        Date date = new Date();
-//        if (combination.getIsShow().equals(1) && combination.getStartTime().before(date) && combination.getStopTime().after(date)) {
-//            throw new ServiceException("活动开启中,商品不支持删除");
-//        }
-//        try {
-//            StoreCombination storeCombination = new StoreCombination();
-//            storeCombination.setId(id);
-//            storeCombination.setIsDelete(1);
-//            storeCombinationService.update(storeCombination);
-//        } catch (Exception e) {
-//            log.error("删除对象操作异常e:{}", e);
-//            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
-//        }
-//        return Result.success();
-//    }
-
-//    @PutMapping("/update")
-//    @ApiOperation(value = "拼团商品表更新")
-//    public Result update(@RequestBody StoreCombination storeCombination) {
-//        if (storeCombination == null) {
-//            return Result.fail(ResultCode.OBJECT_IS_NULL);
-//        }
-//        if (storeCombination.getId() == null) {
-//            return Result.fail(ResultCode.ID_IS_NULL);
-//        }
-//        try {
-//            storeCombination.setUpdateTime(new Date());
-////            storeCombination.setUpdateUserId(userId);
-//            storeCombinationService.update(storeCombination);
-//        } catch (Exception e) {
-//            log.error("更新对象操作异常e:{}", e);
-//            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
-//        }
-//        return Result.success();
-//    }
-
+    
+    //    @PostMapping("/add")
+    //    @ApiOperation(value = "拼团商品表新增")
+    //    public Result add(@RequestBody StoreCombination storeCombination) {
+    //        if (storeCombination == null) {
+    //            return Result.fail(ResultCode.OBJECT_IS_NULL);
+    //        }
+    //        try {
+    //            storeCombination.setCreateTime(new Date());
+    ////            storeCombination.setCreateUserId(userId);
+    //            storeCombinationService.save(storeCombination);
+    //        } catch (Exception e) {
+    //            log.error("新增对象操作异常e:{}", e);
+    //            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+    //        }
+    //        return Result.success();
+    //    }
+    
+    //    @DeleteMapping("/delete")
+    //    @ApiOperation(value = "拼团商品表删除")
+    //    public Result delete(@RequestParam Long id) {
+    //        if (id == null) {
+    //            return Result.fail(ResultCode.ID_IS_NULL);
+    //        }
+    //        StoreCombination combination = storeCombinationService.findById(id);
+    //        if (combination == null) {
+    //            return Result.fail(ResultCode.OBJECT_IS_NULL);
+    //        }
+    //        Date date = new Date();
+    //        if (combination.getIsShow().equals(1) && combination.getStartTime().before(date) && combination.getStopTime().after(date)) {
+    //            throw new ServiceException("活动开启中,商品不支持删除");
+    //        }
+    //        try {
+    //            StoreCombination storeCombination = new StoreCombination();
+    //            storeCombination.setId(id);
+    //            storeCombination.setIsDelete(1);
+    //            storeCombinationService.update(storeCombination);
+    //        } catch (Exception e) {
+    //            log.error("删除对象操作异常e:{}", e);
+    //            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+    //        }
+    //        return Result.success();
+    //    }
+    
+    //    @PutMapping("/update")
+    //    @ApiOperation(value = "拼团商品表更新")
+    //    public Result update(@RequestBody StoreCombination storeCombination) {
+    //        if (storeCombination == null) {
+    //            return Result.fail(ResultCode.OBJECT_IS_NULL);
+    //        }
+    //        if (storeCombination.getId() == null) {
+    //            return Result.fail(ResultCode.ID_IS_NULL);
+    //        }
+    //        try {
+    //            storeCombination.setUpdateTime(new Date());
+    
+    /// /            storeCombination.setUpdateUserId(userId);
+    //            storeCombinationService.update(storeCombination);
+    //        } catch (Exception e) {
+    //            log.error("更新对象操作异常e:{}", e);
+    //            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+    //        }
+    //        return Result.success();
+    //    }
     @GetMapping("/detail")
     @ApiOperation(value = "拼团商品表获取详情")
     public Result<StoreCombination> detail(@RequestParam Long id) {
         if (id == null) {
             return Result.fail(ResultCode.ID_IS_NULL);
         }
-
+        
         StoreCombination storeCombination = null;
         try {
             storeCombination = storeCombinationService.findById(id);
@@ -124,17 +124,17 @@ public class AppCombinationController {
         }
         return Result.success(storeCombination);
     }
-
+    
     @PostMapping("/app/list")
     @ApiOperation(value = "拼团商品表获取列表")
     public Result<List<StoreCombination>> list(@RequestBody StoreProductDTO dto) {
         PageHelper.startPage(dto.getPage(), dto.getSize());
-
+        
         Condition condition = new Condition(StoreCombination.class);
         Example.Criteria criteria = condition.createCriteria();
         criteria.andEqualTo("isDelete", 0);
         criteria.andEqualTo("isShow", 1);
-
+        
         if (dto.getSortWay() == null) {
             dto.setSortWay(0);
         }
@@ -158,10 +158,17 @@ public class AppCombinationController {
         if (dto.getIsNew() != null) {
             criteria.andEqualTo("isNew", 1);
         }
-
-        if (dto.getMinPrice() != null && dto.getMaxPrice() != null) {
-            criteria.andBetween("price", dto.getMinPrice(), dto.getMaxPrice());
+        
+        // if (dto.getMinPrice() != null && dto.getMaxPrice() != null) {
+        //     criteria.andBetween("price", dto.getMinPrice(), dto.getMaxPrice());
+        // }
+        if (dto.getMaxPrice() != null) {
+            criteria.andEqualTo("price", dto.getMaxPrice());
         }
+        Date now = new Date();
+        criteria.andLessThanOrEqualTo("startTime", now);
+        criteria.andGreaterThanOrEqualTo("stopTime", now);
+        
         PageInfo pageInfo = null;
         try {
             List<StoreCombination> list = storeCombinationService.findByCondition(condition);
@@ -172,7 +179,7 @@ public class AppCombinationController {
         }
         return Result.success(pageInfo);
     }
-
+    
     @PostMapping("/addActivityProduct")
     @ApiOperation(value = "添加活动商品")
     public Result addActivityProduct(@RequestBody StoreCombinationAddParam storeCombinationAddParam) {
@@ -185,7 +192,7 @@ public class AppCombinationController {
         storeCombinationService.addActivityProduct(storeCombinationAddParam.getList(), storeCombinationAddParam.getActivityId());
         return Result.success();
     }
-
+    
     @GetMapping("/getActivityProductIds")
     @ApiOperation(value = "获取活动商品ids")
     public Result<List<Long>> getActivityProductIds(@RequestParam("activityId") Long activityId) {
@@ -197,22 +204,22 @@ public class AppCombinationController {
         List<Long> arrayList = combinationList.stream().map(StoreCombination::getProductId).collect(Collectors.toList());
         return Result.success(arrayList);
     }
-
+    
     /**
      * 去开团
      */
-//    @ApiOperation(value = "支付成功-去开团")
-//    @PostMapping(value = "/open")
+    //    @ApiOperation(value = "支付成功-去开团")
+    //    @PostMapping(value = "/open")
     public Result goOpen(@RequestParam("orderId") String orderId) {
         storeOrderService.goOpen(orderId);
         return Result.success();
     }
-
+    
     /**
      * 去拼团
      */
-//    @ApiOperation(value = "去拼团")
-//    @PostMapping(value = "/pink")
+    //    @ApiOperation(value = "去拼团")
+    //    @PostMapping(value = "/pink")
     public Result goPink(@Validated @RequestBody GoPinkDTO dto) {
         if (dto.getPinkId() == null && dto.getCid() == null) {
             return Result.fail(ResultCode.ID_IS_NULL);
@@ -220,7 +227,7 @@ public class AppCombinationController {
         storeOrderService.goPink(dto);
         return Result.success();
     }
-
+    
     /**
      * 更多拼团
      */
@@ -238,7 +245,7 @@ public class AppCombinationController {
         }
         return Result.success(pageInfo);
     }
-
+    
     @ApiOperation(value = "排行榜")
     @GetMapping(value = "/rank")
     public Result<List<StoreCombinationRankVO>> getRank(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
@@ -253,6 +260,6 @@ public class AppCombinationController {
         }
         return Result.success(pageInfo);
     }
-
-
+    
+    
 }

+ 1 - 1
mall-service/src/main/java/com/txz/mall/dao/impl/StoreCombinationMapperImpl.java

@@ -23,7 +23,7 @@ public class StoreCombinationMapperImpl {
     }
     
     public String getIdByProductId(Long productId) {
-        String sql = "select id from m_store_combination where product_id = #{productId} and is_delete = 0 and start_time < now() and stop_time > now() order by start_time limit 1 ";
+        String sql = "select id from m_store_combination where product_id = #{productId} and is_delete = 0 and start_time <= now() and stop_time >= now() and is_show = 1 order by start_time limit 1 ";
         return sql;
     }