Exemple #1
0
        public List <InformationEntity> FetchAllInformations(DataAccess dataAccess)
        {
            List <InformationEntity> informations = new List <InformationEntity>();

            try {
                command = new SqlCommand(FETCH_ALL_INFORMATIONS, dataAccess.GetConnection());

                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    InformationEntity informationEntity = new InformationEntity();

                    informationEntity.Id       = reader.GetInt32(reader.GetOrdinal("id"));
                    informationEntity.Topic    = reader.GetString(reader.GetOrdinal("topic"));
                    informationEntity.Input    = reader.GetString(reader.GetOrdinal("information"));
                    informationEntity.IsActive = reader.GetBoolean(reader.GetOrdinal("isActivated"));

                    DepartmentEntity departmentEntity = new DepartmentEntity();
                    departmentEntity.Id   = reader.GetInt32(reader.GetOrdinal("id"));
                    departmentEntity.Name = reader.GetString(reader.GetOrdinal("name"));

                    informationEntity.DepartmentEntity = departmentEntity;

                    informations.Add(informationEntity);
                }
                reader.Close();
            } catch (SqlException exc) {
            }

            return(informations);
        }
    protected void OnFormSubmit(object sender, EventArgs e)
    {
        if (IsValid)
        {
            try {
                dataAccess.Open();

                InformationEntity informationEntity = new InformationEntity();
                informationEntity.Topic        = topic.Value;
                informationEntity.Input        = input.Value;
                informationEntity.DepartmentId = int.Parse(departmentsSelect.Value);

                bool result = informationsRepository.InsertInformation(dataAccess, informationEntity);

                if (result == true)
                {
                    RegisterSweetAlertScriptOnSuccess();
                    informations = informationsRepository.FetchAllInformations(dataAccess);
                }
            } catch {
            } finally {
                dataAccess.Close();
            }

            // Halt the thread for half a seconds, so we can show the sweetalert message.
            System.Threading.Thread.Sleep(500);
        }
    }
Exemple #3
0
        public void InsertInformation(InformationEntity InformationEntity, Database db, DbTransaction tran)
        {
            string sql        = @"insert into Information
                            (Type,WebInnerType,SendDest,SendUserId,TradeCode,Title,[Content]
                            ,ImagePath,Summary,LinkUrl,StartTime,EndTime,LongTerm,CreateTime) 
                            values (@Type,@WebInnerType,@SendDest,@SendUserId,@TradeCode,@Title
                                    ,@Content,@ImagePath,@Summary,@LinkUrl,@StartTime
                                    ,@EndTime,@LongTerm,@CreateTime)";
            var    parameters = db.CreateParameterCollection();

            parameters.Append("@Type", InformationEntity.InfoType);
            parameters.Append("@WebInnerType", InformationEntity.WebInnerType);
            parameters.Append("@SendDest", InformationEntity.SendDest);
            parameters.Append("@SendUserId", InformationEntity.SendUserId);
            parameters.Append("@TradeCode", InformationEntity.TradeCode);
            parameters.Append("@Title", InformationEntity.Title);
            parameters.Append("@Content", InformationEntity.InfoContent);
            parameters.Append("@ImagePath", InformationEntity.ImagePath);
            parameters.Append("@Summary", InformationEntity.Summary);
            parameters.Append("@LinkUrl", InformationEntity.LinkUrl);
            parameters.Append("@StartTime", InformationEntity.StartTime);
            parameters.Append("@EndTime", InformationEntity.EndTime);
            parameters.Append("@LongTerm", InformationEntity.LongTerm);
            parameters.Append("@CreateTime", InformationEntity.CreateTime);

            //LogHelper.Error("------添加消息信息2------insert sql:" + sql);
            int aa = db.ExecuteNonQuery(CommandType.Text, sql, parameters, tran);
            //LogHelper.Error("------添加消息信息2------insert 结果:" + aa);
        }
        public ActionResult UpdateInformation()
        {
            InformationEntity informationEntity = RequestArgs <InformationEntity>();

            if (informationEntity == null)
            {
                return(RespondResult(false, "参数无效。"));
            }

            informationEntity.Domain = UserContext.User.Domain;
            informationEntity.AppId  = DomainContext.AppId;
            _informationManager.UpdateInformation(informationEntity);

            #region 操作日志

            _operatedLogManager.Create(new OperatedLogEntity()
            {
                Domain      = DomainContext.Domain.Id,
                AppId       = DomainContext.AppId,
                User        = UserContext.User.Id,
                IP          = Request.UserHostAddress,
                Module      = EnumModule.Information,
                Description = "更新分类信息"
            });

            #endregion

            return(RespondResult());
        }
