예제 #1
0
        public bool Add(DeliverChargeInfo deliverChargeInfo)
        {
            Parameters cmdParams = AddInCommonParameter(deliverChargeInfo);

            cmdParams.AddInParameter("@deliverTypeID", DbType.Int32, deliverChargeInfo.DeliverTypeId);
            return(DBHelper.ExecuteProc("PR_Shop_DeliverCharge_Add", cmdParams));
        }
예제 #2
0
        public bool Update(DeliverChargeInfo deliverChargeInfo)
        {
            Parameters cmdParams = AddInCommonParameter(deliverChargeInfo);

            cmdParams.AddInParameter("@id", DbType.Int32, deliverChargeInfo.Id);
            return(DBHelper.ExecuteProc("PR_Shop_DeliverCharge_Update", cmdParams));
        }
예제 #3
0
        private static decimal GetChargeByWeight(string postCode, int deliverTypeId, double totalWeight)
        {
            decimal           chargeMax          = 0M;
            DeliverChargeInfo chargeParmOfWeight = GetChargeParmOfWeight(postCode, deliverTypeId);

            if (chargeParmOfWeight.IsNull)
            {
                return(chargeMax);
            }
            if (totalWeight > 0.0)
            {
                if (totalWeight > chargeParmOfWeight.WeightMin)
                {
                    decimal d = DataConverter.CDecimal((totalWeight - chargeParmOfWeight.WeightMin) / chargeParmOfWeight.WeightPerUnit);
                    if (d > decimal.Floor(d))
                    {
                        d = -(decimal.Floor(d));//将decimal.op_Decrement改为-
                    }
                    chargeMax = chargeParmOfWeight.ChargeMin + (d * chargeParmOfWeight.ChargePerUnit);
                    if (chargeMax > chargeParmOfWeight.ChargeMax)
                    {
                        chargeMax = chargeParmOfWeight.ChargeMax;
                    }
                    return(chargeMax);
                }
                return(chargeParmOfWeight.ChargeMin);
            }
            return(0M);
        }
예제 #4
0
 private static void DeliverChargeInfoFromrdr(DeliverChargeInfo deliverChargeInfo, NullableDataReader rdr)
 {
     deliverChargeInfo.ChargeMin     = rdr.GetDecimal("Charge_Min");
     deliverChargeInfo.WeightMin     = rdr.GetDouble("Weight_Min");
     deliverChargeInfo.ChargePerUnit = rdr.GetDecimal("ChargePerUnit");
     deliverChargeInfo.WeightPerUnit = rdr.GetDouble("WeightPerUnit");
     deliverChargeInfo.ChargeMax     = rdr.GetDecimal("Charge_Max");
     deliverChargeInfo.ArrArea       = rdr.GetString("arrArea");
 }
예제 #5
0
        private static Parameters AddInCommonParameter(DeliverChargeInfo deliverChargeInfo)
        {
            Parameters parameters = new Parameters();

            parameters.AddInParameter("@areaType", DbType.Int32, deliverChargeInfo.AreaType);
            parameters.AddInParameter("@arrArea", DbType.String, deliverChargeInfo.ArrArea);
            parameters.AddInParameter("@charge_Min", DbType.Currency, deliverChargeInfo.ChargeMin);
            parameters.AddInParameter("@weight_Min", DbType.Double, deliverChargeInfo.WeightMin);
            parameters.AddInParameter("@chargePerUnit", DbType.Currency, deliverChargeInfo.ChargePerUnit);
            parameters.AddInParameter("@weightPerUnit", DbType.Double, deliverChargeInfo.WeightPerUnit);
            parameters.AddInParameter("@charge_Max", DbType.Currency, deliverChargeInfo.ChargeMax);
            return(parameters);
        }
예제 #6
0
        private static DeliverChargeInfo CreateInfo(NullableDataReader rdr)
        {
            DeliverChargeInfo info = new DeliverChargeInfo();

            info.Id            = rdr.GetInt32("Id");
            info.DeliverTypeId = rdr.GetInt32("DeliverTypeId");
            info.AreaType      = rdr.GetInt32("AreaType");
            info.ArrArea       = rdr["arrArea"].ToString();
            info.ChargeMin     = rdr.GetDecimal("Charge_Min");
            info.WeightMin     = rdr.GetDouble("Weight_Min");
            info.ChargePerUnit = rdr.GetDecimal("ChargePerUnit");
            info.WeightPerUnit = rdr.GetDouble("WeightPerUnit");
            info.ChargeMax     = rdr.GetDecimal("Charge_Max");
            return(info);
        }
