Esempio n. 1
0
        /// <summary>
        /// 创建GPU订单
        /// </summary>
        /// <returns></returns>
        private FuncResult <GpuOrder> CreateGpuOrder(IUser user, string order_no, decimal amount, PayType PayType)
        {
            string subject   = string.Concat(_arg.OrderType, "升级");
            var    currency  = new Currency(CurrencyType.RMB, amount);
            string notifyUrl = AppConfig.GpuNotifyReceiveUrl;
            var    gpuPay    = new GpuQuickPaymentProvider(user, subject, order_no, currency, (GpuPayType)PayType, TransferReason.升级VIP, notifyUrl);

            gpuPay.SetPrivateValue(AppConfig.VIPORDER_PRIVATE_VALUE);
            GpuOrder order = gpuPay.CreateOrder();

            if (order == null)
            {
                return(FuncResult.FailResult <GpuOrder>(gpuPay.PromptInfo.CustomMessage));
            }
            return(FuncResult.SuccessResult(order));
        }
Esempio n. 2
0
        public bool CreateOrder()
        {
            if (!xUtils.IsCashPayment(this._payType))
            {
                Alert("不支持的支付方式");
                return(false);
            }
            var   fac  = UserModuleFactory.GetUserModuleInstance();
            IUser user = fac?.GetUserByID(this._userId);

            if (user == null)
            {
                Alert("用户账号数据有误");
                return(false);
            }
            string subject = string.Concat(this._rechargeType.ToString(), "充值");

            BeginTransaction();
            Tnet_Recharge daRecharge = new Tnet_Recharge();

            daRecharge.ReferenceTransactionFrom(Transaction);
            daRecharge.Amount        = this._amount;
            daRecharge.Pay_Status    = (int)OrderStatus.等待支付;
            daRecharge.Pay_Type      = (int)this._payType;
            daRecharge.Recharge_Type = (int)this._rechargeType;
            daRecharge.User_Id       = this._userId;
            daRecharge.Subject       = subject;
            string orderNo;

            if (!daRecharge.Insert("R", out orderNo))
            {
                Rollback();
                Alert("创建订单失败");
                return(false);
            }

            Currency currency = new Currency(CurrencyType.RMB, this._amount);
            GpuQuickPaymentProvider provider = new GpuQuickPaymentProvider(user, subject, orderNo, currency, (GpuPayType)this._payType, TransferReason.充值金币, _notifyUrl);

            provider.SetPrivateValue(AppConfig.RECHARGE_PRIVATE_VALUE);
            GpuOrder order = provider.CreateOrder();

            if (order == null)
            {
                Rollback();
                Alert(provider.PromptInfo);
                return(false);
            }
            daRecharge.Voucher = order.Voucher;
            if (!daRecharge.Update())
            {
                Rollback();
                Alert("保存订单凭证失败");
                return(false);
            }
            Commit();
            this.Voucher = order.Voucher;
            this.Amount  = this._amount;
            this.OrderNo = orderNo;
            this.PayUrl  = order.PayUrl;
            return(true);
        }