From e92dfa8b13f01d57ac63c17a260b253c12585c43 Mon Sep 17 00:00:00 2001 From: wuchunlei Date: Thu, 28 Mar 2024 10:29:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=94=A8=E6=A8=A1=E5=9D=97-=E5=95=86?= =?UTF-8?q?=E5=93=81=E8=AF=84=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookLabelAndMarketController.java | 29 ++++++++++++++----- .../ShopProductRecordController.java | 15 +++++++++- .../common/entity/ShopProductRecord.java | 4 +++ .../peanut/modules/job/task/ExpressTask.java | 15 +++++++--- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/peanut/modules/book/controller/BookLabelAndMarketController.java b/src/main/java/com/peanut/modules/book/controller/BookLabelAndMarketController.java index 0491a8fc..7ed47c9a 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookLabelAndMarketController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookLabelAndMarketController.java @@ -198,6 +198,9 @@ public class BookLabelAndMarketController { if (params.containsKey("goodsType")&&!"".equals(params.get("goodsType").toString())){ wrapper.eq(ShopProduct::getGoodsType,params.get("goodsType").toString()); } + if (params.containsKey("productName")&&!"".equals(params.get("productName").toString())){ + wrapper.like(ShopProduct::getProductName,params.get("productName").toString()); + } if (params.containsKey("bookLabelId")&&!"".equals(params.get("bookLabelId").toString())){ String sql = "select product_id from shop_product_to_book_label where del_flag = 0 and book_label_id = "+params.get("bookLabelId"); wrapper.notInSql(ShopProduct::getProductId,sql); @@ -311,19 +314,29 @@ public class BookLabelAndMarketController { @RequestMapping(path = "/delToLable") public R delToLable(String lableId,String productId) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); - wrapper.eq(ShopProductToBookLabel::getBookLabelId,lableId); - wrapper.eq(ShopProductToBookLabel::getProductId,productId); - toLabelService.remove(wrapper); + if(StringUtils.isNotEmpty(productId)){ + String[] productIds = productId.split(","); + for(String id : productIds){ + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(ShopProductToBookLabel::getBookLabelId,lableId); + wrapper.eq(ShopProductToBookLabel::getProductId,id); + toLabelService.remove(wrapper); + } + } return R.ok(); } @RequestMapping(path = "/delToMarket") public R delToMarket(String marketId,String productId) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); - wrapper.eq(ShopProductToBookMarket::getBookMarketId,marketId); - wrapper.eq(ShopProductToBookMarket::getProductId,productId); - toMarketService.remove(wrapper); + if(StringUtils.isNotEmpty(productId)){ + String[] productIds = productId.split(","); + for(String id : productIds){ + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(ShopProductToBookMarket::getBookMarketId,marketId); + wrapper.eq(ShopProductToBookMarket::getProductId,id); + toMarketService.remove(wrapper); + } + } return R.ok(); } diff --git a/src/main/java/com/peanut/modules/common/controller/ShopProductRecordController.java b/src/main/java/com/peanut/modules/common/controller/ShopProductRecordController.java index 95186b7b..2e9aa2f8 100644 --- a/src/main/java/com/peanut/modules/common/controller/ShopProductRecordController.java +++ b/src/main/java/com/peanut/modules/common/controller/ShopProductRecordController.java @@ -6,13 +6,15 @@ import com.peanut.common.utils.R; import com.peanut.modules.common.entity.ShopProduct; import com.peanut.modules.common.entity.ShopProductRecord; import com.peanut.modules.common.service.ShopProductRecordService; +import com.peanut.modules.master.service.ShopProductService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - +import java.util.Date; +import java.util.List; import java.util.Map; /** @@ -25,6 +27,8 @@ public class ShopProductRecordController { @Autowired private ShopProductRecordService recordService; + @Autowired + private ShopProductService productService; @RequestMapping("/listByPage") public R listByPage(@RequestBody Map params) { @@ -41,11 +45,19 @@ public class ShopProductRecordController { wrapper.orderByAsc(ShopProductRecord::getCreateTime); Page records = recordService.page(new Page<>( Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper); + List result = records.getRecords(); + if (result.size() > 0) { + for (ShopProductRecord record:result){ + ShopProduct product = productService.getById(record.getProductId()); + record.setProduct(product); + } + } return R.ok().put("result", records); } @RequestMapping("/saveRecord") public R saveRecord(@RequestBody ShopProductRecord record) { + record.setRecordTime(new Date()); record.setState(1); recordService.saveOrUpdate(record); return R.ok(); @@ -53,6 +65,7 @@ public class ShopProductRecordController { @RequestMapping("/reSaveRecord") public R reSaveRecord(@RequestBody ShopProductRecord record) { + record.setReRecordTime(new Date()); recordService.saveOrUpdate(record); return R.ok(); } diff --git a/src/main/java/com/peanut/modules/common/entity/ShopProductRecord.java b/src/main/java/com/peanut/modules/common/entity/ShopProductRecord.java index ee8b87dd..a588a8ba 100644 --- a/src/main/java/com/peanut/modules/common/entity/ShopProductRecord.java +++ b/src/main/java/com/peanut/modules/common/entity/ShopProductRecord.java @@ -1,5 +1,6 @@ package com.peanut.modules.common.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; @@ -63,4 +64,7 @@ public class ShopProductRecord implements Serializable { @TableLogic private Integer delFlag; + @TableField(exist = false) + private ShopProduct product; + } diff --git a/src/main/java/com/peanut/modules/job/task/ExpressTask.java b/src/main/java/com/peanut/modules/job/task/ExpressTask.java index 68b31954..c1fad9a2 100644 --- a/src/main/java/com/peanut/modules/job/task/ExpressTask.java +++ b/src/main/java/com/peanut/modules/job/task/ExpressTask.java @@ -2,13 +2,11 @@ package com.peanut.modules.job.task; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper; -import com.peanut.modules.common.entity.BuyOrder; -import com.peanut.modules.common.entity.BuyOrderProduct; -import com.peanut.modules.common.entity.ExpressOrder; -import com.peanut.modules.common.entity.ExpressQueryResponse; +import com.peanut.modules.common.entity.*; import com.peanut.modules.book.service.BuyOrderProductService; import com.peanut.modules.book.service.BuyOrderService; import com.peanut.modules.book.service.ExpressOrderService; +import com.peanut.modules.common.service.ShopProductRecordService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; @@ -23,6 +21,8 @@ public class ExpressTask implements ITask{ private BuyOrderProductService productService; @Autowired private ExpressOrderService expressOrderService; + @Autowired + private ShopProductRecordService recordService; @Override public void run(String params) { @@ -37,6 +37,7 @@ public class ExpressTask implements ITask{ for (BuyOrder buyOrder : list) { MPJLambdaWrapper w = new MPJLambdaWrapper(); w.selectAll(ExpressOrder.class); + w.selectAs(BuyOrderProduct::getProductId,"productId"); w.eq(BuyOrderProduct::getOrderId,buyOrder.getOrderId()); w.leftJoin(ExpressOrder.class,ExpressOrder::getId,BuyOrderProduct::getExpressOrderId); List> plist = productService.listMaps(w); @@ -55,6 +56,12 @@ public class ExpressTask implements ITask{ if (flag){ buyOrder.setOrderStatus("3"); buyOrderService.saveOrUpdate(buyOrder); + for (Map m : plist){ + ShopProductRecord record = new ShopProductRecord(); + record.setProductId(Integer.parseInt(m.get("productId").toString())); + record.setUserId(buyOrder.getUserId()); + recordService.save(record); + } } }