public void UpdateChargeDetail(ChargeDetailInfo model)
 {
     //var oldmodel = Context.ChargeDetailInfo.FirstOrDefault(e => e.Id == model.Id);
     var oldmodel = DbFactory.Default.Get <ChargeDetailInfo>().Where(e => e.Id == model.Id).FirstOrDefault();
     //using (TransactionScope scope = new TransactionScope())
     //{
     var flag = DbFactory.Default.InTransaction(() =>
     {
         //oldmodel.ChargeStatus = model.ChargeStatus;
         //oldmodel.ChargeTime = model.ChargeTime.Value;
         //oldmodel.ChargeWay = model.ChargeWay;
         //Context.SaveChanges();
         DbFactory.Default.Set <ChargeDetailInfo>().Set(n => n.ChargeStatus, model.ChargeStatus)
         .Set(n => n.ChargeTime, model.ChargeTime.Value).Set(n => n.ChargeWay, model.ChargeWay).Where(e => e.Id == oldmodel.Id).Succeed();
         CapitalDetailModel capitalDetail = new CapitalDetailModel
         {
             Amount        = oldmodel.ChargeAmount,
             UserId        = oldmodel.MemId,
             PayWay        = model.ChargeWay,
             SourceType    = CapitalDetailInfo.CapitalDetailType.ChargeAmount,
             SourceData    = oldmodel.Id.ToString(),
             PresentAmount = oldmodel.PresentAmount
         };
         AddCapital(capitalDetail);
         //scope.Complete();
         return(true);
     });
 }
