예제 #1
0
        /// <summary>
        /// 根据会员ID发送短信
        /// </summary>
        /// <param name="userIds"></param>
        /// <param name="sendCon"></param>
        public static void SendMsgByUserIds(long[] userIds, string sendCon)
        {
            var messagePlugin = PluginsManagement.GetPlugin <IMessagePlugin>("Himall.Plugin.Message.SMS");

            var members = _iMemberService.GetMembers(userIds);

            string[]      dests  = members.Select(e => e.CellPhone).ToArray();
            List <string> phones = new List <string>();

            foreach (var dest in dests)
            {
                if (messagePlugin.Biz.CheckDestination(dest))
                {
                    phones.Add(dest);
                }
            }
            if (phones.Count == 0)
            {
                throw new HimallException("可发送的对象未空!");
            }
            var siteName = SiteSettingApplication.GetSiteSettings().SiteName;

            sendCon = sendCon + "【" + siteName + "】";
            //【TODO使用队列】
            foreach (var phone in phones)
            {
                messagePlugin.Biz.SendTestMessage(phone, sendCon);
            }

            var sendRecord = new Himall.Model.SendMessageRecordInfo
            {
                ContentType = Himall.CommonModel.WXMsgType.text,
                MessageType = Himall.CommonModel.MsgType.SMS,
                SendContent = sendCon == null ? "" : sendCon,
                SendState   = 1,
                SendTime    = DateTime.Now,
                ToUserLabel = "会员分组"
            };

            WXMsgTemplateApplication.AddSendRecord(sendRecord);
        }
예제 #2
0
        public ActionResult editwxtm()
        {
            var messagePlugins = PluginsManagement.GetPlugins <IMessagePlugin>();
            var data           = messagePlugins.Select(item =>
            {
                dynamic model  = new ExpandoObject();
                model.name     = item.PluginInfo.DisplayName;
                model.pluginId = item.PluginInfo.PluginId;
                model.enable   = item.PluginInfo.Enable;
                model.status   = item.Biz.GetAllStatus();
                return(model);
            }
                                                       );

            ViewBag.messagePlugins = data;

            List <Entities.WeiXinMsgTemplateInfo> wxtempllist = new List <Entities.WeiXinMsgTemplateInfo>();

            wxtempllist = _iWXMsgTemplateService.GetWeiXinMsgTemplateList().Where(e => e.UserInWxApplet == CommonModel.WXMsgTemplateType.WeiXinShop).ToList();
            return(View(wxtempllist));
        }
예제 #3
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseCookiePolicy();
            PluginsManagement.RegistAtStart();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
예제 #4
0
        public IEnumerable <IExpress> GetAllExpress()
        {
            IEnumerable <PluginInfo> installedPluginInfos = PluginsManagement.GetInstalledPluginInfos(PluginType.Express);

            IExpress[] expressArray = new IExpress[installedPluginInfos.Count()];
            int        num          = 0;

            foreach (PluginInfo installedPluginInfo in installedPluginInfos)
            {
                string   classFullName = installedPluginInfo.ClassFullName;
                char[]   chrArray      = new char[] { ',' };
                string   str           = classFullName.Split(chrArray)[1];
                IExpress express       = Instance.Get <IExpress>(installedPluginInfo.ClassFullName);
                express.Logo            = string.Concat("/Plugins/Express/", str, "/", express.Logo);
                express.BackGroundImage = string.Concat("/Plugins/Express/", str, "/", express.BackGroundImage);
                int num1 = num;
                num = num1 + 1;
                expressArray[num1] = express;
            }
            return(expressArray);
        }
        public ActionResult EditWXMessage()
        {
            var messagePlugins = PluginsManagement.GetPlugins <IMessagePlugin>();
            var data           = messagePlugins.Select(item =>
            {
                dynamic model  = new ExpandoObject();
                model.name     = item.PluginInfo.DisplayName;
                model.pluginId = item.PluginInfo.PluginId;
                model.enable   = item.PluginInfo.Enable;
                model.status   = item.Biz.GetAllStatus();
                return(model);
            }
                                                       );

            ViewBag.messagePlugins = data;

            List <WeiXinMsgTemplateInfo> wxtempllist = new List <WeiXinMsgTemplateInfo>();

            wxtempllist = _iWXMsgTemplateService.GetWeiXinMsgTemplateListByApplet();
            return(View(wxtempllist));
        }
예제 #6
0
        //找回密码第二步
        public ActionResult Step2(string key)
        {
            var s = Core.Cache.Get <UserMemberInfo>(key);

            if (s == null)
            {
                return(RedirectToAction("Error", "FindPassWord"));
            }
            var messagePlugins = PluginsManagement.GetPlugins <IMessagePlugin>();
            var data           = messagePlugins.Select(item => new PluginsInfo
            {
                ShortName       = item.Biz.ShortName,
                PluginId        = item.PluginInfo.PluginId,
                Enable          = item.PluginInfo.Enable,
                IsSettingsValid = item.Biz.IsSettingsValid,
                IsBind          = !string.IsNullOrEmpty(_iMessageService.GetDestination(s.Id, item.PluginInfo.PluginId, Himall.Model.MemberContactsInfo.UserTypes.General))
            });

            ViewBag.BindContactInfo = data;
            ViewBag.Key             = key;
            return(View(s));
        }
예제 #7
0
        public JsonResult Enable(string pluginId, MessageTypeEnum messageType, bool enable)
        {
            if (pluginId == wxtmppluginsid)
            {
                _iWXMsgTemplateService.UpdateWeiXinMsgOpenState(messageType, enable);
                return(Json(new { success = true }));
            }
            else
            {
                var messagePlugin = PluginsManagement.GetPlugin <IMessagePlugin>(pluginId);

                if (enable)
                {
                    messagePlugin.Biz.Enable(messageType);
                }
                else
                {
                    messagePlugin.Biz.Disable(messageType);
                }
                return(Json(new { success = true }));
            }
        }
예제 #8
0
        public ActionResult QRPay(string url, string id)
        {
            ViewBag.Logo = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings().Logo;
            Plugin <IPaymentPlugin> plugin = PluginsManagement.GetPlugin <IPaymentPlugin>(id);

            ViewBag.Title = string.Concat(plugin.PluginInfo.DisplayName, "支付");
            ViewBag.Name  = plugin.PluginInfo.DisplayName;
            Bitmap   bitmap = QRCodeHelper.Create(url);
            DateTime now    = DateTime.Now;
            string   str    = string.Concat(now.ToString("yyMMddHHmmssffffff"), ".jpg");
            string   str1   = string.Concat("/temp/", str);

            bitmap.Save(string.Concat(Server.MapPath("~/temp/"), str));
            ViewBag.QRCode = str1;
            dynamic viewBag       = base.ViewBag;
            string  classFullName = plugin.PluginInfo.ClassFullName;

            char[] chrArray = new char[] { ',' };
            viewBag.HelpImage = string.Concat("/Plugins/Payment/", classFullName.Split(chrArray)[1], "/", plugin.Biz.HelpImage);
            ViewBag.Step      = 2;
            return(View());
        }
예제 #9
0
        // GET: Admin/SiteSetting
        public ActionResult Edit()
        {
            Mapper.CreateMap <SiteSettings, SiteSettingModel>().ForMember(a => a.SiteIsOpen, b => b.MapFrom(s => s.SiteIsClose));
            var settings = Mapper.Map <SiteSettings, SiteSettingModel>(SiteSettingApplication.SiteSettings);

            settings.Logo       = Core.HimallIO.GetImagePath(settings.Logo);
            settings.MemberLogo = Core.HimallIO.GetImagePath(settings.MemberLogo);
            settings.PCLoginPic = Core.HimallIO.GetImagePath(settings.PCLoginPic);
            settings.QRCode     = Core.HimallIO.GetImagePath(settings.QRCode);
            settings.WXLogo     = Core.HimallIO.GetImagePath(settings.WXLogo);

            #region 强制绑定手机参数
            var sms = PluginsManagement.GetPlugins <ISMSPlugin>().FirstOrDefault();
            if (sms != null)
            {
                ViewBag.ShowSMS   = true;
                ViewBag.LoginLink = sms.Biz.GetLoginLink();
                ViewBag.BuyLink   = sms.Biz.GetBuyLink();
            }
            #endregion
            return(View(settings));
        }