예제 #7
0
        public DeliverChargeInfo GetChargeParmOfWeight(int areaType, int deliverType)
        {
            Parameters cmdParams = new Parameters();

            cmdParams.AddInParameter("@AreaType", DbType.Int32, areaType);
            cmdParams.AddInParameter("@DeliverType", DbType.Int32, deliverType);
            using (NullableDataReader reader = DBHelper.ExecuteReaderProc("PR_Shop_DeliverCharge_GetChargeParmOfWeight", cmdParams))
            {
                if (reader.Read())
                {
                    DeliverChargeInfo deliverChargeInfo = new DeliverChargeInfo();
                    DeliverChargeInfoFromrdr(deliverChargeInfo, reader);
                    return(deliverChargeInfo);
                }
                return(new DeliverChargeInfo(true));
            }
        }
예제 #8
0
        public IList <DeliverChargeInfo> GetChargeParmListOfWeight(int areaType, int deliverType)
        {
            Parameters cmdParams = new Parameters();

            cmdParams.AddInParameter("@AreaType", DbType.Int32, areaType);
            cmdParams.AddInParameter("@DeliverType", DbType.Int32, deliverType);
            IList <DeliverChargeInfo> list = new List <DeliverChargeInfo>();

            using (NullableDataReader reader = DBHelper.ExecuteReaderProc("PR_Shop_DeliverCharge_GetChargeParmOfWeight", cmdParams))
            {
                while (reader.Read())
                {
                    DeliverChargeInfo deliverChargeInfo = new DeliverChargeInfo();
                    DeliverChargeInfoFromrdr(deliverChargeInfo, reader);
                    list.Add(deliverChargeInfo);
                }
            }
            return(list);
        }
예제 #9
0
 public static bool Update(DeliverChargeInfo deliverChargeInfo)
 {
     return((deliverChargeInfo != null) && dal.Update(deliverChargeInfo));
 }
예제 #10
0
 public static bool Add(DeliverChargeInfo deliverChargeInfo)
 {
     return((deliverChargeInfo != null) && dal.Add(deliverChargeInfo));
 }
예제 #11
0
        private static DeliverChargeInfo GetChargeParmOfWeight(string postCode, int deliverTypeId)
        {
            string            country  = SiteConfig.ShopConfig.Country;
            string            province = SiteConfig.ShopConfig.Province;
            string            city     = SiteConfig.ShopConfig.City;
            RegionInfo        byPostCodeOfFourNumber = Region.GetByPostCodeOfFourNumber(postCode);
            DeliverChargeInfo info2 = new DeliverChargeInfo(true);
            int areaType            = 5;

            if (!byPostCodeOfFourNumber.IsNull)
            {
                if (((byPostCodeOfFourNumber.Country == country) && (byPostCodeOfFourNumber.Province == province)) && (byPostCodeOfFourNumber.City == city))
                {
                    areaType = 1;
                }
                else
                {
                    DeliverChargeInfo chargeParmOfWeight = dal.GetChargeParmOfWeight(2, deliverTypeId);
                    if (!chargeParmOfWeight.IsNull && StringHelper.FoundCharInArr(chargeParmOfWeight.ArrArea, byPostCodeOfFourNumber.Province + "|" + byPostCodeOfFourNumber.City, ","))
                    {
                        areaType = 2;
                        info2    = chargeParmOfWeight;
                    }
                    if (areaType != 2)
                    {
                        if ((byPostCodeOfFourNumber.Country == country) && (byPostCodeOfFourNumber.Province == province))
                        {
                            areaType = 3;
                        }
                        else
                        {
                            areaType = 5;
                            IList <DeliverChargeInfo> list = new List <DeliverChargeInfo>();
                            foreach (DeliverChargeInfo info4 in dal.GetChargeParmListOfWeight(4, deliverTypeId))
                            {
                                if (StringHelper.FoundCharInArr(info4.ArrArea, byPostCodeOfFourNumber.Province, ","))
                                {
                                    areaType = 4;
                                    info2    = info4;
                                    break;
                                }
                            }
                            if ((areaType == 5) && Region.PostCodeExists(postCode))
                            {
                                info2 = dal.GetChargeParmOfWeight(4, deliverTypeId);
                                if (!info2.IsNull)
                                {
                                    areaType = 4;
                                }
                            }
                        }
                    }
                }
            }
            if ((areaType != 2) && (areaType != 4))
            {
                info2 = dal.GetChargeParmOfWeight(areaType, deliverTypeId);
            }
            if (info2.WeightPerUnit <= 0.0)
            {
                info2.WeightPerUnit = 1.0;
            }
            return(info2);
        }