Пример #1
0
        /// <summary>
        /// 用户收藏的店铺
        /// </summary>
        /// <param name="pageNo"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public object GetUserCollectionShop(int pageNo = 1, int pageSize = 8)
        {
            CheckUserLogin();
            if (CurrentUser != null)
            {
                var model = ServiceProvider.Instance <IShopService> .Create.GetUserConcernShops(CurrentUser.Id, pageNo, pageSize);

                var result = model.Models.Select(item =>
                {
                    var shop  = ShopApplication.GetShop(item.ShopId);
                    var vShop = VshopApplication.GetVShopByShopId(item.ShopId);
                    return(new
                    {
                        //Id = item.Id,
                        Id = vShop?.Id ?? 0,
                        ShopId = item.ShopId,
                        Logo = vShop == null ? HimallIO.GetRomoteImagePath(shop.Logo) : HimallIO.GetRomoteImagePath(vShop.Logo),
                        Name = shop.ShopName,
                        Status = shop.ShopStatus,
                        ConcernTime = item.Date,
                        ConcernTimeStr = item.Date.ToString("yyyy-MM-dd"),
                        ConcernCount = FavoriteApplication.GetFavoriteShopCountByShop(item.ShopId)
                    });
                });
                return(new { success = true, data = result });
            }
            else
            {
                return(new Result {
                    success = false, msg = "未登录"
                });
            }
        }
Пример #2
0
        protected override void OnActionExecuting(System.Web.Mvc.ActionExecutingContext filterContext)
        {
            ViewBag.AreaName = string.Format("m-{0}", PlatformType.ToString());
            ViewBag.Logo     = SiteSettings.Logo;
            ViewBag.SiteName = SiteSettings.SiteName;
            //区分平台还是商家
            var MAppType = WebHelper.GetCookie(CookieKeysCollection.MobileAppType);
            var MVshopId = WebHelper.GetCookie(CookieKeysCollection.HIMALL_VSHOPID);

            if (MAppType == string.Empty)
            {
                if (filterContext.HttpContext.Request["shop"] != null)
                {//微信菜单中是否存在店铺ID
                    MAppType = filterContext.HttpContext.Request["shop"].ToString();
                    long shopid = 0;
                    if (long.TryParse(MAppType, out shopid))
                    {//记录当前微店(从微信菜单进来,都带有shop参数)
                        var vshop = VshopApplication.GetVShopByShopId(shopid) ?? new Entities.VShopInfo()
                        {
                        };
                        WebHelper.SetCookie(CookieKeysCollection.HIMALL_VSHOPID, vshop.Id.ToString());
                    }
                    WebHelper.SetCookie(CookieKeysCollection.MobileAppType, MAppType);
                }
            }
            ViewBag.MAppType = MAppType;
            ViewBag.MVshopId = MVshopId;
            if (!filterContext.IsChildAction && !filterContext.HttpContext.Request.IsAjaxRequest())
            {
                //统计代码
                StatisticApplication.StatisticPlatVisitUserCount();
            }
            base.OnActionExecuting(filterContext);
        }
Пример #3
0
        /// <summary>
        /// 取积分优惠券
        /// </summary>
        /// <param name="page"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetIntegralCoupon(int pageNo = 1, int pageSize = 10)
        {
            QueryPageModel <CouponInfo> coupons = CouponApplication.GetIntegralCoupons(pageNo, pageSize);

            Mapper.CreateMap <CouponInfo, CouponGetIntegralCouponModel>();
            QueryPageModel <CouponGetIntegralCouponModel> result = new QueryPageModel <CouponGetIntegralCouponModel>();

            result.Total = coupons.Total;
            if (result.Total > 0)
            {
                var datalist = coupons.Models.ToList();

                var objlist = new List <CouponGetIntegralCouponModel>();
                foreach (var item in datalist)
                {
                    var tmp = Mapper.Map <CouponGetIntegralCouponModel>(item);
                    tmp.ShowIntegralCover = Core.HimallIO.GetRomoteImagePath(item.IntegralCover);
                    var vshopobj = VshopApplication.GetVShopByShopId(tmp.ShopId);
                    if (vshopobj != null)
                    {
                        tmp.VShopId = vshopobj.Id;
                        //优惠价封面为空时,取微店Logo,微店Logo为空时,取商城微信Logo
                        if (string.IsNullOrWhiteSpace(tmp.ShowIntegralCover))
                        {
                            if (!string.IsNullOrWhiteSpace(vshopobj.WXLogo))
                            {
                                tmp.ShowIntegralCover = Core.HimallIO.GetRomoteImagePath(vshopobj.WXLogo);
                            }
                        }
                    }
                    if (string.IsNullOrWhiteSpace(tmp.ShowIntegralCover))
                    {
                        var siteset = SiteSettingApplication.SiteSettings;
                        tmp.ShowIntegralCover = Core.HimallIO.GetRomoteImagePath(siteset.WXLogo);
                    }
                    objlist.Add(tmp);
                }
                result.Models = objlist.ToList();
            }
            return(JsonResult <dynamic>(new { total = result.Total, Data = result.Models }));
        }
Пример #4
0
        public ActionResult Detail(long id)
        {
            var    topic   = TopicApplication.GetTopic(id);
            string tmppath = VTemplateHelper.GetTemplatePath(id.ToString(), VTemplateClientTypes.WapSpecial);

            tmppath = "~" + tmppath;
            string viewpath = tmppath + "Skin-HomePage.cshtml";

            if (topic != null)
            {//判空处理
                ViewBag.Title = "专题-" + topic.Name;
            }
            else
            {
                throw new Himall404();
            }
            VTemplateHelper.DownloadTemplate(id.ToString(), VTemplateClientTypes.WapSpecial);
            ViewBag.ShopId = topic.ShopId;
            var vshop = VshopApplication.GetVShopByShopId(topic.ShopId);

            ViewBag.VshopId = vshop == null ? 0 : vshop.Id;
            return(View(viewpath, topic));
        }
