Beispiel #1
0
        /// <summary>
        /// 从IDataReader创建StoreInfo
        /// </summary>
        public static StoreInfo BuildStoreFromReader(IDataReader reader)
        {
            StoreInfo storeInfo = new StoreInfo();

            storeInfo.StoreId = TypeHelper.ObjectToInt(reader["storeid"]);
            storeInfo.State = TypeHelper.ObjectToInt(reader["state"]);
            storeInfo.Name = reader["name"].ToString();
            storeInfo.RegionId = TypeHelper.ObjectToInt(reader["regionid"]);
            storeInfo.StoreRid = TypeHelper.ObjectToInt(reader["storerid"]);
            storeInfo.StoreIid = TypeHelper.ObjectToInt(reader["storeiid"]);
            storeInfo.Logo = reader["logo"].ToString();
            storeInfo.CreateTime = TypeHelper.ObjectToDateTime(reader["createtime"]);
            storeInfo.Mobile = reader["mobile"].ToString();
            storeInfo.Phone = reader["phone"].ToString();
            storeInfo.QQ = reader["qq"].ToString();
            storeInfo.WW = reader["ww"].ToString();
            storeInfo.DePoint = TypeHelper.ObjectToDecimal(reader["depoint"]);
            storeInfo.SePoint = TypeHelper.ObjectToDecimal(reader["sepoint"]);
            storeInfo.ShPoint = TypeHelper.ObjectToDecimal(reader["shpoint"]);
            storeInfo.Honesties = TypeHelper.ObjectToInt(reader["honesties"]);
            storeInfo.StateEndTime = TypeHelper.ObjectToDateTime(reader["stateendtime"]);
            storeInfo.Theme = reader["theme"].ToString();
            storeInfo.Banner = reader["banner"].ToString();
            storeInfo.Announcement = reader["announcement"].ToString();
            storeInfo.Description = reader["description"].ToString();

            return storeInfo;
        }
Beispiel #2
0
 /// <summary>
 /// 创建店铺
 /// </summary>
 /// <param name="storeInfo">店铺信息</param>
 /// <param name="storeKeeperInfo">店主信息</param>
 /// <returns>店铺id</returns>
 public static int CreateStore(StoreInfo storeInfo, StoreKeeperInfo storeKeeperInfo)
 {
     int storeId = BrnMall.Data.Stores.CreateStore(storeInfo);
     if (storeId > 0)
     {
         storeKeeperInfo.StoreId = storeId;
         CreateStoreKeeper(storeKeeperInfo);
     }
     return storeId;
 }
Beispiel #3
0
 /// <summary>
 /// 更新店铺
 /// </summary>
 /// <param name="storeInfo">店铺信息</param>
 public static void UpdateStore(StoreInfo storeInfo)
 {
     BrnMall.Core.BMAData.RDBS.UpdateStore(storeInfo);
     if (_storenosql != null)
         _storenosql.UpdateStore(storeInfo);
 }
Beispiel #4
0
 /// <summary>
 /// 创建店铺
 /// </summary>
 /// <param name="storeInfo">店铺信息</param>
 /// <returns>店铺id</returns>
 public static int CreateStore(StoreInfo storeInfo)
 {
     return BrnMall.Core.BMAData.RDBS.CreateStore(storeInfo);
 }
Beispiel #5
0
 /// <summary>
 /// 更新店铺
 /// </summary>
 /// <param name="storeInfo">店铺信息</param>
 public static void UpdateStore(StoreInfo storeInfo)
 {
     BrnMall.Data.Stores.UpdateStore(storeInfo);
 }
