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

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.LinkedHashMap;

import jp.co.sint.beans.mallmgr.UIOrderBasic;
import jp.co.sint.config.SIConfig;
import jp.co.sint.config.SIFlagConf;
import jp.co.sint.database.SIDBAccessException;
import jp.co.sint.database.SIDBUtil;
import jp.co.sint.tools.SIFatalException;
import jp.co.sint.tools.SIFlagUtil;
import jp.co.sint.tools.SIUtil;

import org.apache.log4j.Category;

/**
 * @version $Id: SIOrderDetail.java,v 1.0 2003/11/06 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/11/06 17:49:26  Original
 */
public class SIOrderDetail extends UIOrderBasic{
  //ログ用のインスタンスの生成
  private static Category log=Category.getInstance(SIConfig.SILOG4J_WEBSHOP_CATEGORY_NAME);
  
  //受注番号
  private String orderCode="";
  
  //受注配送先項番
  private String deliveryCode="";
  
  //受注明細項番
  private String detailCode="";
  
  //ショップコード
  private String shopCode="";
  
  //ショップ名
  private String shopName="";
  
  //商品コード
  private String cmdtyCode="";
  
  //在庫コード
  private String individualCode="";
  
  //商品名
  private String cmdtyName="";
  
  //規格1
  private String stndrdCode1="";
  
  //エレメント1
  private String elementCode1="";
  
  //規格2
  private String stndrdCode2="";
  
  //エレメント2
  private String elementCode2="";
  
  //規格名1
  private String stndrdName1="";
  
  //エレメント名1
  private String elementName1="";
  
  //規格名2
  private String stndrdName2="";
  
  //エレメント名2
  private String elementName2="";
  
  //数量
  private String amount="0";
  
  //本体値段
  private String orgPrice="0";
  
  //購入値段
  private String price="0";
  
  //購入価格
  private String priceIncTax="0";
  
  //本体価格税区分
  private String taxFlg="1";
  
  //税率
  private String taxRate="0";
  
  //サイズ
  private String cmdtySize="";
  
  //ラッピングコード
  private String wrappingCode="";
  
  //ラッピング名
  private String wrappingName="";
  
  //ラッピング税区分
  private String wrappingTaxFlg="0";
  
  //ラッピング価格
  private String wrappingPrice="0";
  
  //ラッピングフラグ
  private String wrappingFlg="0";
  
  //会員値引きフラグ
  private String memberDiscountFlg="0";
  
  //総合計金額(数量×)
  private String priceIncGift = "0";
  
  //配送種別コード
  private String deliveryTypeCode="";
  
  //配送種別名称
  private String deliveryTypeName="";
  
  //ショップギフトフラグ
  private String shopGiftFlg="0";
  
  //送料
  private String deliveryFee = "0";
  
  //税込み送料
  private String deliveryFeeIncTax = "0";
  
  //個別送料
  private String deliveryIndivFee = "0";
  
  //配送希望日
  private String deliveryDate="";
  
  //出荷日
  private String shippmentDate="";
  
  //到着予定日
  private String arrivalDate="";
  
  //合計金額
  private String totalPrice ="0";
  
  //仕入価格
  private String purchasePrice="0";
  
  //加工費
  private String processingExpance="0";
  
  //担当支店
  private String branchCode = "";
  
  //担当者
  private String chargeCode = "";
  
  //保証期限（商品）
  private String guaranteedTerm = "";
  
  //備考（商品）
  private String remarks = "";
  
  //委託手数料
  private String consignGoodsFee = "0";
  
  //カラー
  private String colorName = "";
  
  //中古新品区分
  private int usedNewFlg = 0;
  
  private boolean isFrontDisp = true; 
  
  //配送希望時間帯
  private String deliveryTime = "";
  
  // EDBTG003-00 elecs-tani add start
  // 明細区分
  private String setDetailFlg = "";
  
  // セット番号
  private String setCode = "";
  
  // セット商品コード
  private String setCmdtyCode = "";
  
  // セット在庫コード
  private String setIndividualCode = "";
  
  // セット明細番号
  private String setDetailCode = "";
  
  // セット値引き
  private String setDiscount = "";
  
  // セット数量
  private String setAmount = "";
  
  // セット区分
  private String cmdtyCompositionFlg = SIConfig.CMDTY_COMPOSITION_NORMAL;
  
  // EDBTG003-00 elecs-tani add end
  // EDBTG003-00 elecs-matsushima add start
  private String orderBranchCode = "";
  
  // DBの受注明細項番
  private String orderDetailCode = "";
  
  // DBのセットコード
  private String oldSetCode = "";
  
  // 引当先変更情報
  private LinkedHashMap allocationMap = new LinkedHashMap();
  // EDBTG003-00 elecs-matsushima add end
  
  public SIOrderDetail(){
  }
  
  public SIOrderDetail(String lOrderCode,String lDeliveryCode,String lDetailCode){
    this.setOrderCode(lOrderCode);
    this.setDeliveryCode(lDeliveryCode);
    this.setDetailCode(lDetailCode);
  }
  