Пример #5
0
        public object GetUserCounponList()
        {
            CheckUserLogin();
            var service        = ServiceProvider.Instance <ICouponService> .Create;
            var vshop          = ServiceProvider.Instance <IVShopService> .Create;
            var userCouponList = service.GetUserCouponList(CurrentUser.Id);
            var shopBonus      = GetBonusList();

            if (userCouponList != null || shopBonus != null)
            {
                //优惠券
                var couponlist = new Object();
                if (userCouponList != null)
                {
                    couponlist = userCouponList.ToArray().Select(a => new
                    {
                        UserId      = a.UserId,
                        ShopId      = a.ShopId,
                        CouponId    = a.CouponId,
                        Price       = a.Price,
                        PerMax      = a.PerMax,
                        OrderAmount = a.OrderAmount,
                        Num         = a.Num,
                        StartTime   = a.StartTime.ToString(),
                        EndTime     = a.EndTime.ToString(),
                        CreateTime  = a.CreateTime.ToString(),
                        CouponName  = a.CouponName,
                        UseStatus   = a.UseStatus,
                        UseTime     = a.UseTime.HasValue ? a.UseTime.ToString() : null,
                        VShop       = GetVShop(a.ShopId),
                        ShopName    = a.ShopName,
                        Remark      = a.Remark,
                        UseArea     = a.UseArea
                    });
                }
                else
                {
                    couponlist = null;
                }
                //代金红包
                var userBonus = new List <dynamic>();
                if (shopBonus != null)
                {
                    userBonus = shopBonus.Select(item =>
                    {
                        var Price = item.Price;

                        var bonusService = ServiceProvider.Instance <IShopBonusService> .Create;
                        var grant        = bonusService.GetGrant(item.BonusGrantId);
                        var bonus        = bonusService.GetShopBonus(grant.ShopBonusId);
                        var shop         = ShopApplication.GetShop(bonus.ShopId);
                        var vShop        = VshopApplication.GetVShopByShopId(shop.Id);

                        var showOrderAmount = bonus.UsrStatePrice > 0 ? bonus.UsrStatePrice : item.Price;
                        if (bonus.UseState != ShopBonusInfo.UseStateType.FilledSend)
                        {
                            showOrderAmount = item.Price;
                        }

                        var Logo     = string.Empty;
                        long VShopId = 0;
                        if (vShop != null)
                        {
                            Logo    = Core.HimallIO.GetRomoteImagePath(vShop.StrLogo);
                            VShopId = vShop.Id;
                        }

                        var State = (int)item.State;
                        if (item.State != ShopBonusReceiveInfo.ReceiveState.Use && bonus.DateEnd < DateTime.Now)
                        {
                            State = (int)ShopBonusReceiveInfo.ReceiveState.Expired;
                        }
                        var BonusDateEnd    = bonus.BonusDateEnd.ToString("yyyy-MM-dd");
                        dynamic obj         = new System.Dynamic.ExpandoObject();
                        obj.Price           = Price;
                        obj.ShowOrderAmount = showOrderAmount;
                        obj.Logo            = Logo;
                        obj.VShopId         = VShopId;
                        obj.State           = State;
                        obj.BonusDateEnd    = BonusDateEnd;
                        obj.DateEnd         = bonus.DateEnd;
                        obj.ShopName        = shop.ShopName;
                        return(obj);
                    }).ToList();
                }
                else
                {
                    shopBonus = null;
                }
                //优惠券
                int NoUseCouponCount = 0;
                int UseCouponCount   = 0;
                if (userCouponList != null)
                {
                    NoUseCouponCount = userCouponList.Count(item => (item.EndTime > DateTime.Now && item.UseStatus == CouponRecordInfo.CounponStatuses.Unuse));
                    UseCouponCount   = userCouponList.Count() - NoUseCouponCount;
                }
                //红包
                int NoUseBonusCount = 0;
                int UseBonusCount   = 0;
                if (shopBonus != null)
                {
                    NoUseBonusCount = userBonus.Count(r => r.State == (int)ShopBonusReceiveInfo.ReceiveState.NotUse && r.DateEnd > DateTime.Now);
                    UseBonusCount   = userBonus.Count() - NoUseBonusCount;
                }

                int UseCount    = UseCouponCount + UseBonusCount;
                int NotUseCount = NoUseCouponCount + NoUseBonusCount;

                var result = new
                {
                    success    = true,
                    NoUseCount = NotUseCount,
                    UserCount  = UseCount,
                    Coupon     = couponlist,
                    Bonus      = userBonus
                };
                return(result);
            }
            else
            {
                throw new Himall.Core.HimallException("没有领取记录!");
            }
        }
        /// <summary>
        /// 为已登录过的用户(存在cookie),绑定OpenId
        /// </summary>
        /// <param name="filterContext"></param>
        /// <returns></returns>
        bool BindOpenIdToUser(ActionExecutingContext filterContext)
        {
            bool end = true;

            //处理手动退出后不自动登录
            string actlogout = WebHelper.GetCookie(CookieKeysCollection.Mall_ACTIVELOGOUT);

            //分析当前平台类型,并创建对应的登录接口
            IMobileOAuth imobileOauth = null;

            switch (PlatformType)
            {
            case Core.PlatformType.WeiXin:
                imobileOauth = new WeixinOAuth();
                break;
            }

            string normalLoginUrl = string.Format("/m-{0}/Login/Entrance?returnUrl={1}", PlatformType.ToString(), WebUtility.UrlEncode(filterContext.HttpContext.Request.Headers["Referer"].ToString()));

            if (imobileOauth != null && GetRequestType(filterContext.HttpContext.Request) == Core.PlatformType.WeiXin)//找到了支持的登录接口
            {
                //可能的待跳转用户授权地址
                string redirectUrl;
                //string strShopid = WebHelper.GetCookie(CookieKeysCollection.Mall_SHOP);
                //long shopid = string.IsNullOrEmpty(strShopid) ? 0 : UserCookieEncryptHelper.Decrypt(strShopid, "Mobile");
                var    settings  = new Entities.WXshopInfo();
                string strShopid = filterContext.HttpContext.Request.Query["shop"].ToString();
                var    AppidType = Entities.MemberOpenIdInfo.AppIdTypeEnum.Normal;
                if (!string.IsNullOrEmpty(strShopid))
                {
                    Log.Warn(strShopid + ":" + filterContext.HttpContext.Request.Headers["Referer"].ToString());
                    long shopid = 0;
                    bool isLong = long.TryParse(strShopid, out shopid);
                    if (shopid > 0)
                    {
                        settings = VshopApplication.GetVShopSetting(shopid);
                    }
                }
                else
                {
                    Log.Warn(filterContext.HttpContext.Request.Headers["Referer"].ToString());
                }

                if (string.IsNullOrEmpty(settings.AppId) || string.IsNullOrEmpty(settings.AppSecret))
                {
                    settings = new Entities.WXshopInfo()
                    {
                        AppId     = SiteSettings.WeixinAppId,
                        AppSecret = SiteSettings.WeixinAppSecret,
                        Token     = SiteSettings.WeixinToken
                    };
                    AppidType = Entities.MemberOpenIdInfo.AppIdTypeEnum.Payment;//是平台Appid,可以作为付款(微信支付)
                }

                //获取当前用户信息
                var userInfo = imobileOauth.GetUserInfo_bequiet(filterContext, out redirectUrl, settings);

                if (string.IsNullOrWhiteSpace(redirectUrl))                              //待跳转地址为空,说明已经经过了用户授权页面
                {
                    end = false;                                                         //不再中断当前action
                    if (userInfo != null && !string.IsNullOrWhiteSpace(userInfo.OpenId)) //用户信息不为空并且OpenId不为空,说明用户已经授权
                    {
                        if (AppidType == Entities.MemberOpenIdInfo.AppIdTypeEnum.Payment)
                        {//记录平台公众号对应的OpenId
                            var curMenberOpenId = Core.Helper.SecureHelper.AESEncrypt(userInfo.OpenId, "Mobile");
                            WebHelper.SetCookie(CookieKeysCollection.Mall_USER_OpenID, curMenberOpenId);
                        }

                        //Mall.Core.Log.Debug("BindOpenIdToUser LoginProvider=" + userInfo.LoginProvider);
                        //Mall.Core.Log.Debug("BindOpenIdToUser OpenId=" + userInfo.OpenId);
                        //Mall.Core.Log.Debug("BindOpenIdToUser UnionId=" + userInfo.UnionId);
                        //检查是否已经有用户绑定过该OpenId
                        Entities.MemberInfo existUser = null;
                        //existUser = member.GetMemberByUnionId(userInfo.LoginProvider, userInfo.UnionId);
                        if (existUser == null)
                        {
                            if (actlogout != "1")
                            {
                                //existUser = member.GetMemberByOpenId(userInfo.LoginProvider, userInfo.OpenId);
                                existUser = MemberApplication.GetMemberByUnionId(userInfo.UnionId);
                            }
                        }
                        if (existUser != null)
                        {
                            #region 如它已冻结了则直接跳到登录页
                            if (existUser.Disabled)
                            {
                                var result = Redirect(normalLoginUrl);
                                end = false;
                                return(end);
                            }
                            #endregion
                            if (!string.IsNullOrEmpty(strShopid))
                            {
                                base.SetUserLoginCookie(existUser.Id);
                                Application.MemberApplication.UpdateLastLoginDate(existUser.Id);
                            }
                        }
                        else//未绑定过,则绑定当前用户
                        {
                            MemberApplication.BindMember(CurrentUser.Id, "Mall.Plugin.OAuth.WeiXin", userInfo.OpenId, AppidType, userInfo.Sex, userInfo.Headimgurl, unionid: userInfo.UnionId);
                            //end = false;//不再中断当前action
                        }
                    }
                }
                else
                {//立即跳转到用户授权页面
                    var result = Redirect(redirectUrl);
                    filterContext.Result = result;
                }
            }
            else
            {
                end = false;
            }
            return(end);
        }
        /// <summary>
        /// 处理普通页面请求的情况
        /// </summary>
        /// <param name="filterContext"></param>
        /// <returns>是否中断当前action提前结束</returns>
        bool ProcessInvalidUser_NormalRequest(ActionExecutingContext filterContext)
        {
            bool end = true;
            //处理手动退出后不自动登录
            string actlogout = WebHelper.GetCookie(CookieKeysCollection.Mall_ACTIVELOGOUT);

            //分析当前平台类型,并创建对应的登录接口
            IMobileOAuth imobileOauth = null;

            switch (PlatformType)
            {
            case Core.PlatformType.WeiXin:
                imobileOauth = new WeixinOAuth();
                break;
            }
            string normalLoginUrl = string.Format("/m-{0}/Login/Entrance?returnUrl={1}", PlatformType.ToString(), WebUtility.UrlEncode(filterContext.HttpContext.Request.GetDisplayUrl().ToString()));

            if (imobileOauth != null && GetRequestType(filterContext.HttpContext.Request) == Core.PlatformType.WeiXin)//找到了支持的登录接口
            {
                //可能的待跳转用户授权地址

                var    settings = new Entities.WXshopInfo();
                string redirectUrl;
                //string strShopid = WebHelper.GetCookie(CookieKeysCollection.Mall_SHOP);
                //long shopid = string.IsNullOrEmpty(strShopid) ? 0 : UserCookieEncryptHelper.Decrypt(strShopid, "Mobile");

                string strShopid = filterContext.HttpContext.Request.Query["shop"].ToString();
                var    AppidType = MemberOpenIdInfo.AppIdTypeEnum.Normal;
                if (!string.IsNullOrEmpty(strShopid))
                {
                    long shopid = 0;
                    bool isLong = long.TryParse(strShopid, out shopid);
                    if (shopid > 0)
                    {
                        settings = VshopApplication.GetVShopSetting(shopid);
                    }
                }

                if (string.IsNullOrEmpty(settings.AppId) || string.IsNullOrEmpty(settings.AppSecret))
                {
                    settings = new Entities.WXshopInfo()
                    {
                        AppId     = SiteSettings.WeixinAppId,
                        AppSecret = SiteSettings.WeixinAppSecret,
                        Token     = SiteSettings.WeixinToken
                    };
                    AppidType = MemberOpenIdInfo.AppIdTypeEnum.Payment;//是平台Appid,可以作为付款(微信支付)
                }

                //获取当前用户信息
                var userInfo = imobileOauth.GetUserInfo(filterContext, out redirectUrl, settings);
                if (string.IsNullOrWhiteSpace(redirectUrl))                              //待跳转地址为空,说明已经经过了用户授权页面
                {
                    if (userInfo != null && !string.IsNullOrWhiteSpace(userInfo.OpenId)) //用户信息不为空并且OpenId不为空,说明用户已经授权
                    {
                        if (AppidType == MemberOpenIdInfo.AppIdTypeEnum.Payment)
                        {
                            var curMenberOpenId = Core.Helper.SecureHelper.AESEncrypt(userInfo.OpenId, "Mobile");
                            WebHelper.SetCookie(CookieKeysCollection.Mall_USER_OpenID, curMenberOpenId);
                        }
                        //检查是否已经有用户绑定过该OpenId
                        //Mall.Core.Log.Debug("InvalidUser LoginProvider=" + userInfo.LoginProvider);
                        //Mall.Core.Log.Debug("InvalidUser OpenId=" + userInfo.OpenId);
                        //Mall.Core.Log.Debug("InvalidUser UnionId=" + userInfo.UnionId);
                        Entities.MemberInfo existUser = null;
                        //existUser = ServiceHelper.Create<IMemberService>().GetMemberByUnionId(userInfo.LoginProvider, userInfo.UnionId);
                        if (existUser == null)
                        {
                            if (actlogout != "1")
                            {
                                //existUser = ServiceHelper.Create<IMemberService>().GetMemberByOpenId(userInfo.LoginProvider, userInfo.OpenId);
                                existUser = MemberApplication.GetMemberByUnionId(userInfo.UnionId);
                            }
                        }

                        if (existUser != null)//已经有用户绑定过,直接标识为该用户
                        {
                            #region 如它已冻结了则直接跳到登录页
                            if (existUser.Disabled)
                            {
                                var result = Redirect(normalLoginUrl);
                                end = false;
                                return(end);
                            }
                            #endregion
                            base.SetUserLoginCookie(existUser.Id);
                            Application.MemberApplication.UpdateLastLoginDate(existUser.Id);
                            var isBind = MessageApplication.IsOpenBindSms(existUser.Id);
                            if (!isBind)
                            {
                                var result = Redirect(string.Format("/m-{0}/Member/BindPhone", PlatformType.ToString()));
                                filterContext.Result = result;
                            }
                        }
                        else//未绑定过,则跳转至登录绑定页面
                        {
                            normalLoginUrl = string.Format("/m-{0}/Login/Entrance?openId={1}&serviceProvider={2}&nickName={3}&realName={4}&headimgurl={5}&returnUrl={6}&AppidType={7}&unionid={8}&sex={9}&city={10}&province={11}&country={12}",
                                                           PlatformType.ToString(),
                                                           userInfo.OpenId,
                                                           "Mall.Plugin.OAuth.WeiXin",//使用同微信登录插件一致的名称, 以此保证微信信任与微信商城登录用户信息统一
                                                           WebUtility.UrlEncode(userInfo.NickName),
                                                           WebUtility.UrlEncode(userInfo.RealName),
                                                           WebUtility.UrlEncode(userInfo.Headimgurl),
                                                           WebUtility.UrlEncode(filterContext.HttpContext.Request.Headers["Referer"].ToString()),
                                                           AppidType,
                                                           userInfo.UnionId,
                                                           userInfo.Sex,
                                                           userInfo.City,
                                                           userInfo.Province,
                                                           userInfo.Country
                                                           );
                            //跳转至登录绑定页面
                            var result = Redirect(normalLoginUrl);
                            filterContext.Result = result;
                        }
                    }
                    else//用户未授权,或者无法获取用户授权
                    {
                        //用户未授权,则跳转至普通登录页面
                        var result = Redirect(normalLoginUrl);
                        filterContext.Result = result;
                    }
                }
                else
                {//立即跳转到用户授权页面
                    var result = Redirect(redirectUrl);
                    filterContext.Result = result;
                }
            }
            else
            {//未找到对应的用户授权实现机制,则跳转至普通登录页面
                var result = Redirect(normalLoginUrl);
                filterContext.Result = result;
            }
            return(end);
        }
