|
@@ -35,86 +35,86 @@ import java.util.stream.Collectors;
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/app/combination")
|
|
@RequestMapping("/app/combination")
|
|
public class AppCombinationController {
|
|
public class AppCombinationController {
|
|
-
|
|
|
|
|
|
+
|
|
private static Logger log = LoggerFactory.getLogger(AppCombinationController.class);
|
|
private static Logger log = LoggerFactory.getLogger(AppCombinationController.class);
|
|
-
|
|
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private StoreCombinationService storeCombinationService;
|
|
private StoreCombinationService storeCombinationService;
|
|
@Resource
|
|
@Resource
|
|
private StoreOrderService storeOrderService;
|
|
private StoreOrderService storeOrderService;
|
|
@Resource
|
|
@Resource
|
|
private OrderServiceBusiness orderServiceBusiness;
|
|
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")
|
|
@GetMapping("/detail")
|
|
@ApiOperation(value = "拼团商品表获取详情")
|
|
@ApiOperation(value = "拼团商品表获取详情")
|
|
public Result<StoreCombination> detail(@RequestParam Long id) {
|
|
public Result<StoreCombination> detail(@RequestParam Long id) {
|
|
if (id == null) {
|
|
if (id == null) {
|
|
return Result.fail(ResultCode.ID_IS_NULL);
|
|
return Result.fail(ResultCode.ID_IS_NULL);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
StoreCombination storeCombination = null;
|
|
StoreCombination storeCombination = null;
|
|
try {
|
|
try {
|
|
storeCombination = storeCombinationService.findById(id);
|
|
storeCombination = storeCombinationService.findById(id);
|
|
@@ -124,17 +124,17 @@ public class AppCombinationController {
|
|
}
|
|
}
|
|
return Result.success(storeCombination);
|
|
return Result.success(storeCombination);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@PostMapping("/app/list")
|
|
@PostMapping("/app/list")
|
|
@ApiOperation(value = "拼团商品表获取列表")
|
|
@ApiOperation(value = "拼团商品表获取列表")
|
|
public Result<List<StoreCombination>> list(@RequestBody StoreProductDTO dto) {
|
|
public Result<List<StoreCombination>> list(@RequestBody StoreProductDTO dto) {
|
|
PageHelper.startPage(dto.getPage(), dto.getSize());
|
|
PageHelper.startPage(dto.getPage(), dto.getSize());
|
|
-
|
|
|
|
|
|
+
|
|
Condition condition = new Condition(StoreCombination.class);
|
|
Condition condition = new Condition(StoreCombination.class);
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
criteria.andEqualTo("isDelete", 0);
|
|
criteria.andEqualTo("isDelete", 0);
|
|
criteria.andEqualTo("isShow", 1);
|
|
criteria.andEqualTo("isShow", 1);
|
|
-
|
|
|
|
|
|
+
|
|
if (dto.getSortWay() == null) {
|
|
if (dto.getSortWay() == null) {
|
|
dto.setSortWay(0);
|
|
dto.setSortWay(0);
|
|
}
|
|
}
|
|
@@ -158,10 +158,17 @@ public class AppCombinationController {
|
|
if (dto.getIsNew() != null) {
|
|
if (dto.getIsNew() != null) {
|
|
criteria.andEqualTo("isNew", 1);
|
|
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;
|
|
PageInfo pageInfo = null;
|
|
try {
|
|
try {
|
|
List<StoreCombination> list = storeCombinationService.findByCondition(condition);
|
|
List<StoreCombination> list = storeCombinationService.findByCondition(condition);
|
|
@@ -172,7 +179,7 @@ public class AppCombinationController {
|
|
}
|
|
}
|
|
return Result.success(pageInfo);
|
|
return Result.success(pageInfo);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@PostMapping("/addActivityProduct")
|
|
@PostMapping("/addActivityProduct")
|
|
@ApiOperation(value = "添加活动商品")
|
|
@ApiOperation(value = "添加活动商品")
|
|
public Result addActivityProduct(@RequestBody StoreCombinationAddParam storeCombinationAddParam) {
|
|
public Result addActivityProduct(@RequestBody StoreCombinationAddParam storeCombinationAddParam) {
|
|
@@ -185,7 +192,7 @@ public class AppCombinationController {
|
|
storeCombinationService.addActivityProduct(storeCombinationAddParam.getList(), storeCombinationAddParam.getActivityId());
|
|
storeCombinationService.addActivityProduct(storeCombinationAddParam.getList(), storeCombinationAddParam.getActivityId());
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@GetMapping("/getActivityProductIds")
|
|
@GetMapping("/getActivityProductIds")
|
|
@ApiOperation(value = "获取活动商品ids")
|
|
@ApiOperation(value = "获取活动商品ids")
|
|
public Result<List<Long>> getActivityProductIds(@RequestParam("activityId") Long activityId) {
|
|
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());
|
|
List<Long> arrayList = combinationList.stream().map(StoreCombination::getProductId).collect(Collectors.toList());
|
|
return Result.success(arrayList);
|
|
return Result.success(arrayList);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 去开团
|
|
* 去开团
|
|
*/
|
|
*/
|
|
-// @ApiOperation(value = "支付成功-去开团")
|
|
|
|
-// @PostMapping(value = "/open")
|
|
|
|
|
|
+ // @ApiOperation(value = "支付成功-去开团")
|
|
|
|
+ // @PostMapping(value = "/open")
|
|
public Result goOpen(@RequestParam("orderId") String orderId) {
|
|
public Result goOpen(@RequestParam("orderId") String orderId) {
|
|
storeOrderService.goOpen(orderId);
|
|
storeOrderService.goOpen(orderId);
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 去拼团
|
|
* 去拼团
|
|
*/
|
|
*/
|
|
-// @ApiOperation(value = "去拼团")
|
|
|
|
-// @PostMapping(value = "/pink")
|
|
|
|
|
|
+ // @ApiOperation(value = "去拼团")
|
|
|
|
+ // @PostMapping(value = "/pink")
|
|
public Result goPink(@Validated @RequestBody GoPinkDTO dto) {
|
|
public Result goPink(@Validated @RequestBody GoPinkDTO dto) {
|
|
if (dto.getPinkId() == null && dto.getCid() == null) {
|
|
if (dto.getPinkId() == null && dto.getCid() == null) {
|
|
return Result.fail(ResultCode.ID_IS_NULL);
|
|
return Result.fail(ResultCode.ID_IS_NULL);
|
|
@@ -220,7 +227,7 @@ public class AppCombinationController {
|
|
storeOrderService.goPink(dto);
|
|
storeOrderService.goPink(dto);
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 更多拼团
|
|
* 更多拼团
|
|
*/
|
|
*/
|
|
@@ -238,7 +245,7 @@ public class AppCombinationController {
|
|
}
|
|
}
|
|
return Result.success(pageInfo);
|
|
return Result.success(pageInfo);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@ApiOperation(value = "排行榜")
|
|
@ApiOperation(value = "排行榜")
|
|
@GetMapping(value = "/rank")
|
|
@GetMapping(value = "/rank")
|
|
public Result<List<StoreCombinationRankVO>> getRank(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
|
|
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);
|
|
return Result.success(pageInfo);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|