/**
 * Copyright (c) 2003-2004 System Integrator Corporation.
 *                 All Rights Reserved.
 */
package jp.co.sint.basic;

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import jp.co.sint.config.SIConfig;
import jp.co.sint.config.SIDBMultiConf;
import jp.co.sint.database.SIDBAccessException;
import jp.co.sint.database.SIDBUtil;
import jp.co.sint.database.SITableCondition;
import jp.co.sint.database.SITableConditionManager;
import jp.co.sint.tools.SICheckUtil;
import jp.co.sint.tools.SICustomError;
import jp.co.sint.tools.SICustomErrors;
import jp.co.sint.tools.SIFatalException;
import jp.co.sint.tools.SIHTMLUtil;
import jp.co.sint.tools.SIURLMap;
import jp.co.sint.tools.SIURLParameter;
import jp.co.sint.tools.SIUtil;

import org.apache.log4j.Category;

/**
 * @version $Id: SIFrontBasic.java,v 1.0 2003/10/24 Exp $
 * @author  Jinwang Chen
* <br>Description:
 * <p>History</p>
 * <p>Author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reason</p>
 *  ============&nbsp;&nbsp;&nbsp;==========&nbsp;&nbsp;===========================<br>
 * Jinwang Chen   2003/10/24 13:49:38  Original
 */
public class SIFrontBasic extends SIBasic{
  //ログ用のインスタンスの生成
  private static Category log=Category.getInstance(SIConfig.SILOG4J_WEBSHOP_CATEGORY_NAME);
  
  //カテゴリコード
  protected String ctgryCodeTxt=SIConfig.SICATEGORY_ROOT_CODE;
  
  //カテゴリに対する条件
  protected String ctgryConditionSQL="";
  
  //画像ある、なし、サムレイル
  protected String dispModeTxt="";//なし:トップ画面 0:画像なし 1:画像あり 2:サムレイル
  
  //トップに表示される表示モード
  protected String cmdtyFlagTxt=SIConfig.SICMDTY_FLAG_ADVICE;
  
  //カートに入れるときに、ショップコード
  protected String cartShopCodeTxt="";
  
  //カートに入れるときに、商品コード
  protected String cartCmdtyCodeTxt="";
  
  //カートに入れるときに、商品コード
  protected String cartIndividualCodeTxt="";
  
  //規格1
  private String cartStndrdCodeTxt1="";
  
  //規格2
  private String cartStndrdCodeTxt2="";
  
  //カートエレメント1
  private String cartElementCodeTxt1="";
  
  //カートエレメント2
  private String cartElementCodeTxt2="";
  
  //商品数量
  protected String cartAmountTxt="1";
  
  //予約商品フラグ
  protected String reserveCmdtyFlgTxt="0";
  
  //予約番号
  protected String reserveCodeTxt="";
  
  //SQL検索のばあいに、条件文
  protected String conditionSQL="";
  
  //検索データ
  protected SISrchKey srchKey=new SISrchKey();
  
  //EDBTG003-00 nagayoshi add start
  // カート投入された商品の商品構成フラグ
  protected String cmdtyCompositionFlg = "0";
  // セット品の構成グループ数
  protected String compositionGroupCount = "";
  // セット品の選択構成品群
  protected Collection compositionDetail = new ArrayList();
  // セット品の選択オプション群
  protected String[] compositionOption = null;
  // セット品の選択添付品群
  protected String[] compositionAppended = null;
  // よりどり点数（よりどりセット品）
  private String totalCompositionGroupDetailAmount = "0";
  //EDBTG003-00 nagayoshi add end
  //EDBTG003-00 elecs-matsushima add start
  // セット値引き
  private String setDiscount = "0";
  
  // 受注明細項番（受注修正引き回し用）
  private String detailCode = "";
  
  // 受注セットコード（受注修正引き回し用）
  private String oldSetcode = "";
  
  // 追加したセットコード
  private String addCartCmdtySetCode = "";
  //EDBTG003-00 elecs-matsushima add end
  
  public SIFrontBasic(){
  }
  
  //setter of カテゴリコード
  public void setReserveCmdtyFlgTxt(String lReserveCmdtyFlgTxt){
    if (SIUtil.isNull(lReserveCmdtyFlgTxt)) lReserveCmdtyFlgTxt="0";
    this.reserveCmdtyFlgTxt=SIUtil.changeTo(lReserveCmdtyFlgTxt.trim(),this.encode);
  }

  //setter of カテゴリコード
  public void setReserveCodeTxt(String lReserveCodeTxt){
    if (SIUtil.isNull(lReserveCodeTxt)) lReserveCodeTxt="";
    this.reserveCodeTxt=SIUtil.changeTo(lReserveCodeTxt.trim(),this.encode);
  }
  
  //setter of カテゴリコード
  public void setCtgryCodeTxt(String lCtgryCodeTxt){
    if (SIUtil.isNull(lCtgryCodeTxt)) lCtgryCodeTxt=SIConfig.SICATEGORY_ROOT_CODE;
    this.ctgryCodeTxt=SIUtil.changeTo(lCtgryCodeTxt.trim(),this.encode);
  }
  
  public void setCartShopCodeTxt(String lCartShopCodeTxt){
    if (SIUtil.isNull(lCartShopCodeTxt)) lCartShopCodeTxt="";
    this.cartShopCodeTxt=SIUtil.changeTo(lCartShopCodeTxt.trim(),this.encode);
  }
  
  //setter of 規格1
  public void setCartStndrdCodeTxt1(String lCartStndrdCodeTxt1){
    if (SIUtil.isNull(lCartStndrdCodeTxt1)) lCartStndrdCodeTxt1="";
    this.cartStndrdCodeTxt1=SIUtil.changeTo(lCartStndrdCodeTxt1.trim(),this.encode);
  }
  
  //setter of 規格2
  public void setCartStndrdCodeTxt2(String lCartStndrdCodeTxt2){
    if (SIUtil.isNull(lCartStndrdCodeTxt2)) lCartStndrdCodeTxt2="";
    this.cartStndrdCodeTxt2=SIUtil.changeTo(lCartStndrdCodeTxt2.trim(),this.encode);
  }
  
  //setter of カートエレメント1
  public void setCartElementCodeTxt1(String lCartElementCodeTxt1){
    if (SIUtil.isNull(lCartElementCodeTxt1)) lCartElementCodeTxt1="";
    this.cartElementCodeTxt1=SIUtil.changeTo(lCartElementCodeTxt1.trim(),this.encode);
  }
  
  //setter of カートエレメント2
  public void setCartElementCodeTxt2(String lCartElementCodeTxt2){
    if (SIUtil.isNull(lCartElementCodeTxt2)) lCartElementCodeTxt2="";
    this.cartElementCodeTxt2=SIUtil.changeTo(lCartElementCodeTxt2.trim(),this.encode);
  }
  
  public void setCartCmdtyCodeTxt(String lCartCmdtyCodeTxt){
    if (SIUtil.isNull(lCartCmdtyCodeTxt)) lCartCmdtyCodeTxt="";
    this.cartCmdtyCodeTxt=SIUtil.changeTo(lCartCmdtyCodeTxt.trim(),this.encode);
  }
  
  public void setCartAmountTxt(String lCartAmountTxt){
    if (SIUtil.isNull(lCartAmountTxt)) lCartAmountTxt="1";
    this.cartAmountTxt=SIUtil.changeTo(lCartAmountTxt.trim(),this.encode);
  }
  
  //setter of カテゴリに対する条件文
  public void setCtgryConditionSQL(String lCtgryConditionSQL){
    if (lCtgryConditionSQL==null)lCtgryConditionSQL="";
    this.ctgryConditionSQL=lCtgryConditionSQL;
  }
  
  //setter of 商品表示モード
  public void setDispModeTxt(String lDispModeTxt){
    if (SIUtil.isNull(lDispModeTxt)) lDispModeTxt="";
    this.dispModeTxt=SIUtil.changeTo(lDispModeTxt.trim(),this.encode);
  }
  
  //setter of 商品表示モード
  public void setCmdtyFlagTxt(String lCmdtyFlagTxt){
    if (SIUtil.isNull(lCmdtyFlagTxt)) lCmdtyFlagTxt="";//7.2.0 ST0301 修正
    this.cmdtyFlagTxt=SIUtil.changeTo(lCmdtyFlagTxt.trim(),this.encode);
  }
  
  //setter of 条件文
  public void setConditionSQL(String lConditionSQL){
    if (lConditionSQL==null)lConditionSQL="";
    this.conditionSQL=lConditionSQL;
  }
  
  //setter of ショップコード
  public void setSrchShopCodeSel(String lSrchShopCodeSel){
    srchKey.setSrchShopCodeSel(lSrchShopCodeSel);
  }
  
  //setter of ワード
  public void setSrchWordTxt(String lSrchWordTxt){
    srchKey.setSrchWordTxt(lSrchWordTxt);
  }
  
  //setter of オプション条件
  public void setSrchKeyNameData(String lSrchKeyName,String lSrchKeyData){
    srchKey.setSrchKeyNameData(lSrchKeyName,lSrchKeyData);
  }
  
  public void setSrchKey(SISrchKey lSrchKey){
    if (lSrchKey==null)lSrchKey=new SISrchKey();
    this.srchKey =lSrchKey;
  }
  
  // EDBTG003-00 nagayoshi add start
  // カート投入された商品の商品構成フラグ
  public void setCmdtyCompositionFlg(String lCmdtyCompositionFlg) {
    if (SIUtil.isNull(lCmdtyCompositionFlg)) lCmdtyCompositionFlg = SIConfig.CMDTY_COMPOSITION_NORMAL;
    this.cmdtyCompositionFlg = SIUtil.changeTo(lCmdtyCompositionFlg.trim(),this.encode);
  }
  
  // セット品の構成グループ数
  public void setCompositionGroupCount(String lGroupCount) {
    if (SIUtil.isNull(lGroupCount)) lGroupCount = "";
    this.compositionGroupCount = SIUtil.changeTo(lGroupCount.trim(),this.encode);
  }
  
  // セット品の選択構成品群
  public void setCompositionDetail(String[] lCompositionDetail) {
    if (lCompositionDetail == null || lCompositionDetail.length <= 0) {
      this.compositionDetail = new ArrayList();
    } else {
      this.compositionDetail.add(lCompositionDetail);
    }
  }
  
  // セット品の選択オプション群
  public void setCompositionOption(String[] lCompositionOption) {
    this.compositionOption = lCompositionOption;
  }
  
  // セット品の選択オプション群
  public void setCompositionAppended(String[] lCompositionAppended) {
    this.compositionAppended = lCompositionAppended;
  }
  
  // よりどり点数（よりどりセット品）
  public void setTotalCompositionGroupDetailAmount(String lTotalCompositionGroupDetailAmount) {
    this.totalCompositionGroupDetailAmount = lTotalCompositionGroupDetailAmount;
  }
  // EDBTG003-00 nagayoshi add end
  
  //getter of カテゴリに対する条件文
  public String getCtgryConditionSQL(){
    return this.ctgryConditionSQL;
  }
  
  public String getCartShopCodeTxt(){
    return this.cartShopCodeTxt;
  }
  
  public String getCartCmdtyCodeTxt(){
    return this.cartCmdtyCodeTxt;
  }
  
  //getter of 規格1
  public String getCartStndrdCodeTxt1(){
    return this.cartStndrdCodeTxt1;
  }
  
  //getter of 規格2
  public String getCartStndrdCodeTxt2(){
    return this.cartStndrdCodeTxt2;
  }
  
  //getter of カートエレメント1
  public String getCartElementCodeTxt1(){
    return this.cartElementCodeTxt1;
  }
  
  //getter of カートエレメント2
  public String getCartElementCodeTxt2(){
    return this.cartElementCodeTxt2;
  }
  
  public String getCartAmountTxt(){
    return this.cartAmountTxt;
  }
  
  //getter of 条件文
  public String getConditionSQL(){
    return this.conditionSQL;
  }
  
  //getter of ショップコード
  public String getSrchShopCodeSel(){
    return srchKey.getSrchShopCodeSel();
  }
  
  //getter of ワード
  public String getSrchWordTxt(){
    return srchKey.getSrchWordTxt();
  }
  
  //getter of オプション条件
  public String getSrchKeyNameData(String lSrchKeyName){
    return srchKey.getSrchKeyNameData(lSrchKeyName);
  }
  
  //getter of オプション条件
  public SISrchKey getSrchKey(){
    return srchKey;
  }
  
  public String getReserveCmdtyFlgTxt(){
    return this.reserveCmdtyFlgTxt;
  }
  
  public String getReserveCodeTxt(){
    return this.reserveCodeTxt;
  }
  
  //getter of カテゴリコード
  public String getCtgryCodeTxt(){
    return this.ctgryCodeTxt;
  }
  
  //getter of 商品表示モード
  public String getDispModeTxt(){
    return this.dispModeTxt;
  }
  
  //getter of 商品表示モード
  public String getCmdtyFlagTxt(){
    return this.cmdtyFlagTxt;
  }
  
  public String getCartIndividualCodeTxt() {
    return cartIndividualCodeTxt;
  }
  
  public void setCartIndividualCodeTxt(String cartIndividualCodeTxt) {
    this.cartIndividualCodeTxt = cartIndividualCodeTxt;
  }
  
  //EDBTG003-00 nagayoshi add start
  // カート投入された商品の商品構成フラグ
  public String getCmdtyCompositionFlg() {
    return this.cmdtyCompositionFlg;
  }
  
  // セット品の構成グループ数
  public String getCompositionGroupCount() {
    return this.compositionGroupCount;
  }
  