  //setter of 受注番号
  public void setOrderCode(String lOrderCode){
    if (SIUtil.isNull(lOrderCode)) lOrderCode="";
    this.orderCode=SIUtil.changeTo(lOrderCode.trim(),this.encode);
  }
  
  //setter of 受注配送先項番
  public void setDeliveryCode(String lDeliveryCode){
    if (SIUtil.isNull(lDeliveryCode)) lDeliveryCode="";
    this.deliveryCode=SIUtil.changeTo(lDeliveryCode.trim(),this.encode);
  }
  
  //setter of 受注明細項番
  public void setDetailCode(String lDetailCode){
    if (SIUtil.isNull(lDetailCode)) lDetailCode="";
    this.detailCode=SIUtil.changeTo(lDetailCode.trim(),this.encode);
  }
  
  //setter of ショップコード
  public void setShopCode(String lShopCode){
    if (SIUtil.isNull(lShopCode)) lShopCode="";
    this.shopCode=SIUtil.changeTo(lShopCode.trim(),this.encode);
  }
  
  //setter of ショップ名
  public void setShopName(String lShopName){
    if (SIUtil.isNull(lShopName)) lShopName="";
    this.shopName=SIUtil.changeTo(lShopName.trim(),this.encode);
  }
  
  //setter of 商品コード
  public void setCmdtyCode(String lCmdtyCode){
    if (SIUtil.isNull(lCmdtyCode)) lCmdtyCode="";
    this.cmdtyCode=SIUtil.changeTo(lCmdtyCode.trim(),this.encode);
  }
  
  //setter of 商品名(必須)
  public void setCmdtyName(String lCmdtyName){
    if (SIUtil.isNull(lCmdtyName)) lCmdtyName="";
    this.cmdtyName=SIUtil.changeTo(lCmdtyName.trim(),this.encode);
  }
  
  //setter of 規格1
  public void setStndrdCode1(String lStndrdCode1){
    if (SIUtil.isNull(lStndrdCode1)) lStndrdCode1="";
    this.stndrdCode1=SIUtil.changeTo(lStndrdCode1.trim(),this.encode);
  }
  
  //setter of エレメント1
  public void setElementCode1(String lElementCode1){
    if (SIUtil.isNull(lElementCode1)) lElementCode1="";
    this.elementCode1=SIUtil.changeTo(lElementCode1.trim(),this.encode);
  }
  
  //setter of 規格2
  public void setStndrdCode2(String lStndrdCode2){
    if (SIUtil.isNull(lStndrdCode2)) lStndrdCode2="";
    this.stndrdCode2=SIUtil.changeTo(lStndrdCode2.trim(),this.encode);
  }
  
  //setter of エレメント2
  public void setElementCode2(String lElementCode2){
    if (SIUtil.isNull(lElementCode2)) lElementCode2="";
    this.elementCode2=SIUtil.changeTo(lElementCode2.trim(),this.encode);
  }
  
  //setter of 規格名1
  public void setStndrdName1(String lStndrdName1){
    if (SIUtil.isNull(lStndrdName1)) lStndrdName1="";
    this.stndrdName1=SIUtil.changeTo(lStndrdName1.trim(),this.encode);
  }
  
  //setter of エレメント名1
  public void setElementName1(String lElementName1){
    if (SIUtil.isNull(lElementName1)) lElementName1="";
    this.elementName1=SIUtil.changeTo(lElementName1.trim(),this.encode);
  }
  
  //setter of 規格名2
  public void setStndrdName2(String lStndrdName2){
    if (SIUtil.isNull(lStndrdName2)) lStndrdName2="";
    this.stndrdName2=SIUtil.changeTo(lStndrdName2.trim(),this.encode);
  }
  
  //setter of エレメント名2
  public void setElementName2(String lElementName2){
    if (SIUtil.isNull(lElementName2)) lElementName2="";
    this.elementName2=SIUtil.changeTo(lElementName2.trim(),this.encode);
  }
  
  //setter of 数量(必須)
  public void setAmount(String lAmount){
    if (SIUtil.isNull(lAmount)) lAmount="0";
    this.amount=SIUtil.changeTo(lAmount.trim(),this.encode);
  }
  
  //setter of 個別送料
  public void setDeliveryIndivFee(String lDeliveryIndivFee){
    if (SIUtil.isNull(lDeliveryIndivFee)) lDeliveryIndivFee="0";
    this.deliveryIndivFee=SIUtil.changeTo(lDeliveryIndivFee.trim(),this.encode);
  }
  
  //setter of 本体値段
  public void setOrgPrice(String lOrgPrice){
    if (SIUtil.isNull(lOrgPrice)) lOrgPrice="0";
    this.orgPrice=SIUtil.changeTo(lOrgPrice.trim(),this.encode);
  }
  
  //setter of 購入値段
  public void setPrice(String lPrice){
    if (SIUtil.isNull(lPrice)) lPrice="0";
    this.price=SIUtil.changeTo(lPrice.trim(),this.encode);
  }
  