예제 #10
0
        public JsonResult Charge(string pluginId, decimal amount)
        {
            amount = Math.Round(amount, 2);
            if (amount <= 0M)
            {
                return(base.Json(new { success = false, msg = "请输入正确的金额" }));
            }
            Plugin <IPaymentPlugin> plugin = PluginsManagement.GetPlugin <IPaymentPlugin>(pluginId);
            ChargeDetail            model  = new ChargeDetail
            {
                ChargeAmount = amount,
                ChargeStatus = ChargeDetailInfo.ChargeDetailStatus.WaitPay,
                ChargeWay    = plugin.PluginInfo.DisplayName,
                CreateTime   = DateTime.Now,
                MemId        = base.CurrentUser.Id
            };
            long   num    = MemberCapitalApplication.AddChargeApply(model);
            string cookie = WebHelper.GetCookie("Himall-User_OpenId");

            if (!string.IsNullOrWhiteSpace(cookie))
            {
                cookie = SecureHelper.AESDecrypt(cookie, "Mobile");
            }
            else
            {
                MemberOpenId id = MemberApplication.GetMemberOpenIdInfoByuserId(base.CurrentUser.Id, MemberOpenIdInfo.AppIdTypeEnum.Payment, "");
                if (id != null)
                {
                    cookie = id.OpenId;
                }
            }
            string str2      = base.Request.Url.Scheme + "://" + base.Request.Url.Authority;
            string notifyUrl = string.Concat(new object[] { str2, "/m-", base.PlatformType, "/Payment/CapitalChargeNotify/", plugin.PluginInfo.PluginId.Replace(".", "-") });
            string returnUrl = string.Concat(new object[] { str2, "/m-", base.PlatformType, "/Capital/Index" });
            string str5      = plugin.Biz.GetRequestUrl(returnUrl, notifyUrl, num.ToString(), amount, "会员充值", cookie);

            return(base.Json(new { href = str5, success = true }));
        }
예제 #11
0
        /// <summary>
        /// 验证手机验证码
        /// </summary>
        /// <param name="checkCode">验证码</param>
        /// <param name="contact">手机号或邮箱</param>
        /// <returns></returns>
        public object GetCheckPhoneCheckCode(string checkCode, string contactsPhone)
        {
            if (string.IsNullOrEmpty(checkCode))
            {
                return(ErrorResult("请输入验证码"));
            }

            PluginInfo pluginInfo;

            pluginInfo = PluginsManagement.GetInstalledPluginInfos(Core.Plugins.PluginType.SMS).First();

            var cache     = CacheKeyCollection.MemberPluginCheck(contactsPhone, pluginInfo.PluginId);
            var cacheCode = Core.Cache.Get(cache);

            if (cacheCode != null && cacheCode.ToString() == checkCode)
            {
                return(OnCheckCheckCodeSuccess(contactsPhone));
            }
            else
            {
                return(ErrorResult("验证码输入错误"));
            }
        }
예제 #12
0
        public JsonResult Send(string pluginId, string destination)
        {
            Plugin <IMessagePlugin> plugin = PluginsManagement.GetPlugin <IMessagePlugin>(pluginId);

            if (string.IsNullOrEmpty(destination))
            {
                Result result = new Result()
                {
                    success = false,
                    msg     = string.Concat("你填写的", plugin.Biz.ShortName, "不能为空!")
                };
                return(Json(result));
            }
            if (!plugin.Biz.CheckDestination(destination))
            {
                Result result1 = new Result()
                {
                    success = false,
                    msg     = string.Concat("你填写的", plugin.Biz.ShortName, "不正确")
                };
                return(Json(result1));
            }
            string siteName = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings().SiteName;
            string str      = plugin.Biz.SendTestMessage(destination, string.Concat("该条为测试信息,请勿回复!【", siteName, "】"), "这是一封测试邮件");

            if (str == "发送成功")
            {
                return(Json(new { success = true }));
            }
            Result result2 = new Result()
            {
                success = false,
                msg     = str
            };

            return(Json(result2));
        }
예제 #13
0
        public ActionResult Edit(string pluginId)
        {
            IEnumerable <object> objs = PluginsManagement.GetPlugins <IMessagePlugin>().Select <Plugin <IMessagePlugin>, object>((Plugin <IMessagePlugin> item) =>
            {
                dynamic expandoObjects  = new ExpandoObject();
                expandoObjects.name     = item.PluginInfo.DisplayName;
                expandoObjects.pluginId = item.PluginInfo.PluginId;
                expandoObjects.enable   = item.PluginInfo.Enable;
                expandoObjects.status   = item.Biz.GetAllStatus();
                return(expandoObjects);
            });

            ViewBag.messagePlugins = objs;
            ViewBag.Id             = pluginId;
            Plugin <IMessagePlugin> plugin = PluginsManagement.GetPlugin <IMessagePlugin>(pluginId);

            ViewBag.Name      = plugin.PluginInfo.DisplayName;
            ViewBag.ShortName = plugin.Biz.ShortName;
            FormData            formData = plugin.Biz.GetFormData();
            Plugin <ISMSPlugin> plugin1  = PluginsManagement.GetPlugins <ISMSPlugin>().FirstOrDefault <Plugin <ISMSPlugin> >();

            ViewBag.ShowSMS = false;
            ViewBag.ShowBuy = false;
            if (plugin1 != null && pluginId == plugin1.PluginInfo.PluginId)
            {
                ViewBag.ShowSMS   = true;
                ViewBag.LoginLink = plugin1.Biz.GetLoginLink();
                ViewBag.BuyLink   = plugin1.Biz.GetBuyLink();
                if (plugin1.Biz.IsSettingsValid)
                {
                    ViewBag.Amount  = plugin1.Biz.GetSMSAmount();
                    ViewBag.ShowBuy = true;
                }
            }
            return(View(formData));
        }
예제 #14
0
        public ActionResult Step2(string key)
        {
            UserMemberInfo userMemberInfo = Cache.Get(key) as UserMemberInfo;

            if (userMemberInfo == null)
            {
                return(RedirectToAction("Error", "FindPassWord"));
            }
            IEnumerable <Plugin <IMessagePlugin> > plugins = PluginsManagement.GetPlugins <IMessagePlugin>();
            IEnumerable <PluginsInfo> pluginsInfo          =
                from item in plugins
                select new PluginsInfo()
            {
                ShortName       = item.Biz.ShortName,
                PluginId        = item.PluginInfo.PluginId,
                Enable          = item.PluginInfo.Enable,
                IsSettingsValid = item.Biz.IsSettingsValid,
                IsBind          = !string.IsNullOrEmpty(ServiceHelper.Create <IMessageService>().GetDestination(userMemberInfo.Id, item.PluginInfo.PluginId, MemberContactsInfo.UserTypes.General))
            };

            ViewBag.BindContactInfo = pluginsInfo;
            ViewBag.Key             = key;
            return(View(userMemberInfo));
        }
예제 #15
0
        public void SendMessageCode(string destination, string pluginId, MessageUserInfo info)
        {
            Plugin <IMessagePlugin> plugin = PluginsManagement.GetPlugin <IMessagePlugin>(pluginId);

            if (string.IsNullOrEmpty(destination) || !plugin.Biz.CheckDestination(destination))
            {
                throw new HimallException(string.Concat(plugin.Biz.ShortName, "错误"));
            }
            string str = plugin.Biz.SendMessageCode(destination, info);

            if (plugin.Biz.EnableLog)
            {
                DbSet <MessageLog> messageLog  = context.MessageLog;
                MessageLog         messageLog1 = new MessageLog()
                {
                    SendTime       = new DateTime?(DateTime.Now),
                    ShopId         = new long?(0),
                    MessageContent = str,
                    TypeId         = "短信"
                };
                messageLog.Add(messageLog1);
                context.SaveChanges();
            }
        }
