Exemple #1
0
        public GiftCreateViewModel GetEditDetail(long id, JoinItemTypeEnum joinItemType)
        {
            var ds = dal.GetEditDetail(id, joinItemType.GetHashCode());
            GiftCreateViewModel model = new GiftCreateViewModel()
            {
                Gift         = ModelConvertHelper <Gift> .ConverToModel(ds.Tables[0]),
                GiftFees     = ModelConvertHelper <GiftFee> .ConvertToList(ds.Tables[1]),
                JoinItemQues = ModelConvertHelper <JoinItemQuestionExt> .ConvertToList(ds.Tables[2])
            };

            return(model);
        }
Exemple #2
0
        public _Gift GetDetail(long id, long userid, JoinItemTypeEnum joinItemType, bool searchMyJoinItem)
        {
            var   ds     = dal.GetGiftDetail(id, userid, joinItemType.GetHashCode(), searchMyJoinItem);
            _Gift amodel = ModelConvertHelper <_Gift> .ConverToModel(ds.Tables[0]);

            amodel.FeeList = ModelConvertHelper <GiftFee> .ConvertToList(ds.Tables[1]);

            amodel.JoinQuestions = ModelConvertHelper <JoinItemQuestionExt> .ConvertToList(ds.Tables[2]);

            if (searchMyJoinItem)
            {
                amodel.JoinFeeList = ModelConvertHelper <UserBuyGiftListInfo> .ConvertToList(ds.Tables[3]);
            }
            return(amodel);
        }
Exemple #3
0
        public GiftBuyerManageViewModel GetBuyerList(long id, JoinItemTypeEnum joinItemType)
        {
            var ds = dal.GetBuyerList(id, joinItemType.GetHashCode());

            var model = new GiftBuyerManageViewModel()
            {
            };

            if (ds.Tables[0].IsNotNullAndRowCount())
            {
                model.GiftInfo = ModelConvertHelper <Gift> .ConverToModel(ds.Tables[0]);

                model.BuyList = ModelConvertHelper <_BuyManageInfo> .ConvertToList(ds.Tables[1]);

                model.JoinQuestions = ModelConvertHelper <JoinItemQuestionExt> .ConvertToList(ds.Tables[2]);

                model.JoinAnswers = ModelConvertHelper <JoinItemAnswerExt> .ConvertToList(ds.Tables[3]);
            }
            return(model);
        }
        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));
        }