public OrderDepositRentInfo GetRentOrder(int merchantId, int posMachineId)
        {
            var merchant = CurrentDb.Merchant.Where(m => m.Id == merchantId).FirstOrDefault();

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

            var orderToRent = CurrentDb.OrderToDepositRent.Where(m => m.MerchantId == merchantId && m.PosMachineId == posMachineId && m.ProductType == Enumeration.ProductType.PosMachineRent && m.Status == Enumeration.OrderStatus.WaitPay).FirstOrDefault();

            CalculateRent calculateRent = new CalculateRent(merchantPosMachine.Rent);

            if (orderToRent == null)
            {
                orderToRent              = new OrderToDepositRent();
                orderToRent.MerchantId   = merchant.Id;
                orderToRent.PosMachineId = posMachineId;
                orderToRent.UserId       = merchantPosMachine.UserId;
                orderToRent.CreateTime   = this.DateTime;
                orderToRent.Creator      = 0;
                orderToRent.SubmitTime   = this.DateTime;
                orderToRent.ProductType  = Enumeration.ProductType.PosMachineRent;
                orderToRent.ProductName  = Enumeration.ProductType.PosMachineRent.GetCnName();
                orderToRent.ProductId    = (int)Enumeration.ProductType.PosMachineRent;

                orderToRent.Deposit = 0;

                orderToRent.RentMonths  = 3;
                orderToRent.MonthlyRent = calculateRent.MonthlyRent;
                orderToRent.RentTotal   = calculateRent.GetRent(orderToRent.RentMonths);
                orderToRent.RentVersion = calculateRent.Version;

                orderToRent.Price  = orderToRent.RentTotal;
                orderToRent.Status = Enumeration.OrderStatus.WaitPay;
                CurrentDb.OrderToDepositRent.Add(orderToRent);
                CurrentDb.SaveChanges();
                orderToRent.Sn = Sn.Build(SnType.DepositRent, orderToRent.Id);
                CurrentDb.SaveChanges();
            }


            OrderDepositRentInfo orderDepositRentInfo = new OrderDepositRentInfo();

            orderDepositRentInfo.Id           = orderToRent.Id;
            orderDepositRentInfo.Sn           = orderToRent.Sn;
            orderDepositRentInfo.Product      = orderToRent.ProductName;
            orderDepositRentInfo.ProductType  = orderToRent.ProductType;
            orderDepositRentInfo.Status       = orderToRent.Status;
            orderDepositRentInfo.StatusName   = orderToRent.Status.GetCnName();
            orderDepositRentInfo.MonthlyRent  = calculateRent.MonthlyRent;
            orderDepositRentInfo.Remarks      = calculateRent.Remark;
            orderDepositRentInfo.MerchantCode = merchant.ClientCode;
            orderDepositRentInfo.RentDueDate  = merchantPosMachine.RentDueDate.ToUnifiedFormatDate();


            return(orderDepositRentInfo);
        }
        public CustomJsonResult GetPayTranSn(int operater, OrderPayTrans orderPayTrans)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {

                var order = CurrentDb.Order.Where(m => m.UserId == orderPayTrans.UserId && m.Id == orderPayTrans.OrderId && m.Sn == orderPayTrans.OrderSn).FirstOrDefault();
                if (order == null)
                {
                    return new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "跳转支付错误");
                }

                var l_orderPayTrans = new OrderPayTrans();

                l_orderPayTrans.UserId = orderPayTrans.UserId;
                l_orderPayTrans.MerchantId = orderPayTrans.MerchantId;
                l_orderPayTrans.PosMachineId = orderPayTrans.PosMachineId;
                l_orderPayTrans.OrderId = orderPayTrans.OrderId;
                l_orderPayTrans.OrderSn = orderPayTrans.OrderSn;
                l_orderPayTrans.TransType = orderPayTrans.TransType;


                if (BizFactory.AppSettings.IsTest)
                {
                    l_orderPayTrans.Amount = "1";
                }
                else
                {
                    l_orderPayTrans.Amount = Convert.ToInt32((order.Price * 100)).ToString();
                }

                l_orderPayTrans.CreateTime = DateTime.Now;
                l_orderPayTrans.Creator = operater;
                CurrentDb.OrderPayTrans.Add(l_orderPayTrans);
                CurrentDb.SaveChanges();

                SnModel snModel = Sn.Build(SnType.OrderPayTrans, l_orderPayTrans.Id);

                l_orderPayTrans.Sn = snModel.Sn;

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


                var model = new { orderId = orderPayTrans.OrderId, orderSn = orderPayTrans.OrderSn, payTransSn = l_orderPayTrans.Sn, transType = l_orderPayTrans.TransType, amount = l_orderPayTrans.Amount };

                result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "获取成功", model);

            }

            return result;
        }
        public CustomJsonResult SubmitClaim(int operater, int userId, OrderToCarClaim orderToCarClaim)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                //用户信息
                var clientUser = CurrentDb.SysClientUser.Where(m => m.Id == userId).FirstOrDefault();
                //商户信息
                var merchant = CurrentDb.Merchant.Where(m => m.Id == clientUser.MerchantId).FirstOrDefault();

                var insuranceCompany = CurrentDb.Company.Where(m => m.Id == orderToCarClaim.InsuranceCompanyId).FirstOrDefault();


                orderToCarClaim.SalesmanId = merchant.SalesmanId ?? 0;
                orderToCarClaim.AgentId = merchant.AgentId ?? 0;

                orderToCarClaim.Type =  Enumeration.OrderType.InsureForCarForClaim;
                orderToCarClaim.TypeName = Enumeration.OrderType.InsureForCarForClaim.GetCnName();
                orderToCarClaim.MerchantId = merchant.Id;
                orderToCarClaim.PosMachineId = orderToCarClaim.PosMachineId;
                orderToCarClaim.UserId = merchant.UserId;
                orderToCarClaim.InsuranceCompanyName = insuranceCompany.Name;
                orderToCarClaim.Status = Enumeration.OrderStatus.Submitted;
                orderToCarClaim.SubmitTime = this.DateTime;
                orderToCarClaim.CreateTime = this.DateTime;
                orderToCarClaim.Creator = operater;
                CurrentDb.OrderToCarClaim.Add(orderToCarClaim);
                CurrentDb.SaveChanges();

                SnModel snModel = Sn.Build(SnType.OrderToCarClaim, orderToCarClaim.Id);

                orderToCarClaim.Sn = snModel.Sn;
                orderToCarClaim.TradeSnByWechat = snModel.TradeSnByWechat;
                orderToCarClaim.TradeSnByAlipay = snModel.TradeSnByAlipay;


                //状态改为待核实
                BizProcessesAudit bizProcessesAudit = BizFactory.BizProcessesAudit.Add(operater, Enumeration.BizProcessesAuditType.OrderToCarClaim, orderToCarClaim.Id, Enumeration.CarClaimDealtStatus.WaitVerifyOrder);
                BizFactory.BizProcessesAudit.ChangeAuditDetails(Enumeration.OperateType.Submit, Enumeration.CarClaimDealtStep.Submit, bizProcessesAudit.Id, operater, orderToCarClaim.ClientRequire, "商户提交理赔需求", this.DateTime);

                orderToCarClaim.BizProcessesAuditId = bizProcessesAudit.Id;

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

                result = new CustomJsonResult(ResultType.Success, "提交成功");
            }


            return result;
        }
        public CustomJsonResult Submit(int operater, OrderToInsurance orderToInsurance)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                var clientUser = CurrentDb.SysClientUser.Where(m => m.Id == orderToInsurance.UserId).FirstOrDefault();
                var merchant   = CurrentDb.Merchant.Where(m => m.Id == clientUser.MerchantId).FirstOrDefault();
                var productSku = CurrentDb.ProductSku.Where(m => m.Id == orderToInsurance.ProductSkuId).FirstOrDefault();
                var product    = CurrentDb.Product.Where(m => m.Id == productSku.ProductId).FirstOrDefault();

                orderToInsurance.SalesmanId           = merchant.SalesmanId ?? 0;
                orderToInsurance.AgentId              = merchant.AgentId ?? 0;
                orderToInsurance.Type                 = Enumeration.OrderType.Insure;
                orderToInsurance.TypeName             = Enumeration.OrderType.Insure.GetCnName();
                orderToInsurance.ProductId            = product.Id;
                orderToInsurance.ProductType          = product.Type;
                orderToInsurance.ProductName          = product.Name;
                orderToInsurance.ProductSkuId         = productSku.Id;
                orderToInsurance.ProductSkuName       = productSku.Name;
                orderToInsurance.InsuranceCompanyId   = product.SupplierId;
                orderToInsurance.InsuranceCompanyName = product.Supplier;
                orderToInsurance.Status               = Enumeration.OrderStatus.Submitted;
                orderToInsurance.SubmitTime           = this.DateTime;
                orderToInsurance.CreateTime           = this.DateTime;
                orderToInsurance.Creator              = operater;
                CurrentDb.OrderToInsurance.Add(orderToInsurance);
                CurrentDb.SaveChanges();


                SnModel snModel = Sn.Build(SnType.OrderToCredit, orderToInsurance.Id);

                orderToInsurance.Sn = snModel.Sn;
                orderToInsurance.TradeSnByWechat = snModel.TradeSnByWechat;
                orderToInsurance.TradeSnByAlipay = snModel.TradeSnByAlipay;

                var bizProcessesAudit = BizFactory.BizProcessesAudit.Add(operater, Enumeration.BizProcessesAuditType.OrderToInsurance, orderToInsurance.Id, Enumeration.AuditFlowV1Status.Submit);
                BizFactory.BizProcessesAudit.ChangeStatusByAuditFlowV1(bizProcessesAudit.Id, Enumeration.AuditFlowV1Status.Submit, operater, null, "提交订单,等待取单");

                orderToInsurance.BizProcessesAuditId = bizProcessesAudit.Id;

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

                result = new CustomJsonResult(ResultType.Success, "提交成功");
            }


            return(result);
        }
