1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.shopping.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.security.permission.ActionKeys;
20  import com.liferay.portal.service.permission.PortletPermissionUtil;
21  import com.liferay.portal.util.PortletKeys;
22  import com.liferay.portlet.shopping.model.ShoppingCoupon;
23  import com.liferay.portlet.shopping.service.base.ShoppingCouponServiceBaseImpl;
24  
25  import java.util.List;
26  
27  /**
28   * <a href="ShoppingCouponServiceImpl.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   */
32  public class ShoppingCouponServiceImpl extends ShoppingCouponServiceBaseImpl {
33  
34      public ShoppingCoupon addCoupon(
35              long plid, String code, boolean autoCode, String name,
36              String description, int startDateMonth, int startDateDay,
37              int startDateYear, int startDateHour, int startDateMinute,
38              int endDateMonth, int endDateDay, int endDateYear, int endDateHour,
39              int endDateMinute, boolean neverExpire, boolean active,
40              String limitCategories, String limitSkus, double minOrder,
41              double discount, String discountType)
42          throws PortalException, SystemException {
43  
44          PortletPermissionUtil.check(
45              getPermissionChecker(), plid, PortletKeys.SHOPPING,
46              ActionKeys.MANAGE_COUPONS);
47  
48          return shoppingCouponLocalService.addCoupon(
49              getUserId(), plid, code, autoCode, name, description,
50              startDateMonth, startDateDay, startDateYear, startDateHour,
51              startDateMinute, endDateMonth, endDateDay, endDateYear, endDateHour,
52              endDateMinute, neverExpire, active, limitCategories, limitSkus,
53              minOrder, discount, discountType);
54      }
55  
56      public void deleteCoupon(long plid, long couponId)
57          throws PortalException, SystemException {
58  
59          PortletPermissionUtil.check(
60              getPermissionChecker(), plid, PortletKeys.SHOPPING,
61              ActionKeys.MANAGE_COUPONS);
62  
63          shoppingCouponLocalService.deleteCoupon(couponId);
64      }
65  
66      public ShoppingCoupon getCoupon(long plid, long couponId)
67          throws PortalException, SystemException {
68  
69          PortletPermissionUtil.check(
70              getPermissionChecker(), plid, PortletKeys.SHOPPING,
71              ActionKeys.MANAGE_COUPONS);
72  
73          return shoppingCouponLocalService.getCoupon(couponId);
74      }
75  
76      public List<ShoppingCoupon> search(
77              long plid, long companyId, String code, boolean active,
78              String discountType, boolean andOperator, int start, int end)
79          throws PortalException, SystemException {
80  
81          PortletPermissionUtil.check(
82              getPermissionChecker(), plid, PortletKeys.SHOPPING,
83              ActionKeys.MANAGE_COUPONS);
84  
85          return shoppingCouponLocalService.search(
86              plid, companyId, code, active, discountType, andOperator, start,
87              end);
88      }
89  
90      public ShoppingCoupon updateCoupon(
91              long plid, long couponId, String name, String description,
92              int startDateMonth, int startDateDay, int startDateYear,
93              int startDateHour, int startDateMinute, int endDateMonth,
94              int endDateDay, int endDateYear, int endDateHour, int endDateMinute,
95              boolean neverExpire, boolean active, String limitCategories,
96              String limitSkus, double minOrder, double discount,
97              String discountType)
98          throws PortalException, SystemException {
99  
100         PortletPermissionUtil.check(
101             getPermissionChecker(), plid, PortletKeys.SHOPPING,
102             ActionKeys.MANAGE_COUPONS);
103 
104         return shoppingCouponLocalService.updateCoupon(
105             getUserId(), couponId, name, description, startDateMonth,
106             startDateDay, startDateYear, startDateHour, startDateMinute,
107             endDateMonth, endDateDay, endDateYear, endDateHour, endDateMinute,
108             neverExpire, active, limitCategories, limitSkus, minOrder, discount,
109             discountType);
110     }
111 
112 }