Пример #8
0
        public object GetIndexData(string openId = "")
        {
            //轮播图
            dynamic result  = new System.Dynamic.ExpandoObject();
            var     slidads = SlideApplication.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.AppGifts).ToList();

            foreach (var item in slidads)
            {
                item.ImageUrl = MallIO.GetRomoteImagePath(item.ImageUrl);
            }
            result.SlideAds = slidads;

            //大转盘刮刮卡
            var malllist = new List <IntegralMallAdInfo>();
            var robj     = GiftApplication.GetAdInfo(IntegralMallAdInfo.AdActivityType.Roulette, IntegralMallAdInfo.AdShowPlatform.APP);

            if (robj != null)
            {
                //robj.LinkUrl = Request.RequestUri.Scheme + "://" + Request.RequestUri.Authority + "/m-wap/BigWheel/index/" + robj.ActivityId;
                robj.LinkUrl = "/m-wap/BigWheel/index/" + robj.ActivityId;
                malllist.Add(robj);
            }
            var cobj = GiftApplication.GetAdInfo(IntegralMallAdInfo.AdActivityType.ScratchCard, IntegralMallAdInfo.AdShowPlatform.APP);

            if (cobj != null)
            {
                //cobj.LinkUrl = Request.RequestUri.Scheme + "://" + Request.RequestUri.Authority + "/m-wap/ScratchCard/index/" + cobj.ActivityId;
                cobj.LinkUrl = "/m-wap/ScratchCard/index/" + cobj.ActivityId;
                malllist.Add(cobj);
            }
            result.WeiActives = malllist;

            //首页礼品
            GiftQuery query = new GiftQuery();

            query.skey     = "";
            query.status   = Mall.Entities.GiftInfo.GiftSalesStatus.Normal;
            query.PageSize = 4;
            query.PageNo   = 1;
            QueryPageModel <GiftModel> gifts = GiftApplication.GetGifts(query);

            result.HomeGiftses  = gifts.Models.ToList();
            result.HasMoreGifts = gifts.Total > 4;
            foreach (var item in result.HomeGiftses)
            {
                item.DefaultShowImage = MallIO.GetRomoteImagePath(item.GetImage(ImageSize.Size_350));
            }

            //积分优惠券
            var coupons = CouponApplication.GetIntegralCoupons(1, 3);

            //   Mapper.CreateMap<CouponInfo, CouponGetIntegralCouponModel>();
            if (coupons.Models.Count > 0)
            {
                var datalist = coupons.Models.ToList();
                var objlist  = new List <CouponGetIntegralCouponModel>();
                foreach (var item in datalist)
                {
                    var tmp = item.Map <CouponGetIntegralCouponModel>();
                    tmp.ShowIntegralCover = MallIO.GetRomoteImagePath(item.IntegralCover);
                    var vshopobj = VshopApplication.GetVShopByShopId(tmp.ShopId);
                    if (vshopobj != null)
                    {
                        tmp.VShopId = vshopobj.Id;
                        //优惠价封面为空时,取微店Logo,微店Logo为空时,取商城微信Logo
                        if (string.IsNullOrWhiteSpace(tmp.ShowIntegralCover))
                        {
                            if (!string.IsNullOrWhiteSpace(vshopobj.WXLogo))
                            {
                                tmp.ShowIntegralCover = MallIO.GetRomoteImagePath(vshopobj.WXLogo);
                            }
                        }
                    }
                    if (string.IsNullOrWhiteSpace(tmp.ShowIntegralCover))
                    {
                        var siteset = SiteSettingApplication.SiteSettings;
                        tmp.ShowIntegralCover = MallIO.GetRomoteImagePath(siteset.WXLogo);
                    }
                    objlist.Add(tmp);
                }
                result.IntegralCoupons        = objlist.ToList();
                result.HasMoreIntegralCoupons = coupons.Total > 3;
            }

            result.HasLogined = false;

            //用户积分与等级
            if (CurrentUser != null)
            {
                //登录后处理会员积分
                var userInte  = MemberIntegralApplication.GetMemberIntegral(CurrentUser.Id);
                var userGrade = MemberGradeApplication.GetMemberGradeByUserIntegral(userInte.HistoryIntegrals);
                result.MemberAvailableIntegrals = userInte.AvailableIntegrals;
                result.MemberGradeName          = userGrade.GradeName;
                result.HasLogined = true;
            }
            return(Json(result));
        }
