/// <summary>
        /// 删除金融标签
        /// </summary>
        /// <param name="id"></param>
        public void DeleteTag(string id)
        {
            var entity = _financeTagConfigRepository.Get(id);

            if (entity == null)
            {
                throw new Exception("id参数有误");
            }

            //删除前判断标签是否正在使用
            var list = _carFinancePolicyRepository.GetAllList(m => m.TAG_IDS.Contains(id));

            if (list?.Count > 0)
            {
                throw new Exception("该标签正在使用,不允许删除");
            }
            _financeTagConfigRepository.Delete(id);
        }
Beispiel #2
0
        /// <summary>
        /// 获取可选和已选标签
        /// </summary>
        /// <param name="code">车型编码</param>
        /// <param name="level">车型级别</param>
        /// <param name="subCode">车型细分编码</param>
        /// <param name="vin">车架号</param>
        /// <returns></returns>
        public Dictionary <string, IList <FinanceTagConfig> > GetOptionalTagList(string code, int level, string subCode, string vin = "")
        {
            #region 参数验证
            if (string.IsNullOrEmpty(code) || string.IsNullOrEmpty(level + ""))
            {
                throw new Exception("code和level参数不允许为空");
            }

            int result;
            if (int.TryParse(level + "", out result))
            {
                if (level < 3 || level > 4)
                {
                    throw new Exception("level参数有误");
                }
            }
            else
            {
                throw new Exception("level应为数字类型");
            }
            #endregion

            Dictionary <string, IList <FinanceTagConfig> > dic = new Dictionary <string, IList <FinanceTagConfig> >();
            try
            {
                var financeTagConfigs = _financeTagConfigRepository.GetAllList(m => m.BU_NO == AbpSession.ORG_NO && m.DEL_FLAG == 1);
                //string[] arr = (from tag in financeTagConfigs select tag.Id).ToArray();

                string where = string.Empty;
                //存车型数据
                IList <CarFinancePolicy> cartypelist     = null;
                IList <FinanceTagConfig> optionalTagList = null; //可选标签
                IList <FinanceTagConfig> usedTagList     = null; //已使用标签

                switch (level)
                {
                case 3:
                    cartypelist = _carFinancePolicyRepository.GetAllList(m => m.TYPE_CODE == code && m.TAG_LEVEL == 3);

                    if (cartypelist == null || cartypelist.Count == 0)
                    {
                        optionalTagList = financeTagConfigs;
                    }
                    else
                    {
                        CarFinancePolicy info = cartypelist.FirstOrDefault();
                        var tagids            = info.TAG_IDS.Replace("'", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        optionalTagList = (from tag in financeTagConfigs where !tagids.Contains(tag.Id) select tag).ToList();
                        usedTagList     = (from tag in financeTagConfigs where tagids.Contains(tag.Id) select tag).ToList();
                    }
                    break;

                case 4:
                    if (string.IsNullOrEmpty(vin))    //新车
                    {
                        where = string.Format("SUBTYPE_CODE='{0}'", subCode);
                        //车型细分信息
                        var subtypeInfos = _carFinancePolicyRepository.FirstOrDefault(m => m.SUBTYPE_CODE == subCode);

                        if (subtypeInfos != null)
                        {
                            var tagids = subtypeInfos.TAG_IDS.Replace("'", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            optionalTagList = (from tag in financeTagConfigs where !tagids.Contains(tag.Id) select tag).ToList();
                            usedTagList     = (from tag in financeTagConfigs where tagids.Contains(tag.Id) select tag).ToList();
                        }
                        else
                        {
                            cartypelist = _carFinancePolicyRepository.GetAllList(m => m.TYPE_CODE == code && m.TAG_LEVEL == 3);
                            if (cartypelist == null || cartypelist.Count == 0)
                            {
                                optionalTagList = financeTagConfigs;
                                break;
                            }
                            CarFinancePolicy cinfo = cartypelist[0];

                            var tagids = cinfo.TAG_IDS.Replace("'", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            optionalTagList = (from tag in financeTagConfigs where !tagids.Contains(tag.Id) select tag).ToList();
                            usedTagList     = (from tag in financeTagConfigs where tagids.Contains(tag.Id) select tag).ToList();
                        }
                    }
                    else    //二手车
                    {
                        //车型细分信息
                        var subtypeInfos = _carFinancePolicyRepository.FirstOrDefault(m => m.SUBTYPE_CODE == subCode && m.UDF1 == vin);

                        if (subtypeInfos != null)
                        {
                            var tagids = subtypeInfos.TAG_IDS.Replace("'", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            optionalTagList = (from tag in financeTagConfigs where !tagids.Contains(tag.Id) select tag).ToList();
                            usedTagList     = (from tag in financeTagConfigs where tagids.Contains(tag.Id) select tag).ToList();
                        }
                        else
                        {
                            optionalTagList = financeTagConfigs;
                            usedTagList     = null;
                        }
                    }
                    break;

                default:
                    break;
                }

                dic.Add("OPTIONAL", optionalTagList);
                dic.Add("USED", usedTagList);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(dic);
        }