Beispiel #5
0
        public CustomJsonResult SubmitClaim(int operater, int userId, OrderToCarClaim orderToCarClaim)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                //用户信息
                var clientUser = CurrentDb.SysClientUser.Where(m => m.Id == userId).FirstOrDefault();
                //商户信息
                var merchant = CurrentDb.Merchant.Where(m => m.Id == clientUser.MerchantId).FirstOrDefault();

                var insuranceCompany = CurrentDb.InsuranceCompany.Where(m => m.Id == orderToCarClaim.InsuranceCompanyId).FirstOrDefault();

                //2011为车险理赔
                var product = CurrentDb.Product.Where(m => m.Id == 2013).FirstOrDefault();

                orderToCarClaim.ProductId            = product.Id;
                orderToCarClaim.ProductType          = product.Type;
                orderToCarClaim.ProductName          = product.Name;
                orderToCarClaim.MerchantId           = merchant.Id;
                orderToCarClaim.PosMachineId         = orderToCarClaim.PosMachineId;
                orderToCarClaim.UserId               = merchant.UserId;
                orderToCarClaim.InsuranceCompanyName = insuranceCompany.Name;
                orderToCarClaim.Status               = Enumeration.OrderStatus.Submitted;
                orderToCarClaim.SubmitTime           = this.DateTime;
                orderToCarClaim.CreateTime           = this.DateTime;
                orderToCarClaim.Creator              = operater;
                CurrentDb.OrderToCarClaim.Add(orderToCarClaim);
                CurrentDb.SaveChanges();
                orderToCarClaim.Sn = Sn.Build(SnType.CarClaim, orderToCarClaim.Id);

                //状态改为待核实
                BizProcessesAudit bizProcessesAudit = BizFactory.BizProcessesAudit.Add(operater, Enumeration.BizProcessesAuditType.CarClaim, orderToCarClaim.Id, Enumeration.CarClaimDealtStatus.WaitVerifyOrder, "");
                BizFactory.BizProcessesAudit.ChangeAuditDetails(Enumeration.OperateType.Submit, Enumeration.CarClaimDealtStep.Submit, bizProcessesAudit.Id, operater, orderToCarClaim.ClientRequire, "商户提交理赔需求", this.DateTime);


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

                result = new CustomJsonResult(ResultType.Success, "提交成功");
            }


            return(result);
        }
        public CustomJsonResult Submit(int operater, OrderToTalentDemand orderToTalentDemand)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                //用户信息
                var clientUser = CurrentDb.SysClientUser.Where(m => m.Id == orderToTalentDemand.UserId).FirstOrDefault();
                //商户信息
                var merchant = CurrentDb.Merchant.Where(m => m.Id == clientUser.MerchantId).FirstOrDefault();

                orderToTalentDemand.SalesmanId  = merchant.SalesmanId ?? 0;
                orderToTalentDemand.AgentId     = merchant.AgentId ?? 0;
                orderToTalentDemand.Type        = Enumeration.OrderType.TalentDemand;
                orderToTalentDemand.TypeName    = Enumeration.OrderType.TalentDemand.GetCnName();
                orderToTalentDemand.WorkJobName = orderToTalentDemand.WorkJob.GetCnName();
                orderToTalentDemand.Status      = Enumeration.OrderStatus.Submitted;
                orderToTalentDemand.SubmitTime  = this.DateTime;
                orderToTalentDemand.CreateTime  = this.DateTime;
                orderToTalentDemand.Creator     = operater;
                CurrentDb.OrderToTalentDemand.Add(orderToTalentDemand);
                CurrentDb.SaveChanges();


                SnModel snModel = Sn.Build(SnType.OrderToTalentDemand, orderToTalentDemand.Id);

                orderToTalentDemand.Sn = snModel.Sn;
                orderToTalentDemand.TradeSnByWechat = snModel.TradeSnByWechat;
                orderToTalentDemand.TradeSnByAlipay = snModel.TradeSnByAlipay;

                var bizProcessesAudit = BizFactory.BizProcessesAudit.Add(operater, Enumeration.BizProcessesAuditType.OrderToTalentDemand, orderToTalentDemand.Id, Enumeration.AuditFlowV1Status.Submit);
                BizFactory.BizProcessesAudit.ChangeStatusByAuditFlowV1(bizProcessesAudit.Id, Enumeration.AuditFlowV1Status.Submit, operater, null, "提交订单,等待取单");

                orderToTalentDemand.BizProcessesAuditId = bizProcessesAudit.Id;

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

                result = new CustomJsonResult(ResultType.Success, "提交成功");
            }


            return(result);
        }
