Пример #1
0
        public string PaymentInterestV2()
        {
            string result = "";
            int    days   = int.Parse(SysAdminConfigDAL.GetConfigsByID(10));

            using (TransactionScope scope = new TransactionScope())
            {
                //为每个单据派发利息
                int rowcount = MemberCapitalDetailDAL.PaymentInterestForOrder(days);
                if (rowcount < 1)
                {
                    result = "0为单据派发利息失败";
                    return(result);
                }
                //汇总并加入到账户信息记录日志
                rowcount = MemberCapitalDetailDAL.SumInterestMoney();
                if (rowcount < 1)
                {
                    result = "0为会员更新利息总额失败";
                    return(result);
                }
                //清空单据上面的利息金额
                rowcount = MemberCapitalDetailDAL.ClearHelperInterest();
                if (rowcount < 1)
                {
                    result = "0清掉帮助订单利息失效";
                    return(result);
                }
                scope.Complete();
                result = "1";
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// 更新提供帮助订单为已打款
        /// </summary>
        /// <param name="hid"></param>
        /// <returns></returns>
        public int UpdateToPlayMoneyV1(int hid, int aid)
        {
            int                    result      = 0;
            string                 value       = SysAdminConfigDAL.GetConfigsByID(6);  //得到打款后返还金额
            string                 inteist     = SysAdminConfigDAL.GetConfigsByID(7);  //得到打款后利率
            string                 inteistlist = SysAdminConfigDAL.GetConfigsByID(11); //得到领导奖利率
            HelpeOrderModel        order       = HelpeOrderDAL.GetHelpOrderInfo(hid);
            List <MatchOrderModel> matchorders = MatchOrderDAL.GetMatchOrderInfo(hid, aid);

            using (TransactionScope scope = new TransactionScope())
            {
                //更改状态为已打款(此处不在变更利率为打款后利率)
                //int rowcount = HelpeOrderDAL.UpdateStatusandinster(hid, 4, decimal.Parse(inteist));
                int rowcount = HelpeOrderDAL.UpdateStatus(hid, 4);
                if (rowcount < 1)
                {
                    return(0);
                }
                rowcount = MatchOrderDAL.UpdateStatusToPayed(hid, aid);
                if (rowcount < 1)
                {
                    return(0);
                }
                //更新匹配接受订单的状态为对方已打款
                rowcount = AcceptHelpOrderDAL.UpdateStatus(aid, 4);
                if (rowcount < 1)
                {
                    return(0);
                }
                try
                {
                    UserBehaviorLogModel log = new UserBehaviorLogModel();
                    log.AOrderCode     = matchorders[0].AcceptOrderCode;
                    log.BehaviorSource = 1;
                    log.BehaviorType   = 4;
                    log.HOrderCode     = matchorders[0].HelperOrderCode;
                    log.MemberID       = order.MemberID;
                    log.MemberName     = order.MemberName;
                    log.MemberPhone    = order.MemberPhone;
                    log.ProcAmount     = matchorders[0].MatchedMoney;
                    log.Remark         = "会员:" + order.MemberPhone + " 变更单据为打款";
                    rowcount           = UserBehaviorLogDAL.AddUserBehaviorLog(log);
                }
                catch { }
                scope.Complete();
                result = 1;
            }
            return(result);
        }
Пример #3
0
        /// <summary>
        /// 为会员派发利息(V3版)
        /// </summary>
        /// <param name="day"></param>
        /// <returns></returns>
        public string PaymentInterestV3()
        {
            string result = "";
            int    days   = int.Parse(SysAdminConfigDAL.GetConfigsByID(10));

            using (TransactionScope scope = new TransactionScope())
            {
                //为每个单据派发利息
                int rowcount = MemberCapitalDetailDAL.PaymentInterestForOrderWithLog(days);
                if (rowcount < 1)
                {
                    result = "0为单据派发利息失败";
                    return(result);
                }
                //更改会员的当前利率和利息
                rowcount = MemberCapitalDetailDAL.ResetInster(days);
                //汇总并加入到账户信息记录日志
                rowcount = MemberCapitalDetailDAL.SumInterestMoneyWithoutLog();
                if (rowcount < 1)
                {
                    result = "0为会员更新利息总额失败";
                    return(result);
                }
                //解冻单据利率为2,状态为5的单据的利息
                rowcount = MemberCapitalDetailDAL.UpdateStaticCaptail();
                try
                {
                    UserBehaviorLogModel log = new UserBehaviorLogModel();
                    log.AOrderCode     = "";
                    log.BehaviorSource = 2;
                    log.BehaviorType   = 11;
                    log.HOrderCode     = "";
                    log.MemberID       = 0;
                    log.MemberName     = "";
                    log.MemberPhone    = "";
                    log.ProcAmount     = 0;
                    log.Remark         = "系统派发利息";
                    rowcount           = UserBehaviorLogDAL.AddUserBehaviorLog(log);
                }
                catch { }
                scope.Complete();
                result = "1";
            }
            return(result);
        }
Пример #4
0
        public int PaymentInterest()
        {
            int result = 0;
            int days   = int.Parse(SysAdminConfigDAL.GetConfigsByID(10));

            using (TransactionScope scope = new TransactionScope())
            {
                //分派利息
                int rowcunt = MemberCapitalDetailDAL.PaymentInterest(days);
                if (rowcunt < 1)
                {
                    return(0);
                }
                scope.Complete();
                result = 1;
            }
            return(result);
        }
Пример #5
0
        /// <summary>
        /// 发送注册验证短信
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        public string SendRegisterSms(string phone)
        {
            string smscontent = SysAdminConfigDAL.GetConfigsByID(18);//得到短信模板
            Random ran        = new Random();
            int    RandKey    = ran.Next(100000, 999999);
            int    id         = AddVerification(RandKey.ToString());
            string content    = string.Format(smscontent, RandKey.ToString());
            string result     = SendSMSClass.SendSMS(phone, content);

            UpdateVerification(result.Substring(1), id);
            if (result.StartsWith("s"))
            {
                return(id.ToString());
            }
            else
            {
                return("0");
            }
        }
Пример #6
0
 public static string GetConfigValue(int id)
 {
     return(SysAdminConfigDAL.GetConfigsByID(id));
 }
Пример #7
0
        /// <summary>
        ///注册会员(已追加注册返还金额功能)
        /// </summary>
        public string AddMemberInfo(MemberInfoModel model)
        {
            string result = "1";
            string value  = SysAdminConfigDAL.GetConfigsByID(4);//得到注册返还金额

            #region 验证用户真实姓名 和手机
            int rows = MemberInfoDAL.GetMemberCountInfoByName(model.TruethName.Trim());
            if (rows > 2)
            {
                return("0用户姓名重复");
            }
            rows = MemberInfoDAL.GetMemberCountInfoByMobile(model.MobileNum.Trim());
            if (rows > 0)
            {
                return("0手机号已被注册");
            }
            //rows = MemberInfoDAL.GetMemberCountInfoByAlipayNum(model.AliPayNum.Trim());
            //if (rows > 0)
            //{
            //    return "0支付宝ID已被注册";
            //}
            rows = MemberInfoDAL.GetMemberCountInfoByAliPayName(model.AliPayName.Trim());
            if (rows > 0)
            {
                return("0支付宝账户已被注册");
            }
            #endregion
            using (TransactionScope scope = new TransactionScope())
            {
                int memberid = dal.AddMemberInfo(model);
                if (memberid < 1)
                {
                    return("0注册失败");
                }
                decimal amont = 0;
                if (!string.IsNullOrWhiteSpace(value))
                {
                    if (!decimal.TryParse(value, out amont))
                    {
                        return("0注册失败");
                    }
                    int row = MemberCapitalDetailDAL.UpdateMemberStaticFreezeMoney(memberid, amont, model.TruethName, model.MobileNum);
                    if (row < 1)
                    {
                        return("0注册失败");
                    }
                }
                //返还激活码金额
                AmountChangeLogModel logmodel = new AmountChangeLogModel();
                logmodel.MemberID     = memberid;
                logmodel.MemberName   = model.TruethName;
                logmodel.MemberPhone  = model.MobileNum;
                logmodel.ProduceMoney = amont;
                logmodel.Remark       = "会员注册激活码" + amont.ToString() + "元";
                logmodel.Type         = 5;
                int rowcount = OperateLogDAL.AddAmountChangeLog(logmodel);
                if (rowcount < 1)
                {
                    return("0注册失败");
                }
                if (model.MemberPhone != model.MobileNum)
                {
                    //插入推荐人信息表
                    MemberInfoModel soucemember = MemberInfoDAL.GetMember(model.MemberPhone);
                    if (soucemember.MStatus == 3)
                    {
                        return("0推荐人账户被冻结");
                    }
                    ReMemberRelationModel remodel = new ReMemberRelationModel();
                    remodel.MemberID         = soucemember.ID;
                    remodel.MemberTruthName  = soucemember.TruethName;
                    remodel.MemberPhone      = soucemember.MobileNum;
                    remodel.RecommMID        = memberid;
                    remodel.RecommMPhone     = model.MobileNum;
                    remodel.RecommMTruthName = model.TruethName;
                    rowcount = ReMemberRelationDAL.AddReMemberRelation(remodel);
                    if (rowcount < 1)
                    {
                        return("0注册失败");
                    }
                }
                //初始化会员扩展信息表
                MemberExtendInfoModel extendinfo = new MemberExtendInfoModel();
                extendinfo.MemberID        = memberid;
                extendinfo.MemberHelpCount = 0;
                extendinfo.LastHelpMoney   = 0;
                extendinfo.LastHelperTime  = DateTime.Now.AddYears(-1);
                rowcount = MemberExtendInfoDAL.AddModelExtendinfo(extendinfo);
                if (rowcount < 1)
                {
                    return("0注册失败");
                }
                scope.Complete();
                result = "1";
            }
            return(result);
        }
Пример #8
0
 /// <summary>
 /// 单据匹配方法4
 /// </summary>
 /// <returns></returns>
 public int OperateMatchOrder(int hid, int aid)
 {
     int result = 0;
     decimal money = 0;
     HelpeOrderModel help = HelpeOrderDAL.GetHelpOrderInfo(hid);
     AcceptHelpOrderModel accept = AcceptHelpOrderDAL.GetAcceptOrderInfo(aid);
     string helpsmscontent = SysAdminConfigDAL.GetConfigsByID(19);
     string acceptsmscontent = SysAdminConfigDAL.GetConfigsByID(20);
     string issendsms = SysAdminConfigDAL.GetConfigsByID(21);
     if (help == null || accept == null)
     {
         return 0;
     }
     if (help.HStatus == 3 || help.HStatus == 5)
     {
         return 0;
     }
     if (accept.AStatus == 3 || accept.AStatus == 5)
     {
         return 0;
     }
     if (help.DiffAmount == 0 || accept.DiffAmount == 0)
     {
         return 0;
     }
     //系统计算匹配金额
     if (help.DiffAmount < accept.DiffAmount)
     {
         money = help.DiffAmount;
     }
     else if (help.DiffAmount > accept.DiffAmount)
     {
         money = accept.DiffAmount;
     }
     else
     {
         money = help.DiffAmount;
     }
     using (TransactionScope scope = new TransactionScope())
     {
         //插入匹配表
         MatchOrderModel matchmodel = new MatchOrderModel();
         matchmodel.AcceptMemberID = accept.MemberID;
         matchmodel.AcceptMemberName = accept.MemberName;
         matchmodel.AcceptMemberPhone = accept.MemberPhone;
         matchmodel.AcceptOrderCode = accept.OrderCode;
         matchmodel.AcceptOrderID = aid;
         matchmodel.HelperMemberID = help.MemberID;
         matchmodel.HelperMemberName = help.MemberName;
         matchmodel.HelperMemberPhone = help.MemberPhone;
         matchmodel.HelperOrderCode = help.OrderCode;
         matchmodel.HelperOrderID = hid;
         matchmodel.MatchedMoney = money;
         matchmodel.MatchTime = DateTime.Now;
         int rowcount = MatchOrderDAL.AddMatchOrder(matchmodel);
         if (rowcount < 1)
         {
             return 0;
         }
         //更新提供订单表状态
         rowcount = HelpeOrderDAL.UpdateHelpOrderMatch(hid, money);
         if (rowcount < 1)
         {
             return 0;
         }
         //更新接受订单表状态
         rowcount = AcceptHelpOrderDAL.UpdateAcceptOrderMatch(aid, money);
         if (rowcount < 1)
         {
             return 0;
         }
         #region 发送短信
         if (issendsms == "1")
         {
             string helpsms = string.Format(helpsmscontent, help.OrderCode);
             string acceptsms = string.Format(acceptsmscontent, accept.OrderCode);
             string resule = SendSMSClass.SendSMS(help.MemberPhone, helpsms);
             resule = SendSMSClass.SendSMS(accept.MemberPhone, acceptsms);
         }
         #endregion
         scope.Complete();
         result = 1;
     }
     return result;
 }
Пример #9
0
        public int UpdateToPlayMoney(int hid)
        {
            int                    result      = 0;
            string                 value       = SysAdminConfigDAL.GetConfigsByID(6);  //得到打款后返还金额
            string                 inteist     = SysAdminConfigDAL.GetConfigsByID(7);  //得到打款后利率
            string                 inteistlist = SysAdminConfigDAL.GetConfigsByID(11); //得到领导奖利率
            HelpeOrderModel        order       = HelpeOrderDAL.GetHelpOrderInfo(hid);
            List <MatchOrderModel> matchorders = MatchOrderDAL.GetMatchOrderInfo(hid, 0);

            using (TransactionScope scope = new TransactionScope())
            {
                //更改状态为已打款和更改利率为已打款后的利率
                int rowcount = HelpeOrderDAL.UpdateStatusandinster(hid, 4, decimal.Parse(inteist));
                if (rowcount < 1)
                {
                    return(0);
                }
                //返还排单币更改会员利率为打款后利率
                //if (!string.IsNullOrWhiteSpace(value))
                //{
                //    rowcount = MemberCapitalDetailDAL.UpdateMemberStaticFreezeMoney(order.MemberID, decimal.Parse(value), order.MemberName, order.MemberPhone);
                //    if (rowcount < 1)
                //    {
                //        return 0;
                //    }
                //AmountChangeLogModel logmodel = new AmountChangeLogModel();
                //logmodel.MemberID = order.MemberID;
                //logmodel.MemberName = order.MemberName;
                //logmodel.MemberPhone = order.MemberPhone;
                //logmodel.OrderCode = order.OrderCode;
                //logmodel.OrderID = hid;
                //logmodel.ProduceMoney = order.Amount;
                //logmodel.Remark = "会员:" + order.MemberPhone + " 打款完成,返还" + order.Amount.ToString() + "元";
                //logmodel.Type = 5;
                //rowcount = OperateLogDAL.AddAmountChangeLog(logmodel);
                //}
                //else
                //{
                //    rowcount = MemberCapitalDetailDAL.UpdateMemberInterest(order.MemberID, decimal.Parse(inteist));
                //    if (rowcount < 1)
                //    {
                //        return 0;
                //    }
                //}
                //更新匹配接受订单的状态为对方已打款
                if (matchorders.Count > 0)
                {
                    foreach (var item in matchorders)
                    {
                        rowcount = AcceptHelpOrderDAL.UpdateStatus(item.AcceptOrderID, 4);
                        if (rowcount < 1)
                        {
                            return(0);
                        }
                    }
                }
                scope.Complete();
                result = 1;
            }
            return(result);
        }
Пример #10
0
        /// <summary>
        /// 添加一条提供帮助单据
        /// </summary>
        public string AddHelpeOrder(HelpeOrderModel model)
        {
            string  result               = "0";
            string  minhelpamont         = SystemConfigs.GetminHelpAmont();                         //得到最小的提供帮助限制
            string  maxhelpamont         = SystemConfigs.GetmaxHelpAmont();                         //得到最大的提供帮助限制
            string  interest             = SysAdminConfigDAL.GetConfigsByID(5);                     //得到排单后的利率
            string  inteistlist          = SysAdminConfigDAL.GetConfigsByID(11);                    //得到领导奖利率
            decimal reinteist            = SysAdminConfigDAL.GetConfigsByID(16).ParseToDecimal(10); //得到首次推荐的利率
            decimal maxcount             = SysAdminConfigDAL.GetConfigsByID(17).ParseToInt(1);      //得到每日最大排单数
            MemberExtendInfoModel meinfo = MemberExtendInfoDAL.GetMemberExtendInfo(model.MemberID);
            int helpcount = HelpeOrderDAL.GetTodayHelpCount(model.MemberID);

            if (model.Amount < minhelpamont.ParseToDecimal(0))
            {
                return("0超出了平台规定的最小规定值");
            }
            if (model.Amount > maxhelpamont.ParseToDecimal(0))
            {
                return("0超出了平台规定的最大规定值");
            }

            if (helpcount >= maxcount)
            {
                return("0今天已经提供过帮助");
            }
            bool isfirst = false;//默认不是第一次

            if (meinfo == null)
            {
                isfirst = true;
            }
            else
            {
                isfirst = meinfo.MemberHelpCount == 0;
            }
            if (string.IsNullOrWhiteSpace(model.ActiveCode))
            {
                return("0没有填写排单币");
            }
            ActiveCodeModel activemodel = ActiveCodeDAL.GetActiveCodeExtendModel(model.ActiveCode);

            if (activemodel == null)//没有该激活码信息为失败
            {
                return("0排单币无效");
            }
            if (activemodel.AStatus == 10)//改激活码已使用为失败
            {
                return("0排单币已经被使用");
            }
            if (model.Amount % 100 > 0)
            {
                return("0提供金额应为100的整数倍");
            }
            ReMemberRelationModel remember = ReMemberRelationDAL.GetReMemberRelation(model.MemberID);

            using (TransactionScope scope = new TransactionScope())
            {
                //更改激活码的使用状态
                int rowcount = ActiveCodeDAL.UpdateStatus(activemodel.ID, 10);
                if (rowcount < 1)
                {
                    return("0操作失败");
                }
                rowcount = ActiveCodeDAL.UpdateMemberActiveToUse(model.MemberID, model.OrderCode, model.ActiveCode);
                if (rowcount < 1)
                {
                    return("0操作失败");
                }
                //插入激活码的使用日志
                ActiveCodeLogModel aclogmodel = new ActiveCodeLogModel();
                aclogmodel.ActiveCode  = model.ActiveCode;
                aclogmodel.AID         = model.ActiveCodeID;
                aclogmodel.MemberID    = model.MemberID;
                aclogmodel.MemberName  = model.MemberName;
                aclogmodel.MemberPhone = model.MemberPhone;
                aclogmodel.Remark      = "会员:" + model.MemberName + " 使用排单币:" + model.ActiveCode + " 进行排单";
                rowcount = OperateLogDAL.AddActiveCodeLog(aclogmodel);
                if (rowcount < 1)
                {
                    return("0操作失败");
                }
                //更改会员的资金信息和利率
                decimal dinterest = 1;
                if (!string.IsNullOrWhiteSpace(interest))
                {
                    if (!decimal.TryParse(interest, out dinterest))
                    {
                        return("0操作失败");
                    }
                }
                //rowcount = MemberCapitalDetailDAL.UpdateMemberStaticCapital(model.MemberID, model.Amount, dinterest,model.MemberName,model.MemberPhone);
                rowcount = MemberCapitalDetailDAL.UpdateMemberStaticFreezeMoneyAndinster(model.MemberID, model.Amount, dinterest, model.MemberName, model.MemberPhone);
                if (rowcount < 1)
                {
                    return("0操作失败");
                }
                //插入表记录
                model.IsFristOrder = isfirst ? 1 : 0;
                int orderid = dal.AddHelpeOrder(model);
                if (orderid < 1)
                {
                    return("0操作失败");
                }
                //更新会员的统计信息
                rowcount = MemberExtendInfoDAL.Update(model.MemberID, model.Amount);
                if (rowcount < 1)
                {
                    return("0操作失败");
                }
                //插入会员的资金变动纪录
                AmountChangeLogModel logmodel = new AmountChangeLogModel();
                logmodel.MemberID     = model.MemberID;
                logmodel.MemberName   = model.MemberName;
                logmodel.MemberPhone  = model.MemberPhone;
                logmodel.OrderCode    = model.OrderCode;
                logmodel.OrderID      = orderid;
                logmodel.ProduceMoney = model.Amount;
                logmodel.Remark       = "会员:" + model.MemberPhone + " 申请提供帮助 " + model.Amount.ToString() + "元";
                logmodel.Type         = 1;
                rowcount = OperateLogDAL.AddAmountChangeLog(logmodel);
                if (rowcount < 1)
                {
                    return("0操作失败");
                }
                //为推荐人添加领导奖
                rowcount = MemberCapitalDetailDAL.PaymentLeaderPrize(model.MemberID, model.Amount, inteistlist, model.OrderCode, orderid);
                if (rowcount < 1)
                {
                    return("0操作失败");
                }
                //若此会员第一次排单,则给推荐人奖励
                if (isfirst)
                {
                    rowcount = MemberCapitalDetailDAL.UpdateMemberDynamicFreezeMoney(remember.MemberID, (model.Amount * reinteist / 100), remember.MemberTruthName, remember.MemberPhone);
                    if (rowcount < 1)
                    {
                        return("0操作失败");
                    }
                    LeaderAmountModel leadermodel = new LeaderAmountModel();//插入领导奖记录
                    leadermodel.OrderID     = orderid;
                    leadermodel.OrderCode   = model.OrderCode;
                    leadermodel.MemberPhone = remember.MemberPhone;
                    leadermodel.MemberName  = remember.MemberTruthName;
                    leadermodel.MemberID    = remember.MemberID;
                    leadermodel.LType       = 1;
                    leadermodel.Amount      = (model.Amount * reinteist / 100);
                    rowcount = MemberCapitalDetailDAL.AddLeaderAmount(leadermodel);
                    if (rowcount < 1)
                    {
                        return("0操作失败");
                    }
                    AmountChangeLogModel logmodel1 = new AmountChangeLogModel();
                    logmodel1.MemberID     = remember.MemberID;
                    logmodel1.MemberName   = remember.MemberTruthName;
                    logmodel1.MemberPhone  = remember.MemberPhone;
                    logmodel1.OrderCode    = model.OrderCode;
                    logmodel1.OrderID      = orderid;
                    logmodel1.ProduceMoney = (model.Amount * reinteist / 100);
                    logmodel1.Remark       = "会员:" + remember.MemberPhone + " 得到来自 " + model.MemberPhone + "的首单推荐奖(已冻结)" + (model.Amount * reinteist / 100).ToString() + "元";
                    logmodel1.Type         = 3;
                    rowcount = OperateLogDAL.AddAmountChangeLog(logmodel1);
                    if (rowcount < 1)
                    {
                        return("0操作失败");
                    }
                }
                try
                {
                    UserBehaviorLogModel log = new UserBehaviorLogModel();
                    log.AOrderCode     = "";
                    log.BehaviorSource = 1;
                    log.BehaviorType   = 2;
                    log.HOrderCode     = model.OrderCode;
                    log.MemberID       = model.MemberID;
                    log.MemberName     = model.MemberName;
                    log.MemberPhone    = model.MemberPhone;
                    log.ProcAmount     = model.Amount;
                    log.Remark         = "会员:" + model.MemberPhone + "提供帮助单号为:" + model.OrderCode;
                    rowcount           = UserBehaviorLogDAL.AddUserBehaviorLog(log);
                }
                catch { }
                scope.Complete();
                result = "1";
            }
            return(result);
        }
Пример #11
0
 /// <summary>
 /// 获取最高接受帮助的金额
 /// </summary>
 /// <returns></returns>
 public static string GetmaxAcceptAmont()
 {
     return(SysAdminConfigDAL.GetConfigsByID(15));
 }
Пример #12
0
 /// <summary>
 /// 获取最高提供帮助的金额
 /// </summary>
 /// <returns></returns>
 public static string GetmaxHelpAmont()
 {
     return(SysAdminConfigDAL.GetConfigsByID(13));
 }
Пример #13
0
        /// <summary>
        /// 更新状态为已完成
        /// </summary>
        /// <returns></returns>
        public int UpdateSingleOrderToComplete(int aid, int hid)
        {
            int result = 0;
            //List<MatchOrderModel> matchorders = MatchOrderDAL.GetMatchOrderInfo(0, aid);
            HelpeOrderModel        helporder = HelpeOrderDAL.GetHelpOrderInfo(hid);        //查询提供帮助的单据
            AcceptHelpOrderModel   accorder  = AcceptHelpOrderDAL.GetAcceptOrderInfo(aid); //查询接受单据的信息
            List <MatchOrderModel> matchinfo = MatchOrderDAL.GetMatchOrderInfo(hid, aid);  //单据的匹配信息
            string value       = SysAdminConfigDAL.GetConfigsByID(4);                      //得到注册返还金额
            string scvalue     = SysAdminConfigDAL.GetConfigsByID(6);                      //得到注册返还金额
            string inteistlist = SysAdminConfigDAL.GetConfigsByID(11);                     //得到领导奖利率
            int    day         = SysAdminConfigDAL.GetConfigsByID(22).ParseToInt(20);      //得到领导奖推荐奖冻结天数
            string inteist     = SysAdminConfigDAL.GetConfigsByID(7);                      //得到打款后利率

            using (TransactionScope scope = new TransactionScope())
            {
                //更改当前的接受单据状态和完成金额
                int rowcount = AcceptHelpOrderDAL.UpdateStatusAndMoneyToComplete(aid, matchinfo[0].MatchedMoney);
                if (rowcount < 1)
                {
                    return(0);
                }
                //更改匹配信息
                rowcount = MatchOrderDAL.UpdateStatusToComplete(hid, aid);
                if (rowcount < 1)
                {
                    return(0);
                }
                //更改匹配的提供帮助订单的状态
                rowcount = HelpeOrderDAL.UpdateStatusForCompleteV1(helporder.ID, matchinfo[0].MatchedMoney);
                if (rowcount < 1)
                {
                    return(0);
                }
                decimal diffamount = (helporder.Amount - helporder.PayedAmount - matchinfo[0].MatchedMoney);
                if (diffamount == 0)
                {
                    //返还匹配会员的静态冻结资金和利息
                    rowcount = MemberCapitalDetailDAL.UpdateStaticInterestAndStaticFreezeMoney(helporder.MemberID, helporder.Amount, helporder.Interest);
                    if (rowcount < 1)
                    {
                        return(0);
                    }
                    //更改单据利率为高利率
                    rowcount = HelpeOrderDAL.UpdateCurrentInterest(hid, inteist.ParseToInt(2));
                    if (rowcount < 1)
                    {
                        return(0);
                    }
                    //更改该单据的利息为0
                    rowcount = HelpeOrderDAL.UpdateHelperOrderClearInterest(helporder.ID);
                    if (rowcount < 1)
                    {
                        return(0);
                    }
                    //返还推荐奖
                    if (helporder.IsFristOrder == 1 && helporder.IsRecommendBack == 0)
                    {
                        decimal inster = SysAdminConfigDAL.GetConfigsByID(16).ParseToInt(10);//得到首次推荐的利率
                        decimal money  = helporder.Amount * inster / 100;
                        ReMemberRelationModel model = ReMemberRelationDAL.GetReMemberRelation(helporder.MemberID);
                        if (day == 0)//若为0,则当时返还
                        {
                            //返还推荐奖
                            rowcount = MemberCapitalDetailDAL.UpdateDynamicInterestForComplete(model.MemberID, money);
                            if (rowcount < 1)
                            {
                                return(0);
                            }
                            AmountChangeLogModel logmodel = new AmountChangeLogModel();
                            logmodel.MemberID     = model.MemberID;
                            logmodel.MemberName   = model.MemberTruthName;
                            logmodel.MemberPhone  = model.MemberPhone;
                            logmodel.OrderCode    = helporder.OrderCode;
                            logmodel.OrderID      = helporder.ID;
                            logmodel.ProduceMoney = money;
                            logmodel.Remark       = "会员:" + model.MemberPhone + " 得到来自单据:" + helporder.OrderCode + "的推荐奖";
                            logmodel.Type         = 3;
                            rowcount = OperateLogDAL.AddAmountChangeLog(logmodel);
                            if (rowcount < 1)
                            {
                                return(result);
                            }
                        }
                        else
                        {
                            //返还推荐奖到待返还列表
                            WaitFreeLeaderAmountModel waitfreemodel = new WaitFreeLeaderAmountModel();
                            waitfreemodel.MemberID       = model.MemberID;
                            waitfreemodel.MemberName     = model.MemberTruthName;
                            waitfreemodel.MemberPhone    = model.MemberPhone;
                            waitfreemodel.Amount         = money;
                            waitfreemodel.AStatus        = 1;
                            waitfreemodel.TheoryFreeTime = DateTime.Now.AddDays(day);
                            waitfreemodel.Type           = 2;
                            waitfreemodel.OrderCode      = helporder.OrderCode;
                            waitfreemodel.OrderID        = helporder.ID;
                            rowcount = MemberCapitalDetailDAL.AddWaitFreeMoney(waitfreemodel);
                            if (rowcount < 1)
                            {
                                return(0);
                            }
                        }
                        //返还激活码的钱
                        rowcount = MemberCapitalDetailDAL.UpdateStaticFreezeMoneyForReiger(helporder.MemberID, value.ParseToDecimal(0));
                        //更改单据为已经派发推荐奖
                        rowcount = HelpeOrderDAL.UpdateHelperOrderIsRecommendBack(helporder.ID);
                    }
                    if (helporder.IsLeaderBack == 0)
                    {
                        if (day == 0)
                        {
                            //返还领导奖
                            rowcount = MemberCapitalDetailDAL.PaymentLeaderPrizeForComplete(helporder.MemberID, inteistlist, helporder.OrderCode, helporder.ID);
                        }
                        else
                        {
                            //返还领导奖到待返还列表
                            rowcount = MemberCapitalDetailDAL.PaymentLeaderPrizeForComplete(helporder.MemberID, inteistlist, helporder.OrderCode, helporder.ID, day);
                        }
                        //更新单据状态
                        rowcount = HelpeOrderDAL.UpdateHelperOrderIsLeaderBack(helporder.ID);
                    }
                    //返还该单据排单币的金额
                    if (helporder.SchedulingAmount == 0)
                    {
                        rowcount = MemberCapitalDetailDAL.UpdateMemberStaticCapital(helporder.MemberID, scvalue.ParseToDecimal(0), helporder.MemberName, helporder.MemberPhone);
                        if (rowcount < 1)
                        {
                            return(0);
                        }
                        rowcount = HelpeOrderDAL.UpdateHelperOrderIsRecommendBack(helporder.ID, scvalue.ParseToDecimal(0));//更新单据的排单币金额
                        if (rowcount < 1)
                        {
                            return(0);
                        }
                        AmountChangeLogModel logmodel = new AmountChangeLogModel();
                        logmodel.MemberID     = helporder.MemberID;
                        logmodel.MemberName   = helporder.MemberName;
                        logmodel.MemberPhone  = helporder.MemberPhone;
                        logmodel.OrderCode    = helporder.OrderCode;
                        logmodel.OrderID      = helporder.ID;
                        logmodel.ProduceMoney = scvalue.ParseToDecimal(0);
                        logmodel.Remark       = "会员:" + helporder.MemberPhone + " 打款完成,返还排单币" + scvalue + "元";
                        logmodel.Type         = 5;
                        rowcount = OperateLogDAL.AddAmountChangeLog(logmodel);
                        if (rowcount < 1)
                        {
                            return(0);
                        }
                    }
                }
                try
                {
                    UserBehaviorLogModel log = new UserBehaviorLogModel();
                    log.AOrderCode     = accorder.OrderCode;
                    log.BehaviorSource = 1;
                    log.BehaviorType   = 5;
                    log.HOrderCode     = helporder.OrderCode;
                    log.MemberID       = accorder.MemberID;
                    log.MemberName     = accorder.MemberName;
                    log.MemberPhone    = accorder.MemberPhone;
                    log.ProcAmount     = matchinfo[0].MatchedMoney;
                    log.Remark         = "会员:" + accorder.MemberPhone + "为单据" + accorder.OrderCode + "确认收款";
                    rowcount           = UserBehaviorLogDAL.AddUserBehaviorLog(log);
                }
                catch { }
                scope.Complete();
                result = 1;
            }
            return(result);
        }
Пример #14
0
        /// <summary>
        /// 更新状态为已完成(遗弃)
        /// </summary>
        /// <returns></returns>
        public int UpdateStatusToComplete(int aid)
        {
            int result = 0;
            //List<MatchOrderModel> matchorders = MatchOrderDAL.GetMatchOrderInfo(0, aid);
            List <HelpeOrderModel> matchorderlist = MatchOrderDAL.GetMatchHelpOrderByAid(aid);
            string value       = SysAdminConfigDAL.GetConfigsByID(4);  //得到注册返还金额
            string inteistlist = SysAdminConfigDAL.GetConfigsByID(11); //得到领导奖利率

            using (TransactionScope scope = new TransactionScope())
            {
                //更改当前的状态
                int rowcount = AcceptHelpOrderDAL.UpdateStatusToComplete(aid);
                if (rowcount < 1)
                {
                    return(0);
                }
                //更改匹配的提供帮助订单的状态
                #region 注释
                //foreach (var item in matchorders)
                //{
                //    rowcount = HelpeOrderDAL.UpdateStatusForComplete(item.HelperOrderID);
                //    if (rowcount < 1)
                //    {
                //        return 0;
                //    }
                //    HelpeOrderModel order = HelpeOrderDAL.GetHelpOrderInfo(item.HelperOrderID);
                //    //解冻会员的静态冻结资金
                //    rowcount = MemberCapitalDetailDAL.UpdateStaticThawDetail(order.MemberID);
                //    if (rowcount < 1)
                //    {
                //        return 0;
                //    }
                //    //插入会员的资金变动记录
                //    AmountChangeLogModel logmodel = new AmountChangeLogModel();
                //    logmodel.MemberID = order.MemberID;
                //    logmodel.MemberName = order.MemberName;
                //    logmodel.MemberPhone = order.MemberPhone;
                //    logmodel.OrderCode = order.OrderCode;
                //    logmodel.OrderID = item.HelperOrderID;
                //    logmodel.ProduceMoney = 0;
                //    logmodel.Remark = "会员:" + order.MemberPhone + " 所有冻结资金解冻";
                //    logmodel.Type = 5;
                //    rowcount = OperateLogDAL.AddAmountChangeLog(logmodel);
                //    if (rowcount < 1)
                //    {
                //        return 0;
                //    }
                //}
                #endregion
                foreach (var item in matchorderlist)
                {
                    rowcount = HelpeOrderDAL.UpdateStatusForComplete(item.ID);
                    if (rowcount < 1)
                    {
                        return(0);
                    }
                    if (item.DiffAmount == 0)
                    {
                        //返还匹配会员的静态冻结资金和利息
                        rowcount = MemberCapitalDetailDAL.UpdateStaticInterestAndStaticFreezeMoney(item.MemberID, item.Amount, item.Interest);
                        if (rowcount < 1)
                        {
                            return(0);
                        }
                        //返还推荐奖
                        if (item.IsFristOrder == 1)
                        {
                            decimal inster = SysAdminConfigDAL.GetConfigsByID(16).ParseToInt(10);//得到首次推荐的利率
                            decimal money  = item.Amount * inster / 100;
                            ReMemberRelationModel model = ReMemberRelationDAL.GetReMemberRelation(item.ID);
                            rowcount = MemberCapitalDetailDAL.UpdateDynamicInterestForComplete(model.MemberID, money);
                            if (rowcount < 1)
                            {
                                return(0);
                            }
                            rowcount = MemberCapitalDetailDAL.UpdateStaticFreezeMoneyForReiger(item.MemberID, value.ParseToDecimal(0));
                        }
                        //返还领导奖
                        rowcount = MemberCapitalDetailDAL.PaymentLeaderPrizeForComplete(item.MemberID, inteistlist, item.OrderCode, item.ID);
                    }
                }
                scope.Complete();
                result = 1;
            }
            return(result);
        }