001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.shopping.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.security.permission.ActionKeys;
020    import com.liferay.portal.service.ServiceContext;
021    import com.liferay.portlet.shopping.model.ShoppingOrder;
022    import com.liferay.portlet.shopping.service.base.ShoppingOrderServiceBaseImpl;
023    import com.liferay.portlet.shopping.service.permission.ShoppingOrderPermission;
024    import com.liferay.portlet.shopping.service.permission.ShoppingPermission;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class ShoppingOrderServiceImpl extends ShoppingOrderServiceBaseImpl {
030    
031            public void completeOrder(
032                            long groupId, String number, String ppTxnId, String ppPaymentStatus,
033                            double ppPaymentGross, String ppReceiverEmail, String ppPayerEmail,
034                            ServiceContext serviceContext)
035                    throws PortalException, SystemException {
036    
037                    ShoppingOrder order = shoppingOrderPersistence.findByNumber(number);
038    
039                    ShoppingOrderPermission.check(
040                            getPermissionChecker(), groupId, order.getOrderId(),
041                            ActionKeys.UPDATE);
042    
043                    shoppingOrderLocalService.completeOrder(
044                            number, ppTxnId, ppPaymentStatus, ppPaymentGross, ppReceiverEmail,
045                            ppPayerEmail, false, serviceContext);
046            }
047    
048            public void deleteOrder(long groupId, long orderId)
049                    throws PortalException, SystemException {
050    
051                    ShoppingOrderPermission.check(
052                            getPermissionChecker(), groupId, orderId, ActionKeys.DELETE);
053    
054                    shoppingOrderLocalService.deleteOrder(orderId);
055            }
056    
057            public ShoppingOrder getOrder(long groupId, long orderId)
058                    throws PortalException, SystemException {
059    
060                    ShoppingOrder order = shoppingOrderLocalService.getOrder(orderId);
061    
062                    if (order.getUserId() == getUserId()) {
063                            return order;
064                    }
065                    else {
066                            ShoppingPermission.check(
067                                    getPermissionChecker(), groupId, ActionKeys.MANAGE_ORDERS);
068    
069                            return order;
070                    }
071            }
072    
073            public void sendEmail(
074                            long groupId, long orderId, String emailType,
075                            ServiceContext serviceContext)
076                    throws PortalException, SystemException {
077    
078                    ShoppingOrderPermission.check(
079                            getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
080    
081                    shoppingOrderLocalService.sendEmail(orderId, emailType, serviceContext);
082            }
083    
084            public ShoppingOrder updateOrder(
085                            long groupId, long orderId, String ppTxnId, String ppPaymentStatus,
086                            double ppPaymentGross, String ppReceiverEmail, String ppPayerEmail)
087                    throws PortalException, SystemException {
088    
089                    ShoppingOrderPermission.check(
090                            getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
091    
092                    return shoppingOrderLocalService.updateOrder(
093                            orderId, ppTxnId, ppPaymentStatus, ppPaymentGross, ppReceiverEmail,
094                            ppPayerEmail);
095            }
096    
097            public ShoppingOrder updateOrder(
098                            long groupId, long orderId, String billingFirstName,
099                            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(), groupId, 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    }