Пример #1
0
        public ActionResult Index()
        {
            if (CurrentSession.User == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            ActivityJoin acJoin = managementActivityJoin.Find(x => x.UserID == CurrentSession.User.Id);



            List <Activity>     activities    = new List <Activity>();
            List <ActivityJoin> activityJoins = new List <ActivityJoin>();

            foreach (ActivityJoin hes in managementActivityJoin.List())
            {
                if (hes.UserID == CurrentSession.User.Id)
                {
                    activityJoins.Add(hes);

                    foreach (Activity hess in managementActivity.List())
                    {
                        if (hess.Id == hes.ActivityID)
                        {
                            activities.Add(hess);
                        }
                    }
                }
            }



            return(View(activities));
        }
Пример #2
0
        /// <summary>
        /// 修改 (可能有其他业务逻辑检查)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResultInfo Update(ActivityJoin model, SqlTransaction tran)
        {
            ResultInfo ri = new ResultInfo();

            if (Edit(model, tran))
            {
                ri.Ok  = true;
                ri.Msg = "修改成功";
            }

            return(ri);
        }
Пример #3
0
        /// <summary>
        /// 保存 (可能有其他业务逻辑检查)
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns></returns>
        public ResultInfo Create(ActivityJoin model, SqlTransaction tran)
        {
            ResultInfo ri = new ResultInfo();

            if (model == null)
            {
                return(ri);
            }

            int result = Add(model, tran);

            if (result > 0)
            {
                ri.Ok  = true;
                ri.Msg = "添加成功";
            }

            return(ri);
        }
Пример #4
0
        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(ActivityJoin model, SqlTransaction tran = null)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ActivityJoin(");
            strSql.Append(" JoinUserID,JoinUserName,FeeType,IsFeed,JoinTime,JoinCount,LinkMan,LinkTel,ActivityId,ActivityFeeId,RealPayFee )");
            strSql.Append(" values (");
            strSql.Append("@JoinUserID,@JoinUserName,@FeeType,@IsFeed,@JoinTime,@JoinCount,@LinkMan,@LinkTel,@ActivityId,@ActivityFeeId,@RealPayFee);select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@JoinUserID",    model.JoinUserID),
                new SqlParameter("@JoinUserName",  model.JoinUserName),
                new SqlParameter("@FeeType",       model.FeeType),
                new SqlParameter("@IsFeed",        model.IsFeed),
                new SqlParameter("@JoinTime",      model.JoinTime),
                new SqlParameter("@JoinCount",     model.JoinCount),
                new SqlParameter("@LinkMan",       model.LinkMan),
                new SqlParameter("@LinkTel",       model.LinkTel),
                new SqlParameter("@ActivityId",    model.ActivityId),
                //new SqlParameter("@DIY1", model.DIY1),
                //new SqlParameter("@DIY2", model.DIY2),
                //new SqlParameter("@DIY3", model.DIY3),
                //new SqlParameter("@DIY4", model.DIY4),
                //new SqlParameter("@DIY5", model.DIY5),
                //new SqlParameter("@DIY6", model.DIY6),
                new SqlParameter("@ActivityFeeId", model.ActivityFeeId),
                new SqlParameter("@RealPayFee",    model.RealPayFee),
            };

            object obj;

            if (tran == null)
            {
                obj = SqlHelper.GetSingle(strSql.ToString(), CommandType.Text, parameters);
            }
            else
            {
                obj = SqlHelper.GetSingle(tran, CommandType.Text, strSql.ToString(), parameters);
            }
            return(obj == null ? 0 : Convert.ToInt32(obj));
        }