  // セット品の選択構成品群
  public Collection getCompositionDetail() {
    return this.compositionDetail;
  }
  
  // セット品の選択オプション群
  public String[] getCompositionOption() {
    return this.compositionOption;
  }
  
  // セット品の選択オプション群
  public String[] getCompositionAppended() {
    return this.compositionAppended;
  }
  
  //よりどり点数（よりどりセット品）
  public String getTotalCompositionGroupDetailAmount() {
    return this.totalCompositionGroupDetailAmount;
  }
  //EDBTG003-00 nagayoshi add end
  
  //EDBTG003-00 elecs-matsushima add start
  public String getSetDiscount() {
    return this.setDiscount;
  }
  
  public void setSetDiscount(String setDiscount) {
    if (SIUtil.isNull(setDiscount)) setDiscount = "";
    this.setDiscount = setDiscount;
  }
  
  public String getDetailCode() {
    return this.detailCode;
  }
  
  public void setDetailCode(String detailCode) {
    if (SIUtil.isNull(detailCode)) detailCode = "";
    this.detailCode = detailCode;
  }
  
  public String getOldSetcode() {
    return this.oldSetcode;
  }
  
  public void setOldSetcode(String oldSetcode) {
    if (SIUtil.isNull(oldSetcode)) oldSetcode = "";
    this.oldSetcode = oldSetcode;
  }
  //EDBTG003-00 elecs-matsushima add end
  
  /**
   * <b>getCmdtyFlagSQL</b>
   * 商品検索の際に使用するフラグを取得します
   * @param lAliasName DBテーブル名
   * @return DBテーブル名.商品フラグ
   */
  public String getCmdtyFlagSQL(String lAliasName){
    StringBuffer lTempBuf=new StringBuffer();
    if (SIUtil.isNotNull(lAliasName)&&!getCmdtyFlagTxt().equalsIgnoreCase(SIConfig.SICMDTY_FLAG_SRCH))lAliasName=" "+lAliasName+".";
    else lAliasName=" ";
    if (getCmdtyFlagTxt().equalsIgnoreCase(SIConfig.SICMDTY_FLAG_NEW)) {
      if (SIDBMultiConf.SIDB_CURRENT_INX==SIDBMultiConf.SIDB_POSTGRESQL_INX){
        lTempBuf.append(" CASE WHEN ").append(lAliasName);
        lTempBuf.append("InitDateTime+").append(SIConfig.SIMALL.getDaysOfNew()).append(">=CURRENT_DATE THEN 1 ELSE 0 END =1");
      }else{
        lTempBuf.append(" CASE WHEN ").append(lAliasName);
        lTempBuf.append("InitDateTime+").append(SIConfig.SIMALL.getDaysOfNew()).append(">=TO_DATE(SYSDATE) THEN 1 ELSE 0 END =1");
      }
      return lTempBuf.toString();
    } else if (getCmdtyFlagTxt().equalsIgnoreCase(SIConfig.SICMDTY_FLAG_ADVICE)) return lAliasName+"AdviceFlg=1 ";
    else if (getCmdtyFlagTxt().equalsIgnoreCase(SIConfig.SICMDTY_FLAG_DISCOUNT)) return "campaignpriceflg=1";//7.3.0 PI-NES0501 修正
    else return " 1=1 ";
  }
  
  /**
   * <b>getCmdtyFlagName</b>
   * 商品フラグの名称
   * @param  なし
   * @return 商品フラグ名称
   */
  public String getCmdtyFlagName(){
    if (getCmdtyFlagTxt().equalsIgnoreCase(SIConfig.SICMDTY_FLAG_NEW)) return "新着";
    else if (getCmdtyFlagTxt().equalsIgnoreCase(SIConfig.SICMDTY_FLAG_ADVICE)) return "おすすめ";
    else if (getCmdtyFlagTxt().equalsIgnoreCase(SIConfig.SICMDTY_FLAG_DISCOUNT)) return "特価品";
    else if (getCmdtyFlagTxt().equalsIgnoreCase(SIConfig.SICMDTY_FLAG_SRCH)) return "全 ";
    else return "検索結果";
  }
  
  /**
   * <b>clear</b>
   * 表示を初期状態に設定します。
   * @param なし
   * @return なし
   */
  public void clear(){
    super.clear();
    this.setCtgryCodeTxt("");
    this.setDispModeTxt("");
    this.setCmdtyFlagTxt("");
    clearSrchKey();
  }

  /**
   * <b>clearSrchKey</b>
   * 検索条件を消去します
   * @param なし
   * @return なし
   */
  public void clearSrchKey(){
    String lSrchKeyName="";
    this.srchKey.setSrchShopCodeSel("");
    this.srchKey.setSrchWordTxt("");
    this.srchKey.setRadioButton("");
    for (int ii=0;ii<SIConfig.SISRCH_KEY_NAME_MAX;ii++){
      lSrchKeyName=SIConfig.getSrchKeyNameHTML(ii);
      this.srchKey.setSrchKeyNameData(lSrchKeyName,"");
    }
  }

