1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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  public class ShoppingCouponServiceImpl extends ShoppingCouponServiceBaseImpl {
41  
42      public ShoppingCoupon addCoupon(
43              long plid, String code, boolean autoCode, String name,
44              String description, int startDateMonth, int startDateDay,
45              int startDateYear, int startDateHour, int startDateMinute,
46              int endDateMonth, int endDateDay, int endDateYear, int endDateHour,
47              int endDateMinute, boolean neverExpire, boolean active,
48              String limitCategories, String limitSkus, double minOrder,
49              double discount, String discountType)
50          throws PortalException, SystemException {
51  
52          PortletPermissionUtil.check(
53              getPermissionChecker(), plid, PortletKeys.SHOPPING,
54              ActionKeys.MANAGE_COUPONS);
55  
56          return shoppingCouponLocalService.addCoupon(
57              getUserId(), plid, code, autoCode, name, description,
58              startDateMonth, startDateDay, startDateYear, startDateHour,
59              startDateMinute, endDateMonth, endDateDay, endDateYear, endDateHour,
60              endDateMinute, neverExpire, active, limitCategories, limitSkus,
61              minOrder, discount, discountType);
62      }
63  
64      public void deleteCoupon(long plid, long couponId)
65          throws PortalException, SystemException {
66  
67          PortletPermissionUtil.check(
68              getPermissionChecker(), plid, PortletKeys.SHOPPING,
69              ActionKeys.MANAGE_COUPONS);
70  
71          shoppingCouponLocalService.deleteCoupon(couponId);
72      }
73  
74      public ShoppingCoupon getCoupon(long plid, long couponId)
75          throws PortalException, SystemException {
76  
77          PortletPermissionUtil.check(
78              getPermissionChecker(), plid, PortletKeys.SHOPPING,
79              ActionKeys.MANAGE_COUPONS);
80  
81          return shoppingCouponLocalService.getCoupon(couponId);
82      }
83  
84      public List<ShoppingCoupon> search(
85              long plid, long companyId, String code, boolean active,
86              String discountType, boolean andOperator, int start, int end)
87          throws PortalException, SystemException {
88  
89          PortletPermissionUtil.check(
90              getPermissionChecker(), plid, PortletKeys.SHOPPING,
91              ActionKeys.MANAGE_COUPONS);
92  
93          return shoppingCouponLocalService.search(
94              plid, companyId, code, active, discountType, andOperator, start,
95              end);
96      }
97  
98      public ShoppingCoupon updateCoupon(
99              long plid, long couponId, String name, String description,
100             int startDateMonth, int startDateDay, int startDateYear,
101             int startDateHour, int startDateMinute, int endDateMonth,
102             int endDateDay, int endDateYear, int endDateHour, int endDateMinute,
103             boolean neverExpire, boolean active, String limitCategories,
104             String limitSkus, double minOrder, double discount,
105             String discountType)
106         throws PortalException, SystemException {
107 
108         PortletPermissionUtil.check(
109             getPermissionChecker(), plid, PortletKeys.SHOPPING,
110             ActionKeys.MANAGE_COUPONS);
111 
112         return shoppingCouponLocalService.updateCoupon(
113             getUserId(), couponId, name, description, startDateMonth,
114             startDateDay, startDateYear, startDateHour, startDateMinute,
115             endDateMonth, endDateDay, endDateYear, endDateHour, endDateMinute,
116             neverExpire, active, limitCategories, limitSkus, minOrder, discount,
117             discountType);
118     }
119 
120 }