Пример #5
0
        public ActionResult ActivityList(EventListViewModel eventListViewModel)
        {
            if (CurrentSession.User == null)
            {
                return(RedirectToAction("Login", "Users"));
            }


            double          range     = eventListViewModel.RangeID / 100;
            double          Latitude  = Convert.ToDouble(eventListViewModel.Latitude.Replace('.', ','));
            double          Longitude = Convert.ToDouble(eventListViewModel.Longitude.Replace('.', ','));
            DatabaseContext db        = new DatabaseContext();

            ActivityJoin acJoin = managementActivityJoin.Find(x => x.UserID == CurrentSession.User.Id);


            List <Activity>     activities    = new List <Activity>();
            List <ActivityJoin> activityJoins = new List <ActivityJoin>();

            foreach (Activity hess in managementActivity.List())
            {
                if (hess.UserID != CurrentSession.User.Id)
                {
                    if ((Convert.ToDouble(hess.Latitude) > Latitude - range && Convert.ToDouble(hess.Latitude) < Latitude + range) &&
                        (Convert.ToDouble(hess.Longitude) > Longitude - range && Convert.ToDouble(hess.Longitude) < Longitude + range) &&
                        hess.CategoryID == eventListViewModel.CategoryID)
                    {
                        foreach (ActivityJoin hes in managementActivityJoin.List())
                        {
                            if (hes.ActivityID != hess.Id)
                            {
                                activities.Add(hess);
                            }
                        }
                    }
                }
            }


            return(View(activities));
        }
Пример #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Update(ActivityJoin model, SqlTransaction tran = null)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ActivityJoin set ");
            strSql.Append("JoinUserID=@JoinUserID,JoinUserName=@JoinUserName,FeeType=@FeeType,IsFeed=@IsFeed,JoinTime=@JoinTime,JoinCount=@JoinCount,LinkMan=@LinkMan,LinkTel=@LinkTel,ActivityId=@ActivityId,ActivityFeeId=@ActivityFeeId,RealPayFee=@RealPayFee");
            strSql.Append(" where ActivityJoinId=@ActivityJoinId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@JoinUserID",     model.JoinUserID),
                new SqlParameter("@JoinUserName",   model.JoinUserName),
                new SqlParameter("@FeeType",        model.FeeType),
                new SqlParameter("@IsFeed",         model.IsFeed),
                new SqlParameter("@JoinTime",       model.JoinTime),
                new SqlParameter("@JoinCount",      model.JoinCount),
                new SqlParameter("@LinkMan",        model.LinkMan),
                new SqlParameter("@LinkTel",        model.LinkTel),
                new SqlParameter("@ActivityId",     model.ActivityId),
                //new SqlParameter("@DIY1", model.DIY1),
                //new SqlParameter("@DIY2", model.DIY2),
                //new SqlParameter("@DIY3", model.DIY3),
                //new SqlParameter("@DIY4", model.DIY4),
                //new SqlParameter("@DIY5", model.DIY5),
                //new SqlParameter("@DIY6", model.DIY6),
                new SqlParameter("@ActivityFeeId",  model.ActivityFeeId),
                new SqlParameter("@RealPayFee",     model.RealPayFee),


                new SqlParameter("@ActivityJoinId", model.ActivityJoinId)
            };

            if (tran == null)
            {
                return(SqlHelper.ExecuteSql(strSql.ToString(), CommandType.Text, parameters) > 0);
            }
            else
            {
                return(SqlHelper.ExecuteSql(tran, CommandType.Text, strSql.ToString(), parameters) > 0);
            }
        }