Exemple #5
0
        private bool HasIdenticalActiveEntryInCollection(InformationEntity information)
        {
            var activeInformationEntry = GetActiveInformationEntryByInformationId(information?.Id);

            if (activeInformationEntry == null)
            {
                return(false);
            }

            var activeEntryProperties =
                activeInformationEntry.Properties?
                .OrderBy(property => property.Name)
                .ToDictionary(
                    property => property.Name,
                    property =>
                    property.Values?
                    .Select(value => value.ToString())
                    .OrderBy(value => value)
                    )
            ;

            var newEntryProperties =
                information.Properties?
                .OrderBy(property => property.Name)
                .ToDictionary(
                    property => property.Name,
                    property =>
                    property.Values?
                    .Select(value => value.ToString())
                    .OrderBy(value => value)
                    )
            ;

            return(JsonConvert.SerializeObject(newEntryProperties) == JsonConvert.SerializeObject(activeEntryProperties));
        }
Exemple #6
0
        /// <summary>
        /// 系统消息详情页
        /// </summary>
        /// <param name="infoid">消息ID</param>
        /// <returns>消息Model</returns>
        public ActionResult SystemMsgDetail(int infoid)
        {
            InformationEntity model = InformationBll.GetSysInfoById(infoid);

            ViewBag.infoid = infoid;
            return(View(model));
        }
Exemple #7
0
        public void AddInformation(InformationEntity InformationEntity)
        {
            var db         = DbSFO2OMain;
            var connection = db.CreateConnection();

            connection.Open();

            using (var tran = connection.BeginTransaction())
            {
                try
                {
                    //LogHelper.Error("------添加消息信息1------insert方法");

                    InsertInformation(InformationEntity, db, tran);

                    tran.Commit();
                    connection.Close();
                    connection.Dispose();
                }
                catch (Exception ext)
                {
                    LogHelper.Error("------添加消息信息1异常------ext:" + ext);
                    tran.Rollback();
                    connection.Close();
                    connection.Dispose();
                    throw ext;
                }
            }
        }
Exemple #8
0
 public void InsertInfo(InformationEntity entity)
 {
     using (IUnitOfWork unitofwork = new AdviserUnit())
     {
         IRepository <InformationEntity> rep = new UserStatisticsRepository(unitofwork);
         rep.Insert(entity);
     }
 }
Exemple #9
0
 public void StoreInformation(InformationEntity information)
 {
     if (!this.HasIdenticalActiveEntryInCollection(information))
     {
         var informationId = information?.Id;
         this.ResetActivityFlagsInInformationEntries(informationId);
         this.InsertNewInformationEntryInCollection(information, informationId);
     }
 }
        public void UpdateInformation(InformationEntity information)
        {
            if (information == null)
            {
                Debug.Assert(false, "information 为空");
                return;
            }

            _dataBase.Update(information);
        }
        public void CreateInformation(InformationEntity information)
        {
            if (information == null)
            {
                Debug.Assert(false, "information 为空");
                return;
            }

            information.CreateTime = DateTime.Now;
            _dataBase.Insert(information);
        }
        public ActionResult GetInformation()
        {
            string id = Request.QueryString["id"];

            if (String.IsNullOrEmpty(id))
            {
                return(RespondResult(false, "参数无效。"));
            }

            InformationEntity information = _informationManager.GetInformation(Guid.Parse(id));

            return(RespondDataResult(information));
        }
        public InformationEntity GetInformation(Guid id)
        {
            InformationEntity information = new InformationEntity();

            information.Id = id;

            if (_dataBase.Fill <InformationEntity>(information))
            {
                return(information);
            }
            else
            {
                return(null);
            }
        }
        public ActionResult InformationCategory()
        {
            string strInformationId = Request.QueryString["informationId"];
            Guid   informationId    = Guid.Empty;

            if (String.IsNullOrEmpty(strInformationId) || Guid.TryParse(strInformationId, out informationId) == false)
            {
                //TODO:ID无效
                //return RedirectToAction("PointCommodity", new { domain = domain });
            }

            InformationEntity information = _informationManager.GetInformation(informationId);

            return(View(information));
        }