  //setter of 購入価格
  public void setPriceIncTax(String lPriceIncTax){
    if (SIUtil.isNull(lPriceIncTax)) lPriceIncTax="0";
    this.priceIncTax=SIUtil.changeTo(lPriceIncTax.trim(),this.encode);
  }
  
  //setter of 本体価格税区分
  public void setTaxFlg(String lTaxFlg){
    if (SIUtil.isNull(lTaxFlg)) lTaxFlg="1";
    this.taxFlg=SIUtil.changeTo(lTaxFlg.trim(),this.encode);
  }
  
  //setter of 税率
  public void setTaxRate(String lTaxRate){
    if (SIUtil.isNull(lTaxRate)) lTaxRate="0";
    this.taxRate=SIUtil.changeTo(lTaxRate.trim(),this.encode);
  }
  
  public void setCmdtySize(String lCmdtySize){
    if (SIUtil.isNull(lCmdtySize)) lCmdtySize="";
    this.cmdtySize=SIUtil.changeTo(lCmdtySize.trim(),this.encode);
  }
  
  public void setWrappingCode(String lWrappingCode){
    if (SIUtil.isNull(lWrappingCode)) lWrappingCode="";
    this.wrappingCode=SIUtil.changeTo(lWrappingCode.trim(),this.encode);
  }
  
  public void setWrappingTaxFlg(String lWrappingTaxFlg){
    if (SIUtil.isNull(lWrappingTaxFlg)) lWrappingTaxFlg="0";
    this.wrappingTaxFlg=SIUtil.changeTo(lWrappingTaxFlg.trim(),this.encode);
  }
  
  public void setWrappingName(String lWrappingName){
    if (SIUtil.isNull(lWrappingName)) lWrappingName="";
    this.wrappingName=SIUtil.changeTo(lWrappingName.trim(),this.encode);
  }
  
  public void setWrappingPrice(String lWrappingPrice){
    if (SIUtil.isNull(lWrappingPrice)) lWrappingPrice="0";
    this.wrappingPrice=SIUtil.changeTo(lWrappingPrice.trim(),this.encode);
  }
  
  public void setWrappingFlg(String lWrappingFlg){
    if (SIUtil.isNull(lWrappingFlg)) lWrappingFlg="0";
    this.wrappingFlg=SIUtil.changeTo(lWrappingFlg.trim(),this.encode);
  }
  
  //setter of 会員値引きフラグ
  public void setMemberDiscountFlg(String lMemberDiscountFlg){
    if (SIUtil.isNull(lMemberDiscountFlg)) lMemberDiscountFlg="0";
    this.memberDiscountFlg=SIUtil.changeTo(lMemberDiscountFlg.trim(),this.encode);
  }
  
  //setter of 個別送料
  public void setDeliveryFeeSingle(String lMemberDiscountFlg){
    if (SIUtil.isNull(lMemberDiscountFlg)) lMemberDiscountFlg="0";
    this.deliveryFee=SIUtil.changeTo(lMemberDiscountFlg.trim(),this.encode);
  }
  
  //setter of 配送種別コード
  public void setDeliveryTypeCode(String lDeliveryTypeCode){
    if (SIUtil.isNull(lDeliveryTypeCode)) lDeliveryTypeCode="";
    this.deliveryTypeCode=SIUtil.changeTo(lDeliveryTypeCode.trim(),this.encode);
  }
  
  //setter of 配送種別名称
  public void setDeliveryTypeName(String lDeliveryTypeName){
    if (SIUtil.isNull(lDeliveryTypeName))lDeliveryTypeName="";
    this.deliveryTypeName =lDeliveryTypeName;
  }
  
  public void setShopGiftFlg(String lShopGiftFlg){
    if (SIUtil.isNull(lShopGiftFlg)) lShopGiftFlg="0";
    this.shopGiftFlg=SIUtil.changeTo(lShopGiftFlg.trim(),this.encode);
  }
  
  //getter of 受注番号
  public String getOrderCode(){
    return this.orderCode;
  }
  
  //getter of 受注配送先項番
  public String getDeliveryCode(){
    return this.deliveryCode;
  }
  
  //getter of 受注明細項番
  public String getDetailCode(){
    return this.detailCode;
  }
  
  //getter of ショップコード
  public String getShopCode(){
    return this.shopCode;
  }
  
  //getter of ショップ名
  public String getShopName(){
    return this.shopName;
  }
  
  //getter of 商品コード
  public String getCmdtyCode(){
    return this.cmdtyCode;
  }
  
  //getter of 在庫コード
  public String getIndividualCode() {
    return individualCode;
  }
  
  //setter of 在庫コード
  public void setIndividualCode(String individualCode) {
    this.individualCode = individualCode;
  }
  
