Exemple #1
0
        public static PromotionModel GetPromotionDetail(int id)
        {
            var dt = DALPromotion.GetPromotionDetail(id);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(new PromotionModel());
            }
            var result = dt.Rows.Cast <DataRow>().Select(row => new PromotionModel(row)).FirstOrDefault();

            var proConfig  = DALPromotion.GetCouponProductConfig(result.PKID);
            var shopConfig = DALPromotion.GetCouponShopConfig(result.PKID);

            result.ShopConfig     = shopConfig.Rows.Cast <DataRow>().Select(row => new CouponRulesConfigShop(row)).ToList();
            result.ProductsConfig = proConfig.Rows.Cast <DataRow>().Select(row => new CouponRulesConfigProduct(row)).ToList();
            var pids = result.ProductsConfig.Where(x => x.Type == 4).Select(x => x.ConfigValue).ToList();

            if (pids.Any())
            {
                IAutoSuppliesManager manager = new AutoSuppliesManager();
                var names = manager.GetProductNamesByPids(pids);
                foreach (var p in result.ProductsConfig)
                {
                    if (p.Type == 4 && names.ContainsKey(p.ConfigValue))
                    {
                        p.ProductName = names[p.ConfigValue];
                    }
                }
            }

            return(result);
        }
Exemple #2
0
 /// <summary>
 /// 获取部门和用途信息
 /// </summary>
 /// <param name="conn"></param>
 /// <param name="settingId"></param>
 /// <returns></returns>
 public static DepartmentAndUseModel GetCouponDepartmentUseSettingBySettingId(int settingId)
 {
     using (var conn = ProcessConnection.OpenConfigurationReadOnly)
     {
         return(DALPromotion.GetCouponDepartmentUseSettingBySettingId(conn, settingId));
     }
 }
Exemple #3
0
        public static IEnumerable <Tuhu.Provisioning.DataAccess.Entity.Category> SelectProductCategoryCategoryNameAndDisplayName()
        {
            var dt = DALPromotion.SelectProductCategoryCategoryNameAndDisplayName();

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(new Tuhu.Provisioning.DataAccess.Entity.Category[0]);
            }

            var result = dt.Rows.Cast <DataRow>().Select(row => new Tuhu.Provisioning.DataAccess.Entity.Category
            {
                CategoryName     = Convert.ToString(row["CategoryName"]),
                DisplayName      = Convert.ToString(row["DisplayName"]),
                oid              = Convert.ToInt32(row["oid"]),
                ParaentOid       = Convert.ToInt32(row["ParaentOid"]),
                ChildrenCategory = new List <Tuhu.Provisioning.DataAccess.Entity.Category>()
            }).ToArray();

            foreach (var category in result)
            {
                category.ParentCategory   = result.Where(c => category.ParaentOid == c.oid);
                category.ChildrenCategory = result.Where(c => c.ParaentOid == category.oid);
            }
            return(result);
        }
Exemple #4
0
        /// <summary>
        /// 获取某种类型的优惠券来的详细信息
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <PromotionModel> SelectPromotionDetail(int id)
        {
            var dt = DALPromotion.SelectPromotionDetail(id);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(new PromotionModel[0]);
            }
            return(dt.Rows.Cast <DataRow>().Select(row => new PromotionModel(row)));
        }
Exemple #5
0
        public IEnumerable <ExchangeCodeDetail> SelectPromotionDetailsByEdit(int id)
        {
            DataTable dt = DALPromotion.SelectPromotionDetailsByEdit(id);

            if (dt == null || dt.Rows.Count == 0)
            {
                return(new List <ExchangeCodeDetail>());
            }
            return(dt.Rows.OfType <DataRow>().Select(x => new ExchangeCodeDetail(x)));
        }
Exemple #6
0
        public IEnumerable <ExchangeCodeDetail> UpdateOEM(int pkid)
        {
            DataTable dt = DALPromotion.UpdateOEM(pkid);

            if (dt == null || dt.Rows.Count == 0)
            {
                return(new List <ExchangeCodeDetail>());
            }
            return(dt.Rows.OfType <DataRow>().Select(x => new ExchangeCodeDetail(x)));
        }
Exemple #7
0
        /// <summary>
        /// 获取产品品牌
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <ProductBrand> SelectProductBrand(string type)
        {
            var dt = DALPromotion.SelectProductBrand(type);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(new List <ProductBrand>());
            }
            return(dt.Rows.Cast <DataRow>().Select(row => new ProductBrand(row)));
        }
Exemple #8
0
        public static IEnumerable <GetPCodeModel> SelectGeCouponRulesByRuleID(int id)
        {
            var dt = DALPromotion.SelectGeCouponRulesByRuleID(id);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(new GetPCodeModel[0]);
            }
            return(dt.Rows.Cast <DataRow>().Select(row => new GetPCodeModel(row)));
        }