Exemple #15
0
 private void InsertNewInformationEntryInCollection(InformationEntity information, string informationId)
 {
     this.informationCollection?.InsertOne(new InformationEntry
     {
         InformationId = informationId,
         IsActive      = true,
         Properties    = information?.Properties?.OrderBy(property => property.Name).Select(property =>
         {
             return(new InformationPropertyEntry
             {
                 Name = property.Name,
                 Values = property.Values?.Select(value => GetBsonValueFromObject(value))
             });
         }),
         DiscoveryTimestamp = DateTime.Now
     });
 }
Exemple #16
0
        public bool InsertInformation(DataAccess dataAccess, InformationEntity informationsEntity)
        {
            command = new SqlCommand(INSERT, dataAccess.GetConnection());

            command.Parameters.AddWithValue("@topic", informationsEntity.Topic);
            command.Parameters.AddWithValue("@information", informationsEntity.Input);
            command.Parameters.AddWithValue("@department", informationsEntity.DepartmentId);
            try {
                int isChanged = (int)command.ExecuteNonQuery();

                if (isChanged != 0)
                {
                    return(true);
                }
            } catch (SqlException exc) {
            }
            return(false);
        }
Exemple #17
0
        /// <summary>
        /// 添加普通订单消息信息
        /// </summary>
        /// <param name="OrderCode"></param>
        /// <param name="entity"></param>
        public void AddNoemalOrderInformationInfo(string OrderCode, OrderPaymentEntity entity)
        {
            //LogHelper.Error("--------获取订单图片After开始----1-----" + OrderCode);
            ProductInfoModel productInfoModel = orderManager.GetOrderImage(OrderCode);
            //LogHelper.Error("--------获取订单图片After结束----1-----" + productInfoModel);

            //LogHelper.Error("--------消息对象设置参数After开始----1-----" + entity.UserId);

            InformationEntity InformationEntity = new InformationEntity();

            InformationEntity.InfoType     = 1;
            InformationEntity.WebInnerType = 3;
            InformationEntity.SendDest     = CommonBll.GetUserRegion(entity.UserId);
            InformationEntity.SendUserId   = entity.UserId;
            InformationEntity.TradeCode    = OrderCode;
            InformationEntity.Title        = InformationUtils.UserPaySuccTitle;
            InformationEntity.InfoContent  = InformationUtils.UserPaySuccContent_Prefix
                                             + OrderCode + InformationUtils.UserPaySuccContent_suffix;

            if (productInfoModel != null)
            {
                //LogHelper.Error("--------消息对象设置参数After开始----2-----" + productInfoModel.ImagePath);
                InformationEntity.ImagePath = productInfoModel.ImagePath;
            }
            else
            {
                InformationEntity.ImagePath = null;
            }

            InformationEntity.Summary    = null;
            InformationEntity.LinkUrl    = "my/detail?orderCode=" + OrderCode;
            InformationEntity.StartTime  = null;
            InformationEntity.EndTime    = null;
            InformationEntity.LongTerm   = 0;
            InformationEntity.CreateTime = DateTime.Now;

            //LogHelper.Error("--------插入消息表开始----1-----");
            InformationBll.AddInformation(InformationEntity);
        }