  public String getCompCode(){
    String lRes=getShopCode()+SIConfig.SIWEBSHOPPING_TOKEN+
           getCmdtyCode()+SIConfig.SIWEBSHOPPING_TOKEN+
           getIndividualCode()+SIConfig.SIWEBSHOPPING_TOKEN+
           getStndrdCode1()+SIConfig.SIWEBSHOPPING_TOKEN+
           getElementCode1()+SIConfig.SIWEBSHOPPING_TOKEN+
           getStndrdCode2()+SIConfig.SIWEBSHOPPING_TOKEN+
    // EDBTG003-00 nagayoshi mod start
//           getElementCode2();
           getElementCode2() +SIConfig.SIWEBSHOPPING_TOKEN+
           getSetCode();
    // EDBTG003-00 nagayoshi mod end
    log.debug("getCompCode():lRes="+lRes);
    return lRes;
  }
  
  //getter of 商品名(必須)
  public String getCmdtyName(){
    return this.cmdtyName;
  }
  
  //getter of 商品名(カラー・区分)
  public String getCartCmdtyName(){
    String lColorName = getColorName();
    int lUsedNewFlg = getUsedNewFlg();
    String lUsedNewName = "";
    // EDBTG003-00 nagayoshi add start
    String lSetDetailName = "";
    String lSetDetailFlg = this.getSetDetailFlg();
    // EDBTG003-00 nagayoshi add end
    if (lUsedNewFlg == 1 || lUsedNewFlg == 6 || lUsedNewFlg == 7) {// 新品
      lUsedNewName = "新品";
    } else if (lUsedNewFlg == 2 || lUsedNewFlg == 4) {// 新古OUTLET
      lUsedNewName = "新古OUTLET";
    } else if (lUsedNewFlg == 3) {// BG認定中古
      lUsedNewName = "BG認定中古";
    } else {// 中古
      lUsedNewName = "中古";
    }
    
    // EDBTG003-00 nagayoshi add start
    if (lSetDetailFlg.equals(SIConfig.SET_DETAIL_FLG_APPENDED)) {
      if (SIUtil.isNotNull(lUsedNewName)) {
        lSetDetailName = "・";
      }
      lSetDetailName = lSetDetailName + "添付品";
    }
    // EDBTG003-00 nagayoshi add end
    
    String str = "";
    if (SIUtil.isNotNull(lColorName)) {
      // EDBTG003-00 nagayoshi mod start
//      str = "(" + lColorName + "・" + lUsedNewName + ")";
      str = "(" + lColorName + "・" + lUsedNewName + lSetDetailName + ")";
      // EDBTG003-00 nagayoshi mod end
    } else {
      // EDBTG003-00 nagayoshi mod start
//      str = "(" + lUsedNewName + ")";
      str = "(" + lUsedNewName + lSetDetailName + ")";
      // EDBTG003-00 nagayoshi mod end
    }
    
    return getCmdtyName() + str;
  }
  
  //getter of 規格1
  public String getStndrdCode1(){
    return this.stndrdCode1;
  }
  
  //getter of エレメント1
  public String getElementCode1(){
    return this.elementCode1;
  }
  
  //getter of 規格2
  public String getStndrdCode2(){
    return this.stndrdCode2;
  }
  
  //getter of エレメント2
  public String getElementCode2(){
    return this.elementCode2;
  }
  
  //getter of 規格名1
  public String getStndrdName1(){
    return this.stndrdName1;
  }
  
  //getter of エレメント名1
  public String getElementName1(){
    return this.elementName1;
  }
  
  //getter of 規格名2
  public String getStndrdName2(){
    return this.stndrdName2;
  }
  
  //getter of エレメント名2
  public String getElementName2(){
    return this.elementName2;
  }
  
  //getter of 数量(必須)
  public String getAmount(){
    return this.amount;
  }
  
  //getter of 数量(必須)
  public String getDeliveryIndivFee(){
    return this.deliveryIndivFee;
  }
  
  //getter of 本体値段
  public String getOrgPrice(){
    return this.orgPrice;
  }
  
  //getter of 購入値段
  public String getPrice(){
    return this.price;
  }
  
  //getter of 本体価格税区分
  public String getTaxFlg(){
    return this.taxFlg;
  }
  
  public String getTaxFlgName(){
    if (getTaxFlg().equals("0")) return "("+SIFlagConf.SIFLAG_TAX_0+")";
    else if (getTaxFlg().equals("1")) return "("+SIFlagConf.SIFLAG_TAX_1+")";
    else if (getTaxFlg().equals("2")) return "("+SIFlagConf.SIFLAG_TAX_2+")";
    else return "";
  }
  
  //商品の課税区分
  public String getCmdtyTaxName(){
    if (getTaxFlg().equals("0")) return SIFlagConf.SIFLAG_TAX_0;
    else if (getTaxFlg().equals("1")) return SIFlagConf.SIFLAG_TAX_1;
    else if (getTaxFlg().equals("2")) return SIFlagConf.SIFLAG_TAX_2;
    else return "";
  }
  
  //getter of 税率
  public String getTaxRate(){
    return this.taxRate;
  }
  
  //getter of ラッピング
  public String getWrappingCode(){
    return this.wrappingCode;
  }
  
  //getter of ラッピング
  public String getWrappingName(){
    return this.wrappingName;
  }
  
