1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /*
- * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * Neither the name of the dreamlu.net developer nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * Author: Chill 庄骞 (smallchill@163.com)
- */
- package com.foonsu.efenxiao.platform.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.foonsu.efenxiao.platform.entity.PlatformGoods;
- import com.foonsu.efenxiao.platform.entity.PlatformGoodsDistribute;
- import com.foonsu.efenxiao.platform.entity.PlatformGoodsSku;
- import com.foonsu.efenxiao.platform.vo.PlatformGoodsSkuVO;
- import com.foonsu.efenxiao.platform.mapper.PlatformGoodsSkuMapper;
- import com.foonsu.efenxiao.platform.service.IPlatformGoodsSkuService;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import org.checkerframework.checker.units.qual.A;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * 服务实现类
- *
- * @author BladeX
- * @since 2022-03-17
- */
- @Service
- public class PlatformGoodsSkuServiceImpl extends ServiceImpl<PlatformGoodsSkuMapper, PlatformGoodsSku> implements IPlatformGoodsSkuService {
- @Autowired
- private PlatformGoodsDistributeServiceImpl platformGoodsDistributeService;
- @Override
- public IPage<PlatformGoodsSkuVO> selectPlatformGoodsSkuPage(IPage<PlatformGoodsSkuVO> page, PlatformGoodsSkuVO platformGoodsSku) {
- return page.setRecords(baseMapper.selectPlatformGoodsSkuPage(page, platformGoodsSku));
- }
- @Override
- public PlatformGoodsSku queryByProductIdSkuId(Long shopBizId, String productId, String skuId) {
- LambdaQueryWrapper<PlatformGoodsSku> queryWrapper = Wrappers.<PlatformGoodsSku>query().lambda().eq(PlatformGoodsSku::getShopBizId, shopBizId)
- .eq(PlatformGoodsSku::getProductId, productId).eq(PlatformGoodsSku::getSkuId, skuId);
- List<PlatformGoodsSku> skus = baseMapper.selectList(queryWrapper);
- return skus.size()>0?skus.get(0):null;
- }
- @Override
- @Transactional
- public void addPlatformGoodsSku(PlatformGoodsSku sku, PlatformGoodsDistribute platformGoodsDistribute) {
- this.save(sku);
- platformGoodsDistributeService.save(platformGoodsDistribute);
- }
- @Override
- public List<PlatformGoodsSku> queryByProductIdsSkuIds(Long shopId, List<String> productIds, List<String> skuIds) {
- if(skuIds.size() == 0){
- return new ArrayList<>();
- }
- LambdaQueryWrapper<PlatformGoodsSku> queryWrapper = Wrappers.<PlatformGoodsSku>query().lambda().eq(PlatformGoodsSku::getShopBizId, shopId)
- .in(PlatformGoodsSku::getProductId, productIds).in(PlatformGoodsSku::getSkuId, skuIds);
- List<PlatformGoodsSku> skus = baseMapper.selectList(queryWrapper);
- return skus;
- }
- }
|