Ejemplo n.º 1
0
        public string SetFract(FractHandlerParam pm)
        {
            Dictionary <int, int> fract = new User_FractL(this.curHelp).GetFract(pm.FractIdentifier);

            //设置积分
            int integral;

            if (fract.TryGetValue(0, out integral))
            {
                if (integral > 0)
                {
                    int    __integral = integral * pm.NT;
                    string __msg      = __integral > 0 ? ",增加" : ",扣除";
                    string slog       = new User_InfoL(this.curHelp).SetUserIntegral(pm.UserID, pm.FK_All, pm.LogIdentifier, __integral, pm.Operator, pm.Remark + __msg + __integral + "积分");
                    if (slog != "1")
                    {
                        return(slog);
                    }
                }
            }

            //设置经验
            int exp;

            if (fract.TryGetValue(1, out exp))
            {
                if (exp > 0)
                {
                    int    __exp = exp * pm.NT;
                    string __msg = __exp > 0 ? ",增加" : ",扣除";

                    string slog = new User_InfoL(this.curHelp).SetUserExp(pm.UserID, pm.FK_All, pm.LogIdentifier, __exp, pm.Operator, pm.Remark + __msg + __exp + "经验");
                    if (slog != "1")
                    {
                        return(slog);
                    }
                }
            }

            return("1");
        }
