1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.shopping.service.impl;
21  
22  import com.liferay.portal.PortalException;
23  import com.liferay.portal.SystemException;
24  import com.liferay.portal.security.permission.ActionKeys;
25  import com.liferay.portal.service.permission.PortletPermissionUtil;
26  import com.liferay.portal.util.PortletKeys;
27  import com.liferay.portlet.shopping.model.ShoppingCoupon;
28  import com.liferay.portlet.shopping.service.base.ShoppingCouponServiceBaseImpl;
29  
30  import java.util.List;
31  
32  /**
33   * <a href="ShoppingCouponServiceImpl.java.html"><b><i>View Source</i></b></a>
34   *
35   * @author Brian Wing Shun Chan
36   *
37   */
38  public class ShoppingCouponServiceImpl extends ShoppingCouponServiceBaseImpl {
39  
40      public ShoppingCoupon addCoupon(
41              long plid, String code, boolean autoCode, String name,
42              String description, int startDateMonth, int startDateDay,
43              int startDateYear, int startDateHour, int startDateMinute,
44              int endDateMonth, int endDateDay, int endDateYear, int endDateHour,
45              int endDateMinute, boolean neverExpire, boolean active,
46              String limitCategories, String limitSkus, double minOrder,
47              double discount, String discountType)
48          throws PortalException, SystemException {
49  
50          PortletPermissionUtil.check(
51              getPermissionChecker(), plid, PortletKeys.SHOPPING,
52              ActionKeys.MANAGE_COUPONS);
53  
54          return shoppingCouponLocalService.addCoupon(
55              getUserId(), plid, code, autoCode, name, description,
56              startDateMonth, startDateDay, startDateYear, startDateHour,
57              startDateMinute, endDateMonth, endDateDay, endDateYear, endDateHour,
58              endDateMinute, neverExpire, active, limitCategories, limitSkus,
59              minOrder, discount, discountType);
60      }
61  
62      public void deleteCoupon(long plid, long couponId)
63          throws PortalException, SystemException {
64  
65          PortletPermissionUtil.check(
66              getPermissionChecker(), plid, PortletKeys.SHOPPING,
67              ActionKeys.MANAGE_COUPONS);
68  
69          shoppingCouponLocalService.deleteCoupon(couponId);
70      }
71  
72      public ShoppingCoupon getCoupon(long plid, long couponId)
73          throws PortalException, SystemException {
74  
75          PortletPermissionUtil.check(
76              getPermissionChecker(), plid, PortletKeys.SHOPPING,
77              ActionKeys.MANAGE_COUPONS);
78  
79          return shoppingCouponLocalService.getCoupon(couponId);
80      }
81  
82      public List<ShoppingCoupon> search(
83              long plid, long companyId, String code, boolean active,
84              String discountType, boolean andOperator, int start, int end)
85          throws PortalException, SystemException {
86  
87          PortletPermissionUtil.check(
88              getPermissionChecker(), plid, PortletKeys.SHOPPING,
89              ActionKeys.MANAGE_COUPONS);
90  
91          return shoppingCouponLocalService.search(
92              plid, companyId, code, active, discountType, andOperator, start,
93              end);
94      }
95  
96      public ShoppingCoupon updateCoupon(
97              long plid, long couponId, String name, String description,
98              int startDateMonth, int startDateDay, int startDateYear,
99              int startDateHour, int startDateMinute, int endDateMonth,
100             int endDateDay, int endDateYear, int endDateHour, int endDateMinute,
101             boolean neverExpire, boolean active, String limitCategories,
102             String limitSkus, double minOrder, double discount,
103             String discountType)
104         throws PortalException, SystemException {
105 
106         PortletPermissionUtil.check(
107             getPermissionChecker(), plid, PortletKeys.SHOPPING,
108             ActionKeys.MANAGE_COUPONS);
109 
110         return shoppingCouponLocalService.updateCoupon(
111             getUserId(), couponId, name, description, startDateMonth,
112             startDateDay, startDateYear, startDateHour, startDateMinute,
113             endDateMonth, endDateDay, endDateYear, endDateHour, endDateMinute,
114             neverExpire, active, limitCategories, limitSkus, minOrder, discount,
115             discountType);
116     }
117 
118 }