Пример #1
0
        public Setting QuerySetting(Common.Enums.PlatformType platform)
        {
            Setting setting = null;
            string  sql     = @"SELECT [Deduct],[Provider],[RebateBalance],setting.[Enabled],[PayInterface],employee.[login] FROM [dbo].[T_Setting] setting                           INNER JOIN dbo.T_Company company ON setting.Provider = company.Id
                           INNER JOIN dbo.T_Employee employee ON employee.IsAdministrator = 1 AND employee.[Owner] = company.Id 
WHERE [Platform]=@Platform";

            using (var dbOperator = new DbOperator(Provider, ConnectionString))
            {
                dbOperator.AddParameter("Platform", (byte)platform);
                using (var reader = dbOperator.ExecuteReader(sql))
                {
                    while (reader.Read())
                    {
                        setting = new Setting()
                        {
                            Platform        = platform,
                            Deduct          = reader.GetDecimal(0),
                            Provider        = reader.GetGuid(1),
                            RebateBalance   = reader.GetDecimal(2),
                            Enabled         = reader.GetBoolean(3),
                            ProviderAccount = reader.GetString(5)
                        };
                        var strPayInterface = reader.GetString(4);
                        var list            = new List <ChinaPay.B3B.DataTransferObject.Common.PayInterface>();
                        foreach (var item in strPayInterface.Split('|'))
                        {
                            list.Add((DataTransferObject.Common.PayInterface) int.Parse(item));
                        }
                        setting.PayInterface = list.ToArray();
                    }
                }
            }
            return(setting);
        }
Пример #2
0
 public static PlatformBase GetPlatform(Common.Enums.PlatformType platform) {
     if(platform == Yeexing.Platform.Instance.PlatformInfo) {
         return Yeexing.Platform.Instance;
     } else if(platform == _517Na.Platform.Instance.PlatformInfo) {
         return _517Na.Platform.Instance;
     }
     throw new CustomException("不支持的外接平台");
 }
Пример #3
0
        public int UpdateStatus(Common.Enums.PlatformType platform, bool enabled)
        {
            string sql = "UPDATE [dbo].[T_Setting] SET [Enabled]= @Enabled WHERE Platform = @Platform";

            using (var dbOperator = new DbOperator(Provider, ConnectionString))
            {
                dbOperator.AddParameter("Enabled", enabled);
                dbOperator.AddParameter("Platform", platform);
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
Пример #4
0
        /// <summary>
        /// 修改外平台的设置状态
        /// </summary>
        /// <param name="platform">外平台</param>
        /// <param name="enabled">状态</param>
        public static void UpdateStatus(Common.Enums.PlatformType platform, bool enabled, string account)
        {
            var reposity = Factory.CreateSettingReposity();

            reposity.UpdateStatus(platform, enabled);
            saveUpdateLog("外接口政策设置",
                          string.Format("平台:{0},状态", !enabled?"启用":"禁用"),
                          string.Format("平台:{0},状态", enabled ? "启用" : "禁用"),
                          platform.GetDescription(),
                          account);
        }
Пример #5
0
        /// <summary>
        /// 取消订单
        /// </summary>
        public static RequestResult <bool> Cancel(Common.Enums.PlatformType platformType, decimal orderId, string externalOrderId, IEnumerable <string> passengers, string reason)
        {
            if (string.IsNullOrWhiteSpace(externalOrderId))
            {
                throw new ArgumentNullException("externalOrderId");
            }
            if (string.IsNullOrWhiteSpace(reason))
            {
                throw new ArgumentNullException("reason");
            }

            var processor = createOrderProcessor(platformType);

            return(processor.Cancel(orderId, externalOrderId, passengers, reason));
        }
Пример #6
0
        /// <summary>
        /// 自动支付
        /// </summary>
        private static RequestResult <AutoPayResult> Pay(Common.Enums.PlatformType platformType, decimal orderId, string externalOrderId, decimal amount, IEnumerable <PayInterface> payInterfaces)
        {
            if (string.IsNullOrWhiteSpace(externalOrderId))
            {
                throw new ArgumentNullException("externalOrderId");
            }
            LogService.SaveTextLog("自动支付方式:" + payInterfaces.Join(",", p => p.ToString()));
            RequestResult <AutoPayResult> result = null;
            var processor = createOrderProcessor(platformType);

            foreach (var payInterface in payInterfaces)
            {
                result = processor.AutoPay(orderId, externalOrderId, payInterface, amount);
                if (result.Success && result.Result.Success)
                {
                    break;
                }
            }
            return(result);
        }
Пример #7
0
        /// <summary>
        /// 获取手动支付地址
        /// </summary>
        public static RequestResult <string> GetPayUrl(Common.Enums.PlatformType platformType, decimal orderId, string externalOrderId, PayInterface payInterface, decimal amount)
        {
            if (string.IsNullOrWhiteSpace(externalOrderId))
            {
                throw new ArgumentNullException("externalOrderId");
            }

            var platform = Processor.PlatformBase.GetPlatform(platformType);

            if (platform.SuportManualPay())
            {
                var processor = platform.GetOrderProcessor();
                return(processor.ManualPay(orderId, externalOrderId, payInterface, amount));
            }
            else
            {
                return(new RequestResult <string> {
                    Success = false,
                    ErrMessage = "不支持手动支付,请到" + platform.PlatformInfo.GetDescription() + "平台进行支付"
                });
            }
        }
Пример #8
0
 /// <summary>
 /// 自动支付
 /// </summary>
 public static RequestResult <AutoPayResult> Pay(Common.Enums.PlatformType platformType, decimal orderId, string externalOrderId, decimal amount, PayInterface payInterface)
 {
     return(Pay(platformType, orderId, externalOrderId, amount, new[] { payInterface }));
 }
Пример #9
0
        /// <summary>
        /// 自动支付
        /// </summary>
        public static RequestResult <AutoPayResult> Pay(Common.Enums.PlatformType platformType, decimal orderId, string externalOrderId, decimal amount)
        {
            var platform = Processor.PlatformBase.GetPlatform(platformType);

            return(Pay(platformType, orderId, externalOrderId, amount, platform.Setting.PayInterface));
        }
Пример #10
0
        private static Processor.IOrderProcessor createOrderProcessor(Common.Enums.PlatformType platformType)
        {
            var platform = Processor.PlatformBase.GetPlatform(platformType);

            return(platform.GetOrderProcessor());
        }
Пример #11
0
        /// <summary>
        /// 查询票号信息
        /// </summary>
        public static RequestResult <TicketInfo> QueryTicketNo(Common.Enums.PlatformType platformType, decimal orderId, string externalOrderId)
        {
            var processor = createOrderProcessor(platformType);

            return(processor.QueryTicketNo(orderId, externalOrderId));
        }
Пример #12
0
        /// <summary>
        /// 查询外平台的设置信息
        /// </summary>
        public static Setting QuerySetting(Common.Enums.PlatformType platform)
        {
            var repository = Factory.CreateSettingReposity();

            return(repository.QuerySetting(platform));
        }