Пример #1
0
        public ActionResult GetReceivers(long Id, int page, int rows)
        {
            CouponRecordQuery query = new CouponRecordQuery();

            query.CouponId = Id;
            query.ShopId   = CurrentSellerManager.ShopId;
            query.PageNo   = page;
            query.PageSize = rows;
            var record  = _iCouponService.GetCouponRecordList(query);
            var coupons = CouponApplication.GetCouponInfo(record.Models.Select(p => p.CouponId));
            var list    = record.Models.Select(item =>
            {
                var coupon = coupons.FirstOrDefault(p => p.Id == item.CouponId);
                return(new
                {
                    Id = item.Id,
                    Price = Math.Round(coupon.Price, 2),
                    CreateTime = coupon.CreateTime.ToString("yyyy-MM-dd"),
                    CouponSN = item.CounponSN,
                    UsedTime = item.UsedTime.HasValue ? item.UsedTime.Value.ToString("yyyy-MM-dd") : "",
                    ReceviceTime = item.CounponTime.ToString("yyyy-MM-dd"),
                    Recever = item.UserName,
                    OrderId = item.OrderId,
                    Status = item.CounponStatus == Entities.CouponRecordInfo.CounponStatuses.Unuse ? (coupon.EndTime < DateTime.Now.Date ? "已过期" : item.CounponStatus.ToDescription()) : item.CounponStatus.ToDescription(),
                });
            });
            var model = new { rows = list, total = record.Total };

            return(Json(model));
        }
Пример #2
0
        /// <summary>
        /// 获取优惠券信息
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetCouponDetail(string openId, int couponId = 0)
        {
            if (couponId <= 0)
            {
                return(Json(ErrorResult <dynamic>("参数错误")));
            }
            CouponInfo coupon = CouponApplication.GetCouponInfo(couponId);

            if (coupon == null)
            {
                return(Json(ErrorResult <dynamic>("错误的优惠券编号")));
            }
            else
            {
                return(JsonResult <dynamic>(new
                {
                    CouponId = coupon.Id,
                    CouponName = coupon.CouponName,
                    Price = coupon.Price,
                    SendCount = coupon.Num,
                    UserLimitCount = coupon.PerMax,
                    OrderUseLimit = Math.Round(coupon.OrderAmount, 2),
                    StartTime = coupon.StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    ClosingTime = coupon.EndTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    CanUseProducts = "",
                    ObtainWay = coupon.ReceiveType,
                    NeedPoint = coupon.NeedIntegral,
                    UseWithGroup = false,
                    UseWithPanicBuying = false,
                    UseWithFireGroup = false,
                    Remark = coupon.Remark,
                    UseArea = coupon.UseArea
                }));
            }
        }
Пример #3
0
        /// <summary>
        /// 获取系统可领取优惠券列表
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetLoadSiteCoupon(string openId = "", int pageSize = 10, int pageIndex = 1, int obtainWay = 1)
        {
            CheckUserLogin();
            CouponRecordQuery query = new CouponRecordQuery();

            query.UserId   = CurrentUser.Id;
            query.PageNo   = pageIndex;
            query.PageSize = pageSize;
            if (obtainWay == 1) //(1=未使用 2=已使用 3=已过期)
            {
                query.Status = 0;
            }
            else if (obtainWay == 2)
            {
                query.Status = 1;
            }
            else
            {
                query.Status = obtainWay;
            }
            var record  = CouponApplication.GetCouponRecordList(query);
            var coupons = CouponApplication.GetCouponInfo(record.Models.Select(p => p.Id));
            var list    = record.Models.Select(
                item => {
                var coupon = coupons.FirstOrDefault(p => p.Id == item.CouponId);
                return(new
                {
                    CouponId = coupon.Id,
                    CouponName = coupon.CouponName,
                    Price = Math.Round(coupon.Price, 2),
                    SendCount = coupon.Num,
                    UserLimitCount = coupon.PerMax,
                    OrderUseLimit = Math.Round(coupon.OrderAmount, 2),
                    StartTime = coupon.StartTime.ToString("yyyy.MM.dd"),
                    ClosingTime = coupon.EndTime.ToString("yyyy.MM.dd"),
                    ObtainWay = coupon.ReceiveType,
                    NeedPoint = coupon.NeedIntegral,
                    UseArea = coupon.UseArea,
                    Remark = coupon.Remark
                });
            });

            return(JsonResult <dynamic>(new { total = record.Total, Data = list }));
        }
