| | |
| | | return banLiShopGoodsSetsMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | @Override
|
| | | public void addSet(BanLiShopGoodsSets set) throws BanLiShopGoodsSetException, BanLiShopGoodsSetPayException {
|
| | | if (set.getId() == null)// 添加
|
| | |
| | | }
|
| | |
|
| | | }
|
| | | |
| | | |
| | | @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) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @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); |
| | | }
|
| | |
|
| | | }
|