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); }
/// <summary> /// 侧边我的资产 /// </summary> /// <returns></returns> public ActionResult MyAsset() { MyAssetViewModel result = new Models.MyAssetViewModel(); result.MyCouponCount = 0; result.isLogin = CurrentUser != null; ViewBag.isLogin = result.isLogin ? "true" : "false"; //用户积分 result.MyMemberIntegral = result.isLogin ? MemberIntegralApplication.GetAvailableIntegral(CurrentUser.Id) : 0; //关注商品 result.MyConcernsProducts = result.isLogin ? _iProductService.GetUserAllConcern(CurrentUser.Id, 10) : new List <Entities.FavoriteInfo>(); //优惠卷 var coupons = result.isLogin ? _iCouponService.GetAllUserCoupon(CurrentUser.Id).ToList() : new List <UserCouponInfo>(); coupons = coupons == null ? new List <UserCouponInfo>() : coupons; result.MyCoupons = coupons; result.MyCouponCount += result.MyCoupons.Count(); //红包 result.MyShopBonus = ShopBonusApplication.GetShopBounsByUser(CurrentUser.Id); result.MyCouponCount += result.MyShopBonus.Count(); //浏览的商品 var browsingPro = result.isLogin ? BrowseHistrory.GetBrowsingProducts(10, CurrentUser == null ? 0 : CurrentUser.Id) : new List <ProductBrowsedHistoryModel>(); result.MyBrowsingProducts = browsingPro; ViewBag.Keyword = SiteSettings.Keyword; return(View(result)); }
//领取优惠券 public object PostAcceptCoupon(CouponAcceptCouponModel value) { CheckUserLogin(); long vshopId = value.vshopId; long couponId = value.couponId; var couponService = ServiceProvider.Instance <ICouponService> .Create; var couponInfo = couponService.GetCouponInfo(couponId); if (couponInfo.EndTime < DateTime.Now) { //已经失效 return(ErrorResult("优惠券已经过期.", 2)); } CouponRecordQuery crQuery = new CouponRecordQuery(); crQuery.CouponId = couponId; crQuery.UserId = CurrentUser.Id; QueryPageModel <CouponRecordInfo> pageModel = couponService.GetCouponRecordList(crQuery); if (couponInfo.PerMax != 0 && pageModel.Total >= couponInfo.PerMax) { //达到个人领取最大张数 return(ErrorResult("达到个人领取最大张数,不能再领取.", 3)); } crQuery = new CouponRecordQuery() { CouponId = couponId }; pageModel = couponService.GetCouponRecordList(crQuery); if (pageModel.Total >= couponInfo.Num) { //达到领取最大张数 return(ErrorResult("此优惠券已经领完了.", 4)); } if (couponInfo.ReceiveType == CouponInfo.CouponReceiveType.IntegralExchange) { var integral = MemberIntegralApplication.GetAvailableIntegral(CurrentUserId); if (integral < couponInfo.NeedIntegral) { return(ErrorResult("积分不足 " + couponInfo.NeedIntegral.ToString(), 5)); } } CouponRecordInfo couponRecordInfo = new CouponRecordInfo() { CouponId = couponId, UserId = CurrentUser.Id, UserName = CurrentUser.UserName, ShopId = couponInfo.ShopId }; couponService.AddCouponRecord(couponRecordInfo); return(SuccessResult("", 1)); }
// GET: Web/UserIntegral public ActionResult Index(int?type, int pageSize = 10, int pageNo = 1) { var model = _iMemberIntegralService.GetIntegralChangeRule(); ViewBag.IntegralPerMoney = model == null ? 0 : model.IntegralPerMoney; ViewBag.Integral = MemberIntegralApplication.GetAvailableIntegral(CurrentUser.Id); Mall.Entities.MemberIntegralInfo.IntegralType?integralType = null; if (type.HasValue) { integralType = (Mall.Entities.MemberIntegralInfo.IntegralType)type.Value; } var query = new IntegralRecordQuery() { IntegralType = integralType, UserId = CurrentUser.Id, PageNo = pageNo, PageSize = pageSize }; var result = _iMemberIntegralService.GetIntegralRecordListForWeb(query); var list = result.Models.Select(item => { var actions = _iMemberIntegralService.GetIntegralRecordAction(item.Id); return(new MemberIntegralRecordInfo { Id = item.Id, UserName = item.UserName, RecordDate = item.RecordDate, Integral = item.Integral, TypeId = item.TypeId, ReMark = GetRemarkFromIntegralType(item.TypeId, actions, item.ReMark) }); }); PagingInfo info = new PagingInfo { CurrentPage = pageNo, ItemsPerPage = pageSize, TotalItems = result.Total }; ViewBag.pageInfo = info; ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; return(View(list)); }
public ActionResult Index(long id) { WeiActivityModel activityModel = WeiActivityApplication.GetActivityModelByBigWheel(id); activityModel.userId = curUserId; activityModel.participationCount = GetParticipationCount(activityModel); consumePoint = activityModel.consumePoint; ViewBag.Integrals = MemberIntegralApplication.GetAvailableIntegral(curUserId); //TODO:改成统一的方式取 Token try { var settings = SiteSettingApplication.SiteSettings; var token = AccessTokenContainer.TryGetToken(settings.WeixinAppId, settings.WeixinAppSecret); var qrTicket = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.Create(token, 86400, 7758259).ticket; ViewBag.QRTicket = qrTicket; } catch { } return(View(activityModel)); }
/// <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 ActionResult Index(long id) { //TODO:改成统一的方式取 Token var settings = SiteSettingApplication.SiteSettings; if (settings.IsOpenH5) { var token = AccessTokenContainer.TryGetAccessToken(settings.WeixinAppId, settings.WeixinAppSecret); SceneHelper helper = new SceneHelper(); var qrTicket = QrCodeApi.Create(token, 86400, 7758258, Senparc.Weixin.MP.QrCode_ActionName.QR_LIMIT_SCENE, null).ticket; ViewBag.QRTicket = qrTicket; } WeiActivityModel activityModel = WeiActivityApplication.GetActivityModel(id); activityModel.userId = curUserId; activityModel.winModel = AddWinInfo(activityModel); activityModel.winModel.integrals = MemberIntegralApplication.GetAvailableIntegral(curUserId); activityModel.participationCount = GetParticipationCount(activityModel); consumePoint = activityModel.consumePoint; return(View(activityModel)); }
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)); }
/// <summary> /// 页面缓存时间 /// </summary> // GET: Web/ProductPartial //[OutputCache(Duration = ConstValues.PAGE_CACHE_DURATION)] public ActionResult Header() { ViewBag.Now = DateTime.Now; bool isLogin = CurrentUser != null; var model = new ProductPartialHeaderModel(); model.PlatformCustomerServices = CustomerServiceApplication.GetPlatformCustomerService(true, false); model.isLogin = isLogin ? "true" : "false"; //用户积分 model.MemberIntegral = isLogin ? MemberIntegralApplication.GetAvailableIntegral(CurrentUser.Id) : 0; //关注商品 var user = CurrentUser?.Id ?? 0; var baseCoupons = new List <DisplayCoupon>(); //优惠卷 var usercoupons = _iCouponService.GetAllUserCoupon(user);//优惠卷 var coupons = CouponApplication.GetCouponInfo(usercoupons.Select(p => p.CouponId)); var shops = ShopApplication.GetShops(coupons.Select(p => p.ShopId)); var shopBonus = ShopBonusApplication.GetShopBounsByUser(user);//红包 baseCoupons.AddRange(usercoupons.Select(item => { var coupon = coupons.FirstOrDefault(p => p.Id == item.CouponId); var shop = shops.FirstOrDefault(p => p.Id == coupon.ShopId); return(new DisplayCoupon { Type = CommonModel.CouponType.Coupon, Limit = coupon.OrderAmount, Price = item.Price, ShopId = shop.Id, ShopName = shop.ShopName, EndTime = coupon.EndTime, }); })); baseCoupons.AddRange(shopBonus.Select(p => new DisplayCoupon { Type = CommonModel.CouponType.ShopBonus, EndTime = p.Bonus.DateEnd, Limit = p.Bonus.UsrStatePrice, Price = p.Receive.Price, ShopId = p.Shop.Id, ShopName = p.Shop.ShopName, UseState = p.Bonus.UseState })); model.BaseCoupon = baseCoupons; //广告 var imageAds = _iSlideAdsService.GetImageAds(0).Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.HeadRightAds).ToList(); if (imageAds.Count > 0) { ViewBag.HeadAds = imageAds; } else { ViewBag.HeadAds = _iSlideAdsService.GetImageAds(0).Take(1).ToList(); } //浏览的商品 //var browsingPro = isLogin ? BrowseHistrory.GetBrowsingProducts(10, CurrentUser == null ? 0 : CurrentUser.Id) : new List<ProductBrowsedHistoryModel>(); //model.BrowsingProducts = browsingPro; InitHeaderData(); string html = System.IO.File.ReadAllText(this.Server.MapPath(_templateHeadHtmlFileFullName));//读取模板头部html静态文件内容 ViewBag.Html = html; return(PartialView("~/Areas/Web/Views/Shared/Header.cshtml", model)); }
public ActionResult ShopHeader(long id) { InitHeaderData(); #region 获取店铺的评价统计 var shopStatisticOrderComments = ServiceApplication.Create <IShopService>().GetShopStatisticOrderComments(id); var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault(); var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault(); var sellerDeliverySpeed = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault(); var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault(); var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault(); var sellerDeliverySpeedPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault(); var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault(); var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault(); var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault(); var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault(); var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault(); var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault(); decimal defaultValue = 5; //宝贝与描述 if (productAndDescription != null && productAndDescriptionPeer != null) { ViewBag.ProductAndDescription = productAndDescription.CommentValue; ViewBag.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue; ViewBag.ProductAndDescriptionMin = productAndDescriptionMin.CommentValue; ViewBag.ProductAndDescriptionMax = productAndDescriptionMax.CommentValue; } else { ViewBag.ProductAndDescription = defaultValue; ViewBag.ProductAndDescriptionPeer = defaultValue; ViewBag.ProductAndDescriptionMin = defaultValue; ViewBag.ProductAndDescriptionMax = defaultValue; } //卖家服务态度 if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null) { ViewBag.SellerServiceAttitude = sellerServiceAttitude.CommentValue; ViewBag.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue; ViewBag.SellerServiceAttitudeMax = sellerServiceAttitudeMax.CommentValue; ViewBag.SellerServiceAttitudeMin = sellerServiceAttitudeMin.CommentValue; } else { ViewBag.SellerServiceAttitude = defaultValue; ViewBag.SellerServiceAttitudePeer = defaultValue; ViewBag.SellerServiceAttitudeMax = defaultValue; ViewBag.SellerServiceAttitudeMin = defaultValue; } //卖家发货速度 if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null) { ViewBag.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue; ViewBag.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue; ViewBag.SellerDeliverySpeedMax = sellerDeliverySpeedMax.CommentValue; ViewBag.sellerDeliverySpeedMin = sellerDeliverySpeedMin.CommentValue; } else { ViewBag.SellerDeliverySpeed = defaultValue; ViewBag.SellerDeliverySpeedPeer = defaultValue; ViewBag.SellerDeliverySpeedMax = defaultValue; ViewBag.sellerDeliverySpeedMin = defaultValue; } #endregion #region 微店二维码 var vshop = ServiceApplication.Create <IVShopService>().GetVShopByShopId(id); string vshopUrl = ""; var curUrl = CurrentUrlHelper.CurrentUrlNoPort(); if (vshop != null) { vshopUrl = curUrl + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + vshop.Id; ViewBag.VShopQR = CreateQR(vshop.StrLogo, vshopUrl); } else { vshopUrl = curUrl + "/m-" + PlatformType.WeiXin.ToString(); ViewBag.VShopQR = CreateQR(null, vshopUrl); } #endregion ViewBag.ShopName = ServiceApplication.Create <IShopService>().GetShop(id).ShopName; var user = CurrentUser?.Id ?? 0; bool isLogin = CurrentUser != null; var model = new ProductPartialHeaderModel(); model.ShopId = id; model.isLogin = isLogin ? "true" : "false"; //用户积分 model.MemberIntegral = isLogin ? MemberIntegralApplication.GetAvailableIntegral(CurrentUser.Id) : 0; var baseCoupons = new List <DisplayCoupon>(); //优惠卷 var usercoupons = _iCouponService.GetAllUserCoupon(user);//优惠卷 var coupons = CouponApplication.GetCouponInfo(usercoupons.Select(p => p.CouponId)); var shops = ShopApplication.GetShops(coupons.Select(p => p.ShopId)); var shopBonus = ShopBonusApplication.GetShopBounsByUser(user);//红包 baseCoupons.AddRange(usercoupons.Select(item => { var coupon = coupons.FirstOrDefault(p => p.Id == item.CouponId); var shop = shops.FirstOrDefault(p => p.Id == coupon.ShopId); return(new DisplayCoupon { Type = CommonModel.CouponType.Coupon, Limit = coupon.OrderAmount, Price = item.Price, ShopId = shop.Id, ShopName = shop.ShopName, EndTime = coupon.EndTime, }); })); baseCoupons.AddRange(shopBonus.Select(p => new DisplayCoupon { Type = CommonModel.CouponType.ShopBonus, EndTime = p.Bonus.DateEnd, Limit = p.Bonus.UsrStatePrice, Price = p.Receive.Price, ShopId = p.Shop.Id, ShopName = p.Shop.ShopName, UseState = p.Bonus.UseState })); model.BaseCoupon = baseCoupons; //浏览的商品 //var browsingPro = isLogin ? BrowseHistrory.GetBrowsingProducts(10, CurrentUser == null ? 0 : CurrentUser.Id) : new List<ProductBrowsedHistoryModel>(); //model.BrowsingProducts = browsingPro; InitHeaderData(); setTheme();//主题设置 ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; return(PartialView("~/Areas/Web/Views/Shared/ShopHeader.cshtml", model)); }