1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.shopping.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.security.permission.ActionKeys;
20  import com.liferay.portlet.shopping.model.ShoppingOrder;
21  import com.liferay.portlet.shopping.service.base.ShoppingOrderServiceBaseImpl;
22  import com.liferay.portlet.shopping.service.permission.ShoppingOrderPermission;
23  import com.liferay.portlet.shopping.service.permission.ShoppingPermission;
24  
25  /**
26   * <a href="ShoppingOrderServiceImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class ShoppingOrderServiceImpl extends ShoppingOrderServiceBaseImpl {
31  
32      public void completeOrder(
33              long groupId, String number, String ppTxnId, String ppPaymentStatus,
34              double ppPaymentGross, String ppReceiverEmail, String ppPayerEmail)
35          throws PortalException, SystemException {
36  
37          ShoppingOrder order = shoppingOrderPersistence.findByNumber(number);
38  
39          ShoppingOrderPermission.check(
40              getPermissionChecker(), groupId, order.getOrderId(),
41              ActionKeys.UPDATE);
42  
43          shoppingOrderLocalService.completeOrder(
44              number, ppTxnId, ppPaymentStatus, ppPaymentGross, ppReceiverEmail,
45              ppPayerEmail, false);
46      }
47  
48      public void deleteOrder(long groupId, long orderId)
49          throws PortalException, SystemException {
50  
51          ShoppingOrderPermission.check(
52              getPermissionChecker(), groupId, orderId, ActionKeys.DELETE);
53  
54          shoppingOrderLocalService.deleteOrder(orderId);
55      }
56  
57      public ShoppingOrder getOrder(long groupId, long orderId)
58          throws PortalException, SystemException {
59  
60          ShoppingOrder order = shoppingOrderLocalService.getOrder(orderId);
61  
62          if (order.getUserId() == getUserId()) {
63              return order;
64          }
65          else {
66              ShoppingPermission.check(
67                  getPermissionChecker(), groupId, ActionKeys.MANAGE_ORDERS);
68  
69              return order;
70          }
71      }
72  
73      public void sendEmail(long groupId, long orderId, String emailType)
74          throws PortalException, SystemException {
75  
76          ShoppingOrderPermission.check(
77              getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
78  
79          shoppingOrderLocalService.sendEmail(orderId, emailType);
80      }
81  
82      public ShoppingOrder updateOrder(
83              long groupId, long orderId, String ppTxnId, String ppPaymentStatus,
84              double ppPaymentGross, String ppReceiverEmail, String ppPayerEmail)
85          throws PortalException, SystemException {
86  
87          ShoppingOrderPermission.check(
88              getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
89  
90          return shoppingOrderLocalService.updateOrder(
91              orderId, ppTxnId, ppPaymentStatus, ppPaymentGross, ppReceiverEmail,
92              ppPayerEmail);
93      }
94  
95      public ShoppingOrder updateOrder(
96              long groupId, long orderId, String billingFirstName,
97              String billingLastName, String billingEmailAddress,
98              String billingCompany, String billingStreet, String billingCity,
99              String billingState, String billingZip, String billingCountry,
100             String billingPhone, boolean shipToBilling,
101             String shippingFirstName, String shippingLastName,
102             String shippingEmailAddress, String shippingCompany,
103             String shippingStreet, String shippingCity, String shippingState,
104             String shippingZip, String shippingCountry, String shippingPhone,
105             String ccName, String ccType, String ccNumber, int ccExpMonth,
106             int ccExpYear, String ccVerNumber, String comments)
107         throws PortalException, SystemException {
108 
109         ShoppingOrderPermission.check(
110             getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
111 
112         return shoppingOrderLocalService.updateOrder(
113             orderId, billingFirstName, billingLastName, billingEmailAddress,
114             billingCompany, billingStreet, billingCity, billingState,
115             billingZip, billingCountry, billingPhone, shipToBilling,
116             shippingFirstName, shippingLastName, shippingEmailAddress,
117             shippingCompany, shippingStreet, shippingCity, shippingState,
118             shippingZip, shippingCountry, shippingPhone, ccName, ccType,
119             ccNumber, ccExpMonth, ccExpYear, ccVerNumber, comments);
120     }
121 
122 }