示例#1
0
        /// <summary>
        /// 获取单个浮动设置模型
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public BaoYangResultEntity <CouponActivityConfigV2Model> GetCouponActivityConfig(int id)
        {
            var result = new BaoYangResultEntity <CouponActivityConfigV2Model>()
            {
                Status = false
            };

            try
            {
                dbScopeManagerConfigurationRead.Execute(conn =>
                {
                    var config = DalCouponActivityConfigV2.GetCouponActivityConfigById(conn, id);
                    if (config == null)
                    {
                        result.Status = true;
                        result.Msg    = "没有查询到数据";
                    }
                    else
                    {
                        config.ChannelConfigs = DalCouponActivityConfigV2.GetChannelConfigs(conn, config.Id, string.Empty);
                        result.Status         = true;
                        result.Data           = config;
                    }
                });
            }
            catch (Exception ex)
            {
                result.Status = false;
                result.Msg    = "程序遇见错误,请联系管理员";
                Logger.Error("GetCouponActivityConfigs", ex);
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// 获取蓄电池/加油卡浮动配置分页列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public BaoYangResultEntity <Tuple <int, List <CouponActivityConfigV2Model> > > GetCouponActivityConfigs(CouponActivityConfigPageRequestModel request)
        {
            var result = new BaoYangResultEntity <Tuple <int, List <CouponActivityConfigV2Model> > >()
            {
                Status = false
            };

            try
            {
                dbScopeManagerConfigurationRead.Execute(conn =>
                {
                    var tupleConfigs = DalCouponActivityConfigV2.GetCouponActivityConfigs(conn, request);
                    if (tupleConfigs == null || !tupleConfigs.Item2.Any() || tupleConfigs.Item1 <= 0)
                    {
                        result.Status = true;
                        result.Msg    = "未查找到数据";
                    }
                    else
                    {
                        var ChannelConfigs   = DalCouponActivityConfigV2.GetChannelConfigs(conn, tupleConfigs.Item2.Select(x => x.Id).ToList());
                        var ChannelConfigDic = ChannelConfigs.GroupBy(x => x.ConfigId).Select(x => new { x.Key, x }).ToDictionary(k => k.Key, v => v.x);
                        foreach (var item in tupleConfigs.Item2)
                        {
                            item.Channels = item.Channel == null ? new List <string>() : item.Channel.Split(',').ToList();
                            if (ChannelConfigDic.ContainsKey(item.Id))
                            {
                                item.ChannelConfigs = ChannelConfigDic[item.Id].ToList();
                            }
                        }
                        result.Status = true;
                        result.Data   = tupleConfigs;
                    }
                });
            }
            catch (Exception ex)
            {
                result.Status = false;
                result.Msg    = "程序遇见错误,请联系管理员";
                Logger.Error("GetCouponActivityConfigs", ex);
            }
            return(result);
        }