예제 #1
0
        /// <summary>
        /// 注销 从数据库删除
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool DeleteCard(CardServiceModel model, CarTypeEnum carType)
        {
            //_redisoperate.model = model;
            bool flag = false;

            switch (carType)
            {
            case CarTypeEnum.TempCar:
                flag = _tempCardDatabaseoperate.DeleteInDataBase(model);
                break;

            case CarTypeEnum.MonthCar:
                flag = _monthCardDatabaseoperate.DeleteInDataBase(model);
                break;

            case CarTypeEnum.ValueCar:
                flag = _valueCardDatabaseoperate.DeleteInDataBase(model);
                break;

            case CarTypeEnum.VIPCar:
                flag = _monthCardDatabaseoperate.DeleteInDataBase(model);
                break;
            }
            //if (flag)
            //{
            //    flag = _redisoperate.DeleteInRedis(); //数据库不成功就不要往下执行了
            //}
            return(flag);
        }
예제 #2
0
        /// <summary>
        /// 获取某卡
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public CardServiceModel GetCard(string carNo, string parkCode, CarTypeEnum carType)
        {
            try
            {
                CardServiceModel model = null;
                string           key   = parkCode + Convert.ToBase64String(Encoding.UTF8.GetBytes(carNo));
                switch (carType)
                {
                case CarTypeEnum.TempCar:
                    model = _tempCardDatabaseoperate.GetFromDataBase(key);
                    break;

                case CarTypeEnum.MonthCar:
                    model = _monthCardDatabaseoperate.GetFromDataBase(key);
                    break;

                case CarTypeEnum.ValueCar:
                    model = _valueCardDatabaseoperate.GetFromDataBase(key);
                    break;

                case CarTypeEnum.VIPCar:
                    model = _monthCardDatabaseoperate.GetFromDataBase(key);
                    break;
                }
                return(model);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// 解锁 可以出场、入场
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UnLockedCard(CardServiceModel model, CarTypeEnum carType)
        {
            model.Locked = false;

            bool flag = false;

            switch (carType)
            {
            case CarTypeEnum.TempCar:
                flag = _TempCardExtendatabaseoperate.ToggleValue(model);
                break;

            case CarTypeEnum.MonthCar:
                flag = _MonthCardExtendatabaseoperate.ToggleValue(model);
                break;

            case CarTypeEnum.ValueCar:
                flag = _ValueCardExtendatabaseoperate.ToggleValue(model);
                break;

            case CarTypeEnum.VIPCar:
                flag = _MonthCardExtendatabaseoperate.ToggleValue(model);
                break;
            }
            //if (flag)
            //{
            //    _redisoperate.model = model;
            //    _redisoperate.SaveToRedis();
            //}
            return(flag);
        }
예제 #4
0
 /// <summary>
 /// 保存储值卡数据到redis
 /// </summary>
 /// <param name="model"></param>
 /// <param name="m_ilogger"></param>
 /// <param name="m_serializer"></param>
 /// <returns></returns>
 public static bool SaveValueCarToRedis(CardServiceModel model, ILogger m_ilogger, ISerializer m_serializer)
 {
     try
     {
         IDatabase    db      = RedisHelper.GetDatabase(0);
         CarTypeModel cartype = m_serializer.Deserialize <CarTypeModel>(db.HashGet("CarTypeList", model.CarTypeGuid));
         if (cartype.CarType == CarTypeEnum.ValueCar)
         {
             //储值车
             string        hashkey       = model.ParkCode + Convert.ToBase64String(Encoding.UTF8.GetBytes(model.CarNo));
             ValueCarModel monthcarmodel = new ValueCarModel()
             {
                 ProjectGuid      = model.ProjectGuid,
                 ParkCode         = model.ParkCode,
                 CarOwnerName     = model.CarOwnerName,
                 Mobile           = model.Mobile,
                 CarNo            = model.CarNo,
                 CarTypeGuid      = model.CarTypeGuid,
                 Enable           = model.Enable,
                 StartDate        = model.StartDate,
                 Locked           = model.Locked,
                 Balance          = model.Balance,
                 DrivewayGuidList = model.DrivewayGuidList
             };
             return(db.HashSet("PermanentCarList", hashkey, m_serializer.Serialize(monthcarmodel)));
         }
         return(false);
     }
     catch (Exception ex)
     {
         m_ilogger.LogFatal(LoggerLogicEnum.Tools, "", model.ParkCode, model.CarNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager.SaveValueCarToRedis", "保存储值车数据异常", ex.ToString());
         return(false);
     }
 }
예제 #5
0
        /// <summary>
        /// 开卡
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddCard(CardServiceModel model, CarTypeEnum carType)
        {
            bool flag = false;

            switch (carType)
            {
            case CarTypeEnum.TempCar:
                flag = _tempCardDatabaseoperate.SaveToDataBase(model);
                break;

            case CarTypeEnum.MonthCar:
                flag = _monthCardDatabaseoperate.SaveToDataBase(model);
                break;

            case CarTypeEnum.ValueCar:
                flag = _valueCardDatabaseoperate.SaveToDataBase(model);
                break;

            case CarTypeEnum.VIPCar:
                flag = _monthCardDatabaseoperate.SaveToDataBase(model);
                break;
            }
            return(flag);

            //if (!flag) return false; //数据库不成功就不要往下执行了
            //_redisoperate.model = model;
            //return _redisoperate.SaveToRedis();
        }
예제 #6
0
        /// <summary>
        /// 修改卡信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool ModifyCard(CardServiceModel model, CarTypeEnum carType)
        {
            bool flag = false;

            switch (carType)
            {
            case CarTypeEnum.TempCar:
                flag = _tempCardDatabaseoperate.SaveToDataBase(model);
                break;

            case CarTypeEnum.MonthCar:
                flag = _monthCardDatabaseoperate.SaveToDataBase(model);
                break;

            case CarTypeEnum.ValueCar:
                flag = _valueCardDatabaseoperate.SaveToDataBase(model);
                break;

            case CarTypeEnum.VIPCar:
                flag = _monthCardDatabaseoperate.SaveToDataBase(model);
                break;
            }
            //if (flag)
            //{
            //    _redisoperate.model = model;
            //    _redisoperate.SaveToRedis();
            //}
            return(flag);
        }
예제 #7
0
        public IHttpActionResult MonthCardRenew(MonthCardServiceRequest model)
        {
            ResponseBaseCommon response = new ResponseBaseCommon()
            {
                IsSuccess      = true,
                MessageCode    = (int)ApiBaseErrorCode.API_SUCCESS,
                MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString()
            };

            if (string.IsNullOrWhiteSpace(model.ParkingCode) ||
                string.IsNullOrWhiteSpace(model.ProjectGuid) ||
                string.IsNullOrWhiteSpace(model.PayStyle) ||
                string.IsNullOrWhiteSpace(model.CarTypeGuid) ||
                model.PayAmount < 0 ||
                string.IsNullOrWhiteSpace(model.CarNo) ||
                model.StartDate == default(DateTime) ||
                model.EndDate == default(DateTime))
            {
                response.IsSuccess      = false;
                response.MessageCode    = (int)ApiBaseErrorCode.API_PARAM_ERROR;
                response.MessageContent = "必要参数缺失,请检查";
                Logger.LogWarn(LoggerLogicEnum.Interface, "", "", "",
                               "Fujica.com.cn.Interface.Management.Controllers.CardServiceController.MonthCardRenew",
                               string.Format("月卡延期必要参数不全,入参:{0}", Serializer.Serialize(model)));
                return(Ok(response));
            }

            if (model.StartDate.Date != DateTime.Now.Date)
            {
                model.StartDate = DateTime.Now;                                            //延期开始日期必须是当天
            }
            CardServiceModel content = new CardServiceModel()
            {
                ProjectGuid      = model.ProjectGuid,
                ParkCode         = model.ParkingCode,
                CarNo            = model.CarNo,
                StartDate        = model.StartDate,
                EndDate          = model.EndDate,
                PayAmount        = model.PayAmount,
                PayStyle         = model.PayStyle,
                CarTypeGuid      = model.CarTypeGuid,
                PrimaryEndDate   = model.PrimaryEndDate,
                RechargeOperator = model.RechargeOperator
            };

            //需要加上报表存储逻辑

            bool flag = _cardServiceManager.RenewCard(content);

            if (!flag)
            {
                response.IsSuccess      = false;
                response.MessageCode    = (int)ApiCardServiceErrorCode.API_DATA_SAVE_ERROR;
                response.MessageContent = _cardServiceManager.LastErrorDescribe;
            }
            return(Ok(response));
        }
예제 #8
0
        public IHttpActionResult ModifyValueCard(ModifyCardServiceRequest model)
        {
            ResponseBaseCommon response = new ResponseBaseCommon()
            {
                IsSuccess      = true,
                MessageCode    = (int)ApiBaseErrorCode.API_SUCCESS,
                MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString()
            };

            if (string.IsNullOrWhiteSpace(model.ParkingCode) ||
                string.IsNullOrWhiteSpace(model.ProjectGuid) ||
                string.IsNullOrWhiteSpace(model.CarOwnerName) ||
                string.IsNullOrWhiteSpace(model.Mobile) ||
                string.IsNullOrWhiteSpace(model.CarNo) ||
                string.IsNullOrWhiteSpace(model.DrivewayGuidList) ||
                string.IsNullOrWhiteSpace(model.CarTypeGuid))
            {
                response.IsSuccess      = false;
                response.MessageCode    = (int)ApiBaseErrorCode.API_PARAM_ERROR;
                response.MessageContent = "必要参数缺失,请检查";
                Logger.LogWarn(LoggerLogicEnum.Interface, "", "", "",
                               "Fujica.com.cn.Interface.Management.Controllers.CardServiceController.ModifyValueCard",
                               string.Format("储值卡修改必要参数不全,入参:{0}", Serializer.Serialize(model)));
                return(Ok(response));
            }

            string[] drivewayguidarray = drivewayguidarray = model.DrivewayGuidList.Split(',');

            CardServiceModel content = new CardServiceModel()
            {
                ProjectGuid      = model.ProjectGuid,
                ParkCode         = model.ParkingCode,
                CarOwnerName     = model.CarOwnerName,
                CarNo            = model.CarNo,
                CarTypeGuid      = model.CarTypeGuid,
                DrivewayGuidList = drivewayguidarray.ToList().FindAll(o => o != ""),
                Mobile           = model.Mobile,
                RechargeOperator = model.RechargeOperator
            };

            bool flag = _cardServiceManager.ModifyCard(content);

            if (!flag)
            {
                response.IsSuccess      = false;
                response.MessageCode    = (int)ApiCardServiceErrorCode.API_DATA_SAVE_ERROR;
                response.MessageContent = _cardServiceManager.LastErrorDescribe;
            }
            return(Ok(response));
        }
예제 #9
0
        public IHttpActionResult CancelCar(CancelCardServiceRequest model)
        {
            ResponseBaseCommon response = new ResponseBaseCommon()
            {
                IsSuccess      = true,
                MessageCode    = (int)ApiBaseErrorCode.API_SUCCESS,
                MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString()
            };

            if (string.IsNullOrWhiteSpace(model.ParkingCode) ||
                string.IsNullOrWhiteSpace(model.ProjectGuid) ||
                string.IsNullOrWhiteSpace(model.CarNo) ||
                model.RefundAmount < 0)
            {
                response.IsSuccess      = false;
                response.MessageCode    = (int)ApiBaseErrorCode.API_PARAM_ERROR;
                response.MessageContent = "必要参数缺失,请检查";
                Logger.LogWarn(LoggerLogicEnum.Interface, "", "", "",
                               "Fujica.com.cn.Interface.Management.Controllers.CardServiceController.CarLocked",
                               string.Format("车辆注销时必要参数不全,入参:{0}", Serializer.Serialize(model)));
                return(Ok(response));
            }

            CardServiceModel content = new CardServiceModel()
            {
                ProjectGuid      = model.ProjectGuid,
                ParkCode         = model.ParkingCode,
                CarNo            = model.CarNo,
                PayAmount        = model.RefundAmount,
                Remark           = model.Remark,
                RechargeOperator = model.RechargeOperator
            };

            //需要加上报表存储逻辑
            bool flag = _cardServiceManager.DeleteCard(content);

            if (!flag)
            {
                response.IsSuccess      = false;
                response.MessageCode    = (int)ApiCardServiceErrorCode.API_DATA_SAVE_ERROR;
                response.MessageContent = _cardServiceManager.LastErrorDescribe;
            }
            return(Ok(response));
        }
예제 #10
0
        /// <summary>
        /// 发送储值卡数据到Fujica
        /// </summary>
        /// <returns></returns>
        private static bool SendValueCarToFujica(CardServiceModel model, string idx)
        {
            RequestFujicaStandard requestFujica = new RequestFujicaStandard();
            //请求方法(新增、修改、删除全用同一个接口)
            string servername = "/BasicResource/ApiUpdateValueCardInfo";
            //请求参数
            Dictionary <string, object> dicParam = new Dictionary <string, object>();

            dicParam["ParkingCode"] = model.ParkCode;
            dicParam["CarType"]     = idx;
            dicParam["CarNo"]       = model.CarNo;
            dicParam["CardNo"]      = "";
            dicParam["Phone"]       = model.Mobile;
            dicParam["CardStatus"]  = model.Enable ? 1 : 2;
            dicParam["Balance"]     = model.Balance;

            //返回fujica api计费模板添加、修改请求结果
            return(requestFujica.RequestInterfaceV2(servername, dicParam));
        }
예제 #11
0
        /// <summary>
        /// 发送储值卡数据到相机
        /// </summary>
        /// <returns></returns>
        private static bool SendValueCarToCameras(CardServiceModel model, ILogger m_ilogger, ISerializer m_serializer)
        {
            ValueCardModel sendmodel = new ValueCardModel()
            {
                CarOwnerName = model.CarOwnerName,
                CarNo        = model.CarNo,
                Delete       = model.Enable ? false : true,
                CarTypeGuid  = model.CarTypeGuid,
                Locked       = false,
                Balance      = model.Balance
            };

            CommandEntity <ValueCardModel> entity = new CommandEntity <ValueCardModel>()
            {
                command = BussineCommand.ValueCar,
                idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                message = sendmodel
            };

            RabbitMQSender rabbitMq = new RabbitMQSender(m_ilogger, m_serializer);

            return(rabbitMq.SendMessageForRabbitMQ("发送储值卡命令", m_serializer.Serialize(entity), entity.idMsg, model.ParkCode));
        }
예제 #12
0
        /// <summary>
        /// 发送月卡数据到Fujica
        /// </summary>
        /// <returns></returns>
        private static bool SendMonthCarToFujica(CardServiceModel model, string idx)
        {
            string beginDt = model.StartDate.Date.AddHours(0).AddMinutes(0).AddSeconds(0).ToString("yyyy-MM-dd HH:mm:ss"); //开始时间从0分秒
            string endDt   = model.EndDate.Date.AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss");                 //结束时间截止到23:59:59
            RequestFujicaStandard requestFujica = new RequestFujicaStandard();
            //请求方法
            string servername = "/BasicResource/ApiUpdateMonthCardInfo";

            //请求参数
            Dictionary <string, object> dicParam = new Dictionary <string, object>();

            dicParam["ParkingCode"] = model.ParkCode;
            dicParam["CarType"]     = idx;
            dicParam["CarNo"]       = model.CarNo;
            dicParam["CardNo"]      = "";
            dicParam["Phone"]       = model.Mobile;
            dicParam["CardStatus"]  = 1;

            dicParam["StartDate"] = beginDt;
            dicParam["EndDate"]   = endDt;

            //返回fujica api计费模板添加、修改请求结果
            return(requestFujica.RequestInterfaceV2(servername, dicParam));
        }
예제 #13
0
        /// <summary>
        /// 发送月卡数据到相机
        /// </summary>
        /// <returns></returns>
        private static bool SendMonthCarToCameras(CardServiceModel model, ILogger m_ilogger, ISerializer m_serializer)
        {
            MonthCardModel sendmodel = new MonthCardModel()
            {
                CarOwnerName = model.CarOwnerName,
                CarNo        = model.CarNo,
                Delete       = model.Enable ? false : true,
                CarTypeGuid  = model.CarTypeGuid,
                Locked       = model.Locked,
                StartDate    = model.StartDate.Date.AddHours(0).AddMinutes(0).AddSeconds(0).ToString("yyyy-MM-dd HH:mm:ss"),
                EndDate      = model.EndDate.Date.AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss") //结束时间截止到23:59:59
            };

            CommandEntity <MonthCardModel> entity = new CommandEntity <MonthCardModel>()
            {
                command = BussineCommand.MonthCar,
                idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                message = sendmodel
            };

            RabbitMQSender rabbitMq = new RabbitMQSender(m_ilogger, m_serializer);

            return(rabbitMq.SendMessageForRabbitMQ("发送月卡命令", m_serializer.Serialize(entity), entity.idMsg, model.ParkCode));
        }
예제 #14
0
 /// <summary>
 /// 查询数据库卡务信息
 /// </summary>
 /// <param name="identifying"></param>
 /// <param name="m_ilogger"></param>
 /// <param name="m_serializer"></param>
 /// <returns></returns>
 public static CardServiceModel GetCard(string identifying, ILogger m_ilogger, ISerializer m_serializer)
 {
     try
     {
         //优先查月卡表
         DataTable table = new DataTable();
         table = dbhelper.ExecuteDataTable(string.Format("select * from t_monthcard where identifying='{0}'", identifying));
         if (table.Rows.Count > 0)
         {
             CardServiceModel model = new CardServiceModel();
             model.ProjectGuid      = (string)table.Rows[0]["projectGuid"];
             model.ParkCode         = (string)table.Rows[0]["parkCode"];
             model.CarNo            = (string)table.Rows[0]["carNo"];
             model.CarOwnerName     = (string)table.Rows[0]["carOwnerName"];
             model.Mobile           = (string)table.Rows[0]["mobile"];
             model.DrivewayGuidList = m_serializer.Deserialize <List <string> >(table.Rows[0]["drivewayListContent"].ToString());
             model.CarTypeGuid      = (string)table.Rows[0]["carTypeGuid"];
             model.Remark           = table.Rows[0]["remark"].ToString();
             model.Enable           = (table.Rows[0]["enable"].ToString() == "0" ? false : true);
             model.Locked           = (table.Rows[0]["locked"].ToString() == "0" ? false : true);
             if (!string.IsNullOrWhiteSpace(table.Rows[0]["startDate"].ToString()))
             {
                 model.StartDate = DateTime.Parse(table.Rows[0]["startDate"].ToString());
             }
             if (!string.IsNullOrWhiteSpace(table.Rows[0]["endDate"].ToString()))
             {
                 model.EndDate = DateTime.Parse(table.Rows[0]["endDate"].ToString());
             }
             if (!string.IsNullOrWhiteSpace(table.Rows[0]["pauseDate"].ToString()))
             {
                 model.PauseDate = DateTime.Parse(table.Rows[0]["pauseDate"].ToString());
             }
             if (!string.IsNullOrWhiteSpace(table.Rows[0]["continueDate"].ToString()))
             {
                 model.ContinueDate = DateTime.Parse(table.Rows[0]["continueDate"].ToString());
             }
             model.Balance = 0;
             return(model);
         }
         else
         {
             //没有则查储值卡表
             table = dbhelper.ExecuteDataTable(string.Format("select * from t_valuecard where identifying='{0}'", identifying));
             if (table.Rows.Count > 0)
             {
                 CardServiceModel model = new CardServiceModel();
                 model.ProjectGuid      = (string)table.Rows[0]["projectGuid"];
                 model.ParkCode         = (string)table.Rows[0]["parkCode"];
                 model.CarNo            = (string)table.Rows[0]["carNo"];
                 model.CarOwnerName     = (string)table.Rows[0]["carOwnerName"];
                 model.Mobile           = (string)table.Rows[0]["mobile"];
                 model.DrivewayGuidList = m_serializer.Deserialize <List <string> >(table.Rows[0]["drivewayListContent"].ToString());
                 model.CarTypeGuid      = (string)table.Rows[0]["carTypeGuid"];
                 model.Remark           = table.Rows[0]["remark"].ToString();
                 model.Enable           = (table.Rows[0]["enable"].ToString() == "0" ? false : true);
                 model.Locked           = (table.Rows[0]["locked"].ToString() == "0" ? false : true);
                 model.Balance          = (decimal)table.Rows[0]["balance"];
                 if (!string.IsNullOrWhiteSpace(table.Rows[0]["startDate"].ToString()))
                 {
                     model.StartDate = DateTime.Parse(table.Rows[0]["startDate"].ToString());
                 }
                 return(model);
             }
         }
     }
     catch (Exception ex)
     {
         m_ilogger.LogFatal(LoggerLogicEnum.Tools, "", "", "", "Fujica.com.cn.MonitorServiceClient.PayDataManager.GetCard", string.Format("获取卡信息时发生异常,入参:{0}", identifying), ex.ToString());
     }
     return(null);
 }
예제 #15
0
        /// <summary>
        /// 保存储值卡数据到数据库
        /// </summary>
        /// <param name="model"></param>
        /// <param name="m_ilogger"></param>
        /// <param name="m_serializer"></param>
        /// <returns></returns>
        public static bool SaveValueCarToDB(CardServiceModel model, ILogger m_ilogger, ISerializer m_serializer)
        {
            try
            {
                int cartype = (int)dbhelper.ExecuteScalar(string.Format("select carType from t_cartype where guid='{0}'", model.CarTypeGuid));
                if (cartype == 2)
                {
                    //储值车
                    string commandtext = @"replace into t_valuecard(projectGuid,identifying,parkCode,carNo,carOwnerName,mobile,carTypeGuid,remark,enable,locked,startDate,balance,drivewayListContent)
                                    values(@projectGuid,@identifying,@parkCode,@carNo,@carOwnerName,@mobile,@carTypeGuid,@remark,@enable,@locked,@startDate,@balance,@drivewayListContent)";

                    DbParameter projectGuid = dbhelper.factory.CreateParameter();
                    projectGuid.ParameterName = "@projectGuid";
                    projectGuid.Value         = model.ProjectGuid;

                    DbParameter identifying = dbhelper.factory.CreateParameter();
                    identifying.ParameterName = "@identifying";
                    identifying.Value         = model.ParkCode + Convert.ToBase64String(Encoding.UTF8.GetBytes(model.CarNo));

                    DbParameter parkCode = dbhelper.factory.CreateParameter();
                    parkCode.ParameterName = "@parkCode";
                    parkCode.Value         = model.ParkCode;

                    DbParameter carNo = dbhelper.factory.CreateParameter();
                    carNo.ParameterName = "@carNo";
                    carNo.Value         = model.CarNo;

                    DbParameter carOwnerName = dbhelper.factory.CreateParameter();
                    carOwnerName.ParameterName = "@carOwnerName";
                    carOwnerName.Value         = model.CarOwnerName;

                    DbParameter mobile = dbhelper.factory.CreateParameter();
                    mobile.ParameterName = "@mobile";
                    mobile.Value         = model.Mobile;

                    DbParameter carTypeGuid = dbhelper.factory.CreateParameter();
                    carTypeGuid.ParameterName = "@carTypeGuid";
                    carTypeGuid.Value         = model.CarTypeGuid;

                    DbParameter remark = dbhelper.factory.CreateParameter();
                    remark.ParameterName = "@remark";
                    remark.Value         = model.Remark;

                    DbParameter enable = dbhelper.factory.CreateParameter();
                    enable.ParameterName = "@enable";
                    enable.Value         = model.Enable;

                    DbParameter locked = dbhelper.factory.CreateParameter();
                    locked.ParameterName = "@locked";
                    locked.Value         = model.Locked;

                    DbParameter startDate = dbhelper.factory.CreateParameter();
                    startDate.ParameterName = "@startDate";
                    startDate.Value         = model.StartDate.ToString("yyyy-MM-dd HH:mm:ss");

                    DbParameter balance = dbhelper.factory.CreateParameter();
                    balance.ParameterName = "@balance";
                    balance.Value         = model.Balance;

                    DbParameter drivewayListContent = dbhelper.factory.CreateParameter();
                    drivewayListContent.ParameterName = "@drivewayListContent";
                    drivewayListContent.Value         = m_serializer.Serialize(model.DrivewayGuidList ?? new List <string>());

                    DbParameter[] parameter = new DbParameter[] { projectGuid, identifying, parkCode, carNo, carOwnerName, mobile, carTypeGuid, remark, enable, locked, startDate, balance, drivewayListContent };
                    return(dbhelper.ExecuteNonQuery(commandtext, parameter) > 0 ? true : false);
                }
            }
            catch (Exception ex)
            {
                m_ilogger.LogFatal(LoggerLogicEnum.Tools, "", model.ParkCode, model.CarNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager.SaveValueCarToDB", string.Format("保存储值卡信息时发生异常,入参:{0}", m_serializer.Serialize(model)), ex.ToString());
            }
            return(false);
        }
예제 #16
0
        public static ResponseCommon DataHandle(ILogger m_ilogger, ISerializer m_serializer)
        {
            ResponseCommon response = new ResponseCommon()
            {
                IsSuccess = false,
                MsgType   = MsgType.PayCard
            };

            IDatabase db;

            db = RedisHelper.GetDatabase(4);
            string redisContent = db.ListLeftPop(mq_ListKey);

            if (string.IsNullOrEmpty(redisContent))
            {
                response.MessageContent = "redis数据库读取值为空";
                return(response);
            }
            response.RedisContent = redisContent;
            m_ilogger.LogInfo(LoggerLogicEnum.Tools, "", "", "", "Fujica.com.cn.MonitorServiceClient.PayDataManager", "支付数据接收成功.原始数据:" + redisContent);

            IssuedRecord recordModel = m_serializer.Deserialize <IssuedRecord>(redisContent);

            if (recordModel == null)
            {
                response.MessageContent = "redis数据库读取值转换成实体失败:";
                return(response);
            }
            if (string.IsNullOrEmpty(recordModel.ParkingCode) ||
                string.IsNullOrEmpty(recordModel.CarNo) ||
                recordModel.CardType <= 0 ||
                string.IsNullOrEmpty(recordModel.TradeNo)
                //|| string.IsNullOrEmpty(inmodel.Remark)
                )
            {
                response.MessageContent = "redis数据转换成实体后必要参数缺失";
                return(response);
            }
            if (recordModel.CardType == 1)
            {
                if (recordModel.RenewDay <= 0 && recordModel.RenewDayType <= 0)
                {
                    response.MessageContent = "redis数据转换成实体后必要参数缺失";
                    return(response);
                }
            }
            else if (recordModel.CardType == 2 && recordModel.Price <= 0)
            {
                response.MessageContent = "redis数据转换成实体后必要参数缺失";
                return(response);
            }

            db = RedisHelper.GetDatabase(0);
            //判断当前订单号,是否已执行过
            string mqPayDataListKey = "PayDataList:" + recordModel.ParkingCode + ":" + DateTime.Now.ToString("yyyyMMdd");

            if (db.HashExists(mqPayDataListKey, recordModel.TradeNo))
            {
                response.MessageContent = "当前订单记录重复执行";
                m_ilogger.LogInfo(LoggerLogicEnum.Tools, recordModel.TradeNo, recordModel.ParkingCode, recordModel.CardNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager", $"TradeNo:{recordModel.TradeNo} 当前订单记录重复执行");
                return(response);
            }
            else
            {
                db.HashSet(mqPayDataListKey, recordModel.TradeNo, redisContent);
                db.KeyExpire(mqPayDataListKey, DateTime.Now.AddDays(1).Date);
            }

            string           hashkey   = recordModel.ParkingCode + Convert.ToBase64String(Encoding.UTF8.GetBytes(recordModel.CarNo));
            CardServiceModel cardModel = m_serializer.Deserialize <CardServiceModel>(db.HashGet("PermanentCarList", hashkey));

            if (cardModel == null)
            {
                cardModel = GetCard(hashkey, m_ilogger, m_serializer);
                if (cardModel == null)
                {
                    response.MessageContent = "根据车场编号和车牌号,读取卡务模型为空";
                    m_ilogger.LogError(LoggerLogicEnum.Tools, recordModel.TradeNo, recordModel.ParkingCode, recordModel.CardNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager", "根据车场编号和车牌号,读取卡务模型为空");
                    return(response);
                }
            }

            CarTypeModel cartypemodel = m_serializer.Deserialize <CarTypeModel>(db.HashGet("CarTypeList", cardModel.CarTypeGuid));

            if (cartypemodel == null)
            {
                response.MessageContent = "根据车类Guid,读取车类模型为空";
                m_ilogger.LogError(LoggerLogicEnum.Tools, recordModel.TradeNo, recordModel.ParkingCode, recordModel.CardNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager", "根据车类Guid,读取车类模型为空");
                return(response);
            }

            try
            {
                if (recordModel.CardType == 1)
                {
                    //月卡延期(截止时间、延期金额、支付方式)
                    //暂时只控制截至日期,暂无日志记录,所以不需要存储延期金额和支付方式
                    cardModel.EndDate = FormatEndDate(cardModel.EndDate, recordModel.RenewDay, recordModel.RenewDayType);

                    bool flag = false;
                    //修改数据库
                    flag = SaveMonthCarToDB(cardModel, m_ilogger, m_serializer);
                    if (!flag)
                    {
                        response.MessageContent = "月卡保存数据库失败";
                        m_ilogger.LogError(LoggerLogicEnum.Tools, recordModel.TradeNo, recordModel.ParkingCode, recordModel.CardNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager", "月卡保存数据库失败");
                        return(response);
                    }
                    //修改redis
                    flag = SaveMonthCarToRedis(cardModel, m_ilogger, m_serializer);
                    if (!flag)
                    {
                        response.MessageContent = "月卡保存数据库成功,保存redis失败";
                        m_ilogger.LogError(LoggerLogicEnum.Tools, recordModel.TradeNo, recordModel.ParkingCode, recordModel.CardNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager", "月卡保存数据库成功,保存redis失败");
                        return(response);
                    }
                    //发送给相机
                    SendMonthCarToCameras(cardModel, m_ilogger, m_serializer);
                    //发送给Fujica
                    flag = SendMonthCarToFujica(cardModel, cartypemodel.Idx);
                    if (!flag)
                    {
                        response.MessageContent = "月卡保存数据库、redis成功,发送Fujica失败";
                        m_ilogger.LogError(LoggerLogicEnum.Tools, recordModel.TradeNo, recordModel.ParkingCode, recordModel.CardNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager", "月卡保存数据库、redis成功,发送Fujica失败");
                        return(response);
                    }
                    m_ilogger.LogInfo(LoggerLogicEnum.Tools, recordModel.TradeNo, recordModel.ParkingCode, recordModel.CardNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager", "月卡保存数据库、redis、发送Fujica成功");
                }
                else if (recordModel.CardType == 2)
                {
                    //储值卡充值(充值金额、充值方式)
                    //暂时只控制余额,暂无日志记录,所以不需要操作充值金额和充值方式
                    cardModel.Balance += recordModel.Price;

                    bool flag = false;
                    //修改数据库、redis
                    flag = SaveValueCarToDB(cardModel, m_ilogger, m_serializer);
                    if (!flag)
                    {
                        response.MessageContent = "储值卡保存数据库失败";
                        m_ilogger.LogError(LoggerLogicEnum.Tools, recordModel.TradeNo, recordModel.ParkingCode, recordModel.CardNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager", "储值卡保存数据库失败");
                        return(response);
                    }

                    //修改redis
                    flag = SaveValueCarToRedis(cardModel, m_ilogger, m_serializer);
                    if (!flag)
                    {
                        response.MessageContent = "储值卡保存数据库成功,保存redis失败";
                        m_ilogger.LogError(LoggerLogicEnum.Tools, recordModel.TradeNo, recordModel.ParkingCode, recordModel.CardNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager", "储值卡保存数据库成功,保存redis失败");
                        return(response);
                    }
                    //发送给相机
                    SendValueCarToCameras(cardModel, m_ilogger, m_serializer);
                    //发送给Fujica
                    flag = SendValueCarToFujica(cardModel, cartypemodel.Idx);
                    if (!flag)
                    {
                        response.MessageContent = "储值卡保存数据库、redis成功,发送Fujica失败";
                        m_ilogger.LogError(LoggerLogicEnum.Tools, recordModel.TradeNo, recordModel.ParkingCode, recordModel.CardNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager", "储值卡保存数据库、redis成功,发送Fujica失败");
                        return(response);
                    }
                    m_ilogger.LogInfo(LoggerLogicEnum.Tools, recordModel.TradeNo, recordModel.ParkingCode, recordModel.CardNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager", "储值卡保存数据库、redis、发送Fujica成功");
                }

                response.IsSuccess      = true;
                response.MessageContent = "支付数据操作成功";
            }
            catch (Exception ex)
            {
                m_ilogger.LogFatal(LoggerLogicEnum.Tools, recordModel.TradeNo, cardModel.ParkCode, recordModel.CardNo, "Fujica.com.cn.MonitorServiceClient.PayDataManager", cardModel.CarNo + "支付数据发生异常", ex.ToString());

                response.MessageContent = cardModel.CarNo + "支付数据发生异常:" + ex.ToString();
                return(response);
            }

            return(response);
        }
예제 #17
0
        public IHttpActionResult ApplyNewCard(ApplyCardServiceRequest model)
        {
            ResponseBaseCommon response = new ResponseBaseCommon()
            {
                IsSuccess      = true,
                MessageCode    = (int)ApiBaseErrorCode.API_SUCCESS,
                MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString()
            };

            if (string.IsNullOrWhiteSpace(model.ParkingCode) ||
                string.IsNullOrWhiteSpace(model.ProjectGuid) ||
                string.IsNullOrWhiteSpace(model.CarOwnerName) ||
                string.IsNullOrWhiteSpace(model.Mobile) ||
                string.IsNullOrWhiteSpace(model.CarNo) ||
                string.IsNullOrWhiteSpace(model.DrivewayGuidList) ||
                string.IsNullOrWhiteSpace(model.CarTypeGuid) ||
                model.PayAmount < 0 ||
                string.IsNullOrWhiteSpace(model.PayStyle))
            {
                response.IsSuccess      = false;
                response.MessageCode    = (int)ApiBaseErrorCode.API_PARAM_ERROR;
                response.MessageContent = "必要参数缺失,请检查";
                Logger.LogWarn(LoggerLogicEnum.Interface, "", "", "",
                               "Fujica.com.cn.Interface.Management.Controllers.CardServiceController.ApplyNewCard",
                               string.Format("开卡必要参数不全,入参:{0}", Serializer.Serialize(model)));
                return(Ok(response));
            }

            if (model.StartDate.Date != DateTime.Now.Date)
            {
                model.StartDate = DateTime.Now;                                            //开始日期必须是当天
            }
            string[] drivewayguidarray = drivewayguidarray = model.DrivewayGuidList.Split(',');

            CardServiceModel content = new CardServiceModel()
            {
                ProjectGuid      = model.ProjectGuid,
                ParkCode         = model.ParkingCode,
                CarOwnerName     = model.CarOwnerName,
                CarNo            = model.CarNo,
                CarTypeGuid      = model.CarTypeGuid,
                DrivewayGuidList = drivewayguidarray.ToList().FindAll(o => o != ""),
                Mobile           = model.Mobile,
                PayAmount        = model.PayAmount,
                PayStyle         = model.PayStyle,
                Remark           = model.Remark,
                Balance          = model.PayAmount, //新开卡时余额就等于支付金额(仅当储值卡时后端逻辑才会读取此值)
                StartDate        = model.StartDate,
                PrimaryEndDate   = model.StartDate,
                EndDate          = model.EndDate,
                RechargeOperator = model.RechargeOperator,
                PauseDate        = default(DateTime),
                Locked           = false,
                Enable           = true
            };

            //需要加上报表存储逻辑

            bool flag = _cardServiceManager.AddNewCard(content);

            if (!flag)
            {
                response.IsSuccess      = false;
                response.MessageCode    = (int)ApiCardServiceErrorCode.API_DATA_SAVE_ERROR;
                response.MessageContent = _cardServiceManager.LastErrorDescribe;
            }
            return(Ok(response));
        }