Beispiel #7
0
        public CustomJsonResult SubmitCarInsure(int operater, int userId, OrderToCarInsure orderToCarInsure, List <OrderToCarInsureOfferCompany> orderToCarInsureOfferCompany, List <OrderToCarInsureOfferKind> orderToCarInsureOfferKind)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                OrderToCarInsure order = new OrderToCarInsure();

                //用户信息
                var clientUser = CurrentDb.SysClientUser.Where(m => m.Id == userId).FirstOrDefault();
                //商户信息
                var merchant = CurrentDb.Merchant.Where(m => m.Id == clientUser.MerchantId).FirstOrDefault();
                //2011为车险投保产品,2012为车险续保产品
                var product = CurrentDb.Product.Where(m => m.Type == orderToCarInsure.ProductType).FirstOrDefault();


                order.MerchantId    = merchant.Id;
                order.PosMachineId  = orderToCarInsure.PosMachineId;
                order.UserId        = merchant.UserId;
                order.ProductId     = product.Id;
                order.ProductName   = product.Name;
                order.ProductType   = product.Type;
                order.ClientRequire = orderToCarInsure.ClientRequire;


                order.InsuranceCompanyId   = orderToCarInsure.InsuranceCompanyId;
                order.InsuranceCompanyName = orderToCarInsure.InsuranceCompanyName;

                order.CarOwner         = orderToCarInsure.CarOwner;
                order.CarOwnerIdNumber = orderToCarInsure.CarOwnerIdNumber;
                order.CarOwnerAddress  = orderToCarInsure.CarOwnerAddress;
                order.CarModel         = orderToCarInsure.CarModel;
                order.CarOwner         = orderToCarInsure.CarOwner;
                order.CarPlateNo       = orderToCarInsure.CarPlateNo;
                order.CarEngineNo      = orderToCarInsure.CarEngineNo;
                order.CarVin           = orderToCarInsure.CarVin;
                order.CarVechicheType  = orderToCarInsure.CarVechicheType;
                order.CarRegisterDate  = orderToCarInsure.CarRegisterDate;
                order.CarIssueDate     = orderToCarInsure.CarIssueDate;


                order.InsurePlanId      = orderToCarInsure.InsurePlanId;
                order.CZ_CL_XSZ_ImgUrl  = orderToCarInsure.CZ_CL_XSZ_ImgUrl;
                order.CZ_SFZ_ImgUrl     = orderToCarInsure.CZ_SFZ_ImgUrl;
                order.YCZ_CLDJZ_ImgUrl  = orderToCarInsure.YCZ_CLDJZ_ImgUrl;
                order.CCSJM_WSZM_ImgUrl = orderToCarInsure.CCSJM_WSZM_ImgUrl;
                order.Status            = Enumeration.OrderStatus.Submitted;
                order.StartOfferTime    = this.DateTime;
                order.SubmitTime        = this.DateTime;
                order.CreateTime        = this.DateTime;
                order.Creator           = operater;
                order.IsLastYearNewCar  = orderToCarInsure.IsLastYearNewCar;
                order.IsSameLastYear    = orderToCarInsure.IsSameLastYear;
                CurrentDb.OrderToCarInsure.Add(order);
                CurrentDb.SaveChanges();
                order.Sn = Sn.Build(SnType.CarInsure, order.Id);



                if (orderToCarInsureOfferCompany != null)
                {
                    foreach (var m in orderToCarInsureOfferCompany)
                    {
                        m.OrderId    = order.Id;
                        m.CreateTime = this.DateTime;
                        m.Creator    = operater;
                        CurrentDb.OrderToCarInsureOfferCompany.Add(m);
                    }
                }

                if (orderToCarInsureOfferKind != null)
                {
                    foreach (var m in orderToCarInsureOfferKind)
                    {
                        m.OrderId    = order.Id;
                        m.CreateTime = this.DateTime;
                        m.Creator    = operater;
                        CurrentDb.OrderToCarInsureOfferKind.Add(m);
                    }
                }


                BizProcessesAudit bizProcessesAudit = BizFactory.BizProcessesAudit.Add(operater, Enumeration.BizProcessesAuditType.CarInsureOffer, order.Id, Enumeration.CarInsureOfferDealtStatus.WaitOffer, "");

                BizFactory.BizProcessesAudit.ChangeAuditDetails(Enumeration.OperateType.Submit, Enumeration.CarInsureOfferDealtStep.Submit, bizProcessesAudit.Id, operater, orderToCarInsure.ClientRequire, "商户提交投保订单", this.DateTime);

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


                result = new CustomJsonResult(ResultType.Success, "提交成功");
            }

            return(result);
        }
        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);
        }
        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);
        }
        public CustomJsonResult CreateAccount(int operater, string token, string validCode, string userName, string password, string deviceId)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                var code = CurrentDb.SysSmsSendHistory.Where(m => m.Token == token && m.ValidCode == validCode && m.IsUse == false && m.ExpireTime >= DateTime.Now).FirstOrDefault();
                if (code == null)
                {
                    return(new CustomJsonResult(ResultType.Failure, "验证码错误"));
                }

                code.IsUse = true;

                var isExists = CurrentDb.SysUser.Where(m => m.UserName == userName).FirstOrDefault();

                if (isExists != null)
                {
                    return(new CustomJsonResult(ResultType.Failure, "账号已经存在"));
                }

                var sysClientUser = new SysClientUser();
                sysClientUser.UserName          = userName;
                sysClientUser.PhoneNumber       = userName;
                sysClientUser.PasswordHash      = PassWordHelper.HashPassword(password);
                sysClientUser.SecurityStamp     = Guid.NewGuid().ToString();
                sysClientUser.RegisterTime      = this.DateTime;
                sysClientUser.CreateTime        = this.DateTime;
                sysClientUser.Creator           = operater;
                sysClientUser.ClientAccountType = Enumeration.ClientAccountType.MasterAccount;
                sysClientUser.Status            = Enumeration.UserStatus.Normal;
                sysClientUser.Type = Enumeration.UserType.Client;

                CurrentDb.SysClientUser.Add(sysClientUser);
                CurrentDb.SaveChanges();

                var clientCode = CurrentDb.SysClientCode.Where(m => m.Id == sysClientUser.Id).FirstOrDefault();

                var merchant = new Merchant();
                merchant.ClientCode = clientCode.Code;
                merchant.UserId     = sysClientUser.Id;
                merchant.CreateTime = this.DateTime;
                merchant.Creator    = operater;
                merchant.Status     = Enumeration.MerchantStatus.WaitFill;
                CurrentDb.Merchant.Add(merchant);
                CurrentDb.SaveChanges();

                sysClientUser.ClientCode = clientCode.Code;
                sysClientUser.MerchantId = merchant.Id;

                var posMachine = CurrentDb.PosMachine.Where(m => m.DeviceId == deviceId).FirstOrDefault();

                if (posMachine == null)
                {
                    return(new CustomJsonResult(ResultType.Failure, "POS机未登记,请联系客服"));

                    //posMachine = new PosMachine();
                    //posMachine.DeviceId = deviceId;
                    //posMachine.Creator = operater;
                    //posMachine.CreateTime = this.DateTime;
                    //CurrentDb.PosMachine.Add(posMachine);
                    //CurrentDb.SaveChanges();
                }
                else
                {
                    if (posMachine.IsUse)
                    {
                        return(new CustomJsonResult(ResultType.Failure, "POS机已被注册"));
                    }

                    if (posMachine.SalesmanId == null)
                    {
                        return(new CustomJsonResult(ResultType.Failure, "POS机未出库,请联系客服"));
                    }

                    posMachine.IsUse          = false;
                    posMachine.Mender         = operater;
                    posMachine.LastUpdateTime = this.DateTime;
                    CurrentDb.SaveChanges();
                }

                var bankCard = new BankCard();
                bankCard.MerchantId = merchant.Id;
                bankCard.UserId     = merchant.UserId;
                bankCard.CreateTime = this.DateTime;
                bankCard.Creator    = operater;
                CurrentDb.BankCard.Add(bankCard);
                CurrentDb.SaveChanges();

                CalculateServiceFee calculateServiceFee = new CalculateServiceFee();

                var merchantPosMachine = new MerchantPosMachine();
                merchantPosMachine.BankCardId       = bankCard.Id;
                merchantPosMachine.UserId           = sysClientUser.Id;
                merchantPosMachine.MerchantId       = merchant.Id;
                merchantPosMachine.PosMachineId     = posMachine.Id;
                merchantPosMachine.Deposit          = calculateServiceFee.Deposit;
                merchantPosMachine.MobileTrafficFee = calculateServiceFee.MobileTrafficFee;
                merchantPosMachine.Status           = Enumeration.MerchantPosMachineStatus.NoActive;
                merchantPosMachine.CreateTime       = this.DateTime;
                merchantPosMachine.Creator          = operater;
                CurrentDb.MerchantPosMachine.Add(merchantPosMachine);
                CurrentDb.SaveChanges();

                var orderToServiceFee = new OrderToServiceFee();
                orderToServiceFee.MerchantId       = merchant.Id;
                orderToServiceFee.PosMachineId     = posMachine.Id;
                orderToServiceFee.UserId           = sysClientUser.Id;
                orderToServiceFee.SubmitTime       = this.DateTime;
                orderToServiceFee.Type             = Enumeration.OrderType.PosMachineServiceFee;
                orderToServiceFee.TypeName         = Enumeration.OrderType.PosMachineServiceFee.GetCnName();
                orderToServiceFee.Deposit          = calculateServiceFee.Deposit;
                orderToServiceFee.MobileTrafficFee = calculateServiceFee.MobileTrafficFee;
                orderToServiceFee.PriceVersion     = calculateServiceFee.Version;
                orderToServiceFee.Price            = calculateServiceFee.Deposit + calculateServiceFee.MobileTrafficFee;
                orderToServiceFee.Status           = Enumeration.OrderStatus.WaitPay;
                orderToServiceFee.CreateTime       = this.DateTime;
                orderToServiceFee.Creator          = operater;
                CurrentDb.OrderToServiceFee.Add(orderToServiceFee);
                CurrentDb.SaveChanges();

                SnModel snModel = Sn.Build(SnType.OrderToServiceFee, orderToServiceFee.Id);
                orderToServiceFee.Sn = snModel.Sn;
                orderToServiceFee.TradeSnByWechat = snModel.TradeSnByWechat;
                orderToServiceFee.TradeSnByAlipay = snModel.TradeSnByAlipay;



                var sysItemCacheUpdateTime = new SysItemCacheUpdateTime();

                sysItemCacheUpdateTime.Name           = sysClientUser.UserName;
                sysItemCacheUpdateTime.Type           = Enumeration.SysItemCacheType.User;
                sysItemCacheUpdateTime.ReferenceId    = sysClientUser.Id;
                sysItemCacheUpdateTime.Creator        = operater;
                sysItemCacheUpdateTime.CreateTime     = this.DateTime;
                sysItemCacheUpdateTime.Mender         = operater;
                sysItemCacheUpdateTime.LastUpdateTime = this.DateTime;

                CurrentDb.SysItemCacheUpdateTime.Add(sysItemCacheUpdateTime);
                CurrentDb.SaveChanges();


                var fund = new Fund();

                fund.UserId     = sysClientUser.Id;
                fund.MerchantId = merchant.Id;
                fund.Balance    = 0;
                fund.Creator    = operater;
                fund.CreateTime = this.DateTime;
                CurrentDb.Fund.Add(fund);
                CurrentDb.SaveChanges();


                var lllegalQueryScore = new LllegalQueryScore();
                lllegalQueryScore.UserId     = sysClientUser.Id;
                lllegalQueryScore.MerchantId = merchant.Id;
                lllegalQueryScore.Score      = 50;
                lllegalQueryScore.Creator    = operater;
                lllegalQueryScore.CreateTime = this.DateTime;
                CurrentDb.LllegalQueryScore.Add(lllegalQueryScore);
                CurrentDb.SaveChanges();


                var lllegalQueryScoreTrans = new LllegalQueryScoreTrans();
                lllegalQueryScoreTrans.UserId      = sysClientUser.Id;
                lllegalQueryScoreTrans.ChangeScore = lllegalQueryScore.Score;
                lllegalQueryScoreTrans.Score       = lllegalQueryScore.Score;
                lllegalQueryScoreTrans.Type        = Enumeration.LllegalQueryScoreTransType.IncreaseByInit;
                lllegalQueryScoreTrans.Description = string.Format("初始违章查询积分:{0}", lllegalQueryScore.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();

                result = new CustomJsonResult(ResultType.Success, "注册成功");
            }

            return(result);
        }
        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);
        }
        public CustomJsonResult Submit(int operater, bool isGetConfirmInfo, OrderToLllegalDealt orderToLllegalDealt, List <OrderToLllegalDealtDetails> orderToLllegalDealtDetails)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                var clientUser = CurrentDb.SysClientUser.Where(m => m.Id == orderToLllegalDealt.UserId).FirstOrDefault();
                var merchant   = CurrentDb.Merchant.Where(m => m.Id == clientUser.MerchantId).FirstOrDefault();


                orderToLllegalDealt.SalesmanId = merchant.SalesmanId ?? 0;
                orderToLllegalDealt.AgentId    = merchant.AgentId ?? 0;
                orderToLllegalDealt.Type       = Enumeration.OrderType.LllegalDealt;
                orderToLllegalDealt.TypeName   = Enumeration.OrderType.LllegalDealt.GetCnName();
                orderToLllegalDealt.SubmitTime = this.DateTime;
                orderToLllegalDealt.CreateTime = this.DateTime;
                orderToLllegalDealt.Creator    = operater;
                orderToLllegalDealt.SumCount   = orderToLllegalDealtDetails.Count();
                orderToLllegalDealt.SumFine    = orderToLllegalDealtDetails.Sum(m => m.Fine);
                orderToLllegalDealt.SumPoint   = orderToLllegalDealtDetails.Sum(m => m.Point);



                orderToLllegalDealt.SumServiceFees = orderToLllegalDealtDetails.Sum(m => m.ServiceFee);
                orderToLllegalDealt.SumLateFees    = orderToLllegalDealtDetails.Sum(m => m.Late_fees);
                orderToLllegalDealt.Price          = orderToLllegalDealt.SumFine + orderToLllegalDealt.SumServiceFees + orderToLllegalDealt.SumLateFees;
                CurrentDb.OrderToLllegalDealt.Add(orderToLllegalDealt);
                CurrentDb.SaveChanges();

                SnModel snModel = Sn.Build(SnType.OrderToLllegalQueryRecharge, orderToLllegalDealt.Id);

                orderToLllegalDealt.Sn = snModel.Sn;
                orderToLllegalDealt.TradeSnByWechat = snModel.TradeSnByWechat;
                orderToLllegalDealt.TradeSnByAlipay = snModel.TradeSnByAlipay;
                CurrentDb.SaveChanges();


                foreach (var item in orderToLllegalDealtDetails)
                {
                    item.OrderId    = orderToLllegalDealt.Id;
                    item.Status     = Enumeration.OrderToLllegalDealtDetailsStatus.WaitPay;
                    item.CreateTime = this.DateTime;
                    item.Creator    = operater;

                    CurrentDb.OrderToLllegalDealtDetails.Add(item);
                    CurrentDb.SaveChanges();
                }



                OrderConfirmInfo yOrder = new OrderConfirmInfo();
                var bizProcessesAudit   = BizFactory.BizProcessesAudit.Add(operater, Enumeration.BizProcessesAuditType.OrderToLllegalDealt, orderToLllegalDealt.Id, Enumeration.AuditFlowV1Status.Submit);
                if (isGetConfirmInfo)
                {
                    orderToLllegalDealt.Status = Enumeration.OrderStatus.WaitPay;

                    yOrder.OrderId       = orderToLllegalDealt.Id;
                    yOrder.OrderSn       = orderToLllegalDealt.Sn;
                    yOrder.remarks       = orderToLllegalDealt.Remarks;
                    yOrder.orderType     = orderToLllegalDealt.Type;
                    yOrder.orderTypeName = orderToLllegalDealt.TypeName;



                    //yOrder.confirmField.Add(new Entity.AppApi.OrderField("订单编号", orderToLllegalDealt.Sn.NullToEmpty()));
                    yOrder.confirmField.Add(new Entity.AppApi.OrderField("车牌号码", orderToLllegalDealt.CarNo.NullToEmpty()));
                    yOrder.confirmField.Add(new Entity.AppApi.OrderField("违章", string.Format("{0}次", orderToLllegalDealt.SumCount)));
                    yOrder.confirmField.Add(new Entity.AppApi.OrderField("扣分", orderToLllegalDealt.SumPoint.NullToEmpty()));
                    yOrder.confirmField.Add(new Entity.AppApi.OrderField("罚款", orderToLllegalDealt.SumFine.NullToEmpty()));
                    yOrder.confirmField.Add(new Entity.AppApi.OrderField("支付金额", string.Format("{0}元", orderToLllegalDealt.Price.NullToEmpty())));


                    #region 支持的支付方式
                    int[] payMethods = new int[1] {
                        1
                    };

                    foreach (var payWayId in payMethods)
                    {
                        var payWay = new PayWay();
                        payWay.id = payWayId;
                        yOrder.payMethod.Add(payWay);
                    }
                    #endregion

                    BizFactory.BizProcessesAudit.ChangeStatusByAuditFlowV1(bizProcessesAudit.Id, Enumeration.AuditFlowV1Status.waitGoDealt, operater, null, "提交订单,等待支付");
                }
                else
                {
                    orderToLllegalDealt.Status = Enumeration.OrderStatus.Submitted;
                    BizFactory.BizProcessesAudit.ChangeStatusByAuditFlowV1(bizProcessesAudit.Id, Enumeration.AuditFlowV1Status.Submit, operater, null, "提交订单,等待取单");
                }

                orderToLllegalDealt.BizProcessesAuditId = bizProcessesAudit.Id;


                CurrentDb.SaveChanges();

                ts.Complete();

                result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "提交成功", yOrder);
            }


            return(result);
        }
        public CustomJsonResult Apply(int operater, int userId, bool confirm, int bankCardId, decimal withdrawAmount)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                var clientUser = CurrentDb.SysClientUser.Where(m => m.Id == userId).FirstOrDefault();

                CalculateWithdrawFee calculateWithdrawFee = new CalculateWithdrawFee(withdrawAmount);

                if (calculateWithdrawFee.Fee > 0)
                {
                    if (!confirm)
                    {
                        return(new CustomJsonResult(ResultType.Success, ResultCode.WithdrawConfirm, "您的提现手续费为" + calculateWithdrawFee.Fee + ",确定要提现?"));
                    }
                }

                var bankCard = CurrentDb.BankCard.Where(m => m.Id == bankCardId).FirstOrDefault();

                var withdraw = new Withdraw();
                withdraw.MerchantId       = clientUser.MerchantId;
                withdraw.UserId           = clientUser.Id;
                withdraw.Amount           = calculateWithdrawFee.Amount;
                withdraw.AmountByAfterFee = calculateWithdrawFee.AmountByAfterFee;
                withdraw.Fee                 = calculateWithdrawFee.Fee;
                withdraw.FeeRateRule         = calculateWithdrawFee.FeeRateRule;
                withdraw.BankCardId          = bankCardId;
                withdraw.SettlementStartTime = this.DateTime;
                withdraw.Creator             = operater;
                withdraw.CreateTime          = this.DateTime;
                withdraw.ExpectArriveTime    = this.DateTime.AddDays(1);
                withdraw.Status              = Enumeration.WithdrawStatus.SendRequest;
                CurrentDb.Withdraw.Add(withdraw);
                withdraw.Sn = Sn.Build(SnType.Withdraw, withdraw.Id);
                CurrentDb.SaveChanges();

                //商户流水
                var clienfund = CurrentDb.Fund.Where(m => m.UserId == clientUser.Id).FirstOrDefault();
                if (clienfund.Balance < withdraw.Amount)
                {
                    return(new CustomJsonResult(ResultType.Failure, "余额不够"));
                }

                clienfund.Balance -= withdraw.Amount;//可用金额

                var clientTrans = new Transactions();
                clientTrans.UserId       = clientUser.Id;
                clientTrans.Type         = Enumeration.TransactionsType.Withdraw;
                clientTrans.ChangeAmount = -withdraw.Amount;
                clientTrans.Balance      = clienfund.Balance;
                clientTrans.Creator      = operater;
                clientTrans.CreateTime   = this.DateTime;
                CurrentDb.Transactions.Add(clientTrans);
                CurrentDb.SaveChanges();
                clientTrans.Sn          = Sn.Build(SnType.Transactions, clientTrans.Id);
                clientTrans.Description = string.Format("您在{0}发起申请一笔提现,金额:{1}元", this.DateTime.ToUnifiedFormatDateTime(), withdraw.Amount);
                CurrentDb.SaveChanges();


                //手续费流水
                if (calculateWithdrawFee.Fee > 0)
                {
                    var withdrawFeeFund = CurrentDb.Fund.Where(m => m.UserId == (int)Enumeration.UserAccount.WithdrawFee).FirstOrDefault();
                    withdrawFeeFund.Balance       += withdraw.Fee;
                    withdrawFeeFund.Mender         = operater;
                    withdrawFeeFund.LastUpdateTime = this.DateTime;

                    var withdrawFeeTrans = new Transactions();
                    withdrawFeeTrans.UserId       = withdrawFeeFund.UserId;
                    withdrawFeeTrans.ChangeAmount = withdraw.Fee;
                    withdrawFeeTrans.Balance      = withdrawFeeFund.Balance;
                    withdrawFeeTrans.Type         = Enumeration.TransactionsType.ChargeFee;
                    withdrawFeeTrans.Description  = string.Format("在{0}来自商户({1})的提现手续费,金额:{2}元", this.DateTime.ToUnifiedFormatDateTime(), clientUser.ClientCode, withdraw.Fee);
                    withdrawFeeTrans.Creator      = operater;
                    withdrawFeeTrans.CreateTime   = this.DateTime;
                    CurrentDb.Transactions.Add(withdrawFeeTrans);
                    CurrentDb.SaveChanges();
                    withdrawFeeTrans.Sn = Sn.Build(SnType.Transactions, withdrawFeeTrans.Id);
                    CurrentDb.SaveChanges();
                }

                //资金池流水
                var withdrawFundPoolFund = CurrentDb.Fund.Where(m => m.UserId == (int)Enumeration.UserAccount.WithdrawFundPool).FirstOrDefault();
                withdrawFundPoolFund.Balance       += calculateWithdrawFee.AmountByAfterFee;
                withdrawFundPoolFund.Mender         = operater;
                withdrawFundPoolFund.LastUpdateTime = this.DateTime;


                var withdrawFundPoolTrans = new Transactions();
                withdrawFundPoolTrans.UserId       = withdrawFundPoolFund.UserId;
                withdrawFundPoolTrans.ChangeAmount = calculateWithdrawFee.AmountByAfterFee;
                withdrawFundPoolTrans.Balance      = withdrawFundPoolFund.Balance;
                withdrawFundPoolTrans.Type         = Enumeration.TransactionsType.TurnsInWithdrawFund;
                withdrawFundPoolTrans.Description  = string.Format("在{0}来自商户({1})的实际提现金额,金额:{2}元", this.DateTime.ToUnifiedFormatDateTime(), clientUser.ClientCode, withdraw.AmountByAfterFee);
                withdrawFundPoolTrans.Creator      = operater;
                withdrawFundPoolTrans.CreateTime   = this.DateTime;
                CurrentDb.Transactions.Add(withdrawFundPoolTrans);
                CurrentDb.SaveChanges();
                withdrawFundPoolTrans.Sn = Sn.Build(SnType.Transactions, withdrawFundPoolTrans.Id);
                CurrentDb.SaveChanges();

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


                ApplyResult applyResult = new ApplyResult();
                applyResult.bankAccount = string.Format("{0} 尾号{1}", bankCard.BankName, CommonUtils.GetBankAccountTail(bankCard.BankAccountNo));
                applyResult.amount      = calculateWithdrawFee.Amount;
                applyResult.fee         = calculateWithdrawFee.Fee;
                applyResult.remark      = "预计1个工作日到账";


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

            return(result);
        }
