Exemplo n.º 1
0
        public CustomJsonResult Apply(string pOperater, string pClientId, RopWithdrawApply rop)
        {
            CustomJsonResult result = new CustomJsonResult();

            lock (lock_Apply)
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    var fund = CurrentDb.Fund.Where(m => m.ClientId == pClientId).FirstOrDefault();

                    if (fund == null)
                    {
                        LogUtil.Error("用户Id:" + pClientId + ",在Fund表没有记录");
                        return(new CustomJsonResult(ResultType.Failure, "系统繁忙"));
                    }

                    if (rop.Amount <= 0)
                    {
                        return(new CustomJsonResult(ResultType.Failure, "提现金额必须大于0"));
                    }

                    if (fund.AvailableBalance < rop.Amount)
                    {
                        return(new CustomJsonResult(ResultType.Failure, "可提现余额不够"));
                    }

                    if (DateTime.Now > DateTime.Parse("2018-11-15 14:00:00"))
                    {
                        return(new CustomJsonResult(ResultType.Failure, "提现失败,已超过指定时间内提现,谢谢"));
                    }

                    var withdraw = new Withdraw();
                    withdraw.Id               = GuidUtil.New();
                    withdraw.Sn               = SnUtil.Build(Enumeration.BizSnType.Withraw, pClientId);
                    withdraw.ClientId         = pClientId;
                    withdraw.Amount           = rop.Amount;
                    withdraw.AcIdNumber       = rop.AcIdNumber;
                    withdraw.AcName           = rop.AcName;
                    withdraw.AcBank           = rop.AcBank;
                    withdraw.AcBankCardNumber = rop.AcBankCardNumber;
                    withdraw.ApplyTime        = this.DateTime;
                    withdraw.ApplyMethod      = "1";
                    withdraw.Status           = Enumeration.WithdrawStatus.Apply;
                    withdraw.Creator          = pOperater;
                    withdraw.CreateTime       = this.DateTime;
                    CurrentDb.Withdraw.Add(withdraw);

                    fund.AvailableBalance -= rop.Amount;
                    fund.LockBalance      += rop.Amount;
                    fund.Mender            = pOperater;
                    fund.MendTime          = this.DateTime;

                    var fundTrans = new FundTrans();
                    fundTrans.Id               = GuidUtil.New();
                    fundTrans.Sn               = SnUtil.Build(Enumeration.BizSnType.FundTrans, pClientId);
                    fundTrans.ClientId         = pClientId;
                    fundTrans.ChangeType       = Enumeration.FundTransChangeType.WtihdrawApply;
                    fundTrans.ChangeAmount     = -rop.Amount;
                    fundTrans.CurrentBalance   = fund.CurrentBalance;
                    fundTrans.AvailableBalance = fund.AvailableBalance;
                    fundTrans.LockBalance      = fund.LockBalance;
                    fundTrans.Creator          = pOperater;
                    fundTrans.CreateTime       = this.DateTime;
                    fundTrans.TipsIcon         = IconUtil.Withdraw;
                    fundTrans.Description      = string.Format("资金提现-到{0}({1})", withdraw.AcBank, CommonUtil.GetLastString(withdraw.AcBankCardNumber, 4));
                    CurrentDb.FundTrans.Add(fundTrans);
                    CurrentDb.SaveChanges();
                    ts.Complete();


                    var ret = new RetWithdrawApply();

                    ret.Id = withdraw.Id;

                    result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "提现申请成功", ret);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        private CustomJsonResult PayLllegalDealtCompleted(int operater, string orderSn)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                var orderToLllegalDealt = CurrentDb.OrderToLllegalDealt.Where(m => m.Sn == orderSn).FirstOrDefault();

                if (orderToLllegalDealt == null)
                {
                    ts.Complete();
                    return(new CustomJsonResult(ResultType.Success, ResultCode.Success, "找不到订单号"));
                }

                if (orderToLllegalDealt.Status == Enumeration.OrderStatus.Completed)
                {
                    ts.Complete();
                    return(new CustomJsonResult(ResultType.Success, ResultCode.Success, "该订单已经支付完成"));
                }


                if (orderToLllegalDealt.Status != Enumeration.OrderStatus.WaitPay)
                {
                    ts.Complete();
                    return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "该订单未在就绪支付状态"));
                }

                orderToLllegalDealt.Status         = Enumeration.OrderStatus.Completed;
                orderToLllegalDealt.PayTime        = this.DateTime;
                orderToLllegalDealt.CompleteTime   = this.DateTime;
                orderToLllegalDealt.LastUpdateTime = this.DateTime;
                orderToLllegalDealt.Mender         = operater;


                var orderToLllegalDealtDetails = CurrentDb.OrderToLllegalDealtDetails.Where(m => m.OrderId == orderToLllegalDealt.Id).ToList();

                foreach (var item in orderToLllegalDealtDetails)
                {
                    item.Status = Enumeration.OrderToLllegalDealtDetailsStatus.InDealt;
                    CurrentDb.SaveChanges();
                }

                var haoYiLianFund = CurrentDb.Fund.Where(m => m.UserId == (int)Enumeration.UserAccount.HaoYiLian).FirstOrDefault();
                haoYiLianFund.Balance       += orderToLllegalDealt.Price;
                haoYiLianFund.Mender         = operater;
                haoYiLianFund.LastUpdateTime = this.DateTime;

                var haoYiLianFundTrans = new FundTrans();
                haoYiLianFundTrans.UserId       = haoYiLianFund.UserId;
                haoYiLianFundTrans.ChangeAmount = orderToLllegalDealt.Price;
                haoYiLianFundTrans.Balance      = haoYiLianFund.Balance;
                haoYiLianFundTrans.Type         = Enumeration.TransactionsType.LllegalDealt;
                haoYiLianFundTrans.Description  = string.Format("订单号:{0},处理违章:{1}元", orderSn, orderToLllegalDealt.Price.ToF2Price());
                haoYiLianFundTrans.Creator      = operater;
                haoYiLianFundTrans.CreateTime   = this.DateTime;
                CurrentDb.FundTrans.Add(haoYiLianFundTrans);
                CurrentDb.SaveChanges();
                haoYiLianFundTrans.Sn = Sn.Build(SnType.FundTrans, haoYiLianFundTrans.Id).Sn;
                CurrentDb.SaveChanges();


                BizFactory.BizProcessesAudit.ChangeStatusByAuditFlowV1(orderToLllegalDealt.BizProcessesAuditId, Enumeration.AuditFlowV1Status.WaitDealt, operater, "", "订单已经支付,等待处理");


                ts.Complete();



                result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "该订单支付结果反馈成功", null);
            }

            return(result);
        }
