1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.shopping.service.impl;
24  
25  import com.liferay.portal.PortalException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.security.permission.ActionKeys;
28  import com.liferay.portal.service.permission.PortletPermissionUtil;
29  import com.liferay.portal.util.PortletKeys;
30  import com.liferay.portlet.shopping.model.ShoppingCoupon;
31  import com.liferay.portlet.shopping.service.base.ShoppingCouponServiceBaseImpl;
32  
33  import java.util.List;
34  
35  /**
36   * <a href="ShoppingCouponServiceImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * @author Brian Wing Shun Chan
39   *
40   */
41  public class ShoppingCouponServiceImpl extends ShoppingCouponServiceBaseImpl {
42  
43      public ShoppingCoupon addCoupon(
44              long plid, String code, boolean autoCode, String name,
45              String description, int startDateMonth, int startDateDay,
46              int startDateYear, int startDateHour, int startDateMinute,
47              int endDateMonth, int endDateDay, int endDateYear, int endDateHour,
48              int endDateMinute, boolean neverExpire, boolean active,
49              String limitCategories, String limitSkus, double minOrder,
50              double discount, String discountType)
51          throws PortalException, SystemException {
52  
53          PortletPermissionUtil.check(
54              getPermissionChecker(), plid, PortletKeys.SHOPPING,
55              ActionKeys.MANAGE_COUPONS);
56  
57          return shoppingCouponLocalService.addCoupon(
58              getUserId(), plid, code, autoCode, name, description,
59              startDateMonth, startDateDay, startDateYear, startDateHour,
60              startDateMinute, endDateMonth, endDateDay, endDateYear, endDateHour,
61              endDateMinute, neverExpire, active, limitCategories, limitSkus,
62              minOrder, discount, discountType);
63      }
64  
65      public void deleteCoupon(long plid, long couponId)
66          throws PortalException, SystemException {
67  
68          PortletPermissionUtil.check(
69              getPermissionChecker(), plid, PortletKeys.SHOPPING,
70              ActionKeys.MANAGE_COUPONS);
71  
72          shoppingCouponLocalService.deleteCoupon(couponId);
73      }
74  
75      public ShoppingCoupon getCoupon(long plid, long couponId)
76          throws PortalException, SystemException {
77  
78          PortletPermissionUtil.check(
79              getPermissionChecker(), plid, PortletKeys.SHOPPING,
80              ActionKeys.MANAGE_COUPONS);
81  
82          return shoppingCouponLocalService.getCoupon(couponId);
83      }
84  
85      public List<ShoppingCoupon> search(
86              long plid, long companyId, String code, boolean active,
87              String discountType, boolean andOperator, int begin, int end)
88          throws PortalException, SystemException {
89  
90          PortletPermissionUtil.check(
91              getPermissionChecker(), plid, PortletKeys.SHOPPING,
92              ActionKeys.MANAGE_COUPONS);
93  
94          return shoppingCouponLocalService.search(
95              plid, companyId, code, active, discountType, andOperator, begin,
96              end);
97      }
98  
99      public ShoppingCoupon updateCoupon(
100             long plid, long couponId, String name, String description,
101             int startDateMonth, int startDateDay, int startDateYear,
102             int startDateHour, int startDateMinute, int endDateMonth,
103             int endDateDay, int endDateYear, int endDateHour, int endDateMinute,
104             boolean neverExpire, boolean active, String limitCategories,
105             String limitSkus, double minOrder, double discount,
106             String discountType)
107         throws PortalException, SystemException {
108 
109         PortletPermissionUtil.check(
110             getPermissionChecker(), plid, PortletKeys.SHOPPING,
111             ActionKeys.MANAGE_COUPONS);
112 
113         return shoppingCouponLocalService.updateCoupon(
114             getUserId(), couponId, name, description, startDateMonth,
115             startDateDay, startDateYear, startDateHour, startDateMinute,
116             endDateMonth, endDateDay, endDateYear, endDateHour, endDateMinute,
117             neverExpire, active, limitCategories, limitSkus, minOrder, discount,
118             discountType);
119     }
120 
121 }