  public String getWrappingTaxFlg(){
    return this.wrappingTaxFlg;
  }
  
  public String getWrappingTaxName(){
    if (getWrappingTaxFlg().equals("0")) return SIFlagConf.SIFLAG_TAX_0;
    else if (getWrappingTaxFlg().equals("1")) return SIFlagConf.SIFLAG_TAX_1;
    else if (getWrappingTaxFlg().equals("2")) return SIFlagConf.SIFLAG_TAX_2;
    else return "";
  }
  
  //getter of ラッピング(税別)
  public String getWrappingPrice(){
    return this.wrappingPrice;
  }
  
  //getter of ラッピング(税込み)
  public String getWrappingPriceIncTax(){
    String lTax="0";
    try {
      if(getWrappingTaxFlg().equals("1")){ //課税の場合
        lTax=SIUtil.multi_LD(getWrappingPrice(),SIUtil.div_DL(getTaxRate(),"100"));
      }
    } catch (SIFatalException e) {
      e.printStackTrace();
    }
    return SIUtil.add_LL(getWrappingPrice(),lTax);
  }
  
  //getter of ラッピングフラグ
  public String getWrappingFlg(){
    return this.wrappingFlg;
  }
  
  //getter of 会員値引きフラグ
  public String getMemberDiscountFlg(){
    return this.memberDiscountFlg;
  }
  
  public boolean getWrappingFlgB(){
    return "1".equals(wrappingFlg);
  }
  
  //購入価格=値段(税込み)*数量
  public String getPriceIncTax(){
    return this.priceIncTax;
  }
  
  //getter of 配送種別コード
  public String getDeliveryTypeCode(){
    return this.deliveryTypeCode;
  }
  
  //getter of 配送種別名称
  public String getDeliveryTypeName(){
    return this.deliveryTypeName;
  }
  
  public String getCmdtySize(){
    return this.cmdtySize;
  }
  
  //商品合計額(数量(税込み)*単価)
  public String getPriceOfCmdty(){
    return SIUtil.multi_LL(this.getAmount(),this.getPriceIncTax());
  }
  
  //ラッピング合計額(数量*ラッピング価格(税込み))
  public String getWrappingPriceOfTotal(){
    return SIUtil.multi_LL(this.getAmount(),this.getWrappingPriceIncTax());
  }
  
  //総合計金額(商品合計額+ラッピング価格)
  public String getPriceIncGift(){
    return SIUtil.add_LL(this.getPriceOfCmdty(),this.getWrappingPriceOfTotal());
  }
  
  //getter of ショップギフトフラグ
  public String getShopGiftFlg(){
  return this.shopGiftFlg;
  }
  
  public boolean getShopGiftFlgB(){
    return "1".equals(shopGiftFlg);
  }
  
  //getter of 送料
  public String getDeliveryFee() {
    if (SIUtil.isNull(this.deliveryFee)) this.deliveryFee="0";
    if (SIUtil.isNull(this.amount)) this.amount="0";
    if("1".equals(this.deliveryTypeCode)){
      return this.deliveryFee;
    }else{
      return SIUtil.multi(this.deliveryFee,this.amount);
    }
  }
  
  //setter of 税込送料
  public void setDeliveryFeeIncTax(String lDeliveryFeeIncTax){
    if (SIUtil.isNull(lDeliveryFeeIncTax)) lDeliveryFeeIncTax="0";
    this.deliveryFeeIncTax=SIUtil.changeTo(lDeliveryFeeIncTax.trim(),this.encode);
  }
  
  //getter of 税込送料
  public String getDeliveryFeeIncTax(){
    return this.deliveryFeeIncTax;
  }
  
  //setter of 送料
  public void setDeliveryFee(String deliveryFee) {
    this.deliveryFee = deliveryFee;
  }
  
  //getter of 合計金額
  public String getTotalPrice() {
    return SIUtil.add_LL(SIUtil.multi(this.getPriceIncTax(),this.amount),this.getDeliveryFee());
  }
  
  //getter of 送料
  public String getDeliveryFeeSingle() {
    return this.deliveryFee;
  }
  
  //gettet of 支店コード
  public String getBranchCode() {
    return branchCode;
  }
  
  //setter of 支店コード
  public void setBranchCode(String branchCode) {
    this.branchCode = branchCode;
  }
  
  //getter of 担当者コード
  public String getChargeCode() {
    return chargeCode;
  }
  
  //setter of 担当者コード
  public void setChargeCode(String chargeCode) {
    this.chargeCode = chargeCode;
  }
  
  //getter of 到着予定日
  public String getArrivalDate() {
    return arrivalDate;
  }
  
  //setter of 到着予定日
  public void setArrivalDate(String arrivalDate) {
    this.arrivalDate = arrivalDate;
  }
  
  //getter of 配送希望日
  public String getDeliveryDate() {
    return deliveryDate;
  }
  
  //setter of 配送希望日
  public void setDeliveryDate(String deliveryDate) {
    if (SIUtil.isNull(deliveryDate))deliveryDate="";
    this.deliveryDate = deliveryDate;
  }
  
