From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetServiceImpl.java | 351 +++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 210 insertions(+), 141 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetServiceImpl.java index 634d06c..bdd5da1 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetServiceImpl.java @@ -1,141 +1,210 @@ -package com.yeshi.fanli.service.impl.shop; - -import java.util.Date; -import java.util.List; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.yeshi.fanli.dao.mybatis.shop.BanLiShopGoodsSetsMapper; -import com.yeshi.fanli.entity.shop.BanLiShopGoodsSets; -import com.yeshi.fanli.entity.shop.BanLiShopGoodsSetsPay; -import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetException; -import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetPayException; -import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetPayService; -import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetService; -import com.yeshi.fanli.util.StringUtil; - -@Service -public class BanLiShopGoodsSetServiceImpl implements BanLiShopGoodsSetService { - - @Resource - private BanLiShopGoodsSetPayService banLiShopGoodsSetPayService; - - @Resource - private BanLiShopGoodsSetsMapper banLiShopGoodsSetsMapper; - - @Override - public List<BanLiShopGoodsSets> listByGoodsId(Long goodsId) { - return banLiShopGoodsSetsMapper.listByGoodsId(goodsId); - } - - @Override - public int countByGoodsId(Long goodsId) { - return (int) banLiShopGoodsSetsMapper.countByGoodsId(goodsId); - } - - @Override - public BanLiShopGoodsSets selectByPrimaryKey(Long id) { - return banLiShopGoodsSetsMapper.selectByPrimaryKey(id); - } - - @Transactional - @Override - public void addSet(BanLiShopGoodsSets set) throws BanLiShopGoodsSetException, BanLiShopGoodsSetPayException { - if (set.getId() == null)// 娣诲姞 - { - if (set.getGoods() == null || set.getGoods().getId() == null) { - throw new BanLiShopGoodsSetException(1, "璇锋寚瀹氬晢鍝�"); - } - - if (StringUtil.isNullOrEmpty(set.getName())) - throw new BanLiShopGoodsSetException(1, "缂哄皯濂楅鍚嶅瓧"); - - if (set.getOriginalPrice() == null || set.getZkPrice() == null) { - throw new BanLiShopGoodsSetException(1, "浠锋牸淇℃伅涓嶅畬鏁�"); - } - - if (set.getStock() == null) { - throw new BanLiShopGoodsSetException(1, "缂哄皯搴撳瓨淇℃伅"); - } - - if (set.getSalesCount() == null) - set.setSalesCount(0L); - - if (set.getCreateTime() == null) - set.setCreateTime(new Date()); - - banLiShopGoodsSetsMapper.insertSelective(set); - if (set.getWeight() == null) {// 鏉冮噸鏇存柊 - BanLiShopGoodsSets update = new BanLiShopGoodsSets(); - update.setId(set.getId()); - update.setWeight((int) set.getId().longValue()); - banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(update); - } - - if (set.getPayList() != null && set.getPayList().size() > 0) { - for (BanLiShopGoodsSetsPay pay : set.getPayList())// 娣诲姞鏀粯鏂瑰紡 - { - pay.setGoodsSet(set); - banLiShopGoodsSetPayService.addSetPay(pay); - } - } - - } else {// 淇敼 - if (set.getUpdateTime() == null) { - set.setUpdateTime(new Date()); - } - - banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(set); - - // 鏇存柊鏀粯鏂瑰紡 - if (set.getPayList() != null && set.getPayList().size() > 0) { - for (BanLiShopGoodsSetsPay pay : set.getPayList())// 鏇存柊鏀粯鏂瑰紡 - banLiShopGoodsSetPayService.addSetPay(pay); - } - } - - } - - @Override - public void updateSelectiveByPrimaryKey(BanLiShopGoodsSets set) { - if (set.getId() == null) - return; - if (set.getUpdateTime() == null) - set.setUpdateTime(new Date()); - banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(set); - } - - @Transactional - @Override - public void delete(List<Long> idsList) { - if (idsList != null) - for (Long id : idsList) - deleteByPrimaryKey(id); - } - - @Transactional - @Override - public void deleteByPrimaryKey(Long id) { - banLiShopGoodsSetsMapper.deleteByPrimaryKey(id); - List<BanLiShopGoodsSetsPay> payList = banLiShopGoodsSetPayService.listByGoodsSetId(id); - if (payList != null) - for (BanLiShopGoodsSetsPay pay : payList) {// 鍒犻櫎鏀粯鏂瑰紡 - banLiShopGoodsSetPayService.deleteByPrimaryKey(pay.getId()); - } - } - - - @Override - public List<BanLiShopGoodsSets> listQuery(int page, int pageSize, String key) { - return banLiShopGoodsSetsMapper.listQuery((page - 1) * pageSize, pageSize, key); - } - - @Override - public long countQuery(String key) { - return banLiShopGoodsSetsMapper.countQuery(key); - } - -} +package com.yeshi.fanli.service.impl.shop; + +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.yeshi.fanli.dao.mybatis.shop.BanLiShopGoodsSetsMapper; +import com.yeshi.fanli.entity.shop.BanLiShopGoodsSets; +import com.yeshi.fanli.entity.shop.BanLiShopGoodsSetsPay; +import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetException; +import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetPayException; +import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetPayService; +import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetService; +import com.yeshi.fanli.util.StringUtil; + +@Service +public class BanLiShopGoodsSetServiceImpl implements BanLiShopGoodsSetService { + + @Resource + private BanLiShopGoodsSetPayService banLiShopGoodsSetPayService; + + @Resource + private BanLiShopGoodsSetsMapper banLiShopGoodsSetsMapper; + + @Override + public List<BanLiShopGoodsSets> listByGoodsId(Long goodsId) { + return banLiShopGoodsSetsMapper.listByGoodsId(goodsId); + } + + @Override + public int countByGoodsId(Long goodsId) { + return (int) banLiShopGoodsSetsMapper.countByGoodsId(goodsId); + } + + @Override + public BanLiShopGoodsSets selectByPrimaryKey(Long id) { + return banLiShopGoodsSetsMapper.selectByPrimaryKey(id); + } + + @Transactional(rollbackFor=Exception.class) + @Override + public void addSet(BanLiShopGoodsSets set) throws BanLiShopGoodsSetException, BanLiShopGoodsSetPayException { + if (set.getId() == null)// 娣诲姞 + { + if (set.getGoods() == null || set.getGoods().getId() == null) { + throw new BanLiShopGoodsSetException(1, "璇锋寚瀹氬晢鍝�"); + } + + if (StringUtil.isNullOrEmpty(set.getName())) + throw new BanLiShopGoodsSetException(1, "缂哄皯濂楅鍚嶅瓧"); + + if (set.getOriginalPrice() == null || set.getZkPrice() == null) { + throw new BanLiShopGoodsSetException(1, "浠锋牸淇℃伅涓嶅畬鏁�"); + } + + if (set.getStock() == null) { + throw new BanLiShopGoodsSetException(1, "缂哄皯搴撳瓨淇℃伅"); + } + + if (set.getSalesCount() == null) + set.setSalesCount(0L); + + if (set.getCreateTime() == null) + set.setCreateTime(new Date()); + + banLiShopGoodsSetsMapper.insertSelective(set); + if (set.getWeight() == null) {// 鏉冮噸鏇存柊 + BanLiShopGoodsSets update = new BanLiShopGoodsSets(); + update.setId(set.getId()); + update.setWeight((int) set.getId().longValue()); + banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(update); + } + + if (set.getPayList() != null && set.getPayList().size() > 0) { + for (BanLiShopGoodsSetsPay pay : set.getPayList())// 娣诲姞鏀粯鏂瑰紡 + { + pay.setGoodsSet(set); + banLiShopGoodsSetPayService.addSetPay(pay); + } + } + + } else {// 淇敼 + if (set.getUpdateTime() == null) { + set.setUpdateTime(new Date()); + } + + banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(set); + + // 鏇存柊鏀粯鏂瑰紡 + if (set.getPayList() != null && set.getPayList().size() > 0) { + for (BanLiShopGoodsSetsPay pay : set.getPayList())// 鏇存柊鏀粯鏂瑰紡 + banLiShopGoodsSetPayService.addSetPay(pay); + } + } + + } + + + @Override + public void saveObject(BanLiShopGoodsSets record) throws BanLiShopGoodsSetException { + if (record.getGoods() == null || record.getGoods().getId() == null) + throw new BanLiShopGoodsSetException(1, "璇锋寚瀹氬晢鍝�"); + + if (StringUtil.isNullOrEmpty(record.getName())) + throw new BanLiShopGoodsSetException(1, "缂哄皯濂楅鍚嶅瓧"); + + if (record.getOriginalPrice() == null || record.getZkPrice() == null) + throw new BanLiShopGoodsSetException(1, "浠锋牸淇℃伅涓嶅畬鏁�"); + + if (record.getStock() == null) + throw new BanLiShopGoodsSetException(1, "缂哄皯搴撳瓨淇℃伅"); + + record.setUpdateTime(new Date()); + if (record.getId() == null) { + record.setCreateTime(new Date()); + banLiShopGoodsSetsMapper.insertSelective(record); + + if (record.getWeight() == null) {// 鏉冮噸鏇存柊 + BanLiShopGoodsSets update = new BanLiShopGoodsSets(); + update.setId(record.getId()); + update.setWeight((int) record.getId().longValue()); + banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(update); + } + } else { + BanLiShopGoodsSets resultObj = banLiShopGoodsSetsMapper.selectDetailByPrimaryKey(record.getId()); + if (resultObj == null) + throw new BanLiShopGoodsSetException(1, "淇敼鍐呭宸蹭笉瀛樺湪"); + + record.setCreateTime(resultObj.getCreateTime()); + banLiShopGoodsSetsMapper.updateByPrimaryKey(record); + } + } + + + @Override + public void switchState(Long id) throws BanLiShopGoodsSetException { + if (id == null) { + throw new BanLiShopGoodsSetException(1, "璇蜂紶閫掓纭弬鏁�"); + } + BanLiShopGoodsSets resultObj = banLiShopGoodsSetsMapper.selectByPrimaryKey(id); + if (resultObj == null) { + throw new BanLiShopGoodsSetException(1, "姝ゅ唴瀹瑰凡涓嶅瓨鍦�"); + } + + Integer state = resultObj.getState(); + if (state == null || state == 0) { + state = 1; + } else { + state = 0; + } + + BanLiShopGoodsSets updateObj = new BanLiShopGoodsSets(); + updateObj.setId(id); + updateObj.setState(state); + banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(updateObj); + } + + @Override + public void updateSelectiveByPrimaryKey(BanLiShopGoodsSets set) { + if (set.getId() == null) + return; + if (set.getUpdateTime() == null) + set.setUpdateTime(new Date()); + banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(set); + } + + @Transactional + @Override + public void delete(List<Long> idsList) { + if (idsList != null) + for (Long id : idsList) + deleteByPrimaryKey(id); + } + + @Transactional + @Override + public void deleteByPrimaryKey(Long id) { + banLiShopGoodsSetsMapper.deleteByPrimaryKey(id); + List<BanLiShopGoodsSetsPay> payList = banLiShopGoodsSetPayService.listByGoodsSetId(id); + if (payList != null) + for (BanLiShopGoodsSetsPay pay : payList) {// 鍒犻櫎鏀粯鏂瑰紡 + banLiShopGoodsSetPayService.deleteByPrimaryKey(pay.getId()); + } + } + + @Override + public List<BanLiShopGoodsSets> listQuery(int page, int pageSize, String key, Long goodsId) { + return banLiShopGoodsSetsMapper.listQuery((page - 1) * pageSize, pageSize, key, goodsId); + } + + @Override + public long countQuery(String key, Long goodsId) { + return banLiShopGoodsSetsMapper.countQuery(key, goodsId); + } + + @Override + public void addSalesCount(Long id, int count) { + BanLiShopGoodsSets set = banLiShopGoodsSetsMapper.selectByPrimaryKey(id); + BanLiShopGoodsSets update = new BanLiShopGoodsSets(); + update.setId(set.getId()); + update.setSalesCount(set.getSalesCount() + count); + update.setStock(set.getStock() - count); + banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(update); + } + +} -- Gitblit v1.8.0