Пример #9
0
        public JsonResult GetCartProducts()
        {
            var memberId  = CurrentUser?.Id ?? 0;
            var cartItems = CartApplication.GetCartItems(memberId);
            var vshops    = VshopApplication.GetVShopsByShopIds(cartItems.Select(p => p.Shop.Id));
            var products  = cartItems.Select(item =>
            {
                var sku     = item.Sku;
                var product = item.Product;
                var shop    = item.Shop;
                var vshop   = vshops.FirstOrDefault(p => p.ShopId == shop.Id);

                var skuDetails = string.Empty;
                if (!string.IsNullOrWhiteSpace(sku.Size))
                {
                    skuDetails += sku.SizeAlias + ":" + sku.Size + "&nbsp;&nbsp;";
                }
                if (!string.IsNullOrWhiteSpace(sku.Color))
                {
                    skuDetails += sku.ColorAlias + ":" + sku.Color + "&nbsp;&nbsp;";
                }
                if (!string.IsNullOrWhiteSpace(sku.Version))
                {
                    skuDetails += sku.VersionAlias + ":" + sku.Version + "&nbsp;&nbsp;";
                }


                return(new
                {
                    cartItemId = item.ItemId,
                    skuId = sku.Id,
                    id = product.Id,
                    imgUrl = Himall.Core.HimallIO.GetProductSizeImage(product.RelativePath, 1, (int)ImageSize.Size_150),
                    name = product.ProductName,
                    price = sku.SalePrice,
                    count = item.Quantity,
                    shopId = shop.Id,
                    vshopId = vshop == null ? 0 : vshop.Id,
                    shopName = shop.ShopName,
                    shopLogo = vshop == null ? "" : vshop.Logo,
                    productstatus = item.IsLimit ? 0 : (sku.Stock <= 0 ? ProductInfo.ProductSaleStatus.InStock.GetHashCode() : product.SaleStatus.GetHashCode()),
                    status = item.IsLimit ? 1 : ProductManagerApplication.GetProductShowStatus(product, sku.Map <DTO.SKU>(), 1),   // 0:正常;1:已失效;2:库存不足;3:已下架;
                    Size = sku.Size,
                    Color = sku.Color,
                    Version = sku.Version,
                    ColorAlias = sku.ColorAlias,
                    SizeAlias = sku.SizeAlias,
                    VersionAlias = sku.VersionAlias,
                    skuDetails = skuDetails,
                    AddTime = item.AddTime,
                    minMath = ProductManagerApplication.GetProductLadderMinMath(product.Id)
                });
            }).OrderBy(p => p.status).ThenByDescending(o => o.AddTime).ToList();

            #region 门店购物车
            var  discount         = CurrentUser?.MemberDiscount ?? 1;
            var  branchCartHelper = new BranchCartHelper();
            long userId           = 0;
            if (CurrentUser != null)
            {
                userId = CurrentUser.Id;
            }
            var Branchcart     = branchCartHelper.GetCartNoCache(userId, 0);
            var shopBranchList = Branchcart.Items.Where(x => x.ShopBranchId > 0).Select(x => x.ShopBranchId).ToList();
            shopBranchList = shopBranchList.GroupBy(x => x).Select(x => x.First()).ToList();
            Dictionary <long, long> buyedCounts = null;
            if (userId > 0)
            {
                buyedCounts = new Dictionary <long, long>();
                buyedCounts = OrderApplication.GetProductBuyCount(userId, Branchcart.Items.Select(x => x.ProductId));
            }

            var branchProducts = PackageCartProducts(Branchcart, discount, true);
            var sbProducts     = branchProducts.OrderBy(p => p.status).ThenByDescending(item => item.AddTime);
            var shopBranchCart = sbProducts.GroupBy(item => item.shopBranchId);
            #endregion

            var cartModel = new { products = products, amount = products.Sum(item => item.price * item.count), totalCount = products.Sum(item => item.count), shopBranchCart = shopBranchCart };
            return(SuccessResult <dynamic>(data: cartModel));
        }