Beispiel #6
0
 /// <summary>
 /// 更新店铺
 /// </summary>
 /// <param name="storeInfo">店铺信息</param>
 public void UpdateStore(StoreInfo storeInfo)
 {
     DbParameter[] parms = {
                             GenerateInParam("@state", SqlDbType.TinyInt,1,storeInfo.State),
                             GenerateInParam("@name", SqlDbType.NChar,60,storeInfo.Name),
                             GenerateInParam("@regionid", SqlDbType.SmallInt,2,storeInfo.RegionId),
                             GenerateInParam("@storerid", SqlDbType.SmallInt,2,storeInfo.StoreRid),
                             GenerateInParam("@storeiid", SqlDbType.SmallInt,2,storeInfo.StoreIid),
                             GenerateInParam("@logo", SqlDbType.NChar,100,storeInfo.Logo),
                             GenerateInParam("@createtime", SqlDbType.DateTime,8,storeInfo.CreateTime),
                             GenerateInParam("@mobile", SqlDbType.Char,15,storeInfo.Mobile),
                             GenerateInParam("@phone", SqlDbType.Char,12,storeInfo.Phone),
                             GenerateInParam("@qq", SqlDbType.Char,11,storeInfo.QQ),
                             GenerateInParam("@ww", SqlDbType.Char,50,storeInfo.WW),
                             GenerateInParam("@depoint", SqlDbType.Decimal,4,storeInfo.DePoint),
                             GenerateInParam("@sepoint", SqlDbType.Decimal,4,storeInfo.SePoint),
                             GenerateInParam("@shpoint", SqlDbType.Decimal,4,storeInfo.ShPoint),
                             GenerateInParam("@honesties", SqlDbType.Int,4,storeInfo.Honesties),
                             GenerateInParam("@stateendtime", SqlDbType.DateTime,8,storeInfo.StateEndTime),
                             GenerateInParam("@theme", SqlDbType.Char,20,storeInfo.Theme),
                             GenerateInParam("@banner", SqlDbType.NChar,100,storeInfo.Banner),
                             GenerateInParam("@announcement", SqlDbType.NChar,200,storeInfo.Announcement),
                             GenerateInParam("@description", SqlDbType.NChar,300,storeInfo.Description),
                             GenerateInParam("@storeid", SqlDbType.Int,4,storeInfo.StoreId)
                            };
     string commandText = string.Format("UPDATE [{0}stores] SET [state]=@state,[name]=@name,[regionid]=@regionid,[storerid]=@storerid,[storeiid]=@storeiid,[logo]=@logo,[createtime]=@createtime,[mobile]=@mobile,[phone]=@phone,[qq]=@qq,[ww]=@ww,[depoint]=@depoint,[sepoint]=@sepoint,[shpoint]=@shpoint,[honesties]=@honesties,[stateendtime]=@stateendtime,[theme]=@theme,[banner]=@banner,[announcement]=@announcement,[description]=@description WHERE [storeid]=@storeid",
                                         RDBSHelper.RDBSTablePre);
     RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);
 }
Beispiel #7
0
 /// <summary>
 /// 创建店铺
 /// </summary>
 /// <param name="storeInfo">店铺信息</param>
 /// <returns>店铺id</returns>
 public int CreateStore(StoreInfo storeInfo)
 {
     DbParameter[] parms = {
                             GenerateInParam("@state", SqlDbType.TinyInt,1,storeInfo.State),
                             GenerateInParam("@name", SqlDbType.NChar,60,storeInfo.Name),
                             GenerateInParam("@regionid", SqlDbType.SmallInt,2,storeInfo.RegionId),
                             GenerateInParam("@storerid", SqlDbType.SmallInt,2,storeInfo.StoreRid),
                             GenerateInParam("@storeiid", SqlDbType.SmallInt,2,storeInfo.StoreIid),
                             GenerateInParam("@logo", SqlDbType.NChar,100,storeInfo.Logo),
                             GenerateInParam("@createtime", SqlDbType.DateTime,8,storeInfo.CreateTime),
                             GenerateInParam("@mobile", SqlDbType.Char,15,storeInfo.Mobile),
                             GenerateInParam("@phone", SqlDbType.Char,12,storeInfo.Phone),
                             GenerateInParam("@qq", SqlDbType.Char,11,storeInfo.QQ),
                             GenerateInParam("@ww", SqlDbType.Char,50,storeInfo.WW),
                             GenerateInParam("@depoint", SqlDbType.Decimal,4,storeInfo.DePoint),
                             GenerateInParam("@sepoint", SqlDbType.Decimal,4,storeInfo.SePoint),
                             GenerateInParam("@shpoint", SqlDbType.Decimal,4,storeInfo.ShPoint),
                             GenerateInParam("@honesties", SqlDbType.Int,4,storeInfo.Honesties),
                             GenerateInParam("@stateendtime", SqlDbType.DateTime,8,storeInfo.StateEndTime),
                             GenerateInParam("@theme", SqlDbType.Char,20,storeInfo.Theme),
                             GenerateInParam("@banner", SqlDbType.NChar,100,storeInfo.Banner),
                             GenerateInParam("@announcement", SqlDbType.NChar,200,storeInfo.Announcement),
                             GenerateInParam("@description", SqlDbType.NChar,300,storeInfo.Description)
                            };
     string commandText = string.Format("INSERT INTO [{0}stores]([state],[name],[regionid],[storerid],[storeiid],[logo],[createtime],[mobile],[phone],[qq],[ww],[depoint],[sepoint],[shpoint],[honesties],[stateendtime],[theme],[banner],[announcement],[description]) VALUES(@state,@name,@regionid,@storerid,@storeiid,@logo,@createtime,@mobile,@phone,@qq,@ww,@depoint,@sepoint,@shpoint,@honesties,@stateendtime,@theme,@banner,@announcement,@description);SELECT SCOPE_IDENTITY();",
                                         RDBSHelper.RDBSTablePre);
     return TypeHelper.ObjectToInt(RDBSHelper.ExecuteScalar(CommandType.Text, commandText, parms), -1);
 }
