001    /**
002     * Copyright (c) 2000-2010 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.portlet.shopping.model.ShoppingOrder;
021    import com.liferay.portlet.shopping.service.base.ShoppingOrderServiceBaseImpl;
022    import com.liferay.portlet.shopping.service.permission.ShoppingOrderPermission;
023    import com.liferay.portlet.shopping.service.permission.ShoppingPermission;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class ShoppingOrderServiceImpl extends ShoppingOrderServiceBaseImpl {
029    
030            public void completeOrder(
031                            long groupId, String number, String ppTxnId, String ppPaymentStatus,
032                            double ppPaymentGross, String ppReceiverEmail, String ppPayerEmail)
033                    throws PortalException, SystemException {
034    
035                    ShoppingOrder order = shoppingOrderPersistence.findByNumber(number);
036    
037                    ShoppingOrderPermission.check(
038                            getPermissionChecker(), groupId, order.getOrderId(),
039                            ActionKeys.UPDATE);
040    
041                    shoppingOrderLocalService.completeOrder(
042                            number, ppTxnId, ppPaymentStatus, ppPaymentGross, ppReceiverEmail,
043                            ppPayerEmail, false);
044            }
045    
046            public void deleteOrder(long groupId, long orderId)
047                    throws PortalException, SystemException {
048    
049                    ShoppingOrderPermission.check(
050                            getPermissionChecker(), groupId, orderId, ActionKeys.DELETE);
051    
052                    shoppingOrderLocalService.deleteOrder(orderId);
053            }
054    
055            public ShoppingOrder getOrder(long groupId, long orderId)
056                    throws PortalException, SystemException {
057    
058                    ShoppingOrder order = shoppingOrderLocalService.getOrder(orderId);
059    
060                    if (order.getUserId() == getUserId()) {
061                            return order;
062                    }
063                    else {
064                            ShoppingPermission.check(
065                                    getPermissionChecker(), groupId, ActionKeys.MANAGE_ORDERS);
066    
067                            return order;
068                    }
069            }
070    
071            public void sendEmail(long groupId, long orderId, String emailType)
072                    throws PortalException, SystemException {
073    
074                    ShoppingOrderPermission.check(
075                            getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
076    
077                    shoppingOrderLocalService.sendEmail(orderId, emailType);
078            }
079    
080            public ShoppingOrder updateOrder(
081                            long groupId, long orderId, String ppTxnId, String ppPaymentStatus,
082                            double ppPaymentGross, String ppReceiverEmail, String ppPayerEmail)
083                    throws PortalException, SystemException {
084    
085                    ShoppingOrderPermission.check(
086                            getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
087    
088                    return shoppingOrderLocalService.updateOrder(
089                            orderId, ppTxnId, ppPaymentStatus, ppPaymentGross, ppReceiverEmail,
090                            ppPayerEmail);
091            }
092    
093            public ShoppingOrder updateOrder(
094                            long groupId, long orderId, String billingFirstName,
095                            String billingLastName, String billingEmailAddress,
096                            String billingCompany, String billingStreet, String billingCity,
097                            String billingState, String billingZip, String billingCountry,
098                            String billingPhone, boolean shipToBilling,
099                            String shippingFirstName, String shippingLastName,
100                            String shippingEmailAddress, String shippingCompany,
101                            String shippingStreet, String shippingCity, String shippingState,
102                            String shippingZip, String shippingCountry, String shippingPhone,
103                            String ccName, String ccType, String ccNumber, int ccExpMonth,
104                            int ccExpYear, String ccVerNumber, String comments)
105                    throws PortalException, SystemException {
106    
107                    ShoppingOrderPermission.check(
108                            getPermissionChecker(), groupId, orderId, ActionKeys.UPDATE);
109    
110                    return shoppingOrderLocalService.updateOrder(
111                            orderId, billingFirstName, billingLastName, billingEmailAddress,
112                            billingCompany, billingStreet, billingCity, billingState,
113                            billingZip, billingCountry, billingPhone, shipToBilling,
114                            shippingFirstName, shippingLastName, shippingEmailAddress,
115                            shippingCompany, shippingStreet, shippingCity, shippingState,
116                            shippingZip, shippingCountry, shippingPhone, ccName, ccType,
117                            ccNumber, ccExpMonth, ccExpYear, ccVerNumber, comments);
118            }
119    
120    }