Пример #4
0
        /// <summary>
        /// 领取优惠券
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <int> > GetUserCoupon(string openId, long couponId)
        {
            CheckUserLogin();
            bool   status  = true;
            string message = "";
            //long vshopId = vspId;// value.vshopId; 店铺Id
            //long couponId = couponId;// value.couponId; 优惠劵Id
            var couponInfo = CouponApplication.GetCouponInfo(couponId);

            if (couponInfo.EndTime < DateTime.Now)
            {//已经失效
                status  = false;
                message = "优惠券已经过期";
            }
            CouponRecordQuery crQuery = new CouponRecordQuery();

            crQuery.CouponId = couponId;
            crQuery.UserId   = CurrentUser.Id;
            QueryPageModel <CouponRecordInfo> pageModel = CouponApplication.GetCouponRecordList(crQuery);

            if (couponInfo.PerMax != 0 && pageModel.Total >= couponInfo.PerMax)
            {//达到个人领取最大张数
                status  = false;
                message = "达到领取最大张数";
            }
            crQuery = new CouponRecordQuery()
            {
                CouponId = couponId
            };
            pageModel = CouponApplication.GetCouponRecordList(crQuery);
            if (pageModel.Total >= couponInfo.Num)
            {//达到领取最大张数
                status  = false;
                message = "此优惠券已经领完了";
            }
            if (couponInfo.ReceiveType == CouponInfo.CouponReceiveType.IntegralExchange)
            {
                var userInte = MemberIntegralApplication.GetMemberIntegral(CurrentUserId);
                if (userInte.AvailableIntegrals < couponInfo.NeedIntegral)
                {
                    //积分不足
                    status  = false;
                    message = "积分不足 ";
                }
            }
            if (status)
            {
                CouponRecordInfo couponRecordInfo = new CouponRecordInfo()
                {
                    CouponId = couponId,
                    UserId   = CurrentUser.Id,
                    UserName = CurrentUser.UserName,
                    ShopId   = couponInfo.ShopId
                };
                CouponApplication.AddCouponRecord(couponRecordInfo);
                return(JsonResult <int>(msg: "领取成功"));//执行成功
            }
            else
            {
                return(Json(ErrorResult <int>(message)));
            }
        }
        /// <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));
        }