Ejemplo n.º 2
0
        public static int Reg1_Trans(IDbHelp tHelp, object obj)
        {
            Reg1_TransM    lsTrans = (Reg1_TransM)obj;
            User_InfoM     infoMod = lsTrans.infoMod;
            User_PersonalM perMod  = lsTrans.perMod;
            User_ContactM  conMod  = lsTrans.conMod;

            if (lsTrans.IsUseCard)
            {
                if (new User_InfoL(tHelp).IsUserCard(infoMod.UserCard))
                {
                    lsTrans.returnValue = "此会员卡卡号已被人注册";
                    return(0);
                }
            }

            string sql = "insert into User_Info(FK_User_Level,UserName,UserPwd,OpenIdentity,Email,UserCard,UserBTJ) values(@FK_User_Level,@UserName,@UserPwd,@OpenIdentity,@Email,@UserCard,@UserBTJ);select SCOPE_IDENTITY()";

            IDataParameter[] dp =
            {
                DbHelp.Def.AddParam("@FK_User_Level", infoMod.FK_User_Level),
                DbHelp.Def.AddParam("@UserName",      infoMod.UserName),
                DbHelp.Def.AddParam("@UserPwd",       infoMod.UserPwd),
                DbHelp.Def.AddParam("@OpenIdentity",  infoMod.OpenIdentity),
                DbHelp.Def.AddParam("@Email",         infoMod.Email),
                DbHelp.Def.AddParam("@UserCard",      infoMod.UserCard),
                DbHelp.Def.AddParam("@UserBTJ",       infoMod.UserBTJ),
            };

            int uid = int.Parse(tHelp.First(sql, dp, "0").ToString());

            //try
            //{
            //uid = int.Parse(tHelp.First(sql, dp, "0").ToString());
            //}
            //catch (Exception ex)
            //{
            //    lsTrans.returnValue = "注册失败:" + ex.Message;
            //    return 0;
            //}

            if (uid <= 0)
            {
                lsTrans.returnValue = "注册失败2";
                return(0);
            }

            sql = "insert into User_Personal(FK_User,RealName,Sex,Area,Address,Tel,FixTel) values(@FK_User,@RealName,@Sex,@Area,@Address,@Tel,@FixTel)";
            IDataParameter[] dp1 =
            {
                DbHelp.Def.AddParam("@FK_User",  uid),
                DbHelp.Def.AddParam("@RealName", perMod.RealName),
                DbHelp.Def.AddParam("@Sex",      perMod.Sex),
                DbHelp.Def.AddParam("@Area",     perMod.Area),
                DbHelp.Def.AddParam("@Address",  perMod.Address),
                DbHelp.Def.AddParam("@Tel",      perMod.Tel),
                DbHelp.Def.AddParam("@FixTel",   perMod.FixTel),
            };
            //User_Personal
            if (tHelp.Update(sql, dp1) <= 0)
            {
                lsTrans.returnValue = "注册失败1";
                return(0);
            }

            //是否添加收货地址
            if (conMod.Name.Length > 0 && conMod.Address.Length > 0 && (conMod.Tel.Length > 0 || conMod.FixTel.Length > 0) && conMod.FK_Area > 0)
            {
                User_ContactL uc = new User_ContactL(tHelp);
                conMod.FK_User = uid;
                string sMsg = string.Empty;

                if (uc.Add(conMod, ref sMsg))//添加收货地址
                {
                }
                else
                {
                    lsTrans.returnValue = "注册失败:" + sMsg;
                    return(0);
                }
            }

            //if (uid > 0)//账号添加成功
            //{
            //    //sql = "insert into User_Personal(FK_User,RealName,Sex,Area,Address,Tel,FixTel) values(@FK_User,@RealName,@Sex,@Area,@Address,@Tel,@FixTel)";

            //    //IDataParameter[] dp1 = {
            //    //                    DbHelp.Def.AddParam("@FK_User",uid),
            //    //                    DbHelp.Def.AddParam("@RealName",perMod.RealName),
            //    //                    DbHelp.Def.AddParam("@Sex",perMod.Sex),
            //    //                    DbHelp.Def.AddParam("@Area",perMod.Area),
            //    //                    DbHelp.Def.AddParam("@Address",perMod.Address),
            //    //                    DbHelp.Def.AddParam("@Tel",perMod.Tel),
            //    //                    DbHelp.Def.AddParam("@FixTel",perMod.FixTel),
            //    //                       };

            //    //bool isUser_Personal;
            //    //try
            //    //{
            //    //    isUser_Personal = tHelp.Update(sql, dp1) > 0;
            //    //}
            //    //catch (Exception ex)
            //    //{
            //    //    lsTrans.returnValue = "注册失败:" + ex.Message;
            //    //    return 0;
            //    //}

            //    if (isUser_Personal)//个人用户信息添加成功
            //    {
            //        //是否添加收货地址

            //        //if (conMod.Name.Length > 0 && conMod.Address.Length > 0 && (conMod.Tel.Length > 0 || conMod.FixTel.Length > 0) && conMod.FK_Area > 0)
            //        //{
            //        //    User_ContactL uc = new User_ContactL(tHelp);
            //        //    conMod.FK_User = uid;
            //        //    string sMsg = string.Empty;

            //        //    if (uc.Add(conMod, ref sMsg))//添加收货地址
            //        //    {
            //        //    }
            //        //    else
            //        //    {
            //        //        lsTrans.returnValue = "注册失败:" + sMsg;
            //        //        return 0;
            //        //    }
            //        //}
            //        //else
            //        //{
            //        //}
            //    }
            //    else
            //    {
            //        //lsTrans.returnValue = "注册失败1";
            //        //return 0;
            //    }
            //}
            //else
            //{
            //    //lsTrans.returnValue = "注册失败2";
            //    //return 0;
            //}

            //增加积分或经验
            User_FractHandler.FractHandlerParam ufParam = new User_FractHandler.FractHandlerParam(uid, "system", 1, "reg", "reg", "注册成功 \"" + infoMod.UserName + "\"");
            string slog = new User_FractHandler(tHelp).SetFract(ufParam);

            if (slog != "1")
            {
                lsTrans.returnValue = slog;
                return(0);
            }

            //是否使用会员卡
            if (lsTrans.IsUseCard)
            {
                //设置会员卡状态
                sql = "update User_Card set FK_User=@FK_User,card_Status=1 where card_Number=@card_Number";
                IDataParameter[] dp_usercard =
                {
                    DbHelp.Def.AddParam("@FK_User",     uid),
                    DbHelp.Def.AddParam("@card_Number", infoMod.UserCard),
                };
                if (tHelp.Update(sql, dp_usercard) <= 0)
                {
                    lsTrans.returnValue = "注册失败2";
                    return(0);
                }

                slog = new User_InfoL(tHelp).SetUserExp(uid, uid, "reg_card", lsTrans.Exp, "system", "注册使用会员卡 \"" + infoMod.UserCard + "\" 赠送" + lsTrans.Exp + "经验");
                if (slog != "1")
                {
                    lsTrans.returnValue = slog;
                    return(0);
                }
            }

            lsTrans.returnValue = "1";
            return(1);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取实际用户价格
        /// </summary>
        /// <param name="drw"></param>
        /// <returns></returns>
        private string GetUserPrice(DataRow drw)
        {
            int    item  = int.Parse(drw["Item"].ToString());
            string price = drw["Price"].ToString();

            if (this.userLevel == 0)
            {
                return(price);
            }

            if (User_InfoL.IsTeam(this.userIdentity))
            {
                if ((item & 2048) == 2048)//企业价
                {
                    price = drw["Price2"].ToString();
                }
            }
            else
            {
                if ((item & 4) == 4)//促销
                {
                    price = drw["Price1"].ToString();
                }
                else if ((item & 16) == 16)//秒杀
                {
                    DateTime MS_StartTime = Fn.IsDate(drw["MS_StartTime"].ToString(), DateTime.Now.AddDays(-1));
                    DateTime MS_EndTime   = Fn.IsDate(drw["MS_EndTime"].ToString(), DateTime.Now.AddDays(-1));
                    DateTime now          = DateTime.Now;

                    if (MS_StartTime > now || MS_EndTime < now)
                    {
                    }
                    else
                    {
                        price = drw["Price1"].ToString();
                    }
                }
                else//获取会员价
                {
                    string levelPrice = drw["LevelPrice"].ToString();//自定义会员价格
                    //若有自定义会员价格
                    if (levelPrice.Length > 0)
                    {
                        if (Fn.IsDoubleBool(levelPrice))
                        {
                            price = levelPrice;//按自定义会员价格
                        }
                    }
                    else//按会员折扣价
                    {
                        if (!Fn.IsDoubleBool(price))
                        {
                            return("0");
                        }
                        double userDiscount = User_LevelL.GetLevelDiscount(this.userLevel);

                        return((Fn.IsDouble(price, 0) * userDiscount).ToString());
                    }
                }
            }

            if (!Fn.IsDoubleBool(price))
            {
                return("0");
            }
            else
            {
                return(price);
            }
        }
Ejemplo n.º 4
0
        public static int Reg_Trans(IDbHelp tHelp, object obj)
        {
            Reg_TransM     lsTrans = (Reg_TransM)obj;
            User_InfoM     infoMod = lsTrans.infoMod;
            User_PersonalM perMod  = lsTrans.perMod;

            if (lsTrans.IsUseCard)
            {
                if (new User_InfoL(tHelp).IsUserCard(infoMod.UserCard))
                {
                    lsTrans.returnValue = "此会员卡卡号已被人注册";
                    return(0);
                }
            }

            string sql = "insert into User_Info(FK_User_Level,UserName,UserPwd,OpenIdentity,Email,UserCard,UserBTJ) values(@FK_User_Level,@UserName,@UserPwd,@OpenIdentity,@Email,@UserCard,@UserBTJ);select SCOPE_IDENTITY()";

            IDataParameter[] dp =
            {
                DbHelp.Def.AddParam("@FK_User_Level", infoMod.FK_User_Level),
                DbHelp.Def.AddParam("@UserName",      infoMod.UserName),
                DbHelp.Def.AddParam("@UserPwd",       infoMod.UserPwd),
                DbHelp.Def.AddParam("@OpenIdentity",  infoMod.OpenIdentity),
                DbHelp.Def.AddParam("@Email",         infoMod.Email),
                DbHelp.Def.AddParam("@UserCard",      infoMod.UserCard),
                DbHelp.Def.AddParam("@UserBTJ",       infoMod.UserBTJ),
            };

            //User_Info
            int uid = int.Parse(tHelp.First(sql, dp, "0").ToString());

            if (uid <= 0)
            {
                lsTrans.returnValue = "注册失败1";
                return(0);
            }

            sql = "insert into User_Personal(FK_User) values(@FK_User)";
            IDataParameter[] dp1 =
            {
                DbHelp.Def.AddParam("@FK_User", uid),
            };
            //User_Personal
            if (tHelp.Update(sql, dp1) <= 0)
            {
                lsTrans.returnValue = "注册失败";
                return(0);
            }

            User_FractHandler.FractHandlerParam ufParam = new User_FractHandler.FractHandlerParam(uid, "system", 1, "reg", "reg", "注册成功 \"" + infoMod.UserName + "\"");
            string slog = new User_FractHandler(tHelp).SetFract(ufParam);

            if (slog != "1")
            {
                lsTrans.returnValue = slog;
                return(0);
            }

            //是否使用会员卡
            if (lsTrans.IsUseCard)
            {
                //设置会员卡状态
                sql = "update User_Card set FK_User=@FK_User,card_Status=1 where card_Number=@card_Number";
                IDataParameter[] dp_usercard =
                {
                    DbHelp.Def.AddParam("@FK_User",     uid),
                    DbHelp.Def.AddParam("@card_Number", infoMod.UserCard),
                };
                if (tHelp.Update(sql, dp_usercard) <= 0)
                {
                    lsTrans.returnValue = "注册失败2";
                    return(0);
                }

                //赠送经验
                slog = new User_InfoL(tHelp).SetUserExp(uid, uid, "reg_card", lsTrans.Exp, "system", "注册使用会员卡 \"" + infoMod.UserCard + "\" 赠送" + lsTrans.Exp + "经验");
                if (slog != "1")
                {
                    lsTrans.returnValue = slog;
                    return(0);
                }
            }

            lsTrans.returnValue = "1";
            return(1);
        }
Ejemplo n.º 5
0
        public static int AddOrder_Trans(IDbHelp thelp, object obj)
        {
            LS_TransM        tMod    = (LS_TransM)obj;
            Ord_InfoM        Mod     = tMod.Mod;
            IList <Ord_ProM> IMod    = tMod.IMod;
            IMessage         msgAjax = tMod.msgAjax;

            SqlData1 sdata = new SqlData1(thelp);
            string   sql   = "UserIdentity,FK_Pay,PayType,OrdNumber,FK_User,UserName,RealName,FixTel,Tel,Area,Address,TotalPrice,Status,StatusPay,Caption,AreaTime,ToMinTime,ToMaxTime,FK_AdminUser_PeiSong,FK_AdminUser_ChuKu,UserType,UserLevel,UserCard";   //添加订单

            if (User_InfoL.IsTeam(Mod.UserIdentity))                                                                                                                                                                                                           //若是团体订购,则添加团体名称
            {
                sql = "UserIdentity,TeamName,FK_Pay,PayType,OrdNumber,FK_User,UserName,RealName,FixTel,Tel,Area,Address,TotalPrice,Status,StatusPay,Caption,AreaTime,ToMinTime,ToMaxTime,FK_AdminUser_PeiSong,FK_AdminUser_ChuKu,UserType,UserLevel,UserCard"; //添加订单
            }

            //若有购物券
            if (Mod.Ticket_1_Number.Length > 0)
            {
                string           sql_Act_1 = "update User_Ticket_1 set tic_Status=1,FK_User="******" where tic_Status=0 and tic_Number=@tic_Number";
                IDataParameter[] dp_Act1   =
                {
                    DbHelp.Def.AddParam("@tic_Number", Mod.Ticket_1_Number),
                };

                if (thelp.Update(sql_Act_1, dp_Act1) > 0)
                {
                    sql += ",Ticket_1_Number,Ticket_1_Price";

                    //总价减去抵金券金额
                    Mod.TotalPrice = Mod.TotalPrice - Mod.Ticket_1_Price;

                    //若总价格小于0 则设置为0
                    if (Mod.TotalPrice <= 0)
                    {
                        Mod.TotalPrice = 0;
                    }
                }
                else
                {
                    msgAjax.Error("抵金券号码错误3" + Mod.Ticket_1_Number);
                    return(0);
                }
            }

            int iOrdID = 0;

            try
            {
                iOrdID = sdata.AddReturnID(Mod, sql);
                if (iOrdID > 0)
                {
                    string sRemark = "订单-创建:<ss>" + Mod.OrdNumber + "</ss>";

                    Log_OrdM mod = new Log_OrdM();
                    mod.FK_Ord   = iOrdID;
                    mod.FK_User  = Mod.FK_User;
                    mod.Operator = Mod.UserName;
                    mod.Remark   = sRemark;

                    if (!new Log_OrdL(thelp).Add(mod))
                    {
                        msgAjax.Error("err:2001");
                        return(0);
                    }
                }
            }
            catch (Exception ex)
            {
                msgAjax.Error(ex.Message);
                return(0);
            }

            if (iOrdID > 0)//若生成订单成功
            {
                foreach (Ord_ProM mod in IMod)
                {
                    //将添加好的OrdId 到订单产品列表
                    mod.FK_Order    = iOrdID;
                    mod.op_ProLevel = Mod.UserType;
                }

                int addN = 0;//公添加了多少产品

                foreach (Ord_ProM mod_pro in IMod)
                {
                    string sql_Pro = "FK_Order,FK_Pro,FK_User,op_ProName,op_ProNumber,op_ProUnit,op_ProUnitNum,op_ProPrice,op_UserPrice,op_UserTotalPrice,op_Num,op_CurProStock,op_ActualNum,op_Status,op_ProLevel"; //添加订单产品

                    string          sql_1 = "FK_A_Admin_User,FK_Pro,np_ProNumber,np_ProUnit,np_ProUnitNum,np_ProName,np_Num,np_CurProStock,np_Status,np_Type,np_ProLevel";                                           //添加采购任务
                    E_NeedPurchaseM mod_1 = new E_NeedPurchaseM();
                    mod_1.FK_A_Admin_User = 0;
                    mod_1.FK_Pro          = mod_pro.FK_Pro;
                    mod_1.np_ProName      = mod_pro.op_ProName;
                    mod_1.np_ProNumber    = mod_pro.op_ProNumber;
                    mod_1.np_ProUnit      = mod_pro.op_ProUnit;
                    mod_1.np_ProUnitNum   = mod_pro.op_ProUnitNum;
                    mod_1.np_CurProStock  = mod_pro.op_CurProStock;
                    mod_1.np_Num          = mod_pro.op_Num;
                    mod_1.np_Status       = 0; //未入库
                    mod_1.np_Type         = 0; //前台提交
                    mod_1.np_ProLevel     = mod_pro.op_ProLevel;

                    string sql_2 = "if exists(select top 1 1 from E_BookPro where FK_Pro=@FK_Pro)"
                                   + " begin update E_BookPro set bp_Num=bp_Num+@bp_Num where FK_Pro=@FK_Pro end"
                                   + " else"
                                   + " begin insert into E_BookPro(FK_A_Admin_User,FK_Pro,bp_ProNumber,bp_ProUnit,bp_ProUnitNum,bp_ProName,bp_Num) values(@FK_A_Admin_User,@FK_Pro,@bp_ProNumber,@bp_ProUnit,@bp_ProUnitNum,@bp_ProName,@bp_Num) end";//总预订产品

                    IDataParameter[] dp_2 =
                    {
                        DbHelp.Def.AddParam("@FK_A_Admin_User",                     0),
                        DbHelp.Def.AddParam("@FK_Pro",          mod_pro.FK_Pro),
                        DbHelp.Def.AddParam("@bp_ProNumber",    mod_pro.op_ProNumber),
                        DbHelp.Def.AddParam("@bp_ProName",      mod_pro.op_ProName),
                        DbHelp.Def.AddParam("@bp_ProUnit",      mod_pro.op_ProUnit),
                        DbHelp.Def.AddParam("@bp_ProUnitNum",   mod_pro.op_ProUnitNum),
                        DbHelp.Def.AddParam("@bp_Num",          mod_pro.op_Num),
                    };

                    try
                    {
                        if (sdata.Add(mod_pro, sql_Pro) &&
                            sdata.Add(mod_1, sql_1) &&
                            (thelp.Update(sql_2, dp_2) > 0)
                            )
                        {
                            addN++;
                        }
                    }
                    catch (Exception ex)
                    {
                        msgAjax.Error(ex.Message + mod_pro.FK_Pro);
                        return(0);
                    }
                }

                //若添加的产品 等于 购物车的产品数量(即全部产品添加完毕)
                if (addN == IMod.Count)
                {
                    //清空购物车产品
                    new User_CartL(thelp).DeleteAll(Mod.FK_User);

                    //若选择预存支付 则冻结金额
                    if (Mod.PayType == "yck")
                    {
                        string setF = new User_InfoL(thelp).SetFreezeMoney(Mod.FK_User, Mod.TotalPrice, Mod.UserName, "订单-创建:<ss>" + Mod.OrdNumber + "</ss>", Fn.SCNumber());
                        if (setF != "1")
                        {
                            msgAjax.Error(setF);
                            return(0);
                        }
                    }

                    msgAjax.AddMessage("jumpurl", "orderComplete.aspx?id=" + iOrdID);
                    msgAjax.Success("提交成功");
                    return(1);
                }
                else
                {
                    msgAjax.Error("提交失败,共有" + IMod.Count + "个产品,但只提交了" + addN + "产品");
                    return(0);
                }
            }
            else
            {
                msgAjax.Error("订单未能提交,重试一下");
                return(0);
            }
        }