| | |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.other.api.domain.Goods; |
| | | import com.ruoyi.other.api.domain.GoodsEvaluate; |
| | | import com.ruoyi.other.mapper.GoodsEvaluateMapper; |
| | | import com.ruoyi.other.service.GoodsEvaluateService; |
| | | import com.ruoyi.other.service.GoodsService; |
| | | import com.ruoyi.other.vo.GoodsEvaluateVO; |
| | |
| | | @Resource |
| | | private GoodsEvaluateService goodsEvaluateService; |
| | | @Resource |
| | | private GoodsEvaluateMapper goodsEvaluateMapper; |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | @Resource |
| | | private GoodsService goodsService; |
| | |
| | | private OrderClient orderClient; |
| | | |
| | | |
| | | /** |
| | | * 通过订单id查询评价id |
| | | */ |
| | | @GetMapping("/getEvaluateIdByOrderId") |
| | | public R<Long> getEvaluateIdByOrderId( @RequestParam("orderId") Long orderId) { |
| | | GoodsEvaluate evaluate = goodsEvaluateMapper.selectOne(new LambdaQueryWrapper<GoodsEvaluate>() |
| | | .eq(GoodsEvaluate::getOrderId, orderId).eq(GoodsEvaluate::getDelFlag,0).eq(GoodsEvaluate::getStatus,2)); |
| | | if (evaluate != null) { |
| | | return R.ok(evaluate.getId()); |
| | | } |
| | | return R.ok(null); |
| | | |
| | | } |
| | | |
| | | @GetMapping("/goodsList") |
| | | @ApiOperation(value = "获取商品评价", tags = {"小程序-获取商品评价"}) |
| | |
| | | */ |
| | | @PostMapping("/addGoodsEvaluate") |
| | | @ApiOperation(value = "发布商品评价", tags = {"小程序-个人中心-我的订单"}) |
| | | public R<Void> addGoodsEvaluate(@RequestBody GoodsEvaluateVO goodsEvaluateVO){ |
| | | goodsEvaluateService.addGoodsEvaluate(goodsEvaluateVO); |
| | | return R.ok(); |
| | | public R addGoodsEvaluate(@RequestBody GoodsEvaluate goodsEvaluate){ |
| | | |
| | | return goodsEvaluateService.addGoodsEvaluate(goodsEvaluate); |
| | | } |
| | | |
| | | /** |
| | | * 评论详情 |
| | | * 商品评价详情 |
| | | */ |
| | | @GetMapping("/detail/{orderId}") |
| | | @ApiOperation(value = "评论详情", tags = {"小程序-评论详情"}) |
| | | public R<List<GoodsEvaluate>> detail(@PathVariable("orderId") Long orderId){ |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | List<GoodsEvaluate> list = goodsEvaluateService.list(new LambdaQueryWrapper<GoodsEvaluate>() |
| | | @ApiOperation(value = "评价详情", tags = {"小程序-查看自己的评价"}) |
| | | public R<GoodsEvaluate> detail(@PathVariable("orderId") Long orderId){ |
| | | GoodsEvaluate evaluate = goodsEvaluateService.getOne(new LambdaQueryWrapper<GoodsEvaluate>() |
| | | .eq(GoodsEvaluate::getStatus, 2) |
| | | .eq(GoodsEvaluate::getAppUserId,loginUserApplet.getUserid()) |
| | | .eq(GoodsEvaluate::getDelFlag, 0) |
| | | .eq(GoodsEvaluate::getOrderId, orderId)); |
| | | for (GoodsEvaluate goodsEvaluate : list) { |
| | | Goods goods = goodsService.getById(goodsEvaluate.getGoodsId()); |
| | | goodsEvaluate.setGoodsName(goods.getName()); |
| | | goodsEvaluate.setGoodsImg(goods.getHomePagePicture()); |
| | | if(evaluate==null){ |
| | | return R.fail("未评价"); |
| | | } |
| | | return R.ok(list); |
| | | Goods goods = goodsService.getById(evaluate.getGoodsId()); |
| | | evaluate.setGoodsName(goods.getName()); |
| | | evaluate.setGoodsImg(goods.getHomePagePicture()); |
| | | |
| | | return R.ok(evaluate); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除评论 |
| | | * 删除评价 |
| | | */ |
| | | @DeleteMapping("/delete/{id}") |
| | | @ApiOperation(value = "删除评论", tags = {"管理后台-商品管理-评价管理"}) |
| | |
| | | Goods goods = goodsService.getById(item.getGoodsId()); |
| | | if(null != goods){ |
| | | item.setGoodsName(goods.getName()); |
| | | item.setGoodsImg(goods.getHomePagePicture()); |
| | | } |
| | | } |
| | | |
| | |
| | | * 评论详情 |
| | | */ |
| | | @GetMapping("/{id}") |
| | | @ApiOperation(value = "评论详情", tags = {"管理后台-商品管理-评价管理"}) |
| | | @ApiOperation(value = "评论详情", tags = {"管理后台-商品管理-评价管理","门店后台-订单-查看用户评价详情"}) |
| | | public R<GoodsEvaluate> getDetail(@PathVariable("id") Long id){ |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id); |
| | | if (null==goodsEvaluate){ |
| | | return R.fail("未找到该评论"); |
| | | } |
| | | buildDetail(goodsEvaluate); |
| | | return R.ok(goodsEvaluate); |
| | | } |