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

📄 checkouthelper.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            }            GenericValue newPref = delegator.makeValue("OrderPaymentPreference", null);            newPref.set("orderPaymentPreferenceId", delegator.getNextSeqId("OrderPaymentPreference"));            newPref.set("orderId", cart.getOrderId());            newPref.set("paymentMethodTypeId", "CASH");            newPref.set("statusId", "PAYMENT_RECEIVED");            newPref.set("maxAmount", change);            newPref.set("createdDate", UtilDateTime.nowTimestamp());            if (userLogin != null) {                newPref.set("createdByUserLogin", userLogin.getString("userLoginId"));            }            delegator.create(newPref);        }    }    public Map checkOrderBlacklist(GenericValue userLogin) {    	if (cart == null) {            return ServiceUtil.returnSuccess("success");    	}        GenericValue shippingAddressObj = this.cart.getShippingAddress();    	if (shippingAddressObj == null) {            return ServiceUtil.returnSuccess("success");    	}        String shippingAddress = UtilFormatOut.checkNull(shippingAddressObj.getString("address1")).toUpperCase();        List exprs = UtilMisc.toList(new EntityExpr(                new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("blacklistString")), EntityOperator.EQUALS, new EntityFunction.UPPER(shippingAddress)), EntityOperator.AND,                new EntityExpr("orderBlacklistTypeId", EntityOperator.EQUALS, "BLACKLIST_ADDRESS")));        String errMsg=null;        List paymentMethods = this.cart.getPaymentMethods();        Iterator i = paymentMethods.iterator();        while (i.hasNext()) {            GenericValue paymentMethod = (GenericValue) i.next();            if (paymentMethod.getString("paymentMethodTypeId").equals("CREDIT_CARD")) {                GenericValue creditCard = null;                GenericValue billingAddress = null;                try {                    creditCard = paymentMethod.getRelatedOne("CreditCard");                    if (creditCard != null)                        billingAddress = creditCard.getRelatedOne("PostalAddress");                } catch (GenericEntityException e) {                    Debug.logError(e, "Problems getting credit card from payment method", module);                    errMsg = UtilProperties.getMessage(resource,"checkhelper.problems_reading_database", (cart != null ? cart.getLocale() : Locale.getDefault()));                    return ServiceUtil.returnError(errMsg);                }                if (creditCard != null) {                    String creditCardNumber = UtilFormatOut.checkNull(creditCard.getString("cardNumber"));                    exprs.add(new EntityExpr(                            new EntityExpr("blacklistString", EntityOperator.EQUALS, creditCardNumber), EntityOperator.AND,                            new EntityExpr("orderBlacklistTypeId", EntityOperator.EQUALS, "BLACKLIST_CREDITCARD")));                }                if (billingAddress != null) {                    String address = UtilFormatOut.checkNull(billingAddress.getString("address1").toUpperCase());                    exprs.add(new EntityExpr(                            new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("blacklistString")), EntityOperator.EQUALS, new EntityFunction.UPPER(address)), EntityOperator.AND,                            new EntityExpr("orderBlacklistTypeId", EntityOperator.EQUALS, "BLACKLIST_ADDRESS")));                }            }        }        List blacklistFound = null;        if (exprs.size() > 0) {            try {                blacklistFound = this.delegator.findByOr("OrderBlacklist", exprs);            } catch (GenericEntityException e) {                Debug.logError(e, "Problems with OrderBlacklist lookup.", module);                errMsg = UtilProperties.getMessage(resource,"checkhelper.problems_reading_database", (cart != null ? cart.getLocale() : Locale.getDefault()));                return ServiceUtil.returnError(errMsg);            }        }        if (blacklistFound != null && blacklistFound.size() > 0) {        	return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderFailed", (cart != null ? cart.getLocale() : Locale.getDefault())));        } else {            return ServiceUtil.returnSuccess("success");        }    }    public Map failedBlacklistCheck(GenericValue userLogin, GenericValue productStore) {        Map result;        String errMsg=null;        String REJECT_MESSAGE = productStore.getString("authFraudMessage");        // Get the orderId from the cart.        String orderId = this.cart.getOrderId();        // set the order/item status - reverse inv        OrderChangeHelper.rejectOrder(dispatcher, userLogin, orderId);        // nuke the userlogin        userLogin.set("enabled", "N");        try {            userLogin.store();        } catch (GenericEntityException e) {            Debug.logError(e, "Problems de-activating userLogin.", module);            errMsg = UtilProperties.getMessage(resource,"checkhelper.database_error", (cart != null ? cart.getLocale() : Locale.getDefault()));            result = ServiceUtil.returnError(errMsg);            return result;        }        result = ServiceUtil.returnSuccess();        result.put(ModelService.ERROR_MESSAGE, REJECT_MESSAGE);        // wipe the cart and session        this.cart.clear();        return result;    }    public Map checkExternalPayment(String orderId) {        Map result;        String errMsg=null;        // warning there can only be ONE payment preference for this to work        // you cannot accept multiple payment type when using an external gateway        GenericValue orderHeader = null;        try {            orderHeader = this.delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));        } catch (GenericEntityException e) {            Debug.logError(e, "Problems getting order header", module);            errMsg = UtilProperties.getMessage(resource,"checkhelper.problems_getting_order_header", (cart != null ? cart.getLocale() : Locale.getDefault()));            result = ServiceUtil.returnError(errMsg);            return result;        }        if (orderHeader != null) {            List paymentPrefs = null;            try {                paymentPrefs = orderHeader.getRelated("OrderPaymentPreference");            } catch (GenericEntityException e) {                Debug.logError(e, "Problems getting order payments", module);                errMsg = UtilProperties.getMessage(resource,"checkhelper.problems_getting_payment_preference", (cart != null ? cart.getLocale() : Locale.getDefault()));                result = ServiceUtil.returnError(errMsg);                return result;            }            if (paymentPrefs != null && paymentPrefs.size() > 0) {                if (paymentPrefs.size() > 1) {                    Debug.logError("Too many payment preferences, you cannot have more then one when using external gateways", module);                }                GenericValue paymentPreference = EntityUtil.getFirst(paymentPrefs);                String paymentMethodTypeId = paymentPreference.getString("paymentMethodTypeId");                if (paymentMethodTypeId.startsWith("EXT_")) {                    String type = paymentMethodTypeId.substring(4);                    result = ServiceUtil.returnSuccess();                    result.put("type", type.toLowerCase());                    return result;                }            }            result = ServiceUtil.returnSuccess();            result.put("type", "none");            return result;        } else {            errMsg = UtilProperties.getMessage(resource,"checkhelper.problems_getting_order_header", (cart != null ? cart.getLocale() : Locale.getDefault()));            result = ServiceUtil.returnError(errMsg);            result.put("type", "error");            return result;        }    }    /**     * Sets the shipping contact mechanism on the cart     *     * @param shippingContactMechId The identifier of the contact     * @return A Map conforming to the OFBiz Service conventions containing     * any error messages     */    public Map finalizeOrderEntryShip(String shippingContactMechId) {        Map result;        String errMsg=null;        //Verify the field is valid        if (UtilValidate.isNotEmpty(shippingContactMechId)) {            this.cart.setShippingContactMechId(shippingContactMechId);            result = ServiceUtil.returnSuccess();        } else {            errMsg = UtilProperties.getMessage(resource,"checkhelper.enter_shipping_address", (cart != null ? cart.getLocale() : Locale.getDefault()));            result = ServiceUtil.returnError(errMsg);        }        return result;    }    /**     * Sets the options associated with the order     *     * @param shippingMethod The shipping method indicating the carrier and     * shipment type to use     * @param shippingInstructions Any additional handling instructions     * @param maySplit "true" or anything else for <code>false</code>     * @param giftMessage A message to have included for the recipient     * @param isGift "true" or anything else for <code>false</code>     * @param internalCode an internal code associated with the order     * @return A Map conforming to the OFBiz Service conventions containing     * any error messages     */    public Map finalizeOrderEntryOptions(String shippingMethod, String shippingInstructions, String maySplit,            String giftMessage, String isGift, String internalCode, String shipBeforeDate, String shipAfterDate) {        Map result;        String errMsg=null;        //Verify the shipping method is valid        if (UtilValidate.isNotEmpty(shippingMethod)) {            int delimiterPos = shippingMethod.indexOf('@');            String shipmentMethodTypeId = null;            String carrierPartyId = null;            if (delimiterPos > 0) {                shipmentMethodTypeId = shippingMethod.substring(0, delimiterPos);                carrierPartyId = shippingMethod.substring(delimiterPos + 1);            }            this.cart.setShipmentMethodTypeId(shipmentMethodTypeId);            this.cart.setCarrierPartyId(carrierPartyId);        } else {            errMsg = UtilProperties.getMessage(resource,"checkhelper.select_shipping_method", (cart != null ? cart.getLocale() : Locale.getDefault()));            result = ServiceUtil.returnError(errMsg);        }        //Set the remaining order options        this.cart.setShippingInstructions(shippingInstructions);        this.cart.setGiftMessage(giftMessage);        this.cart.setMaySplit(Boolean.valueOf(maySplit));        this.cart.setIsGift(Boolean.valueOf(isGift));        this.cart.setInternalCode(internalCode);        // set ship before date        if ((shipBeforeDate != null) && (shipBeforeDate.length() > 8)) {           shipBeforeDate = shipBeforeDate.trim();           if (shipBeforeDate.length() < 14) {               shipBeforeDate = shipBeforeDate + " " + "00:00:00.000";           }           try {               this.cart.setShipBeforeDate((Timestamp) ObjectType.simpleTypeConvert(shipBeforeDate, "Timestamp", null, null));           } catch (Exception e) {               errMsg = "Ship Before Date must be a valid date formed ";               result = ServiceUtil.returnError(errMsg);           }        }        // set ship after date        if ((shipAfterDate != null) && (shipAfterDate.length() > 8)) {           shipAfterDate = shipAfterDate.trim();           if (shipAfterDate.length() < 14) {               shipAfterDate = shipAfterDate + " " + "00:00:00.000";           }           try {               this.cart.setShipAfterDate((Timestamp) ObjectType.simpleTypeConvert(shipAfterDate,"Timestamp", null, null));            } catch (Exception e) {              errMsg = "Ship After Date must be a valid date formed ";              result = ServiceUtil.returnError(errMsg);            }        }        result = ServiceUtil.returnSuccess();        return result;    }    /**     * Sets the payment ID to use during the checkout process     *     * @param checkOutPaymentId The payment ID to be associated with the cart     * @return A Map conforming to the OFBiz Service conventions containing     * any error messages.      */    public Map finalizeOrderEntryPayment(String checkOutPaymentId, Double amount, boolean singleUse, boolean append) {        Map result = ServiceUtil.returnSuccess();        if (UtilValidate.isNotEmpty(checkOutPaymentId)) {

⌨️ 快捷键说明

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