www in docker support
This commit is contained in:
parent
539a848e95
commit
c227fce036
2145 changed files with 399596 additions and 58 deletions
|
|
@ -0,0 +1,99 @@
|
|||
package it.acxent.cart;
|
||||
|
||||
public class AcCartObject {
|
||||
private Class<CartItemIterface> itemClass;
|
||||
|
||||
private Object id;
|
||||
|
||||
private double quantity;
|
||||
|
||||
private boolean RM;
|
||||
|
||||
private String codPromo;
|
||||
|
||||
private String lang;
|
||||
|
||||
public AcCartObject() {}
|
||||
|
||||
public AcCartObject(Class theItemClass, Object theId, double theQuantity) {
|
||||
setItemClass(theItemClass);
|
||||
setId(theId);
|
||||
setQuantity(theQuantity);
|
||||
}
|
||||
|
||||
public AcCartObject(Class theItemClass, long theId, double theQuantity, boolean rm) {
|
||||
setItemClass(theItemClass);
|
||||
setId(new Long(theId));
|
||||
setQuantity(theQuantity);
|
||||
setRM(rm);
|
||||
}
|
||||
|
||||
public AcCartObject(Class theItemClass, long theId, double theQuantity) {
|
||||
setItemClass(theItemClass);
|
||||
setId(new Long(theId));
|
||||
setQuantity(theQuantity);
|
||||
}
|
||||
|
||||
public AcCartObject(Class theItemClass, Object theId, double theQuantity, boolean rm) {
|
||||
setItemClass(theItemClass);
|
||||
setId(theId);
|
||||
setQuantity(theQuantity);
|
||||
setRM(rm);
|
||||
}
|
||||
|
||||
public Object getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Class<CartItemIterface> getItemClass() {
|
||||
return this.itemClass;
|
||||
}
|
||||
|
||||
public double getQuantity() {
|
||||
return this.quantity;
|
||||
}
|
||||
|
||||
public void setId(Object newId) {
|
||||
this.id = newId;
|
||||
}
|
||||
|
||||
public void setId(long newId) {
|
||||
this.id = new Long(newId);
|
||||
}
|
||||
|
||||
public void setItemClass(Class<CartItemIterface> newItemClass) {
|
||||
this.itemClass = newItemClass;
|
||||
}
|
||||
|
||||
public void setQuantity(double newQuantity) {
|
||||
this.quantity = newQuantity;
|
||||
}
|
||||
|
||||
public String getItemsKey() {
|
||||
return String.valueOf(getId()) + " " + String.valueOf(getId());
|
||||
}
|
||||
|
||||
public boolean isRM() {
|
||||
return this.RM;
|
||||
}
|
||||
|
||||
public void setRM(boolean rM) {
|
||||
this.RM = rM;
|
||||
}
|
||||
|
||||
public String getCodPromo() {
|
||||
return (this.codPromo == null) ? "" : this.codPromo.trim();
|
||||
}
|
||||
|
||||
public void setCodPromo(String codPromo) {
|
||||
this.codPromo = codPromo;
|
||||
}
|
||||
|
||||
public String getLang() {
|
||||
return (this.lang == null) ? "" : this.lang.trim();
|
||||
}
|
||||
|
||||
public void setLang(String lang) {
|
||||
this.lang = lang;
|
||||
}
|
||||
}
|
||||
1051
decompiled-libs/www/acxent-common-1.0.1/it/acxent/cart/Cart.java
Normal file
1051
decompiled-libs/www/acxent-common-1.0.1/it/acxent/cart/Cart.java
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,288 @@
|
|||
package it.acxent.cart;
|
||||
|
||||
import it.acxent.db.ApplParmFull;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.util.DoubleOperator;
|
||||
import java.io.Serializable;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
public class CartItem implements CartItemIterface, Serializable {
|
||||
public static final long TYPE_ARTICOLO = 0L;
|
||||
|
||||
public static final long TYPE_ARTICOLO_VARIANTE = 1L;
|
||||
|
||||
public static final long TYPE_ARTICOLO_TAGLIA = 2L;
|
||||
|
||||
public static final long TYPE_ARTICOLO_VARIANTE_TAGLIA = 3L;
|
||||
|
||||
public static final long TYPE_ARTICOLO_TAGLIA_KIT = 4L;
|
||||
|
||||
public static final long TYPE_ARTICOLO_VARIANTE_TAGLIA_KIT = 5L;
|
||||
|
||||
private AcCartObject cartObject;
|
||||
|
||||
private NumberFormat nf2;
|
||||
|
||||
private boolean RM;
|
||||
|
||||
private String cartItemTag;
|
||||
|
||||
private Object itemId;
|
||||
|
||||
private double quantity;
|
||||
|
||||
private Class<CartItemIterface> itemClass;
|
||||
|
||||
private ApplParmFull applParmFull;
|
||||
|
||||
private DBAdapter dbItem;
|
||||
|
||||
public CartItem() {
|
||||
this.quantity = 1.0D;
|
||||
}
|
||||
|
||||
public CartItem(AcCartObject l_aco, ApplParmFull theApplParmFull, double newQuantity) {
|
||||
setCartObject(l_aco);
|
||||
setItemId(l_aco.getId());
|
||||
setQuantity(newQuantity);
|
||||
setItemClass(l_aco.getItemClass());
|
||||
setApplParmFull(theApplParmFull);
|
||||
try {
|
||||
CartItemIterface bean = getItemClass().newInstance();
|
||||
this.cartItemTag = bean.getCartItemTag();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public ApplParmFull getApplParmFull() {
|
||||
return this.applParmFull;
|
||||
}
|
||||
|
||||
public DBAdapter getDbItem() {
|
||||
if (this.dbItem == null && this.itemId != null)
|
||||
try {
|
||||
if (getItemId() instanceof Long) {
|
||||
DBAdapter bean = (DBAdapter)getItemClass().newInstance();
|
||||
bean.setApFull(getApplParmFull());
|
||||
bean.findByPrimaryKey(getItemId());
|
||||
if (bean.getDBState() == 1)
|
||||
this.dbItem = bean;
|
||||
} else {
|
||||
CartItemId cii = (CartItemId)getItemId();
|
||||
DBAdapter bean = (DBAdapter)getItemClass().newInstance();
|
||||
bean.setApFull(getApplParmFull());
|
||||
((CartItemIterface)bean).findByCartitemId(cii);
|
||||
if (bean.getDBState() == 1)
|
||||
this.dbItem = bean;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
return (this.dbItem == null) ? (DBAdapter)getItemClass().newInstance() : this.dbItem;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return this.dbItem;
|
||||
}
|
||||
}
|
||||
|
||||
public Class<CartItemIterface> getItemClass() {
|
||||
return this.itemClass;
|
||||
}
|
||||
|
||||
public Object getItemId() {
|
||||
return this.itemId;
|
||||
}
|
||||
|
||||
public double getQuantity() {
|
||||
return this.quantity;
|
||||
}
|
||||
|
||||
public void setApplParmFull(ApplParmFull newApplParmFull) {
|
||||
this.applParmFull = newApplParmFull;
|
||||
}
|
||||
|
||||
public void setDbItem(DBAdapter newDbItem) {
|
||||
this.dbItem = newDbItem;
|
||||
}
|
||||
|
||||
public void setItemClass(Class<CartItemIterface> newItemClass) {
|
||||
this.itemClass = newItemClass;
|
||||
}
|
||||
|
||||
public void setItemId(Object newItemId) {
|
||||
this.itemId = newItemId;
|
||||
setDbItem(null);
|
||||
}
|
||||
|
||||
public void setQuantity(double newQuantity) {
|
||||
this.quantity = newQuantity;
|
||||
}
|
||||
|
||||
public double getPriceWVat() {
|
||||
return ((CartItemIterface)getDbItem()).getPriceWVat();
|
||||
}
|
||||
|
||||
public double getPrice() {
|
||||
return ((CartItemIterface)getDbItem()).getPrice();
|
||||
}
|
||||
|
||||
public boolean isItemAvailable() {
|
||||
if (getQuantity() <= getAvailItemQty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public double getTotPrice() {
|
||||
DoubleOperator temp = new DoubleOperator(getQuantity());
|
||||
temp.setScale(4, 5);
|
||||
temp.multiply(getPrice());
|
||||
return temp.getResult();
|
||||
}
|
||||
|
||||
public double getAvailItemQty() {
|
||||
double l_dispo = 0.0D;
|
||||
if (this.itemId != null) {
|
||||
this.dbItem = null;
|
||||
l_dispo = ((CartItemIterface)getDbItem()).getAvail();
|
||||
return l_dispo;
|
||||
}
|
||||
return l_dispo;
|
||||
}
|
||||
|
||||
public double getAvail() {
|
||||
return ((CartItemIterface)getDbItem()).getAvail();
|
||||
}
|
||||
|
||||
public String getCartItemDescriptionUrl() {
|
||||
return ((CartItemIterface)getDbItem()).getCartItemDescriptionUrl();
|
||||
}
|
||||
|
||||
public String getCartItemDescription3(String lang) {
|
||||
return ((CartItemIterface)getDbItem()).getCartItemDescription3(lang);
|
||||
}
|
||||
|
||||
public String getCartItemDescription2(String lang) {
|
||||
return ((CartItemIterface)getDbItem()).getCartItemDescription2(lang);
|
||||
}
|
||||
|
||||
public String getCartItemImage() {
|
||||
return ((CartItemIterface)getDbItem()).getCartItemImage();
|
||||
}
|
||||
|
||||
public double getCost() {
|
||||
return ((CartItemIterface)getDbItem()).getCost();
|
||||
}
|
||||
|
||||
public double getDiscount() {
|
||||
return ((CartItemIterface)getDbItem()).getDiscount();
|
||||
}
|
||||
|
||||
public boolean isSale() {
|
||||
return ((CartItemIterface)getDbItem()).isSale();
|
||||
}
|
||||
|
||||
public double getIvaAliquota(long l_id_users) {
|
||||
return ((CartItemIterface)getDbItem()).getIvaAliquota(l_id_users);
|
||||
}
|
||||
|
||||
public Object getId_iva() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isRM() {
|
||||
return this.RM;
|
||||
}
|
||||
|
||||
public long getIvaItemId(long l_id_users) {
|
||||
return ((CartItemIterface)getDbItem()).getIvaItemId(l_id_users);
|
||||
}
|
||||
|
||||
public long getCartItemUdm() {
|
||||
return ((CartItemIterface)getDbItem()).getCartItemUdm();
|
||||
}
|
||||
|
||||
public double getPrice(long l_id_users) {
|
||||
return ((CartItemIterface)getDbItem()).getPrice(l_id_users);
|
||||
}
|
||||
|
||||
public String getCartItemDescription(String lang) {
|
||||
return ((CartItemIterface)getDbItem()).getCartItemDescription(lang);
|
||||
}
|
||||
|
||||
public double getTotPrice(long l_id_users) {
|
||||
DoubleOperator temp = new DoubleOperator(getQuantity());
|
||||
temp.setScale(4, 5);
|
||||
temp.multiply(getPrice(l_id_users));
|
||||
return temp.getResult();
|
||||
}
|
||||
|
||||
public String getCartItemTag() {
|
||||
return (this.cartItemTag == null) ? "" : this.cartItemTag.trim();
|
||||
}
|
||||
|
||||
public void setRM(boolean rM) {
|
||||
this.RM = rM;
|
||||
}
|
||||
|
||||
public NumberFormat getNf() {
|
||||
if (this.nf2 == null) {
|
||||
this.nf2 = NumberFormat.getInstance(Locale.ITALY);
|
||||
this.nf2.setMaximumFractionDigits(2);
|
||||
this.nf2.setMinimumFractionDigits(2);
|
||||
}
|
||||
return this.nf2;
|
||||
}
|
||||
|
||||
public double getTotPriceWVat() {
|
||||
DoubleOperator temp = new DoubleOperator(getQuantity());
|
||||
temp.setScale(4, 5);
|
||||
temp.multiply(getPriceWVat());
|
||||
return temp.getResult();
|
||||
}
|
||||
|
||||
public double getTotPriceWVat(long l_id_users) {
|
||||
DoubleOperator temp = new DoubleOperator(getQuantity());
|
||||
temp.setScale(4, 5);
|
||||
temp.multiply(getPriceWVat(l_id_users));
|
||||
return temp.getResult();
|
||||
}
|
||||
|
||||
public double getPriceWVat(long l_id_users) {
|
||||
return ((CartItemIterface)getDbItem()).getPriceWVat(l_id_users);
|
||||
}
|
||||
|
||||
public AcCartObject getCartObject() {
|
||||
return this.cartObject;
|
||||
}
|
||||
|
||||
public void setCartObject(AcCartObject cartObject) {
|
||||
this.cartObject = cartObject;
|
||||
}
|
||||
|
||||
public String getCartItemDescriptionCC(String lang) {
|
||||
return ((CartItemIterface)getDbItem()).getCartItemDescriptionCC(lang);
|
||||
}
|
||||
|
||||
public void findByCartitemId(CartItemId cii) {
|
||||
((CartItemIterface)getDbItem()).findByCartitemId(cii);
|
||||
}
|
||||
|
||||
public boolean isCostoSpedizionePreventivo(String l_id_nazione) {
|
||||
return ((CartItemIterface)getDbItem()).isCostoSpedizionePreventivo(l_id_nazione);
|
||||
}
|
||||
|
||||
public double getDeliveryCost(String l_id_nazione) {
|
||||
return ((CartItemIterface)getDbItem()).getDeliveryCost(l_id_nazione);
|
||||
}
|
||||
|
||||
public long getPercentileSpedizione() {
|
||||
return ((CartItemIterface)getDbItem()).getPercentileSpedizione();
|
||||
}
|
||||
|
||||
public boolean isScontoTroppoAlto() {
|
||||
return ((CartItemIterface)getDbItem()).isScontoTroppoAlto();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
package it.acxent.cart;
|
||||
|
||||
import it.acxent.util.StringTokenizer;
|
||||
|
||||
public class CartItemId {
|
||||
private long id_articolo = 0L;
|
||||
|
||||
private long id_articoloVariante = 0L;
|
||||
|
||||
private long id_articoloTaglia = 0L;
|
||||
|
||||
private long id_articoloTagliaKit = 0L;
|
||||
|
||||
private long id_articoloKit = 0L;
|
||||
|
||||
private long id_articoloVarianteKit = 0L;
|
||||
|
||||
public long getId_articolo() {
|
||||
return this.id_articolo;
|
||||
}
|
||||
|
||||
public void setId_articolo(long id_articolo) {
|
||||
this.id_articolo = id_articolo;
|
||||
}
|
||||
|
||||
public long getId_articoloVariante() {
|
||||
return this.id_articoloVariante;
|
||||
}
|
||||
|
||||
public void setId_articoloVariante(long id_articoloVariante) {
|
||||
this.id_articoloVariante = id_articoloVariante;
|
||||
}
|
||||
|
||||
public long getId_articoloTaglia() {
|
||||
return this.id_articoloTaglia;
|
||||
}
|
||||
|
||||
public void setId_articoloTaglia(long id_articoloTaglia) {
|
||||
this.id_articoloTaglia = id_articoloTaglia;
|
||||
}
|
||||
|
||||
public long getId_articoloKit() {
|
||||
return this.id_articoloKit;
|
||||
}
|
||||
|
||||
public void setId_articoloKit(long id_articolo2) {
|
||||
this.id_articoloKit = id_articolo2;
|
||||
}
|
||||
|
||||
public long getId_articoloVarianteKit() {
|
||||
return this.id_articoloVarianteKit;
|
||||
}
|
||||
|
||||
public void setId_articoloVarianteKit(long id_articoloVariante2) {
|
||||
this.id_articoloVarianteKit = id_articoloVariante2;
|
||||
}
|
||||
|
||||
public long getId_articoloTagliaKit() {
|
||||
return this.id_articoloTagliaKit;
|
||||
}
|
||||
|
||||
public void setId_articoloTagliaKit(long id_articoloTaglia2) {
|
||||
this.id_articoloTagliaKit = id_articoloTaglia2;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String COMMA = ",";
|
||||
if (getId_articoloTaglia() > 0L && getId_articoloTagliaKit() > 0L) {
|
||||
sb.append("TK");
|
||||
sb.append(getId_articoloTaglia());
|
||||
sb.append(",");
|
||||
sb.append(getId_articoloTagliaKit());
|
||||
} else if (getId_articoloVariante() > 0L) {
|
||||
sb.append("V");
|
||||
sb.append(getId_articoloVariante());
|
||||
} else if (getId_articoloTaglia() > 0L) {
|
||||
sb.append("T");
|
||||
sb.append(getId_articoloTaglia());
|
||||
} else {
|
||||
sb.append(getId_articolo());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void caricaCartItemIdFromReqId(String l_id) {
|
||||
initFields();
|
||||
if (!l_id.isEmpty())
|
||||
if (l_id.startsWith("TK")) {
|
||||
StringTokenizer st = new StringTokenizer(l_id.substring(2), ",");
|
||||
setId_articoloTaglia(Long.parseLong(st.getToken(0)));
|
||||
setId_articoloTagliaKit(Long.parseLong(st.getToken(1)));
|
||||
} else if (l_id.startsWith("V")) {
|
||||
setId_articoloVariante(Long.parseLong(l_id.substring(1)));
|
||||
} else if (l_id.startsWith("T")) {
|
||||
setId_articoloTaglia(Long.parseLong(l_id.substring(1)));
|
||||
} else {
|
||||
setId_articolo(Long.parseLong(l_id));
|
||||
}
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
setId_articolo(0L);
|
||||
setId_articoloKit(0L);
|
||||
setId_articoloTaglia(0L);
|
||||
setId_articoloTagliaKit(0L);
|
||||
setId_articoloVariante(0L);
|
||||
setId_articoloVarianteKit(0L);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package it.acxent.cart;
|
||||
|
||||
public interface CartItemIterface {
|
||||
Object getItemId();
|
||||
|
||||
double getPrice();
|
||||
|
||||
double getPriceWVat();
|
||||
|
||||
boolean isSale();
|
||||
|
||||
boolean isRM();
|
||||
|
||||
double getDiscount();
|
||||
|
||||
double getCost();
|
||||
|
||||
String getCartItemDescriptionUrl();
|
||||
|
||||
String getCartItemDescription2(String paramString);
|
||||
|
||||
String getCartItemDescription3(String paramString);
|
||||
|
||||
String getCartItemDescriptionCC(String paramString);
|
||||
|
||||
long getCartItemUdm();
|
||||
|
||||
double getAvail();
|
||||
|
||||
double getIvaAliquota(long paramLong);
|
||||
|
||||
long getIvaItemId(long paramLong);
|
||||
|
||||
String getCartItemImage();
|
||||
|
||||
String getCartItemDescription(String paramString);
|
||||
|
||||
String getCartItemTag();
|
||||
|
||||
double getPrice(long paramLong);
|
||||
|
||||
double getPriceWVat(long paramLong);
|
||||
|
||||
void findByCartitemId(CartItemId paramCartItemId);
|
||||
|
||||
boolean isCostoSpedizionePreventivo(String paramString);
|
||||
|
||||
double getDeliveryCost(String paramString);
|
||||
|
||||
boolean isScontoTroppoAlto();
|
||||
|
||||
long getPercentileSpedizione();
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package it.acxent.cart;
|
||||
|
||||
public class CartStatus {
|
||||
private long status = 0L;
|
||||
|
||||
public static final long RES_ADD_ITEM_OK = 21L;
|
||||
|
||||
public static final long RES_ADD_ITEM_KO = 22L;
|
||||
|
||||
public static long ST_CHECK_OUT_ERROR = 9L;
|
||||
|
||||
public static long ST_CHECK_OUT_OK = 1L;
|
||||
|
||||
public static long ST_CHECK_OUT_OK_NO_MAIL = 2L;
|
||||
|
||||
public static long ST_LOSTPWD_SEND_ERROR = 12L;
|
||||
|
||||
public static long ST_OK = 0L;
|
||||
|
||||
public static long ST_LOSTPWD_SEND_OK = 10L;
|
||||
|
||||
public long getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public void setStatus(long status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
package it.acxent.cart;
|
||||
|
||||
import it.acxent.util.DoubleOperator;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class IvaGroup {
|
||||
private Hashtable ri;
|
||||
|
||||
private DoubleOperator totImponibileDO;
|
||||
|
||||
private double importoRM;
|
||||
|
||||
public void addCartRow(double imponibile, long l_iva, double l_aliquota, boolean isRM) {
|
||||
Object theKey = new Long(l_iva);
|
||||
if (!isRM) {
|
||||
IvaGroupItem rii;
|
||||
if (getRi().containsKey(theKey)) {
|
||||
rii = (IvaGroupItem)getRi().get(theKey);
|
||||
} else {
|
||||
rii = new IvaGroupItem(l_iva, l_aliquota);
|
||||
}
|
||||
rii.addImporto(imponibile);
|
||||
getTotImponibileDO().add(imponibile);
|
||||
getRi().put(theKey, rii);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
DoubleOperator dop = new DoubleOperator(this.importoRM);
|
||||
dop.add(imponibile);
|
||||
this.importoRM = dop.getResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Enumeration elements() {
|
||||
return getRi().elements();
|
||||
}
|
||||
|
||||
private Hashtable getRi() {
|
||||
if (this.ri == null)
|
||||
this.ri = new Hashtable();
|
||||
return this.ri;
|
||||
}
|
||||
|
||||
public double getImportoRM() {
|
||||
return this.importoRM;
|
||||
}
|
||||
|
||||
public void setImportoRM(double importoRM) {
|
||||
this.importoRM = importoRM;
|
||||
}
|
||||
|
||||
public void addCartRowRM(double imponibile, long l_iva, double l_aliquota, boolean isRM, double costo) {
|
||||
Object theKey = new Long(l_iva);
|
||||
if (!isRM) {
|
||||
IvaGroupItem rii;
|
||||
if (getRi().containsKey(theKey)) {
|
||||
rii = (IvaGroupItem)getRi().get(theKey);
|
||||
} else {
|
||||
rii = new IvaGroupItem(l_iva, l_aliquota);
|
||||
}
|
||||
rii.addImporto(imponibile);
|
||||
getTotImponibileDO().add(imponibile);
|
||||
getRi().put(theKey, rii);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
IvaGroupItem rii;
|
||||
DoubleOperator dop = new DoubleOperator(this.importoRM);
|
||||
dop.add(imponibile);
|
||||
this.importoRM = dop.getResult();
|
||||
double l_imponibile = 0.0D;
|
||||
if (getRi().containsKey(theKey)) {
|
||||
rii = (IvaGroupItem)getRi().get(theKey);
|
||||
} else {
|
||||
rii = new IvaGroupItem(l_iva, l_aliquota);
|
||||
}
|
||||
rii.addImporto(l_imponibile);
|
||||
getTotImponibileDO().add(l_imponibile);
|
||||
getRi().put(theKey, rii);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DoubleOperator getTotImponibileDO() {
|
||||
if (this.totImponibileDO == null)
|
||||
this.totImponibileDO = new DoubleOperator();
|
||||
return this.totImponibileDO;
|
||||
}
|
||||
|
||||
public double getTotImponibile() {
|
||||
return getTotImponibileDO().getResult();
|
||||
}
|
||||
|
||||
public double getTotIva() {
|
||||
Enumeration<IvaGroupItem> enu = getRi().elements();
|
||||
DoubleOperator dIva = new DoubleOperator();
|
||||
dIva.setScale(4, 5);
|
||||
while (enu.hasMoreElements()) {
|
||||
IvaGroupItem row = enu.nextElement();
|
||||
dIva.add(row.getImportoIvaCalc());
|
||||
}
|
||||
dIva.setScale(2, 5);
|
||||
return dIva.getResult();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package it.acxent.cart;
|
||||
|
||||
import it.acxent.util.DoubleOperator;
|
||||
|
||||
public class IvaGroupItem {
|
||||
private long iva;
|
||||
|
||||
private double aliquota;
|
||||
|
||||
private double imponibile;
|
||||
|
||||
public IvaGroupItem(long l_iva, double l_aliquota) {
|
||||
setIva(l_iva);
|
||||
setAliquota(l_aliquota);
|
||||
}
|
||||
|
||||
public void addImporto(double l_imponibile) {
|
||||
DoubleOperator dImponibile = new DoubleOperator(getImponibile());
|
||||
dImponibile.add(l_imponibile);
|
||||
dImponibile.setScale(2, 5);
|
||||
setImponibile(dImponibile.getResult());
|
||||
}
|
||||
|
||||
public double getImponibile() {
|
||||
return this.imponibile;
|
||||
}
|
||||
|
||||
public void setImponibile(double d) {
|
||||
this.imponibile = d;
|
||||
}
|
||||
|
||||
public long getIva() {
|
||||
return this.iva;
|
||||
}
|
||||
|
||||
public double getImportoIvaCalc() {
|
||||
DoubleOperator temp = new DoubleOperator(getImponibile());
|
||||
temp.setScale(4, 5);
|
||||
temp.multiply(getAliquota());
|
||||
temp.divide(100.0F);
|
||||
temp.setScale(2, 5);
|
||||
return temp.getResult();
|
||||
}
|
||||
|
||||
public void setIva(long iva) {
|
||||
this.iva = iva;
|
||||
}
|
||||
|
||||
public double getAliquota() {
|
||||
return this.aliquota;
|
||||
}
|
||||
|
||||
public void setAliquota(double aliquota) {
|
||||
this.aliquota = aliquota;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,892 @@
|
|||
package it.acxent.cart.servlet;
|
||||
|
||||
import it.acxent.cart.AcCartObject;
|
||||
import it.acxent.cart.Cart;
|
||||
import it.acxent.cart.CartStatus;
|
||||
import it.acxent.common.Users;
|
||||
import it.acxent.db.ResParm;
|
||||
import it.acxent.servlet.LogonSvlt;
|
||||
import it.acxent.servlet.SavedHttpRequest;
|
||||
import it.acxent.util.AbMessages;
|
||||
import java.util.StringTokenizer;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
public abstract class AcCartSvlt extends LogonSvlt {
|
||||
protected static String ACT_ADD_ONE = "one";
|
||||
|
||||
protected static String ACT_CHECK_OUT = "checkOut";
|
||||
|
||||
protected static String ACT_LOGIN = "login";
|
||||
|
||||
public static String CAL_CR = "cr";
|
||||
|
||||
public static String CAL_MD = "md";
|
||||
|
||||
public static String CAL_CAT = "cat";
|
||||
|
||||
protected static String JSP_CART = "cart.jsp";
|
||||
|
||||
protected static String ATTR_THE_PAGE = "thePage";
|
||||
|
||||
protected static String JSP_CHECKOUT = "checkOut.jsp";
|
||||
|
||||
protected static String JSP_CHECKOUT_NO_REG = "checkOutNoReg.jsp";
|
||||
|
||||
protected static String JSP_HOME = "index.jsp";
|
||||
|
||||
public static String JSP_LOSTPASSWORD = "lostPwd.jsp";
|
||||
|
||||
protected static String JSP_ORDER = "order.jsp";
|
||||
|
||||
protected static String JSP_ORDER_NO_REG = "orderNoReg.jsp";
|
||||
|
||||
protected static String ACT_LOSTPWD = "lostPwd";
|
||||
|
||||
public static String ATTR_CART = "cart";
|
||||
|
||||
public static String ATTR_CART_STATUS = "cartStatus";
|
||||
|
||||
public static String CMD_ADD_ITEMS = "addItems";
|
||||
|
||||
protected static String DEFAULT_CATALOG_SVLT = "/Catalogo.abl";
|
||||
|
||||
protected static String CMD_CHECK_CART = "checkCart";
|
||||
|
||||
protected static String CMD_CHECKOUT = "checkOut";
|
||||
|
||||
protected static String CMD_LOGOUT = "logout";
|
||||
|
||||
protected static String CMD_DELETE_CART = "deleteCart";
|
||||
|
||||
public static String CMD_DELETE_ITEM = "deleteItem";
|
||||
|
||||
protected static String CMD_MODIFY_ITEM = "modifyItem";
|
||||
|
||||
protected static String CMD_MODIFY_ITEMS = "modifyItems";
|
||||
|
||||
protected static String CMD_UPDATE_CART = "updateCart";
|
||||
|
||||
public static String PROP_ORDER = "bean";
|
||||
|
||||
public static String CMD_LOSTPWD = "lostPwd";
|
||||
|
||||
public static String ATTR_LOSTPWDEMAIL = "lostPwdEmail";
|
||||
|
||||
public static String CMD_ADD_ITEM = "addItem";
|
||||
|
||||
protected static String CMD_LOGON = "logon";
|
||||
|
||||
protected static String ACT_CHECK_OUT_NO_LOGIN = "checkOutNL";
|
||||
|
||||
protected static String CMD_CHECKOUT_NO_REG = "checkOutNoReg";
|
||||
|
||||
protected void addItems(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void callJsp(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (!getCal(req).isEmpty()) {
|
||||
setJspPageRelative(getCal(req), req);
|
||||
} else {
|
||||
setJspPageRelative("cart.jsp", req);
|
||||
}
|
||||
try {
|
||||
RequestDispatcher rd = getServletContext().getRequestDispatcher(getJspPage(req));
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkCart(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
Cart cart = getCart(req);
|
||||
if (cart.getNumberOfItems() == 0L) {
|
||||
String msg = "CheckCart: Il carrello è vuoto!";
|
||||
handleDebug(msg);
|
||||
sendMessage(req, msg);
|
||||
callJsp(req, res);
|
||||
} else {
|
||||
Users utente = getLoginUser(req);
|
||||
if (utente != null && utente.getId_userProfile() == utente.getIdUserProfileNoReg()) {
|
||||
req.getSession().removeAttribute("utenteLogon");
|
||||
req.getSession().removeAttribute("loginUser_id");
|
||||
}
|
||||
afterCheckCart(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkOut(HttpServletRequest req, HttpServletResponse res) {
|
||||
CartStatus cartStatus = new CartStatus();
|
||||
try {
|
||||
Cart cart = getCart(req);
|
||||
if (getAct(req).equals(ATTR_CART)) {
|
||||
if (cart.getNumberOfItems() == 0L) {
|
||||
String msg = "CheckOut: Si è tentato di utilizzare un carrello vuoto!!!!";
|
||||
handleDebug(msg);
|
||||
forceMessage(req, msg);
|
||||
cartStatus.setStatus(CartStatus.ST_CHECK_OUT_ERROR);
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
setCart(req, cart);
|
||||
afterCheckCart(req, res);
|
||||
} else {
|
||||
cartStatus.setStatus(CartStatus.ST_OK);
|
||||
fillObject(req, cart);
|
||||
req.setAttribute(ATTR_CART, cart);
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
afterCheckOut(req, res);
|
||||
}
|
||||
} else if (getAct(req).equals(ACT_LOGIN)) {
|
||||
if (!getLogin(req).equals(""))
|
||||
if (checkLoginName(req, res) >= 5L) {
|
||||
if (!isFirstAccess(req)) {
|
||||
cartStatus.setStatus(CartStatus.ST_OK);
|
||||
} else {
|
||||
SavedHttpRequest shr = (SavedHttpRequest)req.getSession().getAttribute("savedHttpRequest");
|
||||
if (shr == null) {
|
||||
shr = new SavedHttpRequest();
|
||||
shr.setCompleteRequestedURI(req.getRequestURI());
|
||||
shr.setServletPath(req.getServletPath());
|
||||
shr.setAllParametersNAttributes(req);
|
||||
req.getSession().setAttribute("savedHttpRequest", shr);
|
||||
}
|
||||
forceJspPageRelative(getCheckCCPage(), req);
|
||||
RequestDispatcher rd = getServletContext().getRequestDispatcher(getJspPage(req));
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
}
|
||||
} else {
|
||||
sendMessage(req, AbMessages.getMessage(getLang(req), "LOGIN_FAIL"));
|
||||
}
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
getCart(req);
|
||||
afterCheckOut(req, res);
|
||||
} else if (getAct(req).equals(ACT_LOSTPWD)) {
|
||||
ResParm rp = sendLostPasswordMessage(req, res);
|
||||
if (!rp.getStatus())
|
||||
sendMessage(req, rp.getMsg());
|
||||
afterCheckOut(req, res);
|
||||
} else if (getAct(req).equals(ACT_CHECK_OUT)) {
|
||||
if (getLoginUser(req) != null) {
|
||||
if (cart.getNumberOfItems() == 0L) {
|
||||
handleDebug(AbMessages.getMessage(getLang(req), "CART_SUBMIT_EMPTY"));
|
||||
sendMessage(req, AbMessages.getMessage(getLang(req), "CART_SUBMIT_EMPTY"));
|
||||
cartStatus.setStatus(CartStatus.ST_CHECK_OUT_ERROR);
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
setCart(req, cart);
|
||||
afterCheckOut(req, res);
|
||||
} else if (checkAvailability(req) && !cart.areAllItemsAvailable()) {
|
||||
String msg = "CheckOut: Attenzione! Alcuni articoli non sono più disponibili!!!";
|
||||
handleDebug(msg);
|
||||
forceMessage(req, msg);
|
||||
cartStatus.setStatus(CartStatus.ST_CHECK_OUT_ERROR);
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
setCart(req, cart);
|
||||
afterCheckCart(req, res);
|
||||
} else {
|
||||
fillObject(req, cart);
|
||||
setCart(req, cart);
|
||||
ResParm rp = recordOrder(req, res);
|
||||
if (rp.getStatus()) {
|
||||
if (sendCheckOutMessage(req, res).getStatus()) {
|
||||
cartStatus.setStatus(CartStatus.ST_CHECK_OUT_OK);
|
||||
} else {
|
||||
cartStatus.setStatus(CartStatus.ST_CHECK_OUT_OK_NO_MAIL);
|
||||
sendMessage(req, rp.getMsg());
|
||||
}
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
removeCart(req);
|
||||
afterOrderRecorded(req, res);
|
||||
} else {
|
||||
sendMessage(req, rp.getMsg());
|
||||
setJspPageRelative(getJspCheckOutPage(req), req);
|
||||
callJsp(req, res);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sendMessage(req, AbMessages.getMessage(getLang(req), "CART_NEED_LOGIN"));
|
||||
afterCheckOut(req, res);
|
||||
}
|
||||
} else if (getAct(req).equals(ACT_CHECK_OUT_NO_LOGIN)) {
|
||||
if (cart.getNumberOfItems() == 0L) {
|
||||
handleDebug(AbMessages.getMessage(getLang(req), "CART_SUBMIT_EMPTY"));
|
||||
sendMessage(req, AbMessages.getMessage(getLang(req), "CART_SUBMIT_EMPTY"));
|
||||
cartStatus.setStatus(CartStatus.ST_CHECK_OUT_ERROR);
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
setCart(req, cart);
|
||||
afterCheckOut(req, res);
|
||||
} else {
|
||||
fillObject(req, cart);
|
||||
setCart(req, cart);
|
||||
ResParm rp = recordOrder(req, res);
|
||||
if (rp.getStatus()) {
|
||||
if (sendCheckOutMessage(req, res).getStatus()) {
|
||||
cartStatus.setStatus(CartStatus.ST_CHECK_OUT_OK);
|
||||
} else {
|
||||
cartStatus.setStatus(CartStatus.ST_CHECK_OUT_OK_NO_MAIL);
|
||||
sendMessage(req, rp.getMsg());
|
||||
}
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
removeCart(req);
|
||||
afterOrderRecorded(req, res);
|
||||
} else {
|
||||
sendMessage(req, rp.getMsg());
|
||||
afterCheckOut(req, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
sendMessage(req, e.getMessage());
|
||||
callJsp(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
protected void logOut(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
req.getSession().removeAttribute("utenteLogon");
|
||||
req.getSession().removeAttribute("loginUser_id");
|
||||
setJspPageRelative(JSP_HOME, req);
|
||||
_updateCart(req);
|
||||
callJsp(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
sendMessage(req, e.getMessage());
|
||||
callJsp(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
protected void lostPasword(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
CartStatus cs = new CartStatus();
|
||||
ResParm rp = sendLostPasswordMessage(req, res);
|
||||
if (!rp.getStatus()) {
|
||||
forceMessage(req, rp.getMsg());
|
||||
cs.setStatus(CartStatus.ST_LOSTPWD_SEND_ERROR);
|
||||
req.setAttribute(ATTR_CART_STATUS, cs);
|
||||
} else {
|
||||
forceMessage(req, rp.getMsg());
|
||||
cs.setStatus(CartStatus.ST_LOSTPWD_SEND_OK);
|
||||
req.setAttribute(ATTR_CART_STATUS, cs);
|
||||
}
|
||||
req.setAttribute(ATTR_THE_PAGE, getRequestParameter(req, ATTR_THE_PAGE));
|
||||
setJspPageRelative(getJspLostPasswordPage(req), req);
|
||||
callJsp(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
sendMessage(req, e.getMessage());
|
||||
callJsp(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteCart(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
removeCart(req);
|
||||
afterDeleteCart(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteItem(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
AcCartObject aco = getCartObject(req);
|
||||
Cart cart = getCart(req);
|
||||
cart.remove(aco);
|
||||
setCart(req, cart);
|
||||
if (cart.getNumberOfItems() == 0L) {
|
||||
String msg = "Il carrello è vuoto!";
|
||||
handleDebug(msg);
|
||||
sendMessage(req, msg);
|
||||
}
|
||||
afterDeleteItem(req, res);
|
||||
callJsp(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getAfterAddItemServlet(HttpServletRequest req) {
|
||||
return DEFAULT_CATALOG_SVLT;
|
||||
}
|
||||
|
||||
protected Cart getCart(HttpServletRequest req) {
|
||||
HttpSession session = req.getSession(true);
|
||||
Cart cart = null;
|
||||
if (session.getAttribute(ATTR_CART) != null) {
|
||||
cart = (Cart)session.getAttribute(ATTR_CART);
|
||||
cart.setApplParmFull(getApFull(req));
|
||||
updateDeliveryCost(cart, req);
|
||||
} else {
|
||||
cart = new Cart(getApFull(req));
|
||||
updateDeliveryCost(cart, req);
|
||||
}
|
||||
if (cart != null)
|
||||
setCart(req, cart);
|
||||
return cart;
|
||||
}
|
||||
|
||||
protected String getJspCartPage(HttpServletRequest req) {
|
||||
return JSP_CART;
|
||||
}
|
||||
|
||||
protected String getJspCheckOutPage(HttpServletRequest req) {
|
||||
return JSP_CHECKOUT;
|
||||
}
|
||||
|
||||
protected String getJspCheckOutNoRegPage(HttpServletRequest req) {
|
||||
return JSP_CHECKOUT_NO_REG;
|
||||
}
|
||||
|
||||
protected String getJspHomePage(HttpServletRequest req) {
|
||||
return JSP_HOME;
|
||||
}
|
||||
|
||||
protected String getJspLostPasswordPage(HttpServletRequest req) {
|
||||
return JSP_LOSTPASSWORD;
|
||||
}
|
||||
|
||||
protected String getJspOrderPage(HttpServletRequest req) {
|
||||
return JSP_ORDER;
|
||||
}
|
||||
|
||||
protected String getJspOrderPageNoReg(HttpServletRequest req) {
|
||||
return JSP_ORDER_NO_REG;
|
||||
}
|
||||
|
||||
public abstract AcCartObject getCartObject(HttpServletRequest paramHttpServletRequest) throws Exception;
|
||||
|
||||
protected String getCheckOutMailMessage() {
|
||||
return getParm(Cart.P_CHECKOUTMSG).getTesto();
|
||||
}
|
||||
|
||||
protected String getCheckOutMailMessage(String lang) {
|
||||
String temp = getParm(Cart.P_CHECKOUTMSG).getTesto();
|
||||
if (lang != null && !lang.isEmpty()) {
|
||||
int dot = temp.lastIndexOf(".");
|
||||
if (dot > 0)
|
||||
temp = temp.substring(0, dot) + "_" + temp.substring(0, dot) + lang.toLowerCase();
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
protected String getLostPasswordMailMessage() {
|
||||
return getParm(Cart.P_CHECKOUTMSG).getTesto();
|
||||
}
|
||||
|
||||
protected boolean isUsePriceWithVat(HttpServletRequest req) {
|
||||
return !(getParm(Cart.P_USE_PRICE_WITH_VAT).getNumeroInt() == 0);
|
||||
}
|
||||
|
||||
protected double getDeliveryCost(HttpServletRequest req, Cart cart) {
|
||||
return getParm(Cart.P_DELIVERY_COST).getNumeroDouble();
|
||||
}
|
||||
|
||||
protected boolean isCostoSpedizioneFull() {
|
||||
return getParm("CC_COSTO_SPED_FULL").isTrue();
|
||||
}
|
||||
|
||||
protected long getDeliveryIvaId(HttpServletRequest req) {
|
||||
return getParm(Cart.P_DELIVERY_IVA_ID).getNumeroLong();
|
||||
}
|
||||
|
||||
protected double getDeliveryIvaAliquota(HttpServletRequest req) {
|
||||
return getParm(Cart.P_DELIVERY_IVA_ALIQUOTA).getNumeroDouble();
|
||||
}
|
||||
|
||||
protected void modifyItem(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
AcCartObject aco = getCartObject(req);
|
||||
Cart cart = getCart(req);
|
||||
if (aco.getId().equals(""));
|
||||
ResParm rp = cart.add(aco, checkAvailability(req));
|
||||
if (!rp.getStatus())
|
||||
sendMessage(req, rp.getMsg());
|
||||
setCart(req, cart);
|
||||
afterModifyItems(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void modifyItems(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
AcCartObject aco = null;
|
||||
String l_id = "";
|
||||
double l_quantita = 1.0D;
|
||||
Cart cart = getCart(req);
|
||||
String l_id_itemsVector = getRequestParameter(req, "id_itemsVector");
|
||||
l_id_itemsVector = l_id_itemsVector.replace('\'', ' ');
|
||||
StringTokenizer st = new StringTokenizer(l_id_itemsVector, ",");
|
||||
while (st.hasMoreTokens()) {
|
||||
l_id = st.nextToken().trim();
|
||||
req.setAttribute("id", l_id);
|
||||
aco = getCartObject(req);
|
||||
if (req.getParameter("qt_" + l_id) != null &&
|
||||
!req.getParameter("qt_" + l_id).equals(""))
|
||||
l_quantita = getRequestDoubleParameter(req, "qt_" + l_id);
|
||||
aco.setQuantity(l_quantita);
|
||||
ResParm rp = cart.add(aco, checkAvailability(req));
|
||||
if (!rp.getStatus())
|
||||
sendMessage(req, rp.getMsg());
|
||||
}
|
||||
setCart(req, cart);
|
||||
afterModifyItems(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
checkCart(req, res);
|
||||
}
|
||||
|
||||
protected void processRequest(HttpServletRequest req, HttpServletResponse res) {
|
||||
String cmd = getCmd(req);
|
||||
forceJspPage("", req);
|
||||
if (cmd.equals(CMD_ADD_ITEM)) {
|
||||
addItem(req, res);
|
||||
} else if (cmd.equals(CMD_ADD_ITEMS)) {
|
||||
addItems(req, res);
|
||||
} else if (cmd.equals(CMD_MODIFY_ITEM)) {
|
||||
modifyItem(req, res);
|
||||
} else if (cmd.equals(CMD_MODIFY_ITEMS)) {
|
||||
modifyItems(req, res);
|
||||
} else if (cmd.equals(CMD_DELETE_ITEM)) {
|
||||
deleteItem(req, res);
|
||||
} else if (cmd.equals(CMD_DELETE_CART)) {
|
||||
deleteCart(req, res);
|
||||
} else if (cmd.equals(CMD_CHECK_CART)) {
|
||||
checkCart(req, res);
|
||||
} else if (cmd.startsWith(CMD_CHECKOUT_NO_REG)) {
|
||||
checkOutNoReg(req, res);
|
||||
} else if (cmd.startsWith(CMD_CHECKOUT)) {
|
||||
checkOut(req, res);
|
||||
} else if (cmd.equals(CMD_LOGOUT)) {
|
||||
logOut(req, res);
|
||||
} else if (cmd.equals(CMD_LOGON)) {
|
||||
logOn(req, res);
|
||||
} else if (cmd.equals(CMD_LOSTPWD)) {
|
||||
lostPasword(req, res);
|
||||
} else if (cmd.equals(CMD_UPDATE_CART)) {
|
||||
_updateCart(req);
|
||||
} else {
|
||||
ResParm rp = callCmdMethod(req, res);
|
||||
if (!rp.getStatus()) {
|
||||
if (!rp.getMsg().isEmpty())
|
||||
sendMessage(req, rp.getMsg());
|
||||
otherCommands(req, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract ResParm recordOrder(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse);
|
||||
|
||||
protected void removeCart(HttpServletRequest req) {
|
||||
req.getSession(true).removeAttribute(ATTR_CART);
|
||||
}
|
||||
|
||||
protected abstract ResParm sendCheckOutMessage(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse);
|
||||
|
||||
protected abstract ResParm sendLostPasswordMessage(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse);
|
||||
|
||||
protected void setCart(HttpServletRequest req, Cart cart) {
|
||||
cart.setApplParmFull(getApFull(req));
|
||||
cart.setDeliveryCostSetted(false);
|
||||
req.getSession(true).setAttribute(ATTR_CART, cart);
|
||||
}
|
||||
|
||||
protected void afterAddItem(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
if (getCal(req).equals(CAL_CR)) {
|
||||
req.setAttribute("cmd", "search");
|
||||
req.setAttribute("act", CAL_CR);
|
||||
RequestDispatcher rd = getServletContext().getRequestDispatcher(getAfterAddItemServlet(req));
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
} else {
|
||||
req.setAttribute("cmd", "md");
|
||||
req.setAttribute("act", CMD_ADD_ITEM);
|
||||
RequestDispatcher rd = getServletContext().getRequestDispatcher(getAfterAddItemServlet(req));
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void afterCheckCart(HttpServletRequest req, HttpServletResponse res) {
|
||||
setJspPageRelative(getJspCartPage(req), req);
|
||||
try {
|
||||
callJsp(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void afterCheckOut(HttpServletRequest req, HttpServletResponse res) {
|
||||
setJspPageRelative(getJspCheckOutPage(req), req);
|
||||
callJsp(req, res);
|
||||
}
|
||||
|
||||
protected void afterDeleteCart(HttpServletRequest req, HttpServletResponse res) {
|
||||
setJspPageRelative(getJspHomePage(req), req);
|
||||
try {
|
||||
RequestDispatcher rd = getServletContext().getRequestDispatcher(getJspPage(req));
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void afterDeleteItem(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
checkCart(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void afterModifyItems(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
checkCart(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void afterOrderRecorded(HttpServletRequest req, HttpServletResponse res) {
|
||||
setJspPageRelative(getJspOrderPage(req), req);
|
||||
callJsp(req, res);
|
||||
}
|
||||
|
||||
protected void afterOrderRecordedNoReg(HttpServletRequest req, HttpServletResponse res) {
|
||||
setJspPageRelative(getJspOrderPageNoReg(req), req);
|
||||
callJsp(req, res);
|
||||
}
|
||||
|
||||
protected boolean useControlCodeAccess() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean usePriceWithVat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean useDeliveryCostOnUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean checkControlCode(HttpServletRequest req) {
|
||||
try {
|
||||
Users ute = (Users)req.getSession().getAttribute("utenteCC");
|
||||
if (ute == null)
|
||||
return false;
|
||||
ute.findByPrimaryKey(new Long(ute.getId_users()));
|
||||
String controlCode = "";
|
||||
if (req.getParameter("controlCode") != null &&
|
||||
!req.getParameter("controlCode").equals(""))
|
||||
controlCode = req.getParameter("controlCode");
|
||||
if (!ute.getControlCode().equals(controlCode)) {
|
||||
sendMessage(req, AbMessages.getMessage(getLocale(req), "CONTROL_CODE_FAIL"));
|
||||
handleDebug(AbMessages.getMessage(getLocale(req), "CONTROL_CODE_FAIL"), 2);
|
||||
setJspPageRelative(getCheckCCPage(), req);
|
||||
return false;
|
||||
}
|
||||
sendMessage(req, AbMessages.getMessage(getLocale(req), "CONTROL_CODE_OK"));
|
||||
handleDebug(AbMessages.getMessage(getLocale(req), "CONTROL_CODE_OK"));
|
||||
ute.setControlCode("");
|
||||
ute.save();
|
||||
req.getSession().removeAttribute("utenteCC");
|
||||
req.getSession().setAttribute("utenteLogon", ute);
|
||||
req.getSession().setAttribute("loginUser_id", new Long(ute.getId_users()));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getCheckCCPage() {
|
||||
if (!getWebappResource("controlCodePage").equals(""))
|
||||
return getWebappResource("controlCodePage");
|
||||
return "controlCode.jsp";
|
||||
}
|
||||
|
||||
protected boolean isFirstAccess(HttpServletRequest req) {
|
||||
if (useControlCodeAccess())
|
||||
try {
|
||||
Users ute = (Users)req.getSession().getAttribute("utenteLogon");
|
||||
ute.findByPrimaryKey(new Long(ute.getId_users()));
|
||||
if (!ute.getControlCode().equals("")) {
|
||||
req.getSession().removeAttribute("loginUser_id");
|
||||
req.getSession().removeAttribute("utenteLogon");
|
||||
req.getSession().setAttribute("utenteCC", ute);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected double getMoreCost(HttpServletRequest req) {
|
||||
return getParm(Cart.P_MORE_COST).getNumeroDouble();
|
||||
}
|
||||
|
||||
protected void addItem(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
AcCartObject aco = getCartObject(req);
|
||||
Cart cart = getCart(req);
|
||||
CartStatus cartStatus = new CartStatus();
|
||||
String act = getAct(req);
|
||||
if (act.equals(ACT_ADD_ONE)) {
|
||||
ResParm rp = cart.quantityIncrement(aco, checkAvailability(req));
|
||||
if (!rp.getStatus()) {
|
||||
sendMessage(req, rp.getMsg());
|
||||
cartStatus.setStatus(22L);
|
||||
} else {
|
||||
cartStatus.setStatus(21L);
|
||||
}
|
||||
} else {
|
||||
ResParm rp = cart.add(aco, checkAvailability(req));
|
||||
if (!rp.getStatus()) {
|
||||
sendMessage(req, rp.getMsg());
|
||||
cartStatus.setStatus(22L);
|
||||
} else {
|
||||
cartStatus.setStatus(21L);
|
||||
}
|
||||
}
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
updateDeliveryCost(cart, req);
|
||||
setCart(req, cart);
|
||||
afterAddItem(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected double getDeliveryWarnCost(HttpServletRequest req) {
|
||||
return getParm(Cart.P_DELIVERY_WARN_COST).getNumeroDouble();
|
||||
}
|
||||
|
||||
protected void logOn(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
String jspPage = getCal(req);
|
||||
if (jspPage.isEmpty())
|
||||
jspPage = getJspHomePage(req);
|
||||
if (!getLogin(req).isEmpty())
|
||||
if (checkLoginName(req, res) >= 5L) {
|
||||
_updateCart(req);
|
||||
if (isFirstAccess(req)) {
|
||||
SavedHttpRequest shr = (SavedHttpRequest)req.getSession().getAttribute("savedHttpRequest");
|
||||
if (shr == null) {
|
||||
shr = new SavedHttpRequest();
|
||||
shr.setCompleteRequestedURI(req.getRequestURI());
|
||||
shr.setServletPath(req.getServletPath());
|
||||
shr.setAllParametersNAttributes(req);
|
||||
req.getSession().setAttribute("savedHttpRequest", shr);
|
||||
}
|
||||
forceJspPageRelative(getCheckCCPage(), req);
|
||||
RequestDispatcher rd = getServletContext().getRequestDispatcher(getJspPage(req));
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
} else {
|
||||
setJspPageRelative(jspPage, req);
|
||||
callJsp(req, res);
|
||||
}
|
||||
} else {
|
||||
_updateCart(req);
|
||||
sendMessage(req, AbMessages.getMessage(getLang(req), "LOGIN_FAIL"));
|
||||
setJspPageRelative(jspPage, req);
|
||||
callJsp(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
sendMessage(req, e.getMessage());
|
||||
setJspPageRelative(getCal(req), req);
|
||||
callJsp(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean checkAvailability(HttpServletRequest req) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void _updateCart(HttpServletRequest req, HttpServletResponse res) {
|
||||
HttpSession session = req.getSession(true);
|
||||
session.setAttribute(ATTR_CART, getCart(req));
|
||||
setJspPage(getLoginPage(req, res), req);
|
||||
RequestDispatcher rd = getServletContext().getRequestDispatcher(getJspPage(req));
|
||||
try {
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkOutNoReg(HttpServletRequest req, HttpServletResponse res) {
|
||||
CartStatus cartStatus = new CartStatus();
|
||||
try {
|
||||
Cart cart = getCart(req);
|
||||
if (getAct(req).equals(ATTR_CART)) {
|
||||
if (cart.getNumberOfItems() == 0L) {
|
||||
String msg = "CheckOut: Si è tentato di utilizzare un carrello vuoto!!!!";
|
||||
handleDebug(msg);
|
||||
forceMessage(req, msg);
|
||||
cartStatus.setStatus(CartStatus.ST_CHECK_OUT_ERROR);
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
setCart(req, cart);
|
||||
forceJspPageRelative(getJspCheckOutPage(req), req);
|
||||
afterCheckCart(req, res);
|
||||
} else {
|
||||
cartStatus.setStatus(CartStatus.ST_OK);
|
||||
fillObject(req, cart);
|
||||
req.setAttribute(ATTR_CART, cart);
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
afterCheckOutNoReg(req, res);
|
||||
}
|
||||
} else if (getAct(req).equals(ACT_CHECK_OUT)) {
|
||||
if (cart.getNumberOfItems() == 0L) {
|
||||
handleDebug(AbMessages.getMessage(getLang(req), "CART_SUBMIT_EMPTY"));
|
||||
sendMessage(req, AbMessages.getMessage(getLang(req), "CART_SUBMIT_EMPTY"));
|
||||
cartStatus.setStatus(CartStatus.ST_CHECK_OUT_ERROR);
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
setCart(req, cart);
|
||||
afterCheckOut(req, res);
|
||||
} else {
|
||||
fillObject(req, cart);
|
||||
setCart(req, cart);
|
||||
ResParm rp = recordOrderNoReg(req, res);
|
||||
if (rp.getStatus()) {
|
||||
if (sendCheckOutMessage(req, res).getStatus()) {
|
||||
cartStatus.setStatus(CartStatus.ST_CHECK_OUT_OK);
|
||||
} else {
|
||||
cartStatus.setStatus(CartStatus.ST_CHECK_OUT_OK_NO_MAIL);
|
||||
sendMessage(req, rp.getMsg());
|
||||
}
|
||||
req.setAttribute(ATTR_CART_STATUS, cartStatus);
|
||||
removeCart(req);
|
||||
afterOrderRecorded(req, res);
|
||||
} else {
|
||||
sendMessage(req, rp.getMsg());
|
||||
forceJspPageRelative(getJspCheckOutNoRegPage(req), req);
|
||||
afterCheckOutNoReg(req, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
sendMessage(req, e.getMessage());
|
||||
callJsp(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
protected void afterCheckOutNoReg(HttpServletRequest req, HttpServletResponse res) {
|
||||
setJspPageRelative(getJspCheckOutNoRegPage(req), req);
|
||||
callJsp(req, res);
|
||||
}
|
||||
|
||||
protected abstract ResParm recordOrderNoReg(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse);
|
||||
|
||||
public void updateDeliveryCost(Cart cart, HttpServletRequest req) {
|
||||
Users users = getLoginUser(req);
|
||||
if (users == null || users.getId_users() == 0L) {
|
||||
cart.setId_users(0L);
|
||||
resetDeliveryIva();
|
||||
cart.setDeliveryCost(getDeliveryCost(req, cart));
|
||||
cart.setAliquotaIvaDelivery(getDeliveryIvaAliquota(req));
|
||||
cart.setId_ivaDelivery(getDeliveryIvaId(req));
|
||||
} else {
|
||||
cart.setId_users(users.getId_users());
|
||||
resetDeliveryIva();
|
||||
if (useDeliveryCostOnUser()) {
|
||||
if (getLoginUserId(req) != null && getLoginUserId(req) != 0L) {
|
||||
cart.setDeliveryCost(getDeliveryCost(req, cart));
|
||||
cart.setId_ivaDelivery(getDeliveryIvaId(req));
|
||||
cart.setAliquotaIvaDelivery(getDeliveryIvaAliquota(req));
|
||||
cart.setDeliveryCostSetted(true);
|
||||
cart.setUsePriceWithVat(isUsePriceWithVat(req));
|
||||
}
|
||||
System.out.println("updateDeliveryCost2: " + cart.getDeliveryCost());
|
||||
} else {
|
||||
cart.setDeliveryCost(getDeliveryCost(req, cart));
|
||||
cart.setId_ivaDelivery(getDeliveryIvaId(req));
|
||||
cart.setAliquotaIvaDelivery(getDeliveryIvaAliquota(req));
|
||||
cart.setDeliveryCostSetted(true);
|
||||
cart.setUsePriceWithVat(isUsePriceWithVat(req));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Cart getCartOldConDeliveryCostDentro(HttpServletRequest req) {
|
||||
HttpSession session = req.getSession(true);
|
||||
Cart cart = null;
|
||||
if (session.getAttribute(ATTR_CART) != null) {
|
||||
cart = (Cart)session.getAttribute(ATTR_CART);
|
||||
cart.setApplParmFull(getApFull(req));
|
||||
if (useDeliveryCostOnUser()) {
|
||||
if (getLoginUserId(req) != null && getLoginUserId(req) != 0L) {
|
||||
cart.setDeliveryCost(getDeliveryCost(req, cart));
|
||||
cart.setDeliveryCostSetted(true);
|
||||
cart.setId_ivaDelivery(getDeliveryIvaId(req));
|
||||
cart.setAliquotaIvaDelivery(getDeliveryIvaAliquota(req));
|
||||
}
|
||||
} else {
|
||||
cart.setDeliveryCost(getDeliveryCost(req, cart));
|
||||
cart.setId_ivaDelivery(getDeliveryIvaId(req));
|
||||
cart.setAliquotaIvaDelivery(getDeliveryIvaAliquota(req));
|
||||
cart.setDeliveryCostSetted(true);
|
||||
cart.setUsePriceWithVat(isUsePriceWithVat(req));
|
||||
}
|
||||
} else {
|
||||
cart = new Cart(getApFull(req));
|
||||
if (!cart.isDeliveryCostSetted() && getDeliveryCost(req, cart) > 0.0D) {
|
||||
cart.setDeliveryCost(getDeliveryCost(req, cart));
|
||||
cart.setId_ivaDelivery(getDeliveryIvaId(req));
|
||||
cart.setAliquotaIvaDelivery(getDeliveryIvaAliquota(req));
|
||||
cart.setDeliveryCostSetted(true);
|
||||
}
|
||||
}
|
||||
if (cart != null) {
|
||||
Users users = getLoginUser(req);
|
||||
if (users == null || users.getId_users() == 0L) {
|
||||
cart.setId_users(0L);
|
||||
cart.setDeliveryCost(0.0D);
|
||||
cart.setMoreCost(0.0D);
|
||||
cart.setDeliveryWarnCost(0.0D);
|
||||
cart.setId_ivaDelivery(0L);
|
||||
} else {
|
||||
cart.setId_users(users.getId_users());
|
||||
}
|
||||
setCart(req, cart);
|
||||
}
|
||||
return cart;
|
||||
}
|
||||
|
||||
public void _updateCart(HttpServletRequest req) {
|
||||
HttpSession session = req.getSession(true);
|
||||
session.setAttribute(ATTR_CART, getCart(req));
|
||||
}
|
||||
|
||||
public void _updateCartAfterLogin(HttpServletRequest req, HttpServletResponse res) {
|
||||
HttpSession session = req.getSession(true);
|
||||
session.setAttribute(ATTR_CART, getCart(req));
|
||||
setJspPage(getLoginPage(req, res), req);
|
||||
RequestDispatcher rd = getServletContext().getRequestDispatcher(getJspPage(req));
|
||||
try {
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void resetDeliveryIva() {}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
package it.acxent.cart.servlet;
|
||||
Loading…
Add table
Add a link
Reference in a new issue