示例#1
0
        /// <summary>
        /// 会员间赠送激活码
        /// </summary>
        /// <param name="soucememberID">原始会员ID</param>
        /// <param name="type">赠送激活码类型</param>
        /// <param name="acceptMemberPhone">接受会员电话</param>
        /// <param name="count">赠送数量</param>
        /// <returns>返回值(-1 接受会员不存在 -2 没有足够的激活币赠送 0 数据库操作失败 1 成功)</returns>
        public int GiveActiveCodeFromMember(int soucememberID, int type, string acceptMemberPhone, int count)
        {
            int result = 0;
            //读取接受会员信息
            MemberInfoModel member = GetMember(acceptMemberPhone);

            if (member == null)
            {
                return(-1);
            }
            if (member.MStatus != 2)
            {
                return(-1);
            }
            //开启事务
            using (TransactionScope scope = new TransactionScope())
            {
                //查询该会员名下可用类型的激活码数量
                List <MemberActiveCodeModel> aclist = GetMemberActiveCodeList(soucememberID, type);
                if (aclist.Count < count)
                {
                    return(-2);
                }
                //修改激活码的所有者信息
                string         sqltxt   = @"UPDATE TOP ( @count)
        MemberActiveCode
SET     MemberID = @memberid ,
        MemberPhone = @MemberPhone ,
        MemberName = @MemberName
WHERE   MemberID = @soucemid
        AND AMStatus = 1
        AND AMType = @AMType";
                SqlParameter[] paramter =
                {
                    new SqlParameter("@memberid",    member.ID),
                    new SqlParameter("@MemberPhone", member.MobileNum),
                    new SqlParameter("@MemberName",  member.TruethName),
                    new SqlParameter("@soucemid",    soucememberID),
                    new SqlParameter("@AMType",      type),
                    new SqlParameter("@count",       count)
                };
                int row = helper.ExecuteSql(sqltxt, paramter);
                if (row < 0)
                {
                    return(0);
                }
                int rowcount = row;
                //记录转出者名下日志
                MemberInfoModel    sourcemodel = GetMember(soucememberID);
                ActiveCodeLogModel souce       = new ActiveCodeLogModel();
                souce.MemberID    = soucememberID;
                souce.MemberName  = sourcemodel.TruethName;
                souce.MemberPhone = sourcemodel.MobileNum;
                souce.ActiveCode  = "";
                souce.AID         = 0;
                souce.Remark      = " 转出" + rowcount.ToString() + "个" + (type == 1 ? "激活币" : "排单币");
                row = OperateLogDAL.AddActiveCodeLog(souce);
                if (row < 0)
                {
                    return(0);
                }
                //记录转入者名下日志
                ActiveCodeLogModel accept = new ActiveCodeLogModel();
                accept.MemberID    = member.ID;
                accept.MemberName  = member.TruethName;
                accept.MemberPhone = member.MobileNum;
                accept.ActiveCode  = "";
                accept.AID         = 0;
                accept.Remark      = "接收" + rowcount.ToString() + "个" + (type == 1 ? "激活币" : "排单币");
                row = OperateLogDAL.AddActiveCodeLog(accept);
                if (row < 0)
                {
                    return(0);
                }
                //记录系统操作日志
                try
                {
                    UserBehaviorLogModel log = new UserBehaviorLogModel();
                    log.AOrderCode     = "";
                    log.BehaviorSource = 1;
                    if (type == 1)
                    {
                        log.BehaviorType = 8;
                    }
                    else
                    {
                        log.BehaviorType = 7;
                    }
                    log.HOrderCode  = "";
                    log.MemberID    = member.ID;
                    log.MemberName  = member.TruethName;
                    log.MemberPhone = member.MobileNum;
                    log.ProcAmount  = 0;
                    log.Remark      = "会员:" + member.MobileNum + " 得到来自" + sourcemodel.MobileNum + "转来的" + rowcount.ToString() + "个" + (type == 1 ? "激活币" : "排单币");
                    UserBehaviorLogDAL.AddUserBehaviorLog(log);
                }
                catch { }
                scope.Complete();
                result = 1;
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// 分配激活码
        /// </summary>
        /// <param name="codes"></param>
        /// <param name="memberphone"></param>
        /// <returns></returns>
        public int AssignedCode(List <string> codes, string memberphone)
        {
            int result = 0;
            //得到激活码信息
            List <ActiveCodeModel> codelist = GetCodeMassage(codes);
            //得到被分配会员信息
            MemberInfoModel member = GetMember(memberphone);

            if (member.MStatus != 2)
            {
                return(0);
            }
            //开启事务,分配激活码
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    //更改原表状态
                    result = UpdateStatus(codelist);
                    if (result < codelist.Count)
                    {
                        throw new Exception("更改激活码原表失败");
                    }
                    List <MemberActiveCodeModel> maclist = new List <MemberActiveCodeModel>();
                    foreach (var item in codelist)
                    {
                        MemberActiveCodeModel mac = new MemberActiveCodeModel();
                        mac.ActiveCode  = item.ActivationCode;
                        mac.MemberID    = member.ID;
                        mac.MemberName  = member.TruethName;
                        mac.MemberPhone = member.MobileNum;
                        mac.AMType      = item.AType;
                        maclist.Add(mac);
                    }
                    result = AddMemberActiveCode(maclist);
                    if (result < 1)
                    {
                        return(0);
                    }
                    ActiveCodeLogModel activemodel = new ActiveCodeLogModel();
                    activemodel.ActiveCode  = "";
                    activemodel.Addtime     = DateTime.Now;
                    activemodel.AID         = 0;
                    activemodel.MemberID    = member.ID;
                    activemodel.MemberName  = member.TruethName;
                    activemodel.MemberPhone = member.MobileNum;
                    activemodel.Remark      = "接收" + codelist.Count + "个" + (codelist[0].AType == 1 ? "激活币" : "排单币");
                    OperateLogDAL.AddActiveCodeLog(activemodel);
                    try
                    {
                        UserBehaviorLogModel log = new UserBehaviorLogModel();
                        log.AOrderCode     = "";
                        log.BehaviorSource = 2;
                        if (codelist[0].AType == 1)
                        {
                            log.BehaviorType = 8;
                        }
                        else
                        {
                            log.BehaviorType = 7;
                        }
                        log.HOrderCode  = "";
                        log.MemberID    = member.ID;
                        log.MemberName  = member.TruethName;
                        log.MemberPhone = member.MobileNum;
                        log.ProcAmount  = 0;
                        log.Remark      = "系统派发激活码/排单币" + codelist.Count + "个";
                        UserBehaviorLogDAL.AddUserBehaviorLog(log);
                    }
                    catch { }
                    scope.Complete();
                    result = 1;
                }
            }
            catch
            {
                return(0);
            }
            return(result);
        }