예제 #1
0
        public Dictionary <int, bool> InvalidCodes(List <int> codes, string user)
        {
            Dictionary <int, bool>    result         = new Dictionary <int, bool>();
            List <PromotionCodeModel> promotionCodes = new List <PromotionCodeModel>();

            using (var client = new PromotionClient())
            {
                var serviceResult = client.GetPromotionCodeByIDs(new GetPromotionCodesRequest()
                {
                    PKIDList = codes
                });
                if (serviceResult.Success)
                {
                    promotionCodes = serviceResult.Result.ToList();
                }
            }
            foreach (var code in promotionCodes)
            {
                using (var client = new PromotionClient())
                {
                    var serviceResult = client.UpdateUserPromotionCodeStatus(new UpdateUserPromotionCodeStatusRequest()
                    {
                        Status          = 3,
                        PromotionCodeId = code.Pkid,
                        OperationAuthor = user,
                        Channel         = "setting.tuhu.cn",
                        UserID          = Guid.Parse(code.UserId)
                    });
                    if (serviceResult.Exception != null)
                    {
                        logger.Error(serviceResult.Exception);
                    }
                    result[code.Pkid] = serviceResult.Success && serviceResult.Result;
                }
            }

            foreach (var item in result)
            {
                if (item.Value)
                {
                    dbScopeManager.Execute(conn => DALVipBaoYangPackage.UpdatePromotionRemarks(conn, item.Key, $"{user}于{DateTime.Now.ToString("yyyy年MM月dd日 hh:mm")}作废此券"));
                }
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// 作废券
        /// </summary>
        /// <param name="promotionIds"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public Dictionary <int, bool> InvalidCodes(List <int> promotionIds, string user)
        {
            Dictionary <int, bool> result = new Dictionary <int, bool>();

            try
            {
                List <PromotionCodeModel> promotionCodes = new List <PromotionCodeModel>();
                using (var client = new PromotionClient())
                {
                    var serviceResult = client.GetPromotionCodeByIDs(new GetPromotionCodesRequest()
                    {
                        PKIDList = promotionIds
                    });
                    if (serviceResult.Success)
                    {
                        promotionCodes = serviceResult.Result.ToList();
                    }
                }
                foreach (var code in promotionCodes)
                {
                    using (var client = new PromotionClient())
                    {
                        var serviceResult = client.UpdateUserPromotionCodeStatus(new UpdateUserPromotionCodeStatusRequest()
                        {
                            Status          = 3,
                            PromotionCodeId = code.Pkid,
                            OperationAuthor = user,
                            Channel         = "setting.tuhu.cn",
                            UserID          = Guid.Parse(code.UserId)
                        });
                        if (serviceResult.Exception != null)
                        {
                            Logger.Error(serviceResult.Exception);
                        }
                        result[code.Pkid] = serviceResult.Success && serviceResult.Result;
                    }
                }

                foreach (var item in result)
                {
                    if (item.Value)
                    {
                        var log = new
                        {
                            ObjectId    = $"PromotionDetail_{item.Key}",
                            ObjectType  = "VipPaintPackage",
                            BeforeValue = JsonConvert.SerializeObject(item),
                            AfterValue  = "",
                            Remark      = $"喷漆大客户作废券:{user}于{DateTime.Now.ToString("yyyy年MM月dd日 hh:mm")}作废券Id{item.Key}",
                            Creator     = user
                        };
                        LoggerManager.InsertLog("CommonConfigLog", log);
                        dbScopeManagerConfiguration.Execute(conn =>
                                                            DalVipPaintPackage.UpdatePromotionDetailRemark(conn, item.Key, $"{user}于{DateTime.Now.ToString("yyyy年MM月dd日 hh:mm")}作废此券"));
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("InvalidCodes", ex);
            }
            return(result);
        }