@ Indexable ( type = IndexableType . REINDEX ) @ Override public CommerceTierPriceEntry upsertCommerceTierPriceEntry ( long commerceTierPriceEntryId , long commercePriceEntryId , String externalReferenceCode , BigDecimal price , BigDecimal promoPrice , int minQuantity , String priceEntryExternalReferenceCode , ServiceContext serviceContext ) throws PortalException { // Update if ( commerceTierPriceEntryId > 0 ) { try { return updateCommerceTierPriceEntry ( commerceTierPriceEntryId , price , promoPrice , minQuantity , serviceContext ) ; } catch ( NoSuchTierPriceEntryException nstpee ) { if ( _log . isDebugEnabled ( ) ) { _log . debug ( "Unable to find tier price entry with ID: " + commerceTierPriceEntryId ) ; } } } if ( Validator . isNotNull ( externalReferenceCode ) ) { CommerceTierPriceEntry commerceTierPriceEntry = commerceTierPriceEntryPersistence . fetchByC_ERC ( serviceContext . getCompanyId ( ) , externalReferenceCode ) ; if ( commerceTierPriceEntry != null ) { return updateCommerceTierPriceEntry ( commerceTierPriceEntry . getCommerceTierPriceEntryId ( ) , price , promoPrice , minQuantity , serviceContext ) ; } } // Add if ( commercePriceEntryId > 0 ) { validate ( 0L , commercePriceEntryId , minQuantity ) ; CommercePriceEntry commercePriceEntry = _commercePriceEntryPersistence . findByPrimaryKey ( commercePriceEntryId ) ; return addCommerceTierPriceEntry ( commercePriceEntry . getCommercePriceEntryId ( ) , externalReferenceCode , price , promoPrice , minQuantity , serviceContext ) ; } if ( Validator . isNotNull ( priceEntryExternalReferenceCode ) ) { CommercePriceEntry commercePriceEntry = _commercePriceEntryPersistence . findByC_ERC ( serviceContext . getCompanyId ( ) , priceEntryExternalReferenceCode ) ; validate ( 0L , commercePriceEntry . getCommercePriceEntryId ( ) , minQuantity ) ; return addCommerceTierPriceEntry ( commercePriceEntry . getCommercePriceEntryId ( ) , externalReferenceCode , price , promoPrice , minQuantity , serviceContext ) ; } StringBundler sb = new StringBundler ( 6 ) ; sb . append ( "{commercePriceEntryId=" ) ; sb . append ( commercePriceEntryId ) ; sb . append ( StringPool . COMMA_AND_SPACE ) ; sb . append ( "priceEntryExternalReferenceCode=" ) ; sb . append ( priceEntryExternalReferenceCode ) ; sb . append ( CharPool . CLOSE_CURLY_BRACE ) ; throw new NoSuchPriceEntryException ( sb . toString ( ) ) ; }
This method is used to insert a new CommerceTierPriceEntry or update an existing one