  //getter of 出荷日
  public String getShippmentDate() {
    return shippmentDate;
  }
  
  //setter of 出荷日
  public void setShippmentDate(String shippmentDate) {
    this.shippmentDate = shippmentDate;
  }
  
  public String getShippmentDateF(){
    if(SIUtil.isNull(shippmentDate)) return "";
    return shippmentDate.substring(0,4)+"/"+shippmentDate.substring(5,7)+"/"+shippmentDate.substring(8,10);
  }
  
  //配送希望日表示用
  public String getDeliveryDateTxt(){
    String res = "";
    if (SIUtil.isNull(this.deliveryDate)) res = "指定なし";
    else if ("2000-01-01".equals(this.deliveryDate)) res = "最短到着日";
    else res = this.deliveryDate;
    return res;
  }
  
  public String getDeliveryTimeTxt(){
    String res = "";
    if (SIUtil.isNotNull(this.deliveryTime)) res = SIFlagUtil.getFlagName(SIFlagConf.SIFLAG_DELIVERYTIME_FLG_INX,this.deliveryTime);
    return res;
  }
  
  /**
   * @return guaranteedTerm を戻します。
   */
  public String getGuaranteedTerm() {
      return guaranteedTerm;
  }
  
  /**
   * @param guaranteedTerm guaranteedTerm を設定。
   */
  public void setGuaranteedTerm(String guaranteedTerm) {
      this.guaranteedTerm = guaranteedTerm;
  }
  
  /**
   * @return remarks を戻します。
   */
  public String getRemarks() {
      return remarks;
  }
  
  /**
   * @param remarks remarks を設定。
   */
  public void setRemarks(String remarks) {
      this.remarks = remarks;
  }
  /**
   * <b>setShopCode</b>
   * 受注コードと配送先コードから該当ショップコードを取得します
   * @param lConnection
   * @param lOrderCode      受注コード
   * @param lDeliveryCode   配送先コード
   */
  public void setShopCode(Connection lConnection, String lOrderCode, String lDeliveryCode){
    StringBuffer lSqlBuf=new StringBuffer();
    
    lSqlBuf.append("SELECT DISTINCT shopCode FROM ").append(SIConfig.SIVIEW_ORDER_DETAIL_LATEST_NAME);
    lSqlBuf.append(" WHERE OrderCode=").append(SIDBUtil.SQL2Str(lOrderCode," "));
    lSqlBuf.append("   AND DeliveryCode=").append(SIDBUtil.SQL2Str(lDeliveryCode," "));
    
    log.debug("reset:lSqlBuf="+lSqlBuf.toString());
    
    try {
      this.setEncode(SIConfig.SIENCODE_NONE);
      this.setShopCode(SIDBUtil.getFirstData(lConnection, lSqlBuf.toString()));
    }catch(SIDBAccessException sqle){
      sqle.printStackTrace();
    }
  }
  
  //getter of 加工費
  public String getProcessingExpance() {
    return processingExpance;
  }
  
  //setter of 加工費
  public void setProcessingExpance(String processingExpance) {
    this.processingExpance = processingExpance;
  }
  
  //getter of 仕入価格
  public String getPurchasePrice() {
    return purchasePrice;
  }
  
  //setter of 仕入価格
  public void setPurchasePrice(String purchasePrice) {
    this.purchasePrice = purchasePrice;
  }
  
  public String getConsignGoodsFee() {
    return consignGoodsFee;
  }
  
  public String getColorName() {
    return colorName;
  }
  
  public int getUsedNewFlg() {
    return usedNewFlg;
  }
  
  public void setConsignGoodsFee(String consignGoodsFee) {
    if(SIUtil.isNull(consignGoodsFee)) consignGoodsFee="0";
    this.consignGoodsFee = consignGoodsFee;
  }
  
  public void setColorName(String colorName) {
    if (SIUtil.isNull(colorName)) colorName = "";
    this.colorName = colorName;
  }
  
  public void setUsedNewFlg(int usedNewFlg) {
    this.usedNewFlg = usedNewFlg;
  }
  
  public boolean isFrontDisp() {
    return isFrontDisp;
  }
  
  public void setFrontDisp(boolean isFrontDisp) {
    this.isFrontDisp = isFrontDisp;
  }
  
  public String getDeliveryTime() {
    return deliveryTime;
  }
  
  public void setDeliveryTime(String lDeliveryTime) {
    if (SIUtil.isNull(lDeliveryTime)) lDeliveryTime="";
    this.deliveryTime = lDeliveryTime;
  }
  
  // EDBTG003-00 elecs-tani add start
  /**
   * @return setDetailFlg
   */
  public String getSetDetailFlg() {
    return setDetailFlg;
  }
  
  /**
   * @param setDetailFlg セットする setDetailFlg
   */
  public void setSetDetailFlg(String setDetailFlg) {
    this.setDetailFlg = setDetailFlg;
  }
  