예제 #16
0
        // GET: Web/UserCenter
        public ActionResult Home()
        {
            UserCenterHomeModel viewModel = new UserCenterHomeModel();
            var model = _iMemberService.GetUserCenterModel(CurrentUser.Id);

            viewModel.userCenterModel = model;
            viewModel.UserName        = CurrentUser.Nick == "" ? CurrentUser.UserName : CurrentUser.Nick;
            viewModel.Logo            = CurrentUser.Photo;
            var items = _iCartService.GetCart(CurrentUser.Id).Items.OrderByDescending(a => a.AddTime).Select(p => p.ProductId).Take(3).ToArray();

            viewModel.ShoppingCartItems = _iProductService.GetProductByIds(items).ToArray();
            var UnEvaluatProducts = _iCommentService.GetUnEvaluatProducts(CurrentUser.Id).ToArray();

            viewModel.UnEvaluatProductsNum  = UnEvaluatProducts.Count();
            viewModel.Top3UnEvaluatProducts = UnEvaluatProducts.Take(3).ToArray();
            viewModel.Top3RecommendProducts = _iProductService.GetPlatHotSaleProductByNearShop(8, CurrentUser.Id).ToArray();
            viewModel.BrowsingProducts      = BrowseHistrory.GetBrowsingProducts(4, CurrentUser == null ? 0 : CurrentUser.Id);

            var messagePlugins = PluginsManagement.GetPlugins <IMessagePlugin>();
            var data           = messagePlugins.Select(item => new PluginsInfo
            {
                ShortName       = item.Biz.ShortName,
                PluginId        = item.PluginInfo.PluginId,
                Enable          = item.PluginInfo.Enable,
                IsSettingsValid = item.Biz.IsSettingsValid,
                IsBind          = !string.IsNullOrEmpty(_iMessageService.GetDestination(CurrentUser.Id, item.PluginInfo.PluginId, Himall.Model.MemberContactsInfo.UserTypes.General))
            });

            viewModel.BindContactInfo = data;
            var orders = _iOrderService.GetOrders <OrderInfo>(new OrderQuery
            {
                PageNo   = 1,
                PageSize = int.MaxValue,
                UserId   = CurrentUser.Id
            });

            viewModel.OrderCount = orders.Total;
            //交易预约单 待结算
            viewModel.OrderWaitReceiving = orders.Models.Where(c => c.OrderStatus == OrderInfo.OrderOperateStatus.WaitReceiving).Count();
            //交易预约单 待付款
            viewModel.OrderWaitPay = orders.Models.Where(c => c.OrderStatus == OrderInfo.OrderOperateStatus.WaitPay).Count();
            //交易预约单 待评价
            var productEvaluations = _iCommentService.GetProductEvaluation(new CommentQuery
            {
                UserID   = CurrentUser.Id,
                PageSize = int.MaxValue,
                PageNo   = 1,
                Sort     = "PComment"
            });
            var orderEvaluations = productEvaluations.Models.Where(item => item.EvaluationStatus == false).Select(item => item.OrderId).Distinct();

            viewModel.OrderEvaluationStatus = orderEvaluations.Count();
            //TODO:[LLY]增加我的资产
            var capitalInfo = _iMemberCapitalService.GetCapitalInfo(CurrentUser.Id);
            var balance     = 0M;

            if (capitalInfo != null && capitalInfo.Balance.HasValue)
            {
                balance = capitalInfo.Balance.Value;
            }
            viewModel.Balance = balance;
            //TODO:[YZG]增加账户安全等级
            MemberAccountSafety memberAccountSafety = new MemberAccountSafety();

            memberAccountSafety.AccountSafetyLevel = 1;
            if (CurrentUser.PayPwd != null)
            {
                memberAccountSafety.PayPassword         = true;
                memberAccountSafety.AccountSafetyLevel += 1;
            }
            var ImessageService = _iMessageService;

            foreach (var messagePlugin in data)
            {
                if (messagePlugin.PluginId.IndexOf("SMS") > 0)
                {
                    if (messagePlugin.IsBind)
                    {
                        memberAccountSafety.BindPhone           = true;
                        memberAccountSafety.AccountSafetyLevel += 1;
                    }
                }
                else
                {
                    if (messagePlugin.IsBind)
                    {
                        memberAccountSafety.BindEmail           = true;
                        memberAccountSafety.AccountSafetyLevel += 1;
                    }
                }
            }
            viewModel.memberAccountSafety = memberAccountSafety;
            return(View(viewModel));
        }
예제 #17
0
        public JsonResult Get(string orderIds)
        {
            string str;
            IEnumerable <Plugin <IPaymentPlugin> > plugins =
                from item in PluginsManagement.GetPlugins <IPaymentPlugin>(true)
                where item.Biz.SupportPlatforms.Contains <Himall.Core.PlatformType>(base.PlatformType)
                select item;
            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);

            object[]      platformType  = new object[] { str1, "/m-", base.PlatformType, "/Payment/" };
            string        str2          = string.Concat(platformType);
            IOrderService orderService  = ServiceHelper.Create <IOrderService>();
            IOrderService orderService1 = orderService;

            char[] chrArray = new char[] { ',' };
            IEnumerable <OrderInfo> list = orderService1.GetOrders(
                from t in orderIds.Split(chrArray)
                select long.Parse(t)).ToList();
            decimal num = list.Sum <OrderInfo>((OrderInfo t) => t.OrderTotalAmount);
            string  productNameDescriptionFromOrders = GetProductNameDescriptionFromOrders(list);
            string  cookie = WebHelper.GetCookie("Himall-User_OpenId");

            if (string.IsNullOrWhiteSpace(cookie))
            {
                MemberOpenIdInfo memberOpenIdInfo = ServiceHelper.Create <IMemberService>().GetMember(base.CurrentUser.Id).MemberOpenIdInfo.FirstOrDefault((MemberOpenIdInfo item) => item.AppIdType == MemberOpenIdInfo.AppIdTypeEnum.Payment);
                if (memberOpenIdInfo != null)
                {
                    cookie = memberOpenIdInfo.OpenId;
                }
            }
            else
            {
                cookie = SecureHelper.AESDecrypt(cookie, "Mobile");
            }
            string[] strArrays = orderIds.Split(new char[] { ',' });
            string   str3      = string.Concat(str2, "Notify/");

            object[] objArray = new object[] { str1, "/m-", base.PlatformType, "/Member/PaymentToOrders?ids=", orderIds };
            string   str4     = string.Concat(objArray);
            IEnumerable <OrderPayInfo> orderPayInfo =
                from item in strArrays
                select new OrderPayInfo()
            {
                PayId   = 0,
                OrderId = long.Parse(item)
            };
            string str5       = orderService.SaveOrderPayInfo(orderPayInfo, Himall.Core.PlatformType.PC).ToString();
            var    collection = plugins.ToArray <Plugin <IPaymentPlugin> >().Select((Plugin <IPaymentPlugin> item) => {
                string empty = string.Empty;
                try
                {
                    empty = item.Biz.GetRequestUrl(str4, string.Concat(str3, item.PluginInfo.PluginId.Replace(".", "-")), str5, num, productNameDescriptionFromOrders, cookie);
                }
                catch (Exception exception)
                {
                    Log.Error("获取支付方式错误:", exception);
                }
                return(new { id = item.PluginInfo.PluginId, name = item.PluginInfo.DisplayName, logo = item.Biz.Logo, url = empty });
            });

            collection =
                from item in collection
                where !string.IsNullOrWhiteSpace(item.url)
                select item;

            return(Json(collection));
        }
예제 #18
0
        public ContentResult CashPayNotify_Post(string id, string str)
        {
            char[]  chrArray = new char[] { '-' };
            decimal num      = decimal.Parse(str.Split(chrArray)[0]);

            char[] chrArray1 = new char[] { '-' };
            string str1      = str.Split(chrArray1)[1];

            char[] chrArray2 = new char[] { '-' };
            long   num1      = long.Parse(str.Split(chrArray2)[2]);

            id = DecodePaymentId(id);
            string empty  = string.Empty;
            string empty1 = string.Empty;

            try
            {
                Plugin <IPaymentPlugin> plugin      = PluginsManagement.GetPlugin <IPaymentPlugin>(id);
                PaymentInfo             paymentInfo = plugin.Biz.ProcessReturn(base.HttpContext.Request);
                if ((Cache.Get(CacheKeyCollection.PaymentState(string.Join <long>(",", paymentInfo.OrderIds))) == null ? true : false))
                {
                    ICashDepositsService  cashDepositsService   = ServiceHelper.Create <ICashDepositsService>();
                    CashDepositDetailInfo cashDepositDetailInfo = new CashDepositDetailInfo()
                    {
                        AddDate     = DateTime.Now,
                        Balance     = num,
                        Description = "保证金充值",
                        Operator    = str1
                    };
                    List <CashDepositDetailInfo> cashDepositDetailInfos = new List <CashDepositDetailInfo>()
                    {
                        cashDepositDetailInfo
                    };
                    if (cashDepositsService.GetCashDepositByShopId(num1) != null)
                    {
                        cashDepositDetailInfo.CashDepositId = cashDepositsService.GetCashDepositByShopId(num1).Id;
                        ServiceHelper.Create <ICashDepositsService>().AddCashDepositDetails(cashDepositDetailInfo);
                    }
                    else
                    {
                        CashDepositInfo cashDepositInfo = new CashDepositInfo()
                        {
                            CurrentBalance           = num,
                            Date                     = DateTime.Now,
                            ShopId                   = num1,
                            TotalBalance             = num,
                            EnableLabels             = true,
                            Himall_CashDepositDetail = cashDepositDetailInfos
                        };
                        cashDepositsService.AddCashDeposit(cashDepositInfo);
                    }
                    empty1 = plugin.Biz.ConfirmPayResult();
                    string str2 = CacheKeyCollection.PaymentState(string.Join <long>(",", paymentInfo.OrderIds));
                    Cache.Insert(str2, true);
                }
            }
            catch (Exception exception)
            {
                string message = exception.Message;
            }
            return(base.Content(empty1));
        }
