Exemplo n.º 1
0
        /// <summary>
        /// 数据加密密
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="model"></param>
        /// <returns>RequestBaseModel</returns>
        public PayRequestBaseModel apiResult <T>(T model, string Path, string Pwd, string MerchantId, string UserKey) where T : RequestBase, new()
        {
            PayRequestBaseModel baseModel = new PayRequestBaseModel();

            string certAdd = @"" + Path;

            model.UserKey        = UserKey;
            baseModel.MerchantId = MerchantId;

            string certPwd = Pwd;

            model.Ip        = "127.0.0.1";
            model.Mac       = "F4-6D-04-35-B5-A1";
            model.TimesTamp = DateTime.Now.ToString("yyyy-MM-dd HH:ss:dd");

            string jsonData = JsonConvert.SerializeObject(model);

            model.Sign = Encrpty.MD5Encrypt(jsonData + model.UserKey);

            string aesKey = Cryptor.GenerateAESKey();
            string d      = Encrpty.AESEecrypt(JsonConvert.SerializeObject(model), aesKey);

            aesKey               = Encrpty.RSAEcrypt(aesKey, certAdd);
            baseModel.Data       = d;
            baseModel.EncryptKey = aesKey;

            return(baseModel);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 调用保理订单支付返现
        /// </summary>
        /// <param name="payRemony">数据实体</param>
        /// <param name="BaoLiServiceUrl">保理接口地址</param>
        /// <param name="Path">证书路径</param>
        /// <param name="Pwd">密码</param>
        /// <param name="MerchantId">商户编号</param>
        /// <param name="UserKey">key值</param>
        /// <param name="respons">返回支付返现信息</param>
        /// <returns>接口返回信息</returns>
        public ResponsePayAPIMessage BaoLiOrderPayMoney(PayRemoneyImportModel payRemony, UserAccount userAccount, string BaoLiServiceUrl, string Path, string Pwd, string MerchantId, string UserKey, ref ResponsePayModel respons)
        {
            respons = new ResponsePayModel();
            ResponsePayAPIMessage result = new ResponsePayAPIMessage();

            try {
                #region 乘机人信息
                TravelPassenger pmodel = new TravelPassenger();
                pmodel.PassengerName     = payRemony.person.PersonName;
                pmodel.PassengerType     = payRemony.person.PersonType;
                pmodel.CertificateNumber = payRemony.person.IdNumber;
                pmodel.CertificateType   = payRemony.person.CardType;
                pmodel.Birthday          = payRemony.person.BrithDay.ToString("yyyy-MM-dd");
                pmodel.AirTicketNo       = payRemony.person.TicketId;
                #endregion

                #region 航段
                Voyage vmodel = new Voyage();

                vmodel.Departure     = payRemony.DepartCode;
                vmodel.Arrival       = payRemony.ArriveCode;
                vmodel.DepartureTime = payRemony.DepartureTime.ToString();
                vmodel.ArrivalTime   = payRemony.ArriveTime.ToString();
                vmodel.Bunk          = payRemony.Cabin;
                vmodel.Airline       = payRemony.AirCompanyCode;
                vmodel.FlightNo      = payRemony.FlightNo;

                #endregion

                var item = new RequestBaoLiPayAPIModel {
                    PayUserName  = payRemony.PayAccount,
                    IsRemoney    = payRemony.IsRemoney.ToString(),
                    UserName     = payRemony.RemoneyAccount,
                    OrderId      = payRemony.PlateCode,
                    MerchantCode = payRemony.CompanyCode,
                    StartDate    = payRemony.StartDate.ToString("yyyy-MM-dd"),
                    TicketTime   = payRemony.TicketTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    NotifyUrl    = payRemony.CallBackUrl,
                    ReturnUrl    = payRemony.TimelyUrl,
                    Rebate       = Convert.ToInt32(payRemony.Rebate),
                    RetMoney     = Convert.ToInt32(payRemony.SomeRebate),
                    Pnr          = payRemony.PNR,
                    OrderPrice   = payRemony.OrderPrice.ToString("#0.00"),
                    TicketPrice  = payRemony.TicketPrice.ToString("#0.00"),
                    AirPortTax   = Convert.ToInt32(payRemony.AirFee),
                    FuelTax      = Convert.ToInt32(payRemony.FuelFee),
                    Passenger    = pmodel,
                    Voyage       = vmodel,
                    TimesTamp    = payRemony.TimesTamp,
                    Ip           = payRemony.Ip,
                    Mac          = payRemony.Mac,
                    UserKey      = payRemony.UserKey,
                    EnterpriseID = Convert.ToInt32(payRemony.EnterpriseID),
                    IsValid      = true
                };

                PayRequestBaseModel baseModel = apiResult <RequestBaoLiPayAPIModel>(item, Path, Pwd, MerchantId, UserKey);
                string url      = BaoLiServiceUrl + "api/Travel/Pay";
                var    jsonData = JsonConvert.SerializeObject(baseModel);
                //var post = HttpRequest.HttpRequestUtility.SendPostRequestCore(url, jsonData, "UTF-8", null);
                var post = apiPost(url, jsonData);
                result = JsonConvert.DeserializeObject <ResponsePayAPIMessage>(post);
                if (result.Status == 100)
                {
                    var _EnterpriseOrder = new EnterpriseOrder()
                    {
                        OrderId          = item.OrderId,
                        UserInterestRate = userAccount.FactoringInterestRate,
                        UserInterest     = decimal.Parse(item.TicketPrice) * userAccount.FactoringInterestRate
                    };
                    enterpriseOrderRep.UpdateEnterpriseOrderBackState(_EnterpriseOrder);
                }
                if (!string.IsNullOrEmpty(result.Result))
                {
                    respons = JsonConvert.DeserializeObject <ResponsePayModel>(result.Result);
                }
                return(result);
            }
            catch (Exception ex) {
                LoggerFactory.Instance.Logger_Error(ex, "ReviewTravelOrderError");
                return(result);
            }
        }