  /**
   * <b>initSrchKey</b>
   * 検索条件からSQL条件文を作成します。
   * @param lRequest
   * @param lConditionMan
   * @param lAliasName テーブル名
   * @param lUrlParam
   * @return なし
   */
  public void initSrchKey(HttpServletRequest lRequest,SITableConditionManager lConditionMan,String lAliasName,SIURLParameter lUrlParam){//7.1.1 ST0236 修正
    String lSrchKeyName="";
    //7.0.1 修正 ここから
    if (SIURLMap.isAUPost(lRequest)){
      srchKey.setEncode(SIConfig.SIENCODE_NONE);
    }else{
      srchKey.setEncode(SIConfig.SIENCODE_SHIFT_JIS);
    }
    // 7.0.1 修正 ここまで
    //検索用の条件
    /*
    srchKey.setSrchShopCodeSel((String)lUrlParam.getParam("srchShopCodeSel"));//検索項目：ショップコードの選択 //7.1.1 ST0236 修正
    if (lConditionMan!=null&&SIUtil.isNotNull(srchKey.getSrchShopCodeSel())){
      lConditionMan.add(new SITableCondition(lAliasName
                                            ,"ShopCode"
                                            ,srchKey.getSrchShopCodeSel()
                                            ,SIConfig.SICONDITION_TYPE_EQUAL
                                            ,SIConfig.SICONDITION_TYPE_AND));
    }
    this.srchKey.setMakerTxt((String)lUrlParam.getParam("makerTxt"));
    if (lConditionMan!=null&&SIUtil.isNotNull(srchKey.getMakerTxt())&&!srchKey.getMakerTxt().equals("1230")){
      lConditionMan.add(new SITableCondition(lAliasName
                                            ,"makercode"
                                            ,srchKey.getMakerTxt()
                                            ,SIConfig.SICONDITION_TYPE_EQUAL
                                            ,SIConfig.SICONDITION_TYPE_AND));
    } else if (lConditionMan!=null&&SIUtil.isNotNull(srchKey.getMakerTxt())&&srchKey.getMakerTxt().equals("1230")){
      lConditionMan.add(new SITableCondition(" AND "+lAliasName+".makercode IN ('1230','1231','1232') "));
    }
    */
    this.srchKey.setSrchWordTxt((String)lUrlParam.getParam("srchWordTxt"));//検索項目：ワードの選択 //7.1.1 ST0236 修正
    String[] searchWords = srchKey.getSrchWordTxt().split(" |　");
    for (int i=0;i<searchWords.length;i++) {
      if (lConditionMan!=null&&SIUtil.isNotNull(searchWords[i])){
        lConditionMan.add(new SITableCondition("("+lAliasName,"Description",searchWords[i],SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_AND));
        lConditionMan.add(new SITableCondition(lAliasName,"CmdtyName",searchWords[i],SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_OR));
        lConditionMan.add(new SITableCondition(lAliasName,"individualcode",searchWords[i],SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_OR));
        lConditionMan.add(new SITableCondition(lAliasName,"ExpansionComment1Text",searchWords[i],SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_OR));
        lConditionMan.add(new SITableCondition(lAliasName,"ExpansionComment2Text",searchWords[i],SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_OR));
        lConditionMan.add(new SITableCondition(lAliasName,"ExpansionComment3Text",searchWords[i],SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_OR));
        lConditionMan.add(new SITableCondition(lAliasName,"MakerName",searchWords[i],SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_OR));
        lConditionMan.add(new SITableCondition(lAliasName,"OtherName1",searchWords[i],SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_OR));
        lConditionMan.add(new SITableCondition(lAliasName,"OtherName2",searchWords[i],SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_OR));
        lConditionMan.add(new SITableCondition(")"));
      }
    }
    this.srchKey.setRadioButton((String)lUrlParam.getParam("radioButton"));//検索項目：中古・新品区分の選択 //7.3.0 PI-NES0501 追加
    if (lConditionMan!=null&&SIUtil.isNotNull(srchKey.getRadioButton())&&srchKey.getRadioButton().equalsIgnoreCase("used")){
      lConditionMan.add(new SITableCondition("("+lAliasName,"UsedNewFlg","1",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","2",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      //lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","3",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","4",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","6",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","7",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(")"));
    }
    if (lConditionMan!=null&&SIUtil.isNotNull(srchKey.getRadioButton())&&srchKey.getRadioButton().equalsIgnoreCase("spused")){
      lConditionMan.add(new SITableCondition("("+lAliasName,"UsedNewFlg","0",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","1",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","2",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","4",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","6",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","7",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(")"));
    }
    if (lConditionMan!=null&&SIUtil.isNotNull(srchKey.getRadioButton())&&srchKey.getRadioButton().equalsIgnoreCase("new")){
      lConditionMan.add(new SITableCondition("("+lAliasName,"UsedNewFlg","0",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","2",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","3",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","4",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","5",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(")"));
    }
    if (lConditionMan!=null&&SIUtil.isNotNull(srchKey.getRadioButton())&&srchKey.getRadioButton().equalsIgnoreCase("outlet")){
      lConditionMan.add(new SITableCondition("("+lAliasName,"UsedNewFlg","0",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","1",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","3",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","5",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","6",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(lAliasName,"UsedNewFlg","7",SIConfig.SICONDITION_TYPE_NOT_EQUAL,SIConfig.SICONDITION_TYPE_AND));
      lConditionMan.add(new SITableCondition(")"));
    }
    //オプションの検索条件の設定
    for (int ii=0;ii<SIConfig.SISRCH_KEY_NAME_MAX;ii++){
      lSrchKeyName=SIConfig.getSrchKeyNameHTML(ii);
      srchKey.setSrchKeyNameData(lSrchKeyName,(String)lUrlParam.getParam(lSrchKeyName));//7.1.1 ST0236 修正
      if (lConditionMan!=null&&SIUtil.isNotNull((String)lUrlParam.getParam(lSrchKeyName))){//7.1.1 ST0236 修正
        lConditionMan.add(new SITableCondition(lAliasName,SIConfig.getSrchKeyNameDB(ii),srchKey.getSrchKeyNameData(lSrchKeyName),SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_AND));
      }
    }
  }
  //7.1.1 ST0236 修正 ここから
  public void init(HttpServletRequest lRequest,SITableConditionManager lConditionMan,String lAliasName,SIURLParameter lUrlParam){
    super.init(lRequest,lUrlParam);
    initSrchKey(lRequest,lConditionMan,lAliasName,lUrlParam);
    this.setCtgryCodeTxt((String)lUrlParam.getParam("ctc"));//カテゴリコード
    this.setDispModeTxt((String)lUrlParam.getParam("dispModeTxt"));
    this.setCmdtyFlagTxt((String)lUrlParam.getParam("cmdtyFlagTxt"));
  }
  //7.1.1 ST0236 修正 ここまで
  //7.1.1 ST0236 修正 ここから
  public void initCart(SIURLParameter lUrlParam){
    this.setCartShopCodeTxt((String)lUrlParam.getParam("cartShopCodeTxt"));
    this.setCartCmdtyCodeTxt((String)lUrlParam.getParam("cartCmdtyCodeTxt"));
    this.setCartIndividualCodeTxt((String)lUrlParam.getParam("cartIndividualCodeTxt"));
    this.setCartStndrdCodeTxt1((String)lUrlParam.getParam("cartStndrdCodeTxt1"));//規格1
    this.setCartStndrdCodeTxt2((String)lUrlParam.getParam("cartStndrdCodeTxt2"));//規格2
    this.setCartElementCodeTxt1((String)lUrlParam.getParam("cartElementCodeTxt1"));//カートエレメント1
    this.setCartElementCodeTxt2((String)lUrlParam.getParam("cartElementCodeTxt2"));//カートエレメント2
    this.setCartAmountTxt((String)lUrlParam.getParam("cartAmountTxt"));
    this.setReserveCmdtyFlgTxt((String)lUrlParam.getParam("reserveCmdtyFlgTxt"));
    this.setReserveCodeTxt((String)lUrlParam.getParam("reserveCodeTxt"));
    // EDBTG003-00 nagayoshi add start
    // 商品構成フラグ取得
    this.setCmdtyCompositionFlg((String)lUrlParam.getParam("cmdtyCompositionFlg"));
    // EDBTG003-00 nagayoshi add end
  }

  //EDBTG005-00 kamata add start
  public void initCartForQuickOrder(SIURLParameter lUrlParam, String taishoRow){
    this.setCartShopCodeTxt((String)lUrlParam.getParam("cartShopCodeTxt" + taishoRow));
    this.setCartCmdtyCodeTxt((String)lUrlParam.getParam("cartCmdtyCodeTxt" + taishoRow));
    this.setCartIndividualCodeTxt((String)lUrlParam.getParam("cartIndividualCodeTxt" + taishoRow));
    this.setCartStndrdCodeTxt1((String)lUrlParam.getParam("cartStndrdCodeTxt1" + taishoRow));//規格1
    this.setCartStndrdCodeTxt2((String)lUrlParam.getParam("cartStndrdCodeTxt2" + taishoRow));//規格2
    this.setCartElementCodeTxt1((String)lUrlParam.getParam("cartElementCodeTxt1" + taishoRow));//カートエレメント1
    this.setCartElementCodeTxt2((String)lUrlParam.getParam("cartElementCodeTxt2" + taishoRow));//カートエレメント2
    this.setCartAmountTxt((String)lUrlParam.getParam("cartAmountTxt" + taishoRow));
    this.setReserveCmdtyFlgTxt((String)lUrlParam.getParam("reserveCmdtyFlgTxt" + taishoRow));
    this.setReserveCodeTxt((String)lUrlParam.getParam("reserveCodeTxt" + taishoRow));
    // 商品構成フラグ取得
    this.setCmdtyCompositionFlg((String)lUrlParam.getParam("cmdtyCompositionFlg" + taishoRow));
  }
  // EDBTG005-00 kamata add end

  // EDBTG005-00 kamata mod start
  public void initSetCart(HttpServletRequest lRequest, SIURLParameter lUrlParam) {
      getetCartData(lRequest, lUrlParam, "");
  }
  public void initSetCartForQuichOrder(HttpServletRequest lRequest, SIURLParameter lUrlParam, String row) {
      getetCartData(lRequest, lUrlParam, row);
  }
  // EDBTG003-00 nagayoshi add start
  public void getetCartData(HttpServletRequest lRequest, SIURLParameter lUrlParam, String taishoRow) {
    if (this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_SELECTION_SET)) {
        // よりどりセット品の場合
        // よりどり対象構成品の取得
        String[] compositionGroupDetail = (String[])lRequest.getParameterValues("compositionGroupDetail"+ taishoRow);
        String sectionCount = (String)lUrlParam.getParam("sectionCount" + taishoRow);
        String totalCompositionGroupDetailAmount = "0";
        if (compositionGroupDetail != null) {
          // よりどり対象構成品の数量取得
          for (int i = 0; i < compositionGroupDetail.length; i++) {
            // 数量取得
            String compositionGroupDetailAmount = (String)lUrlParam.getParam("compositionGroupDetailAmount_" + compositionGroupDetail[i] + taishoRow);
            totalCompositionGroupDetailAmount = SIUtil.add_LL(totalCompositionGroupDetailAmount, compositionGroupDetailAmount);
            if (SIUtil.isNotNull(compositionGroupDetailAmount) && !compositionGroupDetailAmount.equals("0")) {
              // 構成品情報の取得
              String[] compositionDetail = compositionGroupDetail[i].split(SIConfig.SIWEBSHOPPING_TOKEN);
              // 構成数の取得
              String compositionAmount = compositionDetail[3];
              // 数量 * 構成数の算出
              String calcAmount = SIUtil.multi_LL(compositionAmount, compositionGroupDetailAmount);
              // 算出値にて、構成品パラメータ作成
              String[] cmdty = new String[1];
              cmdty[0] = compositionDetail[0] + SIConfig.SIWEBSHOPPING_TOKEN
                       + compositionDetail[1] + SIConfig.SIWEBSHOPPING_TOKEN
                       + compositionDetail[2] + SIConfig.SIWEBSHOPPING_TOKEN
                       + calcAmount;
              this.setCompositionDetail(cmdty);
            }
          }
        }
        int div = Integer.parseInt(totalCompositionGroupDetailAmount) % Integer.parseInt(sectionCount);
        if (totalCompositionGroupDetailAmount.equals("0") || div > 0 || div < 0) {
          this.setCompositionDetail(new String[0]);
        }
        // よりどり点数の設定（画面にて選択された合計点数）
        this.setTotalCompositionGroupDetailAmount(totalCompositionGroupDetailAmount);
      } else {
        // よりどりセット品の場合
        // セット品の構成グループ数を取得
        this.setCompositionGroupCount((String)lUrlParam.getParam("compositionGroupCount" + taishoRow));
        if (SIUtil.isNotNull(this.getCompositionGroupCount()) && !this.getCompositionGroupCount().equals("0")) {
          // セット品の構成グループ数を初期化
          int groupCount = Integer.parseInt(this.getCompositionGroupCount());
          // セット品の構成グループ毎に選択値を取得する
          for (int i = 0; i < groupCount; i++) {
            // グループ単位の選択値を取得
            String[] detail = (String[])lRequest.getParameterValues("compositionGroupDetail_" + (i + 1) + taishoRow);
            this.setCompositionDetail(detail);
          }
        }
      }
      // セット品のオプション選択値を取得
      this.setCompositionOption((String[])lRequest.getParameterValues("option" + taishoRow));
      // セット品の添付を取得(HttpServletRequest lRequest, SIURLParameter lUrlParam) {
      this.setCompositionAppended((String[])lRequest.getParameterValues("appended" + taishoRow));
  }
  // EDBTG003-00 nagayoshi add end
  // EDBTG005-00 kamata mod end
  
  //7.1.1 ST0236 修正 ここまで
  public boolean initCartFromJan(Connection lConnection,SIURLParameter lUrlParam) {
    String janCode = (String) lUrlParam.getParam("janCodeIndividual");
    Statement lStatement = null;
    ResultSet lResultSet = null;
    boolean res = false;
    if (SIUtil.isNull(janCode)) return res;
    try {
      lStatement = lConnection.createStatement();
      lResultSet = lStatement.executeQuery("SELECT cmdtyCode,individualCode From individualtbl WHERE janCodeIndividual = " + SIDBUtil.SQL2Str(janCode));
      if (lResultSet.next()) {
        this.setCartShopCodeTxt("0");
        this.setCartCmdtyCodeTxt(lResultSet.getString("CmdtyCode"));
        this.setCartIndividualCodeTxt(lResultSet.getString("IndividualCode"));
        this.setCartAmountTxt("1");
        res = true;
      }
    } catch(Exception e) {
      res = false;
    } finally {
      SIDBUtil.close(lStatement, lResultSet);
    }
    return res;
  }
  
  //7.1.1 ST0236 修正 ここから
  public void init(HttpServletRequest lRequest,SIURLParameter lUrlParam){
    init(lRequest,null,null,lUrlParam);
  }
  //7.1.1 ST0236 修正 ここまで
  
  //7.2.0 ST1030 修正 ここから
  /**
   * <b>addCart</b>
   * トップ画面で、顧客が選択データをカートに格納します
   * @param request クライアントからリクエスト
   * @param mode (true:フロント false:バック)//7.1.1 ST0211 追加
   * @return なし
   * @throws なし
   */
  public void addCart(HttpServletRequest lRequest,Connection lConnection,boolean mode){//7.1.1 ST0211 修正
    addCart(lRequest, lConnection, mode, false);
  }
  /**
   * <b>addCart</b>
   * トップ画面で、顧客が選択データをカートに格納します
   * @param request クライアントからリクエスト
   * @param mode    (true:フロント  false:バック)
   * @param updMode (true:バックの修正時  false:左記以外)
   * @return なし
   * @throws なし
   */
  public void addCart(HttpServletRequest lRequest, Connection lConnection, boolean mode, boolean updMode) {
    //7.2.0 ST1030 修正 ここまで
    setAddCartCmdtySetCode(""); //EDBTG003-00 elecs-matsushima add
    //カートの情報
    HttpSession session=lRequest.getSession();
    SICartManager cartManager=(SICartManager)session.getAttribute(SIConfig.SISESSION_CART_INFO_NAME);
    SIReserveCartManager rsrCartManager=(SIReserveCartManager)session.getAttribute(SIConfig.SISESSION_RESERVE_CART_INFO_NAME);

    if (cartManager==null)cartManager=new SICartManager();
    if (rsrCartManager==null)rsrCartManager=new SIReserveCartManager();

    SICartCmdty lCartCmdty=new SICartCmdty(getCartShopCodeTxt()
                                           ,getCartCmdtyCodeTxt()
                                           ,getCartIndividualCodeTxt()
                                           ,getCartStndrdCodeTxt1()
                                           ,getCartElementCodeTxt1()
                                           ,getCartStndrdCodeTxt2()
                                           ,getCartElementCodeTxt2());
    log.debug("addCart:snc1="+lCartCmdty.getStndrdCode1()+",ec1="+lCartCmdty.getElementCode1()+
              ",snc2="+lCartCmdty.getStndrdCode2()+",ec2="+lCartCmdty.getElementCode2()+
              ",reserveFlg="+getReserveCmdtyFlgTxt());
    
    //7.1.1 ST0211 修正 ここから
    if (lCartCmdty.reset(lConnection,mode)){
      SIReserveCartManager lRsrCartManager=(SIReserveCartManager)session.getAttribute(SIConfig.SISESSION_RESERVE_CART_INFO_NAME);
      if (lRsrCartManager==null)lRsrCartManager=new SIReserveCartManager();
      String lRsrAmount=lRsrCartManager.getAmount(lCartCmdty.getShopCode()
                                                 ,lCartCmdty.getCmdtyCode()
                                                 ,lCartCmdty.getIndividualCode()
                                                 ,lCartCmdty.getStndrdCode1()
                                                 ,lCartCmdty.getElementCode1()
                                                 ,lCartCmdty.getStndrdCode2()
                                                 ,lCartCmdty.getElementCode2());
      if (SIUtil.isNull(lRsrAmount))lRsrAmount="0";
      int lAmount=Integer.parseInt(getCartAmountTxt())-Integer.parseInt(lRsrAmount);
      
      // EDBTG003-00 nagayoshi add start
      String calcAmount = "0";
      if (!this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL) && mode) {
        //セット値引金額を設定
        lCartCmdty.setSetDiscountPrice(lCartCmdty.getSetDiscount(lConnection));
        // セット構成情報取得Keyを設定
        lCartCmdty.setCmdtyCompositionKeySet(this.getCompositionKeySet(lConnection, lCartCmdty));
        /**************** 同一構成セット品チェック *****************/
        // ショップ情報初期化
        SIMallShop lMallShop=new SIMallShop();
        // カート情報初期化
        SICart templCart=new SICart();
        // 現在カートの取得
        SICartManager tempCartMan=(SICartManager)session.getAttribute(SIConfig.SISESSION_CART_INFO_NAME);
        if (tempCartMan == null)tempCartMan = new SICartManager();
        Iterator lTempShopIta = tempCartMan.getShopCollection(lConnection).iterator();
        Iterator lTempCartIta;
        // セット品の場合
        boolean setExist = false;
        // セット品チェックカウント
        int setCount = 0;
        while (lTempShopIta.hasNext()){
          lMallShop=(SIMallShop)lTempShopIta.next();
          lTempCartIta=tempCartMan.getCartCollection(lMallShop.getMallShopCode()).iterator();
          while (lTempCartIta.hasNext()){
            templCart=(SICart)lTempCartIta.next();
            // カウント
            if (templCart.getCartCmdty().isCmdtyComposition()) {
              setCount = Integer.parseInt(templCart.getCartCmdty().getSetCode());
            }
            if (lCartCmdty.isCmdtyComposition()) {
              LinkedHashMap check = (LinkedHashMap)templCart.getCartCmdty().getCartsCmdtyCompositionDetailMap();
              if (check.containsKey(lCartCmdty.getCmdtyCompositionKeySet())) {
                // 同一構成品が存在する場合
                lCartCmdty.setSetCode(templCart.getCartCmdty().getSetCode());
                setExist = true;
                break;
              }
            }
          }
        }
        if (!setExist) {
          // カウントアップ
          lCartCmdty.setSetCode(String.valueOf(setCount + 1));
        } else {
          calcAmount = templCart.getAmount();
        }
        /**************** 同一構成セット品チェック *****************/
      }
      //EDBTG003-00 nagayoshi add end
      
      SICart lCart=cartManager.getCart(lCartCmdty);
      
      // EDBTG003-00 nagayoshi add start
      /**************** 在庫チェック *****************/
      if (!this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL) && mode) {
        // 構成品、添付情報を追加する
        lCartCmdty = this.getCartsCmdtyCompositionInfo(lConnection, mode, "", lCartCmdty, calcAmount);
        if (lCartCmdty == null) {
          // 構成品商品がない場合
          return;
        }
        // 現在カートのセット品の各構成品在庫数Mapを取得します
        LinkedHashMap amountCmdtyMap = this.getSetCartAmountInfo(session, lConnection);
        // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi mod start
//        if (checkAddSetAmount(lCartCmdty, amountCmdtyMap, lAmount, false)) {
        if (checkAddSetAmount(lCartCmdty, amountCmdtyMap, lAmount, false, Integer.parseInt(calcAmount))) {
        // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi mod end
          // 在庫チェックOKの場合
          lCart.setCmdty(lCartCmdty);
        } else {
          // 在庫チェックNGの場合
          return;
        }
        /**************** 在庫チェック *****************/
      } else if (this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL)) {
        if (mode&&//フロントだけ
            !getReserveCmdtyFlgTxt().equals("1")&&//予約確認画面から無条件にカートに入れる
            "1".equalsIgnoreCase(lCartCmdty.getAmountFlg())&&//在庫管理する
            "0".equalsIgnoreCase(lCartCmdty.getNoStockFlg())&&//在庫なし販売しない
            Integer.parseInt(lCart.getAmount())+lAmount>Integer.parseInt(lCartCmdty.getAmount())){
          log.warn("addCart:在庫超...ShopCode="+lCartCmdty.getShopCode() +",CmdtyCode="+lCartCmdty.getCmdtyCode() +",Amount="+lCartCmdty.getAmount());
          return;
        }
      }
      // EDBTG003-00 nagayoshi add end
      
      if (getReserveCmdtyFlgTxt().equals("1")) {
        Iterator checkIte = rsrCartManager.getReserveCodes().keySet().iterator();
        String lReserveCode = "";
        while (checkIte.hasNext()) {
          lReserveCode = (String)checkIte.next();
          if (lReserveCode.equals(getReserveCodeTxt())) return;
        }
      }
      lCart=new SICart(lCartCmdty,getCartAmountTxt());
      cartManager.add(lCart);
      if (getReserveCmdtyFlgTxt().equals("1")){
        
        rsrCartManager.add(getReserveCodeTxt()
                          ,getCartShopCodeTxt()
                          ,getCartCmdtyCodeTxt()
                          ,getCartIndividualCodeTxt()
                          ,getCartStndrdCodeTxt1()
                          ,getCartElementCodeTxt1()
                          ,getCartStndrdCodeTxt2()
                          ,getCartElementCodeTxt2()
                          ,getCartAmountTxt());
      }
      //7.1.1 ST0211 修正 ここまで
    }else{
      log.warn("addCart:not found shopCode="+getCartShopCodeTxt()+",cmdtyCode="+getCartCmdtyCodeTxt());
    }
    log.debug("cartManager=="+cartManager.getAmount());
    session.setAttribute(SIConfig.SISESSION_CART_INFO_NAME, cartManager);
    session.setAttribute(SIConfig.SISESSION_RESERVE_CART_INFO_NAME, rsrCartManager);
    //7.2.0 ST1030 修正 ここから
    if (!updMode) {
      SICartManager.clearCasher(lRequest);//7.1.1 ST0154 追加
    }
    //7.2.0 ST1030 修正 ここまで
    //EDBTG003-00 elecs-matsushima add start
    if (!this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL) && !mode){
      setAddCartCmdtySetCode(lCartCmdty.getSetCode());  //EDBTG003-00 elecs-matsushima add
    } else if (!mode){
      setAddCartCmdtySetCode("0");
    }
    //EDBTG003-00 elecs-matsushima add end
    lCartCmdty.setMemberDiscountRate(SIHTMLUtil.getUserInfo(lRequest).getDiscountRate());
  }
  
  // EDBTG003-00 elecs-matsushima add start
  /**
   * <b>addCart（受注修正時に使用）</b>
   * トップ画面で、顧客が選択データをカートに格納します
   * @param request クライアントからリクエスト
   * @param mode    (true:フロント  false:バック)
   * @param updMode (true:バックの修正時  false:左記以外)
   * @return なし
   * @throws なし
   */
  public void addCartPos(HttpServletRequest lRequest, Connection lConnection, boolean mode, boolean updMode) {
    setAddCartCmdtySetCode("");
    //カートの情報
    HttpSession session=lRequest.getSession();
    SICartManager cartManager=(SICartManager)session.getAttribute(SIConfig.SISESSION_CART_INFO_NAME);
    SIReserveCartManager rsrCartManager=(SIReserveCartManager)session.getAttribute(SIConfig.SISESSION_RESERVE_CART_INFO_NAME);
    
    if (cartManager==null)cartManager=new SICartManager();
    if (rsrCartManager==null)rsrCartManager=new SIReserveCartManager();
    
    SICartCmdty lCartCmdty=new SICartCmdty(getCartShopCodeTxt()
                                           ,getCartCmdtyCodeTxt()
                                           ,getCartIndividualCodeTxt()
                                           ,getCartStndrdCodeTxt1()
                                           ,getCartElementCodeTxt1()
                                           ,getCartStndrdCodeTxt2()
                                           ,getCartElementCodeTxt2());
    log.debug("addCart:snc1="+lCartCmdty.getStndrdCode1()+",ec1="+lCartCmdty.getElementCode1()+
              ",snc2="+lCartCmdty.getStndrdCode2()+",ec2="+lCartCmdty.getElementCode2()+
              ",reserveFlg="+getReserveCmdtyFlgTxt());
    
    if (lCartCmdty.reset(lConnection,mode)){
      SIReserveCartManager lRsrCartManager=(SIReserveCartManager)session.getAttribute(SIConfig.SISESSION_RESERVE_CART_INFO_NAME);
      if (lRsrCartManager==null)lRsrCartManager=new SIReserveCartManager();
      String lRsrAmount=lRsrCartManager.getAmount(lCartCmdty.getShopCode()
                                                 ,lCartCmdty.getCmdtyCode()
                                                 ,lCartCmdty.getIndividualCode()
                                                 ,lCartCmdty.getStndrdCode1()
                                                 ,lCartCmdty.getElementCode1()
                                                 ,lCartCmdty.getStndrdCode2()
                                                 ,lCartCmdty.getElementCode2());
      if (SIUtil.isNull(lRsrAmount))lRsrAmount="0";
      int lAmount=Integer.parseInt(getCartAmountTxt())-Integer.parseInt(lRsrAmount);
      
      String calcAmount = "0";
      if (!this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL) && mode) {
        ////セット値引金額を設定
        //lCartCmdty.setSetDiscountPrice(lCartCmdty.getSetDiscount(lConnection));
        // セット構成情報取得Keyを設定
        lCartCmdty.setCmdtyCompositionKeySet(this.getCompositionKeySet(lConnection, lCartCmdty));
        /**************** 同一構成セット品チェック *****************/
        // ショップ情報初期化
        SIMallShop lMallShop=new SIMallShop();
        // カート情報初期化
        SICart templCart=new SICart();
        // 現在カートの取得
        SICartManager tempCartMan=(SICartManager)session.getAttribute(SIConfig.SISESSION_CART_INFO_NAME);
        if (tempCartMan == null)tempCartMan = new SICartManager();
        Iterator lTempShopIta = tempCartMan.getShopCollection(lConnection).iterator();
        Iterator lTempCartIta;
        // セット品の場合
        boolean setExist = false;
        // セット品チェックカウント
        int setCount = 0;
        while (lTempShopIta.hasNext()){
          lMallShop=(SIMallShop)lTempShopIta.next();
          lTempCartIta=tempCartMan.getCartCollection(lMallShop.getMallShopCode()).iterator();
          while (lTempCartIta.hasNext()){
            templCart=(SICart)lTempCartIta.next();
            // カウント
            if (templCart.getCartCmdty().isCmdtyComposition()) {
              setCount = Integer.parseInt(templCart.getCartCmdty().getSetCode());
            }
            if (lCartCmdty.isCmdtyComposition()) {
              LinkedHashMap check = (LinkedHashMap)templCart.getCartCmdty().getCartsCmdtyCompositionDetailMap();
              if (check.containsKey(lCartCmdty.getCmdtyCompositionKeySet())) {
                // 同一構成品が存在する場合
                lCartCmdty.setSetCode(templCart.getCartCmdty().getSetCode());
                setExist = true;
                break;
              }
            }
          }
        }
        lCartCmdty.setMemberDiscountRate(SIHTMLUtil.getUserInfo(lRequest).getDiscountRate());
        if (!setExist) {
          // カウントアップ
          lCartCmdty.setSetCode(String.valueOf(setCount + 1));
          lCartCmdty.setSetDiscountPrice(lCartCmdty.getSetDiscountPrice(lCartCmdty.getSetDiscount(lConnection)));
        } else {
          calcAmount = templCart.getAmount();
          lCartCmdty.setSetDiscountPrice(templCart.getCartCmdty().getSetDiscountPrice());
        }
        /**************** 同一構成セット品チェック *****************/
      }
      
      SICart lCart=cartManager.getCart(lCartCmdty);
      
      /**************** 在庫チェック *****************/
      if (!this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL) && mode) {
        // 構成品、添付情報を追加する
        lCartCmdty = this.getCartsCmdtyCompositionInfo(lConnection, mode, "", lCartCmdty, calcAmount);
        if (lCartCmdty == null) {
          // 構成品商品がない場合
          return;
        }
        // 現在カートのセット品の各構成品在庫数Mapを取得します
        LinkedHashMap amountCmdtyMap = this.getSetCartAmountInfoPos(session, lConnection);
        // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi mod start
//        if (checkAddSetAmount(lCartCmdty, amountCmdtyMap, lAmount, false, true)) {
        if (checkAddSetAmount(lCartCmdty, amountCmdtyMap, lAmount, false, true, Integer.parseInt(calcAmount))) {
        // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi mod end
          // 在庫チェックOKの場合
          lCart.setCmdty(lCartCmdty);
        } else {
          // 在庫チェックNGの場合
          return;
        }
        /**************** 在庫チェック *****************/
      } else if (this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL)) {
        LinkedHashMap amountCmdtyMap = this.getSetCartAmountInfoPos(session, lConnection);
        String cartAmount = (String) amountCmdtyMap.get(lCartCmdty.getIndividualCode());
        if (SIUtil.isNotNull(cartAmount)) {
          cartAmount = SIUtil.sub_LL(cartAmount, lCart.getAmount());
        } else {
          cartAmount = "0";
        }
        if (mode&&//フロントだけ
            !getReserveCmdtyFlgTxt().equals("1")&&//予約確認画面から無条件にカートに入れる
            "1".equalsIgnoreCase(lCartCmdty.getAmountFlg())&&//在庫管理する
            "0".equalsIgnoreCase(lCartCmdty.getNoStockFlg())&&//在庫なし販売しない
            Integer.parseInt(lCart.getAmount())+lAmount+Integer.parseInt(cartAmount)>Integer.parseInt(lCartCmdty.getAmount())){
          log.warn("addCart:在庫超...ShopCode="+lCartCmdty.getShopCode() +",CmdtyCode="+lCartCmdty.getCmdtyCode() +",Amount="+lCartCmdty.getAmount());
          return;
        }
      }
      
      if (getReserveCmdtyFlgTxt().equals("1")) {
        Iterator checkIte = rsrCartManager.getReserveCodes().keySet().iterator();
        String lReserveCode = "";
        while (checkIte.hasNext()) {
          lReserveCode = (String)checkIte.next();
          if (lReserveCode.equals(getReserveCodeTxt())) return;
        }
      }
      lCart=new SICart(lCartCmdty,getCartAmountTxt());
      cartManager.add(lCart);
      if (getReserveCmdtyFlgTxt().equals("1")){
        
        rsrCartManager.add(getReserveCodeTxt()
                          ,getCartShopCodeTxt()
                          ,getCartCmdtyCodeTxt()
                          ,getCartIndividualCodeTxt()
                          ,getCartStndrdCodeTxt1()
                          ,getCartElementCodeTxt1()
                          ,getCartStndrdCodeTxt2()
                          ,getCartElementCodeTxt2()
                          ,getCartAmountTxt());
      }
    }else{
      log.warn("addCart:not found shopCode="+getCartShopCodeTxt()+",cmdtyCode="+getCartCmdtyCodeTxt());
    }
    log.debug("cartManager=="+cartManager.getAmount());
    session.setAttribute(SIConfig.SISESSION_CART_INFO_NAME, cartManager);
    session.setAttribute(SIConfig.SISESSION_RESERVE_CART_INFO_NAME, rsrCartManager);
    
    if (!updMode) {
      SICartManager.clearCasher(lRequest);
    }
    
    if (!this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL)){
      setAddCartCmdtySetCode(lCartCmdty.getSetCode());
    } else {
      setAddCartCmdtySetCode("0");
    }
    
  }
  
  /**
   * <b>addCart（受注修正時（refresh)に使用</b>
   * トップ画面で、顧客が選択データをカートに格納します
   * @param request クライアントからリクエスト
   * @param mode    (true:フロント  false:バック)
   * @param updMode (true:バックの修正時  false:左記以外)
   * @return なし
   * @throws なし
   */
  public void addCartPos2(HttpServletRequest lRequest, Connection lConnection, boolean mode, boolean updMode) {
    //カートの情報
    HttpSession session=lRequest.getSession();
    SICartManager cartManager=(SICartManager)session.getAttribute(SIConfig.SISESSION_CART_INFO_NAME);
    SIReserveCartManager rsrCartManager=(SIReserveCartManager)session.getAttribute(SIConfig.SISESSION_RESERVE_CART_INFO_NAME);
    
    if (cartManager==null)cartManager=new SICartManager();
    if (rsrCartManager==null)rsrCartManager=new SIReserveCartManager();
    
    SICartCmdty lCartCmdty=new SICartCmdty(getCartShopCodeTxt()
                                           ,getCartCmdtyCodeTxt()
                                           ,getCartIndividualCodeTxt()
                                           ,getCartStndrdCodeTxt1()
                                           ,getCartElementCodeTxt1()
                                           ,getCartStndrdCodeTxt2()
                                           ,getCartElementCodeTxt2());
    log.debug("addCart:snc1="+lCartCmdty.getStndrdCode1()+",ec1="+lCartCmdty.getElementCode1()+
              ",snc2="+lCartCmdty.getStndrdCode2()+",ec2="+lCartCmdty.getElementCode2()+
              ",reserveFlg="+getReserveCmdtyFlgTxt());

    if (lCartCmdty.reset(lConnection,mode)){
      SIReserveCartManager lRsrCartManager=(SIReserveCartManager)session.getAttribute(SIConfig.SISESSION_RESERVE_CART_INFO_NAME);
      if (lRsrCartManager==null)lRsrCartManager=new SIReserveCartManager();
      String lRsrAmount=lRsrCartManager.getAmount(lCartCmdty.getShopCode()
                                                 ,lCartCmdty.getCmdtyCode()
                                                 ,lCartCmdty.getIndividualCode()
                                                 ,lCartCmdty.getStndrdCode1()
                                                 ,lCartCmdty.getElementCode1()
                                                 ,lCartCmdty.getStndrdCode2()
                                                 ,lCartCmdty.getElementCode2());
      if (SIUtil.isNull(lRsrAmount))lRsrAmount="0";
      int lAmount=Integer.parseInt(getCartAmountTxt())-Integer.parseInt(lRsrAmount);
      
      String calcAmount = "0";
      if (!this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL)) {
        //セット値引金額を設定（画面設定値）
        lCartCmdty.setSetDiscountPrice(this.getSetDiscount());
        // セット構成情報取得Keyを設定
        lCartCmdty.setCmdtyCompositionKeySet(this.getCompositionKeySet(lConnection, lCartCmdty));
        
        /**************** 同一構成セット品チェック *****************/
        // ショップ情報初期化
        SIMallShop lMallShop=new SIMallShop();
        // カート情報初期化
        SICart templCart=new SICart();
        // 現在カートの取得
        SICartManager tempCartMan=(SICartManager)session.getAttribute(SIConfig.SISESSION_CART_INFO_NAME);
        if (tempCartMan == null)tempCartMan = new SICartManager();
        Iterator lTempShopIta = tempCartMan.getShopCollection(lConnection).iterator();
        Iterator lTempCartIta;
        // セット品の場合
        boolean setExist = false;
        // セット品チェックカウント
        int setCount = 0;
        while (lTempShopIta.hasNext()){
          lMallShop=(SIMallShop)lTempShopIta.next();
          lTempCartIta=tempCartMan.getCartCollection(lMallShop.getMallShopCode()).iterator();
          while (lTempCartIta.hasNext()){
            templCart=(SICart)lTempCartIta.next();
            // カウント
            if (templCart.getCartCmdty().isCmdtyComposition()) {
              setCount = Integer.parseInt(templCart.getCartCmdty().getSetCode());
            }
            if (lCartCmdty.isCmdtyComposition()) {
              LinkedHashMap check = (LinkedHashMap)templCart.getCartCmdty().getCartsCmdtyCompositionDetailMap();
              if (check.containsKey(lCartCmdty.getCmdtyCompositionKeySet())) {
                // 同一構成品が存在する場合
                lCartCmdty.setSetCode(templCart.getCartCmdty().getSetCode());
                setExist = true;
                break;
              }
            }
          }
        }
        if (!setExist) {
          // カウントアップ
          lCartCmdty.setSetCode(String.valueOf(setCount + 1));
        } else {
          calcAmount = templCart.getAmount();
        }
        /**************** 同一構成セット品チェック *****************/
        
        lCartCmdty.setSetCode(String.valueOf(setCount + 1));
      }
      
      SICart lCart=cartManager.getCart(lCartCmdty);
      
      if (!this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL)) {
        // 構成品、添付情報を追加する
        lCartCmdty = this.getCartsCmdtyCompositionInfoPos2(lConnection, mode, "", lCartCmdty, calcAmount);
        if (lCartCmdty == null) {
          // 構成品商品がない場合
          return;
        }
        
      } else if (this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL)) {
        lCartCmdty.setDetailCode(this.getDetailCode());
        lCartCmdty.setOldSetCode(this.getOldSetcode());
        lCartCmdty.setAllocationMap(new LinkedHashMap()); // EDBTG003-00 elecs-matsushima add
        if (mode&&//フロントだけ
            !getReserveCmdtyFlgTxt().equals("1")&&//予約確認画面から無条件にカートに入れる
            "1".equalsIgnoreCase(lCartCmdty.getAmountFlg())&&//在庫管理する
            "0".equalsIgnoreCase(lCartCmdty.getNoStockFlg())&&//在庫なし販売しない
            Integer.parseInt(lCart.getAmount())+lAmount>Integer.parseInt(lCartCmdty.getAmount())){
          log.warn("addCart:在庫超...ShopCode="+lCartCmdty.getShopCode() +",CmdtyCode="+lCartCmdty.getCmdtyCode() +",Amount="+lCartCmdty.getAmount());
          return;
        }
      }
      
      if (getReserveCmdtyFlgTxt().equals("1")) {
        Iterator checkIte = rsrCartManager.getReserveCodes().keySet().iterator();
        String lReserveCode = "";
        while (checkIte.hasNext()) {
          lReserveCode = (String)checkIte.next();
          if (lReserveCode.equals(getReserveCodeTxt())) return;
        }
      }
      
      lCart=new SICart(lCartCmdty,getCartAmountTxt());
      cartManager.add(lCart);
      if (getReserveCmdtyFlgTxt().equals("1")){
        
        rsrCartManager.add(getReserveCodeTxt()
                          ,getCartShopCodeTxt()
                          ,getCartCmdtyCodeTxt()
                          ,getCartIndividualCodeTxt()
                          ,getCartStndrdCodeTxt1()
                          ,getCartElementCodeTxt1()
                          ,getCartStndrdCodeTxt2()
                          ,getCartElementCodeTxt2()
                          ,getCartAmountTxt());
      }
    }else{
      log.warn("addCart:not found shopCode="+getCartShopCodeTxt()+",cmdtyCode="+getCartCmdtyCodeTxt());
    }
    log.debug("cartManager=="+cartManager.getAmount());
    session.setAttribute(SIConfig.SISESSION_CART_INFO_NAME, cartManager);
    session.setAttribute(SIConfig.SISESSION_RESERVE_CART_INFO_NAME, rsrCartManager);
    if (!updMode) {
      SICartManager.clearCasher(lRequest);
    }
  }
  
  /**
   * <b>getCartsCmdtyCompositionInfo</b>
   * セット構成品のKey値を作成します
   * @param request クライアントからリクエスト
   * @return なし
   * @throws なし
   */
  public SICartCmdty getCartsCmdtyCompositionInfoPos2(Connection lConnection, boolean lMode, String lBranch, SICartCmdty lCartCmdty, String lAmount) {
    // カート投入した構成品・オプション・添付品の商品情報を設定
    LinkedHashMap cmdtyCompositionMap = new LinkedHashMap();
    Collection composition = new ArrayList();
    // 構成品データ取得
    Iterator detailIte = this.getCompositionDetail().iterator();
    // 明細番号項番
    int setDetailCount = 1;
    while(detailIte.hasNext()) {
      // 構成品1件分の情報を取得しカート投入処理を開始
      String[] detail = (String[])detailIte.next();
      for (int i = 0; i < detail.length; i ++) {
        String[] cmdty = detail[i].split("~");
        SICartCmdty cartCmdtyCompositionInfo = new SICartCmdty();
        // 構成品情報1件分の取得
        cartCmdtyCompositionInfo.setShopCode(cmdty[0]);
        cartCmdtyCompositionInfo.setCmdtyCode(cmdty[1]);
        cartCmdtyCompositionInfo.setIndividualCode(cmdty[2]);
        if (cmdty.length > 4){
          cartCmdtyCompositionInfo.setDetailCode(cmdty[4]);
        }
        if (cartCmdtyCompositionInfo.reset(lConnection, lMode, lBranch)){
          // 明細区分設定
          cartCmdtyCompositionInfo.setSetDetailFlg(SIConfig.SET_DETAIL_FLG_COMPOSITION);
          // 明細番号設定
          cartCmdtyCompositionInfo.setSetDetailCode(String.valueOf(setDetailCount));
          // 構成数
          cartCmdtyCompositionInfo.setSetCompositionCount(cmdty[3]);
          // 特価値引フラグ
          cartCmdtyCompositionInfo.setSalesDiscountFlg(lCartCmdty.getSalesDiscountFlg());
          // 会員値引フラグ
          cartCmdtyCompositionInfo.setMemberDiscountFlg(lCartCmdty.getMemberDiscountFlg());
          // 一括値引フラグ
          cartCmdtyCompositionInfo.setDiscountFlg(lCartCmdty.getDiscountFlg());
          // DBのセットコード
          cartCmdtyCompositionInfo.setOldSetCode(lCartCmdty.getOldSetCode());
          cartCmdtyCompositionInfo.setAllocationMap(lCartCmdty.getAllocationMap());// EDBTG003-00 elecs-matsushima add
          
          // 明細番号カウントアップ
          setDetailCount++;
          // セット
          composition.add(cartCmdtyCompositionInfo);
        }
      }
    }
    if (composition.size() == 0) {
      return null;
    }
    // オプションデータの取得
    String[] optionIte = this.getCompositionOption();
    if (optionIte != null) {
      for (int i = 0; i < optionIte.length; i++) {
        SICartCmdty cartOptionCompositionInfo = new SICartCmdty();
        String[] option = optionIte[i].split("~");
        // 構成品情報1件分の取得
        cartOptionCompositionInfo.setShopCode(option[0]);
        cartOptionCompositionInfo.setCmdtyCode(option[1]);
        cartOptionCompositionInfo.setIndividualCode(option[2]);
        if (option.length > 4){
          cartOptionCompositionInfo.setDetailCode(option[4]);
        }
        if (cartOptionCompositionInfo.reset(lConnection, lMode, lBranch)){
          // 明細区分設定
          cartOptionCompositionInfo.setSetDetailFlg(SIConfig.SET_DETAIL_FLG_OPTION);
          // 明細番号設定
          cartOptionCompositionInfo.setSetDetailCode(String.valueOf(setDetailCount));
          // 構成数
          cartOptionCompositionInfo.setSetCompositionCount(option[3]);
          // 特価値引フラグ
          cartOptionCompositionInfo.setSalesDiscountFlg(lCartCmdty.getSalesDiscountFlg());
          // 会員値引フラグ
          cartOptionCompositionInfo.setMemberDiscountFlg(lCartCmdty.getMemberDiscountFlg());
          // 一括値引フラグ
          cartOptionCompositionInfo.setDiscountFlg(lCartCmdty.getDiscountFlg());
          // DBのセットコード
          cartOptionCompositionInfo.setOldSetCode(lCartCmdty.getOldSetCode());
          cartOptionCompositionInfo.setAllocationMap(lCartCmdty.getAllocationMap());// EDBTG003-00 elecs-matsushima add
          // 明細番号カウントアップ
          setDetailCount++;
          // セット
          composition.add(cartOptionCompositionInfo);
        }
      }
    }
    
    // 添付品の取得
    String[] appendIte = this.getCompositionAppended();
    if (appendIte != null) {
      for (int i = 0; i < appendIte.length; i++) {
        SICartCmdty cartOptionCompositionInfo = new SICartCmdty();
        String[] append = appendIte[i].split("~");
        // 構成品情報1件分の取得
        cartOptionCompositionInfo.setShopCode(append[0]);
        cartOptionCompositionInfo.setCmdtyCode(append[1]);
        cartOptionCompositionInfo.setIndividualCode(append[2]);
        if (append.length > 4){
          cartOptionCompositionInfo.setDetailCode(append[4]);
        }
        if (cartOptionCompositionInfo.reset(lConnection, lMode, lBranch)){
          // 明細区分設定
          cartOptionCompositionInfo.setSetDetailFlg(SIConfig.SET_DETAIL_FLG_OPTION);
          // 明細番号設定
          cartOptionCompositionInfo.setSetDetailCode(String.valueOf(setDetailCount));
          // 構成数
          cartOptionCompositionInfo.setSetCompositionCount(append[3]);
          // 特価値引フラグ
          cartOptionCompositionInfo.setSalesDiscountFlg(lCartCmdty.getSalesDiscountFlg());
          // 会員値引フラグ
          cartOptionCompositionInfo.setMemberDiscountFlg(lCartCmdty.getMemberDiscountFlg());
          // 一括値引フラグ
          cartOptionCompositionInfo.setDiscountFlg(lCartCmdty.getDiscountFlg());
          // DBのセットコード
          cartOptionCompositionInfo.setOldSetCode(lCartCmdty.getOldSetCode());
          cartOptionCompositionInfo.setAllocationMap(lCartCmdty.getAllocationMap());// EDBTG003-00 elecs-matsushima add
          // 明細番号カウントアップ
          setDetailCount++;
          // セット
          composition.add(cartOptionCompositionInfo);
        }
      }
    }
    
    // 構成情報をMapへ保存
    cmdtyCompositionMap.put(lCartCmdty.getCmdtyCompositionKeySet(), composition);
    // カート構成品情報を設定
    lCartCmdty.setCartsCmdtyCompositionDetailMap(cmdtyCompositionMap);
    
    return lCartCmdty;
  }
  
  //EDBTG003-00 elecs-matsushima add end
  
  public boolean addCartPos(HttpServletRequest lRequest, Connection lConnection) {
    //カートの情報
    HttpSession session=lRequest.getSession();
    SICartManager cartManager=(SICartManager)session.getAttribute(SIConfig.SISESSION_CART_INFO_NAME);
    SIReserveCartManager rsrCartManager=(SIReserveCartManager)session.getAttribute(SIConfig.SISESSION_RESERVE_CART_INFO_NAME);
    
    if (cartManager==null)cartManager=new SICartManager();
    if (rsrCartManager==null)rsrCartManager=new SIReserveCartManager();
    
    SICartCmdty lCartCmdty=new SICartCmdty(getCartShopCodeTxt()
                                           ,getCartCmdtyCodeTxt()
                                           ,getCartIndividualCodeTxt()
                                           ,getCartStndrdCodeTxt1()
                                           ,getCartElementCodeTxt1()
                                           ,getCartStndrdCodeTxt2()
                                           ,getCartElementCodeTxt2());
    String branch = (String) session.getAttribute(SIConfig.SISESSION_MAN_POS_BRANCH_NAME);
    if (branch == null) branch = "";
    if (lCartCmdty.reset(lConnection,true,branch)){
      SIReserveCartManager lRsrCartManager=(SIReserveCartManager)session.getAttribute(SIConfig.SISESSION_RESERVE_CART_INFO_NAME);
      if (lRsrCartManager==null)lRsrCartManager=new SIReserveCartManager();
      String lRsrAmount=lRsrCartManager.getAmount(lCartCmdty.getShopCode()
                                                 ,lCartCmdty.getCmdtyCode()
                                                 ,lCartCmdty.getIndividualCode()
                                                 ,lCartCmdty.getStndrdCode1()
                                                 ,lCartCmdty.getElementCode1()
                                                 ,lCartCmdty.getStndrdCode2()
                                                 ,lCartCmdty.getElementCode2());
      if (SIUtil.isNull(lRsrAmount))lRsrAmount="0";
      int lAmount=Integer.parseInt(getCartAmountTxt())-Integer.parseInt(lRsrAmount);
      
      // EDBTG003-00 nagayoshi add start
      String calcAmount = "0";
      if (!this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL)) {
        //セット値引金額を設定
        lCartCmdty.setSetDiscountPrice(lCartCmdty.getSetDiscount(lConnection));
        // セット構成情報取得Keyを設定
        lCartCmdty.setCmdtyCompositionKeySet(this.getCompositionKeySet(lConnection, lCartCmdty));
        /**************** 同一構成セット品チェック *****************/
        // ショップ情報初期化
        SIMallShop lMallShop=new SIMallShop();
        // カート情報初期化
        SICart templCart=new SICart();
        // 現在カートの取得
        SICartManager tempCartMan=(SICartManager)session.getAttribute(SIConfig.SISESSION_CART_INFO_NAME);
        if (tempCartMan == null)tempCartMan = new SICartManager();
        Iterator lTempShopIta = tempCartMan.getShopCollection(lConnection).iterator();
        Iterator lTempCartIta;
        // セット品の場合
        boolean setExist = false;
        // セット品チェックカウント
        int setCount = 0;
        while (lTempShopIta.hasNext()){
          lMallShop=(SIMallShop)lTempShopIta.next();
          lTempCartIta=tempCartMan.getCartCollection(lMallShop.getMallShopCode()).iterator();
          while (lTempCartIta.hasNext()){
            templCart=(SICart)lTempCartIta.next();
            // カウント
            if (templCart.getCartCmdty().isCmdtyComposition()) {
              setCount = Integer.parseInt(templCart.getCartCmdty().getSetCode());
            }
            if (lCartCmdty.isCmdtyComposition()) {
              LinkedHashMap check = (LinkedHashMap)templCart.getCartCmdty().getCartsCmdtyCompositionDetailMap();
              if (check.containsKey(lCartCmdty.getCmdtyCompositionKeySet())) {
                // 同一構成品が存在する場合
                lCartCmdty.setSetCode(templCart.getCartCmdty().getSetCode());
                setExist = true;
                break;
              }
            }
          }
        }
        if (!setExist) {
          // カウントアップ
          lCartCmdty.setSetCode(String.valueOf(setCount + 1));
        } else {
          calcAmount = templCart.getAmount();
        }
        /**************** 同一構成セット品チェック *****************/
      }
      //EDBTG003-00 nagayoshi add end
      
      SICart lCart=cartManager.getCart(lCartCmdty);
      
      // EDBTG003-00 nagayoshi add start
      /**************** 在庫チェック *****************/
      if (!this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL)) {
        // 構成品、添付情報を追加する
        lCartCmdty = this.getCartsCmdtyCompositionInfo(lConnection, true, "", lCartCmdty, calcAmount);
        if (lCartCmdty == null) {
          // 構成品商品がない場合
          return false;
        }
        // 現在カートのセット品の各構成品在庫数Mapを取得します
        LinkedHashMap amountCmdtyMap = this.getSetCartAmountInfo(session, lConnection);
        // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi mod start
//        if (checkAddSetAmount(lCartCmdty, amountCmdtyMap, lAmount, true)) {
        if (checkAddSetAmount(lCartCmdty, amountCmdtyMap, lAmount, true, Integer.parseInt(calcAmount))) {
        // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi mod end
          // 在庫チェックOKの場合
          lCart.setCmdty(lCartCmdty);
        } else {
          // 在庫チェックNGの場合
          return false;
        }
        /**************** 在庫チェック *****************/
      } else if (this.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_NORMAL)) {
        if (!getReserveCmdtyFlgTxt().equals("1")&&//予約確認画面から無条件にカートに入れる
            "1".equalsIgnoreCase(lCartCmdty.getAmountFlg())&&//在庫管理する
            Integer.parseInt(lCart.getAmount())+lAmount>Integer.parseInt(lCartCmdty.getAmount())){
          log.warn("addCart:在庫超...ShopCode="+lCartCmdty.getShopCode() +",CmdtyCode="+lCartCmdty.getCmdtyCode() +",Amount="+lCartCmdty.getAmount());
          return false;
        }
      }
      // EDBTG003-00 nagayoshi add end
      
      if (getReserveCmdtyFlgTxt().equals("1")) {
        Iterator checkIte = rsrCartManager.getReserveCodes().keySet().iterator();
        String lReserveCode = "";
        while (checkIte.hasNext()) {
          lReserveCode = (String)checkIte.next();
          if (lReserveCode.equals(getReserveCodeTxt())) return false;
        }
      }
      lCart=new SICart(lCartCmdty,getCartAmountTxt());
      cartManager.add(lCart);
      if (getReserveCmdtyFlgTxt().equals("1")){
        rsrCartManager.add(getReserveCodeTxt()
                          ,getCartShopCodeTxt()
                          ,getCartCmdtyCodeTxt()
                          ,getCartIndividualCodeTxt()
                          ,getCartStndrdCodeTxt1()
                          ,getCartElementCodeTxt1()
                          ,getCartStndrdCodeTxt2()
                          ,getCartElementCodeTxt2()
                          ,getCartAmountTxt());
      }
    }else{
      log.warn("addCart:not found shopCode="+getCartShopCodeTxt()+",cmdtyCode="+getCartCmdtyCodeTxt());
      return false;
    }
    log.debug("cartManager=="+cartManager.getAmount());
    session.setAttribute(SIConfig.SISESSION_CART_INFO_NAME, cartManager);
    session.setAttribute(SIConfig.SISESSION_RESERVE_CART_INFO_NAME, rsrCartManager);
    SICartManager.clearCasher(lRequest);
    return true;
  }
  
  /**
   * <b>addCart</b>
   * トップ画面で、顧客が選択データをカートに格納します
   * @param request クライアントからリクエスト
   * @return なし
   * @throws なし
   */
  public void addCart(HttpServletRequest lRequest,Connection lConnection){
    addCart(lRequest,lConnection,true);
  }
  
  public String getPageFromNumber(int listSize){
    String res = SIUtil.add(SIUtil.multi(SIUtil.sub(getPageNumberTxt(), "1"), getPageSizeSel()), "1");
    if (SICheckUtil.isGreater(res, String.valueOf(listSize))) res = String.valueOf(listSize);
    return res;
  }
  
  public String getPageToNumber(int listSize){
    String res = SIUtil.multi(getPageNumberTxt(), getPageSizeSel());
    if (SICheckUtil.isGreater(res, String.valueOf(listSize))) res = String.valueOf(listSize);
    return res;
  }
  
  public int getMinPageNumber(int limitSize) throws SIFatalException {
    String res = "1";
    if (SICheckUtil.isLess(getPageNumberTxt(), "7")) res = "1";
    else if (SICheckUtil.isLess(String.valueOf(limitSize), SIUtil.multi(getPageSizeSel(), "10"))) res = "1";
    else if (SICheckUtil.isGreater(String.valueOf(limitSize), SIUtil.multi(getPageSizeSel(), SIUtil.add(getPageNumberTxt(), "4")))){
      res = SIUtil.sub(getPageNumberTxt(), "5");
    } else {
      res = SIUtil.sub(SIUtil.div(String.valueOf(limitSize - 1), getPageSizeSel()), "8");
    }
    return Integer.parseInt(res);
  }
  
  public int getMaxPageNumber(int limitSize) throws SIFatalException {
    String res = "1";
    if (SICheckUtil.isLess(String.valueOf(limitSize), SIUtil.add(getPageSizeSel(), "1"))) {
      res = "1";
    } else if (SICheckUtil.isLess(getPageNumberTxt(), "7") && SICheckUtil.isLess(String.valueOf(limitSize - 1), SIUtil.multi(getPageSizeSel(), "10"))) {
      res = SIUtil.add(SIUtil.div(String.valueOf(limitSize - 1), getPageSizeSel()), "1");
    } else if (SICheckUtil.isLess(getPageNumberTxt(), "7")){
      res = "10";
    } else if (SICheckUtil.isLess(String.valueOf(limitSize - 1), SIUtil.multi(getPageSizeSel(), SIUtil.add(getPageNumberTxt(), "4")))) {
      res = SIUtil.add(SIUtil.div(String.valueOf(limitSize - 1), getPageSizeSel()), "1");
    } else {
      res = SIUtil.add(getPageNumberTxt(), "4");
    }
    return Integer.parseInt(res);
  }
  
  public String getCtgryTitle(Connection lConnection,String path) throws SIDBAccessException {
    String res = "";
    String ctgryGroup = "eyelashgarage";
    if (SIUtil.isNotNull(path)&&path.equals("/hair")) ctgryGroup = "hair";
    else if (SIUtil.isNotNull(path)&&path.equals("/esthe")) ctgryGroup = "esthe";
    else if (SIUtil.isNotNull(path)&&path.equals("/bed")) ctgryGroup = "bed";
    else if (SIUtil.isNotNull(path)&&path.equals("/cosme")) ctgryGroup = "cosme";
    else if (SIUtil.isNotNull(path)&&path.equals("/nail")) ctgryGroup = "nail";
    else if (SIUtil.isNotNull(path)&&path.equals("/haircosme")) ctgryGroup = "haircosme";
    else if (SIUtil.isNotNull(path)&&path.equals("/book")) ctgryGroup = "book";
    else if (SIUtil.isNotNull(path)&&path.equals("/eyelash")) ctgryGroup = "eyelash";
    
    res = SIDBUtil.getFirstData(lConnection, "SELECT a.ctgryname FROM ctgrymtbl a,ctgrygrouptbl b WHERE a.ctgrycode=b.ctgrycode AND b.ctgrygroup="+SIDBUtil.SQL2Str(ctgryGroup)+" AND a.ctgrycode="+SIDBUtil.SQL2Str(getCtgryCodeTxt()));
    if (SIUtil.isNotNull(res)) return res;
    res = SIDBUtil.getFirstData(lConnection, "SELECT a.ctgryname FROM ctgrymtbl a,ctgrygrouptbl b,ctgrymtbl c WHERE a.ctgrycode=b.ctgrycode AND c.parentctgrycode=b.ctgrycode AND b.ctgrygroup="+SIDBUtil.SQL2Str(ctgryGroup)+" AND c.ctgrycode="+SIDBUtil.SQL2Str(getCtgryCodeTxt()));
    if (SIUtil.isNotNull(res)) return res;
    return "検索結果一覧";
  }
  
  public String getCtgryTitleCode(Connection lConnection,String path) throws SIDBAccessException {
    String res = "";
    String ctgryGroup = "eyelashgarage";
    if (SIUtil.isNotNull(path)&&path.equals("/hair")) ctgryGroup = "hair";
    else if (SIUtil.isNotNull(path)&&path.equals("/esthe")) ctgryGroup = "esthe";
    else if (SIUtil.isNotNull(path)&&path.equals("/bed")) ctgryGroup = "bed";
    else if (SIUtil.isNotNull(path)&&path.equals("/cosme")) ctgryGroup = "cosme";
    else if (SIUtil.isNotNull(path)&&path.equals("/nail")) ctgryGroup = "nail";
    else if (SIUtil.isNotNull(path)&&path.equals("/haircosme")) ctgryGroup = "haircosme";
    else if (SIUtil.isNotNull(path)&&path.equals("/book")) ctgryGroup = "book";
    else if (SIUtil.isNotNull(path)&&path.equals("/eyelash")) ctgryGroup = "eyelash";
    
    res = SIDBUtil.getFirstData(lConnection, "SELECT a.ctgrycode FROM ctgrymtbl a,ctgrygrouptbl b WHERE a.ctgrycode=b.ctgrycode AND b.ctgrygroup="+SIDBUtil.SQL2Str(ctgryGroup)+" AND a.ctgrycode="+SIDBUtil.SQL2Str(getCtgryCodeTxt()));
    if (SIUtil.isNotNull(res)) return res;
    res = SIDBUtil.getFirstData(lConnection, "SELECT a.ctgrycode FROM ctgrymtbl a,ctgrygrouptbl b,ctgrymtbl c WHERE a.ctgrycode=b.ctgrycode AND c.parentctgrycode=b.ctgrycode AND b.ctgrygroup="+SIDBUtil.SQL2Str(ctgryGroup)+" AND c.ctgrycode="+SIDBUtil.SQL2Str(getCtgryCodeTxt()));
    if (SIUtil.isNotNull(res)) return res;
    return SIConfig.SICATEGORY_ROOT_CODE;
  }
  
  public String getCtgryNameTxt(Connection lConnection) throws SIDBAccessException {
    return SIDBUtil.getFirstData(lConnection,"SELECT ctgryname FROM ctgrymtbl WHERE ctgrycode="+SIDBUtil.SQL2Str(this.getCtgryCodeTxt()));
  }
  
  //EDBTG003-00 nagayoshi add start
  /**
   * <b>getCompositionKeySet</b>
   * セット構成品のKey値を作成します
   * @param request クライアントからリクエスト
   * @return なし
   * @throws なし
   */
  public String getCompositionKeySet(Connection lConnection, SICartCmdty lCartCmdty) {
    // カート投入した構成品・オプション・添付品にてKey値を作成
    StringBuffer keySet = new StringBuffer();
    String sep = "~";
    keySet.append(this.getCartShopCodeTxt());
    keySet.append(sep);
    keySet.append(this.getCartCmdtyCodeTxt());
    keySet.append(sep);
    keySet.append(this.getCartIndividualCodeTxt());
    // 構成品のカート投入
    Iterator detailIte = this.getCompositionDetail().iterator();
    while(detailIte.hasNext()) {
      // 構成品1件分の情報を取得しカート投入処理を開始
      String[] detail = (String[])detailIte.next();
      for (int i = 0; i < detail.length; i ++) {
        String[] cmdty = detail[i].split("~");
        // Keyへ追加
        keySet.append(sep);
        keySet.append(cmdty[2]);
      }
    }
    // オプションのカート投入
    if (this.getCompositionOption() != null) {
      for (int i = 0; i < this.getCompositionOption().length; i++) {
        // オプション1件分の情報を取得しカート投入処理を開始
        String[] cmdty = this.getCompositionOption()[i].split("~");
        // Keyへ追加
        keySet.append(sep);
        keySet.append(cmdty[2]);
      }
    }
    // 添付品のカート投入
    if (this.getCompositionAppended() != null) {
      for (int i = 0; i < this.getCompositionAppended().length; i++) {
        // 添付品1件分の情報を取得しカート投入処理を開始
        String[] cmdty = this.getCompositionAppended()[i].split("~");
        // Keyへ追加
        keySet.append(sep);
        keySet.append(cmdty[2]);
      }
    }
    return keySet.toString();
  }
  
  /**
   * <b>getCartsCmdtyCompositionInfo</b>
   * セット構成品のKey値を作成します
   * @param request クライアントからリクエスト
   * @return なし
   * @throws なし
   */
  public SICartCmdty getCartsCmdtyCompositionInfo(Connection lConnection, boolean lMode, String lBranch, SICartCmdty lCartCmdty) {
    return this.getCartsCmdtyCompositionInfo(lConnection, lMode, lBranch, lCartCmdty, "0");
  }
  
  /**
   * <b>getCartsCmdtyCompositionInfo</b>
   * セット構成品のKey値を作成します
   * @param request クライアントからリクエスト
   * @return なし
   * @throws なし
   */
  public SICartCmdty getCartsCmdtyCompositionInfo(Connection lConnection, boolean lMode, String lBranch, SICartCmdty lCartCmdty, String lAmount) {
    // カート投入した構成品・オプション・添付品の商品情報を設定
    LinkedHashMap cmdtyCompositionMap = new LinkedHashMap();
    Collection composition = new ArrayList();
    // 構成品データ取得
    Iterator detailIte = this.getCompositionDetail().iterator();
    // 明細番号項番
    int setDetailCount = 1;
    while(detailIte.hasNext()) {
      // 構成品1件分の情報を取得しカート投入処理を開始
      String[] detail = (String[])detailIte.next();
      for (int i = 0; i < detail.length; i ++) {
        String[] cmdty = detail[i].split("~");
        SICartCmdty cartCmdtyCompositionInfo = new SICartCmdty();
        // 構成品情報1件分の取得
        cartCmdtyCompositionInfo.setShopCode(cmdty[0]);
        cartCmdtyCompositionInfo.setCmdtyCode(cmdty[1]);
        cartCmdtyCompositionInfo.setIndividualCode(cmdty[2]);
        if (cartCmdtyCompositionInfo.reset(lConnection, lMode, lBranch)){
          // 明細区分設定
          cartCmdtyCompositionInfo.setSetDetailFlg(SIConfig.SET_DETAIL_FLG_COMPOSITION);
          // 明細番号設定
          cartCmdtyCompositionInfo.setSetDetailCode(String.valueOf(setDetailCount));
          // 構成数
          cartCmdtyCompositionInfo.setSetCompositionCount(cmdty[3]);
          // 特価値引フラグ
          cartCmdtyCompositionInfo.setSalesDiscountFlg(lCartCmdty.getSalesDiscountFlg());
          // 会員値引フラグ
          cartCmdtyCompositionInfo.setMemberDiscountFlg(lCartCmdty.getMemberDiscountFlg());
          // 一括値引フラグ
          cartCmdtyCompositionInfo.setDiscountFlg(lCartCmdty.getDiscountFlg());
          // 明細番号カウントアップ
          setDetailCount++;
          // セット
          composition.add(cartCmdtyCompositionInfo);
        }
      }
    }
    if (composition.size() == 0) {
      return null;
    }
    // オプションデータの取得
    String[] optionIte = this.getCompositionOption();
    if (optionIte != null) {
      for (int i = 0; i < optionIte.length; i++) {
        SICartCmdty cartOptionCompositionInfo = new SICartCmdty();
        String[] option = optionIte[i].split("~");
        // 構成品情報1件分の取得
        cartOptionCompositionInfo.setShopCode(option[0]);
        cartOptionCompositionInfo.setCmdtyCode(option[1]);
        cartOptionCompositionInfo.setIndividualCode(option[2]);
        if (cartOptionCompositionInfo.reset(lConnection, lMode, lBranch)){
          // 明細区分設定
          cartOptionCompositionInfo.setSetDetailFlg(SIConfig.SET_DETAIL_FLG_OPTION);
          // 明細番号設定
          cartOptionCompositionInfo.setSetDetailCode(String.valueOf(setDetailCount));
          // 構成数
          cartOptionCompositionInfo.setSetCompositionCount(option[3]);
          // 特価値引フラグ
          cartOptionCompositionInfo.setSalesDiscountFlg(lCartCmdty.getSalesDiscountFlg());
          // 会員値引フラグ
          cartOptionCompositionInfo.setMemberDiscountFlg(lCartCmdty.getMemberDiscountFlg());
          // 一括値引フラグ
          cartOptionCompositionInfo.setDiscountFlg(lCartCmdty.getDiscountFlg());
          // 明細番号カウントアップ
          setDetailCount++;
          // セット
          composition.add(cartOptionCompositionInfo);
        }
      }
    }
    
    // 添付品の取得
    if (this.getCompositionAppended() != null) {
      Collection appendedColl = lCartCmdty.getCmdtyCompositionAppended(lConnection);
      Iterator ite = appendedColl.iterator();
      while(ite.hasNext()) {
        SICartCmdty cartAppendedCompositionInfo = new SICartCmdty();
        SICmdtyCompositionAppended cmdtyCompositionAppended = (SICmdtyCompositionAppended)ite.next();
        // 構成品情報1件分の取得
        cartAppendedCompositionInfo.setShopCode(cmdtyCompositionAppended.getShopCode());
        cartAppendedCompositionInfo.setCmdtyCode(cmdtyCompositionAppended.getDetailCmdtyCode());
        cartAppendedCompositionInfo.setIndividualCode(cmdtyCompositionAppended.getDetailIndividualCode());
        if (cartAppendedCompositionInfo.reset(lConnection, lMode, lBranch)){
          // 明細区分設定
          cartAppendedCompositionInfo.setSetDetailFlg(SIConfig.SET_DETAIL_FLG_APPENDED);
          // 明細番号設定
          cartAppendedCompositionInfo.setSetDetailCode(String.valueOf(setDetailCount));
          // 構成数
          cartAppendedCompositionInfo.setSetCompositionCount(cmdtyCompositionAppended.getAppendedCount());
          // セット数(xセット毎の値)
          cartAppendedCompositionInfo.setSetCount(cmdtyCompositionAppended.getSetCount());
          // 添付品については、固定で単価0円とする
          cartAppendedCompositionInfo.setUnitPrice("0");
          cartAppendedCompositionInfo.setSalesUnitPrice("0");
          cartAppendedCompositionInfo.setCalcUnitPrice("0");
          cartAppendedCompositionInfo.setDiscountRate("0");
          cartAppendedCompositionInfo.setConsignGoodsFee("0");
          // 明細番号カウントアップ
          setDetailCount++;
          // セット
          composition.add(cartAppendedCompositionInfo);
        }
      }
    }
    
    // 構成情報をMapへ保存
    cmdtyCompositionMap.put(lCartCmdty.getCmdtyCompositionKeySet(), composition);
    // カート構成品情報を設定
    lCartCmdty.setCartsCmdtyCompositionDetailMap(cmdtyCompositionMap);
    
    return lCartCmdty;
  }
  
  /**
   * <b>getSetCartAmountInfo</b>
   * 現在カートのセット構成品・オプション・添付品の合計数量情報を取得します。
   * @param HttpSession
   * @param Connection
   * @return LinkedHashMap
   * @throws なし
   */
  protected LinkedHashMap getSetCartAmountInfo(HttpSession session, Connection lConnection) {
    // 返却変数
    LinkedHashMap amountCmdtyMap = new LinkedHashMap();
    // 現在カートの取得
    SICartManager tempAmountCartMan=(SICartManager)session.getAttribute(SIConfig.SISESSION_CART_INFO_NAME);
    if (tempAmountCartMan == null)tempAmountCartMan = new SICartManager();
    Iterator lTempShopIta = tempAmountCartMan.getShopCollection(lConnection).iterator();
    // セット品チェックカウント
    while (lTempShopIta.hasNext()){
      SIMallShop lMallShop = (SIMallShop)lTempShopIta.next();
      Iterator lTempCartIta=tempAmountCartMan.getCartCollection(lMallShop.getMallShopCode()).iterator();
      while (lTempCartIta.hasNext()){
        SICart templCart = (SICart)lTempCartIta.next();
        if (templCart.getCmdty().isCmdtyComposition()) {
          // 構成品・オプション・添付品の在庫数を算出
          LinkedHashMap compositionMap = (LinkedHashMap)templCart.getCmdty().getCartsCmdtyCompositionDetailMap();
          Iterator ite = compositionMap.values().iterator();
          while (ite.hasNext()) {
            // 構成品・オプション・添付品の在庫数を算出
            Collection cmdtyCompositionColl = (Collection)ite.next();
            Iterator ite2 = cmdtyCompositionColl.iterator();
            while (ite2.hasNext()) {
              SICartCmdty cmdtyComposition = (SICartCmdty)ite2.next();
              if (!amountCmdtyMap.containsKey(cmdtyComposition.getIndividualCode())) {
                if (cmdtyComposition.getSetDetailFlg().equals(SIConfig.SET_DETAIL_FLG_APPENDED)) {
                  // 添付商品数の計算
                  String setCount = cmdtyComposition.getSetCount();
                  BigDecimal a = new BigDecimal(templCart.getAmount());
                  BigDecimal b = new BigDecimal(setCount);
                  BigDecimal calc = a.divide(b, BigDecimal.ROUND_DOWN);
                  if (calc.compareTo(new BigDecimal(0)) > 0) {
                    // 在庫数加算未処理の場合
                    // 在庫保持Mapに入れる
                    String totalAmount = SIUtil.multi_LL(cmdtyComposition.getSetCompositionCount(), calc.toString());
                    amountCmdtyMap.put(cmdtyComposition.getIndividualCode(), totalAmount);
                  }
                } else {
                  // 在庫数加算未処理の場合
                  String totalAmount = SIUtil.multi_LL(templCart.getAmount(), cmdtyComposition.getSetCompositionCount());
                  // 在庫保持Mapに入れる
                  amountCmdtyMap.put(cmdtyComposition.getIndividualCode(), totalAmount);
                }
              } else {
                String amount = (String)amountCmdtyMap.get(cmdtyComposition.getIndividualCode());
                if (cmdtyComposition.getSetDetailFlg().equals(SIConfig.SET_DETAIL_FLG_APPENDED)) {
                  // 添付商品数の計算
                  String setCount = cmdtyComposition.getSetCount();
                  BigDecimal a = new BigDecimal(templCart.getAmount());
                  BigDecimal b = new BigDecimal(setCount);
                  BigDecimal calc = a.divide(b, BigDecimal.ROUND_DOWN);
                  if (calc.compareTo(new BigDecimal(0)) > 0) {
                    // 在庫数加算未処理の場合
                    // 在庫保持Mapに入れる
                    String totalAmount = SIUtil.add_LL(amount, SIUtil.multi_LL(cmdtyComposition.getSetCompositionCount(), calc.toString()));
                    amountCmdtyMap.put(cmdtyComposition.getIndividualCode(), totalAmount);
                  }
                } else {
                  String totalAmount = SIUtil.add_LL(amount, SIUtil.multi_LL(templCart.getAmount(), cmdtyComposition.getSetCompositionCount()));
                  // 在庫保持Mapに入れる
                  amountCmdtyMap.put(cmdtyComposition.getIndividualCode(), totalAmount);
                }
              }
            }
          }
        }
      }
    }
    return amountCmdtyMap;
  }
  //EDBTG003-00 elecs-matsushima add start
  /**
   * <b>getSetCartAmountInfo</b>
   * 現在カートのセット構成品・オプション・添付品の合計数量情報を取得します。
   * @param HttpSession
   * @param Connection
   * @return LinkedHashMap
   * @throws なし
   */
  public LinkedHashMap getSetCartAmountInfoPos(HttpSession session, Connection lConnection) {
    // 返却変数
    LinkedHashMap amountCmdtyMap = new LinkedHashMap();
    
    LinkedHashMap detailMap = (LinkedHashMap) session.getAttribute(SIConfig.SISESSION_CART_DETAIL_NAME);
    
    for(Iterator detailMapIte = detailMap.keySet().iterator(); detailMapIte.hasNext();) {
      SIOrderDetail orderDetail = (SIOrderDetail) detailMap.get(detailMapIte.next());
      
      if (!amountCmdtyMap.containsKey(orderDetail.getIndividualCode())) {
        amountCmdtyMap.put(orderDetail.getIndividualCode(), orderDetail.getAmount());
      } else {
        String totalAmount = (String) amountCmdtyMap.get(orderDetail.getIndividualCode());
        if (SIUtil.isNull(totalAmount)) totalAmount = "0";
        totalAmount = SIUtil.add_LL(totalAmount, orderDetail.getAmount());
        amountCmdtyMap.put(orderDetail.getIndividualCode(), totalAmount);
      }
    }
    
    return amountCmdtyMap;
  }
  //EDBTG003-00 elecs-matsushima add end
  
  // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi mod start
