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.portlet.shopping.model.ShoppingOrder;
29  import com.liferay.portlet.shopping.service.base.ShoppingOrderServiceBaseImpl;
30  import com.liferay.portlet.shopping.service.permission.ShoppingOrderPermission;
31  import com.liferay.portlet.shopping.service.permission.ShoppingPermission;
32  
33  /**
34   * <a href="ShoppingOrderServiceImpl.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   */
38  public class ShoppingOrderServiceImpl extends ShoppingOrderServiceBaseImpl {
39  
40      public void completeOrder(
41              long groupId, String number, String ppTxnId, String ppPaymentStatus,
42              double ppPaymentGross, String ppReceiverEmail, String ppPayerEmail)
43          throws PortalException, SystemException {
44  
45          ShoppingOrder order = shoppingOrderPersistence.findByNumber(number);
46  
47          ShoppingOrderPermission.check(
48              getPermissionChecker(), groupId, order.getOrderId(),
49              ActionKeys.UPDATE);
50  
51          shoppingOrderLocalService.completeOrder(
52              number, ppTxnId, ppPaymentStatus, ppPaymentGross, ppReceiverEmail,
53              ppPayerEmail, false);
54      }
55  
56      public void deleteOrder(long groupId, long orderId)
57          throws PortalException, SystemException {
58  
59          ShoppingOrderPermission.check(
60              getPermissionChecker(), groupId, orderId, ActionKeys.DELETE);
61  
62          shoppingOrderLocalService.deleteOrder(orderId);
63      }
64  
65      public ShoppingOrder getOrder(long groupId, long orderId)
66          throws PortalException, SystemException {
67  
68          ShoppingOrder order = shoppingOrderLocalService.getOrder(orderId);
69  
70          if (order.getUserId() == getUserId()) {
71              return order;
72          }
73          else {
74              ShoppingPermission.check(
75                  getPermissionChecker(), groupId, ActionKeys.MANAGE_ORDERS);
76  
77              return order;
78          }
79      }
80  
81      public void sendEmail(long groupId, long orderId, String emailType)
82          throws PortalException, SystemException {
83  
84          ShoppingOrderPermission.check(
85              getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
86  
87          shoppingOrderLocalService.sendEmail(orderId, emailType);
88      }
89  
90      public ShoppingOrder updateOrder(
91              long groupId, long orderId, String ppTxnId, String ppPaymentStatus,
92              double ppPaymentGross, String ppReceiverEmail, String ppPayerEmail)
93          throws PortalException, SystemException {
94  
95          ShoppingOrderPermission.check(
96              getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
97  
98          return shoppingOrderLocalService.updateOrder(
99              orderId, ppTxnId, ppPaymentStatus, ppPaymentGross, ppReceiverEmail,
100             ppPayerEmail);
101     }
102 
103     public ShoppingOrder updateOrder(
104             long groupId, long orderId, String billingFirstName,
105             String billingLastName, String billingEmailAddress,
106             String billingCompany, String billingStreet, String billingCity,
107             String billingState, String billingZip, String billingCountry,
108             String billingPhone, boolean shipToBilling,
109             String shippingFirstName, String shippingLastName,
110             String shippingEmailAddress, String shippingCompany,
111             String shippingStreet, String shippingCity, String shippingState,
112             String shippingZip, String shippingCountry, String shippingPhone,
113             String ccName, String ccType, String ccNumber, int ccExpMonth,
114             int ccExpYear, String ccVerNumber, String comments)
115         throws PortalException, SystemException {
116 
117         ShoppingOrderPermission.check(
118             getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
119 
120         return shoppingOrderLocalService.updateOrder(
121             orderId, billingFirstName, billingLastName, billingEmailAddress,
122             billingCompany, billingStreet, billingCity, billingState,
123             billingZip, billingCountry, billingPhone, shipToBilling,
124             shippingFirstName, shippingLastName, shippingEmailAddress,
125             shippingCompany, shippingStreet, shippingCity, shippingState,
126             shippingZip, shippingCountry, shippingPhone, ccName, ccType,
127             ccNumber, ccExpMonth, ccExpYear, ccVerNumber, comments);
128     }
129 
130 }