public object GetUser(string UserKey) { CheckUserLogin(); dynamic data = SuccessResult(); long userId = CurrentUser.Id; var member = MemberApplication.GetMember(userId); data.UserId = member.Id; data.UserName = member.UserName; data.Photo = string.IsNullOrEmpty(member.Photo) ? "" : HimallIO.GetRomoteImagePath(member.Photo); data.CellPhone = member.CellPhone; data.QQ = member.QQ; data.BirthDay = member.BirthDay; data.Nick = member.Nick; data.RealName = member.RealName; data.Sex = (int)member.Sex; var orderStatic = StatisticApplication.GetMemberOrderStatistic(userId, true); //用户所有订单 data.AllOrders = orderStatic.OrderCount; //待付款订单 data.WaitingForPay = orderStatic.WaitingForPay; //待发货订单 data.WaitingForDelivery = orderStatic.WaitingForDelivery;//获取待发货订单数 //未评论订单 data.WaitingForComments = orderStatic.WaitingForComments; //待收货订单/待消费 data.WaitingForRecieve = orderStatic.WaitingForRecieve + OrderApplication.GetWaitConsumptionOrderNumByUserId(userId); //待处理的售后 data.RefundOrders = orderStatic.RefundCount; data.FavoriteShop = ShopApplication.GetUserConcernShopsCount(userId); data.FavoriteProduct = FavoriteApplication.GetFavoriteCountByUser(userId); data.Coupon = MemberApplication.GetAvailableCouponCount(userId); data.Integral = MemberIntegralApplication.GetAvailableIntegral(userId); data.Balance = MemberCapitalApplication.GetBalanceByUserId(userId); //用户参与的团数量 var seastatus = new List <FightGroupOrderJoinStatus> { FightGroupOrderJoinStatus.Ongoing, FightGroupOrderJoinStatus.JoinSuccess, FightGroupOrderJoinStatus.BuildFailed, FightGroupOrderJoinStatus.BuildSuccess }; //TODO:FG 查询待优化 data.GroupTotal = ServiceProvider.Instance <IFightGroupService> .Create.GetJoinGroups(userId, seastatus, 1, 1).Total; data.MyGroup = ServiceProvider.Instance <IFightGroupService> .Create.CountJoiningOrder(userId); data.IsOpenRechargePresent = SiteSettingApplication.SiteSettings.IsOpenRechargePresent; MemberApplication.AddIntegel(member);//给用户加积分//执行登录后初始化相关操作 return(data); }
public ActionResult ApplyWithDraw() { var siteSetting = SiteSettingApplication.SiteSettings; if (string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret)) { throw new MallException("未配置公众号参数"); } var token = AccessTokenContainer.TryGetAccessToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret); SceneModel scene = new SceneModel(QR_SCENE_Type.WithDraw) { Object = CurrentUser.Id.ToString() }; SceneHelper helper = new SceneHelper(); var sceneid = helper.SetModel(scene); var ticket = QrCodeApi.Create(token, 300, sceneid, Senparc.Weixin.MP.QrCode_ActionName.QR_LIMIT_SCENE, null); ViewBag.ticket = ticket.ticket; ViewBag.Sceneid = sceneid; var balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id); ViewBag.ApplyWithMoney = balance; var member = _iMemberService.GetMember(CurrentUser.Id);//CurrentUser对象有缓存,取不到最新数据 ViewBag.IsSetPwd = string.IsNullOrWhiteSpace(member.PayPwd) ? false : true; ViewBag.WithDrawMinimum = siteSetting.WithDrawMinimum; ViewBag.WithDrawMaximum = siteSetting.WithDrawMaximum; ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; return(View()); }
public JsonResult ChageCapital(long userId, decimal amount, string remark) { var result = new Result { msg = "错误的会员编号" }; var _user = MemberApplication.GetMember(userId); if (_user != null) { if (string.IsNullOrWhiteSpace(remark)) { result.msg = "请填写备注信息"; } else { if (amount < 0) { var balance = MemberCapitalApplication.GetBalanceByUserId(userId); if (balance < Math.Abs(amount)) { throw new HimallException("用户余额不足相减"); } } if (amount < 0) { CapitalDetailModel capita = new CapitalDetailModel { UserId = userId, SourceType = CapitalDetailType.ChargeAmount, Amount = amount, CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = remark, PayWay = "管理员操作" }; _iMemberCapitalService.AddCapital(capita); } else { var detail = new Entities.ChargeDetailInfo() { ChargeAmount = amount, ChargeStatus = Entities.ChargeDetailInfo.ChargeDetailStatus.WaitPay, CreateTime = DateTime.Now, MemId = userId, ChargeWay = "管理员操作" }; long id = _iMemberCapitalService.AddChargeApply(detail); _iMemberCapitalService.ChargeSuccess(id, remark + " 管理员操作"); } result.success = true; result.msg = "操作成功"; } } return(Json(result)); }
public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd, int applyType = 1) { var success = Application.MemberApplication.VerificationPayPwd(CurrentUser.Id, pwd); if (!success) { throw new MallException("支付密码不对,请重新输入!"); } if (applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode() && !SiteSettings.Withdraw_AlipayEnable) { throw new MallException("不支持支付宝提现方式!"); } //TODO:FG 存在多处申请提现逻辑,提取至Application中实现 var balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id); if (amount > balance) { throw new MallException("提现金额不能超出可用金额!"); } if (amount <= 0) { throw new MallException("提现金额不能小于等于0!"); } if (string.IsNullOrWhiteSpace(openid)) { throw new MallException("数据异常,OpenId或收款账号不可为空!"); } if (string.IsNullOrWhiteSpace(nickname) && applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode()) { throw new MallException("数据异常,真实姓名不可为空!"); } var siteSetting = SiteSettingApplication.SiteSettings; if (!(amount <= siteSetting.WithDrawMaximum) && !(amount >= siteSetting.WithDrawMinimum)) { throw new MallException("提现金额不能小于:" + siteSetting.WithDrawMinimum + ",不能大于:" + siteSetting.WithDrawMaximum); } Mall.Entities.ApplyWithdrawInfo model = new Mall.Entities.ApplyWithdrawInfo() { ApplyAmount = amount, ApplyStatus = Mall.Entities.ApplyWithdrawInfo.ApplyWithdrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = CurrentUser.Id, OpenId = openid, NickName = nickname, ApplyType = (CommonModel.UserWithdrawType)applyType }; _iMemberCapitalService.AddWithDrawApply(model); return(Json(new { success = true })); }
/// <summary> /// 个人中心主页 /// </summary> /// <returns></returns> public new JsonResult <Result <dynamic> > GetUser() { CheckUserLogin(); dynamic d = new System.Dynamic.ExpandoObject(); long id = CurrentUser.Id; var member = MemberApplication.GetMember(id); DistributorInfo currentDistributor = DistributionApplication.GetDistributor(member.Id); d.UserName = member.UserName; //用户名 d.RealName = member.RealName; //真实姓名 d.Nick = member.Nick; //昵称 d.UserId = member.Id.ToString(); d.CellPhone = member.CellPhone; //绑定的手机号码 d.Photo = String.IsNullOrEmpty(member.Photo) ? "" : HimallIO.GetRomoteImagePath(member.Photo); //头像 var statistic = StatisticApplication.GetMemberOrderStatistic(id, true); d.AllOrders = statistic.OrderCount; d.WaitingForPay = statistic.WaitingForPay; d.WaitingForRecieve = statistic.WaitingForRecieve + OrderApplication.GetWaitConsumptionOrderNumByUserId(id); d.WaitingForDelivery = statistic.WaitingForDelivery; d.WaitingForComments = statistic.WaitingForComments; d.RefundOrders = statistic.RefundCount; d.FavoriteShop = ShopApplication.GetUserConcernShopsCount(member.Id); //收藏的店铺数 d.FavoriteProduct = FavoriteApplication.GetFavoriteCountByUser(member.Id); //收藏的商品数 d.Counpon = MemberApplication.GetAvailableCouponCount(id); d.Integral = MemberIntegralApplication.GetAvailableIntegral(member.Id); //我的积分 d.Balance = MemberCapitalApplication.GetBalanceByUserId(member.Id); //我的资产 d.IsOpenRechargePresent = SiteSettingApplication.SiteSettings.IsOpenRechargePresent; var phone = SiteSettingApplication.SiteSettings.SitePhone; d.ServicePhone = string.IsNullOrEmpty(phone) ? "" : phone; d.IsDistributor = (currentDistributor != null && currentDistributor.DistributionStatus == (int)DistributorStatus.Audited); return(JsonResult <dynamic>(d)); }
public object PostApplyWithDraw(MemberCapitalApplyWithDrawModel para) { CheckUserLogin(); if (para == null) { para = new MemberCapitalApplyWithDrawModel(); } var success = MemberApplication.VerificationPayPwd(CurrentUser.Id, para.pwd); var sitesetting = SiteSettingApplication.SiteSettings; if (para.applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode() && !sitesetting.Withdraw_AlipayEnable) { return(Json(ErrorResult <bool>("不支持支付宝提现方式"))); } if (!success) { return(Json(ErrorResult <bool>("支付密码不对,请重新输入"))); } var balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id); if (para.amount > balance) { return(Json(ErrorResult <bool>("提现金额不能超出可用金额!"))); } if (para.amount <= 0) { return(Json(ErrorResult <bool>("提现金额不能小于等于0!"))); } if (string.IsNullOrWhiteSpace(para.openId) && para.applyType == CommonModel.UserWithdrawType.WeiChat.GetHashCode()) { var mo = MemberApplication.GetMemberOpenIdInfoByuserId(CurrentUser.Id, Entities.MemberOpenIdInfo.AppIdTypeEnum.Payment, PLUGIN_OAUTH_WEIXIN); if (mo != null && !string.IsNullOrWhiteSpace(mo.OpenId)) { para.openId = mo.OpenId; } } if (string.IsNullOrWhiteSpace(para.nickname) && para.applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode()) { return(Json(ErrorResult <bool>("数据异常,真实姓名不可为空!"))); } if (!string.IsNullOrWhiteSpace(para.openId) && para.applyType == CommonModel.UserWithdrawType.WeiChat.GetHashCode()) { //para.openid = Core.Helper.SecureHelper.AESDecrypt(para.openid, "Mobile"); if (!string.IsNullOrWhiteSpace(sitesetting.WeixinAppletId) && !string.IsNullOrWhiteSpace(sitesetting.WeixinAppletSecret)) { string token = AccessTokenContainer.TryGetAccessToken(sitesetting.WeixinAppletId, sitesetting.WeixinAppletSecret); var userinfo = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetUserInfo(token, para.openId); if (userinfo != null) { para.nickname = userinfo.nickname; } } } if (string.IsNullOrWhiteSpace(para.openId)) { return(Json(ErrorResult <bool>("数据异常,OpenId或收款账号不可为空!"))); } Mall.Entities.ApplyWithdrawInfo model = new Mall.Entities.ApplyWithdrawInfo() { ApplyAmount = para.amount, ApplyStatus = Mall.Entities.ApplyWithdrawInfo.ApplyWithdrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = CurrentUser.Id, OpenId = para.openId, NickName = para.nickname, ApplyType = (CommonModel.UserWithdrawType)para.applyType }; MemberCapitalApplication.AddWithDrawApply(model); return(Json(true)); }
public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd, int applyType = 1) { var success = MemberApplication.VerificationPayPwd(CurrentUser.Id, pwd); if (!success) { throw new HimallException("支付密码不对,请重新输入!"); } if (applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode() && !SiteSettings.Withdraw_AlipayEnable) { throw new HimallException("不支持支付宝提现方式!"); } var balance = MemberCapitalApplication.GetBalanceByUserId(UserId); if (amount > balance) { throw new HimallException("提现金额不能超出可用金额!"); } if (amount <= 0) { throw new HimallException("提现金额不能小于等于0!"); } if (string.IsNullOrWhiteSpace(openid) && applyType == CommonModel.UserWithdrawType.WeiChat.GetHashCode()) { openid = Core.Helper.WebHelper.GetCookie(CookieKeysCollection.HIMALL_USER_OpenID); } if (string.IsNullOrWhiteSpace(nickname) && applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode()) { throw new HimallException("数据异常,真实姓名不可为空!"); } if (!string.IsNullOrWhiteSpace(openid) && applyType == CommonModel.UserWithdrawType.WeiChat.GetHashCode()) { openid = Core.Helper.SecureHelper.AESDecrypt(openid, "Mobile"); var siteSetting = SiteSettingApplication.SiteSettings; if (!(string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret))) { string token = AccessTokenContainer.TryGetToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret); var userinfo = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetUserInfo(token, openid); if (userinfo != null) { nickname = userinfo.nickname; } } } if (string.IsNullOrWhiteSpace(openid)) { throw new HimallException("数据异常,OpenId或收款账号不可为空!"); } Himall.Entities.ApplyWithDrawInfo model = new Himall.Entities.ApplyWithDrawInfo() { ApplyAmount = amount, ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = CurrentUser.Id, OpenId = openid, NickName = nickname, ApplyType = (CommonModel.UserWithdrawType)applyType }; _iMemberCapitalService.AddWithDrawApply(model); return(Json(new { success = true })); }
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)); }
public ActionResult Center() { var userId = CurrentUser.Id; MemberCenterModel model = new MemberCenterModel(); var statistic = StatisticApplication.GetMemberOrderStatistic(userId, true); var member = _iMemberService.GetMember(userId); model.Member = member; model.AllOrders = statistic.OrderCount; model.WaitingForRecieve = statistic.WaitingForRecieve + OrderApplication.GetWaitConsumptionOrderNumByUserId(UserId); model.WaitingForPay = statistic.WaitingForPay; model.WaitingForDelivery = statistic.WaitingForDelivery; model.WaitingForComments = statistic.WaitingForComments; model.RefundOrders = statistic.RefundCount; model.FavoriteProductCount = FavoriteApplication.GetFavoriteCountByUser(userId); //拼团 model.CanFightGroup = FightGroupApplication.IsOpenMarketService(); model.BulidFightGroupNumber = FightGroupApplication.CountJoiningOrder(userId); model.Capital = MemberCapitalApplication.GetBalanceByUserId(userId); model.CouponsCount = MemberApplication.GetAvailableCouponCount(userId); var integral = MemberIntegralApplication.GetMemberIntegral(userId); model.GradeName = MemberGradeApplication.GetMemberGradeByUserIntegral(integral.HistoryIntegrals).GradeName; model.MemberAvailableIntegrals = MemberIntegralApplication.GetAvailableIntegral(userId); model.CollectionShop = ShopApplication.GetUserConcernShopsCount(userId); model.CanSignIn = _iMemberSignInService.CanSignInByToday(userId); model.SignInIsEnable = _iMemberSignInService.GetConfig().IsEnable; model.userMemberInfo = CurrentUser; model.IsOpenRechargePresent = SiteSettings.IsOpenRechargePresent; model.DistributionOpenMyShopShow = SiteSettings.DistributorRenameOpenMyShop; model.DistributionMyShopShow = SiteSettings.DistributorRenameMyShop; if (PlatformType == PlatformType.WeiXin) { //分销 model.IsShowDistributionOpenMyShop = SiteSettings.DistributionIsEnable; var duser = DistributionApplication.GetDistributor(CurrentUser.Id); if (duser != null && duser.DistributionStatus != (int)DistributorStatus.UnApply) { model.IsShowDistributionOpenMyShop = false; //拒绝的分销员显示“我要开店” if (duser.DistributionStatus == (int)DistributorStatus.Refused || duser.DistributionStatus == (int)DistributorStatus.UnAudit) { model.IsShowDistributionOpenMyShop = true && SiteSettings.DistributionIsEnable; } model.IsShowDistributionMyShop = true && SiteSettings.DistributionIsEnable; if (duser.DistributionStatus == (int)DistributorStatus.NotAvailable || duser.DistributionStatus == (int)DistributorStatus.Refused || duser.DistributionStatus == (int)DistributorStatus.UnAudit) { model.IsShowDistributionMyShop = false; } } } _iMemberService.AddIntegel(member); //给用户加积分//执行登录后初始化相关操作 return(View(model)); }