Exemple #1
0
        //更新购物车中的AllMoney(实际购买总价),便于后期查看详情
        private double UpdateCartAllMoney(DataTable dt)
        {
            M_UserInfo mu       = buser.GetLogin();
            double     allmoney = 0;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow   dr      = dt.Rows[i];
                M_Cart    cartMod = cartBll.GetCartByid(Convert.ToInt32(dr["ID"]));
                M_Product proMod  = proBll.GetproductByid(Convert.ToInt32(dr["Proid"]));
                //--附加币值计价
                //if (orderCom.HasPrice(proMod.LinPrice_Json))
                //{
                //    M_LinPrice priceMod = JsonConvert.DeserializeObject<M_LinPrice>(proMod.LinPrice_Json);
                //    priceMod.Purse = priceMod.Purse * cartMod.Pronum;
                //    priceMod.Sicon = priceMod.Sicon * cartMod.Pronum;
                //    priceMod.Point = priceMod.Point * cartMod.Pronum;
                //    dr["AllMoney_Json"] = JsonConvert.SerializeObject(priceMod);
                //    cartMod.AllMoney_Json = DataConvert.CStr(dr["AllMoney_Json"]);
                //}
                //根据商品价格类型,看使用  零售|批发|会员|会员组价格
                //多区域价格
                if (string.IsNullOrEmpty(Region))
                {
                    Region = buser.GetRegion(mu.UserID);
                }
                double price = regionBll.GetRegionPrice(proMod.ID, proMod.LinPrice, Region, mu.GroupID);
                //如果多区域价格未匹配,则匹配会员价
                if (price == proMod.LinPrice)
                {
                    price = proBll.P_GetByUserType(proMod, mu);
                }
                //--多价格编号,则使用多价格编号的价钱,ProName(已在购物车页面更新)
                //double price =proBll.GetPriceByCode(dr["code"], proMod.Wholesalesinfo, ref price);
                cartMod.AllMoney    = price * cartMod.Pronum;
                cartMod.AllIntegral = cartMod.AllMoney;
                //----计算折扣
                dr["AllMoney"]    = cartMod.AllMoney;
                dr["AllIntegral"] = cartMod.AllIntegral;
                if (proMod.Recommend > 0)
                {
                    dr["AllMoney"]   = (cartMod.AllIntegral - (cartMod.AllIntegral * ((double)proMod.Recommend / 100)));
                    cartMod.AllMoney = Convert.ToDouble(dr["AllMoney"]);
                }
                cartBll.UpdateByID(cartMod);
                allmoney += cartMod.AllMoney;
            }
            return(allmoney);
        }