Пример #1
0
        /// <summary>
        /// 插入单条追号
        /// </summary>
        private decimal CatchIssue(string catchNumCode, decimal detailMonery, List <CatchDto> source, int lotteryid, ref string fsIssueCode)
        {
            // bool isFirst = true;
            decimal sumMonery = 0;

            foreach (var s in source)
            {
                CatchNumIssue item = new CatchNumIssue();
                item.CatchNumIssueCode = "i" + Utils.BuilderNum();
                item.CatchNumCode      = catchNumCode;
                item.IsMatch           = false;
                item.IssueCode         = s.IssueCode;
                item.Multiple          = s.Multiple;
                item.Stauts            = BetResultType.NotOpen;
                item.TotalAmt          = detailMonery * item.Multiple;
                item.WinMoney          = 0;

                //保存至数据库
                this.mSysCatchNumIssueService.AddCatchIssue(item, lotteryid);
                if (string.IsNullOrEmpty(fsIssueCode))
                {
                    fsIssueCode = s.IssueCode;
                }
                sumMonery += item.TotalAmt;
            }

            return(sumMonery);
        }
Пример #2
0
        /// <summary>
        /// 终止追号
        /// </summary>
        private void CannelCatchNum(string catchNum, string catchNumIssueCode)
        {
            ISysCatchNumService      sysCatchNumService      = IoC.Resolve <ISysCatchNumService>();
            ISysCatchNumIssueService sysCatchNumIssueService = IoC.Resolve <ISysCatchNumIssueService>();
            //验证当前单号是否正在进行
            var fs = sysCatchNumService.Where(item => item.CatchNumCode == catchNum).FirstOrDefault();

            if (fs == null)
            {
                //非法撤单
                AppGlobal.RenderResult(ApiCode.Fail);
                return;
            }
            //获取注单详情
            var source = sysCatchNumIssueService.GetCatchIssue(catchNum);

            //获取用户余额
            CatchNumIssue catchNumIssue = null;
            int           noCannelCount = 0;

            foreach (var item in source)
            {
                //未开奖的状态才允许撤单
                if (catchNumIssueCode == item.CatchNumIssueCode)
                {
                    fs.UserCannelIssue++;
                    fs.UserCannelMonery += item.TotalAmt;
                    item.Stauts          = BetResultType.SysCancel; //对本注进行撤单
                    catchNumIssue        = item;
                }
                if (item.Stauts == BetResultType.NotOpen)
                {
                    noCannelCount++;
                }
            }
            //撤单
            sysCatchNumIssueService.Save();
            if (noCannelCount <= 0) //全部撤销
            {
                sysCatchNumService.CannelCatch(catchNum);
            }
            sysCatchNumService.Save();

            //返还金额
            if (catchNumIssue != null)
            {
                ISysUserBalanceService sysUserBalanceService = IoC.Resolve <ISysUserBalanceService>();
                var details = new SysUserBalanceDetail()
                {
                    RelevanceNo = catchNumIssue.CatchNumIssueCode,
                    SerialNo    = "b" + Utils.BuilderNum(),
                    Status      = 0,
                    TradeAmt    = catchNumIssue.TotalAmt,
                    TradeType   = TradeType.追号返款,
                    UserId      = fs.UserId
                };
                sysUserBalanceService.UpdateUserBalance(details, catchNumIssue.TotalAmt);
            }
        }