Exemple #9
0
        /// <summary>
        /// 获取优惠券领取规则
        /// </summary>
        /// <param name="getRuleId"></param>
        /// <returns></returns>
        public static GetPCodeModel SelectGeCouponRulesByGetRuleID(int getRuleId)
        {
            var dt = DALPromotion.SelectGeCouponRulesByGetRuleID(getRuleId);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(null);
            }
            return(dt.Rows.Cast <DataRow>().Select(row => new GetPCodeModel(row)).FirstOrDefault());
        }
Exemple #10
0
        public IEnumerable <ExchangeCodeDetail> SelectGiftBag(int PageNumber, int PageSize, out int TotalCount)
        {
            DataTable dt = DALPromotion.SelectGiftBag(PageNumber, PageSize, out TotalCount);

            if (dt == null || dt.Rows.Count == 0)
            {
                return(null);
            }
            return(dt.Rows.OfType <DataRow>().Select(x => new ExchangeCodeDetail(x)));
        }
Exemple #11
0
        public static int SaveCouponRuleInfo(PromotionModel PromotionModel, string action, string[] shoptypes, string[] shopids, string[] categorys, string[] brands, string[] pids)
        {
            PromotionModel.ConfigType = ((categorys ?? new string[] { }).Any() ? 1 : 0) +
                                        ((brands ?? new string[] { }).Any() ? 2 : 0) +
                                        ((pids ?? new string[] { }).Any() ? 4 : 0) +
                                        ((shoptypes ?? new string[] { }).Any() ? 8 : 0) +
                                        ((shopids ?? new string[] { }).Any() ? 16 : 0);
            switch (action)
            {
            case "add":
                return(DALPromotion.SaveCouponRuleInfo(PromotionModel, shoptypes, shopids, categorys, brands, pids));

            case "update":
                #region 链接信息处理
                //APP
                if (PromotionModel.CustomSkipPage == "{{TempProductListRouteLink}}")
                {
                    PromotionModel.CustomSkipPage = "/searchResult?ruleid=" + PromotionModel.PKID + "&s=";
                }
                else if (PromotionModel.CustomSkipPage == "{{GroupBuyingProductLink}}")
                {
                    PromotionModel.CustomSkipPage = "/webView?url=https%3A%2F%2Fwx.tuhu.cn%2Fvue%2FGroupBuy%2Fpages%2Fsearch%2Fsearch%3FruleId%3D" + PromotionModel.PKID;
                }
                //小程序
                if (PromotionModel.WxSkipPage == "{{TempProductListRouteLink}}")           //商品列表
                {
                    PromotionModel.WxSkipPage = "/pages/search/search?flag=coupon&ruleId=" + PromotionModel.PKID;
                }
                else if (PromotionModel.WxSkipPage == "{{GroupBuyingProductLink}}")        //拼团商品列表
                {
                    PromotionModel.WxSkipPage = "/pages/search/search?appid=wx25f9f129712845af&ruleId=" + PromotionModel.PKID;
                }
                //H5
                if (PromotionModel.H5SkipPage == "{{TempProductListRouteLink}}")
                {
                    PromotionModel.H5SkipPage = "http://wx.tuhu.cn/ChePin/CpList?ruleId=" + PromotionModel.PKID;
                }
                else if (PromotionModel.H5SkipPage == "{{GroupBuyingProductLink}}")
                {
                    PromotionModel.H5SkipPage = "https://wx.tuhu.cn/vue/GroupBuy/pages/search/search?ruleId=" + PromotionModel.PKID;
                }
                #endregion
                return(DALPromotion.UpdateCouponRuleInfo(PromotionModel, shoptypes, shopids, categorys, brands, pids));

            default:
                throw new Exception($"action={action}没有对应的处理方法");
            }
        }
Exemple #12
0
        public static IEnumerable <Tuple <string, string, bool> > GetProductsByPIDs(string[] pids)
        {
            var result       = new List <Tuple <string, string, bool> >();
            var productTable = DALPromotion.SelectProductNamesByPIDs(pids);

            if (productTable != null)
            {
                foreach (DataRow item in productTable.Rows)
                {
                    result.Add(Tuple.Create(item.GetValue <string>("PID"), item.GetValue <string>("DisplayName"), item.GetValue <bool>("Exist")));
                }
            }
            pids?.ToList().ForEach(f =>
            {
                var product = result.Where(w => w.Item1 == f).FirstOrDefault();
                if (product == null)
                {
                    result.Add(Tuple.Create(f, "", false));
                }
            });
            return(result);
        }
Exemple #13
0
        public static IEnumerable <Tuple <int, string, bool> > GetShopsByShopIds(int[] shopIds)
        {
            var result    = new List <Tuple <int, string, bool> >();
            var shopTable = DALPromotion.SelectShopNamesByIDs(shopIds);

            if (shopTable != null)
            {
                foreach (DataRow item in shopTable.Rows)
                {
                    result.Add(Tuple.Create(item.GetValue <int>("PKID"), item.GetValue <string>("CarparName"), item.GetValue <bool>("Exist")));
                }
            }
            shopIds?.ToList().ForEach(f =>
            {
                var shops = result.Where(w => w.Item1 == f).FirstOrDefault();
                if (shops == null)
                {
                    result.Add(Tuple.Create(f, "", false));
                }
            });
            return(result);
        }
