예제 #1
0
        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);
        }
예제 #2
0
        public CustomJsonResult Confirm(int operater, PayConfirmModel model)
        {
            CustomJsonResult result = new CustomJsonResult();

            using (TransactionScope ts = new TransactionScope())
            {
                YiBanShiPayOrder   yOrder             = new YiBanShiPayOrder();
                YiBanShiOrderInfo  yOrderInfo         = new YiBanShiOrderInfo();
                MerchantPosMachine merchantPosMachine = null;
                CalculateRent      calculateRent      = null;
                YbsMerchantModel   ybs_mer            = null;
                switch (model.ProductType)
                {
                case Enumeration.ProductType.InsureForCarForInsure:
                case Enumeration.ProductType.InsureForCarForRenewal:

                    #region  投保和续保
                    var orderToCarInsure = CurrentDb.OrderToCarInsure.Where(m => m.Sn == model.OrderSn).FirstOrDefault();

                    var payCarInsureConfirmParams = Newtonsoft.Json.JsonConvert.DeserializeObject <PayCarInsureConfirmParams>(model.Params.ToString());


                    var orderToCarInsureOfferCompany = CurrentDb.OrderToCarInsureOfferCompany.Where(m => m.Id == payCarInsureConfirmParams.OfferId).FirstOrDefault();

                    orderToCarInsure.InsuranceCompanyId   = orderToCarInsureOfferCompany.InsuranceCompanyId;
                    orderToCarInsure.InsureImgUrl         = orderToCarInsureOfferCompany.InsureImgUrl;
                    orderToCarInsure.InsuranceCompanyName = orderToCarInsureOfferCompany.InsuranceCompanyName;
                    orderToCarInsure.InsuranceOrderId     = orderToCarInsureOfferCompany.InsuranceOrderId;
                    orderToCarInsure.CommercialPrice      = orderToCarInsureOfferCompany.CommercialPrice == null ? 0 : orderToCarInsureOfferCompany.CommercialPrice.Value;
                    orderToCarInsure.TravelTaxPrice       = orderToCarInsureOfferCompany.TravelTaxPrice == null ? 0 : orderToCarInsureOfferCompany.TravelTaxPrice.Value;
                    orderToCarInsure.CompulsoryPrice      = orderToCarInsureOfferCompany.CompulsoryPrice == null ? 0 : orderToCarInsureOfferCompany.CompulsoryPrice.Value;

                    orderToCarInsure.ShippingAddress = payCarInsureConfirmParams.ShippingAddress;
                    orderToCarInsure.Price           = orderToCarInsureOfferCompany.InsureTotalPrice.Value;

                    CurrentDb.SaveChanges();

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


                    yOrder.prodcut   = orderToCarInsure.ProductName;
                    yOrder.transName = "消费";
                    yOrder.amount    = orderToCarInsure.Price.ToF2Price().Replace(".", "").PadLeft(12, '0');

                    yOrder.confirmField.Add(new OrderField("订单编号", orderToCarInsure.Sn.NullToEmpty()));
                    yOrder.confirmField.Add(new OrderField("保险公司", orderToCarInsure.InsuranceCompanyName.NullToEmpty()));
                    yOrder.confirmField.Add(new OrderField("车主姓名", orderToCarInsure.CarOwner.NullToEmpty()));
                    yOrder.confirmField.Add(new OrderField("车牌号码", orderToCarInsure.CarPlateNo.NullToEmpty()));
                    yOrder.confirmField.Add(new OrderField("支付金额", string.Format("{0}元", orderToCarInsure.Price.ToF2Price())));


                    yOrderInfo.order_no           = orderToCarInsure.Sn.NullToEmpty();
                    yOrderInfo.insurance_company  = orderToCarInsure.InsuranceCompanyName.NullToEmpty();
                    yOrderInfo.insurance_type     = "";
                    yOrderInfo.customer_id_type   = "01";
                    yOrderInfo.customer_id        = orderToCarInsure.CarOwnerIdNumber.NullToEmpty();
                    yOrderInfo.customer_sex       = "";
                    yOrderInfo.customer_name      = orderToCarInsure.CarOwner.NullToEmpty();
                    yOrderInfo.customer_mobile_no = "";
                    yOrderInfo.customer_birthdate = "";
                    yOrderInfo.insurance_order_no = orderToCarInsure.InsuranceOrderId.NullToEmpty();
                    yOrderInfo.car_type           = orderToCarInsure.CarVechicheType.NullToEmpty();
                    yOrderInfo.car_license        = orderToCarInsure.CarPlateNo.NullToEmpty();
                    yOrderInfo.car_frame_no       = "";
                    yOrderInfo.payer_id_type      = "";
                    yOrderInfo.payer_id           = "";
                    yOrderInfo.payer_name         = "";
                    yOrderInfo.payer_mobile_no    = "";
                    yOrderInfo.payer_address      = "";


                    ybs_mer = BizFactory.Ybs.GetCarInsureMerchantInfo(insuranceCompany.Id, insuranceCompany.YBS_MerchantId, insuranceCompany.YBS_MerchantCode);

                    yOrderInfo.ybs_mer_code = ybs_mer.ybs_mer_code;
                    yOrderInfo.merchant_id  = ybs_mer.merchant_id;

                    yOrderInfo.merchant_name = "";
                    yOrderInfo.phone_no      = "";
                    yOrderInfo.cashier_id    = "";
                    yOrderInfo.teller_id     = "45567";//暂定

                    yOrder.orderInfo = yOrderInfo;


                    result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "确认成功", yOrder);
                    #endregion

                    break;

                case Enumeration.ProductType.InsureForCarForClaim:

                    #region 理赔
                    var orderToCarClaim = CurrentDb.OrderToCarClaim.Where(m => m.Sn == model.OrderSn).FirstOrDefault();


                    yOrder.prodcut   = orderToCarClaim.ProductName;
                    yOrder.transName = "消费";

                    yOrder.amount = orderToCarClaim.Price.ToF2Price().Replace(".", "").PadLeft(12, '0');

                    yOrder.confirmField.Add(new OrderField("订单编号", orderToCarClaim.Sn.NullToEmpty()));
                    yOrder.confirmField.Add(new OrderField("保险公司", orderToCarClaim.InsuranceCompanyName));
                    yOrder.confirmField.Add(new OrderField("车牌号码", orderToCarClaim.CarPlateNo));
                    yOrder.confirmField.Add(new OrderField("支付金额", string.Format("{0}元", orderToCarClaim.Price.NullToEmpty())));


                    yOrderInfo.order_no           = orderToCarClaim.Sn;
                    yOrderInfo.customer_id_type   = "";
                    yOrderInfo.customer_id        = "";
                    yOrderInfo.customer_sex       = "";
                    yOrderInfo.customer_name      = "";
                    yOrderInfo.customer_mobile_no = "";
                    yOrderInfo.customer_birthdate = "";
                    yOrderInfo.payer_id_type      = "";
                    yOrderInfo.payer_id           = "";
                    yOrderInfo.payer_name         = "";
                    yOrderInfo.payer_mobile_no    = "";
                    yOrderInfo.payer_address      = "";



                    ybs_mer = BizFactory.Ybs.GetCarClaimMerchantInfo();
                    yOrderInfo.ybs_mer_code = ybs_mer.ybs_mer_code;
                    yOrderInfo.merchant_id  = ybs_mer.merchant_id;



                    yOrderInfo.merchant_name = "";
                    yOrderInfo.phone_no      = "";
                    yOrderInfo.cashier_id    = "";
                    yOrderInfo.teller_id     = "";

                    yOrder.orderInfo = yOrderInfo;

                    result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "确认成功", yOrder);
                    #endregion

                    break;

                case Enumeration.ProductType.PosMachineDepositRent:

                    #region 押金租金


                    var payDepositRentParams = Newtonsoft.Json.JsonConvert.DeserializeObject <PayDepositRentConfirmParams>(model.Params.ToString());

                    var orderToDepositRent = CurrentDb.OrderToDepositRent.Where(m => m.Sn == model.OrderSn).FirstOrDefault();

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

                    calculateRent = new CalculateRent(merchantPosMachine.Rent);

                    orderToDepositRent.MonthlyRent = calculateRent.MonthlyRent;
                    orderToDepositRent.RentMonths  = payDepositRentParams.RentMonths;
                    orderToDepositRent.RentTotal   = calculateRent.GetRent(payDepositRentParams.RentMonths);
                    orderToDepositRent.RentVersion = calculateRent.Version;


                    orderToDepositRent.Price       = orderToDepositRent.Deposit + orderToDepositRent.RentTotal;
                    orderToDepositRent.RentDueDate = this.DateTime.AddMonths(payDepositRentParams.RentMonths);

                    yOrder.prodcut   = orderToDepositRent.ProductName;
                    yOrder.transName = "消费";
                    yOrder.amount    = orderToDepositRent.Price.ToF2Price().Replace(".", "").PadLeft(12, '0');

                    yOrder.confirmField.Add(new OrderField("订单编号", orderToDepositRent.Sn.NullToEmpty()));
                    yOrder.confirmField.Add(new OrderField("押金", string.Format("{0}元", orderToDepositRent.Deposit.ToF2Price())));
                    yOrder.confirmField.Add(new OrderField("租金", string.Format("{0}元", orderToDepositRent.RentTotal.ToF2Price())));
                    yOrder.confirmField.Add(new OrderField("到期时间", orderToDepositRent.RentDueDate.ToUnifiedFormatDate()));
                    yOrder.confirmField.Add(new OrderField("支付金额", string.Format("{0}元", orderToDepositRent.Price.NullToEmpty())));


                    yOrderInfo.order_no           = orderToDepositRent.Sn;
                    yOrderInfo.customer_id_type   = "";
                    yOrderInfo.customer_id        = "";
                    yOrderInfo.customer_sex       = "";
                    yOrderInfo.customer_name      = "";
                    yOrderInfo.customer_mobile_no = "";
                    yOrderInfo.customer_birthdate = "";
                    yOrderInfo.payer_id_type      = "";
                    yOrderInfo.payer_id           = "";
                    yOrderInfo.payer_name         = "";
                    yOrderInfo.payer_mobile_no    = "";
                    yOrderInfo.payer_address      = "";

                    ybs_mer = BizFactory.Ybs.GetDepositRentMerchantInfo();
                    yOrderInfo.ybs_mer_code = ybs_mer.ybs_mer_code;
                    yOrderInfo.merchant_id  = ybs_mer.merchant_id;


                    yOrderInfo.merchant_name = "";
                    yOrderInfo.phone_no      = "";
                    yOrderInfo.cashier_id    = "";
                    yOrderInfo.teller_id     = "";

                    yOrder.orderInfo = yOrderInfo;

                    result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "确认成功", yOrder);
                    #endregion

                    break;

                case Enumeration.ProductType.PosMachineRent:

                    #region 租金

                    var orderToRent = CurrentDb.OrderToDepositRent.Where(m => m.Sn == model.OrderSn).FirstOrDefault();

                    var payRentParams = Newtonsoft.Json.JsonConvert.DeserializeObject <PayDepositRentConfirmParams>(model.Params.ToString());

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

                    calculateRent = new CalculateRent(merchantPosMachine.Rent);

                    orderToRent.MonthlyRent = calculateRent.MonthlyRent;
                    orderToRent.RentMonths  = payRentParams.RentMonths;
                    orderToRent.RentTotal   = calculateRent.GetRent(payRentParams.RentMonths);
                    orderToRent.RentVersion = calculateRent.Version;
                    orderToRent.Price       = orderToRent.Deposit + orderToRent.RentTotal;
                    orderToRent.RentDueDate = merchantPosMachine.RentDueDate.Value.AddMonths(payRentParams.RentMonths);

                    yOrderInfo.order_no = orderToRent.Sn;
                    yOrder.transName    = "消费";
                    yOrder.amount       = orderToRent.Price.ToF2Price().Replace(".", "").PadLeft(12, '0');

                    yOrder.confirmField.Add(new OrderField("订单编号", orderToRent.Sn.NullToEmpty()));
                    yOrder.confirmField.Add(new OrderField("租金", string.Format("{0}元", orderToRent.RentTotal.ToF2Price())));
                    yOrder.confirmField.Add(new OrderField("续期", string.Format("{0}个月", payRentParams.RentMonths)));
                    yOrder.confirmField.Add(new OrderField("到期时间", orderToRent.RentDueDate.ToUnifiedFormatDate()));
                    yOrder.confirmField.Add(new OrderField("支付金额", string.Format("{0}元", orderToRent.Price.NullToEmpty())));


                    yOrderInfo.order_no           = orderToRent.Sn;
                    yOrderInfo.customer_id_type   = "";
                    yOrderInfo.customer_id        = "";
                    yOrderInfo.customer_sex       = "";
                    yOrderInfo.customer_name      = "";
                    yOrderInfo.customer_mobile_no = "";
                    yOrderInfo.customer_birthdate = "";
                    yOrderInfo.payer_id_type      = "";
                    yOrderInfo.payer_id           = "";
                    yOrderInfo.payer_name         = "";
                    yOrderInfo.payer_mobile_no    = "";
                    yOrderInfo.payer_address      = "";

                    ybs_mer = BizFactory.Ybs.GetDepositRentMerchantInfo();
                    yOrderInfo.ybs_mer_code = ybs_mer.ybs_mer_code;
                    yOrderInfo.merchant_id  = ybs_mer.merchant_id;


                    yOrderInfo.merchant_name = "";
                    yOrderInfo.phone_no      = "";
                    yOrderInfo.cashier_id    = "";
                    yOrderInfo.teller_id     = "";

                    yOrder.orderInfo = yOrderInfo;

                    result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "确认成功", yOrder);
                    #endregion

                    break;
                }

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

            return(result);
        }