Пример #7
0
        public ActionResult Pay(decimal fee, string desc, List <UserJoinItemViewModel> joinItems, long id = 0, int type = 0, int count = 1)
        {
            ResultInfo       ri        = new ResultInfo();
            int              result    = 0;
            string           seq       = string.Empty;
            string           returnUri = string.Empty;
            JoinItemTypeEnum jointype  = JoinItemTypeEnum.None;

            try
            {
                BeginTran();
                long buyItemID = 0;
                var  now       = DateTime.Now;
                #region 校验
                if (fee <= 0)
                {
                    ri.Msg = "金额不正常(如何支付为0的金额呢?),请刷新页面重试";
                    return(Result(ri));
                }

                if (type == 0)
                {
                    ri.Msg = "支付异常,请刷新页面重试";
                    return(Result(ri));
                }
                if (type == 1)
                {
                    if (id == 0)
                    {
                        seq       = "CZ";
                        returnUri = "http://www.baixiaotangtop.com/User";
                    }
                    else
                    {
                        ri.Msg = "支付异常,请刷新页面重试";
                        return(Result(ri));
                    }
                }
                else
                {
                    if (id == 0)
                    {
                        ri.Msg = "支付异常,请刷新页面重试";
                        return(Result(ri));
                    }
                    if (type == 2)
                    {
                        #region 礼物、课程、数据相关逻辑
                        //先根据ID获取费用信息
                        var feeInfo = GiftFeeBLL.Instance.GetModel(id);
                        if (feeInfo != null)
                        {
                            long giftId = GetRequest <long>("mid");
                            if (giftId != feeInfo.GiftID)
                            {
                                ri.Msg = "商品信息不正确!";
                                return(Result(ri));
                            }

                            if (feeInfo.FeeType != 30)
                            {
                                ri.Msg = "商品价格信息有误!";
                                return(Result(ri));
                            }
                            else if (feeInfo.Fee != fee)
                            {
                                ri.Msg = "商品价格被篡改,请刷新页面重新支付";
                                return(Result(ri));
                            }

                            if (feeInfo.FeeCount > 0)
                            {
                                if (feeInfo.FeeCount >= count)
                                {
                                    id        = giftId;
                                    returnUri = "http://www.baixiaotangtop.com/gift/detail/{0}".FormatWith(id);

                                    Gift gift = GiftBLL.Instance.GetModel(giftId);
                                    if (gift != null)
                                    {
                                        #region 创建购买商品信息
                                        string   linkMan = GetRequest("LinkMan");
                                        string   linktel = GetRequest("LinkTel");
                                        UserGift buygift = new UserGift()
                                        {
                                            BuyCount  = count,
                                            BuyTime   = now,
                                            BuyUserID = UserID,
                                            Fee       = feeInfo.Fee * count,
                                            FeeType   = feeInfo.FeeType,
                                            GiftFeeId = feeInfo.GiftFeeId,
                                            GiftID    = giftId,
                                            GType     = gift.GType,
                                            IsPay     = 0,
                                        };
                                        if (linkMan.IsNotNullOrEmpty())
                                        {
                                            buygift.LinkMan = linkMan;
                                        }
                                        if (linktel.IsNotNullOrEmpty())
                                        {
                                            buygift.LinkTel = linktel;
                                        }
                                        if ((buyItemID = UserGiftBLL.Instance.Add(buygift, Tran)) < 1)
                                        {
                                            RollBack();
                                            ri.Msg = "创建订单失败!";
                                            return(Result(ri));
                                        }
                                        if (gift.GType == 1)
                                        {
                                            seq      = "LP";
                                            jointype = JoinItemTypeEnum.Gift;
                                        }
                                        else if (gift.GType == 2)
                                        {
                                            seq      = "SJ";
                                            type     = 4;
                                            jointype = JoinItemTypeEnum.DataAnalysis;
                                        }
                                        else
                                        {
                                            seq      = "KC";
                                            type     = 8;
                                            jointype = JoinItemTypeEnum.KeCheng;
                                        }

                                        #endregion
                                    }
                                    else
                                    {
                                        ri.Msg = "商品不存在";
                                        return(Result(ri));
                                    }
                                }
                                else
                                {
                                    ri.Msg = "当前余票不足{0}份,请重新选择数量!".FormatWith(count);
                                    return(Result(ri));
                                }
                            }
                            else
                            {
                                ri.Msg = "该票种已无余票!请购买其它票种或联系主办方!";
                                return(Result(ri));
                            }
                        }
                        else
                        {
                            ri.Msg = "商品不存在";
                            return(Result(ri));
                        }
                        #endregion
                    }
                    else
                    {
                        #region 活动相关逻辑
                        seq      = "HD";
                        jointype = JoinItemTypeEnum.Party;
                        ActivityFee activityfee = ActivityFeeBLL.Instance.GetModel(id);
                        if (activityfee != null)
                        {
                            long activityId = GetRequest <long>("mid");
                            if (activityId != activityfee.ActivityId)
                            {
                                ri.Msg = "活动信息不正确!";
                                return(Result(ri));
                            }
                            if (activityfee.FeeType != 30)
                            {
                                ri.Msg = "活动价格信息有误!";
                                return(Result(ri));
                            }
                            else if (activityfee.Fee != fee)
                            {
                                ri.Msg = "活动价格被篡改,请刷新页面重新支付";
                                return(Result(ri));
                            }

                            if (activityfee.FeeCount > 0)
                            {
                                if (activityfee.FeeCount >= count)
                                {
                                    #region 判断活动是否能够报名
                                    Activity party = ActivityBLL.Instance.GetModel(activityId);
                                    if (party != null && party.IsDelete == 0)
                                    {
                                        if (!ActivityBLL.Instance.CanJoinParty(party).Ok)
                                        {
                                            return(Result(ri));
                                        }
                                    }
                                    else
                                    {
                                        ri.Msg = "活动不存在!";
                                        return(Result(ri));
                                    }
                                    #endregion
                                    id        = activityId;
                                    returnUri = "http://www.baixiaotangtop.com/party/detail/{0}".FormatWith(id);

                                    #region 创建报名活动信息

                                    string       linkMan = GetRequest("LinkMan");
                                    string       linktel = GetRequest("LinkTel");
                                    ActivityJoin ajoin   = new ActivityJoin();
                                    ajoin.ActivityId    = activityId;
                                    ajoin.FeeType       = activityfee.FeeType;
                                    ajoin.IsFeed        = 0;
                                    ajoin.RealPayFee    = activityfee.Fee * count;
                                    ajoin.JoinCount     = count;
                                    ajoin.JoinTime      = now;
                                    ajoin.JoinUserID    = UserID;
                                    ajoin.JoinUserName  = UserInfo.UserName;
                                    ajoin.ActivityFeeId = activityfee.ActivityFeeId;
                                    if (linkMan.IsNotNullOrEmpty())
                                    {
                                        ajoin.LinkMan = linkMan;
                                    }
                                    if (linktel.IsNotNullOrEmpty())
                                    {
                                        ajoin.LinkTel = linktel;
                                    }
                                    if ((buyItemID = ActivityJoinBLL.Instance.Add(ajoin, Tran)) < 1)
                                    {
                                        RollBack();
                                        ri.Msg = "创建订单失败!";
                                        return(Result(ri));
                                    }
                                }
                                else
                                {
                                    ri.Msg = "当前余票不足{0}份,请重新选择数量!".FormatWith(count);
                                    return(Result(ri));
                                }
                            }
                            else
                            {
                                ri.Msg = "该票种已无余票!请购买其它票种或联系主办方!";
                                return(Result(ri));
                            }
                            #endregion
                        }
                        else
                        {
                            ri.Msg = "活动不存在";
                            return(Result(ri));
                        }
                        #endregion
                    }
                }
                #endregion

                #region 记录报名填写项
                bool insertOk = true;
                //记录报名填写项
                if (joinItems != null && joinItems.Count > 0)
                {
                    foreach (var join in joinItems)
                    {
                        JoinItemAnswerExt model = new JoinItemAnswerExt()
                        {
                            BuyerID               = UserID,
                            CreateTime            = now,
                            ItemAnswer            = join.Value,
                            JoinItemQuestionExtId = join.Id,
                            JoinMainID            = id,
                            JoinType              = jointype.GetHashCode()
                        };
                        if (JoinItemAnswerExtBLL.Instance.Add(model, Tran) <= 0)
                        {
                            insertOk = false;
                            break;
                        }
                    }
                }
                if (!insertOk)
                {
                    RollBack();
                    ri.Msg = "创建订单失败!";
                    return(Result(ri));
                }
                #endregion

                #region 创建订单
                string payOrderID = string.Empty;
                string _msg_      = _orderService.CreateOrder(UserID, fee, id, type, desc, seq, count, now, Tran, out result, out payOrderID);
                if (result < 1)
                {
                    ri.Msg = _msg_;
                    RollBack();
                    return(Result(ri));
                }
                #endregion

                //记录用户购买单号
                SessionHelper.Set(payOrderID, buyItemID);

                #region 跳转支付
                ri = Redirect2Pay(desc, fee * count, payOrderID, returnUri, ConfigHelper.AppSettings("AliPayNotify"));
                if (ri.Ok)
                {
                    Commit();
                }
                else
                {
                    RollBack();
                }
                #endregion
            }
            catch
            {
                RollBack();
                ri.Msg = "支付异常,请重试!";
            }
            return(Result(ri));
        }