예제 #19
0
        /// <summary>
        /// 发货通知
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="info"></param>
        public void SendMessageOnOrderShipping(long userId, MessageOrderInfo info)
        {
            var message = PluginsManagement.GetPlugins <IMessagePlugin>().ToList();

            foreach (var msg in message)
            {
                if (msg.Biz.GetStatus(MessageTypeEnum.OrderShipping) == StatusEnum.Open)
                {
                    string destination = GetDestination(userId, msg.PluginInfo.PluginId, MemberContactsInfo.UserTypes.General);
                    if (!msg.Biz.CheckDestination(destination))
                    {
                        throw new HimallException(msg.Biz.ShortName + "错误");
                    }
                    var content = msg.Biz.SendMessageOnOrderShipping(destination, info);
                    if (msg.Biz.EnableLog)
                    {
                        Context.MessageLog.Add(new MessageLog()
                        {
                            SendTime = DateTime.Now, ShopId = info.ShopId, MessageContent = content, TypeId = "短信"
                        });
                        Context.SaveChanges();
                    }
                }
            }
            #region 发送模板消息
            if (info.MsgOrderType == MessageOrderType.Normal)
            {
                var userinfo = Context.UserMemberInfo.FirstOrDefault(d => d.Id == userId);
                if (userinfo != null)
                {
                    var msgdata = new WX_MsgTemplateSendDataModel();
                    msgdata.first.value    = "嗖嗖,您的预约单已发货,正加速送到您的手上。";
                    msgdata.first.color    = "#000000";
                    msgdata.keyword1.value = info.ProductName + "等...";
                    msgdata.keyword1.color = "#000000";
                    msgdata.keyword2.value = info.ShippingCompany.ToString();
                    msgdata.keyword2.color = "#000000";
                    msgdata.keyword3.value = info.ShippingNumber.ToString();
                    msgdata.keyword3.color = "#FF0000";
                    msgdata.keyword4.value = info.ShipTo;
                    msgdata.keyword4.color = "#000000";
                    msgdata.remark.value   = "请您耐心等候";
                    msgdata.remark.color   = "#000000";
                    var    _iwxtser = Himall.ServiceProvider.Instance <IWXMsgTemplateService> .Create;
                    string url      = _iwxtser.GetMessageTemplateShowUrl(MessageTypeEnum.OrderShipping);
                    url = url.Replace("{id}", info.OrderId.ToString());
                    _iwxtser.SendMessageByTemplate(MessageTypeEnum.OrderShipping, userId, msgdata);
                }
            }
            #endregion
            #region 小程序模版
            else
            {
                var userinfo = Context.UserMemberInfo.FirstOrDefault(d => d.Id == userId);
                if (userinfo != null)
                {
                    var msgdata = new WX_MsgTemplateSendDataModel();
                    msgdata.keyword1.value = info.ShippingCompany; //快递公司
                    msgdata.keyword1.color = "#173177";
                    msgdata.keyword2.value = info.ShippingNumber;  //快递单号
                    msgdata.keyword2.color = "#173177";
                    msgdata.keyword3.value = info.OrderTime.ToString("yyyy-MM-dd HH:mm:ss");
                    msgdata.keyword3.color = "#173177";
                    msgdata.keyword4.value = info.ProductName + "等...";
                    msgdata.keyword4.color = "#173177";
                    msgdata.keyword5.value = info.ShipTo;
                    msgdata.keyword5.color = "#173177";

                    //处理url
                    var    _iwxtser   = Himall.ServiceProvider.Instance <IWXMsgTemplateService> .Create;
                    var    _iwxmember = Himall.ServiceProvider.Instance <IMemberService> .Create;
                    string page       = _iwxtser.GetWXAppletMessageTemplateShowUrl(MessageTypeEnum.OrderShipping);//小程序跳转地址
                    page = page.Replace("{id}", info.OrderId.ToString());

                    string openId = _iwxmember.GetMemberOpenIdInfoByuserIdAndType(userId, "WeiXinSmallProg").OpenId;//登录小程序的OpenId

                    string formid    = "";
                    var    formmodel = _iwxtser.GetWXAppletFromDataById(MessageTypeEnum.OrderPay, info.OrderId.ToString());
                    if (formmodel != null)
                    {
                        formid = formmodel.FormId;//根据OrderId获取FormId
                    }
                    _iwxtser.SendAppletMessageByTemplate(MessageTypeEnum.OrderShipping, userId, msgdata, page, openId, formid);
                }
            }
            #endregion
        }
예제 #20
0
        public JsonResult PaymentList(decimal balance)
        {
            string  str;
            decimal needPayCashDepositByShopId = ServiceHelper.Create <ICashDepositsService>().GetNeedPayCashDepositByShopId(base.CurrentSellerManager.ShopId);

            if (balance < needPayCashDepositByShopId)
            {
                throw new HimallException("缴纳保证金必须大于应缴保证金");
            }
            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, "/SellerAdmin/CashDeposit/Return/{0}?balance={1}");
            //string str3 = string.Concat(str1, "/pay/CashNotify/{0}?str={1}");
            string str3 = string.Concat(str1, "/SellerAdmin/CashDeposit/CashNotify/{0}?str={1}");
            IEnumerable <Plugin <IPaymentPlugin> > plugins =
                from item in PluginsManagement.GetPlugins <IPaymentPlugin>(true)
                where item.Biz.SupportPlatforms.Contains <PlatformType>(PlatformType.PC)
                select item;
            string str4   = DateTime.Now.ToString("yyyyMMddmmss");
            long   shopId = base.CurrentSellerManager.ShopId;
            string str5   = string.Concat(str4, shopId.ToString());
            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), balance), string.Format(str3, EncodePaymentId(item.PluginInfo.PluginId), string.Concat(new object[] { balance, "-", CurrentSellerManager.UserName, "-", CurrentSellerManager.ShopId })), str5, balance, "保证金充值", 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 = paymentModels.Where((PaymentModel item) =>
            {
                if (string.IsNullOrEmpty(item.RequestUrl))
                {
                    return(false);
                }
                return(item.Id != "Himall.Plugin.Payment.WeiXinPay");
            });
            paymentModels = paymentModels.Where(a => !a.Id.Equals("Himall.Plugin.Payment.WeiXinPay_Native"));//只支持支付宝
            return(Json(paymentModels));
        }
예제 #21
0
        public JsonResult ConfirmPay(long id, ApplyWithDrawInfo.ApplyWithDrawStatus status, string remark)
        {
            JsonResult            jsonResult;
            IMemberCapitalService memberCapitalService = ServiceHelper.Create <IMemberCapitalService>();

            if (status == ApplyWithDrawInfo.ApplyWithDrawStatus.Refuse)
            {
                memberCapitalService.RefuseApplyWithDraw(id, status, base.CurrentManager.UserName, remark);
                return(Json(new { success = true, msg = "审核成功!" }));
            }
            ApplyWithDrawQuery applyWithDrawQuery = new ApplyWithDrawQuery()
            {
                withDrawNo = new long?(id),
                PageNo     = 1,
                PageSize   = 1
            };
            ApplyWithDrawQuery      applyWithDrawQuery1 = applyWithDrawQuery;
            ApplyWithDrawInfo       applyWithDrawInfo   = memberCapitalService.GetApplyWithDraw(applyWithDrawQuery1).Models.FirstOrDefault();
            Plugin <IPaymentPlugin> plugin = (
                from e in PluginsManagement.GetPlugins <IPaymentPlugin>(true)
                where e.PluginInfo.PluginId.ToLower().Contains("weixin")
                select e).FirstOrDefault <Plugin <IPaymentPlugin> >();

            if (plugin == null)
            {
                return(Json(new { success = false, msg = "未找到支付插件" }));
            }
            try
            {
                EnterprisePayPara enterprisePayPara = new EnterprisePayPara()
                {
                    amount       = applyWithDrawInfo.ApplyAmount,
                    check_name   = false,
                    openid       = applyWithDrawInfo.OpenId,
                    out_trade_no = applyWithDrawInfo.Id.ToString(),
                    desc         = "提现"
                };
                PaymentInfo       paymentInfo        = plugin.Biz.EnterprisePay(enterprisePayPara);
                ApplyWithDrawInfo applyWithDrawInfo1 = new ApplyWithDrawInfo()
                {
                    PayNo       = paymentInfo.TradNo,
                    ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess,
                    Remark      = plugin.PluginInfo.Description,
                    PayTime     = new DateTime?((paymentInfo.TradeTime.HasValue ? paymentInfo.TradeTime.Value : DateTime.Now)),
                    ConfirmTime = new DateTime?(DateTime.Now),
                    OpUser      = base.CurrentManager.UserName,
                    ApplyAmount = applyWithDrawInfo.ApplyAmount,
                    Id          = applyWithDrawInfo.Id
                };
                memberCapitalService.ConfirmApplyWithDraw(applyWithDrawInfo1);
                return(Json(new { success = true, msg = "付款成功" }));
            }
            catch (Exception exception)
            {
                Log.Error(string.Concat("调用企业付款接口异常:", exception.Message));
                ApplyWithDrawInfo applyWithDrawInfo2 = new ApplyWithDrawInfo()
                {
                    ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail,
                    Remark      = plugin.PluginInfo.Description,
                    ConfirmTime = new DateTime?(DateTime.Now),
                    OpUser      = base.CurrentManager.UserName,
                    ApplyAmount = applyWithDrawInfo.ApplyAmount,
                    Id          = applyWithDrawInfo.Id
                };
                memberCapitalService.ConfirmApplyWithDraw(applyWithDrawInfo2);
                jsonResult = Json(new { success = false, msg = "付款接口异常" });
            }
            return(jsonResult);
        }