//  protected boolean checkAddSetAmount(SICartCmdty lCartCmdty, LinkedHashMap lAmountCmdtyMap, int lAmountValue, boolean posFlg) {
//    return checkAddSetAmount(lCartCmdty, lAmountCmdtyMap, lAmountValue, posFlg, false);
  protected boolean checkAddSetAmount(SICartCmdty lCartCmdty, LinkedHashMap lAmountCmdtyMap, int lAmountValue, boolean posFlg, int lCartAmount) {
    return checkAddSetAmount(lCartCmdty, lAmountCmdtyMap, lAmountValue, posFlg, false, lCartAmount);
  // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi mod end
  }
  /**
   * <b>checkAddSetAmount</b>
   * セット品カート投入時の在庫チェックをおこないます
   * @param HttpServletRequest
   * @param SICart
   * @param LinkedHashMap
   * @param String
   * @return boolean
   * @throws なし
   */
  // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi mod start
//  protected boolean checkAddSetAmount(SICartCmdty lCartCmdty, LinkedHashMap lAmountCmdtyMap, int lAmountValue, boolean posFlg, boolean backmode) {
  protected boolean checkAddSetAmount(SICartCmdty lCartCmdty, LinkedHashMap lAmountCmdtyMap, int lAmountValue, boolean posFlg, boolean backmode, int lCartAmount) {
  // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi mod end
    // 返却変数
    boolean errors = true;
    // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi add start
    Map tempMap = new HashMap();
    // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi add end
    // 構成商品・オプション・添付品の在庫チェック
    LinkedHashMap compositionMap = (LinkedHashMap)lCartCmdty.getCartsCmdtyCompositionDetailMap();
    Iterator ite = compositionMap.values().iterator();
    while (ite.hasNext()) {
      // 構成品・オプション・添付品の在庫数を算出
      Collection cmdtyColl = (Collection)ite.next();
      Iterator cmdtyIte = cmdtyColl.iterator();
      while (cmdtyIte.hasNext()) {
        SICartCmdty cmdty = (SICartCmdty)cmdtyIte.next();
        String cartAmount = "0";
        if (lAmountCmdtyMap.containsKey(cmdty.getIndividualCode())) {
          cartAmount = (String)lAmountCmdtyMap.get(cmdty.getIndividualCode());
        }
        //String amount = SIUtil.multi_LL(String.valueOf(lAmountValue), cmdty.getSetCompositionCount());
        String amount = "0";
        if (backmode){ // 管理モードは実数値を設定
          amount = cmdty.getSetCompositionCount();
          // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi add start
          amount = String.valueOf(Integer.parseInt(cartAmount) + Integer.parseInt(amount));
          // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi add end
        } else {
          // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi add start
          if (cmdty.getSetDetailFlg().equals(SIConfig.SET_DETAIL_FLG_APPENDED)) {
            // 添付商品数の計算
            String setCount = cmdty.getSetCount(); // 添付のセット数(セット毎設定値)
            BigDecimal a = new BigDecimal(lAmountValue + lCartAmount);
            BigDecimal b = new BigDecimal(setCount);
            BigDecimal calc = a.divide(b, BigDecimal.ROUND_DOWN);
            if (calc.compareTo(new BigDecimal(0)) > 0) {
              amount = cmdty.getSetCompositionCount();
              if (tempMap.containsKey(cmdty.getIndividualCode())) {
                amount = String.valueOf(Integer.parseInt(amount) + Integer.parseInt((String)tempMap.get(cmdty.getIndividualCode())));
              }
            } else {
              continue;
            }
          } else {
            // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi add end
            amount = SIUtil.multi_LL(String.valueOf(lAmountValue), cmdty.getSetCompositionCount());
            // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi add start
            amount = String.valueOf(Integer.parseInt(cartAmount) + Integer.parseInt(amount));
          }
          // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi add end
          if (tempMap.containsKey(cmdty.getIndividualCode())) {
            String tmpamount = (String)tempMap.get(cmdty.getIndividualCode());
            tempMap.put(cmdty.getIndividualCode(), String.valueOf((Integer.parseInt(amount) + Integer.parseInt(tmpamount))));
          } else {
            tempMap.put(cmdty.getIndividualCode(), amount);
          }
        }
        // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi mod start
        /*
        if (posFlg) {
          // 在庫チェックを実施
          if ("1".equalsIgnoreCase(cmdty.getAmountFlg())&&//在庫管理する
              (Integer.parseInt(cartAmount) + Integer.parseInt(amount)) > Integer.parseInt(cmdty.getAmount())) {
              log.warn("addCart:在庫超...ShopCode="+cmdty.getShopCode() +",CmdtyCode="+cmdty.getCmdtyCode() +",Amount="+cmdty.getAmount());
              errors = false;
          }
        } else {
          // 在庫チェックを実施
          if ("1".equalsIgnoreCase(cmdty.getAmountFlg())&&//在庫管理する
              "0".equalsIgnoreCase(cmdty.getNoStockFlg())&&//在庫なし販売しない
              (Integer.parseInt(cartAmount) + Integer.parseInt(amount)) > Integer.parseInt(cmdty.getAmount())) {
              log.warn("addCart:在庫超...ShopCode="+cmdty.getShopCode() +",CmdtyCode="+cmdty.getCmdtyCode() +",Amount="+cmdty.getAmount());
              errors = false;
          }
        }
        */
        if (posFlg) {
          // 在庫チェックを実施
          if ("1".equalsIgnoreCase(cmdty.getAmountFlg())&&//在庫管理する
              Integer.parseInt(amount) > Integer.parseInt(cmdty.getAmount())) {
              log.warn("addCart:在庫超...ShopCode="+cmdty.getShopCode() +",CmdtyCode="+cmdty.getCmdtyCode() +",Amount="+cmdty.getAmount());
              errors = false;
          }
        } else {
          // 在庫チェックを実施
          if ("1".equalsIgnoreCase(cmdty.getAmountFlg())&&//在庫管理する
              "0".equalsIgnoreCase(cmdty.getNoStockFlg())&&//在庫なし販売しない
              Integer.parseInt(amount) > Integer.parseInt(cmdty.getAmount())) {
              log.warn("addCart:在庫超...ShopCode="+cmdty.getShopCode() +",CmdtyCode="+cmdty.getCmdtyCode() +",Amount="+cmdty.getAmount());
              errors = false;
          }
        }
        // EDBTG003-00 [不具合管理票-No25] 2013/03/14 nagayoshi mod end
      }
    }
    return errors;
  }
  
  /**
   * <b>checkModSetAmount</b>
   * カート数量変更時の在庫チェックをおこないます
   * @param HttpServletRequest
   * @param SICart
   * @param LinkedHashMap
   * @param String
   * @return boolean
   * @throws なし
   */
  protected SICustomErrors checkModSetAmount(Connection lConnection, SICartManager cartMan, String[] lShopCmdtyCode, LinkedHashMap lAmountCmdtyMap, String lAmountValue) {
    // 返却変数
    SICustomErrors errors = new SICustomErrors();
    // 現在カートの取得
    Iterator shopIta = cartMan.getShopCollection(lConnection).iterator();
    Iterator cartIta;
    String totalAmount = "0";
    while (shopIta.hasNext()){
      SIMallShop lMallShop = (SIMallShop)shopIta.next();
      cartIta=cartMan.getCartCollection(lMallShop.getMallShopCode()).iterator();
      while (cartIta.hasNext()){
        SICart cart = (SICart)cartIta.next();
        if (cart.getCartCmdty().isCmdtyComposition()) {
          // 削除対象のセット品または、数量変更のセット品を取得します
          if (lShopCmdtyCode[7].equals(cart.getCartCmdty().getSetCode())) {
            LinkedHashMap compositionMap = (LinkedHashMap)cart.getCartCmdty().getCartsCmdtyCompositionDetailMap();
            Iterator ite = compositionMap.values().iterator();
            while (ite.hasNext()) {
              // 構成品・オプション・添付品の在庫数を算出
              Collection cmdtyCompositionColl = (Collection)ite.next();
              Iterator ite2 = cmdtyCompositionColl.iterator();
              while (ite2.hasNext()) {
                SICartCmdty cmdtyComposition = (SICartCmdty)ite2.next();
                if (!lAmountCmdtyMap.containsKey(cmdtyComposition.getIndividualCode())) {
                  if (cmdtyComposition.getSetDetailFlg().equals(SIConfig.SET_DETAIL_FLG_APPENDED)) {
                    // 添付商品数の計算
                    String setCount = cmdtyComposition.getSetCount();
                    BigDecimal a = new BigDecimal(lAmountValue);
                    BigDecimal b = new BigDecimal(setCount);
                    BigDecimal calc = a.divide(b, BigDecimal.ROUND_DOWN);
                    if (calc.compareTo(new BigDecimal(0)) > 0) {
                      // 在庫数加算未処理の場合
                      // 在庫保持Mapに入れる
                      totalAmount = SIUtil.multi_LL(cmdtyComposition.getSetCompositionCount(), calc.toString());
                      lAmountCmdtyMap.put(cmdtyComposition.getIndividualCode(), totalAmount);
                    }
                  } else {
                    // 在庫数加算未処理の場合
                    totalAmount = SIUtil.multi_LL(lAmountValue, cmdtyComposition.getSetCompositionCount());
                    // 在庫保持Mapに入れる
                    lAmountCmdtyMap.put(cmdtyComposition.getIndividualCode(), totalAmount);
                  }
                } else {
                  String amount = (String)lAmountCmdtyMap.get(cmdtyComposition.getIndividualCode());
                  if (cmdtyComposition.getSetDetailFlg().equals(SIConfig.SET_DETAIL_FLG_APPENDED)) {
                    // 添付商品数の計算
                    String setCount = cmdtyComposition.getSetCount();
                    BigDecimal a = new BigDecimal(lAmountValue);
                    BigDecimal b = new BigDecimal(setCount);
                    BigDecimal calc = a.divide(b, BigDecimal.ROUND_DOWN);
                    if (calc.compareTo(new BigDecimal(0)) > 0) {
                      // 在庫数加算未処理の場合
                      // 在庫保持Mapに入れる
                      totalAmount = SIUtil.add_LL(amount, SIUtil.multi_LL(cmdtyComposition.getSetCompositionCount(), calc.toString()));
                      lAmountCmdtyMap.put(cmdtyComposition.getIndividualCode(), totalAmount);
                    }
                  } else {
                    totalAmount = SIUtil.add_LL(amount, SIUtil.multi_LL(lAmountValue, cmdtyComposition.getSetCompositionCount()));
                    // 在庫保持Mapに入れる
                    lAmountCmdtyMap.put(cmdtyComposition.getIndividualCode(), totalAmount);
                  }
                }
                // 在庫チェックの実施
                if (cmdtyComposition.getAmountFlg().equals("1") && cmdtyComposition.isExceedAmount(totalAmount)) {
                  if (Integer.parseInt(cmdtyComposition.getAmount()) <= 0) {
                    errors.addError(new SICustomError("manager.app.exceed.amount.no.reserve",cmdtyComposition.getCartCmdtyName()));
                  } else {
                    errors.addError(new SICustomError("manager.app.exceed.amount.with.cancel",cmdtyComposition.getCartCmdtyName()));
                  }
                }
              }
            }
            if (errors.isEmpty()) {
              // 在庫エラーがない場合、セット品の数量変更をおこなう
              cartMan.update(cart.getCartCmdty(),lAmountValue);
            }
            break;
          }
        }
      }
    }
    return errors;
  }
  
  /**
  *
  * @param lRequest
  * @param lConnection
  * @return boolean
  */
 public boolean validateSelectionSet(HttpServletRequest lRequest, SIURLParameter lUrlParam){
   SICustomErrors errors = new SICustomErrors();
   // よりどり点数チェック
   // よりどり点数の取得
   String sectionCount = (String)lUrlParam.getParam("sectionCount");
   if (!sectionCount.equals(this.getTotalCompositionGroupDetailAmount())) {
     errors.addError(new SICustomError("input.data.sectioncount",sectionCount));
   }
   if (!errors.isEmpty()) {
     lRequest.setAttribute(SIConfig.SIERROR_ATTRIBUTE_MESSAGE_KEY,errors);
   } else {
     lRequest.removeAttribute(SIConfig.SIERROR_ATTRIBUTE_MESSAGE_KEY);
   }
   return errors.isEmpty();
 }
 // EDBTG003-00 nagayoshi add end
 //EDBTG003-00 elecs-matsushima add start
  public String getAddCartCmdtySetCode() {
    return this.addCartCmdtySetCode;
  }
  
  public void setAddCartCmdtySetCode(String addCartCmdtySetCode) {
    if (SIUtil.isNull(addCartCmdtySetCode)) addCartCmdtySetCode = "";
    this.addCartCmdtySetCode = addCartCmdtySetCode;
  }
  //EDBTG003-00 elecs-matsushima add end
}