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.ServiceContext;
29  import com.liferay.portlet.shopping.model.ShoppingCoupon;
30  import com.liferay.portlet.shopping.service.base.ShoppingCouponServiceBaseImpl;
31  import com.liferay.portlet.shopping.service.permission.ShoppingPermission;
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              String code, boolean autoCode, String name, String description,
44              int startDateMonth, int startDateDay, int startDateYear,
45              int startDateHour, int startDateMinute, int endDateMonth,
46              int endDateDay, int endDateYear, int endDateHour, int endDateMinute,
47              boolean neverExpire, boolean active, String limitCategories,
48              String limitSkus, double minOrder, double discount,
49              String discountType, ServiceContext serviceContext)
50          throws PortalException, SystemException {
51  
52          ShoppingPermission.check(
53              getPermissionChecker(), serviceContext.getScopeGroupId(),
54              ActionKeys.MANAGE_COUPONS);
55  
56          return shoppingCouponLocalService.addCoupon(
57              getUserId(), 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, serviceContext);
62      }
63  
64      public void deleteCoupon(long groupId, long couponId)
65          throws PortalException, SystemException {
66  
67          ShoppingPermission.check(
68              getPermissionChecker(), groupId, ActionKeys.MANAGE_COUPONS);
69  
70          shoppingCouponLocalService.deleteCoupon(couponId);
71      }
72  
73      public ShoppingCoupon getCoupon(long groupId, long couponId)
74          throws PortalException, SystemException {
75  
76          ShoppingPermission.check(
77              getPermissionChecker(), groupId, ActionKeys.MANAGE_COUPONS);
78  
79          return shoppingCouponLocalService.getCoupon(couponId);
80      }
81  
82      public List<ShoppingCoupon> search(
83              long groupId, long companyId, String code, boolean active,
84              String discountType, boolean andOperator, int start, int end)
85          throws PortalException, SystemException {
86  
87          ShoppingPermission.check(
88              getPermissionChecker(), groupId, ActionKeys.MANAGE_COUPONS);
89  
90          return shoppingCouponLocalService.search(
91              groupId, companyId, code, active, discountType, andOperator, start,
92              end);
93      }
94  
95      public ShoppingCoupon updateCoupon(
96              long couponId, String name, String description, int startDateMonth,
97              int startDateDay, int startDateYear, int startDateHour,
98              int startDateMinute, int endDateMonth, int endDateDay,
99              int endDateYear, int endDateHour, int endDateMinute,
100             boolean neverExpire, boolean active, String limitCategories,
101             String limitSkus, double minOrder, double discount,
102             String discountType, ServiceContext serviceContext)
103         throws PortalException, SystemException {
104 
105         ShoppingPermission.check(
106             getPermissionChecker(), serviceContext.getScopeGroupId(),
107             ActionKeys.MANAGE_COUPONS);
108 
109         return shoppingCouponLocalService.updateCoupon(
110             getUserId(), couponId, name, description, startDateMonth,
111             startDateDay, startDateYear, startDateHour, startDateMinute,
112             endDateMonth, endDateDay, endDateYear, endDateHour, endDateMinute,
113             neverExpire, active, limitCategories, limitSkus, minOrder, discount,
114             discountType, serviceContext);
115     }
116 
117 }