예제 #22
0
        public void ConfirmRefund(long refundId, string managerRemark, string managerName)
        {
            decimal?        nullable;
            OrderRefundInfo now = context.OrderRefundInfo.FindById <OrderRefundInfo>(refundId);

            if (now.RefundPayType.HasValue)
            {
                switch (now.RefundPayType.Value)
                {
                case OrderRefundInfo.OrderRefundPayType.BackOut:
                {
                    if (now.RefundPayStatus.HasValue && now.RefundPayStatus.Value == OrderRefundInfo.OrderRefundPayStatus.PaySuccess)
                    {
                        break;
                    }
                    string paymentTypeGateway = now.OrderItemInfo.OrderInfo.PaymentTypeGateway;
                    IEnumerable <Plugin <IPaymentPlugin> > plugins =
                        from item in PluginsManagement.GetPlugins <IPaymentPlugin>(true)
                        where item.PluginInfo.PluginId == paymentTypeGateway
                        select item;
                    if (plugins.Count <Plugin <IPaymentPlugin> >() <= 0)
                    {
                        throw new HimallException("退款时,未找到支付方式!");
                    }
                    OrderPayInfo      orderPayInfo = context.OrderPayInfo.FirstOrDefault((OrderPayInfo e) => e.PayState && e.OrderId == now.OrderId);
                    IQueryable <long> nums         =
                        from item in context.OrderPayInfo
                        where item.PayId == orderPayInfo.PayId && item.PayState
                        select item into e
                        select e.OrderId;
                    decimal num = (
                        from o in context.OrderInfo
                        where nums.Contains(o.Id)
                        select o).ToList().Sum <OrderInfo>((OrderInfo e) => e.OrderTotalAmount);
                    if (orderPayInfo == null)
                    {
                        throw new HimallException("退款时,未找到原支付订单信息!");
                    }
                    PaymentPara paymentPara = new PaymentPara()
                    {
                        out_refund_no = now.Id.ToString(),
                        out_trade_no  = orderPayInfo.PayId.ToString(),
                        refund_fee    = now.Amount,
                        total_fee     = num
                    };
                    PaymentPara paymentPara1 = paymentPara;
                    PaymentInfo paymentInfo  = plugins.FirstOrDefault <Plugin <IPaymentPlugin> >().Biz.ProcessRefundFee(paymentPara1);
                    if (paymentInfo.OrderIds == null || paymentInfo.OrderIds.Count() <= 0)
                    {
                        break;
                    }
                    now.RefundPayStatus = new OrderRefundInfo.OrderRefundPayStatus?(OrderRefundInfo.OrderRefundPayStatus.PaySuccess);
                    context.SaveChanges();
                    break;
                }

                case OrderRefundInfo.OrderRefundPayType.BackCapital:
                {
                    if (now.RefundPayStatus.HasValue && now.RefundPayStatus.Value == OrderRefundInfo.OrderRefundPayStatus.PaySuccess)
                    {
                        break;
                    }
                    CapitalInfo capitalInfo = context.CapitalInfo.FirstOrDefault((CapitalInfo e) => e.MemId == now.UserId);
                    OrderBO     orderBO     = new OrderBO();
                    if (capitalInfo != null)
                    {
                        CapitalDetailInfo capitalDetailInfo = new CapitalDetailInfo()
                        {
                            Amount     = now.Amount,
                            CapitalID  = capitalInfo.Id,
                            CreateTime = new DateTime?(DateTime.Now),
                            SourceType = CapitalDetailInfo.CapitalDetailType.Refund,
                            SourceData = now.Id.ToString(),
                            Id         = orderBO.GenerateOrderNumber()
                        };
                        CapitalDetailInfo capitalDetailInfo1 = capitalDetailInfo;
                        CapitalInfo       capitalInfo1       = capitalInfo;
                        decimal?          balance            = capitalInfo1.Balance;
                        decimal           amount             = now.Amount;
                        if (balance.HasValue)
                        {
                            nullable = new decimal?(balance.GetValueOrDefault() + amount);
                        }
                        else
                        {
                            nullable = null;
                        }
                        capitalInfo1.Balance = nullable;
                        context.CapitalDetailInfo.Add(capitalDetailInfo1);
                    }
                    else
                    {
                        CapitalInfo capitalInfo2 = new CapitalInfo()
                        {
                            Balance      = new decimal?(now.Amount),
                            MemId        = now.UserId,
                            FreezeAmount = new decimal?(new decimal(0)),
                            ChargeAmount = new decimal?(new decimal(0))
                        };
                        List <CapitalDetailInfo> capitalDetailInfos = new List <CapitalDetailInfo>();
                        CapitalDetailInfo        capitalDetailInfo2 = new CapitalDetailInfo()
                        {
                            Amount     = now.Amount,
                            CreateTime = new DateTime?(DateTime.Now),
                            SourceData = now.Id.ToString(),
                            SourceType = CapitalDetailInfo.CapitalDetailType.Refund,
                            Id         = orderBO.GenerateOrderNumber()
                        };
                        capitalDetailInfos.Add(capitalDetailInfo2);
                        capitalInfo2.ChemCloud_CapitalDetail = capitalDetailInfos;
                        capitalInfo = capitalInfo2;
                        context.CapitalInfo.Add(capitalInfo);
                    }
                    now.RefundPayStatus = new OrderRefundInfo.OrderRefundPayStatus?(OrderRefundInfo.OrderRefundPayStatus.PaySuccess);
                    context.SaveChanges();
                    break;
                }
                }
            }
            if (now.ManagerConfirmStatus != OrderRefundInfo.OrderRefundConfirmStatus.UnConfirm)
            {
                throw new HimallException("只有未确认状态的退款/退货才能进行确认操作");
            }
            now.ManagerConfirmStatus = OrderRefundInfo.OrderRefundConfirmStatus.Confirmed;
            now.ManagerConfirmDate   = DateTime.Now;
            now.ManagerRemark        = managerRemark;
            OrderOperationLogInfo orderOperationLogInfo = new OrderOperationLogInfo()
            {
                Operator       = managerName,
                OrderId        = now.OrderId,
                OperateDate    = DateTime.Now,
                OperateContent = "确认退款/退货"
            };

            context.OrderOperationLogInfo.Add(orderOperationLogInfo);
            UserMemberInfo userMemberInfo   = context.UserMemberInfo.FindById <UserMemberInfo>(now.UserId);
            OrderInfo      orderInfo        = context.OrderInfo.FindById <OrderInfo>(now.OrderId);
            decimal        orderTotalAmount = orderInfo.OrderTotalAmount - orderInfo.Freight;
            decimal        amount1          = now.Amount - (orderInfo.IntegralDiscount * (now.Amount / orderTotalAmount));

            amount1 = Math.Round(amount1, 2);
            if (amount1 > new decimal(0))
            {
                OrderInfo refundTotalAmount = orderInfo;
                refundTotalAmount.RefundTotalAmount = refundTotalAmount.RefundTotalAmount + amount1;
                if (orderInfo.RefundTotalAmount > orderTotalAmount)
                {
                    orderInfo.RefundTotalAmount = orderTotalAmount;
                }
            }
            if (now.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund)
            {
                MemberIntegralExchangeRules integralChangeRule = Instance <IMemberIntegralService> .Create.GetIntegralChangeRule();

                if (integralChangeRule != null)
                {
                    int            moneyPerIntegral = integralChangeRule.MoneyPerIntegral;
                    int            num1             = (int)Math.Floor(now.Amount / moneyPerIntegral);
                    MemberIntegral memberIntegral   = userMemberInfo.ChemCloud_MemberIntegral.FirstOrDefault();
                    int            num2             = (memberIntegral == null ? 0 : memberIntegral.AvailableIntegrals);
                    if (num1 > 0 && num2 > 0 && orderInfo.OrderStatus == OrderInfo.OrderOperateStatus.Finish)
                    {
                        MemberIntegralRecord memberIntegralRecord = new MemberIntegralRecord()
                        {
                            UserName   = userMemberInfo.UserName,
                            MemberId   = userMemberInfo.Id,
                            RecordDate = new DateTime?(DateTime.Now),
                            TypeId     = MemberIntegral.IntegralType.Others
                        };
                        object[] id = new object[] { "售后编号【", now.Id, "】退款应扣除积分", num1.ToString() };
                        memberIntegralRecord.ReMark = string.Concat(id);
                        num1 = (num1 > num2 ? num2 : num1);
                        num1 = -num1;
                        IConversionMemberIntegralBase conversionMemberIntegralBase = Instance <IMemberIntegralConversionFactoryService> .Create.Create(MemberIntegral.IntegralType.Others, num1);

                        Instance <IMemberIntegralService> .Create.AddMemberIntegral(memberIntegralRecord, conversionMemberIntegralBase);
                    }
                }
            }
            context.SaveChanges();
            MessageOrderInfo messageOrderInfo = new MessageOrderInfo()
            {
                OrderId     = orderInfo.Id.ToString(),
                ShopId      = orderInfo.ShopId,
                ShopName    = orderInfo.ShopName,
                RefundMoney = now.Amount,
                SiteName    = Instance <ISiteSettingService> .Create.GetSiteSettings().SiteName,
                TotalMoney  = orderInfo.OrderTotalAmount
            };

            Task.Factory.StartNew(() => Instance <IMessageService> .Create.SendMessageOnOrderRefund(orderInfo.UserId, messageOrderInfo));
            if (orderInfo.PayDate.HasValue)
            {
                UpdateShopVisti(now, orderInfo.PayDate.Value);
                UpdateProductVisti(now, orderInfo.PayDate.Value);
            }
        }