Exemple #2
0
        public ActionResult PayReturn_Charge(string id)
        {
            string empty = string.Empty;

            try
            {
                id = DecodePaymentId(id);
                Plugin <IPaymentPlugin> plugin = PluginsManagement.GetPlugin <IPaymentPlugin>(id);
                if (plugin != null)
                {
                    PaymentInfo           paymentInfo          = plugin.Biz.ProcessReturn(base.Request);
                    IMemberCapitalService memberCapitalService = ServiceHelper.Create <IMemberCapitalService>();
                    ChargeDetailInfo      chargeDetail         = memberCapitalService.GetChargeDetail(paymentInfo.OrderIds.FirstOrDefault());
                    if (chargeDetail != null && chargeDetail.ChargeStatus != ChargeDetailInfo.ChargeDetailStatus.ChargeSuccess)
                    {
                        chargeDetail.ChargeWay    = plugin.PluginInfo.DisplayName;
                        chargeDetail.ChargeStatus = ChargeDetailInfo.ChargeDetailStatus.ChargeSuccess;
                        chargeDetail.ChargeTime   = new DateTime?((paymentInfo.TradeTime.HasValue ? paymentInfo.TradeTime.Value : DateTime.Now));
                        memberCapitalService.UpdateChargeDetail(chargeDetail);
                        plugin.Biz.ConfirmPayResult();
                        string str = CacheKeyCollection.PaymentState(chargeDetail.Id.ToString());
                        Cache.Insert(str, true, 15);
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Error(string.Concat("预付款充值回调出错:", exception.Message));
            }
            return(View());
        }
 public long AddChargeApply(ChargeDetailInfo model)
 {
     if (model.Id == 0)
     {
         model.Id = CreateCode(CapitalDetailInfo.CapitalDetailType.ChargeAmount);
     }
     Context.ChargeDetailInfo.Add(model);
     Context.SaveChanges();
     return(model.Id);
 }
        public JsonResult ChargeSubmit(decimal amount)
        {
            ChargeDetailInfo chargeDetailInfo = new ChargeDetailInfo()
            {
                ChargeAmount = amount,
                ChargeStatus = ChargeDetailInfo.ChargeDetailStatus.WaitPay,
                CreateTime   = new DateTime?(DateTime.Now),
                MemId        = base.CurrentSellerManager.Id
            };
            long num = ServiceHelper.Create <IMemberCapitalService>().AddChargeApply(chargeDetailInfo);

            return(Json(new { success = true, msg = num.ToString() }));
        }
        public void UpdateChareeOrderStatu(long orderId)
        {
            ChargeDetailInfo nullable = context.ChargeDetailInfo.FirstOrDefault((ChargeDetailInfo m) => m.Id == orderId);

            if (nullable == null)
            {
                return;
            }
            nullable.ChargeStatus = ChemCloud.Model.ChargeDetailInfo.ChargeDetailStatus.ChargeSuccess;
            nullable.CreateTime   = DateTime.Now;
            nullable.ChargeTime   = DateTime.Now;
            context.SaveChanges();
        }
Exemple #6
0
        public JsonResult ChargeSubmit(decimal amount)
        {
            //var ids = _iMemberCapitalService.CreateCode(CapitalDetailInfo.CapitalDetailType.ChargeAmount);
            ChargeDetailInfo detail = new ChargeDetailInfo()
            {
                ChargeAmount = amount,
                ChargeStatus = ChargeDetailInfo.ChargeDetailStatus.WaitPay,
                CreateTime   = DateTime.Now,
                MemId        = CurrentUser.Id
            };
            long id = _iMemberCapitalService.AddChargeApply(detail);

            return(Json(new { success = true, msg = id.ToString() }));
        }
        public void UpdateChargeDetail(ChargeDetailInfo model)
        {
            ChargeDetailInfo chargeStatus = context.ChargeDetailInfo.FirstOrDefault((ChargeDetailInfo e) => e.Id == model.Id);

            using (TransactionScope transactionScope = new TransactionScope())
            {
                chargeStatus.ChargeStatus = model.ChargeStatus;
                chargeStatus.ChargeTime   = new DateTime?(model.ChargeTime.Value);
                chargeStatus.ChargeWay    = model.ChargeWay;
                context.SaveChanges();
                CapitalDetailModel capitalDetailModel = new CapitalDetailModel()
                {
                    Amount     = chargeStatus.ChargeAmount,
                    UserId     = chargeStatus.MemId,
                    PayWay     = model.ChargeWay,
                    SourceType = CapitalDetailInfo.CapitalDetailType.ChargeAmount,
                    SourceData = chargeStatus.Id.ToString()
                };
                AddCapital(capitalDetailModel);
                transactionScope.Complete();
            }
        }
        public void CheckChargeAsync(string orderIds)
        {
            base.AsyncManager.OutstandingOperations.Increment();
            int num1 = 200;
            int num2 = 10000;

            Task.Factory.StartNew(() => {
                string str = CacheKeyCollection.PaymentState(orderIds);
                int num    = 0;
                while (true)
                {
                    if (Cache.Get(str) == null)
                    {
                        using (IMemberCapitalService create = Instance <IMemberCapitalService> .Create)
                        {
                            ChargeDetailInfo chargeDetail = create.GetChargeDetail(long.Parse(orderIds));
                            Cache.Insert(str, (chargeDetail == null ? false : chargeDetail.ChargeStatus == ChargeDetailInfo.ChargeDetailStatus.ChargeSuccess), 15);
                        }
                    }
                    if ((bool)Cache.Get(str))
                    {
                        AsyncManager.Parameters["done"] = true;
                        break;
                    }
                    else if (num <= num2)
                    {
                        num = num + num1;
                        Thread.Sleep(num1);
                    }
                    else
                    {
                        AsyncManager.Parameters["done"] = false;
                        break;
                    }
                }
                AsyncManager.OutstandingOperations.Decrement();
            });
        }
        public void UpdateChargeDetail(ChargeDetailInfo model)
        {
            var oldmodel = Context.ChargeDetailInfo.FirstOrDefault(e => e.Id == model.Id);

            using (TransactionScope scope = new TransactionScope())
            {
                oldmodel.ChargeStatus = model.ChargeStatus;
                oldmodel.ChargeTime   = model.ChargeTime.Value;
                oldmodel.ChargeWay    = model.ChargeWay;
                Context.SaveChanges();
                CapitalDetailModel capitalDetail = new CapitalDetailModel
                {
                    Amount     = oldmodel.ChargeAmount,
                    UserId     = oldmodel.MemId,
                    PayWay     = model.ChargeWay,
                    SourceType = CapitalDetailInfo.CapitalDetailType.ChargeAmount,
                    SourceData = oldmodel.Id.ToString()
                };

                AddCapital(capitalDetail);
                scope.Complete();
            }
        }
Exemple #10
0
 public ActionResult CapitalChargeReturn(string orderIds)
 {
     try
     {
         IMemberCapitalService memberCapitalService = ServiceHelper.Create <IMemberCapitalService>();
         ChargeDetailInfo      chargeDetail         = memberCapitalService.GetChargeDetail(long.Parse(orderIds));
         if (chargeDetail != null && chargeDetail.ChargeStatus != ChargeDetailInfo.ChargeDetailStatus.ChargeSuccess)
         {
             chargeDetail.ChargeWay    = "PayPal";
             chargeDetail.ChargeStatus = ChargeDetailInfo.ChargeDetailStatus.ChargeSuccess;
             chargeDetail.ChargeTime   = DateTime.Now;
             memberCapitalService.UpdateChargeDetail(chargeDetail);
             //plugin.Biz.ConfirmPayResult();
             string str = CacheKeyCollection.PaymentState(chargeDetail.Id.ToString());
             Cache.Insert(str, true, 15);
         }
     }
     catch (Exception exception)
     {
         Log.Error(string.Concat("Recharge Failed:", exception.Message));
     }
     return(View());
 }
        public ActionResult ChargePay(string orderIds)
        {
            string str;

            if (string.IsNullOrEmpty(orderIds))
            {
                return(RedirectToAction("/SellerAdmin"));
            }
            IMemberCapitalService memberCapitalService = ServiceHelper.Create <IMemberCapitalService>();
            ChargeDetailInfo      chargeDetail         = memberCapitalService.GetChargeDetail(long.Parse(orderIds));

            if (chargeDetail == null || chargeDetail.MemId != base.CurrentSellerManager.Id || chargeDetail.ChargeStatus == ChargeDetailInfo.ChargeDetailStatus.ChargeSuccess)
            {
                Log.Error(string.Concat("未找到充值申请记录:", orderIds));
                return(RedirectToAction("SticsMoneyList"));
            }
            SiteSettingsInfo siteSettings = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings();

            ViewBag.Logo   = siteSettings.Logo;
            ViewBag.Orders = chargeDetail;
            string scheme = base.Request.Url.Scheme;
            string host   = base.HttpContext.Request.Url.Host;

            if (base.HttpContext.Request.Url.Port == 80)
            {
                str = "";
            }
            else
            {
                int port = base.HttpContext.Request.Url.Port;
                str = string.Concat(":", port.ToString());
            }
            string str1 = string.Concat(scheme, "://", host, str);
            string str2 = string.Concat(str1, "/Pay/CapitalChargeReturn/{0}");
            string str3 = string.Concat(str1, "/Pay/CapitalChargeNotify/{0}");
            IEnumerable <Plugin <IPaymentPlugin> > plugins =
                from item in PluginsManagement.GetPlugins <IPaymentPlugin>(true)
                where item.Biz.SupportPlatforms.Contains <PlatformType>(PlatformType.PC)
                select item;
            IEnumerable <PaymentModel> paymentModels = plugins.Select <Plugin <IPaymentPlugin>, PaymentModel>((Plugin <IPaymentPlugin> item) =>
            {
                string empty = string.Empty;
                try
                {
                    empty = item.Biz.GetRequestUrl(string.Format(str2, EncodePaymentId(item.PluginInfo.PluginId)), string.Format(str3, EncodePaymentId(item.PluginInfo.PluginId)), orderIds, chargeDetail.ChargeAmount, "预付款充值", null);
                }
                catch (Exception exception)
                {
                    Log.Error("支付页面加载支付插件出错", exception);
                }
                return(new PaymentModel()
                {
                    Logo = string.Concat("/Plugins/Payment/", item.PluginInfo.ClassFullName.Split(new char[] { ',' })[1], "/", item.Biz.Logo),
                    RequestUrl = empty,
                    UrlType = item.Biz.RequestUrlType,
                    Id = item.PluginInfo.PluginId
                });
            });

            paymentModels =
                from item in paymentModels
                where !string.IsNullOrEmpty(item.RequestUrl)
                select item;

            ViewBag.OrderIds      = orderIds;
            ViewBag.TotalAmount   = chargeDetail.ChargeAmount;
            ViewBag.Step          = 1;
            ViewBag.UnpaidTimeout = siteSettings.UnpaidTimeout;
            return(View());
        }
 public static void UpdateChargeDetail(ChargeDetailInfo model)
 {
     _iMemberCapitalService.UpdateChargeDetail(model);
 }
 public static void UpdateChargeDetail(ChargeDetailInfo model)
 {
     Service.UpdateChargeDetail(model);
 }