Пример #10
0
        private List <CartProductModel> PackageCartProducts(Himall.Entities.ShoppingCartInfo cart, decimal discount, bool isBranch = false)
        {
            List <CartProductModel> products = new List <CartProductModel>();
            var limitProducts = LimitTimeApplication.GetPriceByProducrIds(cart.Items.Select(e => e.ProductId).ToList());//限时购价格
            var groupCart     = cart.Items.Where(item => item.ShopBranchId == 0).Select(c =>
            {
                var cItem   = new Himall.Entities.ShoppingCartItem();
                var skuInfo = _iProductService.GetSku(c.SkuId);
                if (skuInfo != null)
                {
                    cItem = c;
                }
                return(cItem);
            }).GroupBy(i => i.ProductId).ToList();

            foreach (var item in cart.Items)
            {
                var                        product       = ProductManagerApplication.GetProduct(item.ProductId);
                var                        shop          = _iShopService.GetShop(product.ShopId);
                DTO.ShopBranch             shopbranch    = null;
                Entities.ShopBranchSkuInfo shopbranchsku = null;
                if (item.ShopBranchId > 0)
                {
                    shopbranch    = ShopBranchApplication.GetShopBranchById(item.ShopBranchId);
                    shopbranchsku = ShopBranchApplication.GetSkusByIds(item.ShopBranchId, new List <string> {
                        item.SkuId
                    }).FirstOrDefault();
                }

                if (null != shop)
                {
                    var vshop = VshopApplication.GetVShopByShopId(shop.Id);
                    var sku   = ProductManagerApplication.GetSKU(item.SkuId);
                    if (sku == null)
                    {
                        continue;
                    }
                    //处理限时购、会员折扣价格
                    var prod      = limitProducts.FirstOrDefault(e => e.ProductId == item.ProductId);
                    var prodPrice = sku.SalePrice;
                    if (prod != null && !isBranch)
                    {
                        prodPrice = prod.MinPrice;
                    }
                    else
                    {
                        if (shop.IsSelf)
                        {//官方自营店才计算会员折扣
                            prodPrice = sku.SalePrice * discount;
                        }
                    }
                    #region 阶梯价--张宇枫
                    //阶梯价
                    if (product.IsOpenLadder)
                    {
                        var quantity = groupCart.Where(i => i.Key == item.ProductId).ToList().Sum(cartitem => cartitem.Sum(i => i.Quantity));
                        prodPrice = ProductManagerApplication.GetProductLadderPrice(item.ProductId, quantity);
                        if (shop.IsSelf)
                        {
                            prodPrice = prodPrice * discount;
                        }
                    }
                    #endregion
                    var    typeInfo     = TypeApplication.GetProductType(product.TypeId);
                    string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                    if (product != null)
                    {
                        colorAlias   = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias;
                        sizeAlias    = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias;
                        versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias;
                    }
                    if (sku != null)
                    {
                        #region 正在参加限时抢购商品在购物车失效 TDO:ZYF
                        var isLimit = false;
                        //门店商品,在参加限时购,也可以正常购买
                        var limit = LimitTimeApplication.GetLimitTimeMarketItemByProductId(item.ProductId);
                        if (limit != null && !isBranch)
                        {
                            isLimit = limit.Status == Entities.FlashSaleInfo.FlashSaleStatus.Ongoing;
                        }
                        #endregion
                        var _tmp = new CartProductModel
                        {
                            cartItemId     = item.Id,
                            skuId          = item.SkuId,
                            id             = product.Id,
                            imgUrl         = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_150),
                            name           = product.ProductName,
                            price          = prodPrice.ToString("F2"),
                            count          = item.Quantity,
                            ShopId         = shop.Id.ToString(),
                            Size           = sku.Size,
                            Color          = sku.Color,
                            Version        = sku.Version,
                            VShopId        = vshop == null ? "0" : vshop.Id.ToString(),
                            ShopName       = shop.ShopName,
                            ShopLogo       = vshop == null ? "" : Core.HimallIO.GetRomoteImagePath(vshop.StrLogo),
                            Url            = Core.HimallIO.GetRomoteImagePath("/m-IOS/product/detail/") + item.ProductId,
                            ProductStatus  = isLimit ? 0 : (sku.Stock <= 0 ? ProductInfo.ProductSaleStatus.InStock.GetHashCode() : product.SaleStatus.GetHashCode()),
                            status         = isLimit ? 1 : ProductManagerApplication.GetProductShowStatus(product, sku, item.Quantity, shopbranch, shopbranchsku),// 0:正常;1:已失效;2:库存不足;3:已下架;
                            ColorAlias     = colorAlias,
                            SizeAlias      = sizeAlias,
                            VersionAlias   = versionAlias,
                            AddTime        = item.AddTime,
                            shopBranchId   = item.ShopBranchId,
                            shopBranchName = null == shopbranch ? "" : shopbranch.ShopBranchName,
                            ShopBranchLogo = null == shopbranch ? "" : Core.HimallIO.GetRomoteImagePath(shopbranch.ShopImages)
                        };
                        products.Add(_tmp);
                    }
                }
            }
            return(products);
        }
