From 51a4ff5d777028d52a19c314a99f796334cb7b51 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 23 十一月 2019 18:30:01 +0800 Subject: [PATCH] 配置文件修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetServiceImpl.java | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 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 dd82728..cd17ff6 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 @@ -98,6 +98,44 @@ } } + + + @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 updateSelectiveByPrimaryKey(BanLiShopGoodsSets set) { @@ -127,4 +165,24 @@ } } + @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