Beispiel #14
0
        public CustomJsonResult VerifyClaimOrder(int operater, Enumeration.OperateType operate, OrderToCarClaim orderToCarClaim, int estimateMerchantId, string estimateMerchantRemarks, BizProcessesAudit bizProcessesAudit)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                var l_bizProcessesAudit = CurrentDb.BizProcessesAudit.Where(m => m.Id == bizProcessesAudit.CurrentDetails.BizProcessesAuditId && (m.Status == (int)Enumeration.CarInsureOfferDealtStatus.WaitOffer || m.Status == (int)Enumeration.CarInsureOfferDealtStatus.InOffer)).FirstOrDefault();

                if (bizProcessesAudit == null)
                {
                    return(new CustomJsonResult(ResultType.Success, "该订单已经处理完成"));
                }

                if (bizProcessesAudit.Auditor != null)
                {
                    if (bizProcessesAudit.Auditor.Value != operater)
                    {
                        return(new CustomJsonResult(ResultType.Failure, "该订单其他用户正在处理"));
                    }
                }


                var l_orderToCarClaim = CurrentDb.OrderToCarClaim.Where(m => m.Id == orderToCarClaim.Id).FirstOrDefault();
                l_orderToCarClaim.HandMerchantId   = estimateMerchantId;
                l_orderToCarClaim.HandMerchantType = Enumeration.MerchantType.CarRepair;
                l_orderToCarClaim.Remarks          = orderToCarClaim.Remarks;

                bizProcessesAudit.CurrentDetails.AuditComments = orderToCarClaim.Remarks;

                switch (operate)
                {
                case Enumeration.OperateType.Save:

                    result = new CustomJsonResult(ResultType.Success, "保存成功");

                    BizFactory.BizProcessesAudit.ChangeAuditDetails(operate, Enumeration.CarClaimDealtStep.VerifyOrder, bizProcessesAudit.CurrentDetails.BizProcessesAuditId, operater, bizProcessesAudit.CurrentDetails.AuditComments, null);

                    break;

                case Enumeration.OperateType.Cancle:

                    l_orderToCarClaim.Status     = Enumeration.OrderStatus.Cancled;
                    l_orderToCarClaim.CancleTime = this.DateTime;

                    BizFactory.BizProcessesAudit.ChangeAuditDetails(operate, Enumeration.CarClaimDealtStep.VerifyOrder, bizProcessesAudit.CurrentDetails.BizProcessesAuditId, operater, bizProcessesAudit.CurrentDetails.AuditComments, "后台人员撤销订单", this.DateTime);

                    BizFactory.BizProcessesAudit.ChangeCarInsureOfferDealtStatus(operater, bizProcessesAudit.CurrentDetails.BizProcessesAuditId, Enumeration.CarInsureOfferDealtStatus.StaffCancle);

                    result = new CustomJsonResult(ResultType.Success, "撤销成功");

                    break;

                case Enumeration.OperateType.Submit:

                    l_orderToCarClaim.Status = Enumeration.OrderStatus.Follow;

                    l_orderToCarClaim.FollowStatus = (int)Enumeration.OrderToCarClaimFollowStatus.WaitEstimate;


                    var merchant = CurrentDb.Merchant.Where(m => m.Id == l_orderToCarClaim.HandMerchantId).FirstOrDefault();

                    var estimateOrderToCarClaim = new OrderToCarClaim();
                    estimateOrderToCarClaim.RepairsType          = l_orderToCarClaim.RepairsType;
                    estimateOrderToCarClaim.MerchantId           = merchant.Id;
                    estimateOrderToCarClaim.PosMachineId         = l_orderToCarClaim.PosMachineId;
                    estimateOrderToCarClaim.UserId               = merchant.UserId;
                    estimateOrderToCarClaim.HandPerson           = l_orderToCarClaim.HandPerson;
                    estimateOrderToCarClaim.HandPersonPhone      = l_orderToCarClaim.HandPersonPhone;
                    estimateOrderToCarClaim.InsuranceCompanyId   = l_orderToCarClaim.InsuranceCompanyId;
                    estimateOrderToCarClaim.InsuranceCompanyName = l_orderToCarClaim.InsuranceCompanyName;
                    estimateOrderToCarClaim.CarPlateNo           = l_orderToCarClaim.CarPlateNo;
                    estimateOrderToCarClaim.Status               = Enumeration.OrderStatus.Follow;
                    estimateOrderToCarClaim.FollowStatus         = (int)Enumeration.OrderToCarClaimFollowStatus.WaitUploadEstimateList;
                    estimateOrderToCarClaim.SubmitTime           = this.DateTime;
                    estimateOrderToCarClaim.Creator              = operater;
                    estimateOrderToCarClaim.CreateTime           = this.DateTime;

                    estimateOrderToCarClaim.HandMerchantId   = l_orderToCarClaim.MerchantId;
                    estimateOrderToCarClaim.HandMerchantType = Enumeration.MerchantType.CarSales;
                    estimateOrderToCarClaim.Remarks          = estimateMerchantRemarks;//告知维修厂备注


                    estimateOrderToCarClaim.ProductId     = l_orderToCarClaim.ProductId;
                    estimateOrderToCarClaim.ProductName   = l_orderToCarClaim.ProductName;
                    estimateOrderToCarClaim.ProductType   = l_orderToCarClaim.ProductType;
                    estimateOrderToCarClaim.PId           = l_orderToCarClaim.Id;
                    estimateOrderToCarClaim.ClientRequire = l_orderToCarClaim.ClientRequire;
                    CurrentDb.OrderToCarClaim.Add(estimateOrderToCarClaim);
                    estimateOrderToCarClaim.Sn = Sn.Build(SnType.CarClaim, estimateOrderToCarClaim.Id);


                    BizFactory.BizProcessesAudit.ChangeAuditDetails(operate, Enumeration.CarClaimDealtStep.VerifyOrder, bizProcessesAudit.CurrentDetails.BizProcessesAuditId, operater, bizProcessesAudit.CurrentDetails.AuditComments, "后台人员派单完成", this.DateTime);

                    BizFactory.BizProcessesAudit.ChangeCarClaimDealtStatus(operater, bizProcessesAudit.CurrentDetails.BizProcessesAuditId, Enumeration.CarClaimDealtStatus.FllowUploadEstimateListImg, "等待商户上传定损单");

                    result = new CustomJsonResult(ResultType.Success, "提交成功");
                    break;
                }



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

            return(result);
        }
        public CustomJsonResult SubmitCarInsure(int operater, OrderToCarInsure orderToCarInsure, List<OrderToCarInsureOfferCompany> orderToCarInsureOfferCompany, List<OrderToCarInsureOfferKind> orderToCarInsureOfferKind)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                OrderToCarInsure order = new OrderToCarInsure();

                //用户信息
                var clientUser = CurrentDb.SysClientUser.Where(m => m.Id == orderToCarInsure.UserId).FirstOrDefault();
                //商户信息
                var merchant = CurrentDb.Merchant.Where(m => m.Id == clientUser.MerchantId).FirstOrDefault();



                order.MerchantId = merchant.Id;
                order.PosMachineId = orderToCarInsure.PosMachineId;
                order.UserId = merchant.UserId;
                order.SalesmanId = merchant.SalesmanId ?? 0;
                order.AgentId = merchant.AgentId ?? 0;
                order.Type = Enumeration.OrderType.InsureForCarForInsure;
                order.TypeName = Enumeration.OrderType.InsureForCarForInsure.GetCnName();
                order.ClientRequire = orderToCarInsure.ClientRequire;
                order.InsuranceCompanyId = orderToCarInsure.InsuranceCompanyId;
                order.InsuranceCompanyName = orderToCarInsure.InsuranceCompanyName;
                order.CarOwner = orderToCarInsure.CarOwner;
                order.CarOwnerIdNumber = orderToCarInsure.CarOwnerIdNumber;
                order.CarOwnerAddress = orderToCarInsure.CarOwnerAddress;
                order.CarModel = orderToCarInsure.CarModel;
                order.CarOwner = orderToCarInsure.CarOwner;
                order.CarPlateNo = orderToCarInsure.CarPlateNo;
                order.CarEngineNo = orderToCarInsure.CarEngineNo;
                order.CarVin = orderToCarInsure.CarVin;
                order.CarVechicheType = orderToCarInsure.CarVechicheType;
                order.CarRegisterDate = orderToCarInsure.CarRegisterDate;
                order.CarIssueDate = orderToCarInsure.CarIssueDate;
                order.InsurePlanId = orderToCarInsure.InsurePlanId;
                order.CZ_CL_XSZ_ImgUrl = orderToCarInsure.CZ_CL_XSZ_ImgUrl;
                order.CZ_SFZ_ImgUrl = orderToCarInsure.CZ_SFZ_ImgUrl;
                order.YCZ_CLDJZ_ImgUrl = orderToCarInsure.YCZ_CLDJZ_ImgUrl;
                order.CCSJM_WSZM_ImgUrl = orderToCarInsure.CCSJM_WSZM_ImgUrl;
                order.Status = Enumeration.OrderStatus.Submitted;
                order.StartOfferTime = this.DateTime;
                order.SubmitTime = this.DateTime;
                order.CreateTime = this.DateTime;
                order.Creator = operater;
                order.IsLastYearNewCar = orderToCarInsure.IsLastYearNewCar;
                order.IsSameLastYear = orderToCarInsure.IsSameLastYear;
                order.AutoCancelByHour = 24;
                CurrentDb.OrderToCarInsure.Add(order);
                CurrentDb.SaveChanges();

                SnModel snModel = Sn.Build(SnType.OrderToCarInsure, order.Id);

                order.Sn = snModel.Sn;
                order.TradeSnByWechat = snModel.TradeSnByWechat;
                order.TradeSnByAlipay = snModel.TradeSnByAlipay;


                if (orderToCarInsureOfferCompany != null)
                {
                    foreach (var m in orderToCarInsureOfferCompany)
                    {
                        m.OrderId = order.Id;
                        m.CreateTime = this.DateTime;
                        m.Creator = operater;
                        CurrentDb.OrderToCarInsureOfferCompany.Add(m);
                    }
                }

                if (orderToCarInsureOfferKind != null)
                {
                    foreach (var m in orderToCarInsureOfferKind)
                    {
                        m.OrderId = order.Id;
                        m.CreateTime = this.DateTime;
                        m.Creator = operater;
                        CurrentDb.OrderToCarInsureOfferKind.Add(m);
                    }
                }


                BizProcessesAudit bizProcessesAudit = BizFactory.BizProcessesAudit.Add(operater, Enumeration.BizProcessesAuditType.OrderToCarInsure, order.Id, Enumeration.CarInsureOfferDealtStatus.WaitOffer);

                BizFactory.BizProcessesAudit.ChangeAuditDetails(Enumeration.OperateType.Submit, Enumeration.CarInsureOfferDealtStep.Submit, bizProcessesAudit.Id, operater, orderToCarInsure.ClientRequire, "商户提交投保订单,等待报价", this.DateTime);


                order.BizProcessesAuditId = bizProcessesAudit.Id;

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


                result = new CustomJsonResult(ResultType.Success, "提交成功");
            }

            return result;
        }