  /**
   * @return setCode
   */
  public String getSetCode() {
    return setCode;
  }
  
  /**
   * @param setCode セットする setCode
   */
  public void setSetCode(String setCode) {
    this.setCode = setCode;
  }
  
  /**
   * @return setCmdtyCode
   */
  public String getSetCmdtyCode() {
    return setCmdtyCode;
  }
  
  /**
   * @param setCmdtyCode セットする setCmdtyCode
   */
  public void setSetCmdtyCode(String setCmdtyCode) {
    this.setCmdtyCode = setCmdtyCode;
  }
  
  /**
   * @return setIndividualCode
   */
  public String getSetIndividualCode() {
    return setIndividualCode;
  }
  
  /**
   * @param setIndividualCode セットする setIndividualCode
   */
  public void setSetIndividualCode(String setIndividualCode) {
    this.setIndividualCode = setIndividualCode;
  }
  
  /**
   * @return setDetailCode
   */
  public String getSetDetailCode() {
    return setDetailCode;
  }
  
  /**
   * @param setDetailCode セットする setDetailCode
   */
  public void setSetDetailCode(String setDetailCode) {
    this.setDetailCode = setDetailCode;
  }
  
  /**
   * @return setDiscount
   */
  public String getSetDiscount() {
    return setDiscount;
  }
  
  /**
   * @param setDiscount セットする setDiscount
   */
  public void setSetDiscount(String setDiscount) {
    this.setDiscount = setDiscount;
  }
  
  /**
   * @return setAmount
   */
  public String getSetAmount() {
    return setAmount;
  }
  
  /**
   * @param setAmount セットする setAmount
   */
  public void setSetAmount(String setAmount) {
    this.setAmount = setAmount;
  }
  // EDBTG003-00 elecs-tani add end
  
  /**
   * <b>reset</b>
   * 修正モードの場合には、PKのデータを元に、明細データをデータベースから取り込んで
   * 画面に表示します。
   * @param lConnection データベースへのコネンクション
   * @return なし
   * @throws なし
   */
  public boolean reset(Connection lConnection){
    boolean lResult=false;
    if (SIUtil.isNull(this.getOrderCode())) return lResult;
    Statement lStatement=null;
    ResultSet lResultSet=null;
    StringBuffer lSqlBuf=new StringBuffer();
    lSqlBuf.append("SELECT * FROM OrderDetailVW ");
    lSqlBuf.append("WHERE OrderCode=").append(SIDBUtil.SQL2Str(this.getOrderCode()," "));
    lSqlBuf.append("AND DeliveryCode=").append(SIDBUtil.SQL2Str(this.getDeliveryCode()," "));
    lSqlBuf.append("AND DetailCode=").append(SIDBUtil.SQL2Str(this.getDetailCode()," "));
    if(SIUtil.isNotNull(this.getShopCode())) lSqlBuf.append("AND ShopCode=").append(SIDBUtil.SQL2Str(this.getShopCode()," "));
    if(SIUtil.isNotNull(this.getCmdtyCode())) lSqlBuf.append("AND CmdtyCode=").append(SIDBUtil.SQL2Str(this.getCmdtyCode()));
    
    log.debug("reset:lSqlBuf="+lSqlBuf.toString());
    try {
      lStatement=lConnection.createStatement();
      lResultSet=lStatement.executeQuery(lSqlBuf.toString());
      
      if (lResultSet.next()){
        this.setEncode(SIConfig.SIENCODE_NONE);
        lResult=true;
        this.setOrderCode(lResultSet.getString("orderCode"));//受注番号
        this.setDeliveryCode(lResultSet.getString("deliveryCode"));//受注配送先項番
        this.setDetailCode(lResultSet.getString("detailCode"));//受注明細項番
        this.setShopCode(lResultSet.getString("shopCode"));//ショップコード
        this.setShopName(lResultSet.getString("shopName"));//ショップ名
        this.setCmdtyCode(lResultSet.getString("cmdtyCode"));//商品コード
        this.setCmdtyName(lResultSet.getString("cmdtyName"));//商品名(必須)
        this.setStndrdCode1(lResultSet.getString("stndrdCode1"));//規格1
        this.setElementCode1(lResultSet.getString("elementCode1"));//エレメント1
        this.setStndrdCode2(lResultSet.getString("stndrdCode2"));//規格2
        this.setElementCode2(lResultSet.getString("elementCode2"));//エレメント2
        this.setStndrdName1(lResultSet.getString("stndrdName1"));//規格名1
        this.setElementName1(lResultSet.getString("elementName1"));//エレメント名1
        this.setStndrdName2(lResultSet.getString("stndrdName2"));//規格名2
        this.setElementName2(lResultSet.getString("elementName2"));//エレメント名2
        this.setAmount(lResultSet.getString("amount"));//数量(必須)
        this.setOrgPrice(lResultSet.getString("OrgPrice"));//本体価格
        this.setPrice(lResultSet.getString("price"));//購入価格
        this.setTaxFlg(lResultSet.getString("taxFlg"));//本体価格税区分
        this.setTaxRate(lResultSet.getString("taxRate"));//税率
        this.setCmdtySize(lResultSet.getString("cmdtySize"));//サイズ
        this.setPriceIncTax(lResultSet.getString("priceIncTax"));//購入価格
        this.setWrappingCode(lResultSet.getString("wrappingCode"));//ラッピングコード
        this.setWrappingName(lResultSet.getString("wrappingName"));//ラッピング名
        this.setWrappingTaxFlg(lResultSet.getString("wrappingTaxFlg"));//ラッピング税フラグ
        this.setWrappingPrice(lResultSet.getString("wrappingPrice"));//ラッピング価格
        this.setBranchCode(lResultSet.getString("branchcode"));
        this.setChargeCode(lResultSet.getString("chargeCode"));
        this.setDeliveryFee(lResultSet.getString("deliveryFee"));
        this.setDeliveryDate(lResultSet.getString("deliveryDate"));
        this.setDeliveryTime(lResultSet.getString("deliveryTime"));
        this.setShippmentDate(lResultSet.getString("shippmentDate"));
        this.setConsignGoodsFee(lResultSet.getString("consignGoodsFee"));
        this.setIndividualCode(lResultSet.getString("individualCode"));
      }else {
        log.error("not find record for ordercode="+getOrderCode());
      }
    }catch(SQLException sqle){
      sqle.printStackTrace();
    }finally{
      SIDBUtil.close(lStatement,lResultSet);
    }
    return lResult;
  }
  