Beispiel #8
0
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="storeInfo">店铺信息</param>
        /// <param name="orderProductList">订单商品列表</param>
        /// <param name="singlePromotionList">单品促销活动列表</param>
        /// <param name="fullShipAddressInfo">配送地址</param>
        /// <param name="payPluginInfo">支付方式</param>
        /// <param name="payCreditCount">支付积分数</param>
        /// <param name="couponList">优惠劵列表</param>
        /// <param name="fullCut">满减</param>
        /// <param name="buyerRemark">买家备注</param>
        /// <param name="bestTime">最佳配送时间</param>
        /// <param name="ip">ip地址</param>
        /// <returns>订单信息</returns>
        public static OrderInfo CreateOrder(PartUserInfo partUserInfo, StoreInfo storeInfo, List<OrderProductInfo> orderProductList, List<SinglePromotionInfo> singlePromotionList, FullShipAddressInfo fullShipAddressInfo, PluginInfo payPluginInfo, ref int payCreditCount, List<CouponInfo> couponList, int fullCut, string buyerRemark, DateTime bestTime, string ip)
        {
            DateTime nowTime = DateTime.Now;
            IPayPlugin payPlugin = (IPayPlugin)payPluginInfo.Instance;

            OrderInfo orderInfo = new OrderInfo();

            orderInfo.OSN = GenerateOSN(storeInfo.StoreId, partUserInfo.Uid, fullShipAddressInfo.RegionId, nowTime); ;
            orderInfo.Uid = partUserInfo.Uid;

            orderInfo.Weight = Carts.SumOrderProductWeight(orderProductList);
            orderInfo.ProductAmount = Carts.SumOrderProductAmount(orderProductList);
            orderInfo.FullCut = fullCut;
            orderInfo.ShipFee = GetShipFee(fullShipAddressInfo.ProvinceId, fullShipAddressInfo.CityId, orderProductList);
            orderInfo.PayFee = payPlugin.GetPayFee(orderInfo.ProductAmount - orderInfo.FullCut, nowTime, partUserInfo);
            orderInfo.OrderAmount = orderInfo.ProductAmount - orderInfo.FullCut + orderInfo.ShipFee + orderInfo.PayFee;

            decimal payCreditMoney = Credits.PayCreditsToMoney(payCreditCount);
            if (orderInfo.OrderAmount >= payCreditMoney)
            {
                orderInfo.PayCreditCount = payCreditCount;
                orderInfo.PayCreditMoney = payCreditMoney;
                payCreditCount = 0;
            }
            else
            {
                int orderPayCredits = Credits.MoneyToPayCredits(orderInfo.OrderAmount);
                orderInfo.PayCreditCount = orderPayCredits;
                orderInfo.PayCreditMoney = orderInfo.OrderAmount;
                payCreditCount = payCreditCount - orderPayCredits;
            }

            orderInfo.CouponMoney = Coupons.SumCouponMoney(couponList);
            orderInfo.SurplusMoney = orderInfo.OrderAmount - orderInfo.PayCreditMoney - orderInfo.CouponMoney;

            orderInfo.OrderState = (orderInfo.SurplusMoney <= 0 || payPlugin.PayMode == 0) ? (int)OrderState.Confirming : (int)OrderState.WaitPaying;

            orderInfo.ParentId = 0;
            orderInfo.IsReview = 0;
            orderInfo.AddTime = nowTime;
            orderInfo.StoreId = storeInfo.StoreId;
            orderInfo.StoreName = storeInfo.Name;
            orderInfo.PaySystemName = payPluginInfo.SystemName;
            orderInfo.PayFriendName = payPluginInfo.FriendlyName;
            orderInfo.PayMode = payPlugin.PayMode;

            orderInfo.RegionId = fullShipAddressInfo.RegionId;
            orderInfo.Consignee = fullShipAddressInfo.Consignee;
            orderInfo.Mobile = fullShipAddressInfo.Mobile;
            orderInfo.Phone = fullShipAddressInfo.Phone;
            orderInfo.Email = fullShipAddressInfo.Email;
            orderInfo.ZipCode = fullShipAddressInfo.ZipCode;
            orderInfo.Address = fullShipAddressInfo.Address;
            orderInfo.BestTime = bestTime;

            orderInfo.BuyerRemark = buyerRemark;
            orderInfo.IP = ip;

            try
            {
                //添加订单
                int oid = _iorderstrategy.CreateOrder(orderInfo, Carts.IsPersistOrderProduct, orderProductList);
                if (oid > 0)
                {
                    orderInfo.Oid = oid;

                    //减少商品库存数量
                    Products.DecreaseProductStockNumber(orderProductList);
                    //更新限购库存
                    if (singlePromotionList.Count > 0)
                        Promotions.UpdateSinglePromotionStock(singlePromotionList);
                    //使用支付积分
                    Credits.PayOrder(ref partUserInfo, orderInfo, orderInfo.PayCreditCount, nowTime);
                    //使用优惠劵
                    foreach (CouponInfo couponInfo in couponList)
                    {
                        if (couponInfo.Uid > 0)
                            Coupons.UseCoupon(couponInfo.CouponId, oid, nowTime, ip);
                        else
                            Coupons.ActivateAndUseCoupon(couponInfo.CouponId, partUserInfo.Uid, oid, nowTime, ip);
                    }

                    return orderInfo;
                }
            }
            catch (Exception ex)
            {
                //throw ex;
            }

            return null;
        }