예제 #23
0
        /// <summary>
        /// 发送优惠券
        /// </summary>
        /// <param name="labelids">发送标签</param>
        /// <param name="labelinfos">标签名称</param>
        /// <param name="couponIds">优惠券名称</param>
        /// <returns>-1:优惠券不足;-2:请选择发送的优惠券;-3:标签中用户数为0</returns>
        public static string SendCouponMsg(string labelids, string labelinfos, string couponIds, string url)
        {
            var    messageEmali = PluginsManagement.GetPlugin <IMessagePlugin>("Himall.Plugin.Message.Email");
            var    messageSMS   = PluginsManagement.GetPlugin <IMessagePlugin>("Himall.Plugin.Message.SMS");
            string result       = "";

            if (!couponIds.TrimEnd(',').Equals(""))
            {
                //取出标签对应的会员信息
                long[] lids = string.IsNullOrWhiteSpace(labelids) ? null : labelids.Split(',').Select(s => long.Parse(s)).ToArray();
                int    pageNo = 1, pageSize = 100;
                var    pageMode = MemberApplication.GetMembers(new MemberQuery
                {
                    LabelId  = lids,
                    PageNo   = pageNo,
                    PageSize = pageSize
                });
                if (pageMode.Total > 0)
                {
                    List <UserMemberInfo> mUserMember = new List <UserMemberInfo>();
                    while (pageMode.Models.Count() > 0)//循环批量获取用户信息
                    {
                        string[] dests = pageMode.Models.Select(e => e.Email).ToArray();
                        foreach (var item in pageMode.Models)
                        {
                            mUserMember.Add(item);
                        }
                        pageNo  += 1;
                        pageMode = MemberApplication.GetMembers(new MemberQuery
                        {
                            LabelId  = lids,
                            PageNo   = pageNo,
                            PageSize = pageSize
                        });
                    }

                    string[] arrStr       = couponIds.TrimEnd(',').Split(',');
                    long[]   arrcouponIds = arrStr.Select(a => long.Parse(a)).ToArray();

                    var model = _iCouponService.GetCouponInfo(arrcouponIds);//获取所选优惠券集合

                    //查询优惠券领取状况
                    var mCouponRecord = _iCouponService.GetCouponRecordTotal(arrcouponIds);

                    decimal price = 0;
                    List <SendmessagerecordCouponInfo>   lsendInfo = new List <SendmessagerecordCouponInfo>();
                    List <SendmessagerecordCouponSNInfo> lsendSN   = new List <SendmessagerecordCouponSNInfo>();
                    //验证优惠券是否充足
                    foreach (var item in model)
                    {
                        price += item.Price;
                        lsendInfo.Add(new SendmessagerecordCouponInfo()
                        {
                            CouponId = item.Id
                        });
                        if ((item.Num - item.Himall_CouponRecord.Count()) < mUserMember.Count)
                        {
                            result = item.CouponName + "优惠券的数量不足,无法赠送";
                            break;
                        }
                    }
                    var siteName = ServiceProvider.Instance <ISiteSettingService> .Create.GetSiteSettings().SiteName;

                    if (result == "")
                    {
                        //发送优惠券
                        bool alTotal = false;
                        for (int i = 0; i < mUserMember.Count; i++)
                        {
                            bool suTotal = false;//会员发送优惠券成功数
                            foreach (var item in model)
                            {
                                //判断会员领取限制,是否可领取此优惠券
                                bool isf = true;
                                if (item.PerMax > 0)
                                {
                                    int total = mCouponRecord.Where(p => p.UserId == mUserMember[i].Id && p.CouponId == item.Id).ToList().Count;
                                    if (item.PerMax <= total)
                                    {
                                        isf = false;
                                    }
                                }

                                if (isf)
                                {
                                    suTotal = true;
                                    alTotal = true;

                                    CouponRecordInfo info = new CouponRecordInfo();
                                    info.UserId   = mUserMember[i].Id;
                                    info.UserName = mUserMember[i].UserName;
                                    info.ShopId   = item.ShopId;
                                    info.CouponId = item.Id;
                                    var couponRecord = _iCouponService.AddCouponRecord(info);
                                    lsendSN.Add(new SendmessagerecordCouponSNInfo()
                                    {
                                        CouponSN = couponRecord.CounponSN
                                    });
                                }
                            }

                            if (suTotal)
                            {
                                MessageCouponInfo info = new MessageCouponInfo();
                                info.Money    = price;
                                info.SiteName = siteName;
                                info.UserName = mUserMember[i].UserName;
                                MessageApplication.SendMessageOnCouponSuccess(mUserMember[i].Id, info);
                            }
                        }

                        Log.Debug("sendCoupon:" + alTotal);
                        //查看成功发送会员数
                        if (alTotal)
                        {
                            //记录发送历史
                            var sendRecord = new Himall.Model.SendMessageRecordInfo
                            {
                                ContentType = WXMsgType.wxcard,
                                MessageType = MsgType.Coupon,
                                SendContent = "",
                                SendState   = 1,
                                SendTime    = DateTime.Now,
                                ToUserLabel = labelinfos == null ? "" : labelinfos,
                                Himall_SendmessagerecordCoupon = lsendInfo
                            };
                            var record = WXMsgTemplateApplication.AddSendRecordItem(sendRecord);
                            foreach (var item in lsendSN)
                            {
                                item.MessageId = record.Id;
                            }
                            _iCouponService.AddSendmessagerecordCouponSN(lsendSN);
                        }
                        else
                        {
                            result = "此标签下无符合领取此优惠券的会员";
                        }
                    }
                }
                else
                {
                    result = "该标签下无任何会员";
                }
            }
            else
            {
                result = "请选择发送的优惠券";
            }
            return(result);
        }
예제 #24
0
        public ActionResult Pay(string orderIds)
        {
            string str;

            if (string.IsNullOrEmpty(orderIds))
            {
                return(RedirectToAction("index", "userCenter", new { url = "/userOrder", tar = "userOrder" }));
            }
            char[]             chrArray = new char[] { ',' };
            IEnumerable <long> nums     =
                from item in orderIds.Split(chrArray)
                select long.Parse(item);

            if (ServiceHelper.Create <IOrderService>().GetOrders(nums).Any((OrderInfo item) =>
            {
                if (item.OrderStatus != OrderInfo.OrderOperateStatus.WaitPay)
                {
                    return(true);
                }
                return(item.UserId != base.CurrentUser.Id);
            }))
            {
                return(RedirectToAction("index", "userCenter", new { url = string.Concat("/userOrder?orderids=", orderIds), tar = "userOrder" }));
            }
            SiteSettingsInfo siteSettings = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings();

            ViewBag.Logo = siteSettings.Logo;
            IOrderService    orderService = ServiceHelper.Create <IOrderService>();
            List <OrderInfo> list         = orderService.GetOrders(nums).Where((OrderInfo item) =>
            {
                if (item.OrderStatus != OrderInfo.OrderOperateStatus.WaitPay)
                {
                    return(false);
                }
                return(item.UserId == base.CurrentUser.Id);
            }).ToList();
            bool             flag       = false;
            List <OrderInfo> orderInfos = new List <OrderInfo>();

            foreach (OrderInfo orderInfo in list)
            {
                orderInfo.HaveDelProduct = orderService.IsHaveNoOnSaleProduct(orderInfo.Id);
                if (!orderInfo.HaveDelProduct)
                {
                    continue;
                }
                orderInfos.Add(orderInfo);
                flag = true;
                orderService.PlatformCloseOrder(orderInfo.Id, "automatic", "You have not sell the goods, please contact the merchant or Administration");
            }
            if (flag)
            {
                foreach (OrderInfo orderInfo1 in orderInfos)
                {
                    list.Remove(orderInfo1);
                }
                throw new HimallException("有订单商品处于非销售状态,请手动处理。");
            }
            ViewBag.HaveNoSalePro = flag;
            if (list == null || list.Count == 0)
            {
                return(RedirectToAction("index", "userCenter", new { url = "/userOrder", tar = "userOrder" }));
            }
            ViewBag.Orders = list;
            decimal num = list.Sum <OrderInfo>((OrderInfo a) => a.OrderTotalAmount);

            if (num == new decimal(0))
            {
                ViewBag.TotalAmount = num;
                return(View("PayConfirm"));
            }
            string productNameDescriptionFromOrders = GetProductNameDescriptionFromOrders(list);
            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/Return/{0}");
            string str3 = string.Concat(str1, "/Pay/Notify/{0}");
            IEnumerable <Plugin <IPaymentPlugin> > plugins =
                from item in PluginsManagement.GetPlugins <IPaymentPlugin>(true)
                where item.Biz.SupportPlatforms.Contains <PlatformType>(PlatformType.PC)
                select item;

            char[] chrArray1 = new char[] { ',' };
            IEnumerable <OrderPayInfo> orderPayInfos =
                from item in orderIds.Split(chrArray1)
                select new OrderPayInfo()
            {
                PayId   = 0,
                OrderId = long.Parse(item)
            };
            long   num1 = orderService.SaveOrderPayInfo(orderPayInfos, PlatformType.PC);
            string str4 = num1.ToString();
            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)), str4, num, productNameDescriptionFromOrders, 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   = num;
            ViewBag.Step          = 1;
            ViewBag.UnpaidTimeout = siteSettings.UnpaidTimeout;
            CapitalInfo capitalInfo = ServiceHelper.Create <IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id);

            if (capitalInfo != null)
            {
                ViewBag.Capital = capitalInfo.Balance;
            }
            else
            {
                ViewBag.Capital = 0;
            }
            ViewBag.PayId = num1;
            return(View(paymentModels));
        }
