|
@@ -32,6 +32,7 @@ import java.util.Objects;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 我的商品相关接口
|
|
* 我的商品相关接口
|
|
|
|
|
+ *
|
|
|
* @author
|
|
* @author
|
|
|
* @date 2026/1/26 下午6:41
|
|
* @date 2026/1/26 下午6:41
|
|
|
*/
|
|
*/
|
|
@@ -58,8 +59,8 @@ public class MyProductController {
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 新增商品浏览记录
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 新增商品浏览记录
|
|
|
|
|
+ */
|
|
|
@PostMapping("/addProductBrowsingHistory/{productId}")
|
|
@PostMapping("/addProductBrowsingHistory/{productId}")
|
|
|
public R addProductBrowsingHistory(@PathVariable Long productId) {
|
|
public R addProductBrowsingHistory(@PathVariable Long productId) {
|
|
|
ProductBrowsingHistoryBo productBrowsingHistoryBo = new ProductBrowsingHistoryBo();
|
|
ProductBrowsingHistoryBo productBrowsingHistoryBo = new ProductBrowsingHistoryBo();
|
|
@@ -71,8 +72,8 @@ public class MyProductController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 删除浏览记录
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 删除浏览记录
|
|
|
|
|
+ */
|
|
|
@DeleteMapping("/deleteProductBrowsingHistory/{ids}")
|
|
@DeleteMapping("/deleteProductBrowsingHistory/{ids}")
|
|
|
public R deleteProductBrowsingHistory(@PathVariable Long[] ids) {
|
|
public R deleteProductBrowsingHistory(@PathVariable Long[] ids) {
|
|
|
productBrowsingHistoryService.remove(Wrappers.lambdaQuery(ProductBrowsingHistory.class)
|
|
productBrowsingHistoryService.remove(Wrappers.lambdaQuery(ProductBrowsingHistory.class)
|
|
@@ -83,16 +84,16 @@ public class MyProductController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 浏览记录的商品
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 浏览记录的商品
|
|
|
|
|
+ */
|
|
|
@GetMapping("/getProductBrowsingHistory")
|
|
@GetMapping("/getProductBrowsingHistory")
|
|
|
- public R<Map<String,List<PcProductVo>>> getProductBrowsingHistory() {
|
|
|
|
|
|
|
+ public R<Map<String, List<PcProductVo>>> getProductBrowsingHistory() {
|
|
|
return R.ok(productBaseService.getProductBrowsingHistory(LoginHelper.getUserId()));
|
|
return R.ok(productBaseService.getProductBrowsingHistory(LoginHelper.getUserId()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 新增商品收藏夹
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 新增商品收藏夹
|
|
|
|
|
+ */
|
|
|
@PostMapping("/addProductFavorites")
|
|
@PostMapping("/addProductFavorites")
|
|
|
public R addProductFavorites(@RequestBody ProductFavoritesBo bo) {
|
|
public R addProductFavorites(@RequestBody ProductFavoritesBo bo) {
|
|
|
bo.setUserId(LoginHelper.getUserId());
|
|
bo.setUserId(LoginHelper.getUserId());
|
|
@@ -109,31 +110,33 @@ public class MyProductController {
|
|
|
bo.setUserId(LoginHelper.getUserId());
|
|
bo.setUserId(LoginHelper.getUserId());
|
|
|
return productFavoritesService.queryPageList(bo, pageQuery);
|
|
return productFavoritesService.queryPageList(bo, pageQuery);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * 删除收藏夹
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 删除收藏夹
|
|
|
|
|
+ */
|
|
|
@DeleteMapping("/deleteProductFavorites/{favoritesId}")
|
|
@DeleteMapping("/deleteProductFavorites/{favoritesId}")
|
|
|
public R deleteProductFavorites(@PathVariable Long favoritesId) {
|
|
public R deleteProductFavorites(@PathVariable Long favoritesId) {
|
|
|
//做校验是否存在收藏商品
|
|
//做校验是否存在收藏商品
|
|
|
- if(productCollectService.exists(Wrappers.lambdaQuery(ProductCollect.class)
|
|
|
|
|
- .eq(ProductCollect::getFavoritesId, favoritesId))){
|
|
|
|
|
|
|
+ if (productCollectService.exists(Wrappers.lambdaQuery(ProductCollect.class)
|
|
|
|
|
+ .eq(ProductCollect::getFavoritesId, favoritesId))) {
|
|
|
return R.fail("收藏夹下有收藏商品,请先取消收藏商品");
|
|
return R.fail("收藏夹下有收藏商品,请先取消收藏商品");
|
|
|
}
|
|
}
|
|
|
productFavoritesService.deleteWithValidByIds(List.of(favoritesId), false);
|
|
productFavoritesService.deleteWithValidByIds(List.of(favoritesId), false);
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * 收藏商品
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 收藏商品
|
|
|
|
|
+ */
|
|
|
@PostMapping("/addProductCollect")
|
|
@PostMapping("/addProductCollect")
|
|
|
public R addProductCollect(@RequestBody ProductCollectBo bo) {
|
|
public R addProductCollect(@RequestBody ProductCollectBo bo) {
|
|
|
//如果未传收藏夹id,则查询有没有默认收藏夹,如果没有就新增收藏夹
|
|
//如果未传收藏夹id,则查询有没有默认收藏夹,如果没有就新增收藏夹
|
|
|
- if(bo.getFavoritesId() == null){
|
|
|
|
|
|
|
+ if (bo.getFavoritesId() == null) {
|
|
|
ProductFavorites one = productFavoritesService.getOne(Wrappers.lambdaQuery(ProductFavorites.class)
|
|
ProductFavorites one = productFavoritesService.getOne(Wrappers.lambdaQuery(ProductFavorites.class)
|
|
|
.eq(ProductFavorites::getUserId, LoginHelper.getUserId())
|
|
.eq(ProductFavorites::getUserId, LoginHelper.getUserId())
|
|
|
.eq(ProductFavorites::getIsDefault, "0")
|
|
.eq(ProductFavorites::getIsDefault, "0")
|
|
|
);
|
|
);
|
|
|
- if(one == null){
|
|
|
|
|
|
|
+ if (one == null) {
|
|
|
one = new ProductFavorites();
|
|
one = new ProductFavorites();
|
|
|
one.setUserId(LoginHelper.getUserId());
|
|
one.setUserId(LoginHelper.getUserId());
|
|
|
one.setCustomerId(LoginHelper.getLoginUser().getCustomerId());
|
|
one.setCustomerId(LoginHelper.getLoginUser().getCustomerId());
|
|
@@ -150,8 +153,8 @@ public class MyProductController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 取消收藏
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 取消收藏
|
|
|
|
|
+ */
|
|
|
@DeleteMapping("/cancelProductCollect")
|
|
@DeleteMapping("/cancelProductCollect")
|
|
|
public R cancelProductCollect(ProductCollectBo bo) {
|
|
public R cancelProductCollect(ProductCollectBo bo) {
|
|
|
productCollectService.remove(Wrappers.lambdaQuery(ProductCollect.class)
|
|
productCollectService.remove(Wrappers.lambdaQuery(ProductCollect.class)
|
|
@@ -163,16 +166,16 @@ public class MyProductController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 收藏夹商品列表
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 收藏夹商品列表
|
|
|
|
|
+ */
|
|
|
@GetMapping("/getFavoritesProductPage")
|
|
@GetMapping("/getFavoritesProductPage")
|
|
|
- public TableDataInfo<PcProductVo> getFavoritesProductPage(Long favoritesId,PageQuery pageQuery) {
|
|
|
|
|
- return productBaseService.getFavoritesProductPage(favoritesId, LoginHelper.getUserId(),pageQuery);
|
|
|
|
|
|
|
+ public TableDataInfo<PcProductVo> getFavoritesProductPage(Long favoritesId, PageQuery pageQuery) {
|
|
|
|
|
+ return productBaseService.getFavoritesProductPage(favoritesId, LoginHelper.getUserId(), pageQuery);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 查询商品是否在默认收藏夹收藏
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 查询商品是否在默认收藏夹收藏
|
|
|
|
|
+ */
|
|
|
@GetMapping("/isProductInDefaultCollect/{productIds}")
|
|
@GetMapping("/isProductInDefaultCollect/{productIds}")
|
|
|
public R isProductInDefaultCollect(@PathVariable Long[] productIds) {
|
|
public R isProductInDefaultCollect(@PathVariable Long[] productIds) {
|
|
|
//查询商品是否在默认收藏夹收藏
|
|
//查询商品是否在默认收藏夹收藏
|
|
@@ -180,7 +183,7 @@ public class MyProductController {
|
|
|
.eq(ProductFavorites::getUserId, LoginHelper.getUserId())
|
|
.eq(ProductFavorites::getUserId, LoginHelper.getUserId())
|
|
|
.eq(ProductFavorites::getIsDefault, "0")
|
|
.eq(ProductFavorites::getIsDefault, "0")
|
|
|
);
|
|
);
|
|
|
- if(one == null){
|
|
|
|
|
|
|
+ if (one == null) {
|
|
|
one = new ProductFavorites();
|
|
one = new ProductFavorites();
|
|
|
one.setUserId(LoginHelper.getUserId());
|
|
one.setUserId(LoginHelper.getUserId());
|
|
|
one.setTitle("默认收藏夹");
|
|
one.setTitle("默认收藏夹");
|
|
@@ -195,8 +198,8 @@ public class MyProductController {
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 将商品添加到购物车
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 将商品添加到购物车
|
|
|
|
|
+ */
|
|
|
@PostMapping("/addProductShoppingCart")
|
|
@PostMapping("/addProductShoppingCart")
|
|
|
public R addProductShoppingCart(@RequestBody ProductShoppingCartBo bo) {
|
|
public R addProductShoppingCart(@RequestBody ProductShoppingCartBo bo) {
|
|
|
Long userId = LoginHelper.getUserId();
|
|
Long userId = LoginHelper.getUserId();
|
|
@@ -205,11 +208,11 @@ public class MyProductController {
|
|
|
.eq(ProductShoppingCart::getUserId, userId)
|
|
.eq(ProductShoppingCart::getUserId, userId)
|
|
|
.eq(ProductShoppingCart::getProductId, bo.getProductId())
|
|
.eq(ProductShoppingCart::getProductId, bo.getProductId())
|
|
|
);
|
|
);
|
|
|
- if(one != null){
|
|
|
|
|
|
|
+ if (one != null) {
|
|
|
one.setProductNum(one.getProductNum() + bo.getProductNum());
|
|
one.setProductNum(one.getProductNum() + bo.getProductNum());
|
|
|
productShoppingCartService.updateById(one);
|
|
productShoppingCartService.updateById(one);
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
bo.setUserId(userId);
|
|
bo.setUserId(userId);
|
|
|
productShoppingCartService.insertByBo(bo);
|
|
productShoppingCartService.insertByBo(bo);
|
|
|
}
|
|
}
|
|
@@ -217,8 +220,24 @@ public class MyProductController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 删除购物车商品
|
|
|
|
|
|
|
+ * 更新购物车商品数量
|
|
|
* */
|
|
* */
|
|
|
|
|
+ @PostMapping("/updateProductShoppingCart")
|
|
|
|
|
+ public R updateProductShoppingCart(@RequestBody ProductShoppingCartBo bo) {
|
|
|
|
|
+ productShoppingCartService.update(Wrappers.lambdaUpdate(ProductShoppingCart.class)
|
|
|
|
|
+ .eq(ProductShoppingCart::getUserId, LoginHelper.getUserId())
|
|
|
|
|
+ .eq(ProductShoppingCart::getProductId, bo.getProductId())
|
|
|
|
|
+ .set(ProductShoppingCart::getProductNum, bo.getProductNum())
|
|
|
|
|
+ );
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除购物车商品
|
|
|
|
|
+ */
|
|
|
@DeleteMapping("/deleteProductShoppingCart/{ids}")
|
|
@DeleteMapping("/deleteProductShoppingCart/{ids}")
|
|
|
public R deleteProductShoppingCart(@PathVariable Long[] ids) {
|
|
public R deleteProductShoppingCart(@PathVariable Long[] ids) {
|
|
|
productShoppingCartService.removeByIds(Arrays.asList(ids));
|
|
productShoppingCartService.removeByIds(Arrays.asList(ids));
|
|
@@ -226,16 +245,16 @@ public class MyProductController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 查询购物车的商品
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 查询购物车的商品
|
|
|
|
|
+ */
|
|
|
@GetMapping("/getProductShoppingCartPage")
|
|
@GetMapping("/getProductShoppingCartPage")
|
|
|
public TableDataInfo<PcProductVo> getProductShoppingCartPage(String id, PageQuery pageQuery) {
|
|
public TableDataInfo<PcProductVo> getProductShoppingCartPage(String id, PageQuery pageQuery) {
|
|
|
- return productBaseService.getProductShoppingCartPage(id,LoginHelper.getUserId(),pageQuery);
|
|
|
|
|
|
|
+ return productBaseService.getProductShoppingCartPage(id, LoginHelper.getUserId(), pageQuery);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 获取购物车商品未失效的商品数量
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 获取购物车商品未失效的商品数量
|
|
|
|
|
+ */
|
|
|
@GetMapping("/getProductShoppingCartCount")
|
|
@GetMapping("/getProductShoppingCartCount")
|
|
|
public R getProductShoppingCartCount() {
|
|
public R getProductShoppingCartCount() {
|
|
|
return R.ok(productBaseService.getProductShoppingCartCount(LoginHelper.getUserId(), 0));
|
|
return R.ok(productBaseService.getProductShoppingCartCount(LoginHelper.getUserId(), 0));
|
|
@@ -243,30 +262,31 @@ public class MyProductController {
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 协议供货商品列表
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 协议供货商品列表
|
|
|
|
|
+ */
|
|
|
@GetMapping("/getAgreementSupplyProductPage")
|
|
@GetMapping("/getAgreementSupplyProductPage")
|
|
|
public TableDataInfo<PcProductVo> getProtocolProductsPage(PcProductBo bo, PageQuery pageQuery) {
|
|
public TableDataInfo<PcProductVo> getProtocolProductsPage(PcProductBo bo, PageQuery pageQuery) {
|
|
|
bo.setCustomerId(LoginHelper.getLoginUser().getCustomerId());
|
|
bo.setCustomerId(LoginHelper.getLoginUser().getCustomerId());
|
|
|
- return productBaseService.getProtocolProductsPage(bo,pageQuery);
|
|
|
|
|
|
|
+ return productBaseService.getProtocolProductsPage(bo, pageQuery);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 获取采购方案
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 获取采购方案
|
|
|
|
|
+ */
|
|
|
@GetMapping("/getProcurementProgramProductPage")
|
|
@GetMapping("/getProcurementProgramProductPage")
|
|
|
public TableDataInfo<ProcurementProgramVo> getProcurementProgramProductPage(ProcurementProgramBo bo, PageQuery pageQuery) {
|
|
public TableDataInfo<ProcurementProgramVo> getProcurementProgramProductPage(ProcurementProgramBo bo, PageQuery pageQuery) {
|
|
|
- if(Objects.equals(bo.getType(), "1")){
|
|
|
|
|
- return procurementProgramService.queryPageList(bo,pageQuery);
|
|
|
|
|
- }else if(Objects.equals(bo.getType(), "2")){
|
|
|
|
|
|
|
+ if (Objects.equals(bo.getType(), "1")) {
|
|
|
|
|
+ return procurementProgramService.queryPageList(bo, pageQuery);
|
|
|
|
|
+ } else if (Objects.equals(bo.getType(), "2")) {
|
|
|
return TableDataInfo.build();
|
|
return TableDataInfo.build();
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
return TableDataInfo.build();
|
|
return TableDataInfo.build();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * 收藏采购方案
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 收藏采购方案
|
|
|
|
|
+ */
|
|
|
@PostMapping("/addProcurementProgramCollect")
|
|
@PostMapping("/addProcurementProgramCollect")
|
|
|
public R addProcurementProgramCollect(@RequestBody ProcurementProgramCollectBo bo) {
|
|
public R addProcurementProgramCollect(@RequestBody ProcurementProgramCollectBo bo) {
|
|
|
bo.setUserId(LoginHelper.getUserId());
|
|
bo.setUserId(LoginHelper.getUserId());
|
|
@@ -276,14 +296,14 @@ public class MyProductController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 导出购物车的商品
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+ * 导出购物车的商品
|
|
|
|
|
+ */
|
|
|
@PostMapping("/exportProductShoppingCart")
|
|
@PostMapping("/exportProductShoppingCart")
|
|
|
- public void exportProductShoppingCart( HttpServletResponse response) {
|
|
|
|
|
|
|
+ public void exportProductShoppingCart(HttpServletResponse response) {
|
|
|
PageQuery pageQuery = new PageQuery();
|
|
PageQuery pageQuery = new PageQuery();
|
|
|
pageQuery.setPageNum(1);
|
|
pageQuery.setPageNum(1);
|
|
|
pageQuery.setPageSize(Integer.MAX_VALUE);
|
|
pageQuery.setPageSize(Integer.MAX_VALUE);
|
|
|
- TableDataInfo<PcProductVo> tableDataInfo = productBaseService.getProductShoppingCartPage(null, LoginHelper.getUserId(),pageQuery);
|
|
|
|
|
|
|
+ TableDataInfo<PcProductVo> tableDataInfo = productBaseService.getProductShoppingCartPage(null, LoginHelper.getUserId(), pageQuery);
|
|
|
// 转换为导出对象
|
|
// 转换为导出对象
|
|
|
List<ProductShoppingCartExportVo> exportList = new ArrayList<>();
|
|
List<ProductShoppingCartExportVo> exportList = new ArrayList<>();
|
|
|
BigDecimal totalAmount = BigDecimal.ZERO;
|
|
BigDecimal totalAmount = BigDecimal.ZERO;
|