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   */
39  public class ShoppingOrderServiceImpl extends ShoppingOrderServiceBaseImpl {
40  
41      public void completeOrder(
42              long groupId, 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(), groupId, 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 groupId, long orderId)
58          throws PortalException, SystemException {
59  
60          ShoppingOrderPermission.check(
61              getPermissionChecker(), groupId, orderId, ActionKeys.DELETE);
62  
63          shoppingOrderLocalService.deleteOrder(orderId);
64      }
65  
66      public ShoppingOrder getOrder(long groupId, 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              ShoppingPermission.check(
76                  getPermissionChecker(), groupId, ActionKeys.MANAGE_ORDERS);
77  
78              return order;
79          }
80      }
81  
82      public void sendEmail(long groupId, long orderId, String emailType)
83          throws PortalException, SystemException {
84  
85          ShoppingOrderPermission.check(
86              getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
87  
88          shoppingOrderLocalService.sendEmail(orderId, emailType);
89      }
90  
91      public ShoppingOrder updateOrder(
92              long groupId, long orderId, String billingFirstName,
93              String billingLastName, String billingEmailAddress,
94              String billingCompany, String billingStreet, String billingCity,
95              String billingState, String billingZip, String billingCountry,
96              String billingPhone, boolean shipToBilling,
97              String shippingFirstName, String shippingLastName,
98              String shippingEmailAddress, String shippingCompany,
99              String shippingStreet, String shippingCity, String shippingState,
100             String shippingZip, String shippingCountry, String shippingPhone,
101             String ccName, String ccType, String ccNumber, int ccExpMonth,
102             int ccExpYear, String ccVerNumber, String comments)
103         throws PortalException, SystemException {
104 
105         ShoppingOrderPermission.check(
106             getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
107 
108         return shoppingOrderLocalService.updateOrder(
109             orderId, billingFirstName, billingLastName, billingEmailAddress,
110             billingCompany, billingStreet, billingCity, billingState,
111             billingZip, billingCountry, billingPhone, shipToBilling,
112             shippingFirstName, shippingLastName, shippingEmailAddress,
113             shippingCompany, shippingStreet, shippingCity, shippingState,
114             shippingZip, shippingCountry, shippingPhone, ccName, ccType,
115             ccNumber, ccExpMonth, ccExpYear, ccVerNumber, comments);
116     }
117 
118     public ShoppingOrder updateOrder(
119             long groupId, long orderId, String ppTxnId, String ppPaymentStatus,
120             double ppPaymentGross, String ppReceiverEmail, String ppPayerEmail)
121         throws PortalException, SystemException {
122 
123         ShoppingOrderPermission.check(
124             getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
125 
126         return shoppingOrderLocalService.updateOrder(
127             orderId, ppTxnId, ppPaymentStatus, ppPaymentGross, ppReceiverEmail,
128             ppPayerEmail);
129     }
130 
131 }