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