Ejemplo n.º 1
0
        /// <summary>
        /// 店铺创建支付
        /// </summary>
        /// <param name="shopId">店铺ID</param>
        /// <param name="balance">支付金额</param>
        /// <param name="webRoot">站点URL</param>
        /// <returns></returns>
        public static ChargePayModel PaymentList(long shopId, decimal balance, string webRoot)
        {
            ChargeDetailShopInfo model = new ChargeDetailShopInfo()
            {
                ChargeAmount = balance,
                ChargeStatus = Himall.Model.ChargeDetailInfo.ChargeDetailStatus.WaitPay,
                CreateTime   = DateTime.Now,
                ShopId       = shopId
            };
            long orderIds = _iMemberCapitalService.AddChargeDetailShop(model);

            ChargePayModel viewmodel = new ChargePayModel();

            //获取同步返回地址
            string returnUrl = webRoot + "/SellerAdmin/Pay/CapitalChargeReturn/{0}";

            //获取异步通知地址
            string payNotify = webRoot + "/SellerAdmin/Pay/CapitalChargeNotify/{0}";

            var payments = Core.PluginsManagement.GetPlugins <IPaymentPlugin>(true).Where(item => item.Biz.SupportPlatforms.Contains(PlatformType.PC));

            const string RELATEIVE_PATH = "/Plugins/Payment/";

            var models = payments.Select(item =>
            {
                string requestUrl = string.Empty;
                try
                {
                    requestUrl = item.Biz.GetRequestUrl(string.Format(returnUrl, EncodePaymentId(item.PluginInfo.PluginId)), string.Format(payNotify, EncodePaymentId(item.PluginInfo.PluginId)), orderIds.ToString(), model.ChargeAmount, "预付款充值");
                }
                catch (Exception ex)
                {
                    Core.Log.Error("支付页面加载支付插件出错", ex);
                }
                return(new PaymentModel()
                {
                    Logo = RELATEIVE_PATH + item.PluginInfo.ClassFullName.Split(',')[1] + "/" + item.Biz.Logo,
                    RequestUrl = requestUrl,
                    UrlType = item.Biz.RequestUrlType,
                    Id = item.PluginInfo.PluginId
                });
            });

            models                  = models.Where(item => !string.IsNullOrEmpty(item.RequestUrl) && item.Id != "Himall.Plugin.Payment.WeiXinPay" && item.Id != "Himall.Plugin.Payment.WeiXinPay_Native");//只选择正常加载的插件
            viewmodel.OrderIds      = orderIds.ToString();
            viewmodel.TotalAmount   = model.ChargeAmount;
            viewmodel.Step          = 1;
            viewmodel.UnpaidTimeout = _iSiteSettingService.GetSiteSettings().UnpaidTimeout;
            viewmodel.models        = models.ToList();
            return(viewmodel);
        }
 /// <summary>
 /// 添加诊所充值流水
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static long AddChargeDetailShop(ChargeDetailShopInfo model)
 {
     return(_iMemberCapitalService.AddChargeDetailShop(model));
 }