⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orderstatus.bsh

📁 国外的一套开源CRM
💻 BSH
字号:
/*
 *  Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a 
 *  copy of this software and associated documentation files (the "Software"), 
 *  to deal in the Software without restriction, including without limitation 
 *  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 *  and/or sell copies of the Software, and to permit persons to whom the 
 *  Software is furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included 
 *  in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
 *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
 *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
 *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 
 *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 
 *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 *@author     Andy Zeneski
 *@version    $Revision: 1.6 $
 *@since      2.1
*/

import org.ofbiz.base.util.*;
import org.ofbiz.entity.*;
import org.ofbiz.entity.util.*;
import org.ofbiz.accounting.payment.*;
import org.ofbiz.order.order.*;
import org.ofbiz.party.contact.*;
import org.ofbiz.product.catalog.*;
import org.ofbiz.product.store.*;

delegator = request.getAttribute("delegator");
orderId = request.getParameter("order_id");
if (orderId == null)
    orderId = request.getAttribute("order_id");
orderHeader = null;

if (orderId != null && orderId.length() > 0) {
  orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
}

if (orderHeader != null) {   
    orderReadHelper = new OrderReadHelper(orderHeader);
    orderItems = orderReadHelper.getOrderItems();
    orderAdjustments = orderReadHelper.getAdjustments();
    orderHeaderAdjustments = orderReadHelper.getOrderHeaderAdjustments();
    orderSubTotal = orderReadHelper.getOrderItemsSubTotal();
    headerAdjustmentsToShow = orderReadHelper.getOrderHeaderAdjustmentsToShow();

    context.put("orderHeader", orderHeader);
    context.put("localOrderReadHelper", orderReadHelper);
    context.put("orderItems", orderItems);
    context.put("orderAdjustments", orderAdjustments);
    context.put("orderHeaderAdjustments", orderHeaderAdjustments);
    context.put("orderSubTotal", orderSubTotal);
    context.put("headerAdjustmentsToShow", headerAdjustmentsToShow);
    
    shippingAmount = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orderItems, orderAdjustments, false, false, true);
    shippingAmount += OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, false, true);
    context.put("orderShippingTotal", shippingAmount);

    taxAmount = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orderItems, orderAdjustments, false, true, false);
    taxAmount += OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, true, false);
    context.put("orderTaxTotal", taxAmount);   
    context.put("orderGrandTotal", OrderReadHelper.getOrderGrandTotal(orderItems, orderAdjustments));
    
    placingCustomerOrderRoles = delegator.findByAnd("OrderRole",UtilMisc.toMap("orderId", orderId, "roleTypeId", "PLACING_CUSTOMER"));
    placingCustomerOrderRole = EntityUtil.getFirst(placingCustomerOrderRoles);        
    placingCustomerPerson = placingCustomerOrderRole == null ? null : delegator.findByPrimaryKey("Person",UtilMisc.toMap("partyId", placingCustomerOrderRole.getString("partyId")));
    context.put("placingCustomerPerson", placingCustomerPerson);

    shippingAddress = orderReadHelper.getShippingAddress();
    context.put("shippingAddress", shippingAddress);
    billingAccount = orderHeader.getRelatedOne("BillingAccount");
    if (billingAccount != null)
        context.put("billingAccount", billingAccount);
  
    orderPaymentPreferences = UtilMisc.toIterator(orderHeader.getRelated("OrderPaymentPreference"));
    paymentMethodTypeId = null;
    if (orderPaymentPreferences != null && orderPaymentPreferences.hasNext()) {
        orderPaymentPreference = orderPaymentPreferences.next();
        paymentMethod = orderPaymentPreference.getRelatedOne("PaymentMethod");        
        paymentMethodType = orderPaymentPreference.getRelatedOne("PaymentMethodType");
        paymentMethodTypeId = paymentMethodType.getString("paymentMethodTypeId");
        if (paymentMethod != null)
            context.put("paymentMethod", paymentMethod);
        if (paymentMethodType != null)
            context.put("paymentMethodType", paymentMethodType);
        
        if (paymentMethod != null && "CREDIT_CARD".equals(paymentMethod.getString("paymentMethodTypeId"))) {
            creditCard = paymentMethod.getRelatedOneCache("CreditCard");
            context.put("creditCard", creditCard);
            context.put("formattedCardNumber", ContactHelper.formatCreditCard(creditCard));
        } else if (paymentMethod != null && "EFT_ACCOUNT".equals(paymentMethod.getString("paymentMethodTypeId"))) {
            eftAccount = paymentMethod.getRelatedOneCache("EftAccount");
            context.put("eftAccount", eftAccount);
        }        
    } 
    
    webSiteId = CatalogWorker.getWebSiteId(request);
    productStore = ProductStoreWorker.getProductStore(request);
    if (productStore != null) {
        payToPartyId = productStore.getString("payToPartyId");
        paymentAddress =  PaymentWorker.getPaymentAddress(delegator, payToPartyId);    
        if (paymentAddress != null) context.put("paymentAddress", paymentAddress);
    }    
       
    orderShipmentPreferences = UtilMisc.toIterator(orderHeader.getRelated("OrderShipmentPreference"));
    if (orderShipmentPreferences != null && orderShipmentPreferences.hasNext()) {
        shipmentPreference = orderShipmentPreferences.next();
        context.put("carrierPartyId", shipmentPreference.getString("carrierPartyId"));
        context.put("shipmentMethodTypeId", shipmentPreference.getString("shipmentMethodTypeId"));       
        shipmentMethodType = delegator.findByPrimaryKey("ShipmentMethodType", UtilMisc.toMap("shipmentMethodTypeId", shipmentPreference.getString("shipmentMethodTypeId")));
        context.put("shipMethDescription", shipmentMethodType.getString("description"));       
        context.put("shippingInstructions", shipmentPreference.getString("shippingInstructions"));
        context.put("maySplit", shipmentPreference.getBoolean("maySplit"));
        context.put("giftMessage", shipmentPreference.getString("giftMessage"));
        context.put("isGift", shipmentPreference.getBoolean("isGift"));
        context.put("trackingNumber", shipmentPreference.getString("trackingNumber"));
    }

    customerPoNumber = null;
    orderItemPOIter = UtilMisc.toIterator(orderItems);
    if (orderItemPOIter != null && orderItemPOIter.hasNext()) {
        orderItemPo = orderItemPOIter.next();
        context.put("customerPoNumber", orderItemPo.getString("correspondingPoId"));
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -