Пример #1
0
 public void AddPrepaymentRequest(Prepayment prepayment)
 {
     using (var context = new scrumprojectEntities())
     {
         context.Prepayments.Add(prepayment);
     }
 }
Пример #2
0
        public void AddPrepaymentRequest(AdvancePayments advancePayment)
        {
            var prepay = new Prepayment
            {
                PID         = advancePayment.PrepaidId,
                UID         = advancePayment.UserId,
                Amount      = advancePayment.Amount,
                Description = advancePayment.Description,
                Status      = null
            };

            advancePaymentsRepository.AddPrepaymentRequest(prepay);
        }
        public static void Update(Prepayment prepayment)
        {
            var connection = DatabaseConnection.Connection;

            using (var command = connection.CreateCommand())
            {
                const string sql = "update T_Prepayment set Prepayment_Warranty_Date = @date where Prepayment_Id = @id";
                command.CommandText = sql;
                command.Parameters.AddWithValue("@id", prepayment.Id);
                command.Parameters.AddWithValue("@date", prepayment.WarrantyDate);
                Logger.LogQuery($"{sql}\r\n{prepayment}");
                command.ExecuteNonQuery();
                connection.Close();
            }
        }
        public static void Insert(Prepayment prepayment)
        {
            var connection = DatabaseConnection.Connection;

            using (var command = connection.CreateCommand())
            {
                const string sql = "insert into T_Prepayment(Prepayment_Id,Prepayment_Warranty_Date) values(@id,@date)";
                command.CommandText = sql;
                command.Parameters.AddWithValue("@id", prepayment.Id);
                command.Parameters.AddWithValue("@date", prepayment.WarrantyDate);
                Logger.LogQuery($"execute sql = {sql}\r\n{prepayment}");
                command.ExecuteNonQuery();
                connection.Close();
            }
        }
Пример #5
0
        public void OnEnable()
        {
            MsgRepo = new MsgRepo();

            title = "支付测试";

            _prepayment                = new Prepayment();
            _prepayment.name           = "TestPrepayment";
            _prepayment.display_name   = "测试支付包";
            _prepayment.description    = "充值即可获得大礼哦";
            _prepayment.currency_type  = CurrencyType.GOLDEN_EGG;
            _prepayment.currency_count = 20000;
            _prepayment.price          = 6;
            _prepayment.pay_channel.Add(PayChannelType.IOS_IAP);
            _prepayment.pay_channel.Add(PayChannelType.ALIPAY_IOS);
            _prepayment.pay_channel.Add(PayChannelType.ALIPAY_CLIENT);

            _trade              = new Trade();
            _trade.pay_channel  = PayChannelType.ALIPAY_IOS;
            _trade.out_trade_no = "KSLDHGKL21934";
        }
        public static Prepayment SelectById(string prepaymentId)
        {
            var connection = DatabaseConnection.Connection;

            using (var command = connection.CreateCommand())
            {
                const string sql = "select * from T_Prepayment where Prepayment_Id = @id";
                command.CommandText = sql;
                command.Parameters.AddWithValue("@id", prepaymentId);
                Logger.LogQuery($"execute sql = {sql}\r\n id = {prepaymentId}");
                Prepayment prepayment = null;
                using (var reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        prepayment = new Prepayment(prepaymentId);
                        //date
                        if (connection.State == ConnectionState.Closed)
                        {
                            connection.Open();
                        }
                        var date = reader["Prepayment_Warranty_Date"].ToString();
                        try
                        {
                            prepayment.WarrantyDate = DateConverter.StringToPersianDate(date);
                        }
                        catch (Exception e)
                        {
                            Logger.LogException(e);
                        }
                    }
                    else
                    {
                        throw new ItemNotFoundException("prepayment", "id", prepaymentId);
                    }
                }
                connection.Close();
                return(prepayment);
            }
        }
Пример #7
0
        /// <summary>
        /// 计算支付包等值的金蛋数量。
        /// </summary>
        /// <returns></returns>
        public static long CalculateGeValue(Prepayment prepayment)
        {
            if (prepayment == null)
            {
                return(0);
            }

            var geCount = 0L;
            var ypCount = 0L;

            if (prepayment.currency_type == CurrencyType.GOLDEN_EGG)
            {
                geCount += prepayment.currency_count;
            }
            else if (prepayment.currency_type == CurrencyType.YIN_PIAO)
            {
                ypCount += prepayment.currency_count;
            }

            var extraPack = prepayment.extra_pack;

            if (extraPack != null && extraPack.Count > 0)
            {
                for (int i = 0; i < extraPack.Count; i++)
                {
                    var cur = extraPack[i];
                    if (cur.type == CurrencyType.GOLDEN_EGG)
                    {
                        geCount += cur.count;
                    }
                    else if (cur.type == CurrencyType.YIN_PIAO)
                    {
                        ypCount += cur.count;
                    }
                }
            }

            return(geCount + ypCount * 100);
        }
Пример #8
0
        public void ApplyData(string reason, Prepayment prepayment)
        {
            _reason = reason;
            _data   = prepayment;

            if (prepayment == null)
            {
                return;
            }

            if (PayContent)
            {
                if (!PayContent.gameObject.activeSelf)
                {
                    PayContent.gameObject.SetActive(true);
                }

                var content = !string.IsNullOrEmpty(prepayment.display_name)
                    ? "购买:" + prepayment.display_name
                    : "";

                PayContent.text = content;
            }

            if (PayPrice)
            {
                if (!PayPrice.gameObject.activeSelf)
                {
                    PayPrice.gameObject.SetActive(true);
                }

                PayPrice.text = "价格:¥ " + prepayment.price;
            }

            if (Description)
            {
                if (!string.IsNullOrEmpty(prepayment.description))
                {
                    if (!Description.gameObject.activeSelf)
                    {
                        Description.gameObject.SetActive(true);
                    }

                    Description.text = prepayment.description;
                }
                else
                {
                    if (Description.gameObject.activeSelf)
                    {
                        Description.gameObject.SetActive(false);
                    }
                }
            }

            AnalyticPanelShow();

            // 不再在客户端对支付渠道进行过滤。
            var channelList = prepayment.pay_channel;

            // 因为releaseConfig本身就是针对各个不同渠道特殊性而设计的。
            // 所以也应该是根据特殊的情况来进行过滤。

            var featureSwitch = _featureSwitch.Read();
            var extraCharge   = featureSwitch != null && featureSwitch.extra_charge;

#if UNITY_IOS
            if (featureSwitch == null || !extraCharge)
            {
                if (channelList != null && channelList.Count > 0)
                {
                    for (int i = 0; i < channelList.Count; i++)
                    {
                        if (channelList[i] != PayChannelType.IOS_IAP)
                        {
                            channelList.RemoveAt(i);
                            i--;
                        }
                    }
                }
            }
#endif

#if UNITY_ANDROID
            var configHolder = GetConfigHolder();
            if (configHolder.XiaoMiMode && !extraCharge)
            {
                if (channelList != null && channelList.Count > 0)
                {
                    for (int i = 0; i < channelList.Count; i++)
                    {
                        if (channelList[i] != PayChannelType.XIAOMI)
                        {
                            channelList.RemoveAt(i);
                            i--;
                        }
                    }
                }
            }
#endif

            if (channelList == null || channelList.Count <= 0)
            {
                // 数据错误,关闭支付列表,显示一个错误的提示。
                EnableComponent(false, false, true);
                SetStateTxt("数据发生错误,无法支付!\n请联系下方客服QQ解决");
            }
            else if (channelList.Count <= 1)
            {
                // 如果只有一种支付方式则直接开始支付。
                StartPay(channelList[0]);
            }
            else
            {
                // 多于一种支付方式,则显示支付列表。
                EnableComponent(true, false, false);
                if (PayChannelList)
                {
                    PayChannelList.ApplyData(channelList);
                }
            }
        }