Beispiel #16
0
        private CustomJsonResult PayCarInsureCompleted(int operater, string orderSn)
        {
            CustomJsonResult result = new CustomJsonResult();

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


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

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

                var commissionRate = CurrentDb.CarInsureCommissionRate.Where(m => (m.Type == Enumeration.CommissionRateType.Uplink && m.ReferenceId == orderToCarInsure.InsuranceCompanyId) || (m.Type == Enumeration.CommissionRateType.YiBanShi && m.ReferenceId == 1) || (m.Type == Enumeration.CommissionRateType.InsuranceCompany && m.ReferenceId == orderToCarInsure.InsuranceCompanyId)).ToList();


                var uplink_CommissionRate = commissionRate.Where(m => m.Type == Enumeration.CommissionRateType.Uplink).FirstOrDefault();


                var uplink_Commission_Commercial = orderToCarInsure.CommercialPrice * (uplink_CommissionRate.Commercial / 100);
                var uplink_Commission_Compulsory = orderToCarInsure.CompulsoryPrice * (uplink_CommissionRate.Compulsory / 100);
                var uplink_Commission            = GetPayDecimal(uplink_Commission_Commercial + uplink_Commission_Compulsory);

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

                uplinkFund.Balance       += uplink_Commission;
                uplinkFund.Mender         = operater;
                uplinkFund.LastUpdateTime = this.DateTime;

                var uplinkFundTrans = new Transactions();
                uplinkFundTrans.UserId       = uplinkFund.UserId;
                uplinkFundTrans.ChangeAmount = uplink_Commission;
                uplinkFundTrans.Balance      = uplinkFund.Balance;
                uplinkFundTrans.Type         = Enumeration.TransactionsType.CarInsureCommission;
                uplinkFundTrans.Description  = string.Format("投保订单佣金收益,交强险:{0}元,商业险:{1}:元,合计:{2}元", uplink_Commission_Compulsory.ToPrice(), uplink_Commission_Commercial.ToPrice(), uplink_Commission.ToPrice());
                uplinkFundTrans.Creator      = operater;
                uplinkFundTrans.CreateTime   = this.DateTime;
                CurrentDb.Transactions.Add(uplinkFundTrans);
                CurrentDb.SaveChanges();
                uplinkFundTrans.Sn = Sn.Build(SnType.Transactions, uplinkFundTrans.Id);
                CurrentDb.SaveChanges();

                var yiBanShi_CommissionRate = commissionRate.Where(m => m.Type == Enumeration.CommissionRateType.YiBanShi).FirstOrDefault();


                var yiBanShi_Commission_Commercial = orderToCarInsure.CommercialPrice * (yiBanShi_CommissionRate.Commercial / 100);
                var yiBanShi_Commission_Compulsory = orderToCarInsure.CompulsoryPrice * (yiBanShi_CommissionRate.Compulsory / 100);
                var yiBanShi_Commission            = GetPayDecimal(yiBanShi_Commission_Commercial + yiBanShi_Commission_Compulsory);

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


                YiBanShiFund.Balance       += uplink_Commission;
                YiBanShiFund.Mender         = operater;
                YiBanShiFund.LastUpdateTime = this.DateTime;

                var YiBanShiFundTrans = new Transactions();
                YiBanShiFundTrans.UserId       = YiBanShiFund.UserId;
                YiBanShiFundTrans.ChangeAmount = yiBanShi_Commission;
                YiBanShiFundTrans.Balance      = YiBanShiFund.Balance;
                YiBanShiFundTrans.Type         = Enumeration.TransactionsType.CarInsureCommission;
                YiBanShiFundTrans.Description  = string.Format("投保订单佣金收益,交强险:{0}元,商业险:{1}:元,合计:{2}元", yiBanShi_Commission_Compulsory.ToPrice(), yiBanShi_Commission_Commercial.ToPrice(), yiBanShi_Commission.ToPrice());
                YiBanShiFundTrans.Creator      = operater;
                YiBanShiFundTrans.CreateTime   = this.DateTime;
                CurrentDb.Transactions.Add(YiBanShiFundTrans);
                CurrentDb.SaveChanges();
                YiBanShiFundTrans.Sn = Sn.Build(SnType.Transactions, YiBanShiFundTrans.Id);
                CurrentDb.SaveChanges();


                var merchant_CommissionRate = commissionRate.Where(m => m.Type == Enumeration.CommissionRateType.InsuranceCompany).FirstOrDefault();


                var merchant_Commission_Commercial = orderToCarInsure.CommercialPrice * (merchant_CommissionRate.Commercial / 100);
                var merchant_Commission_Compulsory = orderToCarInsure.CompulsoryPrice * (merchant_CommissionRate.Compulsory / 100);
                var merchant_Commission            = GetPayDecimal(merchant_Commission_Commercial + merchant_Commission_Compulsory);

                var merchantFund = CurrentDb.Fund.Where(m => m.UserId == orderToCarInsure.UserId).FirstOrDefault();


                merchantFund.Balance       += merchant_Commission;
                merchantFund.Mender         = operater;
                merchantFund.LastUpdateTime = this.DateTime;

                var merchantFundTrans = new Transactions();
                merchantFundTrans.UserId       = merchantFund.UserId;
                merchantFundTrans.ChangeAmount = merchant_Commission;
                merchantFundTrans.Balance      = merchantFund.Balance;
                merchantFundTrans.Type         = Enumeration.TransactionsType.CarInsureCommission;
                merchantFundTrans.Description  = string.Format("投保订单佣金收益,交强险:{0}元,商业险:{1}:元,合计:{2}元", merchant_Commission_Compulsory.ToPrice(), merchant_Commission_Commercial.ToPrice(), merchant_Commission.ToPrice());
                merchantFundTrans.Creator      = operater;
                merchantFundTrans.CreateTime   = this.DateTime;
                CurrentDb.Transactions.Add(merchantFundTrans);
                CurrentDb.SaveChanges();
                merchantFundTrans.Sn = Sn.Build(SnType.Transactions, merchantFundTrans.Id);
                CurrentDb.SaveChanges();

                orderToCarInsure.MerchantCommission = merchant_Commission;
                orderToCarInsure.YiBanShiCommission = yiBanShi_Commission;
                orderToCarInsure.CommissionVersion  = "2017.02.28";
                orderToCarInsure.UplinkCommission   = uplink_Commission;
                orderToCarInsure.Status             = Enumeration.OrderStatus.Completed;
                orderToCarInsure.PayTime            = this.DateTime;
                orderToCarInsure.CompleteTime       = this.DateTime;
                orderToCarInsure.LastUpdateTime     = this.DateTime;
                orderToCarInsure.Mender             = operater;

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

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

            return(result);
        }
