| | |
| | | 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.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.other.api.domain.*; |
| | | import com.ruoyi.other.api.vo.GetGoodsBargainPrice; |
| | | import com.ruoyi.other.service.*; |
| | | import com.ruoyi.other.vo.AddGoodsBargainPriceVo; |
| | | import com.ruoyi.other.vo.GoodsBargainPriceInfo; |
| | | import com.ruoyi.other.vo.ShopGoodsList; |
| | | import com.ruoyi.other.vo.ShopGoodsListVo; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import io.swagger.annotations.*; |
| | | import io.swagger.models.auth.In; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | /** |
| | | * 根据商品id和会员等级获取门店特价 |
| | | * |
| | | * @param goodsBargainPrice |
| | | * @return |
| | | */ |
| | | @PostMapping("/getGoodsBargainPrice") |
| | | public R<GoodsBargainPriceDetail> getGoodsBargainPrice(@RequestBody GetGoodsBargainPrice 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()); |
| | | }); |
| | | }); |
| | | 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); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/getGoodsBargainPriceInfo/{id}") |
| | | @ApiOperation(value = "获取商品特殊售价详情", tags = {"门店后台-商品管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "商品id", name = "id", required = true, dataType = "int"), |
| | | }) |
| | | public R<GoodsBargainPriceInfo> getGoodsBargainPriceInfo(@PathVariable("id") Integer id){ |
| | | GoodsBargainPriceInfo goodsBargainPriceInfo = goodsBargainPriceService.getGoodsBargainPriceInfo(id); |
| | | return R.ok(goodsBargainPriceInfo); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/addGoodsBargainPrice/{id}") |
| | | @ApiOperation(value = "保存商品特殊售价", tags = {"门店后台-商品管理"}) |
| | | public R addGoodsBargainPrice(@RequestBody AddGoodsBargainPriceVo vo){ |
| | | return goodsBargainPriceService.addGoodsBargainPrice(vo); |
| | | } |
| | | } |
| | | |