Exemple #18
0
        /// <summary>
        /// 添加团订单消息信息
        /// </summary>
        /// <param name="teamDetailList"></param>
        public void AddTeamOrderInformationInfo(IList <TeamDetailEntity> teamDetailList)
        {
            //LogHelper.Info("--------TeamPayAfter 消息插入循环进入前----");
            foreach (TeamDetailEntity teamDetail in teamDetailList)
            {
                //LogHelper.Info("--------TeamPayAfter 消息插入循环----" + teamDetail.OrderCode);
                ProductInfoModel productInfoModel = orderManager.GetOrderImage(teamDetail.OrderCode);
                //LogHelper.Info("--------TeamPayAfter 获取商品图片结束----productInfoModel=" + productInfoModel);

                InformationEntity InformationEntityTeam = new InformationEntity();
                InformationEntityTeam.InfoType     = 1;
                InformationEntityTeam.WebInnerType = 3;
                InformationEntityTeam.SendDest     = CommonBll.GetUserRegion(teamDetail.UserId);
                InformationEntityTeam.SendUserId   = teamDetail.UserId;
                InformationEntityTeam.TradeCode    = teamDetail.TeamCode;
                InformationEntityTeam.Title        = InformationUtils.TeamJoinSuccTitle;
                InformationEntityTeam.InfoContent  = InformationUtils.TeamJoinSuccContent;

                if (productInfoModel != null)
                {
                    InformationEntityTeam.ImagePath = productInfoModel.ImagePath;
                }
                else
                {
                    InformationEntityTeam.ImagePath = null;
                }

                InformationEntityTeam.Summary    = null;
                InformationEntityTeam.LinkUrl    = "team/teamDetail?TeamCode=" + teamDetail.TeamCode + "&Flag=1";
                InformationEntityTeam.StartTime  = null;
                InformationEntityTeam.EndTime    = null;
                InformationEntityTeam.LongTerm   = 0;
                InformationEntityTeam.CreateTime = DateTime.Now;

                //LogHelper.Info("--------TeamPayAfter 消息插入开始----");
                InformationBll.AddInformation(InformationEntityTeam);
            }
        }
Exemple #19
0
        public ActionResult ConfirmOrder(string orderCode)
        {
            try
            {
                if (string.IsNullOrEmpty(orderCode))
                {
                    return(this.HandleError("订单编号不能为空!"));
                }

                var model = Bll.ConfirmOrder(base.LoginUser.UserID, base.DeliveryRegion, base.language, orderCode);
                if (model)
                {
                    LogHelper.Info("--------ConfirmOrder----获取订单的商品图片开始---orderCode:" + orderCode);

                    /// 获取订单的商品图片
                    ProductInfoModel productInfoModel = orderManager.GetOrderImage(orderCode);
                    LogHelper.Info("--------ConfirmOrder----获取订单的商品图片结束---orderCode:" + orderCode);

                    LogHelper.Info("--------ConfirmOrder----设置对象参数开始");
                    InformationEntity InformationEntity = new InformationEntity();
                    InformationEntity.InfoType     = 1;
                    InformationEntity.WebInnerType = 3;
                    InformationEntity.SendDest     = CommonBll.GetUserRegion(base.LoginUser.UserID);
                    InformationEntity.SendUserId   = base.LoginUser.UserID;
                    InformationEntity.TradeCode    = orderCode;
                    InformationEntity.Title        = InformationUtils.OrderTradeSuccTitle;
                    InformationEntity.InfoContent  = InformationUtils.OrderTradeSuccContent_Prefix
                                                     + orderCode + InformationUtils.OrderTradeSuccContent_suffix;

                    if (productInfoModel != null)
                    {
                        InformationEntity.ImagePath = productInfoModel.ImagePath;
                    }
                    else
                    {
                        InformationEntity.ImagePath = null;
                    }

                    InformationEntity.Summary    = null;
                    InformationEntity.LinkUrl    = "my/detail?orderCode=" + orderCode;
                    InformationEntity.StartTime  = null;
                    InformationEntity.EndTime    = null;
                    InformationEntity.LongTerm   = 0;
                    InformationEntity.CreateTime = DateTime.Now;
                    LogHelper.Info("--------ConfirmOrder----设置对象参数结束");

                    LogHelper.Info("--------ConfirmOrder----执行消息表插入方法开始");
                    InformationBll.AddInformation(InformationEntity);
                    LogHelper.Info("--------ConfirmOrder----执行消息表插入方法结束");

                    return(this.HandleSuccess("ok"));
                }
                else
                {
                    return(this.HandleError("系统异常请稍后再试!"));
                }
            }
            catch (Exception ex)
            {
                return(this.HandleError(ex));
            }
        }