Exemplo n.º 3
0
        private CustomJsonResult PayServiceFeeCompleted(int operater, string orderSn)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                var orderToServiceFee = CurrentDb.OrderToServiceFee.Where(m => m.Sn == orderSn).FirstOrDefault();

                if (orderToServiceFee == null)
                {
                    ts.Complete();
                    return(new CustomJsonResult(ResultType.Success, ResultCode.Success, "找不到订单号"));
                }

                if (orderToServiceFee.Status == Enumeration.OrderStatus.Completed)
                {
                    ts.Complete();
                    return(new CustomJsonResult(ResultType.Success, ResultCode.Success, "该订单已经支付完成"));
                }


                if (orderToServiceFee.Status != Enumeration.OrderStatus.WaitPay)
                {
                    ts.Complete();
                    return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "该订单未在就绪支付状态"));
                }


                var haoYiLianFund = CurrentDb.Fund.Where(m => m.UserId == (int)Enumeration.UserAccount.HaoYiLian).FirstOrDefault();

                if (haoYiLianFund == null)
                {
                    Log.Warn("找不到haoYiLianFund");
                }

                haoYiLianFund.Balance       += orderToServiceFee.Price;
                haoYiLianFund.Mender         = operater;
                haoYiLianFund.LastUpdateTime = this.DateTime;

                var haoYiLianFundTrans = new FundTrans();
                haoYiLianFundTrans.UserId       = haoYiLianFund.UserId;
                haoYiLianFundTrans.ChangeAmount = orderToServiceFee.Price;
                haoYiLianFundTrans.Balance      = haoYiLianFund.Balance;
                haoYiLianFundTrans.Type         = Enumeration.TransactionsType.ServiceFee;
                haoYiLianFundTrans.Description  = string.Format("订单号:{0},押金:{1}元,流量费用:{2}元,合计:{3}元", orderSn, orderToServiceFee.Deposit, orderToServiceFee.MobileTrafficFee, orderToServiceFee.Price);
                haoYiLianFundTrans.Creator      = operater;
                haoYiLianFundTrans.CreateTime   = this.DateTime;
                CurrentDb.FundTrans.Add(haoYiLianFundTrans);
                CurrentDb.SaveChanges();
                haoYiLianFundTrans.Sn = Sn.Build(SnType.FundTrans, haoYiLianFundTrans.Id).Sn;
                CurrentDb.SaveChanges();


                var merchantPosMachine = CurrentDb.MerchantPosMachine.Where(m => m.MerchantId == orderToServiceFee.MerchantId && m.PosMachineId == orderToServiceFee.PosMachineId).FirstOrDefault();

                if (merchantPosMachine == null)
                {
                    Log.Warn("找不到merchantPosMachine");
                }

                merchantPosMachine.ExpiryTime = this.DateTime.AddYears(1);

                if (merchantPosMachine.ActiveTime == null)
                {
                    merchantPosMachine.ActiveTime = this.DateTime;
                }

                merchantPosMachine.Status         = Enumeration.MerchantPosMachineStatus.Normal;
                merchantPosMachine.LastUpdateTime = this.DateTime;
                merchantPosMachine.Mender         = operater;

                orderToServiceFee.ExpiryTime     = this.DateTime.AddYears(1);
                orderToServiceFee.Status         = Enumeration.OrderStatus.Completed;
                orderToServiceFee.PayTime        = this.DateTime;
                orderToServiceFee.CompleteTime   = this.DateTime;
                orderToServiceFee.LastUpdateTime = this.DateTime;
                orderToServiceFee.Mender         = operater;


                var merchant = CurrentDb.Merchant.Where(m => m.Id == orderToServiceFee.MerchantId).FirstOrDefault();

                if (merchant == null)
                {
                    Log.Warn("找不到merchant");
                }

                var posMachine = CurrentDb.PosMachine.Where(m => m.Id == orderToServiceFee.PosMachineId).FirstOrDefault();

                if (posMachine == null)
                {
                    Log.Warn("找不到posMachine");
                }

                if (orderToServiceFee.SalesmanId == null)
                {
                    orderToServiceFee.SalesmanId = posMachine.SalesmanId;
                }
                if (orderToServiceFee.AgentId == null)
                {
                    orderToServiceFee.AgentId = posMachine.AgentId;
                }

                if (orderToServiceFee.Deposit > 0)
                {
                    merchant.SalesmanId = posMachine.SalesmanId;
                    merchant.AgentId    = posMachine.AgentId;

                    posMachine.IsUse = true;

                    BizFactory.BizProcessesAudit.Add(operater, Enumeration.BizProcessesAuditType.MerchantAudit, orderToServiceFee.MerchantId, Enumeration.MerchantAuditStatus.WaitPrimaryAudit);

                    CurrentDb.SaveChanges();
                }


                CurrentDb.SaveChanges();

                ts.Complete();
                result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "该订单支付结果反馈成功");
            }

            return(result);
        }