Beispiel #9
0
        private StoreInfo storeInfo = null;//店铺信息

        protected override void OnAuthorization(AuthorizationContext filterContext)
        {
            ip = WebHelper.GetIP();
            //当用户ip不在允许的后台访问ip列表时
            if (!string.IsNullOrEmpty(mallConfigInfo.AdminAllowAccessIP) && !ValidateHelper.InIPList(ip, mallConfigInfo.AdminAllowAccessIP))
            {
                filterContext.Result = HttpNotFound();
                return;
            }
            //当用户IP被禁止时
            if (BannedIPs.CheckIP(ip))
            {
                filterContext.Result = HttpNotFound();
                return;
            }

            //获得用户id
            int uid = MallUtils.GetUidCookie();
            if (uid < 1)
                uid = WebHelper.GetRequestInt("uid");

            if (uid < 1)//当用户为游客时
            {
                //创建游客
                partUserInfo = Users.CreatePartGuest();
            }
            else//当用户为会员时
            {
                //获得保存在cookie中的密码
                string encryptPwd = MallUtils.GetCookiePassword();
                if (string.IsNullOrWhiteSpace(encryptPwd))
                    encryptPwd = WebHelper.GetRequestString("password");
                //防止用户密码被篡改为危险字符
                if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd))
                {
                    //创建游客
                    partUserInfo = Users.CreatePartGuest();
                    MallUtils.SetUidCookie(-1);
                    MallUtils.SetCookiePassword("");
                }
                else
                {
                    partUserInfo = Users.GetPartUserByUidAndPwd(uid, MallUtils.DecryptCookiePassword(encryptPwd));
                    if (partUserInfo == null)
                    {
                        partUserInfo = Users.CreatePartGuest();
                        MallUtils.SetUidCookie(-1);
                        MallUtils.SetCookiePassword("");
                    }
                }
            }

            //当用户等级是禁止访问等级时
            if (partUserInfo.UserRid == 1)
            {
                filterContext.Result = HttpNotFound();
                return;
            }

            //如果当前用户没有登录
            if (partUserInfo.Uid < 1)
            {
                filterContext.Result = HttpNotFound();
                return;
            }

            //店铺不存在或店铺关闭
            storeInfo = AdminStores.GetStoreById(partUserInfo.StoreId);
            if (storeInfo == null || storeInfo.State == (int)StoreState.Close)
            {
                filterContext.Result = HttpNotFound();
                return;
            }
        }
Beispiel #10
0
        public ActionResult AddStore(AddStoreModel model)
        {
            if (AdminStores.GetStoreIdByName(model.StoreName) > 0)
                ModelState.AddModelError("StoreName", "名称已经存在");

            if (ModelState.IsValid)
            {
                StoreInfo storeInfo = new StoreInfo()
                {
                    State = (int)StoreState.Open,
                    Name = model.StoreName,
                    RegionId = 0,
                    StoreRid = AdminStoreRanks.GetLowestStoreRank().StoreRid,
                    StoreIid = 0,
                    Logo = "",
                    CreateTime = DateTime.Now,
                    Mobile = "",
                    Phone = "",
                    QQ = "",
                    WW = "",
                    DePoint = 10.00m,
                    SePoint = 10.00m,
                    ShPoint = 10.00m,
                    Honesties = 0,
                    StateEndTime = model.StateEndTime,
                    Theme = "Default",
                    Banner = "",
                    Announcement = "",
                    Description = ""
                };

                StoreKeeperInfo storeKeeperInfo = new StoreKeeperInfo()
                {
                    Type = model.Type,
                    Name = model.StoreKeeperName,
                    IdCard = model.IdCard,
                    Address = model.Address
                };

                int storeId = AdminStores.CreateStore(storeInfo, storeKeeperInfo);
                if (storeId > 0)
                {
                    AddMallAdminLog("添加店铺", "添加店铺,店铺id为:" + storeId);
                    return PromptView("店铺添加成功");
                }
                else
                {
                    return PromptView("店铺添加失败");
                }
            }

            ViewData["referer"] = MallUtils.GetMallAdminRefererCookie();
            return View(model);
        }