| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | 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.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.domain.GoodsBargainPrice; |
| | | import com.ruoyi.other.api.domain.GoodsBargainPriceDetail; |
| | | import com.ruoyi.other.api.vo.GetGoodsBargainPrice; |
| | | import com.ruoyi.other.service.*; |
| | | import com.ruoyi.other.service.GoodsBargainPriceDetailService; |
| | | import com.ruoyi.other.service.GoodsBargainPriceService; |
| | | 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.*; |
| | | import io.swagger.models.auth.In; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.alibaba.nacos.shaded.org.checkerframework.checker.units.UnitsTools.g; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | @Resource |
| | | private GoodsService goodsService; |
| | | |
| | | @Resource |
| | | private GoodsCategoryService goodsCategoryService; |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Resource |
| | | private ShopService shopService; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "列表", tags = {"管理后台-商品管理-门店特殊售价"}) |
| | | public R<Page<GoodsBargainPrice>> list(@ApiParam("页码") @RequestParam(value = "pageNum", required = false) Integer pageNum, |
| | | public R<IPage<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, |
| | | @ApiParam("商品名称") @RequestParam(value = "goodsName", required = false) String goodsName, |
| | | @ApiParam("商品类型") @RequestParam(value = "goodsType", required = false) Integer goodsType, |
| | | @ApiParam("所属分类") @RequestParam(value = "categoryId", required = false) Integer categoryId, |
| | | @ApiParam("审核状态") @RequestParam(value = "auditStatus", required = false) Integer auditStatus) { |
| | | |
| | | |
| | | 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 (CollectionUtils.isEmpty(goodsIds)){ |
| | | return R.ok(); |
| | | } |
| | | |
| | | Page<GoodsBargainPrice> page = goodsBargainPriceService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<GoodsBargainPrice>() |
| | | .in(!CollectionUtils.isEmpty(goodsIds), GoodsBargainPrice::getGoodsId, goodsIds) |
| | | .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.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); |
| | | GoodsBargainPrice bargainPrice = new GoodsBargainPrice(); |
| | | bargainPrice.setGoodsName(goodsName); |
| | | bargainPrice.setGoodsId(goodsId); |
| | | bargainPrice.setGoodsType(goodsType); |
| | | bargainPrice.setCategoryId(categoryId); |
| | | bargainPrice.setAuditStatus(auditStatus); |
| | | IPage<GoodsBargainPrice> goodsBargainPriceIPage = goodsBargainPriceService.queryGoodsBargainPricePage(Page.of(pageNum, pageSize), bargainPrice); |
| | | return R.ok(goodsBargainPriceIPage); |
| | | } |
| | | |
| | | |
| | |
| | | public R addGoodsBargainPrice(@RequestBody AddGoodsBargainPriceVo vo){ |
| | | return goodsBargainPriceService.addGoodsBargainPrice(vo); |
| | | } |
| | | |
| | | /** |
| | | * 审核商品 |
| | | */ |
| | | @PostMapping("/auditGoods") |
| | | @ApiOperation(value = "审核商品", tags = {"管理后台-商品管理-门店特殊售价"}) |
| | | public R<Void> auditGoods(@RequestBody GoodsBargainPrice goodsBargainPrice) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | Integer id = goodsBargainPrice.getId(); |
| | | GoodsBargainPrice bargainPrice = goodsBargainPriceService.getById(id); |
| | | bargainPrice.setAuditStatus(goodsBargainPrice.getAuditStatus()); |
| | | bargainPrice.setAuditMsg(goodsBargainPrice.getAuditMsg()); |
| | | bargainPrice.setAuditUserId(loginUser.getUserid()); |
| | | bargainPrice.setAuditTime(LocalDateTime.now()); |
| | | goodsBargainPriceService.updateById(bargainPrice); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |