public static List <Dictionary <string, object> > GetMall_HotSaleList()
        {
            string context_path = Utility.Tools.GetContextPath();
            List <Dictionary <string, object> > results = new List <Dictionary <string, object> >();
            var list = Mall_HotSale.GetMall_HotSales().Where(p => p.Is_Valid).OrderBy(p => p.SortOrder).ToArray();

            if (list.Length == 0)
            {
                return(results);
            }
            var list_product_ids  = list.Where(p => p.Type == 1).Select(p => p.RelatedID).ToList();
            var list_business_ids = list.Where(p => p.Type == 2).Select(p => p.RelatedID).ToList();

            Mall_ProductDetail[] product_list  = new Mall_ProductDetail[] { };
            Mall_Business[]      business_list = new Mall_Business[] { };
            if (list_product_ids.Count > 0)
            {
                product_list = Mall_ProductDetail.GetMall_ProductDetailListByIDList(list_product_ids).Where(p => p.IsAllowProductBuy).ToArray();
            }
            if (list_business_ids.Count > 0)
            {
                business_list = Mall_Business.GetMall_BusinessListByIDList(list_business_ids);
            }
            foreach (var item in list)
            {
                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic["id"]        = item.ID;
                dic["type"]      = item.Type;
                dic["RelatedID"] = item.RelatedID > 0 ? item.RelatedID : 0;
                if (item.Type == 1)
                {
                    var my_data = product_list.FirstOrDefault(p => p.ID == item.RelatedID);
                    if (my_data == null)
                    {
                        continue;
                    }
                    dic["imageurl"]   = !string.IsNullOrEmpty(my_data.CoverImage) ? context_path + my_data.CoverImage : "";
                    dic["title"]      = my_data.ProductName;
                    dic["pricevalue"] = my_data.FinalVariantPrice;
                    dic["price"]      = my_data.NormalPriceDesc.ToString();
                    dic["addtime"]    = my_data.AddTime.ToString("yyyy-MM-dd HH:mm:ss");
                    dic["salecount"]  = my_data.SaleCount;
                }
                else if (item.Type == 2)
                {
                    var my_data = business_list.FirstOrDefault(p => p.ID == item.RelatedID);
                    if (my_data == null)
                    {
                        continue;
                    }
                    dic["imageurl"]   = !string.IsNullOrEmpty(my_data.CoverImage) ? context_path + my_data.CoverImage : "";
                    dic["title"]      = my_data.BusinessName;
                    dic["pricevalue"] = 0;
                    dic["price"]      = "¥0.00";
                    dic["addtime"]    = my_data.AddTime.ToString("yyyy-MM-dd HH:mm:ss");
                    dic["salecount"]  = 0;
                }
                dic["SortOrder"] = item.SortOrder > int.MinValue ? item.SortOrder : int.MaxValue;
                results.Add(dic);
            }
            results = results.OrderBy(p => Convert.ToInt32(p["SortOrder"])).ToList();
            return(results);
        }
Exemple #2
0
        private void savebusinessuserinfo(HttpContext context)
        {
            string UserType   = UserTypeDefine.APPBusiness.ToString();
            int    UserID     = GetIntValue(context, "UserID");
            int    BusinessID = GetIntValue(context, "BusinessID");

            Foresight.DataAccess.User          user     = null;
            Foresight.DataAccess.Mall_Business business = null;
            if (BusinessID > 0)
            {
                business = Mall_Business.GetMall_Business(BusinessID);
            }
            if (business == null)
            {
                WebUtil.WriteJson(context, new { status = false, error = "商家不存在" });
                return;
            }
            if (UserID > 0)
            {
                user = User.GetUser(UserID);
            }
            bool new_user_add = false;

            if (user == null)
            {
                new_user_add    = true;
                user            = new User();
                user.CreateTime = DateTime.Now;
            }
            string LoginName = context.Request.Params["LoginName"];
            var    sameuser  = Foresight.DataAccess.User.GetAPPUserByLoginName(LoginName, UserType: UserTypeDefine.APPBusiness.ToString());

            if (sameuser != null && sameuser.UserID != user.UserID)
            {
                WebUtil.WriteJson(context, new { status = false, error = "登录名已存在" });
                return;
            }
            user.Type        = UserType;
            user.NickName    = context.Request.Params["NickName"];
            user.RealName    = context.Request.Params["RealName"];
            user.PhoneNumber = context.Request.Params["PhoneNumber"];
            user.Gender      = context.Request.Params["Gender"];
            int isLocked = GetIntValue(context, "IsLocked");

            user.IsLocked = isLocked == 0 ? false : true;
            if (user.IsLocked)
            {
                user.LockTime = DateTime.Now;
            }
            if (!user.IsLocked)
            {
                user.ActiveTime = DateTime.Now;
            }
            string Pwd = context.Request.Params["Password"];

            user.LoginName = LoginName;
            if (!string.IsNullOrEmpty(Pwd))
            {
                user.Password = User.EncryptPassword(Pwd);
            }
            using (SqlHelper helper = new SqlHelper())
            {
                try
                {
                    helper.BeginTransaction();
                    user.Save(helper);
                    Mall_BusinessUser.Save_Mall_BusinessUser(business.ID, user.UserID, helper);
                    helper.Commit();
                }
                catch (Exception)
                {
                    helper.Rollback();
                }
            }
            if (new_user_add)
            {
                #region 新增账号日志
                APPCode.CommHelper.SaveOperationLog("新增账号" + user.LoginName, Utility.EnumModel.OperationModule.AddUser.ToString(), "新增账号", user.UserID.ToString(), "User");
                #endregion
            }
            WebUtil.WriteJson(context, new { status = true });
        }