Пример #7
0
        public object GetOrderDetail(long orderId)
        {
            CheckUserLogin();
            var orderService       = ServiceProvider.Instance <IOrderService> .Create;
            var order              = orderService.GetOrder(orderId, CurrentUser.Id);
            var orderitems         = orderService.GetOrderItemsByOrderId(order.Id);
            var orderRefundService = ServiceProvider.Instance <IRefundService> .Create;
            var productService     = ServiceProvider.Instance <IProductService> .Create;
            var coupon             = ServiceProvider.Instance <ICouponService> .Create.GetCouponRecordInfo(order.UserId, order.Id);

            string  couponName  = "";
            decimal couponAmout = 0;

            if (coupon != null)
            {
                var c = CouponApplication.GetCouponInfo(coupon.CouponId);
                couponName  = c.CouponName;
                couponAmout = c.Price;
            }

            //订单信息是否正常
            if (order == null)
            {
                throw new MallException("订单号不存在!");
            }
            dynamic expressTrace = new ExpandoObject();

            //取订单物流信息
            if (!string.IsNullOrWhiteSpace(order.ShipOrderNumber))
            {
                var expressData = ServiceProvider.Instance <IExpressService> .Create.GetExpressData(order.ExpressCompanyName, order.ShipOrderNumber);

                if (expressData.Success)
                {
                    expressData.ExpressDataItems = expressData.ExpressDataItems.OrderByDescending(item => item.Time);//按时间逆序排列
                    expressTrace.traces          = expressData.ExpressDataItems.Select(item => new
                    {
                        acceptTime    = item.Time.ToString("yyyy-MM-dd HH:mm:ss"),
                        acceptStation = item.Content
                    });
                }
            }
            var orderRefunds     = OrderApplication.GetOrderRefunds(orderitems.Select(p => p.Id));
            var isCanOrderReturn = OrderApplication.CanRefund(order);
            //获取订单商品项数据
            var orderDetail = new
            {
                ShopId = order.ShopId,
                EnabledRefundAmount = order.OrderEnabledRefundAmount,
                OrderItems          = orderitems.Select(item =>
                {
                    var productinfo            = productService.GetProduct(item.ProductId);
                    Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(productinfo.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;
                    var itemStatusText         = "";
                    var itemrefund             = orderRefunds.Where(or => or.OrderItemId == item.Id).FirstOrDefault(d => d.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund);
                    int?itemrefstate           = (itemrefund == null ? 0 : (int?)itemrefund.SellerAuditStatus);
                    itemrefstate = (itemrefstate > 4 ? (int?)itemrefund.ManagerConfirmStatus : itemrefstate);
                    if (itemrefund != null)
                    {     //默认为商家处理进度
                        if (itemrefstate == 4)
                        { //商家拒绝,可以再发起申请
                            itemStatusText = "";
                        }
                        else
                        {
                            itemStatusText = "售后处理中";
                        }
                    }
                    if (itemrefstate > 4)
                    {//如果商家已经处理完,则显示平台处理进度
                        if (itemrefstate == 7)
                        {
                            itemStatusText = "退款成功";
                        }
                    }
                    if (productinfo != null)
                    {
                        colorAlias   = (!string.IsNullOrWhiteSpace(productinfo.ColorAlias)) ? productinfo.ColorAlias : colorAlias;//如果商品有自定义规格名称,则用
                        sizeAlias    = (!string.IsNullOrWhiteSpace(productinfo.SizeAlias)) ? productinfo.SizeAlias : sizeAlias;
                        versionAlias = (!string.IsNullOrWhiteSpace(productinfo.VersionAlias)) ? productinfo.VersionAlias : versionAlias;
                    }

                    long activeId   = 0;
                    int activetype  = 0;
                    var limitbuyser = ServiceProvider.Instance <ILimitTimeBuyService> .Create;
                    var limitBuy    = limitbuyser.GetLimitTimeMarketItemByProductId(item.ProductId);
                    if (limitBuy != null)
                    {
                        //salePrice = limitBuy.MinPrice;
                        activeId   = limitBuy.Id;
                        activetype = 1;
                    }
                    else
                    {
                        #region 限时购预热
                        var FlashSale       = limitbuyser.IsFlashSaleDoesNotStarted(item.ProductId);
                        var FlashSaleConfig = limitbuyser.GetConfig();

                        if (FlashSale != null)
                        {
                            TimeSpan flashSaleTime = DateTime.Parse(FlashSale.BeginDate) - DateTime.Now; //开始时间还剩多久
                            TimeSpan preheatTime   = new TimeSpan(FlashSaleConfig.Preheat, 0, 0);        //预热时间是多久
                            if (preheatTime >= flashSaleTime)                                            //预热大于开始
                            {
                                if (!FlashSaleConfig.IsNormalPurchase)
                                {
                                    activeId   = FlashSale.Id;
                                    activetype = 1;
                                }
                            }
                        }
                        #endregion
                    }

                    return(new
                    {
                        Status = itemrefstate,
                        StatusText = itemStatusText,
                        Id = item.Id,
                        SkuId = item.SkuId,
                        ProductId = item.ProductId,
                        Name = item.ProductName,
                        Amount = item.Quantity,
                        Price = item.SalePrice,
                        //ProductImage = "http://" + Url.Request.RequestUri.Host + productService.GetProduct(item.ProductId).GetImage(ProductInfo.ImageSize.Size_100),
                        Image = Core.MallIO.GetRomoteProductSizeImage(productService.GetProduct(item.ProductId).RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_100),
                        color = item.Color,
                        size = item.Size,
                        version = item.Version,
                        IsCanRefund = OrderApplication.CanRefund(order, itemrefstate, itemId: item.Id),
                        ColorAlias = colorAlias,
                        SizeAlias = sizeAlias,
                        VersionAlias = versionAlias,
                        SkuText = colorAlias + ":" + item.Color + ";" + sizeAlias + ":" + item.Size + ";" + versionAlias + ":" + item.Version,
                        EnabledRefundAmount = item.EnabledRefundAmount,
                        ActiveId = activeId,    //活动Id
                        ActiveType = activetype //活动类型(1代表限购,2代表团购,3代表商品预售,4代表限购预售,5代表团购预售)
                    });
                })
            };

            //取拼团订单状态
            var fightGroupOrderInfo = ServiceProvider.Instance <IFightGroupService> .Create.GetFightGroupOrderStatusByOrderId(order.Id);

            #region 门店信息
            var branchInfo = new ShopBranch();
            if (order.ShopBranchId > 0)
            {
                branchInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
            }
            else
            {
                branchInfo = null;
            }
            #endregion

            #region 虚拟订单信息
            VirtualProductInfo virtualProductInfo = null;
            int            validityType = 0; string startDate = string.Empty, endDate = string.Empty;
            List <dynamic> orderVerificationCodes = null;
            List <dynamic> virtualOrderItemInfos  = null;
            bool           isCanRefundVirtual     = false;
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                var orderItemInfo = orderitems.FirstOrDefault();
                if (orderItemInfo != null)
                {
                    virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId);
                    if (virtualProductInfo != null)
                    {
                        validityType = virtualProductInfo.ValidityType ? 1 : 0;
                        if (validityType == 1)
                        {
                            startDate = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd");
                            endDate   = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd");
                        }
                    }
                    var codes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                    {
                        order.Id
                    });
                    orderVerificationCodes = codes.Select(p =>
                    {
                        return(new
                        {
                            VerificationCode = Regex.Replace(p.VerificationCode, @"(\d{4})", "$1 "),
                            Status = p.Status,
                            StatusText = p.Status.ToDescription(),
                            QRCode = GetQRCode(p.VerificationCode)
                        });
                    }).ToList <dynamic>();

                    var virtualItems = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id);
                    virtualOrderItemInfos = virtualItems.Select(p =>
                    {
                        return(new
                        {
                            VirtualProductItemName = p.VirtualProductItemName,
                            Content = ReplaceImage(p.Content, p.VirtualProductItemType),
                            VirtualProductItemType = p.VirtualProductItemType
                        });
                    }).ToList <dynamic>();
                }
            }
            if (order.OrderStatus == Mall.Entities.OrderInfo.OrderOperateStatus.WaitVerification)
            {
                if (virtualProductInfo != null)
                {
                    if (virtualProductInfo.SupportRefundType == 2)
                    {
                        isCanRefundVirtual = true;
                    }
                    else if (virtualProductInfo.SupportRefundType == 1)
                    {
                        if (virtualProductInfo.EndDate.Value > DateTime.Now)
                        {
                            isCanRefundVirtual = true;
                        }
                    }
                    else if (virtualProductInfo.SupportRefundType == 3)
                    {
                        isCanRefundVirtual = false;
                    }

                    if (isCanRefundVirtual)
                    {
                        long num = orderVerificationCodes.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count();
                        if (num > 0)
                        {
                            isCanRefundVirtual = true;
                        }
                        else
                        {
                            isCanRefundVirtual = false;
                        }
                    }
                }
            }
            #endregion
            #region 虚拟订单核销地址信息
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                if (order.ShopBranchId > 0 && branchInfo != null)
                {
                    shipperAddress  = RegionApplication.GetFullName(branchInfo.AddressId) + " " + branchInfo.AddressDetail;
                    shipperTelPhone = branchInfo.ContactPhone;
                }
                else
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(order.ShopId);
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            #endregion
            var bonusmodel = ServiceProvider.Instance <IShopBonusService> .Create.GetGrantByUserOrder(orderId, CurrentUser.Id);

            bool   hasBonus    = bonusmodel != null ? true : false;
            string shareHref   = "";
            string shareTitle  = "";
            string shareDetail = "";
            string shareImg    = "";
            if (hasBonus)
            {
                shareHref = "/m-weixin/ShopBonus/Index/" + ServiceProvider.Instance <IShopBonusService> .Create.GetGrantIdByOrderId(orderId);

                var bonus = ShopBonusApplication.GetBonus(bonusmodel.ShopBonusId);
                shareTitle  = bonus.ShareTitle;
                shareDetail = bonus.ShareDetail;
                shareImg    = MallIO.GetRomoteImagePath(bonus.ShareImg);
            }
            var orderModel = new
            {
                OrderId             = order.Id,
                Status              = (int)order.OrderStatus,
                StatusText          = order.OrderStatus.ToDescription(),
                EnabledRefundAmount = order.OrderEnabledRefundAmount,
                OrderTotal          = order.OrderTotalAmount,
                CapitalAmount       = order.CapitalAmount,
                OrderAmount         = order.ProductTotalAmount,
                DeductionPoints     = 0,
                DeductionMoney      = order.IntegralDiscount,
                //CouponAmount = couponAmout.ToString("F2"),//优惠劵金额
                CouponAmount                = order.DiscountAmount, //优惠劵金额
                CouponName                  = couponName,           //优惠劵名称
                RefundAmount                = order.RefundTotalAmount,
                Tax                         = order.Tax,
                AdjustedFreight             = order.Freight,
                OrderDate                   = order.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"),
                ItemStatus                  = 0,
                ItemStatusText              = "",
                ShipTo                      = order.ShipTo,
                ShipToDate                  = order.ShippingDate.HasValue ? order.ShippingDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
                Cellphone                   = order.CellPhone,
                Address                     = order.DeliveryType == CommonModel.DeliveryType.SelfTake && branchInfo != null ? branchInfo.AddressFullName : (order.RegionFullName + " " + order.Address),
                FreightFreePromotionName    = string.Empty,
                ReducedPromotionName        = string.Empty,
                ReducedPromotionAmount      = order.FullDiscount,
                SentTimesPointPromotionName = string.Empty,
                CanBackReturn               = !string.IsNullOrWhiteSpace(order.PaymentTypeGateway),
                CanCashierReturn            = false,
                PaymentType                 = order.PaymentType.ToDescription(),
                OrderPayAmount              = order.OrderPayAmount,//订单需要第三方支付的金额
                PaymentTypeName             = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName,
                PaymentTypeDesc             = order.PaymentTypeDesc,
                Remark                      = string.IsNullOrEmpty(order.OrderRemarks) ? "" : order.OrderRemarks,
                //InvoiceTitle = order.InvoiceTitle,
                //Invoice = order.InvoiceType.ToDescription(),
                //InvoiceValue = (int)order.InvoiceType,
                //InvoiceContext = order.InvoiceContext,
                //InvoiceCode = order.InvoiceCode,
                ModeName               = order.DeliveryType.ToDescription(),
                LogisticsData          = expressTrace,
                TakeCode               = order.PickupCode,
                LineItems              = orderDetail.OrderItems,
                IsCanRefund            = !(orderDetail.OrderItems.Any(e => e.IsCanRefund == true)) && OrderApplication.CanRefund(order, null, null),
                IsSelfTake             = order.DeliveryType == Mall.CommonModel.DeliveryType.SelfTake ? 1 : 0,
                BranchInfo             = branchInfo,
                DeliveryType           = (int)order.DeliveryType,
                OrderInvoice           = OrderApplication.GetOrderInvoiceInfo(order.Id),
                ValidityType           = validityType,
                StartDate              = startDate,
                EndDate                = endDate,
                OrderVerificationCodes = orderVerificationCodes,
                VirtualOrderItemInfos  = virtualOrderItemInfos,
                IsCanRefundVirtual     = isCanRefundVirtual,
                ShipperAddress         = shipperAddress,
                ShipperTelPhone        = shipperTelPhone,
                OrderType              = order.OrderType,
                JoinStatus             = fightGroupOrderInfo == null ? -2 : fightGroupOrderInfo.JoinStatus,
                HasBonus               = hasBonus,
                ShareHref              = shareHref,
                ShareTitle             = shareTitle,
                ShareDetail            = shareDetail,
                ShareImg               = shareImg,
                ShopName               = order.ShopName
            };

            return(Json(orderModel));
        }
