Example #1
0
        public CustomJsonResult VerifyClaimAmount(int operater, Enumeration.OperateType operate, OrderToCarClaim orderToCarClaim, 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.WorkingHoursPrice = orderToCarClaim.WorkingHoursPrice;
                l_orderToCarClaim.AccessoriesPrice  = orderToCarClaim.AccessoriesPrice;
                l_orderToCarClaim.EstimatePrice     = orderToCarClaim.WorkingHoursPrice + orderToCarClaim.AccessoriesPrice;
                l_orderToCarClaim.Remarks           = orderToCarClaim.Remarks;


                //bizProcessesAudit.CurrentDetails.AuditComments = orderToCarClaim.Remarks;
                var estimateOrderToCarClaim = CurrentDb.OrderToCarClaim.Where(m => m.PId == orderToCarClaim.Id).FirstOrDefault();
                switch (operate)
                {
                case Enumeration.OperateType.Save:

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

                    BizFactory.BizProcessesAudit.ChangeAuditDetailsAuditComments(operater, bizProcessesAudit.CurrentDetails.BizProcessesAuditId, bizProcessesAudit.CurrentDetails.AuditComments, null);

                    break;

                case Enumeration.OperateType.Cancle:

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

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

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

                    BizFactory.BizProcessesAudit.ChangeCarClaimDealtStatus(operater, bizProcessesAudit.CurrentDetails.BizProcessesAuditId, Enumeration.CarClaimDealtStatus.StaffCancle);

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

                    break;

                case Enumeration.OperateType.Submit:


                    estimateOrderToCarClaim.WorkingHoursPrice = l_orderToCarClaim.WorkingHoursPrice;
                    estimateOrderToCarClaim.AccessoriesPrice  = l_orderToCarClaim.AccessoriesPrice;


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

                    estimateOrderToCarClaim.EstimatePrice = l_orderToCarClaim.EstimatePrice;
                    estimateOrderToCarClaim.Remarks       = orderToCarClaim.Remarks;


                    if (l_orderToCarClaim.RepairsType == Enumeration.RepairsType.EstimateRepair)
                    {
                        l_orderToCarClaim.Status       = Enumeration.OrderStatus.Follow;
                        l_orderToCarClaim.FollowStatus = (int)Enumeration.OrderToCarClaimFollowStatus.WaitPayCommission;
                        l_orderToCarClaim.Price        = 0;


                        estimateOrderToCarClaim.Status       = Enumeration.OrderStatus.WaitPay;
                        estimateOrderToCarClaim.FollowStatus = (int)Enumeration.OrderToCarClaimFollowStatus.WaitPayCommission;
                        estimateOrderToCarClaim.Price        = calculateCarClaimPayPrice.PayPrice;//应付金额
                    }
                    else if (l_orderToCarClaim.RepairsType == Enumeration.RepairsType.Estimate)
                    {
                        l_orderToCarClaim.Status       = Enumeration.OrderStatus.WaitPay;
                        l_orderToCarClaim.FollowStatus = (int)Enumeration.OrderToCarClaimFollowStatus.WaitPayCommission;
                        l_orderToCarClaim.Price        = calculateCarClaimPayPrice.PayPrice;//应付金额

                        estimateOrderToCarClaim.Status       = Enumeration.OrderStatus.Follow;
                        estimateOrderToCarClaim.FollowStatus = (int)Enumeration.OrderToCarClaimFollowStatus.WaitPayCommission;
                        estimateOrderToCarClaim.Price        = 0;
                    }

                    BizFactory.BizProcessesAudit.ChangeAuditDetails(operate, Enumeration.CarClaimDealtStep.VerifyAmount, bizProcessesAudit.CurrentDetails.BizProcessesAuditId, operater, bizProcessesAudit.CurrentDetails.AuditComments, "复核金额完成,提交给商户支付", this.DateTime);

                    BizFactory.BizProcessesAudit.ChangeCarClaimDealtStatus(operater, bizProcessesAudit.CurrentDetails.BizProcessesAuditId, Enumeration.CarClaimDealtStatus.Complete, "复核金额完成,提交给商户支付");


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



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

            return(result);
        }
Example #2
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);
        }