コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Update(ActivityFee model, SqlTransaction tran = null)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ActivityFee set ");
            strSql.Append("FeeType=@FeeType,Fee=@Fee,FeeCount=@FeeCount,ActivityId=@ActivityId,FeeName=@FeeName");

            strSql.Append(" where ActivityFeeId=@ActivityFeeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FeeType",       model.FeeType),
                new SqlParameter("@Fee",           model.Fee),
                new SqlParameter("@FeeCount",      model.FeeCount),
                new SqlParameter("@ActivityId",    model.ActivityId),
                new SqlParameter("@FeeName",       model.FeeName),


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

            if (tran == null)
            {
                return(SqlHelper.ExecuteSql(strSql.ToString(), CommandType.Text, parameters) > 0);
            }
            else
            {
                return(SqlHelper.ExecuteSql(tran, CommandType.Text, strSql.ToString(), parameters) > 0);
            }
        }
コード例 #2
0
        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(ActivityFee model, SqlTransaction tran = null)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ActivityFee(");
            strSql.Append(" FeeType,Fee,FeeCount,ActivityId,FeeName )");
            strSql.Append(" values (");
            strSql.Append("@FeeType,@Fee,@FeeCount,@ActivityId,@FeeName);select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FeeType",    model.FeeType),
                new SqlParameter("@Fee",        model.Fee),
                new SqlParameter("@FeeCount",   model.FeeCount),
                new SqlParameter("@ActivityId", model.ActivityId),
                new SqlParameter("@FeeName",    model.FeeName),
            };

            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));
        }
コード例 #3
0
        /// <summary>
        /// 修改 (可能有其他业务逻辑检查)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResultInfo Update(ActivityFee model, SqlTransaction tran = null)
        {
            ResultInfo ri = new ResultInfo();

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

            return(ri);
        }
コード例 #4
0
        /// <summary>
        /// 保存 (可能有其他业务逻辑检查)
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns></returns>
        public ResultInfo Create(ActivityFee model)
        {
            ResultInfo ri = new ResultInfo();

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

            int result = Add(model);

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

            return(ri);
        }
コード例 #5
0
ファイル: PayController.cs プロジェクト: ccxlimin/baixiaotang
        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));
        }
コード例 #6
0
 /// <summary>
 /// 修改一条记录
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <returns></returns>
 public bool Edit(ActivityFee model, SqlTransaction tran = null)
 {
     return(dal.Update(model, tran));
 }
コード例 #7
0
 /// <summary>
 /// 添加一条记录,没有任何逻辑
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <returns></returns>
 public int Add(ActivityFee model, SqlTransaction tran = null)
 {
     return(dal.Add(model, tran));
 }