Пример #11
0
        public JsonResult GetUserOrders(int?orderStatus, int pageNo, int pageSize = 8)
        {
            if (orderStatus.HasValue && orderStatus == 0)
            {
                orderStatus = null;
            }
            var queryModel = new OrderQuery()
            {
                Status   = (Model.OrderInfo.OrderOperateStatus?)orderStatus,
                UserId   = CurrentUser.Id,
                PageSize = pageSize,
                PageNo   = pageNo
            };

            if (queryModel.Status.HasValue && queryModel.Status.Value == OrderInfo.OrderOperateStatus.WaitReceiving)
            {
                if (queryModel.MoreStatus == null)
                {
                    queryModel.MoreStatus = new List <OrderInfo.OrderOperateStatus>()
                    {
                    };
                }
                queryModel.MoreStatus.Add(OrderInfo.OrderOperateStatus.WaitSelfPickUp);
            }
            if (orderStatus.GetValueOrDefault() == (int)Model.OrderInfo.OrderOperateStatus.Finish)
            {
                queryModel.Commented = false;//只查询未评价的订单
            }
            var orders        = OrderApplication.GetOrders(queryModel);
            var orderItems    = OrderApplication.GetOrderItemsByOrderId(orders.Models.Select(p => p.Id));
            var orderComments = OrderApplication.GetOrderCommentCount(orders.Models.Select(p => p.Id));
            var orderRefunds  = OrderApplication.GetOrderRefunds(orderItems.Select(p => p.Id));
            var products      = ProductManagerApplication.GetProductsByIds(orderItems.Select(p => p.ProductId));
            var vshops        = VshopApplication.GetVShopsByShopIds(products.Select(p => p.ShopId));

            var result = orders.Models.Select(item =>
            {
                var _ordrefobj = _iRefundService.GetOrderRefundByOrderId(item.Id) ?? new OrderRefundInfo {
                    Id = 0
                };
                if (item.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery && item.OrderStatus != OrderInfo.OrderOperateStatus.WaitSelfPickUp)
                {
                    _ordrefobj = new OrderRefundInfo {
                        Id = 0
                    };
                }
                int?ordrefstate = (_ordrefobj == null ? null : (int?)_ordrefobj.SellerAuditStatus);
                ordrefstate     = (ordrefstate > 4 ? (int?)_ordrefobj.ManagerConfirmStatus : ordrefstate);
                return(new
                {
                    id = item.Id,
                    status = item.OrderStatus.ToDescription(),
                    orderStatus = item.OrderStatus,
                    shopname = item.ShopName,
                    orderTotalAmount = item.OrderTotalAmount.ToString("F2"),
                    productCount = item.OrderProductQuantity,
                    commentCount = orderComments.ContainsKey(item.Id) ? orderComments[item.Id] : 0,
                    PaymentType = item.PaymentType,
                    RefundStats = ordrefstate,
                    OrderRefundId = _ordrefobj.Id,
                    OrderType = item.OrderType,
                    PickUp = item.PickupCode,
                    ShopBranchId = item.ShopBranchId,
                    DeliveryType = item.DeliveryType,
                    ShipOrderNumber = item.ShipOrderNumber,
                    EnabledRefundAmount = item.OrderEnabledRefundAmount,
                    itemInfo = orderItems.Where(oi => oi.OrderId == item.Id).Select(a =>
                    {
                        var prodata = products.FirstOrDefault(p => p.Id == a.ProductId);
                        VShop vshop = null;
                        if (prodata != null)
                        {
                            vshop = vshops.FirstOrDefault(vs => vs.ShopId == prodata.ShopId);
                        }
                        if (vshop == null)
                        {
                            vshop = new VShop {
                                Id = 0
                            }
                        }
                        ;

                        var itemrefund = orderRefunds.Where(or => or.OrderItemId == a.Id).FirstOrDefault(d => d.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund);
                        int?itemrefstate = (itemrefund == null ? null : (int?)itemrefund.SellerAuditStatus);
                        itemrefstate = (itemrefstate > 4 ? (int?)itemrefund.ManagerConfirmStatus : itemrefstate);
                        return new
                        {
                            itemid = a.Id,
                            productId = a.ProductId,
                            productName = a.ProductName,
                            image = HimallIO.GetProductSizeImage(a.ThumbnailsUrl, 1, (int)ImageSize.Size_100),
                            count = a.Quantity,
                            price = a.SalePrice,
                            Unit = prodata == null ? "" : prodata.MeasureUnit,
                            vshopid = vshop.Id,
                            color = a.Color,
                            size = a.Size,
                            version = a.Version,
                            RefundStats = itemrefstate,
                            OrderRefundId = (itemrefund == null ? 0 : itemrefund.Id),
                            EnabledRefundAmount = a.EnabledRefundAmount
                        };
                    }),
                    HasAppendComment = HasAppendComment(orderItems.Where(oi => oi.OrderId == item.Id).FirstOrDefault()),
                    CanRefund = (item.OrderStatus == Himall.Model.OrderInfo.OrderOperateStatus.WaitDelivery || item.OrderStatus == Himall.Model.OrderInfo.OrderOperateStatus.WaitSelfPickUp) &&
                                !item.RefundStats.HasValue && item.PaymentType != Himall.Model.OrderInfo.PaymentTypes.CashOnDelivery && item.PaymentType != Himall.Model.OrderInfo.PaymentTypes.None &&
                                (item.FightGroupCanRefund == null || item.FightGroupCanRefund == true) && ordrefstate.GetValueOrDefault().Equals(0)
                });
            });
Пример #12
0
        public JsonResult GetUserOrders(int?orderStatus, int pageNo, int pageSize = 8)
        {
            if (orderStatus.HasValue && orderStatus == 0)
            {
                orderStatus = null;
            }
            var queryModel = new OrderQuery()
            {
                Status   = (Entities.OrderInfo.OrderOperateStatus?)orderStatus,
                UserId   = CurrentUser.Id,
                PageSize = pageSize,
                PageNo   = pageNo,
                IsFront  = true
            };

            if (queryModel.Status.HasValue && queryModel.Status.Value == Entities.OrderInfo.OrderOperateStatus.WaitReceiving)
            {
                if (queryModel.MoreStatus == null)
                {
                    queryModel.MoreStatus = new List <Entities.OrderInfo.OrderOperateStatus>()
                    {
                    };
                }
                queryModel.MoreStatus.Add(Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp);
            }
            if (orderStatus.GetValueOrDefault() == (int)OrderInfo.OrderOperateStatus.Finish)
            {
                queryModel.Commented = false;//只查询未评价的订单
            }
            var orders        = OrderApplication.GetOrders(queryModel);
            var orderItems    = OrderApplication.GetOrderItemsByOrderId(orders.Models.Select(p => p.Id));
            var orderComments = OrderApplication.GetOrderCommentCount(orders.Models.Select(p => p.Id));
            var orderRefunds  = OrderApplication.GetOrderRefunds(orderItems.Select(p => p.Id));
            var products      = ProductManagerApplication.GetProductsByIds(orderItems.Select(p => p.ProductId));
            var vshops        = VshopApplication.GetVShopsByShopIds(products.Select(p => p.ShopId));
            //查询结果的门店ID
            var branchIds = orders.Models.Where(e => e.ShopBranchId > 0).Select(p => p.ShopBranchId).ToList();
            //根据门店ID获取门店信息
            var shopBranchs            = ShopBranchApplication.GetShopBranchByIds(branchIds);
            var orderVerificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(orders.Models.Select(p => p.Id).ToList());
            var result = orders.Models.Select(item =>
            {
                var codes      = orderVerificationCodes.Where(a => a.OrderId == item.Id);
                var _ordrefobj = _iRefundService.GetOrderRefundByOrderId(item.Id) ?? new Entities.OrderRefundInfo {
                    Id = 0
                };
                if (item.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitDelivery && item.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp)
                {
                    _ordrefobj = new Entities.OrderRefundInfo {
                        Id = 0
                    };
                }
                int?ordrefstate   = (_ordrefobj == null ? null : (int?)_ordrefobj.SellerAuditStatus);
                ordrefstate       = (ordrefstate > 4 ? (int?)_ordrefobj.ManagerConfirmStatus : ordrefstate);
                var branchObj     = shopBranchs.FirstOrDefault(e => item.ShopBranchId > 0 && e.Id == item.ShopBranchId);
                string branchName = branchObj == null ? string.Empty : branchObj.ShopBranchName;
                return(new
                {
                    id = item.Id,
                    status = item.OrderStatus.ToDescription(),
                    orderStatus = item.OrderStatus,
                    shopname = item.ShopName,
                    orderTotalAmount = item.OrderTotalAmount,
                    capitalAmount = item.CapitalAmount,
                    productCount = orderItems.Where(oi => oi.OrderId == item.Id).Sum(a => a.Quantity),
                    commentCount = orderComments.ContainsKey(item.Id) ? orderComments[item.Id] : 0,
                    PaymentType = item.PaymentType,
                    RefundStats = ordrefstate,
                    OrderRefundId = _ordrefobj.Id,
                    OrderType = item.OrderType,
                    PickUp = item.PickupCode,
                    ShopBranchId = item.ShopBranchId,
                    ShopBranchName = branchName,
                    DeliveryType = item.DeliveryType,
                    ShipOrderNumber = item.ShipOrderNumber,
                    EnabledRefundAmount = item.OrderEnabledRefundAmount,
                    itemInfo = orderItems.Where(oi => oi.OrderId == item.Id).Select(a =>
                    {
                        var prodata = products.FirstOrDefault(p => p.Id == a.ProductId);
                        VShop vshop = null;
                        if (prodata != null)
                        {
                            vshop = vshops.FirstOrDefault(vs => vs.ShopId == prodata.ShopId);
                        }
                        if (vshop == null)
                        {
                            vshop = new VShop {
                                Id = 0
                            }
                        }
                        ;

                        var itemrefund = orderRefunds.Where(or => or.OrderItemId == a.Id).FirstOrDefault(d => d.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund);
                        int?itemrefstate = (itemrefund == null ? null : (int?)itemrefund.SellerAuditStatus);
                        itemrefstate = (itemrefstate > 4 ? (int?)itemrefund.ManagerConfirmStatus : itemrefstate);
                        return new
                        {
                            itemid = a.Id,
                            productId = a.ProductId,
                            productName = a.ProductName,
                            image = HimallIO.GetProductSizeImage(a.ThumbnailsUrl, 1, (int)ImageSize.Size_100),
                            count = a.Quantity,
                            price = a.SalePrice,
                            Unit = prodata == null ? "" : prodata.MeasureUnit,
                            vshopid = vshop.Id,
                            color = a.Color,
                            size = a.Size,
                            version = a.Version,
                            RefundStats = itemrefstate,
                            OrderRefundId = (itemrefund == null ? 0 : itemrefund.Id),
                            EnabledRefundAmount = a.EnabledRefundAmount
                        };
                    }),
                    HasAppendComment = HasAppendComment(orderItems.Where(oi => oi.OrderId == item.Id).FirstOrDefault()),
                    CanRefund = OrderApplication.CanRefund(item, ordrefstate),
                    IsVirtual = item.OrderType == OrderInfo.OrderTypes.Virtual ? 1 : 0,
                    IsPay = item.PayDate.HasValue ? 1 : 0
                });
            });
Пример #13
0
        /// <summary>
        /// 跳转到手机URL
        /// </summary>
        /// <param name="JumpUrl">为空表示自动处理</param>
        //TODO:DZY[150730] 统一跳转

        /* zjt
         * Url请改为小写 【参数命名规范】
         */
        protected void JumpMobileUrl(ActionExecutingContext filterContext, string url = "")
        {
            string curUrl  = Request.Path.ToString() + Request.QueryString.ToString();
            string jumpUrl = curUrl;
            var    route   = filterContext.RouteData;

            //无路由信息不跳转
            if (route == null)
            {
                return;
            }

            //路由处理
            string controller = route.Values["controller"].ToString().ToLower();
            string action     = route.Values["action"].ToString().ToLower();
            //string area = (route.DataTokens["area"] == null ? "" : route.DataTokens["area"].ToString().ToLower());


            object areaObj = null;
            string area    = "";

            if (filterContext.RouteData.Values.TryGetValue("area", out areaObj))
            {
                area = areaObj.ToString().ToLower();
            }



            if (area == "mobile" || area == "admin")
            {
                return;  //在移动端跳出
            }
            //Web区域跳转移动端
            if (area == "web")
            {
                IsAutoJumpMobile = true;
            }

            if (this.IsAutoJumpMobile && IsMobileTerminal)
            {
                if (Regex.Match(curUrl, @"\/m(\-.*)?").Length < 1)
                {
                    JumpUrlRoute jurdata = GetRouteUrl(controller, action, area, curUrl);
                    //非手机端跳转
                    switch (visitorTerminalInfo.Terminal)
                    {
                    case EnumVisitorTerminal.WeiXin:
                        if (jurdata != null)
                        {
                            jumpUrl = jurdata.WX;
                        }
                        jumpUrl = @"/m-WeiXin" + jumpUrl;
                        break;

                    case EnumVisitorTerminal.IOS:
                        if (jurdata != null)
                        {
                            jumpUrl = jurdata.WAP;
                        }
                        jumpUrl = @"/m-ios" + jumpUrl;
                        break;

                    default:
                        if (jurdata != null)
                        {
                            jumpUrl = jurdata.WAP;
                        }
                        jumpUrl = @"/m-wap" + jumpUrl;
                        break;
                    }

                    #region 参数特殊处理
                    if (jurdata.IsSpecial)
                    {
                        #region 店铺参数转换
                        if (jurdata.PC.ToLower() == @"/shop")
                        {
                            //商家首页参数处理
                            string strid   = route.Values["id"].ToString();
                            long   shopId  = 0;
                            long   vshopId = 0;
                            if (!long.TryParse(strid, out shopId))
                            {
                                shopId = 0;
                            }
                            if (shopId > 0)
                            {
                                var vshop = VshopApplication.GetVShopByShopId(shopId);
                                if (vshop != null)
                                {
                                    vshopId = vshop.Id;
                                }
                            }
                            jumpUrl = jumpUrl + "/" + vshopId.ToString();
                        }
                        #endregion

                        //TODO:LRL 订单页面参数转换

                        /* zjt
                         * TODO可移除,保留注释即可
                         */
                        #region  单页面参数转换
                        if (jurdata.PC.ToLower() == @"/order/submit")
                        {
                            //商家首页参数处理
                            var strcartid = string.Empty;
                            var arg       = route.Values["cartitemids"];
                            if (arg == null)
                            {
                                strcartid = Request.Query["cartitemids"].ToString();
                            }
                            else
                            {
                                strcartid = arg.ToString();
                            }
                            jumpUrl = jumpUrl + "/?cartItemIds=" + strcartid;
                        }
                        #endregion
                    }
                    #endregion

                    if (!string.IsNullOrWhiteSpace(url))
                    {
                        jumpUrl = url;
                    }
                    //string testurl = jumpUrl;
                    //testurl = Request.Url.Scheme + "://" + Request.Url.Authority + testurl;
                    ////页面不存在
                    //if (!IsExistPage(testurl))
                    //{
                    //    if (visitorTerminalInfo.Terminal == EnumVisitorTerminal.WeiXin)
                    //    {
                    //        jumpUrl = @"/m-WeiXin/";
                    //    }
                    //    else
                    //    {
                    //        jumpUrl = @"/m-wap/";
                    //    }

                    //}

                    filterContext.Result = Redirect(jumpUrl);
                }
            }
        }
Пример #14
0
        public object GetCartProduct(string openId = "")
        {
            CheckUserLogin();
            List <CartProductModel> products = new List <CartProductModel>();
            var cartItems = CartApplication.GetCartItems(CurrentUser.Id);
            var vshops    = VshopApplication.GetVShopsByShopIds(cartItems.Select(p => p.Shop.Id));

            foreach (var item in cartItems)
            {
                var sku     = item.Sku;
                var product = item.Product;
                var shop    = item.Shop;
                var vshop   = vshops.FirstOrDefault(p => p.ShopId == shop.Id);

                var _tmp = new CartProductModel
                {
                    CartItemId    = item.ItemId.ToString(),
                    SkuId         = sku.Id,
                    Id            = product.Id.ToString(),
                    ImgUrl        = Core.MallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)ImageSize.Size_150),
                    Name          = product.ProductName,
                    Price         = sku.SalePrice.ToString("F2"),
                    MarketPrice   = product.MarketPrice.ToString("F2"),
                    Count         = item.Quantity.ToString(),
                    ShopId        = shop.Id.ToString(),
                    Size          = sku.Size,
                    Color         = sku.Color,
                    Version       = sku.Version,
                    VShopId       = vshop == null ? "0" : vshop.Id.ToString(),
                    ShopName      = shop.ShopName,
                    ShopLogo      = vshop == null ? "" : Core.MallIO.GetRomoteImagePath(vshop.Logo),
                    Url           = Core.MallIO.GetRomoteImagePath("/m-IOS/product/detail/") + product.Id,
                    ProductStatus = item.ShowStatus,
                    ColorAlias    = sku.ColorAlias,
                    SizeAlias     = sku.SizeAlias,
                    VersionAlias  = sku.VersionAlias,
                    AddTime       = item.AddTime,
                    IsOpenLadder  = product.IsOpenLadder,
                    MaxBuyCount   = product.MaxBuyCount,
                    MinBath       = ProductManagerApplication.GetProductLadderMinMath(product.Id),
                    ActiveId      = item.LimitId
                };
                _tmp.IsValid = (_tmp.ProductStatus == 0) ? 0 : 1;
                products.Add(_tmp);
            }


            products = products.OrderBy(p => p.IsValid).ThenByDescending(item => item.AddTime).ToList();
            var     cartShop  = products.GroupBy(item => item.ShopId);
            decimal prodPrice = 0.0M; //优惠价格
            decimal discount  = 1.0M; //默认折扣为1(没有折扣)

            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
            }
            var productService    = ServiceProvider.Instance <IProductService> .Create;
            var shopService       = ServiceProvider.Instance <IShopService> .Create;
            var vshopService      = ServiceProvider.Instance <IVShopService> .Create;
            var siteSetting       = SiteSettingApplication.SiteSettings;
            var typeservice       = ServiceProvider.Instance <ITypeService> .Create;
            var shopBranchService = ServiceProvider.Instance <IShopBranchService> .Create;
            var shopCartHelper    = ServiceProvider.Instance <IBranchCartService> .Create;
            var branchcart        = shopCartHelper.GetCart(CurrentUser.Id, 0);
            var branchProducts    = PackageCartProducts(branchcart, prodPrice, discount, productService, shopService, shopBranchService, vshopService, typeservice, true);
            var sbProducts        = branchProducts.OrderBy(p => p.Status).ThenByDescending(item => item.AddTime);
            var sbCartShop        = sbProducts.GroupBy(item => item.ShopBranchId);

            return(Json(new { Shop = cartShop, ShopBranch = sbCartShop }));
        }