  /**
   * <b>getMiscData</b>
   * 仕入価格、加工費を取得します。
   * @param lConnection データベースへのコネンクション
   * @return なし
   * @throws なし
   */
  public boolean getMiscData(Connection lConnection){
    boolean lResult=false;
    Statement lStatement=null;
    ResultSet lResultSet=null;
    StringBuffer lSqlBuf=new StringBuffer();
    lSqlBuf.append("SELECT CASE amountflg WHEN 0 THEN purchaseprice2 ELSE purchaseprice END AS purchaseprice,processingexpence FROM individualtbl ");
    lSqlBuf.append("WHERE ShopCode=").append(SIDBUtil.SQL2Str(this.getShopCode()," "));
    lSqlBuf.append("AND CmdtyCode=").append(SIDBUtil.SQL2Str(this.getCmdtyCode()," "));
    lSqlBuf.append("AND IndividualCode=").append(SIDBUtil.SQL2Str(this.getIndividualCode()," "));
    
    log.debug("reset:lSqlBuf="+lSqlBuf.toString());
    try {
      lStatement=lConnection.createStatement();
      lResultSet=lStatement.executeQuery(lSqlBuf.toString());
      
      if (lResultSet.next()){
        this.setEncode(SIConfig.SIENCODE_NONE);
        lResult=true;
        this.setPurchasePrice(lResultSet.getString("purchaseprice"));//仕入価格
        if(this.purchasePrice == null){
          this.setPurchasePrice("0");
        }
        this.setProcessingExpance(lResultSet.getString("processingexpence"));//加工費
        if(this.processingExpance == null){
          this.setProcessingExpance("0");
        }
      }else {
        log.error("not find record for ordercode="+getOrderCode());
      }
    }catch(SQLException sqle){
      sqle.printStackTrace();
    }finally{
      SIDBUtil.close(lStatement,lResultSet);
    }
    return lResult;
  }
  
  // EDBTG003-00 elecs-matsushima add start
  public String getOrderBranchCode() {
    return this.orderBranchCode;
  }
  
  public void setOrderBranchCode(String orderBranchCode) {
    if (SIUtil.isNull(orderBranchCode)) orderBranchCode = "";
    this.orderBranchCode = orderBranchCode;
  }
  
  public String getOrderDetailCode() {
    return this.orderDetailCode;
  }
  
  public void setOrderDetailCode(String orderDetailCode) {
    if (SIUtil.isNull(orderDetailCode)) orderDetailCode = "";
    this.orderDetailCode = orderDetailCode;
  }
  
  public String getOldSetCode() {
    return this.oldSetCode;
  }
  
  public void setOldSetCode(String oldSetCode) {
    if (SIUtil.isNull(oldSetCode)) oldSetCode = "";
    this.oldSetCode = oldSetCode;
  }
  
  public LinkedHashMap getAllocationMap() {
    return this.allocationMap;
  }
  
  public void setAllocationMap(LinkedHashMap allocationMap) {
    if (allocationMap == null) allocationMap = new LinkedHashMap();
    this.allocationMap = allocationMap;
  }
  // EDBTG003-00 elecs-matsushima add end
  public String getCmdtyCompositionFlg() {
    return cmdtyCompositionFlg;
  }
  
  public void setCmdtyCompositionFlg(String cmdtyCompositionFlg) {
    if (SIUtil.isNull(cmdtyCompositionFlg)) cmdtyCompositionFlg = SIConfig.CMDTY_COMPOSITION_NORMAL;
    this.cmdtyCompositionFlg = cmdtyCompositionFlg;
  }
}
