1
phpcjl
2024-12-16 c31c769b7c5864be9973d8dd7e11d9ff8e2ac3e9
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java
@@ -64,8 +64,6 @@
    /**
     * 根据商品id和会员等级获取门店特价
     *
     * @param goodsBargainPrice
     * @return
     */
    @PostMapping("/getGoodsBargainPrice")
    public R<GoodsBargainPriceDetail> getGoodsBargainPrice(@RequestBody GetGoodsBargainPrice goodsBargainPrice) {
@@ -88,7 +86,7 @@
     * 新增
     */
    @PostMapping("/add")
    @ApiOperation(value = "商品管理-门店特殊售价-新增", tags = {"后台管理"})
    @ApiOperation(value = "新增", tags = {"管理后台-商品管理-门店特殊售价"})
    @Transactional(rollbackFor = Exception.class)
    public R<Void> add(@RequestBody GoodsBargainPrice goodsBargainPrice) {
        LoginUser loginUserApplet = tokenService.getLoginUserApplet();
@@ -114,7 +112,7 @@
     * 删除
     */
    @DeleteMapping("/delete")
    @ApiOperation(value = "商品管理-门店特殊售价-删除", tags = {"后台管理"})
    @ApiOperation(value = "删除", tags = {"管理后台-商品管理-门店特殊售价-"})
    public R<Void> delete(@ApiParam("id") @RequestParam("id") Integer id) {
        goodsBargainPriceService.removeById(id);
        goodsBargainPriceDetailService.remove(new LambdaQueryWrapper<GoodsBargainPriceDetail>()
@@ -126,7 +124,7 @@
     * 修改
     */
    @PutMapping("/edit")
    @ApiOperation(value = "商品管理-门店特殊售价-修改", tags = {"后台管理"})
    @ApiOperation(value = "修改", tags = {"管理后台-商品管理-门店特殊售价"})
    @Transactional(rollbackFor = Exception.class)
    public R<Void> edit(@RequestBody GoodsBargainPrice goodsBargainPrice) {
        goodsBargainPriceService.updateById(goodsBargainPrice);
@@ -140,7 +138,7 @@
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperation(value = "商品管理-门店特殊售价-详情", tags = {"后台管理"})
    @ApiOperation(value = "详情", tags = {"管理后台-商品管理-门店特殊售价"})
    public R<GoodsBargainPrice> detail(@ApiParam("id") @RequestParam("id") Integer id) {
        GoodsBargainPrice goodsBargainPrice = goodsBargainPriceService.getById(id);
        List<GoodsBargainPriceDetail> goodsBargainPriceDetailList = goodsBargainPriceDetailService.list(new LambdaQueryWrapper<GoodsBargainPriceDetail>()
@@ -153,7 +151,7 @@
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "商品管理-门店特殊售价-列表", tags = {"后台管理"})
    @ApiOperation(value = "列表", tags = {"管理后台-商品管理-门店特殊售价"})
    public R<Page<GoodsBargainPrice>> list(@ApiParam("页码") @RequestParam(value = "pageNum", required = false) Integer pageNum,
                                           @ApiParam("每页数量") @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                           @ApiParam("商品id") @RequestParam(value = "goodsId", required = false) Integer goodsId,
@@ -176,24 +174,22 @@
                .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());
                    });
        });
        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);
    }