/// <summary>
        /// 删除固定车延期模板
        /// </summary>
        /// <returns></returns>
        public bool DeletePermanentTemplate(PermanentTemplateModel model)
        {
            redisoperate.model = model;
            bool flag = databaseoperate.DeleteInDataBase(model);

            if (flag)
            {
                flag = redisoperate.DeleteInRedis();
            }
            return(flag);
        }
Example #2
0
        /// <summary>
        /// 新增/编辑-模板数据同步到主平台Fujica
        /// </summary>
        /// <param name="model">固定车延期模板</param>
        /// <param name="actionType">新增:1 修改:2 删除:3</param>
        /// <returns></returns>
        private bool SetTemplateDataToFujica(PermanentTemplateModel model, int actionType)
        {
            //1、根据不同的计费方式将数据进行格式化
            string templateStr = TemplateDataFormatStr(model);

            //2、格式化后数据同步到主平台
            if (!string.IsNullOrEmpty(templateStr))
            {
                return(TemplateDataToFujica(model.CarTypeGuid, actionType, templateStr));
            }
            return(false);
        }
        /// <summary>
        /// 设置固定车延期模板
        /// </summary>
        /// <returns></returns>
        public bool SetPermanentTemplate(PermanentTemplateModel model)
        {
            redisoperate.model = model;
            bool flag = databaseoperate.SaveToDataBase(model);

            if (flag)
            {
                //此时不需要判断redis是否成功,因为修改时redis一定会返回false
                redisoperate.SaveToRedis();
            }
            return(flag);
        }
Example #4
0
        /// <summary>
        /// 模板数据格式化
        /// </summary>
        /// <param name="model">固定车延期模板</param>
        /// <returns></returns>
        private string TemplateDataFormatStr(PermanentTemplateModel model)
        {
            //示例:MAD00001000M00010000Y00000000
            //说明:M:固定卡标识 A: 卡类(B、C、D)  D00000000: 天金额(单位: 分)  M00000000: 月金额(单位: 分)  Y00000000: 年金额(单位: 分)
            //*系统目前只控制月份字段内容
            string templateStr = "MA";
            string dayStr      = "D00000000";
            string monthStr    = "M" + Convert.ToInt32(model.Amount * 100).ToString().PadLeft(8, '0');
            string yearStr     = "Y00000000";

            templateStr = templateStr + dayStr + monthStr + yearStr;
            return(templateStr);
        }
Example #5
0
        /// <summary>
        /// 设置固定车延期模板
        /// </summary>
        /// <returns></returns>
        public bool SetPermanentTemplate(PermanentTemplateModel model)
        {
            PermanentTemplateModel content = GetPermanentTemplate(model.CarTypeGuid);
            //是新增还是编辑操作
            bool isEdit = false;

            if (content != null)
            {
                //验证数据库值和传输内容是否一致
                if (content.ProjectGuid != model.ProjectGuid)
                {
                    LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_PARAM_ERROR_PROJECTGUID.GetDesc();
                    return(false);
                }
                if (content.ParkCode != model.ParkCode)
                {
                    LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_PARAM_ERROR_PARKINGCODE.GetDesc();
                    return(false);
                }
                isEdit = true;
            }

            bool flag = _iPermanentTemplateContext.SetPermanentTemplate(model);

            if (!flag)
            {
                LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_SAVE_BILLING.GetDesc();
                return(false); //数据库不成功就不要往下执行了
            }

            //将数据同步到主平台Fujica Api
            bool toFujicaResult = false;

            if (isEdit)
            {
                toFujicaResult = EditTemplateDataToFujica(model);
            }
            else
            {
                toFujicaResult = AddTemplateDataToFujica(model);
            }
            if (!toFujicaResult)
            {
                LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_SAVE_BILLING_TOFUJICA.GetDesc();
            }
            return(toFujicaResult);
        }
Example #6
0
        /// <summary>
        /// 删除车类
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool DeleteCarType(CarTypeModel model)
        {
            bool flag = false;

            //删除计费模板
            if (model.CarType == CarTypeEnum.TempCar || model.CarType == CarTypeEnum.ValueCar)
            {
                //如果当前车类为临时车或者储值车
                //判断该车类是否已创建计费模板
                BillingTemplateModel billingModel = GetBillingTemplate(model.Guid);
                if (billingModel != null)
                {
                    //计费模板存在则需要先删除计费模板
                    flag = DeleteBillingTemplate(billingModel);
                    if (!flag)
                    {
                        return(flag);
                    }
                }
            }
            else
            {
                //删除固定车延期模板
                PermanentTemplateModel permanentModel = GetPermanentTemplate(model.Guid);
                if (permanentModel != null)
                {
                    //如果存在则删除固定车延期模板
                    flag = DeletePermanentTemplate(permanentModel);
                    if (!flag)
                    {
                        return(flag);
                    }
                }
            }

            flag = _iCarTypeContext.DeleteCarType(model);
            if (!flag)
            {
                LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_DELETE_CARTYPE.GetDesc();
                return(false);
            }
            return(flag);
        }
Example #7
0
        /// <summary>
        /// 删除固定车延期模板
        /// </summary>
        /// <returns></returns>
        public bool DeletePermanentTemplate(PermanentTemplateModel model)
        {
            bool flag = _iPermanentTemplateContext.DeletePermanentTemplate(model);

            if (!flag)
            {
                LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_DELETE_BILLING.GetDesc();
                return(false); //数据库不成功就不要往下执行了
            }

            //将数据同步到主平台Fujica Api
            bool toFujicaResult = DeleteTemplateDataToFujica(model);

            if (!toFujicaResult)
            {
                LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_SAVE_BILLING_TOFUJICA.GetDesc();
            }
            return(toFujicaResult);
        }
        /// <summary>
        /// 获取固定车延期模板
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public PermanentTemplateModel GetPermanentTemplate(string cartypeguid)
        {
            PermanentTemplateModel model = null;

            redisoperate.model = new PermanentTemplateModel()
            {
                CarTypeGuid = cartypeguid
            };
            model = redisoperate.GetFromRedis();

            //从数据库读
            if (model == null)
            {
                model = databaseoperate.GetFromDataBase(cartypeguid);
                //缓存到redis
                if (model != null)
                {
                    redisoperate.model = model;
                    redisoperate.SaveToRedis();
                }
            }

            return(model);
        }
Example #9
0
 /// <summary>
 /// 删除-模板数据同步到主平台Fujica
 /// </summary>
 /// <param name="model">固定车延期模板</param>
 /// <returns></returns>
 private bool DeleteTemplateDataToFujica(PermanentTemplateModel model)
 {
     return(SetTemplateDataToFujica(model, 3));
 }
Example #10
0
 /// <summary>
 /// 编辑-模板数据同步到主平台Fujica
 /// </summary>
 /// <param name="model">固定车延期模板</param>
 /// <returns></returns>
 private bool EditTemplateDataToFujica(PermanentTemplateModel model)
 {
     return(SetTemplateDataToFujica(model, 2));
 }
Example #11
0
        /// <summary>
        /// 获取固定车延期模板
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public PermanentTemplateModel GetPermanentTemplate(string cartypeguid)
        {
            PermanentTemplateModel model = _iPermanentTemplateContext.GetPermanentTemplate(cartypeguid);

            return(model);
        }