Пример #15
0
        public object GetCart(long shopBranchId)
        {
            //CheckUserLogin();
            long userId = 0;
            //会员折扣
            decimal discount = 1.0M;//默认折扣为1(没有折扣)

            if (CurrentUser != null)
            {
                userId   = CurrentUser.Id;
                discount = CurrentUser.MemberDiscount;
            }
            var cart       = GetCart(userId, shopBranchId);
            var shopBranch = ShopBranchApplication.GetShopBranchById(shopBranchId);

            if (shopBranch == null)
            {
                throw new MallException("门店库存不足");
            }
            var     stores    = cart.Items.Where(d => d.ShopBranchId > 0).OrderByDescending(d => d.AddTime).Select(d => d.ShopBranchId).GroupBy(d => d);
            decimal prodPrice = 0.0M;//优惠价格
            //var rets = new List<CartStoreModel>();
            var _store = new CartStoreModel();

            _store.ShopBranchId   = shopBranch.Id;
            _store.ShopId         = shopBranch.ShopId;
            _store.ShopBranchName = shopBranch.ShopBranchName;
            _store.Status         = shopBranch.Status.GetHashCode();
            _store.DeliveFee      = shopBranch.DeliveFee;
            _store.DeliveTotalFee = shopBranch.DeliveTotalFee;
            _store.FreeMailFee    = shopBranch.FreeMailFee;
            var product = cart.Items.Where(d => d.ShopBranchId == shopBranch.Id).OrderBy(s => s.Status).ThenByDescending(o => o.AddTime).ToList();

            _store.Products = new List <CartStoreProduct>();
            foreach (var pitem in product)
            {
                var pro           = ProductManagerApplication.GetProduct(pitem.ProductId);
                var shopbranchsku = ShopBranchApplication.GetSkusByIds(_store.ShopBranchId, new List <string> {
                    pitem.SkuId
                }).FirstOrDefault();
                var     shop       = ShopApplication.GetShop(pro.ShopId);
                var     vshop      = VshopApplication.GetVShopByShopId(pro.ShopId);
                DTO.SKU sku        = ProductManagerApplication.GetSKU(pitem.SkuId);
                string  skuDetails = "";
                if (null != shop && sku != null)
                {
                    prodPrice = sku.SalePrice;
                    if (shop.IsSelf)
                    {
                        //官方自营店才计算会员折扣
                        prodPrice = sku.SalePrice * discount;
                    }
                    prodPrice = decimal.Round(prodPrice, 2, MidpointRounding.AwayFromZero);

                    var typeInfo = TypeApplication.GetProductType(pro.TypeId);
                    skuDetails = "";
                    if (!string.IsNullOrWhiteSpace(sku.Size))
                    {
                        if (!string.IsNullOrWhiteSpace(skuDetails))
                        {
                            skuDetails += "、";
                        }
                        skuDetails += sku.Size;
                    }
                    if (!string.IsNullOrWhiteSpace(sku.Color))
                    {
                        if (!string.IsNullOrWhiteSpace(skuDetails))
                        {
                            skuDetails += "、";
                        }
                        skuDetails += sku.Color;
                    }
                    if (!string.IsNullOrWhiteSpace(sku.Version))
                    {
                        if (!string.IsNullOrWhiteSpace(skuDetails))
                        {
                            skuDetails += "、";
                        }
                        skuDetails += sku.Version;
                    }
                    string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                    if (pro != null)
                    {
                        colorAlias   = !string.IsNullOrWhiteSpace(pro.ColorAlias) ? pro.ColorAlias : colorAlias;
                        sizeAlias    = !string.IsNullOrWhiteSpace(pro.SizeAlias) ? pro.SizeAlias : sizeAlias;
                        versionAlias = !string.IsNullOrWhiteSpace(pro.VersionAlias) ? pro.VersionAlias : versionAlias;
                    }
                    var _product = new CartStoreProduct
                    {
                        ShopBranchId = shopBranchId,
                        CartItemId   = pitem.Id,
                        SkuId        = pitem.SkuId,
                        Id           = pro.Id,
                        ProductName  = pro.ProductName,
                        Price        = prodPrice,
                        Count        = pitem.Quantity,
                        Stock        = shopbranchsku == null ? 0 : shopbranchsku.Stock,
                        //阶梯价商品在门店购物车自动下架
                        Status       = ProductManagerApplication.GetProductShowStatus(pro, sku, 1, shopBranch, shopbranchsku),//0:正常;1:冻结;2:库存不足
                        SkuDetails   = skuDetails,
                        ColorAlias   = colorAlias,
                        SizeAlias    = sizeAlias,
                        VersionAlias = versionAlias,
                        Size         = sku.Size,
                        Color        = sku.Color,
                        Version      = sku.Version,
                        AddTime      = pitem.AddTime,
                        DefaultImage = MallIO.GetRomoteProductSizeImage(pro.ImagePath, 1, 500)
                    };
                    _store.Products.Add(_product);
                }
            }
            _store.Amount     = (_store.Products != null && _store.Products.Count > 0) ? _store.Products.Where(x => x.Status == 0).Sum(s => s.Price * s.Count) : 0;
            _store.TotalCount = (_store.Products != null && _store.Products.Count > 0) ? _store.Products.Where(x => x.Status == 0).Sum(s => s.Count) : 0;
            if (_store.Products.Count > 0)
            {//有商品数据,才返回门店信息
                _store.Products = _store.Products.OrderBy(p => p.Status).ThenByDescending(p => p.AddTime).ToList();
                //rets.Add(_store);
            }
            return(Json(_store));
        }