通用模块-商品评价
This commit is contained in:
@@ -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<ShopProductToBookLabel> 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<ShopProductToBookLabel> 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<ShopProductToBookMarket> 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<ShopProductToBookMarket> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(ShopProductToBookMarket::getBookMarketId,marketId);
|
||||
wrapper.eq(ShopProductToBookMarket::getProductId,id);
|
||||
toMarketService.remove(wrapper);
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<String, Object> params) {
|
||||
@@ -41,11 +45,19 @@ public class ShopProductRecordController {
|
||||
wrapper.orderByAsc(ShopProductRecord::getCreateTime);
|
||||
Page<ShopProductRecord> records = recordService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
|
||||
List<ShopProductRecord> 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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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<BuyOrderProduct> 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<Map<String,Object>> plist = productService.listMaps(w);
|
||||
@@ -55,6 +56,12 @@ public class ExpressTask implements ITask{
|
||||
if (flag){
|
||||
buyOrder.setOrderStatus("3");
|
||||
buyOrderService.saveOrUpdate(buyOrder);
|
||||
for (Map<String,Object> m : plist){
|
||||
ShopProductRecord record = new ShopProductRecord();
|
||||
record.setProductId(Integer.parseInt(m.get("productId").toString()));
|
||||
record.setUserId(buyOrder.getUserId());
|
||||
recordService.save(record);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user