Exemple #20
0
        /// <summary>
        /// 进入消息中心
        /// </summary>
        /// <returns></returns>
        public ActionResult ToInformationCenter()
        {
            /// 声明消息中心页面Model
            InformationViewModel InfoViewModel = new InformationViewModel();

            /// 获得消息最后一条的信息
            IList <InformationEntity> InformationLastList = InformationBll.GetInformationLast(base.LoginUser.UserID);

            if (InformationLastList == null || InformationLastList.Count() == 0)
            {
                /// 没有任何消息
                InfoViewModel.InformationLast = 0;
                return(View("InformationCenter", InfoViewModel));
            }
            else
            {
                /// 有消息
                InfoViewModel.InformationLast = 1;

                /// 获得系统消息和站内系统消息
                InformationEntity SystemInfo         = InformationLastList.FirstOrDefault(d => d.WebInnerType == 1);
                InformationEntity WebInnerSystemInfo = InformationLastList.FirstOrDefault(d => d.WebInnerType == 4);

                /// 系统消息和站内系统消息都不为空
                if (SystemInfo != null && WebInnerSystemInfo != null)
                {
                    DateTime SystemInfoCreateTime         = SystemInfo.CreateTime;
                    DateTime WebInnerSystemInfoCreateTime = WebInnerSystemInfo.CreateTime;

                    if (SystemInfoCreateTime > WebInnerSystemInfoCreateTime)
                    {
                        //string CreateTime = CreatwTimeFormatter(SystemInfoCreateTime);
                        InfoViewModel.SystemInfoLastCreateTime = SystemInfoCreateTime.ToString("MM-dd");
                        InfoViewModel.SystemInfoLastTitle      = SystemInfo.Title;
                    }
                    else
                    {
                        //string CreateTime = CreatwTimeFormatter(WebInnerSystemInfoCreateTime);
                        InfoViewModel.SystemInfoLastCreateTime = WebInnerSystemInfoCreateTime.ToString("MM-dd");
                        InfoViewModel.SystemInfoLastTitle      = WebInnerSystemInfo.Title;
                    }

                    InfoViewModel.SystemInformationLast = 1;
                }
                /// 只有系统消息数据
                else if (SystemInfo != null)
                {
                    InfoViewModel.SystemInformationLast = 1;
                    //string CreateTime = CreatwTimeFormatter(SystemInfo.CreateTime);
                    InfoViewModel.SystemInfoLastCreateTime = SystemInfo.CreateTime.ToString("MM-dd");
                    InfoViewModel.SystemInfoLastTitle      = SystemInfo.Title;
                }
                /// 只有站内系统消息数据
                else if (WebInnerSystemInfo != null)
                {
                    InfoViewModel.SystemInformationLast = 1;
                    //string CreateTime = CreatwTimeFormatter(WebInnerSystemInfo.CreateTime);
                    InfoViewModel.SystemInfoLastCreateTime = WebInnerSystemInfo.CreateTime.ToString("MM-dd");
                    InfoViewModel.SystemInfoLastTitle      = WebInnerSystemInfo.Title;
                }
                /// 系统消息和站内系统消息都没有数据
                else
                {
                    InfoViewModel.SystemInformationLast = 0;
                }

                /// 获得活动消息
                InformationEntity ActivityInfo = InformationLastList.FirstOrDefault(d => d.WebInnerType == 2);
                if (ActivityInfo != null)
                {
                    InfoViewModel.ActivityInformationLast = 1;
                    InfoViewModel.ActivityInfoLastTitle   = ActivityInfo.Title;

                    //string CreateTime = CreatwTimeFormatter(ActivityInfo.CreateTime);
                    InfoViewModel.ActivityInfoLastCreateTime = ActivityInfo.CreateTime.ToString("MM-dd");
                }
                else
                {
                    InfoViewModel.ActivityInformationLast = 0;
                }

                /// 获得订单消息
                InformationEntity OrderInfo = InformationLastList.FirstOrDefault(d => d.WebInnerType == 3);
                if (OrderInfo != null)
                {
                    InfoViewModel.OrderInformationLast = 1;
                    InfoViewModel.OrderInfoLastTitle   = OrderInfo.Title;

                    //string CreateTime = CreatwTimeFormatter(OrderInfo.CreateTime);
                    InfoViewModel.OrderInfoLastCreateTime = OrderInfo.CreateTime.ToString("MM-dd");
                }
                else
                {
                    InfoViewModel.OrderInformationLast = 0;
                }
            }

            /// 获得未读消息
            IList <InformationEntity> NotReadInformations = InformationBll.GetNotReadInfomation(base.LoginUser.UserID);

            if (NotReadInformations == null || NotReadInformations.Count() == 0)
            {
                /// 消息全部已读
                InfoViewModel.InformationRead = 1;
            }
            else
            {
                /// 消息有未读
                InfoViewModel.InformationRead = 0;
            }

            /// 系统消息未读条数总计
            InfoViewModel.SystemInfoTotalNotReadCount = NotReadInformations.Where(d => d.WebInnerType == 1).Sum(d => d.NotReadInfoCount)
                                                        + NotReadInformations.Where(d => d.WebInnerType == 4).Sum(d => d.NotReadInfoCount);
            /*InfoViewModel.SystemInfoTotalNotReadCount = 100;*/
            InfoViewModel.ActivityInfoNotReadCount = NotReadInformations.Where(d => d.WebInnerType == 2).Sum(d => d.NotReadInfoCount);
            /*InfoViewModel.ActivityInfoNotReadCount = 100;*/
            InfoViewModel.OrderInfoNotReadCount = NotReadInformations.Where(d => d.WebInnerType == 3).Sum(d => d.NotReadInfoCount);
            /*InfoViewModel.OrderInfoNotReadCount = 100;*/

            return(View("InformationCenter", InfoViewModel));
        }
        public ServiceResult UpdateInformation()
        {
            // Download pollen PDF
            var uri = new Uri ("http://www.allergie.hexal.de/pollenflug/vorhersage/pdf_create.php?plz=" + "40764");
            var pdfContent = PdfService.ExtractTextFromPdf(uri);

            // Prepare information
            var information = new InformationEntity();
            information.Date = DateTime.Now;

            try
            {
                // Extract Information
                information.Text =
                    pdfContent.Substring(
                        pdfContent.IndexOf("Für Deutschland:") + 17,
                        (pdfContent.IndexOf("Für Postleitzahl") - (pdfContent.IndexOf("Für Deutschland:") + 17)));
            }
            catch (Exception)
            {
                // Recovery Text
                information.Text = "Derzeit sind keine weiteren Informationen vorhanden. Wir wünschen eine Pollenfreie Zeit!";
            }

            informationTable.InsertOnSubmit(information);
            DataContext.SubmitChanges();

            return new ServiceResult(true);
        }