Пример #8
0
        public ActionResult Detail(long id)
        {
            var order      = _iOrderService.GetOrder(id, CurrentUser.Id);//限制到用户
            var orderItems = _iOrderService.GetOrderItemsByOrderId(order.Id);
            //补充商品货号
            var proids      = orderItems.Select(d => d.ProductId);
            var procodelist = ProductManagerApplication.GetProductByIds(proids).Select(d => new { d.Id, d.ProductCode, d.FreightTemplateId }).ToList();

            foreach (var item in orderItems)
            {
                var _tmp = procodelist.Find(d => d.Id == item.ProductId);
                if (_tmp != null)
                {
                    item.ProductCode = _tmp.ProductCode;
                    item.FreightId   = _tmp.FreightTemplateId;
                }
            }
            var service = ServiceApplication.Create <Mall.IServices.IProductService>();
            //  string RegionIdPath = regionService.GetRegionPath(order.RegionId);
            var freightProductGroup = orderItems.GroupBy(a => a.FreightId);

            if (order.DeliveryType != CommonModel.DeliveryType.SelfTake)
            {
                var regionService = ServiceApplication.Create <Mall.IServices.IRegionService>();
                var region        = regionService.GetRegion(order.RegionId);
                int cityId        = 0;
                if (region != null)
                {
                    cityId = region.Id;
                }
                //foreach (var f in freightProductGroup)
                //{
                //    var productIds = f.Select(a => a.ProductId);
                //    var counts = f.Select(a => Convert.ToInt32(a.Quantity));
                //    decimal freight = service.GetFreight(productIds, counts, cityId);

                //    foreach (var item in f)
                //    {
                //        item.Freight = freight;
                //    }
                //}
            }

            ViewBag.freightProductGroup = freightProductGroup;

            ViewBag.Coupon = 0;
            var coupon = _iCouponService.GetCouponRecordInfo(order.UserId, order.Id);
            var bonus  = _iShopBonusService.GetUsedPrice(order.Id, order.UserId);

            if (coupon != null)
            {
                ViewBag.Coupon = CouponApplication.GetCouponInfo(coupon.CouponId).Price;
            }
            else if (bonus > 0)
            {
                ViewBag.Coupon = bonus;
            }

            if (order.OrderType == Entities.OrderInfo.OrderTypes.FightGroup)
            {
                var fgord = _iFightGroupService.GetFightGroupOrderStatusByOrderId(order.Id);
                order.FightGroupOrderJoinStatus = fgord.GetJoinStatus;
                order.FightGroupCanRefund       = fgord.CanRefund;
            }
            //使用OrderListModel
            //   AutoMapper.Mapper.CreateMap<OrderInfo, OrderListModel>();
            // AutoMapper.Mapper.CreateMap<OrderItemInfo, OrderItemListModel>();
            var orderModel = order.Map <OrderListModel>();

            orderModel.OrderItemList = orderItems.Map <IEnumerable <OrderItemListModel> >();
            if (order.ShopBranchId > 0)
            {//补充数据
                var branch = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
                if (branch != null)
                {
                    orderModel.ShopBranchName         = branch.ShopBranchName;
                    orderModel.ShopBranchAddress      = branch.AddressFullName;
                    orderModel.ShopBranchContactPhone = branch.ContactPhone;
                }
            }
            if (order.FightGroupOrderJoinStatus.HasValue)
            {
                orderModel.FightGroupJoinStatus = order.FightGroupOrderJoinStatus.Value;
            }
            orderModel.UserRemark = order.OrderRemarks;
            ViewBag.Keyword       = SiteSettings.Keyword;
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;

            #region 虚拟订单
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                orderModel.OrderVerificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                {
                    order.Id
                });
                orderModel.OrderVerificationCodes.ForEach(a =>
                {
                    a.QRCode = GetQRCode(a.VerificationCode);
                });
                orderModel.VirtualOrderItems = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id);
                if (order.ShopBranchId > 0)//门店订单取门店地址
                {
                    var shopBranch = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
                    if (shopBranch != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(shopBranch.AddressId) + " " + shopBranch.AddressDetail;
                        shipperTelPhone = shopBranch.ContactPhone;
                    }
                }
                else
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(order.ShopId);
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            ViewBag.ShipperAddress  = shipperAddress;
            ViewBag.ShipperTelPhone = shipperTelPhone;
            #endregion
            orderModel.PaymentTypeName = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName;
            //发票信息
            orderModel.OrderInvoice = OrderApplication.GetOrderInvoiceInfo(order.Id);
            return(View(orderModel));
        }