ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsBargainPrice.java
@@ -70,5 +70,24 @@ @TableField(exist = false) private List<GoodsBargainPriceDetail> goodsBargainPriceDetailList; @ApiModelProperty(value = "商品名称") @TableField(exist = false) private String goodsName; @ApiModelProperty(value = "所属分类") @TableField(exist = false) private String categoryName; @ApiModelProperty(value = "门店名称") @TableField(exist = false) private String shopName; @ApiModelProperty(value = "店长名称") @TableField(exist = false) private String ownerName; @ApiModelProperty(value = "店长手机号") @TableField(exist = false) private String ownerPhone; } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsEvaluate.java
@@ -75,10 +75,14 @@ private String avatar; @ApiModelProperty(value = "名字") @ApiModelProperty(value = "评价用户") @TableField(exist = false) private String userName; @ApiModelProperty(value = "联系电话") @TableField(exist = false) private String phone; @ApiModelProperty(value = "商品名字") @TableField(exist = false) private String goodsName; ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java
@@ -3,16 +3,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.Goods; import com.ruoyi.other.api.domain.GoodsBargainPrice; import com.ruoyi.other.api.domain.GoodsBargainPriceDetail; import com.ruoyi.other.api.domain.*; import com.ruoyi.other.api.vo.GetGoodsBargainPrice; import com.ruoyi.other.service.GoodsBargainPriceDetailService; import com.ruoyi.other.service.GoodsBargainPriceService; import com.ruoyi.other.service.GoodsService; import com.ruoyi.other.service.*; import com.ruoyi.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -24,6 +22,7 @@ import javax.annotation.Resource; import java.util.List; import java.util.stream.Collectors; import static com.alibaba.nacos.shaded.org.checkerframework.checker.units.UnitsTools.g; @@ -51,6 +50,15 @@ @Resource private GoodsService goodsService; @Resource private GoodsCategoryService goodsCategoryService; @Resource private AppUserClient appUserClient; @Resource private ShopService shopService; /** @@ -155,16 +163,38 @@ @ApiParam("审核状态") @RequestParam(value = "auditStatus", required = false) Integer auditStatus) { List<Integer> goodsIds = goodsService.listObjs(new LambdaQueryWrapper<Goods>() .select(Goods::getId) List<Goods> goodsList = goodsService.list(new LambdaQueryWrapper<Goods>() .eq(StringUtils.isNotEmpty(goodsName), Goods::getName, goodsName) .eq(goodsType != null, Goods::getType, goodsType) .eq(categoryId != null, Goods::getGoodsCategoryId, categoryId)); List<Integer> goodsIds = goodsList.stream().map(Goods::getId).collect(Collectors.toList()); if (goodsId != null){ goodsIds.add(goodsId); } goodsIds.add(goodsId); Page<GoodsBargainPrice> page = goodsBargainPriceService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<GoodsBargainPrice>() .eq(!CollectionUtils.isEmpty(goodsIds), GoodsBargainPrice::getGoodsId, goodsId) .eq(auditStatus != null, GoodsBargainPrice::getAuditStatus, auditStatus)); page.getRecords().forEach(goodsBargainPrice -> { goodsList.stream() .filter(goods -> goods.getId().equals(goodsBargainPrice.getGoodsId())) .findFirst().ifPresent(g -> { GoodsCategory goodsCategory = goodsCategoryService.getById(g.getGoodsCategoryId()); Integer shopId = goodsBargainPrice.getShopId(); Shop shop = shopService.getById(shopId); R<AppUser> r = appUserClient.getAppUserByPhone(shop.getPhone()); if (R.isError(r)){ throw new RuntimeException("获取店长信息失败"); } goodsBargainPrice.setOwnerName(r.getData().getName()); goodsBargainPrice.setOwnerPhone(shop.getPhone()); goodsBargainPrice.setShopName(shop.getName()); goodsBargainPrice.setGoodsName(g.getName()); goodsBargainPrice.setCategoryName(goodsCategory.getName()); }); }); return R.ok(page); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java
@@ -2,9 +2,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.Goods; import com.ruoyi.other.api.domain.GoodsEvaluate; @@ -19,7 +21,6 @@ import javax.annotation.Resource; import java.util.List; import java.util.stream.Collectors; /** * <p> @@ -84,5 +85,69 @@ return R.ok(list); } /** * 删除评论 */ @DeleteMapping("/delete/{id}") @ApiOperation(value = "删除评论", tags = {"后台管理-商品管理-评价管理-删除评论"}) public R<Void> delete(@PathVariable("id") Long id){ goodsEvaluateService.removeById(id); return R.ok(); } /** * 评论列表 */ @GetMapping("/list") @ApiOperation(value = "评论列表", tags = {"后台管理-商品管理-评价管理-评论列表"}) public R<List<GoodsEvaluate>> list(GoodsEvaluate goodsEvaluate){ List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery() .like(StringUtils.isNotEmpty(goodsEvaluate.getGoodsName()),GoodsEvaluate::getGoodsName, goodsEvaluate.getComment()) .like(StringUtils.isNotEmpty(goodsEvaluate.getUserName()),GoodsEvaluate::getUserName, goodsEvaluate.getUserName()) .like(StringUtils.isNotEmpty(goodsEvaluate.getPhone()),GoodsEvaluate::getPhone, goodsEvaluate.getPhone()) .eq(goodsEvaluate.getStatus()!=null,GoodsEvaluate::getStatus, goodsEvaluate.getStatus()) .orderByDesc(GoodsEvaluate::getCreateTime) .list(); list.forEach(this::buildDetail); return R.ok(list); } private void buildDetail(GoodsEvaluate item) { AppUser appUser = appUserClient.getAppUserById(item.getAppUserId()); if (appUser == null){ throw new RuntimeException("获取用户信息失败"); } Goods goods = goodsService.getById(item.getGoodsId()); item.setGoodsName(goods.getName()); item.setPhone(appUser.getPhone()); item.setUserName(appUser.getName()); } /** * 评论详情 */ @GetMapping("/{id}") @ApiOperation(value = "评论详情", tags = {"后台管理-商品管理-评价管理-评论详情"}) public R<GoodsEvaluate> getDetail(@PathVariable("id") Long id){ GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id); buildDetail(goodsEvaluate); return R.ok(goodsEvaluate); } /** * 评论上/下架 */ @PutMapping("/changeStatus") @ApiOperation(value = "评论上/下架", tags = {"后台管理-商品管理-评价管理-评论上/下架"}) public R<Void> changeStatus(@RequestBody GoodsEvaluate goodsEvaluate){ goodsEvaluateService.update(new LambdaUpdateWrapper<GoodsEvaluate>() .eq(GoodsEvaluate::getId, goodsEvaluate.getId()) .set(GoodsEvaluate::getStatus, goodsEvaluate.getStatus())); return R.ok(); } }