Exemple #22
0
 public void AddInformation(InformationEntity InformationEntity)
 {
     informationDal.AddInformation(InformationEntity);
 }
 public void StoreInformation(InformationEntity information)
 {
     this.NumberOfStoreInformationCalls++;
     this.LastRequest = information;
 }
Exemple #24
0
        public JsonResult SubmitComplain(string model, string sku)
        {
            try
            {
                #region 参数验证
                if (string.IsNullOrEmpty(model))
                {
                    return(Json(new { Type = 0, Content = "缺少必要参数" }, JsonRequestBehavior.DenyGet));
                }
                RefundOrderEntity entity = JsonHelper.ToObject <RefundOrderEntity>(model);
                if (entity == null)
                {
                    return(Json(new { Type = 0, Content = "缺少必要参数" }, JsonRequestBehavior.DenyGet));
                }
                var orderInfo = myOrderBll.GetMyOrderInfo(LoginUser.UserID, base.DeliveryRegion, base.language, entity.OrderCode);
                if (orderInfo == null)
                {
                    return(Json(new { Type = 0, Content = "该订单不存在" }));
                }
                if (orderInfo.SkuInfos == null)
                {
                    return(Json(new { Type = 0, Content = "该订单商品不存在" }));
                }
                if (orderInfo.OrderStatus != 3)
                {
                    return(Json(new { Type = 0, Content = "该订单申诉时间已过,不能进行申诉" }));
                }

                var skuInfo = orderInfo.SkuInfos.FirstOrDefault(s => s.Sku == sku);
                if (skuInfo == null)
                {
                    return(Json(new { Type = 0, Content = "该商品不存在" }));
                }
                if (entity.RefundType < 0)
                {
                    return(Json(new { type = 0, content = "请选择退款类型" }));
                }
                if (entity.RefundReason <= 0)
                {
                    return(Json(new { Type = 0, Content = "请选择退款原因" }));
                }
                if (string.IsNullOrEmpty(entity.RefundDescription))
                {
                    return(Json(new { Type = 0, Content = "请输入详细理由" }));
                }
                else if (entity.RefundDescription.Length > 1000)
                {
                    return(Json(new { Type = 0, Content = "详细理由最多1000字" }));
                }
                if (string.IsNullOrEmpty(entity.ImagePath))
                {
                    return(Json(new { Type = 0, Content = "请至少上传2张问题图片" }));
                }
                else
                {
                    var images = entity.ImagePath.Split(',').ToArray();
                    if (images != null && images.Length > 10)
                    {
                        return(Json(new { Type = 0, Content = "问题图片最多上传10张" }));
                    }
                }
                #endregion
                if (string.IsNullOrEmpty(entity.RefundCode) || entity.RefundCode == "0")//申诉
                {
                    if (!refundBll.IsCanRefund(orderInfo.OrderCode, skuInfo.Sku))
                    {
                        return(Json(new { Type = 1, Content = "该商品已全部申诉,不能再进行申诉", LinkUrl = "/Refund/Refund" }));
                    }
                    entity.UserId         = LoginUser.UserID;
                    entity.CreateBy       = LoginUser.UserName;
                    entity.CreateTime     = DateTime.Now;
                    entity.TotalAmount    = 0;
                    entity.RMBTotalAmount = 0;
                    entity.RefundStatus   = (int)RefundStatus.WaitAudit;
                    entity.RefundCode     = BuildRefundCode(orderInfo.OrderCode);
                    entity.OrderCode      = orderInfo.OrderCode;
                    entity.ExchangeRate   = orderInfo.ExchangeRate;
                    entity.SupplierId     = skuInfo.SupplierId;
                    entity.RegionCode     = base.DeliveryRegion;
                    entity.Commision      = skuInfo.Commission;

                    RefundProductEntity productEntity = new RefundProductEntity();
                    productEntity.RefundCode   = entity.RefundCode;
                    productEntity.Quantity     = 1;
                    productEntity.UnitPrice    = skuInfo.UnitPrice;
                    productEntity.RMBUnitPrice = skuInfo.PayUnitPrice;
                    productEntity.Sku          = skuInfo.Sku;
                    productEntity.Spu          = skuInfo.Spu;
                    productEntity.TaxRate      = skuInfo.TaxRate;
                    productEntity.IsBearDuty   = skuInfo.IsBearDuty;
                    //查询OrderProducts表里的HuoLi
                    ProductBll       productBll  = new ProductBll();
                    ProductInfoModel productInfo = productBll.getProductInfo(orderInfo.OrderCode, skuInfo.Sku);

                    //查询refundProducts的记录
                    List <RefundProductEntity> list = refundBll.getOrderProductCount(orderInfo.OrderCode, skuInfo.Sku);
                    if (productInfo.HuoLi > 0 || productInfo.Coupon > 0)
                    {
                        //退回的酒豆
                        if (productInfo.Qty - list.Count() > 1)
                        {
                            productEntity.HuoLi  = (int)(productInfo.HuoLi / productInfo.Qty);
                            productEntity.Coupon = Math.Round(productInfo.Coupon / productInfo.Qty, 2, MidpointRounding.AwayFromZero);
                        }
                        else if (productInfo.Qty - list.Count() <= 1)
                        {
                            productEntity.HuoLi  = (int)(productInfo.HuoLi - (int)(productInfo.HuoLi / productInfo.Qty) * (productInfo.Qty - 1));
                            productEntity.Coupon = Math.Round(productInfo.Coupon - Math.Round(Math.Round((productInfo.Coupon / productInfo.Qty), 2, MidpointRounding.AwayFromZero) * (productInfo.Qty - 1), 2, MidpointRounding.AwayFromZero), 2, MidpointRounding.AwayFromZero);
                        }
                        else
                        {
                            productEntity.HuoLi  = 0;
                            productEntity.Coupon = 0;
                        }
                    }
                    if (refundBll.AddRefund(entity, productEntity))
                    {
                        ProductInfoModel productInfoModel = orderManager.GetOrderImage(orderInfo.OrderCode);

                        InformationEntity InformationEntity = new InformationEntity();
                        InformationEntity.InfoType     = 1;
                        InformationEntity.WebInnerType = 3;
                        InformationEntity.SendDest     = CommonBll.GetUserRegion(base.LoginUser.UserID);
                        InformationEntity.SendUserId   = base.LoginUser.UserID;
                        InformationEntity.TradeCode    = entity.RefundCode;
                        InformationEntity.Title        = InformationUtils.RefundSubmitSuccTitle;
                        InformationEntity.InfoContent  = InformationUtils.RefundSubmitSuccContent;

                        if (productInfoModel != null)
                        {
                            InformationEntity.ImagePath = productInfoModel.ImagePath;
                        }
                        else
                        {
                            InformationEntity.ImagePath = null;
                        }

                        InformationEntity.Summary    = null;
                        InformationEntity.LinkUrl    = "refund/refundInfo?code=" + entity.RefundCode;
                        InformationEntity.StartTime  = null;
                        InformationEntity.EndTime    = null;
                        InformationEntity.LongTerm   = 0;
                        InformationEntity.CreateTime = DateTime.Now;

                        InformationBll.AddInformation(InformationEntity);

                        return(Json(new { Type = 1, Content = "申诉已提交,请耐心等待", LinkUrl = "/Refund/Refund" }));
                    }
                    else
                    {
                        return(Json(new { Type = 0, Content = "申诉失败" }));
                    }
                }
                else
                {
                    //修改申诉
                    RefundOrderEntity oldEntity = refundBll.GetRefundOrderInfo(entity.RefundCode);
                    if (string.IsNullOrEmpty(oldEntity.RefundCode))
                    {
                        return(Json(new { Type = 0, Content = "退款单号不正确" }));
                    }
                    else
                    {
                        if (oldEntity.RefundStatus != (int)RefundStatus.WaitAudit)
                        {
                            return(Json(new { Type = 0, Content = "该退款单已审核通过,不能提交修改" }));
                        }
                    }
                    entity.RefundStatus = (int)RefundStatus.WaitAudit;
                    if (refundBll.EditRefund(entity))
                    {
                        return(Json(new { Type = 1, Content = "修改申诉成功", LinkUrl = "/Refund/Refund" }));
                    }
                    else
                    {
                        return(Json(new { Type = 0, Content = "修改申诉失败" }));
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                return(Json(new { Type = 0, Content = "系统错误,请稍后再试" }));
            }
        }