예제 #25
0
        public ActionResult Home()
        {
            UserCenterHomeModel viewModel = new UserCenterHomeModel();

            viewModel.userCenterModel = MemberApplication.GetUserCenterModel(CurrentUser.Id);
            viewModel.UserName        = CurrentUser.Nick == "" ? CurrentUser.UserName : CurrentUser.Nick;
            viewModel.Logo            = CurrentUser.Photo;
            var items = _iCartService.GetCart(CurrentUser.Id).Items.OrderByDescending(a => a.AddTime).Select(p => p.ProductId).Take(3).ToArray();

            viewModel.ShoppingCartItems = ProductManagerApplication.GetProductByIds(items).ToArray();
            var UnEvaluatProducts = _iCommentService.GetUnEvaluatProducts(CurrentUser.Id).ToArray();

            viewModel.UnEvaluatProductsNum  = UnEvaluatProducts.Count();
            viewModel.Top3UnEvaluatProducts = UnEvaluatProducts.Take(3).ToArray();
            viewModel.Top3RecommendProducts = _iProductService.GetPlatHotSaleProductByNearShop(8, CurrentUser.Id).ToArray();
            viewModel.BrowsingProducts      = BrowseHistrory.GetBrowsingProducts(4, CurrentUser == null ? 0 : CurrentUser.Id);

            var messagePlugins = PluginsManagement.GetPlugins <IMessagePlugin>();
            var data           = messagePlugins.Select(item => new PluginsInfo
            {
                ShortName       = item.Biz.ShortName,
                PluginId        = item.PluginInfo.PluginId,
                Enable          = item.PluginInfo.Enable,
                IsSettingsValid = item.Biz.IsSettingsValid,
                IsBind          = !string.IsNullOrEmpty(_iMessageService.GetDestination(CurrentUser.Id, item.PluginInfo.PluginId, Entities.MemberContactInfo.UserTypes.General))
            });

            viewModel.BindContactInfo = data;

            var statistic = StatisticApplication.GetMemberOrderStatistic(CurrentUser.Id);

            viewModel.OrderCount            = statistic.OrderCount;
            viewModel.OrderWaitReceiving    = statistic.WaitingForRecieve;
            viewModel.OrderWaitPay          = statistic.WaitingForPay;
            viewModel.OrderEvaluationStatus = statistic.WaitingForComments;
            viewModel.Balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id);
            //TODO:[YZG]增加账户安全等级
            MemberAccountSafety memberAccountSafety = new MemberAccountSafety
            {
                AccountSafetyLevel = 1
            };

            if (CurrentUser.PayPwd != null)
            {
                memberAccountSafety.PayPassword         = true;
                memberAccountSafety.AccountSafetyLevel += 1;
            }
            var ImessageService = _iMessageService;

            foreach (var messagePlugin in data)
            {
                if (messagePlugin.PluginId.IndexOf("SMS") > 0)
                {
                    if (messagePlugin.IsBind)
                    {
                        memberAccountSafety.BindPhone           = true;
                        memberAccountSafety.AccountSafetyLevel += 1;
                    }
                }
                else
                {
                    if (messagePlugin.IsBind)
                    {
                        memberAccountSafety.BindEmail           = true;
                        memberAccountSafety.AccountSafetyLevel += 1;
                    }
                }
            }
            viewModel.memberAccountSafety = memberAccountSafety;
            ViewBag.Keyword  = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords = SiteSettings.HotKeyWords;
            return(View(viewModel));
        }
예제 #26
0
 private IEnumerable <string> GetOAuthValidateContents()
 {
     return
         (from item in PluginsManagement.GetPlugins <IOAuthPlugin>(true)
          select item.Biz.GetValidateContent());
 }
예제 #27
0
 private IExpress GetIExpressByName(string name)
 {
     return(PluginsManagement.GetInstalledPlugins <IExpress>(PluginType.Express).FirstOrDefault((IExpress item) => item.Name == name));
 }
