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