Exemplo n.º 4
0
        private CustomJsonResult PayLllegalQueryRechargeCompleted(int operater, string orderSn)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                var orderToLllegalQueryRecharge = CurrentDb.OrderToLllegalQueryRecharge.Where(m => m.Sn == orderSn).FirstOrDefault();

                if (orderToLllegalQueryRecharge == null)
                {
                    ts.Complete();
                    return(new CustomJsonResult(ResultType.Success, ResultCode.Success, "找不到订单号"));
                }

                if (orderToLllegalQueryRecharge.Status == Enumeration.OrderStatus.Completed)
                {
                    ts.Complete();
                    return(new CustomJsonResult(ResultType.Success, ResultCode.Success, "该订单已经支付完成"));
                }


                if (orderToLllegalQueryRecharge.Status != Enumeration.OrderStatus.WaitPay)
                {
                    ts.Complete();
                    return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "该订单未在就绪支付状态"));
                }

                orderToLllegalQueryRecharge.Status         = Enumeration.OrderStatus.Completed;
                orderToLllegalQueryRecharge.PayTime        = this.DateTime;
                orderToLllegalQueryRecharge.CompleteTime   = this.DateTime;
                orderToLllegalQueryRecharge.LastUpdateTime = this.DateTime;
                orderToLllegalQueryRecharge.Mender         = operater;

                var haoYiLianFund = CurrentDb.Fund.Where(m => m.UserId == (int)Enumeration.UserAccount.HaoYiLian).FirstOrDefault();
                haoYiLianFund.Balance       += orderToLllegalQueryRecharge.Price;
                haoYiLianFund.Mender         = operater;
                haoYiLianFund.LastUpdateTime = this.DateTime;

                var haoYiLianFundTrans = new FundTrans();
                haoYiLianFundTrans.UserId       = haoYiLianFund.UserId;
                haoYiLianFundTrans.ChangeAmount = orderToLllegalQueryRecharge.Price;
                haoYiLianFundTrans.Balance      = haoYiLianFund.Balance;
                haoYiLianFundTrans.Type         = Enumeration.TransactionsType.LllegalQueryRecharg;
                haoYiLianFundTrans.Description  = string.Format("订单号:{0},充值违章查询积分:{1}元", orderSn, orderToLllegalQueryRecharge.Price);
                haoYiLianFundTrans.Creator      = operater;
                haoYiLianFundTrans.CreateTime   = this.DateTime;
                CurrentDb.FundTrans.Add(haoYiLianFundTrans);
                CurrentDb.SaveChanges();
                haoYiLianFundTrans.Sn = Sn.Build(SnType.FundTrans, haoYiLianFundTrans.Id).Sn;
                CurrentDb.SaveChanges();



                var lllegalQueryScore = CurrentDb.LllegalQueryScore.Where(m => m.UserId == orderToLllegalQueryRecharge.UserId && m.MerchantId == orderToLllegalQueryRecharge.MerchantId).FirstOrDefault();
                lllegalQueryScore.Score         += orderToLllegalQueryRecharge.Score;
                lllegalQueryScore.Mender         = operater;
                lllegalQueryScore.LastUpdateTime = this.DateTime;
                CurrentDb.SaveChanges();


                var lllegalQueryScoreTrans = new LllegalQueryScoreTrans();
                lllegalQueryScoreTrans.UserId      = orderToLllegalQueryRecharge.UserId;
                lllegalQueryScoreTrans.ChangeScore = orderToLllegalQueryRecharge.Score;
                lllegalQueryScoreTrans.Score       = lllegalQueryScore.Score;
                lllegalQueryScoreTrans.Type        = Enumeration.LllegalQueryScoreTransType.IncreaseByRecharge;
                lllegalQueryScoreTrans.Description = string.Format("充值{0}元,得到违章查询积分:{1}", orderToLllegalQueryRecharge.Price.ToF2Price(), orderToLllegalQueryRecharge.Score);
                lllegalQueryScoreTrans.Creator     = operater;
                lllegalQueryScoreTrans.CreateTime  = this.DateTime;
                CurrentDb.LllegalQueryScoreTrans.Add(lllegalQueryScoreTrans);
                CurrentDb.SaveChanges();
                lllegalQueryScoreTrans.Sn = Sn.Build(SnType.LllegalQueryScoreTrans, lllegalQueryScoreTrans.Id).Sn;
                CurrentDb.SaveChanges();

                ts.Complete();


                var score = new { score = lllegalQueryScore.Score };


                result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "该订单支付结果反馈成功", score);
            }

            return(result);
        }
