| | |
| | | /** |
| | | * 根据商品id和会员等级获取门店特价 |
| | | * |
| | | * @param goodsBargainPrice |
| | | * @return |
| | | */ |
| | | @PostMapping("/getGoodsBargainPrice") |
| | | public R<GoodsBargainPriceDetail> getGoodsBargainPrice(@RequestBody GetGoodsBargainPrice goodsBargainPrice) { |
| | |
| | | * 新增 |
| | | */ |
| | | @PostMapping("/add") |
| | | @ApiOperation(value = "新增", tags = {"后台管理-门店特殊售价"}) |
| | | @ApiOperation(value = "新增", tags = {"管理后台-商品管理-门店特殊售价"}) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Void> add(@RequestBody GoodsBargainPrice goodsBargainPrice) { |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | |
| | | * 删除 |
| | | */ |
| | | @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>() |
| | |
| | | * 修改 |
| | | */ |
| | | @PutMapping("/edit") |
| | | @ApiOperation(value = "修改", tags = {"后台管理-门店特殊售价"}) |
| | | @ApiOperation(value = "修改", tags = {"管理后台-商品管理-门店特殊售价"}) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Void> edit(@RequestBody GoodsBargainPrice goodsBargainPrice) { |
| | | goodsBargainPriceService.updateById(goodsBargainPrice); |
| | |
| | | * 详情 |
| | | */ |
| | | @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>() |
| | |
| | | * 列表 |
| | | */ |
| | | @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, |
| | |
| | | .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.getAppUserByPhone1(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); |
| | | } |