Beispiel #17
0
        private CustomJsonResult PayCarClaimCompleted(int operater, string orderSn)
        {
            CustomJsonResult result = new CustomJsonResult();

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


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


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


                CalculateCarClaimPayPrice calculateCarClaimPayPrice = new CalculateCarClaimPayPrice(orderToCarClaim.WorkingHoursPrice, orderToCarClaim.AccessoriesPrice);


                decimal uplink_Commission   = calculateCarClaimPayPrice.UplinkCommission;
                decimal merchant_Commission = calculateCarClaimPayPrice.MerchantCommission;

                var merchant = CurrentDb.Merchant.Where(m => m.Id == orderToCarClaim.HandMerchantId).FirstOrDefault();



                var merchantFund = CurrentDb.Fund.Where(m => m.UserId == merchant.UserId).FirstOrDefault();


                merchantFund.Balance       += merchant_Commission;
                merchantFund.Mender         = operater;
                merchantFund.LastUpdateTime = this.DateTime;

                var merchantFundTrans = new Transactions();
                merchantFundTrans.UserId       = merchantFund.UserId;
                merchantFundTrans.ChangeAmount = merchant_Commission;
                merchantFundTrans.Balance      = merchantFund.Balance;
                merchantFundTrans.Type         = Enumeration.TransactionsType.CarClaimCommission;
                merchantFundTrans.Description  = string.Format("理赔订单佣金收益,理赔总金额:{0}元,应付金额:{1}:元,佣金:{2}元", orderToCarClaim.EstimatePrice.ToF2Price(), orderToCarClaim.Price.ToF2Price(), merchant_Commission.ToF2Price());
                merchantFundTrans.Creator      = operater;
                merchantFundTrans.CreateTime   = this.DateTime;
                CurrentDb.Transactions.Add(merchantFundTrans);
                CurrentDb.SaveChanges();
                merchantFundTrans.Sn = Sn.Build(SnType.Transactions, merchantFundTrans.Id);
                CurrentDb.SaveChanges();



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

                uplinkFund.Balance       += uplink_Commission;
                uplinkFund.Mender         = operater;
                uplinkFund.LastUpdateTime = this.DateTime;

                var uplinkFundTrans = new Transactions();
                uplinkFundTrans.UserId       = uplinkFund.UserId;
                uplinkFundTrans.ChangeAmount = uplink_Commission;
                uplinkFundTrans.Balance      = uplinkFund.Balance;
                uplinkFundTrans.Type         = Enumeration.TransactionsType.CarClaimCommission;
                uplinkFundTrans.Description  = string.Format("理赔订单佣金收益,理赔总金额:{0}元,应付金额:{1}:元,佣金:{2}元", orderToCarClaim.EstimatePrice.ToF2Price(), orderToCarClaim.Price.ToF2Price(), uplink_Commission.ToF2Price());
                uplinkFundTrans.Creator      = operater;
                uplinkFundTrans.CreateTime   = this.DateTime;
                CurrentDb.Transactions.Add(uplinkFundTrans);
                CurrentDb.SaveChanges();
                uplinkFundTrans.Sn = Sn.Build(SnType.Transactions, uplinkFundTrans.Id);
                CurrentDb.SaveChanges();


                orderToCarClaim.Status            = Enumeration.OrderStatus.Completed;
                orderToCarClaim.PayTime           = this.DateTime;
                orderToCarClaim.CompleteTime      = this.DateTime;
                orderToCarClaim.LastUpdateTime    = this.DateTime;
                orderToCarClaim.Mender            = operater;
                orderToCarClaim.CommissionVersion = calculateCarClaimPayPrice.Version;

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

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

            return(result);
        }
Beispiel #18
0
        private CustomJsonResult PayRentCompleted(int operater, string orderSn)
        {
            CustomJsonResult result = new CustomJsonResult();

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


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


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

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

                var UplinkFundTrans = new Transactions();
                UplinkFundTrans.UserId       = UplinkFund.UserId;
                UplinkFundTrans.ChangeAmount = orderToRent.Price;
                UplinkFundTrans.Balance      = UplinkFund.Balance;
                UplinkFundTrans.Type         = Enumeration.TransactionsType.Rent;
                UplinkFundTrans.Description  = string.Format("租金订单:{0}:元", orderToRent.Price.ToPrice());
                UplinkFundTrans.Creator      = operater;
                UplinkFundTrans.CreateTime   = this.DateTime;
                CurrentDb.Transactions.Add(UplinkFundTrans);
                CurrentDb.SaveChanges();
                UplinkFundTrans.Sn = Sn.Build(SnType.Transactions, UplinkFundTrans.Id);
                CurrentDb.SaveChanges();


                var merchantPosMachine = CurrentDb.MerchantPosMachine.Where(m => m.MerchantId == orderToRent.MerchantId && m.PosMachineId == orderToRent.PosMachineId).FirstOrDefault();
                merchantPosMachine.RentDueDate    = orderToRent.RentDueDate;
                merchantPosMachine.Status         = Enumeration.MerchantPosMachineStatus.Normal;
                merchantPosMachine.LastUpdateTime = this.DateTime;
                merchantPosMachine.Mender         = operater;


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


                BizFactory.Merchant.GetRentOrder(orderToRent.MerchantId, orderToRent.PosMachineId);

                CurrentDb.SaveChanges();

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

            return(result);
        }