예제 #28
0
        public JsonResult ConfirmApply(long id, ApplyWithDrawInfo.ApplyWithDrawStatus comfirmStatus, string remark)
        {
            IMemberCapitalService memberCapitalService = this._iMemberCapitalService;

            ApplyWithDrawInfo.ApplyWithDrawStatus status = comfirmStatus;
            ApplyWithDrawInfo applyWithDrawInfo1         = memberCapitalService.GetApplyWithDrawInfo(id);

            if (status == ApplyWithDrawInfo.ApplyWithDrawStatus.Refuse)
            {
                memberCapitalService.RefuseApplyWithDraw(id, status, this.CurrentManager.UserName, remark);
                this._iOperationLogService.AddPlatformOperationLog(new LogInfo()
                {
                    Date        = DateTime.Now,
                    Description = string.Format("会员提现审核拒绝,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark),
                    IPAddress   = this.Request.UserHostAddress,
                    PageUrl     = "/Admin/Capital/WithDraw",
                    UserName    = this.CurrentManager.UserName,
                    ShopId      = 0L
                });
                return(this.Json((object)new BaseController.Result()
                {
                    success = true,
                    msg = "审核成功!"
                }));
            }
            UserWithdrawType?applyType = applyWithDrawInfo1.ApplyType;

            if ((applyType.GetValueOrDefault() != UserWithdrawType.ALiPay ? 0 : (applyType.HasValue ? 1 : 0)) != 0)
            {
                if (applyWithDrawInfo1.ApplyStatus == ApplyWithDrawInfo.ApplyWithDrawStatus.PayPending)
                {
                    return(this.Json((object)new BaseController.Result()
                    {
                        success = false,
                        msg = "等待第三方处理中,如有误操作,请先取消后再进行付款操作!"
                    }));
                }
                Plugin <IPaymentPlugin> plugin = Enumerable.FirstOrDefault <Plugin <IPaymentPlugin> >(PluginsManagement.GetPlugins <IPaymentPlugin>(true), (Func <Plugin <IPaymentPlugin>, bool>)(e => e.PluginInfo.PluginId == "Himall.Plugin.Payment.Alipay"));
                if (plugin != null)
                {
                    try
                    {
                        string            format = CurrentUrlHelper.CurrentUrlNoPort() + "/Pay/EnterpriseNotify/{0}?outid={1}";
                        EnterprisePayPara para   = new EnterprisePayPara()
                        {
                            amount       = applyWithDrawInfo1.ApplyAmount,
                            check_name   = false,
                            openid       = applyWithDrawInfo1.OpenId,
                            re_user_name = applyWithDrawInfo1.NickName,
                            out_trade_no = applyWithDrawInfo1.Id.ToString(),
                            desc         = "提现",
                            notify_url   = string.Format(format, (object)this.EncodePaymentId(plugin.PluginInfo.PluginId), (object)applyWithDrawInfo1.Id.ToString())
                        };
                        PaymentInfo       paymentInfo        = plugin.Biz.EnterprisePay(para);
                        ApplyWithDrawInfo applyWithDrawInfo2 = new ApplyWithDrawInfo();
                        applyWithDrawInfo2.PayNo       = paymentInfo.TradNo;
                        applyWithDrawInfo2.ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.PayPending;
                        ApplyWithDrawInfo applyWithDrawInfo3 = applyWithDrawInfo2;
                        DateTime?         tradeTime          = paymentInfo.TradeTime;
                        DateTime          now;
                        if (!tradeTime.HasValue)
                        {
                            now = DateTime.Now;
                        }
                        else
                        {
                            tradeTime = paymentInfo.TradeTime;
                            now       = tradeTime.Value;
                        }
                        DateTime?nullable = new DateTime?(now);
                        applyWithDrawInfo3.PayTime     = nullable;
                        applyWithDrawInfo2.ConfirmTime = new DateTime?(DateTime.Now);
                        applyWithDrawInfo2.OpUser      = this.CurrentManager.UserName;
                        applyWithDrawInfo2.ApplyAmount = applyWithDrawInfo1.ApplyAmount;
                        applyWithDrawInfo2.Id          = applyWithDrawInfo1.Id;
                        ApplyWithDrawInfo info = applyWithDrawInfo2;
                        memberCapitalService.ConfirmApplyWithDraw(info);
                        this._iOperationLogService.AddPlatformOperationLog(new LogInfo()
                        {
                            Date        = DateTime.Now,
                            Description = string.Format("会员提现审核成功,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark),
                            IPAddress   = this.Request.UserHostAddress,
                            PageUrl     = "/Admin/Capital/WithDraw",
                            UserName    = this.CurrentManager.UserName,
                            ShopId      = 0L
                        });
                        return(this.Json((object)new BaseController.Result()
                        {
                            success = true,
                            msg = "审核操作成功",
                            status = 2,
                            Data = (object)paymentInfo.ResponseContentWhenFinished
                        }));
                    }
                    catch (PluginException ex)
                    {
                        Log.Error((object)("调用企业付款接口异常:" + ex.Message));
                        this._iOperationLogService.AddPlatformOperationLog(new LogInfo()
                        {
                            Date        = DateTime.Now,
                            Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark),
                            IPAddress   = this.Request.UserHostAddress,
                            PageUrl     = "/Admin/Capital/WithDraw",
                            UserName    = this.CurrentManager.UserName,
                            ShopId      = 0L
                        });
                        return(this.Json((object)new BaseController.Result()
                        {
                            success = false,
                            msg = ex.Message
                        }));
                    }
                    catch (Exception ex)
                    {
                        Log.Error((object)("提现审核异常:" + ex.Message));
                        return(this.Json((object)new BaseController.Result()
                        {
                            success = false,
                            msg = "付款接口异常"
                        }));
                    }
                }
                else
                {
                    return(this.Json((object)new BaseController.Result()
                    {
                        success = false,
                        msg = "未找到支付插件"
                    }));
                }
            }
            else
            {
                Plugin <IPaymentPlugin> plugin = Enumerable.FirstOrDefault <Plugin <IPaymentPlugin> >(Enumerable.Where <Plugin <IPaymentPlugin> >(PluginsManagement.GetPlugins <IPaymentPlugin>(true), (Func <Plugin <IPaymentPlugin>, bool>)(e => e.PluginInfo.PluginId.ToLower().Contains("weixin"))));
                if (plugin != null)
                {
                    try
                    {
                        EnterprisePayPara para = new EnterprisePayPara()
                        {
                            amount       = applyWithDrawInfo1.ApplyAmount,
                            check_name   = false,
                            openid       = applyWithDrawInfo1.OpenId,
                            out_trade_no = applyWithDrawInfo1.Id.ToString(),
                            desc         = "提现"
                        };
                        PaymentInfo       paymentInfo        = plugin.Biz.EnterprisePay(para);
                        ApplyWithDrawInfo applyWithDrawInfo2 = new ApplyWithDrawInfo();
                        applyWithDrawInfo2.PayNo       = paymentInfo.TradNo;
                        applyWithDrawInfo2.ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess;
                        applyWithDrawInfo2.Remark      = plugin.PluginInfo.Description;
                        ApplyWithDrawInfo applyWithDrawInfo3 = applyWithDrawInfo2;
                        DateTime?         tradeTime          = paymentInfo.TradeTime;
                        DateTime          now;
                        if (!tradeTime.HasValue)
                        {
                            now = DateTime.Now;
                        }
                        else
                        {
                            tradeTime = paymentInfo.TradeTime;
                            now       = tradeTime.Value;
                        }
                        DateTime?nullable = new DateTime?(now);
                        applyWithDrawInfo3.PayTime     = nullable;
                        applyWithDrawInfo2.ConfirmTime = new DateTime?(DateTime.Now);
                        applyWithDrawInfo2.OpUser      = this.CurrentManager.UserName;
                        applyWithDrawInfo2.ApplyAmount = applyWithDrawInfo1.ApplyAmount;
                        applyWithDrawInfo2.Id          = applyWithDrawInfo1.Id;
                        ApplyWithDrawInfo info = applyWithDrawInfo2;
                        memberCapitalService.ConfirmApplyWithDraw(info);
                        this._iOperationLogService.AddPlatformOperationLog(new LogInfo()
                        {
                            Date        = DateTime.Now,
                            Description = string.Format("会员提现审核成功,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark),
                            IPAddress   = this.Request.UserHostAddress,
                            PageUrl     = "/Admin/Capital/WithDraw",
                            UserName    = this.CurrentManager.UserName,
                            ShopId      = 0L
                        });
                    }
                    catch (PluginException ex)
                    {
                        Log.Error((object)("调用企业付款接口异常:" + ex.Message));
                        this._iOperationLogService.AddPlatformOperationLog(new LogInfo()
                        {
                            Date        = DateTime.Now,
                            Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark),
                            IPAddress   = this.Request.UserHostAddress,
                            PageUrl     = "/Admin/Capital/WithDraw",
                            UserName    = this.CurrentManager.UserName,
                            ShopId      = 0L
                        });
                        return(this.Json((object)new BaseController.Result()
                        {
                            success = false,
                            msg = ex.Message
                        }));
                    }
                    catch (Exception ex)
                    {
                        Log.Error((object)("提现审核异常:" + ex.Message));
                        ApplyWithDrawInfo info = new ApplyWithDrawInfo()
                        {
                            ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail,
                            Remark      = plugin.PluginInfo.Description,
                            ConfirmTime = new DateTime?(DateTime.Now),
                            OpUser      = this.CurrentManager.UserName,
                            ApplyAmount = applyWithDrawInfo1.ApplyAmount,
                            Id          = applyWithDrawInfo1.Id
                        };
                        memberCapitalService.ConfirmApplyWithDraw(info);
                        this._iOperationLogService.AddPlatformOperationLog(new LogInfo()
                        {
                            Date        = DateTime.Now,
                            Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark),
                            IPAddress   = this.Request.UserHostAddress,
                            PageUrl     = "/Admin/Capital/WithDraw",
                            UserName    = this.CurrentManager.UserName,
                            ShopId      = 0L
                        });
                        return(this.Json((object)new BaseController.Result()
                        {
                            success = false,
                            msg = "付款接口异常"
                        }));
                    }
                    return(this.Json((object)new BaseController.Result()
                    {
                        success = true,
                        msg = "审核操作成功"
                    }));
                }
                return(this.Json((object)new BaseController.Result()
                {
                    success = false,
                    msg = "未找到支付插件"
                }));
            }
        }
예제 #29
0
        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());
        }
예제 #30
0
        /// <summary>
        /// 发送手机或邮箱验证码
        /// </summary>
        /// <param name="imageCheckCode"></param>
        /// <param name="contact"></param>
        /// <returns></returns>
        public JsonResult <Result <int> > GetPhoneOrEmailCheckCode(string contact, string id = null, string imageCheckCode = null, bool checkBind = false)
        {
            if (CurrentUser == null)
            {
                if (string.IsNullOrEmpty(imageCheckCode))
                {
                    return(Json(ErrorResult <int>("请输入验证码")));
                }

                var key             = "ImageCheckCode:" + id;
                var systemCheckCode = Cache.Get <string>(key);
                if (systemCheckCode == null)
                {
                    return(Json(ErrorResult <int>("验证码已过期")));
                }

                if (systemCheckCode.ToLower() != imageCheckCode.ToLower())
                {
                    return(Json(ErrorResult <int>("验证码错误")));
                }
                else
                {
                    Cache.Remove(key);
                }
            }

            string msg;
            var    checkResult = this.CheckContact(contact, out msg);

            if (!checkResult)
            {
                return(Json(ErrorResult <int>(string.IsNullOrEmpty(msg) ? "手机或邮箱号码不存在" : msg)));
            }

            PluginInfo pluginInfo;
            var        isMobile = Core.Helper.ValidateHelper.IsMobile(contact);

            if (isMobile)
            {
                pluginInfo = PluginsManagement.GetInstalledPluginInfos(Core.Plugins.PluginType.SMS).First();
            }
            else
            {
                pluginInfo = PluginsManagement.GetInstalledPluginInfos(PluginType.Email).First();
            }

            if (pluginInfo == null)
            {
                Log.Error(string.Format("未找到{0}发送插件", isMobile ? "短信" : "邮件"));
                return(Json(ErrorResult <int>("验证码发送失败")));
            }

            if (checkBind && Application.MessageApplication.GetMemberContactsInfo(pluginInfo.PluginId, contact, Entities.MemberContactInfo.UserTypes.General) != null)
            {
                return(Json(ErrorResult <int>(contact + "已经绑定过了!")));
            }

            var timeoutKey = CacheKeyCollection.MemberPluginCheckTime(contact, pluginInfo.PluginId);

            if (Core.Cache.Exists(timeoutKey))
            {
                return(Json(ErrorResult <int>("请求过于频繁,请稍后再试!")));
            }
            int cacheTime = 60;

            Core.Cache.Insert(timeoutKey, cacheTime, DateTime.Now.AddSeconds(cacheTime));

            var checkCode = new Random().Next(10000, 99999);
            var siteName  = Application.SiteSettingApplication.SiteSettings.SiteName;
            var message   = new Himall.Core.Plugins.Message.MessageUserInfo()
            {
                UserName = contact, SiteName = siteName, CheckCode = checkCode.ToString()
            };

            Application.MessageApplication.SendMessageCode(contact, pluginInfo.PluginId, message);
            //缓存验证码
            Core.Cache.Insert(CacheKeyCollection.MemberPluginCheck(contact, pluginInfo.PluginId), checkCode.ToString(), DateTime.Now.AddMinutes(10));

            return(JsonResult <int>(msg: "验证码发送成功"));
        }