ShopCooperationCouponServiceImpl implements
		ShopCooperationCouponService { @Override public List<String> subtractStock(final Long productId,final int quantity){ Map<String, Object> parameters = new HashMap<String,Object>(); parameters.put("productId", productId); parameters.put("_endRow", 1+quantity); parameters.put("_startRow", 1); List<String> info=new ArrayList<String>(); List<ShopCooperationCoupon> list = shopCooperationCouponDAO.query(parameters); if(null != list && !list.isEmpty() && quantity == list.size() ){ List<Long> idList = new ArrayList<Long>(); for(ShopCooperationCoupon coupon:list){ idList.add(coupon.getId()); info.add(coupon.getCouponInfo()); } parameters.clear(); parameters.put("idList",idList); int i=shopCooperationCouponDAO.batchDeleteCoupon(parameters); parameters.clear(); parameters.put("productId", productId); updateProductStock(parameters,productId); if(i!=quantity){ LOG.info("productId="+productId+" "+" quatity="+quantity+" delete result number is "+i); } } return info; }  @Override int batchInsertCoupon(final List<ShopCooperationCoupon> list,final boolean isClean,final Long productId,final String operatorId); @Override int batchDeleteCoupon(final Map<String, Object> parameters); @Override List<ShopCooperationCoupon> query(final Map<String, Object> parameters); @Override Long count(final Map<String, Object> parameters); @Override ShopCooperationCoupon queryByParameters(
			final Map<String, Object> parameters); @Override ShopCooperationCoupon queryCouponByKey(final Long key); @Override List<String> subtractStock(final Long productId,final int quantity); ShopCooperationCouponDAO getShopCooperationCouponDAO(); void setShopCooperationCouponDAO(
			ShopCooperationCouponDAO shopCooperationCouponDAO); ShopProductDAO getShopProductDAO(); void setShopProductDAO(ShopProductDAO shopProductDAO); ShopLogService getShopLogService(); void setShopLogService(ShopLogService shopLogService);  }
@Test public void testSubtractStock() { List<String> infoList = shopCooperationCouponService.subtractStock(4L,3); for(int i=0;i<infoList.size();i++){ System.out.println(infoList.get(i)); } Assert.assertEquals(3, infoList.size()); }