Exemple #14
0
        /// <summary>
        /// 新增部门或用途
        /// </summary>
        /// <param name="model"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public static bool InsertDepartmentUseSettingName(DepartmentAndUseModel model, string userName)
        {
            var result = DALPromotion.InsertDepartmentUseSetting(model);

            #region 新增日志
            if (result)
            {
                using (var log = new ConfigLogClient())
                {
                    log.InsertDefaultLogQueue("PromotionConfigLog", JsonConvert.SerializeObject(new
                    {
                        ObjectId    = model.SettingId,
                        ObjectType  = "CouponDepartmentAndUse",
                        BeforeValue = "",
                        AfterValue  = JsonConvert.SerializeObject(model),
                        Operate     = "新增",
                        Author      = userName
                    }));
                }
            }
            #endregion
            return(result);
        }
Exemple #15
0
        /// <summary>
        /// 删除部门或用途
        /// </summary>
        /// <param name="id"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public static bool DeleteDepartmentUseSettingNameBySettingId(int id, string userName)
        {
            var CouponDepartUseInfo = GetCouponDepartmentUseSettingBySettingId(id);
            var result = DALPromotion.DeleteDepartmentUseSettingNameBySettingId(id);

            #region 新增日志
            if (result)
            {
                using (var log = new ConfigLogClient())
                {
                    log.InsertDefaultLogQueue("PromotionConfigLog", JsonConvert.SerializeObject(new
                    {
                        ObjectId    = id,
                        ObjectType  = "CouponDepartmentAndUse",
                        BeforeValue = JsonConvert.SerializeObject(CouponDepartUseInfo),
                        AfterValue  = "",
                        Operate     = "删除",
                        Author      = userName
                    }));
                }
            }
            #endregion
            return(result);
        }
Exemple #16
0
 /// <summary>
 /// 获取产品的所有的分类
 /// </summary>
 /// <returns></returns>
 public static IEnumerable <Tuhu.Provisioning.DataAccess.Entity.Category> SelectProductCategory()
 {
     return(Tuhu.Provisioning.DataAccess.Entity.Category.Parse(DALPromotion.SelectProductCategory()));
 }
Exemple #17
0
 public int CreeatePromotion(ExchangeCodeDetail ecd)
 {
     return(DALPromotion.CreeatePromotion(ecd));
 }
Exemple #18
0
 public static ListModel <GetPCodeModel> SelectGeCouponRulesByCondition(int id, PromotionFilterConditionModel model) => DALPromotion.SelectGeCouponRulesByCondition(id, model);
Exemple #19
0
        public static PromotionModel FetchPromotionByPKID(string id)
        {
            var dw = DALPromotion.FetchPromotionByPKID(id);

            return(new PromotionModel(dw));
        }
Exemple #20
0
 public static DataTable SelectExchangeCodeDetailByPage(int PageNumber, int PageSize, out int TotalCount)
 {
     return(DALPromotion.SelectExchangeCodeDetailByPage(PageNumber, PageSize, out TotalCount));
 }
Exemple #21
0
 public static DataTable GetPromotionLog(string objectId, string objectType)
 {
     return(DALPromotion.GetPromotionLog(objectId, objectType));
 }
Exemple #22
0
 public int DeletePromoCode(int pkid)
 {
     return(DALPromotion.DeletePromoCode(pkid));
 }
Exemple #23
0
 public static IEnumerable <PromotionModel> SelectPromotionDetailNew(int id)
 {
     return(DALPromotion.SelectPromotionDetailNew(id));
 }
Exemple #24
0
 public static DataTable GetDepartmentUseSettingNameBySettingId(int[] ids)
 {
     return(DALPromotion.GetDepartmentUseSettingNameBySettingId(ids.ToList()));
 }
Exemple #25
0
 public static DataTable GetDepartmentUseSetting()
 {
     return(DALPromotion.GetDepartmentUseSetting());
 }
Exemple #26
0
 public int DeleteGift(int pkid)
 {
     return(DALPromotion.DeleteGift(pkid));
 }
Exemple #27
0
 public int UpdatePromotionDetailsByOK(ExchangeCodeDetail ecd)
 {
     return(DALPromotion.UpdatePromotionDetailsByOK(ecd));
 }
Exemple #28
0
 public static DataTable GetDepartmentUseSettingByParentId(int parentId)
 {
     return(DALPromotion.GetDepartmentUseSettingByParentId(parentId));
 }
Exemple #29
0
 public static DataTable GetDepartmentUseSettingNameBySettingId(int id)
 {
     return(DALPromotion.GetDepartmentUseSettingNameBySettingId(id));
 }
Exemple #30
0
 public DataTable CreateExcel(int pkid)
 {
     return(DALPromotion.CreateExcel(pkid));
 }