Exemplo n.º 5
0
        public CustomJsonResult Audit(string pOperater, RopWithdrawAudit rop)
        {
            CustomJsonResult result = new CustomJsonResult();


            using (TransactionScope ts = new TransactionScope())
            {
                var withdraw = CurrentDb.Withdraw.Where(m => m.Id == rop.WithdrawId).FirstOrDefault();

                if (withdraw == null)
                {
                    return(new CustomJsonResult(ResultType.Failure, "找不到提现记录"));
                }

                if (withdraw.Status == Enumeration.WithdrawStatus.Handing)
                {
                    return(new CustomJsonResult(ResultType.Failure, "该提现申请正在处理中"));
                }

                if (withdraw.Status == Enumeration.WithdrawStatus.Success || withdraw.Status == Enumeration.WithdrawStatus.Failure)
                {
                    return(new CustomJsonResult(ResultType.Failure, "该提现申请已经被处理"));
                }

                withdraw.AuditComments = rop.AuditComments;

                switch (rop.Operate)
                {
                case RopWithdrawAuditOperate.Pass:
                    withdraw.Status    = Enumeration.WithdrawStatus.Handing;
                    withdraw.Mender    = pOperater;
                    withdraw.MendTime  = this.DateTime;
                    withdraw.Auditor   = pOperater;
                    withdraw.AuditTime = this.DateTime;

                    result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "审核通过");

                    break;

                case RopWithdrawAuditOperate.NoPass:

                    withdraw.Status        = Enumeration.WithdrawStatus.Failure;
                    withdraw.FailureReason = rop.AuditComments;
                    withdraw.Mender        = pOperater;
                    withdraw.MendTime      = this.DateTime;
                    withdraw.Auditor       = pOperater;
                    withdraw.AuditTime     = this.DateTime;

                    var fund = CurrentDb.Fund.Where(m => m.ClientId == withdraw.ClientId).FirstOrDefault();

                    fund.AvailableBalance += withdraw.Amount;
                    fund.LockBalance      -= withdraw.Amount;
                    fund.Mender            = pOperater;
                    fund.MendTime          = this.DateTime;

                    var fundTrans = new FundTrans();
                    fundTrans.Id               = GuidUtil.New();
                    fundTrans.Sn               = SnUtil.Build(Enumeration.BizSnType.FundTrans, withdraw.ClientId);
                    fundTrans.ClientId         = withdraw.ClientId;
                    fundTrans.ChangeType       = Enumeration.FundTransChangeType.WtihdrawFailure;
                    fundTrans.ChangeAmount     = withdraw.Amount;
                    fundTrans.CurrentBalance   = fund.CurrentBalance;
                    fundTrans.AvailableBalance = fund.AvailableBalance;
                    fundTrans.LockBalance      = fund.LockBalance;
                    fundTrans.Creator          = pOperater;
                    fundTrans.CreateTime       = this.DateTime;
                    fundTrans.Description      = string.Format("资金提现失败,原因:{0}", withdraw.FailureReason);
                    fundTrans.TipsIcon         = IconUtil.Withdraw;
                    fundTrans.IsNoDisplay      = false;
                    CurrentDb.FundTrans.Add(fundTrans);

                    result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "审核不通过");
                    break;

                default:
                    result = new CustomJsonResult(ResultType.Failure, "未知操作");
                    break;
                }

                CurrentDb.SaveChanges();
                ts.Complete();
            }


            return(result);
        }