Beispiel #19
0
        public CustomJsonResult <LllegalQueryResult> Query(int operater, LllegalQueryParams pms)
        {
            CustomJsonResult <LllegalQueryResult> result = new CustomJsonResult <LllegalQueryResult>();

            using (TransactionScope ts = new TransactionScope())
            {
                if (pms.EnginNo.Length < 6)
                {
                    return(new CustomJsonResult <LllegalQueryResult>(ResultType.Failure, ResultCode.Failure, "请输入发动机号后6位", null));
                }

                if (pms.RackNo.Length < 6)
                {
                    return(new CustomJsonResult <LllegalQueryResult>(ResultType.Failure, ResultCode.Failure, "请输入车架号后6位", null));
                }

                var lllegalQueryScore = CurrentDb.LllegalQueryScore.Where(m => m.UserId == pms.UserId && m.MerchantId == pms.MerchantId).FirstOrDefault();

                if (lllegalQueryScore.Score == 0)
                {
                    return(new CustomJsonResult <LllegalQueryResult>(ResultType.Failure, ResultCode.LllegalQueryNotEnoughScore, "当前的查询积分为0,请充值积分", null));
                }

                pms.CarNo   = pms.CarNo.ToUpper();
                pms.EnginNo = pms.EnginNo.ToUpper();
                pms.RackNo  = pms.RackNo.ToUpper();

                List <DataLllegal> dataLllegal = new List <DataLllegal>();


                CarQueryDataList_Params p = new CarQueryDataList_Params();
                p.carNo     = pms.CarNo;
                p.enginNo   = pms.EnginNo;
                p.rackNo    = pms.RackNo;
                p.isCompany = pms.IsCompany;
                p.carType   = pms.CarType;
                var api_result = HeLianApi.CarQueryDataList(p);


                if (api_result.resultCode != "0")
                {
                    return(new CustomJsonResult <LllegalQueryResult>(ResultType.Failure, ResultCode.Failure, api_result.resultMsg, null));
                }

                List <LllegalRecord> lllegalRecords = new List <LllegalRecord>();


                var d = api_result.data;
                if (d != null)
                {
                    foreach (var m in d)
                    {
                        DataLllegal dl = new DataLllegal();
                        dl.bookNo         = m.bookNo;
                        dl.bookType       = m.bookType;
                        dl.cityCode       = m.cityCode;
                        dl.lllegalCode    = m.lllegalCode;
                        dl.lllegalTime    = m.lllegalTime;
                        dl.point          = m.point;
                        dl.fine           = m.fine;
                        dl.lllegalAddress = m.address;
                        dataLllegal.Add(dl);

                        LllegalRecord lllegalRecord = new LllegalRecord();
                        lllegalRecord.bookNo        = m.bookNo;
                        lllegalRecord.bookType      = m.bookType;
                        lllegalRecord.bookTypeName  = GetBookTypeName(m.bookType);
                        lllegalRecord.offerType     = m.offerType;
                        lllegalRecord.ofserTypeName = GetOfferTypeName(m.offerType);
                        lllegalRecord.lllegalDesc   = m.lllegalDesc;
                        lllegalRecord.cityCode      = m.cityCode;
                        lllegalRecord.lllegalCode   = m.lllegalCode;
                        lllegalRecord.lllegalCity   = m.lllegalCity;
                        lllegalRecord.lllegalTime   = m.lllegalTime;
                        lllegalRecord.point         = m.point;

                        lllegalRecord.fine = m.fine;
                        if (lllegalRecord.point == 0)
                        {
                            lllegalRecord.serviceFee = m.serviceFee + 3;//非扣分单
                        }
                        else
                        {
                            lllegalRecord.serviceFee = m.serviceFee;
                        }

                        lllegalRecord.serviceFee = m.serviceFee;
                        lllegalRecord.address    = m.address;
                        lllegalRecord.content    = m.content;
                        lllegalRecord.late_fees  = m.late_fees;

                        lllegalRecords.Add(lllegalRecord);
                    }
                }

                CarQueryGetLllegalPrice_Params p1 = new CarQueryGetLllegalPrice_Params();

                p1.carNo       = pms.CarNo;
                p1.enginNo     = pms.EnginNo;
                p1.rackNo      = pms.RackNo;
                p1.isCompany   = pms.IsCompany;
                p1.carType     = pms.CarType;
                p1.dataLllegal = dataLllegal;

                var queryResult = new LllegalQueryResult();

                queryResult.IsOfferPrice = pms.IsOfferPrice == "true" ? true : false;
                queryResult.CarNo        = pms.CarNo;

                string msg = "";
                if (queryResult.IsOfferPrice)
                {
                    var api_result1 = HeLianApi.CarQueryGetLllegalPrice(p1);

                    if (api_result1.resultCode != "0")
                    {
                        return(new CustomJsonResult <LllegalQueryResult>(ResultType.Failure, ResultCode.Failure, api_result1.resultMsg, null));
                    }

                    msg = api_result1.resultMsg;

                    var d1 = api_result1.data;

                    if (d1 != null)
                    {
                        foreach (var record in lllegalRecords)
                        {
                            var priceresult = d1.Where(m => m.bookNo == record.bookNo).FirstOrDefault();
                            if (priceresult != null)
                            {
                                record.serviceFee = priceresult.serviceFee;
                                record.fine       = priceresult.fine;
                                record.late_fees  = priceresult.fine;
                            }

                            record.status = "待处理";


                            if (record.point == 0)
                            {
                                record.canDealt = true;
                            }
                            else
                            {
                                record.canDealt = false;
                            }

                            var details = CurrentDb.OrderToLllegalDealtDetails.Where(m => m.BookNo == record.bookNo).ToList();
                            if (details != null)
                            {
                                var hasDealt     = details.Where(m => m.Status == Enumeration.OrderToLllegalDealtDetailsStatus.InDealt).Count();
                                var hasCompleted = details.Where(m => m.Status == Enumeration.OrderToLllegalDealtDetailsStatus.Completed).Count();


                                if (hasDealt > 0)
                                {
                                    record.status   = "处理中";
                                    record.canDealt = false;
                                }

                                if (hasCompleted > 0)
                                {
                                    record.status   = "完成";
                                    record.canDealt = false;
                                }
                            }
                        }
                    }
                }

                queryResult.DealtTip = "扣分单需处理,请咨询客服";
                queryResult.SumCount = lllegalRecords.Count().ToString();
                queryResult.SumFine  = lllegalRecords.Sum(m => m.fine).ToString();
                queryResult.SumPoint = lllegalRecords.Sum(m => m.point).ToString();


                var lllegalQueryLog = new LllegalQueryLog();

                lllegalQueryLog.UserId     = pms.UserId;
                lllegalQueryLog.MerchantId = pms.MerchantId;
                lllegalQueryLog.CarNo      = pms.CarNo;
                lllegalQueryLog.EnginNo    = pms.EnginNo;
                lllegalQueryLog.RackNo     = pms.RackNo;
                lllegalQueryLog.IsCompany  = pms.IsCompany;
                lllegalQueryLog.CarType    = pms.CarType;
                lllegalQueryLog.Result     = Newtonsoft.Json.JsonConvert.SerializeObject(lllegalRecords);
                lllegalQueryLog.Creator    = operater;
                lllegalQueryLog.CreateTime = this.DateTime;
                CurrentDb.LllegalQueryLog.Add(lllegalQueryLog);

                var changeScore = -1;
                lllegalQueryScore.Score         += changeScore;
                lllegalQueryScore.Mender         = operater;
                lllegalQueryScore.LastUpdateTime = this.DateTime;

                var lllegalQueryScoreTrans = new LllegalQueryScoreTrans();
                lllegalQueryScoreTrans.UserId      = pms.UserId;
                lllegalQueryScoreTrans.ChangeScore = changeScore;
                lllegalQueryScoreTrans.Score       = lllegalQueryScore.Score;
                lllegalQueryScoreTrans.Type        = Enumeration.LllegalQueryScoreTransType.DecreaseByQuery;
                lllegalQueryScoreTrans.Description = string.Format("查询违章扣除积分:{0}", changeScore);
                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();

                queryResult.QueryScore = lllegalQueryScore.Score;

                queryResult.Record = lllegalRecords;


                result = new CustomJsonResult <LllegalQueryResult>(ResultType.Success, ResultCode.Success, msg, queryResult);
            }

            return(result);
        }
        public CustomJsonResult ReCarInsureOffer(int operater, int userId, int merchantId, int orderId)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                var oldOrder = CurrentDb.OrderToCarInsure.Where(m => m.Id == orderId).FirstOrDefault();

                var newOrder = new OrderToCarInsure();
                newOrder.MerchantId = oldOrder.MerchantId;
                newOrder.PosMachineId = oldOrder.PosMachineId;
                newOrder.UserId = oldOrder.UserId;
         
                //newOrder.ProductName = oldOrder.ProductName;
                //newOrder.ProductType = oldOrder.ProductType;
                newOrder.ClientRequire = oldOrder.ClientRequire;
                newOrder.InsuranceCompanyId = oldOrder.InsuranceCompanyId;
                newOrder.InsuranceCompanyName = oldOrder.InsuranceCompanyName;
                newOrder.CarOwner = oldOrder.CarOwner;
                newOrder.CarOwnerIdNumber = oldOrder.CarOwnerIdNumber;
                newOrder.CarOwnerAddress = oldOrder.CarOwnerAddress;
                newOrder.CarModel = oldOrder.CarModel;
                newOrder.CarModelName = oldOrder.CarModelName;
                newOrder.CarOwner = oldOrder.CarOwner;
                newOrder.CarPlateNo = oldOrder.CarPlateNo;
                newOrder.CarEngineNo = oldOrder.CarEngineNo;
                newOrder.CarVin = oldOrder.CarVin;
                newOrder.CarVechicheType = oldOrder.CarVechicheType;
                newOrder.CarRegisterDate = oldOrder.CarRegisterDate;
                newOrder.CarIssueDate = oldOrder.CarIssueDate;
                newOrder.CarPurchasePrice = oldOrder.CarPurchasePrice;
                newOrder.InsurePlanId = oldOrder.InsurePlanId;
                newOrder.CZ_CL_XSZ_ImgUrl = oldOrder.CZ_CL_XSZ_ImgUrl;
                newOrder.CZ_SFZ_ImgUrl = oldOrder.CZ_SFZ_ImgUrl;
                newOrder.YCZ_CLDJZ_ImgUrl = oldOrder.YCZ_CLDJZ_ImgUrl;
                newOrder.CCSJM_WSZM_ImgUrl = oldOrder.CCSJM_WSZM_ImgUrl;
                newOrder.ZJ1_ImgUrl = oldOrder.ZJ1_ImgUrl;
                newOrder.ZJ2_ImgUrl = oldOrder.ZJ2_ImgUrl;
                newOrder.ZJ3_ImgUrl = oldOrder.ZJ3_ImgUrl;
                newOrder.ZJ4_ImgUrl = oldOrder.ZJ4_ImgUrl;

                newOrder.Status = Enumeration.OrderStatus.Submitted;

                newOrder.SubmitTime = this.DateTime;
                newOrder.CreateTime = this.DateTime;
                newOrder.Creator = operater;
                newOrder.IsLastYearNewCar = oldOrder.IsLastYearNewCar;
                newOrder.IsSameLastYear = oldOrder.IsSameLastYear;
                newOrder.AutoCancelByHour = 24;
                CurrentDb.OrderToCarInsure.Add(newOrder);
                CurrentDb.SaveChanges();

                SnModel snModel = Sn.Build(SnType.OrderToCarInsure, newOrder.Id);

                newOrder.Sn = snModel.Sn;
                newOrder.TradeSnByWechat = snModel.TradeSnByWechat;
                newOrder.TradeSnByAlipay = snModel.TradeSnByAlipay;




                var oldOrderToCarInsureOfferCompany = CurrentDb.OrderToCarInsureOfferCompany.Where(m => m.OrderId == oldOrder.Id).ToList();
                if (oldOrderToCarInsureOfferCompany != null)
                {
                    foreach (var m in oldOrderToCarInsureOfferCompany)
                    {
                        var newOrderToCarInsureOfferCompany = new OrderToCarInsureOfferCompany();

                        newOrderToCarInsureOfferCompany.OrderId = newOrder.Id;
                        newOrderToCarInsureOfferCompany.InsuranceCompanyId = m.InsuranceCompanyId;
                        newOrderToCarInsureOfferCompany.InsuranceCompanyName = m.InsuranceCompanyName;
                        newOrderToCarInsureOfferCompany.CreateTime = this.DateTime;
                        newOrderToCarInsureOfferCompany.Creator = operater;
                        CurrentDb.OrderToCarInsureOfferCompany.Add(newOrderToCarInsureOfferCompany);
                    }
                }


                var oldKinds = CurrentDb.OrderToCarInsureOfferKind.Where(m => m.OrderId == oldOrder.Id).ToList();

                if (oldKinds != null)
                {
                    foreach (var m in oldKinds)
                    {
                        var newKinds = new OrderToCarInsureOfferKind();
                        newKinds.OrderId = newOrder.Id;
                        newKinds.KindId = m.KindId;
                        newKinds.KindValue = m.KindValue;
                        newKinds.KindDetails = m.KindDetails;
                        newKinds.IsWaiverDeductible = m.IsWaiverDeductible;
                        newKinds.CreateTime = this.DateTime;
                        newKinds.Creator = operater;
                        CurrentDb.OrderToCarInsureOfferKind.Add(newKinds);
                    }
                }

                BizProcessesAudit bizProcessesAudit = BizFactory.BizProcessesAudit.Add(operater, Enumeration.BizProcessesAuditType.OrderToCarInsure, newOrder.Id, Enumeration.CarInsureOfferDealtStatus.WaitOffer);

                BizFactory.BizProcessesAudit.ChangeAuditDetails(Enumeration.OperateType.Submit, Enumeration.CarInsureOfferDealtStep.Submit, bizProcessesAudit.Id, operater, newOrder.ClientRequire, "商户重新报价,等待报价", this.DateTime);

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


                result = new CustomJsonResult(ResultType.Success, "重新报价");

            }

            return result;
        }
        public CustomJsonResult SubmitLllegalQueryScoreRecharge(int operater, OrderToLllegalQueryRecharge orderToLllegalQueryRecharge)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                var clientUser = CurrentDb.SysClientUser.Where(m => m.Id == orderToLllegalQueryRecharge.UserId).FirstOrDefault();
                var merchant = CurrentDb.Merchant.Where(m => m.Id == clientUser.MerchantId).FirstOrDefault();
     
                orderToLllegalQueryRecharge.SalesmanId = merchant.SalesmanId ?? 0;
                orderToLllegalQueryRecharge.AgentId = merchant.AgentId ?? 0;

                orderToLllegalQueryRecharge.Type = Enumeration.OrderType.LllegalQueryRecharge;
                orderToLllegalQueryRecharge.TypeName = Enumeration.OrderType.LllegalQueryRecharge.GetCnName();
                orderToLllegalQueryRecharge.Status = Enumeration.OrderStatus.WaitPay;
                orderToLllegalQueryRecharge.SubmitTime = this.DateTime;
                orderToLllegalQueryRecharge.CreateTime = this.DateTime;
                orderToLllegalQueryRecharge.Creator = operater;
                CurrentDb.OrderToLllegalQueryRecharge.Add(orderToLllegalQueryRecharge);
                CurrentDb.SaveChanges();



                SnModel snModel = Sn.Build(SnType.OrderToLllegalQueryRecharge, orderToLllegalQueryRecharge.Id);

                orderToLllegalQueryRecharge.Sn = snModel.Sn;
                orderToLllegalQueryRecharge.TradeSnByWechat = snModel.TradeSnByWechat;
                orderToLllegalQueryRecharge.TradeSnByAlipay = snModel.TradeSnByAlipay;
                CurrentDb.SaveChanges();



                OrderConfirmInfo yOrder = new OrderConfirmInfo();


                yOrder.OrderId = orderToLllegalQueryRecharge.Id;
                yOrder.OrderSn = orderToLllegalQueryRecharge.Sn;
                yOrder.remarks = orderToLllegalQueryRecharge.Remarks;
                yOrder.orderType = orderToLllegalQueryRecharge.Type;
                yOrder.orderTypeName = orderToLllegalQueryRecharge.TypeName;

                // yOrder.confirmField.Add(new Entity.AppApi.OrderField("订单编号", orderToLllegalQueryRecharge.Sn.NullToEmpty()));
                yOrder.confirmField.Add(new Entity.AppApi.OrderField("积分", string.Format("{0}", orderToLllegalQueryRecharge.Score)));
                yOrder.confirmField.Add(new Entity.AppApi.OrderField("支付金额", string.Format("{0}元", orderToLllegalQueryRecharge.Price.NullToEmpty())));


                #region 支持的支付方式
                int[] payMethods = new int[1] { 1 };

                foreach (var payWayId in payMethods)
                {
                    var payWay = new PayWay();
                    payWay.id = payWayId;
                    yOrder.payMethod.Add(payWay);
                }
                #endregion


                ts.Complete();

                result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "提交成功", yOrder);
            }


            return result;
        }
        public CustomJsonResult Feedback(int operater, int cutoffid, List <WithdrawCutOffDetails> updateCutOffDetails)
        {
            CustomJsonResult result = new CustomJsonResult();


            using (TransactionScope ts = new TransactionScope())
            {
                int handingCount = 0;
                int successCount = 0;
                int failureCount = 0;
                foreach (var m in updateCutOffDetails)
                {
                    DateTime dateNow      = DateTime.Now;
                    var      cutOffDetail = CurrentDb.WithdrawCutOffDetails.Where(q => q.WithdrawSn == m.WithdrawSn).FirstOrDefault();
                    if (cutOffDetail != null)
                    {
                        var withdraw = CurrentDb.Withdraw.Where(q => q.Id == cutOffDetail.WithdrawId && q.Status == Enumeration.WithdrawStatus.Handing).FirstOrDefault();
                        if (withdraw != null)
                        {
                            if (m.WithdrawStatus == Enumeration.WithdrawStatus.Handing)
                            {
                                handingCount++;

                                #region 处理中
                                cutOffDetail.WithdrawStatus = Enumeration.WithdrawStatus.Handing;
                                cutOffDetail.LastUpdateTime = dateNow;
                                cutOffDetail.Mender         = operater;

                                withdraw.Status         = Enumeration.WithdrawStatus.Handing;
                                withdraw.LastUpdateTime = dateNow;
                                withdraw.Mender         = operater;
                                #endregion
                            }
                            else if (m.WithdrawStatus == Enumeration.WithdrawStatus.Success)
                            {
                                successCount++;

                                #region 成功

                                var client = CurrentDb.SysClientUser.Find(withdraw.UserId);

                                cutOffDetail.WithdrawSettlementEndTime = dateNow;
                                cutOffDetail.WithdrawStatus            = Enumeration.WithdrawStatus.Success;
                                cutOffDetail.LastUpdateTime            = dateNow;
                                cutOffDetail.Mender = operater;

                                withdraw.SettlementEndTime = dateNow;
                                withdraw.Status            = Enumeration.WithdrawStatus.Success;
                                withdraw.LastUpdateTime    = dateNow;
                                withdraw.Mender            = operater;

                                var withdrawFundPoolFund = CurrentDb.Fund.Where(c => c.UserId == (int)Enumeration.UserAccount.WithdrawFundPool).FirstOrDefault();
                                withdrawFundPoolFund.Balance       -= withdraw.AmountByAfterFee;
                                withdrawFundPoolFund.Mender         = operater;
                                withdrawFundPoolFund.LastUpdateTime = dateNow;


                                var withdrawFundPoolTrans = new Transactions();
                                withdrawFundPoolTrans.UserId       = withdrawFundPoolFund.UserId;
                                withdrawFundPoolTrans.Type         = Enumeration.TransactionsType.TurnsOutWithdrawFund;
                                withdrawFundPoolTrans.ChangeAmount = -withdraw.AmountByAfterFee;
                                withdrawFundPoolTrans.Balance      = withdrawFundPoolFund.Balance;
                                withdrawFundPoolTrans.Description  = string.Format("提现到帐成功,转出提现资金给商户({0}),金额:{1}", client.ClientCode, withdraw.AmountByAfterFee);
                                withdrawFundPoolTrans.Creator      = operater;
                                withdrawFundPoolTrans.CreateTime   = dateNow;
                                CurrentDb.Transactions.Add(withdrawFundPoolTrans);
                                CurrentDb.SaveChanges();
                                withdrawFundPoolTrans.Sn = Sn.Build(SnType.Transactions, withdrawFundPoolTrans.Id);
                                CurrentDb.SaveChanges();



                                var uplinkFund = CurrentDb.Fund.Where(c => c.UserId == (int)Enumeration.UserAccount.Uplink).FirstOrDefault();
                                uplinkFund.Balance       -= withdraw.AmountByAfterFee;
                                uplinkFund.Mender         = operater;
                                uplinkFund.LastUpdateTime = dateNow;


                                var uplinkFundTrans = new Transactions();
                                uplinkFundTrans.UserId       = uplinkFund.UserId;
                                uplinkFundTrans.Type         = Enumeration.TransactionsType.Advance;
                                uplinkFundTrans.ChangeAmount = -withdraw.AmountByAfterFee;
                                uplinkFundTrans.Balance      = uplinkFund.Balance;
                                uplinkFundTrans.Description  = string.Format("商户({0})提现到帐成功,全线通垫付资金,金额:{1}", client.ClientCode, withdraw.AmountByAfterFee);
                                uplinkFundTrans.Creator      = operater;
                                uplinkFundTrans.CreateTime   = dateNow;
                                CurrentDb.Transactions.Add(uplinkFundTrans);
                                CurrentDb.SaveChanges();
                                uplinkFundTrans.Sn = Sn.Build(SnType.Transactions, uplinkFundTrans.Id);
                                CurrentDb.SaveChanges();



                                #endregion
                            }
                            else if (m.WithdrawStatus == Enumeration.WithdrawStatus.Failure)
                            {
                                failureCount++;

                                #region 失败

                                cutOffDetail.WithdrawSettlementEndTime = dateNow;
                                cutOffDetail.WithdrawStatus            = Enumeration.WithdrawStatus.Failure;
                                cutOffDetail.WithdrawFailureReason     = m.WithdrawFailureReason;
                                cutOffDetail.LastUpdateTime            = dateNow;
                                cutOffDetail.Mender = operater;

                                withdraw.SettlementEndTime = dateNow;
                                withdraw.Status            = Enumeration.WithdrawStatus.Failure;
                                withdraw.FailureReason     = m.WithdrawFailureReason;
                                withdraw.LastUpdateTime    = dateNow;
                                withdraw.Mender            = operater;

                                var client = CurrentDb.SysClientUser.Find(withdraw.UserId);

                                var clientStoreFund = CurrentDb.Fund.Where(c => c.UserId == withdraw.UserId).FirstOrDefault();


                                #region 客户虚拟帐户中扣除对应的金额

                                clientStoreFund.Balance += withdraw.Amount;//可用金额

                                CurrentDb.SaveChanges();

                                var clientTrans = new Transactions();
                                clientTrans.UserId       = client.Id;
                                clientTrans.Type         = Enumeration.TransactionsType.WithdrawRefund;
                                clientTrans.ChangeAmount = withdraw.Amount;
                                clientTrans.Balance      = clientStoreFund.Balance;
                                clientTrans.Creator      = operater;
                                clientTrans.CreateTime   = dateNow;
                                CurrentDb.Transactions.Add(clientTrans);
                                CurrentDb.SaveChanges();
                                clientTrans.Sn = Sn.Build(SnType.Transactions, clientTrans.Id);
                                string description = "";
                                clientTrans.Description = description;
                                CurrentDb.SaveChanges();


                                #endregion


                                #region 平台虚拟账户中更改对应的金额


                                if (withdraw.Fee > 0)
                                {
                                    var withdrawFeeStoreFund = CurrentDb.Fund.Where(c => c.UserId == (int)Enumeration.UserAccount.WithdrawFee).FirstOrDefault();
                                    withdrawFeeStoreFund.Balance       -= withdraw.Fee;
                                    withdrawFeeStoreFund.Mender         = operater;
                                    withdrawFeeStoreFund.LastUpdateTime = dateNow;


                                    var withdrawFeeTrans = new Transactions();
                                    withdrawFeeTrans.UserId       = withdrawFeeStoreFund.UserId;
                                    withdrawFeeTrans.Type         = Enumeration.TransactionsType.ReturnFee;
                                    withdrawFeeTrans.ChangeAmount = -withdraw.Fee;
                                    withdrawFeeTrans.Balance      = withdrawFeeStoreFund.Balance;
                                    withdrawFeeTrans.Description  = "";
                                    withdrawFeeTrans.Creator      = operater;
                                    withdrawFeeTrans.CreateTime   = dateNow;
                                    CurrentDb.Transactions.Add(withdrawFeeTrans);
                                    CurrentDb.SaveChanges();
                                    withdrawFeeTrans.Sn = Sn.Build(SnType.Transactions, withdrawFeeTrans.Id);
                                    CurrentDb.SaveChanges();
                                }


                                var withdrawFundPoolStoreFund = CurrentDb.Fund.Where(c => c.UserId == (int)Enumeration.UserAccount.WithdrawFundPool).FirstOrDefault();
                                withdrawFundPoolStoreFund.Balance       -= withdraw.AmountByAfterFee;
                                withdrawFundPoolStoreFund.Mender         = operater;
                                withdrawFundPoolStoreFund.LastUpdateTime = dateNow;


                                var withdrawFundPoolTrans = new Transactions();
                                withdrawFundPoolTrans.UserId       = withdrawFundPoolStoreFund.UserId;
                                withdrawFundPoolTrans.Type         = Enumeration.TransactionsType.ReturnWithdrawFund;
                                withdrawFundPoolTrans.ChangeAmount = -withdraw.AmountByAfterFee;
                                withdrawFundPoolTrans.Balance      = withdrawFundPoolStoreFund.Balance;
                                withdrawFundPoolTrans.Description  = "";
                                withdrawFundPoolTrans.Creator      = operater;
                                withdrawFundPoolTrans.CreateTime   = dateNow;
                                CurrentDb.Transactions.Add(withdrawFundPoolTrans);
                                CurrentDb.SaveChanges();
                                withdrawFundPoolTrans.Sn = Sn.Build(SnType.Transactions, withdrawFundPoolTrans.Id);
                                CurrentDb.SaveChanges();
                                #endregion

                                #endregion
                            }
                        }
                    }
                }

                //操作历史
                // SysFactory.SysOperateHistory.Add(Enumeration.OperateType.WithdrawFeedback, operater, cutoffid, string.Format("提现反馈:处理中({0}),成功({1}),失败:({2})", handingCount, successCount, failureCount));

                CurrentDb.SaveChanges();

                ts.Complete();


                result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "截单反馈成功");
            }

            return(result);
        }