Beispiel #1
0
        /// <summary>
        /// 更新众筹
        /// </summary>
        /// <param name="crowdfundingDTO">众筹实体</param>
        public ResultDTO UpdateCrowdfundingExt(Jinher.AMP.BTP.Deploy.CrowdfundingDTO crowdfundingDTO)
        {
            if (crowdfundingDTO == null)
            {
                return new ResultDTO {
                           ResultCode = 2, Message = "DTO is null"
                }
            }
            ;
            Crowdfunding crowdfunding = Crowdfunding.ObjectSet().FirstOrDefault(c => c.Id == crowdfundingDTO.Id);

            if (crowdfunding == null)
            {
                return new ResultDTO {
                           ResultCode = 2, Message = "BE is null"
                }
            }
            ;
            try
            {
                ContextSession contextSession = ContextFactory.CurrentThreadContext;

                crowdfunding.Slogan      = crowdfundingDTO.Slogan;
                crowdfunding.Description = crowdfundingDTO.Description;
                crowdfunding.EntityState = EntityState.Modified;
                contextSession.SaveObject(crowdfunding);
                contextSession.SaveChanges();
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("修改众筹服务异常。crowdfundingDTO:{0}", crowdfundingDTO), ex);
                return(new ResultDTO {
                    ResultCode = 1, Message = "Error"
                });
            }
            return(new ResultDTO {
                ResultCode = 0, Message = "Success"
            });
        }
Beispiel #2
0
        /// <summary>
        /// 添加众筹
        /// </summary>
        /// <param name="crowdfundingDTO">众筹实体</param>
        public ResultDTO AddCrowdfundingExt(Jinher.AMP.BTP.Deploy.CrowdfundingDTO crowdfundingDTO)
        {
            if (crowdfundingDTO == null)
            {
                return new ResultDTO {
                           ResultCode = 2, Message = "入参不能为空"
                }
            }
            ;
            if (crowdfundingDTO.AppId == Guid.Empty)
            {
                return new ResultDTO {
                           ResultCode = 2, Message = "请正确填写应用"
                }
            }
            ;

            var dividendPercent = crowdfundingDTO.DividendPercent * crowdfundingDTO.ShareCount;

            if (dividendPercent > CustomConfig.CrowdfundingConfig.MaxDividend)
            {
                return new ResultDTO {
                           ResultCode = 2, Message = "您的订单成交额已不足抵扣分红,请重新设置!"
                }
            }
            ;

            if (crowdfundingDTO.StartTime < DateTime.Now)
            {
                return(new ResultDTO {
                    ResultCode = 2, Message = "众筹开始时间必须大于当前时间!"
                });
            }

            string message = "Success";

            try
            {
                var tmp = Crowdfunding.ObjectSet().FirstOrDefault(c => c.AppId == crowdfundingDTO.AppId);
                if (tmp != null)
                {
                    return new ResultDTO {
                               ResultCode = 3, Message = "该应用已经参加众筹活动,不能重复添加"
                    }
                }
                ;

                Dictionary <Guid, string> list = APPSV.GetAppNameListByIds(new List <Guid> {
                    crowdfundingDTO.AppId
                });

                if (list == null || !list.Any() || !list.ContainsKey(crowdfundingDTO.AppId) || list[crowdfundingDTO.AppId] != crowdfundingDTO.AppName.Trim())
                {
                    return new ResultDTO {
                               ResultCode = 2, Message = "应用Id与名称不符"
                    }
                }
                ;

                ContextSession contextSession = ContextFactory.CurrentThreadContext;

                //保存众筹
                Crowdfunding entity = Crowdfunding.CreateCrowdfunding();
                entity.AppName         = crowdfundingDTO.AppName;
                entity.AppId           = crowdfundingDTO.AppId;
                entity.PerShareMoney   = crowdfundingDTO.PerShareMoney;
                entity.DividendPercent = crowdfundingDTO.DividendPercent;
                entity.ShareCount      = crowdfundingDTO.ShareCount;
                entity.StartTime       = crowdfundingDTO.StartTime;
                entity.State           = 0;
                entity.Slogan          = crowdfundingDTO.Slogan;
                entity.Description     = crowdfundingDTO.Description;
                contextSession.SaveObject(entity);

                //保存众筹计数表
                CrowdfundingCount cnt = CrowdfundingCount.CreateCrowdfundingCount();
                cnt.AppId          = entity.AppId;
                cnt.CrowdfundingId = entity.Id;
                cnt.ShareCount     = entity.ShareCount;
                contextSession.SaveObject(cnt);

                contextSession.SaveChanges();
                if (dividendPercent > CustomConfig.CrowdfundingConfig.WarnDividend)
                {
                    message = string.Format("您的分红支出已超{0:P0},请注意收支平衡!", CustomConfig.CrowdfundingConfig.WarnDividend);
                }

                CrowdfundingMessageDTO Message = new CrowdfundingMessageDTO();
                Message.Now       = DateTime.Now;
                Message.StartTime = entity.StartTime;
                Message.State     = -1;
                AddMessage addMessage = new AddMessage();
                addMessage.SendMessage(entity.Id, entity.AppId, entity.StartTime, Message);
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("添加众筹服务异常。crowdfundingDTO:{0}", crowdfundingDTO), ex);
                return(new ResultDTO {
                    ResultCode = 1, Message = "Error"
                });
            }
            return(new ResultDTO {
                ResultCode = 0, Message = message
            });
        }
Beispiel #3
0
 /// <summary>
 /// 更新众筹
 /// </summary>
 /// <param name="crowdfundingDTO">众筹实体</param>
 public ResultDTO UpdateCrowdfunding(Jinher.AMP.BTP.Deploy.CrowdfundingDTO crowdfundingDTO)
 {
     base.Do();
     return(this.UpdateCrowdfundingExt(crowdfundingDTO));
 }
Beispiel #4
0
 /// <summary>
 /// 添加众筹
 /// </summary>
 /// <param name="crowdfundingDTO">众筹实体</param>
 public ResultDTO AddCrowdfunding(Jinher.AMP.BTP.Deploy.CrowdfundingDTO crowdfundingDTO)
 {
     base.Do();
     return(this.Command.AddCrowdfunding(crowdfundingDTO));
 }