Пример #8
0
        public ActionResult Submit(long id, int fee, long feeid, int count, string LinkMan, string LinkTel, List <UserJoinItemViewModel> JoinItems)
        {
            ResultInfo ri = new ResultInfo();

            if (id > 0)
            {
                //根据ID查找详情
                _Activity activity = ActivityBLL.Instance.GetDetail(id, 0, false);
                if (activity != null)
                {
                    ri = ActivityBLL.Instance.CanJoinParty(activity);
                    if (ri.Ok)
                    {
                        ri = new ResultInfo();
                        BeginTran();

                        #region 报名
                        #region 获取报名费用

                        List <ActivityFee> feelist = activity.FeeList;
                        var feeInfo = feelist.FirstOrDefault(a => { return(a.ActivityFeeId == feeid && a.Fee == fee); });
                        if (feeInfo != null)
                        {
                            if (feeInfo.FeeCount > 0)
                            {
                                if (feeInfo.FeeCount >= count)
                                {
                                    //判断是否需要扣费
                                    //TODO

                                    int coinType = feeInfo.FeeType == 10 ? 1 : feeInfo.FeeType == 20 ? 2 : 0;
                                    int coin     = Convert.ToInt32(feeInfo.Fee.Value) * count;//计算总费用

                                    bool canJoin = true;
                                    if (fee != 0)
                                    {
                                        canJoin = UserExtBLL.Instance.HasEnoughCoin(coinType, coin, UserID);
                                    }
                                    //记录参加活动
                                    if (canJoin)
                                    {
                                        ActivityJoin ajoin = new ActivityJoin();
                                        ajoin.ActivityId    = activity.ActivityId;
                                        ajoin.FeeType       = feeInfo.FeeType;
                                        ajoin.IsFeed        = 1;
                                        ajoin.RealPayFee    = coin;
                                        ajoin.JoinCount     = count;
                                        ajoin.JoinTime      = DateTime.Now;
                                        ajoin.JoinUserID    = UserID;
                                        ajoin.JoinUserName  = UserInfo.UserName;
                                        ajoin.ActivityFeeId = feeInfo.ActivityFeeId;
                                        ajoin.LinkMan       = LinkMan;
                                        ajoin.LinkTel       = LinkTel;
                                        if (ActivityJoinBLL.Instance.Add(ajoin, Tran) > 0)
                                        {
                                            bool insertOk = true;
                                            //记录报名填写项
                                            if (JoinItems != null && JoinItems.Count > 0)
                                            {
                                                foreach (var join in JoinItems)
                                                {
                                                    JoinItemAnswerExt model = new JoinItemAnswerExt()
                                                    {
                                                        BuyerID               = UserID,
                                                        CreateTime            = DateTime.Now,
                                                        ItemAnswer            = join.Value,
                                                        JoinItemQuestionExtId = join.Id,
                                                        JoinMainID            = activity.ActivityId,
                                                        JoinType              = 1
                                                    };
                                                    if (JoinItemAnswerExtBLL.Instance.Add(model, Tran) <= 0)
                                                    {
                                                        insertOk = false;
                                                        break;
                                                    }
                                                }
                                            }

                                            if (insertOk)
                                            {
                                                //更新剩余名额
                                                if (ActivityFeeBLL.Instance.UpdateCount(count, feeInfo.ActivityFeeId, Tran))
                                                {
                                                    ////生成订单
                                                    //string orderDesc = GetRequest("desc", "参加" + activity.Title);
                                                    ////添加订单
                                                    //int _orderResult = 0;
                                                    //string _orderNo = string.Empty;
                                                    //var addOrder = _orderService.CreateOrder(UserID, fee, id, OrderEnumType.Party.GetHashCode(), orderDesc, "HD", count, Tran, out _orderResult, out _orderNo);
                                                    //if (_orderResult > 0)
                                                    //{
                                                    if (fee == 0)
                                                    {
                                                        ri.Ok  = true;
                                                        ri.Msg = "报名成功";
                                                        Commit();
                                                    }
                                                    else
                                                    {
                                                        //报名成功
                                                        //扣除相应数据
                                                        //用户帐户减去相应的积分或金钱
                                                        if (UserExtBLL.Instance.SubScore(UserID, coin, coinType, Tran))
                                                        {
                                                            if (ScoreCoinLogBLL.Instance.Log(-coin, coinType, CoinSourceEnum.JoinActivity, UserID, UserInfo.UserName, Tran))
                                                            {
                                                                Commit();
                                                                ri.Ok  = true;
                                                                ri.Msg = "报名成功";
                                                            }
                                                            else
                                                            {
                                                                ri.Msg = "报名失败";
                                                                RollBack();
                                                            }
                                                        }
                                                        else
                                                        {
                                                            ri.Msg = "报名失败";
                                                            RollBack();
                                                        }
                                                    }
                                                    if (ri.Ok)
                                                    {
                                                        //通知
                                                        NoticeBLL.Instance.OnBuySuccess_Notice_Buyer(UserID, DateTime.Now, fee == 0 ? true : false, "{0}{1}".FormatWith(coin, feeInfo.FeeType == 10 ? "积分" : feeInfo.FeeType == 20 ? "VIP分" : string.Empty), count, ConfigHelper.AppSettings("PartyDetail").FormatWith(id), activity.Title, false, NoticeTypeEnum.Party_Join);
                                                    }
                                                    //}
                                                    //else
                                                    //{
                                                    //    RollBack();
                                                    //    ri.Msg = addOrder;
                                                    //}
                                                }
                                                else
                                                {
                                                    RollBack();
                                                }
                                            }
                                            else
                                            {
                                                RollBack();
                                            }
                                        }
                                        else
                                        {
                                            RollBack();
                                        }
                                    }
                                    else
                                    {
                                        ri.Msg = $"对不起,您没有足够的{(coinType == 1 ? "积分" : "金钱")}";
                                    }
                                }
                                else
                                {
                                    ri.Type = 1;
                                    ri.Msg  = "当前余票不足{0}份,请重新选择数量!".FormatWith(count);
                                }
                            }
                            else
                            {
                                ri.Msg = "该票种已无余票!请购买其它票种或联系主办方!";
                            }
                        }
                        else
                        {
                            ri.Msg = "费用异常!";
                        }
                        #endregion
                    }
                    #endregion
                }
                else
                {
                    ri.Msg = "活动不存在";
                }
            }
            else
            {
                ri.Msg = "活动详情错误";
            }
            return(Result(ri));
        }
Пример #9
0
 /// <summary>
 /// 修改一条记录
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <returns></returns>
 public bool Edit(ActivityJoin model, SqlTransaction tran)
 {
     return(dal.Update(model, tran));
 }
Пример #10
0
 /// <summary>
 /// 添加一条记录,没有任何逻辑
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <returns></returns>
 public int Add(ActivityJoin model, SqlTransaction tran)
 {
     return(dal.Add(model, tran));
 }