PlatformGoodsSkuServiceImpl.java 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the dreamlu.net developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: Chill 庄骞 (smallchill@163.com)
  16. */
  17. package com.foonsu.efenxiao.platform.service.impl;
  18. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  19. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  20. import com.foonsu.efenxiao.platform.entity.PlatformGoods;
  21. import com.foonsu.efenxiao.platform.entity.PlatformGoodsDistribute;
  22. import com.foonsu.efenxiao.platform.entity.PlatformGoodsSku;
  23. import com.foonsu.efenxiao.platform.vo.PlatformGoodsSkuVO;
  24. import com.foonsu.efenxiao.platform.mapper.PlatformGoodsSkuMapper;
  25. import com.foonsu.efenxiao.platform.service.IPlatformGoodsSkuService;
  26. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  27. import org.checkerframework.checker.units.qual.A;
  28. import org.springframework.beans.factory.annotation.Autowired;
  29. import org.springframework.stereotype.Service;
  30. import com.baomidou.mybatisplus.core.metadata.IPage;
  31. import org.springframework.transaction.annotation.Transactional;
  32. import java.util.ArrayList;
  33. import java.util.List;
  34. /**
  35. * 服务实现类
  36. *
  37. * @author BladeX
  38. * @since 2022-03-17
  39. */
  40. @Service
  41. public class PlatformGoodsSkuServiceImpl extends ServiceImpl<PlatformGoodsSkuMapper, PlatformGoodsSku> implements IPlatformGoodsSkuService {
  42. @Autowired
  43. private PlatformGoodsDistributeServiceImpl platformGoodsDistributeService;
  44. @Override
  45. public IPage<PlatformGoodsSkuVO> selectPlatformGoodsSkuPage(IPage<PlatformGoodsSkuVO> page, PlatformGoodsSkuVO platformGoodsSku) {
  46. return page.setRecords(baseMapper.selectPlatformGoodsSkuPage(page, platformGoodsSku));
  47. }
  48. @Override
  49. public PlatformGoodsSku queryByProductIdSkuId(Long shopBizId, String productId, String skuId) {
  50. LambdaQueryWrapper<PlatformGoodsSku> queryWrapper = Wrappers.<PlatformGoodsSku>query().lambda().eq(PlatformGoodsSku::getShopBizId, shopBizId)
  51. .eq(PlatformGoodsSku::getProductId, productId).eq(PlatformGoodsSku::getSkuId, skuId);
  52. List<PlatformGoodsSku> skus = baseMapper.selectList(queryWrapper);
  53. return skus.size()>0?skus.get(0):null;
  54. }
  55. @Override
  56. @Transactional
  57. public void addPlatformGoodsSku(PlatformGoodsSku sku, PlatformGoodsDistribute platformGoodsDistribute) {
  58. this.save(sku);
  59. platformGoodsDistributeService.save(platformGoodsDistribute);
  60. }
  61. @Override
  62. public List<PlatformGoodsSku> queryByProductIdsSkuIds(Long shopId, List<String> productIds, List<String> skuIds) {
  63. if(skuIds.size() == 0){
  64. return new ArrayList<>();
  65. }
  66. LambdaQueryWrapper<PlatformGoodsSku> queryWrapper = Wrappers.<PlatformGoodsSku>query().lambda().eq(PlatformGoodsSku::getShopBizId, shopId)
  67. .in(PlatformGoodsSku::getProductId, productIds).in(PlatformGoodsSku::getSkuId, skuIds);
  68. List<PlatformGoodsSku> skus = baseMapper.selectList(queryWrapper);
  69. return skus;
  70. }
  71. }