Example #1
0
 public GiftsController()
 {
     _iGiftService        = ServiceApplication.Create <IGiftService>();
     _iGiftsOrderService  = ServiceApplication.Create <IGiftsOrderService>();
     _iMemberService      = ServiceApplication.Create <IMemberService>();
     _iMemberGradeService = ServiceApplication.Create <IMemberGradeService>();
 }
Example #2
0
        public static MvcHtmlString CategoryPath(string path, string pName)
        {
            StringBuilder sb = new StringBuilder("<div class=\"breadcrumb\">");

            try
            {
                pName = pName.Length > 40 ? pName.Substring(0, 40) + " ..." : pName;
                string mian = "", second = "", third = "";
                var    catepath = path.Split('|');
                if (catepath.Length > 0)
                {
                    mian = ServiceApplication.Create <ICategoryService>().GetCategory(long.Parse(catepath[0])).Name;
                }
                if (catepath.Length > 1)
                {
                    second = ServiceApplication.Create <ICategoryService>().GetCategory(long.Parse(catepath[1])).Name;
                }
                if (catepath.Length > 2)
                {
                    third = ServiceApplication.Create <ICategoryService>().GetCategory(long.Parse(catepath[2])).Name;
                }
                sb.AppendFormat("<strong><a href=\"/search/searchAd?cid={0}\">{1}</a></strong>", long.Parse(catepath[0]), mian);
                sb.AppendFormat("<span>{0}{1}&nbsp;&gt;&nbsp;<a href=\"\">{2}</a></span>",
                                string.IsNullOrWhiteSpace(second) ? "" : string.Format("&nbsp;&gt;&nbsp;<a href=\"/search/searchAd?cid={0}\">{1}</a>", long.Parse(catepath[1]), second),
                                string.IsNullOrWhiteSpace(third) ? "" : string.Format("&nbsp;&gt;&nbsp;<a href=\"/search/searchAd?cid={0}\">{1}</a>", long.Parse(catepath[2]), third), pName);

                sb.AppendFormat("</div>");
            }
            catch
            {
                sb.AppendFormat("</div>");
            }
            return(MvcHtmlString.Create(sb.ToString()));
        }
        private string GetFreightStr(long productId, decimal discount, string skuId, int addressId)
        {
            string freightStr = "免运费";
            //if (addressId <= 0)//如果用户的默认收货地址为空,则运费没法计算
            //    return freightStr;
            bool isFree = false;

            if (addressId > 0)
            {
                isFree = ProductManagerApplication.IsFreeRegion(productId, discount, addressId, 1, skuId);//默认取第一个规格
            }
            if (isFree)
            {
                freightStr = "免运费";//卖家承担运费
            }
            else
            {
                decimal freight = ServiceApplication.Create <IProductService>().GetFreight(new List <long>()
                {
                    productId
                }, new List <int>()
                {
                    1
                }, addressId);
                freightStr = freight <= 0 ? "免运费" : string.Format("运费 {0}元", freight.ToString("f2"));
            }
            return(freightStr);
        }
        /// <summary>
        /// 获取用户积分明细
        /// </summary>
        /// <param name="id">用户编号</param>
        /// <param name="type"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNo"></param>
        /// <returns></returns>
        public object GetIntegralRecord(Himall.Entities.MemberIntegralInfo.IntegralType?type = null, int page = 1, int pagesize = 10)
        {
            CheckUserLogin();
            //处理当前用户与id的判断
            var _iMemberIntegralService = ServiceApplication.Create <IMemberIntegralService>();

            var query = new IntegralRecordQuery()
            {
                IntegralType = type, UserId = CurrentUser.Id, PageNo = page, PageSize = pagesize
            };
            var result = _iMemberIntegralService.GetIntegralRecordListForWeb(query);
            var list   = result.Models.Select(item => {
                var actions = _iMemberIntegralService.GetIntegralRecordAction(item.Id);
                return(new UserCenterGetIntegralRecordModel
                {
                    Id = item.Id,
                    RecordDate = item.RecordDate,
                    Integral = item.Integral,
                    TypeId = item.TypeId,
                    ShowType = (item.TypeId == MemberIntegralInfo.IntegralType.WeiActivity) ? item.ReMark : item.TypeId.ToDescription(),
                    ReMark = GetRemarkFromIntegralType(item.TypeId, actions, item.ReMark)
                });
            });
            dynamic pageresult = SuccessResult();

            pageresult.total = result.Total;
            pageresult.data  = list.ToList();
            return(pageresult);
        }
Example #5
0
        /// <summary>
        /// 初始化缓存
        /// </summary>
        public static void InitCache()
        {
            //加载移动端当前首页模版
            var curr = ServiceApplication.Create <ITemplateSettingsService>().GetCurrentTemplate(0);

            Core.Cache.Insert <TemplateVisualizationSettingInfo>(CacheKeyCollection.MobileHomeTemplate("0"), curr);
        }
Example #6
0
        public JsonResult GetExpressData(string expressCompanyName, string shipOrderNumber)
        {
            if (string.IsNullOrWhiteSpace(expressCompanyName) || string.IsNullOrWhiteSpace(shipOrderNumber))
            {
                throw new MallException("错误的订单信息");
            }
            string         kuaidi100Code = ServiceApplication.Create <IExpressService>().GetExpress(expressCompanyName).Kuaidi100Code;
            HttpWebRequest request       = (HttpWebRequest)HttpWebRequest.Create(string.Format("http://www.kuaidi100.com/query?type={0}&postid={1}", kuaidi100Code, shipOrderNumber));

            request.Timeout = 8000;

            string content = "暂时没有此快递单号的信息";

            try
            {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream stream = response.GetResponseStream();
                    System.IO.StreamReader streamReader = new StreamReader(stream, System.Text.Encoding.GetEncoding("UTF-8"));

                    // 读取流字符串内容
                    content = streamReader.ReadToEnd();
                    content = content.Replace("&amp;", "");
                    content = content.Replace("&nbsp;", "");
                    content = content.Replace("&", "");
                }
            }
            catch
            {
            }
            return(Json(content));
        }
Example #7
0
        public ContentResult ShopEnterpriseNotify_Post(string id, string outid)
        {
            Log.Info("[SENP]" + Core.Helper.WebHelper.GetRawUrl());
            id = DecodePaymentId(id);
            string errorMsg = string.Empty;
            string response = string.Empty;
            var    _iOperationLogService = ServiceApplication.Create <IOperationLogService>();
            var    withdrawId            = long.Parse(outid);
            var    withdrawData          = BillingApplication.GetShopWithDrawInfo(withdrawId);

            if (withdrawData == null)
            {
                Log.Info("[ShopEnterpriseNotify_Post]" + id + " ^ " + outid);
                throw new HimallException("参数错误");
            }
            try
            {
                var payment = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id);
                var payInfo = payment.Biz.ProcessEnterprisePayNotify(HttpContext.Request);
                if (withdrawData.Status == Himall.CommonModel.WithdrawStaus.PayPending)
                {
                    BillingApplication.ShopApplyWithDrawCallBack(withdrawId, Himall.CommonModel.WithdrawStaus.Succeed, payInfo, "支付宝提现成功", Request.UserHostAddress, "异步回调");
                }
                response = payment.Biz.ConfirmPayResult();
            }
            catch (Exception ex)
            {
                BillingApplication.ShopApplyWithDrawCallBack(withdrawId, Himall.CommonModel.WithdrawStaus.Fail, null, "支付宝提现失败", Request.UserHostAddress, "异步回调");
                errorMsg = ex.Message;
                Log.Error("ShopEnterpriseNotify_Post", ex);
            }
            return(Content(response));
        }
Example #8
0
 public JsonResult Setting(bool autoAllotOrder)
 {
     try
     {
         ShopApplication.SetAutoAllotOrder(CurrentSellerManager.ShopId, autoAllotOrder);
         ServiceApplication.Create <IOperationLogService>().AddSellerOperationLog(new Entities.LogInfo
         {
             Date        = DateTime.Now,
             Description = string.Format("{0}:订单自动分配到门店", autoAllotOrder ? "开启" : "关闭"),
             IPAddress   = base.Request.HttpContext.Features.Get <IHttpConnectionFeature>()?.RemoteIpAddress.ToString(),
             PageUrl     = "/ShopBranch/Setting",
             UserName    = CurrentSellerManager.UserName,
             ShopId      = CurrentSellerManager.ShopId
         });
         return(Json(new
         {
             success = true
         }));
     }
     catch (Exception e)
     {
         return(Json(new
         {
             success = false,
             msg = e.Message
         }));
     }
 }
Example #9
0
        public JsonResult GetShopInfo(long shopId)
        {
            var shopinfo = ServiceApplication.Create <IShopService>().GetShop(shopId);
            var model    = new { SenderAddress = shopinfo.SenderAddress, SenderPhone = shopinfo.SenderPhone, SenderName = shopinfo.SenderName };

            return(Json(model));
        }
Example #10
0
        public object GetList(int pageNo = 1, int pageSize = 10)
        {
            CheckUserLogin();
            var capitalService = ServiceApplication.Create <IMemberCapitalService>();

            var query = new CapitalDetailQuery
            {
                memberId = CurrentUser.Id,
                PageSize = pageSize,
                PageNo   = pageNo
            };
            var pageMode = capitalService.GetCapitalDetails(query);
            var model    = pageMode.Models.ToList().Select(e => new CapitalDetailModel
            {
                Id            = e.Id,
                Amount        = e.Amount + e.PresentAmount,
                PresentAmount = e.PresentAmount,
                CapitalID     = e.CapitalID,
                CreateTime    = e.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
                SourceData    = e.SourceData,
                SourceType    = e.SourceType,
                Remark        = e.SourceType == CapitalDetailInfo.CapitalDetailType.Brokerage ? GetBrokerageRemark(e) : e.Remark,
                PayWay        = e.Remark
            });
            dynamic result = SuccessResult();

            result.rows  = model;
            result.total = pageMode.Total;

            return(result);
        }
Example #11
0
 /// <summary>
 /// 更改限时购销售量
 /// </summary>
 public static void IncreaseSaleCount(List <long> orderid)
 {
     if (orderid.Count == 1)
     {
         var service = ServiceApplication.Create <ILimitTimeBuyService>();
         service.IncreaseSaleCount(orderid);
     }
 }
Example #12
0
 public object GetPayOrderByIntegral(string orderIds)
 {
     CheckUserLogin();
     var orderIdArr = orderIds.Split(',').Select(item => long.Parse(item));
     var service = ServiceApplication.Create<IOrderService>();
     service.ConfirmZeroOrder(orderIdArr, CurrentUser.Id);
     return SuccessResult();
 }
        public JsonResult GetShopInfo(long sid, long productId = 0)
        {
            string cacheKey = CacheKeyCollection.CACHE_SHOPINFO(sid, productId);

            if (Cache.Exists(cacheKey))
            {
                return(Cache.Get <JsonResult>(cacheKey));
            }

            string  brandLogo    = string.Empty;
            long    brandId      = 0L;
            decimal cashDeposits = 0M;

            if (productId != 0)
            {
                var product = ServiceApplication.Create <IProductService>().GetProduct(productId);
                if (product != null)
                {
                    var brand = ServiceApplication.Create <IBrandService>().GetBrand(product.BrandId);
                    brandLogo = brand == null ? string.Empty : brand.Logo;
                    brandId   = brand == null ? brandId : brand.Id;
                }
            }
            var shop             = ServiceApplication.Create <IShopService>().GetShop(sid);
            var mark             = Framework.ShopServiceMark.GetShopComprehensiveMark(sid);
            var cashDepositsInfo = ServiceApplication.Create <ICashDepositsService>().GetCashDepositByShopId(sid);

            if (cashDepositsInfo != null)
            {
                cashDeposits = cashDepositsInfo.CurrentBalance;
            }

            var cashDepositModel = ServiceApplication.Create <ICashDepositsService>().GetCashDepositsObligation(productId);
            var model            = new
            {
                CompanyName              = shop.CompanyName,
                Id                       = sid,
                PackMark                 = mark.PackMark,
                ServiceMark              = mark.ServiceMark,
                ComprehensiveMark        = mark.ComprehensiveMark,
                Phone                    = shop.CompanyPhone,
                Name                     = shop.ShopName,
                Address                  = ServiceApplication.Create <IRegionService>().GetFullName(shop.CompanyRegionId),
                ProductMark              = 3,
                IsSelf                   = shop.IsSelf,
                BrandLogo                = Core.MallIO.GetImagePath(brandLogo),
                BrandId                  = brandId,
                CashDeposits             = cashDeposits,
                IsSevenDayNoReasonReturn = cashDepositModel.IsSevenDayNoReasonReturn,
                IsCustomerSecurity       = cashDepositModel.IsCustomerSecurity,
                TimelyDelivery           = cashDepositModel.IsTimelyShip
            };
            JsonResult result = Json(model, true);

            Cache.Insert(cacheKey, result, 600);
            return(result);
        }
Example #14
0
        /// <summary>
        /// 获取轮播图
        /// </summary>
        /// <returns></returns>
        public List <Entities.SlideAdInfo> GetSlideAds()
        {
            ISlideAdsService _ISlideAdsService = ServiceApplication.Create <ISlideAdsService>();
            var sql    = _ISlideAdsService.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.AppGifts);
            var result = sql.ToList();

            foreach (var item in result)
            {
                item.ImageUrl = HimallIO.GetRomoteImagePath(item.ImageUrl);
            }
            return(result);
        }
Example #15
0
        public ContentResult EnterpriseNotify_Post(string id, string outid)
        {
            Log.Info("[ENP]" + Core.Helper.WebHelper.GetRawUrl());
            id = DecodePaymentId(id);
            string errorMsg = string.Empty;
            string response = string.Empty;
            var    _iOperationLogService = ServiceApplication.Create <IOperationLogService>();
            var    withdrawId            = long.Parse(outid);
            var    withdrawData          = MemberCapitalApplication.GetApplyWithDrawInfo(withdrawId);

            if (withdrawData == null)
            {
                Log.Info("[EnterpriseNotify]" + id + " ^ " + outid);
                throw new HimallException("参数错误");
            }
            try
            {
                var payment = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id);
                var payInfo = payment.Biz.ProcessEnterprisePayNotify(HttpContext.Request);
                if (withdrawData.ApplyStatus == Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.PayPending)
                {
                    withdrawData.ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess;
                    withdrawData.PayTime     = DateTime.Now;
                    MemberCapitalApplication.ConfirmApplyWithDraw(withdrawData);
                }
                response = payment.Biz.ConfirmPayResult();
            }
            catch (Exception ex)
            {
                //支付失败
                withdrawData.ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail;
                withdrawData.Remark      = "异步通知失败,请查看日志";
                withdrawData.ConfirmTime = DateTime.Now;
                MemberCapitalApplication.ConfirmApplyWithDraw(withdrawData);
                //操作日志
                _iOperationLogService.AddPlatformOperationLog(new Entities.LogInfo
                {
                    Date        = DateTime.Now,
                    Description = string.Format("会员提现审核失败,提现编号:{0}", outid),
                    IPAddress   = Request.UserHostAddress,
                    PageUrl     = "/Pay/EnterpriseNotify",
                    UserName    = "******",
                    ShopId      = 0
                });
                errorMsg = ex.Message;
                Log.Error("EnterpriseNotify_Post", ex);
            }
            return(Content(response));
        }
Example #16
0
        //TODO:DZY[171121]前台没看到调用代码
        public JsonResult LoadProducts(int page, int pageSize)
        {
            var homeProducts = ServiceApplication.Create <IMobileHomeProductsService>().GetMobileHomeProducts(0, Core.PlatformType.WeiXin, page, pageSize);
            var products     = ProductManagerApplication.GetProducts(homeProducts.Models.Select(p => p.ProductId));
            var model        = products.Select(item => new
            {
                name        = item.ProductName,
                id          = item.Id,
                image       = item.GetImage(ImageSize.Size_350),
                price       = item.MinSalePrice,
                marketPrice = item.MarketPrice
            });

            return(Json(model));
        }
Example #17
0
        public void CheckChargeAsync(string orderIds)
        {
            //AsyncManager.OutstandingOperations.Increment();
            int interval       = 200;       //定义刷新间隔为200ms
            int maxWaitingTime = 10 * 1000; //定义最大等待时间为15s

            Task.Factory.StartNew(() =>
            {
                string payStateKey = CacheKeyCollection.PaymentState(orderIds);//获取支付状态缓存键
                int time           = 0;
                while (true)
                {
                    //检查是否已经建立缓存
                    var payStateObj = Cache.Exists(payStateKey);
                    if (!payStateObj)
                    {//没有进入缓存
                     //检查对应订单是否已经支付

                        using (var service = ServiceApplication.Create <IMemberCapitalService>())
                        {
                            var model   = service.GetChargeDetail(long.Parse(orderIds));
                            var payDone = model != null && model.ChargeStatus == Mall.Entities.ChargeDetailInfo.ChargeDetailStatus.ChargeSuccess;
                            Cache.Insert(payStateKey, payDone, 15);//标记支付状态
                        }
                    }

                    //检查缓存的值,如果已支付则直接结束,若未替并小于15秒则阻塞200ms后重复检查,否则直接结束
                    var payState = Cache.Get <bool>(payStateKey);
                    if (payState)
                    {//如果已成功支付,则调用成功
                        //AsyncManager.Parameters["done"] = true;
                        break;
                    }
                    if (time > maxWaitingTime)
                    {//大于15秒
                        //AsyncManager.Parameters["done"] = false;
                        break;
                    }
                    else
                    {
                        time += interval;
                        System.Threading.Thread.Sleep(interval);
                    }
                }
                //AsyncManager.OutstandingOperations.Decrement();
            });
        }
        // GET: Mobile/PortfolioBuy
        public ActionResult ProductDetail(long productId)
        {
            var serivce     = ServiceApplication.Create <ICollocationService>();
            var collocation = serivce.GetCollocationByProductId(productId);

            if (collocation == null)
            {
                return(View());
            }
            var cProducts = serivce.GetProducts(new List <long> {
                collocation.Id
            });
            var allCollSKUs = serivce.GetSKUs(cProducts.Select(p => p.Id).ToList());
            var products    = ProductManagerApplication.GetOnSaleProducts(cProducts.Select(p => p.ProductId).ToList());
            var allSKUs     = ProductManagerApplication.GetSKUByProducts(products.Select(p => p.Id).ToList());

            //移除下架商品
            cProducts = cProducts.Where(p => products.Select(o => o.Id).Contains(p.ProductId)).ToList();

            var result = cProducts.Select(item =>
            {
                var product            = products.FirstOrDefault(p => p.Id == item.ProductId);
                var cSKUs              = allCollSKUs.Where(p => p.ProductId == item.ProductId);
                var skus               = allSKUs.Where(p => p.ProductId == item.ProductId);
                var collocationProduct = new CollocationProducts()
                {
                    DisplaySequence = item.DisplaySequence,
                    IsMain          = item.IsMain,
                    Stock           = skus.Sum(t => t.Stock),
                    ProductName     = product.ProductName,
                    ProductId       = item.ProductId,
                    ColloPid        = item.Id,
                    Image           = Core.MallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_100),
                    IsShowSku       = isShowSku(item.ProductId)
                };
                if (cSKUs != null && cSKUs.Count() > 0)
                {
                    collocationProduct.MaxCollPrice = cSKUs.Max(x => x.Price);
                    collocationProduct.MaxSalePrice = cSKUs.Max(x => x.SkuPirce);
                    collocationProduct.MinCollPrice = cSKUs.Min(x => x.Price);
                    collocationProduct.MinSalePrice = cSKUs.Min(x => x.SkuPirce);
                }
                return(collocationProduct);
            }).Where(p => p.Stock > 0).OrderBy(a => a.DisplaySequence).ToList();

            return(View(result));
        }
Example #19
0
        public void CheckAsync(string orderIds)
        {
            // AsyncManager.OutstandingOperations.Increment();
            int interval       = 200;       //定义刷新间隔为200ms
            int maxWaitingTime = 10 * 1000; //定义最大等待时间为15s

            Task.Factory.StartNew(() =>
            {
                string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", orderIds));   //获取支付状态缓存键
                int time           = 0;
                while (true)
                {
                    //检查是否已经建立缓存
                    var payStateObj = Cache.Exists(payStateKey);
                    if (!payStateObj)
                    {   //没有进入缓存
                        var orderIdArr = orderIds.Split(',').Select(item => long.Parse(item));
                        //检查对应订单是否已经支付

                        using (var service = ServiceApplication.Create <IOrderService>())
                        {
                            var payDone = !service.GetOrders(orderIdArr).Any(item => item.OrderStatus == Entities.OrderInfo.OrderOperateStatus.WaitPay);
                            Cache.Insert(payStateKey, payDone, 15);   //标记支付状态
                        }
                    }

                    //检查缓存的值,如果已支付则直接结束,若未替并小于15秒则阻塞200ms后重复检查,否则直接结束
                    var payState = Cache.Get <bool>(payStateKey);
                    if (payState)
                    {   //如果已成功支付,则调用成功
                        //AsyncManager.Parameters["done"] = true;
                        break;
                    }
                    if (time > maxWaitingTime)
                    {   //大于15秒
                        //  AsyncManager.Parameters["done"] = false;
                        break;
                    }
                    else
                    {
                        time += interval;
                        System.Threading.Thread.Sleep(interval);
                    }
                }
                // AsyncManager.OutstandingOperations.Decrement();
            });
        }
Example #20
0
        /// <summary>
        /// 发货
        /// </summary>
        /// <param name="OrderNO">订单号</param>
        /// <param name="SndStyle">发货方式:圆通,顺丰等</param>
        /// <param name="BillID">发货单号</param>
        /// <returns></returns>
        public string SendOrder(HttpContext context)
        {
            string OrderNO  = context.Request["OrderNO"];
            string SndStyle = context.Request["SndStyle"];
            string BillID   = context.Request["BillID"];

            StringBuilder sb      = new StringBuilder();
            string        OrderId = OrderNO.Trim();

            if (OrderNO.IndexOf(',') > 0)
            {
                return(ExMsg("不支持合并发货,请选择单个订单"));
            }
            long orderId = Convert.ToInt64(OrderId);
            var  order   = ServiceApplication.Create <IOrderService>().GetOrder(orderId);

            if (order == null)
            {
                return(ExMsg("未找到此订单"));
            }
            if (order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitDelivery)
            {
                return(ExMsg("只有待发货状态的订单才能发货!"));
            }
            //if (!CanSendGood(orderId))
            //{
            //    return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Rsp><Result>0</Result><Cause><![CDATA[{拼团完成后订单才可以发货!}]]></Cause></Rsp>";
            //}
            if (string.IsNullOrEmpty(BillID.Trim()) || BillID.Trim().Length > 20)
            {
                return(ExMsg("运单号码不能为空,在1至20个字符之间!"));
            }
            try
            {
                var result = new Result();
                //var returnurl = String.Format("http://{0}/Common/ExpressData/SaveExpressData", Request.RequestUri.Authority);
                //商家发货
                //Application.OrderApplication.SellerSendGood(orderId, order.ShopName, SndStyle, BillID, returnurl);
            }
            catch (Exception ex)
            {
                return(ExMsg(ex.Message));
            }
            return("");
        }
Example #21
0
        public ActionResult EditPersonal(long id = 0)
        {
            if (id == 0)
            {
                return(View(new ShopModel()));
            }
            var shop = _iShopService.GetShop(id);

            ShopPersonal shopPersoal = new ShopPersonal()
            {
                Id                 = shop.Id,
                CompanyAddress     = shop.CompanyAddress,
                CompanyName        = shop.CompanyName,
                CompanyRegion      = ServiceApplication.Create <IRegionService>().GetFullName(shop.CompanyRegionId),
                EndDate            = shop.EndDate.ToString("yyyy-MM-dd"),
                IDCard             = shop.IDCard,
                IDCardUrl          = shop.IDCardUrl,
                IDCardUrl2         = shop.IDCardUrl2,
                NewCompanyRegionId = shop.CompanyRegionId,
                Name               = shop.ShopName
            };
            var obj = ServiceApplication.Create <IShopService>().GetShopGrade(shop.GradeId);

            shopPersoal.ShopGrade = obj == null ? "" : obj.Name;


            var shopGrade = _iShopService.GetShopGrades();
            List <SelectListItem> ShopG = new List <SelectListItem>();

            foreach (var item in shopGrade)
            {
                ShopG.Add(new SelectListItem
                {
                    Selected = item.Id == shop.GradeId,
                    Text     = item.Name,
                    Value    = item.Id.ToString()
                });
            }
            ViewBag.ShopGrade           = ShopG;
            ViewBag.Status              = (int)shop.ShopStatus;
            ViewBag.BankRegionIds       = _iRegionService.GetRegionPath(shop.BankRegionId);
            ViewBag.CompanyRegionIds    = _iRegionService.GetRegionPath(shop.CompanyRegionId);
            ViewBag.BusinessLicenceArea = _iRegionService.GetRegionPath(shop.BusinessLicenceRegionId);
            return(View(shopPersoal));
        }
Example #22
0
        /// <summary>
        /// 获取收货地址
        /// </summary>
        /// <param name="regionId"></param>
        /// <returns></returns>
        private Entities.ShippingAddressInfo GetShippingAddress(long?regionId)
        {
            Entities.ShippingAddressInfo result = null;
            var _iShippingAddressService        = ServiceApplication.Create <IShippingAddressService>();

            if (regionId != null)
            {
                result = _iShippingAddressService.GetUserShippingAddress((long)regionId);
            }
            else
            {
                if (CurrentUser != null)
                {
                    result = _iShippingAddressService.GetDefaultUserShippingAddressByUserId(CurrentUser.Id);
                }
            }
            return(result);
        }
Example #23
0
        public JsonResult SendGift(long id, string expname, string expnum)
        {
            Result result = new Result();

            _iGiftsOrderService.SendGood(id, expname, expnum);

            string host      = CurrentUrlHelper.CurrentUrl();
            var    returnurl = String.Format("{0}/Common/ExpressData/SaveExpressData", host);
            var    key       = SiteSettingApplication.SiteSettings.Kuaidi100Key;

            if (!string.IsNullOrEmpty(key))
            {
                Task.Factory.StartNew(() => ServiceApplication.Create <IExpressService>().SubscribeExpress100(expname, expnum, key, string.Empty, returnurl));
            }
            result.success = true;
            result.status  = 1;
            result.msg     = "发货成功";
            return(Json(result));
        }
        public JsonResult GetSKUInfo(long pId, long colloPid = 0)
        {
            var product = ServiceApplication.Create <IProductService>().GetProduct(pId);
            List <Mall.Entities.CollocationSkuInfo> collProduct = null;

            if (colloPid != 0)
            {
                collProduct = ServiceApplication.Create <ICollocationService>().GetProductColloSKU(pId, colloPid);
            }
            var skuArray = new List <ProductSKUModel>();
            var skus     = ProductManagerApplication.GetSKUs(product.Id);

            foreach (var sku in skus.Where(s => s.Stock > 0))
            {
                var price = sku.SalePrice;
                if (collProduct != null && collProduct.Count > 0)
                {
                    var collsku = collProduct.FirstOrDefault(a => a.SkuID == sku.Id);
                    if (collsku != null)
                    {
                        price = collsku.Price;
                    }
                }
                skuArray.Add(new ProductSKUModel
                {
                    Price = price,
                    SkuId = sku.Id,
                    Stock = sku.Stock
                });
            }
            //foreach (var item in skuArray)
            //{
            //    var str = item.SKUId.Split('_');
            //    item.SKUId = string.Format("{0};{1};{2}", str[1], str[2], str[3]);
            //}
            return(Json(new
            {
                skuArray = skuArray
            }));
        }
Example #25
0
        public JsonResult verificationToCart(long id)
        {
            long buyid = 0;
            bool success = false;

            var iLimitService = ServiceApplication.Create<ILimitTimeBuyService>();
            var ltmbuy = iLimitService.GetLimitTimeMarketItemByProductId(id);
            if (ltmbuy != null)
            {
                buyid = ltmbuy.Id;
            }
            else
            {
                var sku = _iProductService.GetSKUs(id);
                if (sku.ToList().Count == 1 && sku.FirstOrDefault().Id.Contains("0_0_0"))
                {
                    success = true;
                }
            }

            return Json(new { success = success, id = buyid });
        }
Example #26
0
        /// <summary>
        /// 支付完生成红包
        /// </summary>
        public static Dictionary <long, Entities.ShopBonusInfo> GenerateBonus(IEnumerable <long> orderIds, string urlHost)
        {
            var    bonusGrantIds = new Dictionary <long, Entities.ShopBonusInfo>();
            string url           = CurrentUrlHelper.GetScheme() + "://" + urlHost + "/m-weixin/shopbonus/index/";
            var    bonusService  = ServiceApplication.Create <IShopBonusService>();
            var    buyOrders     = ServiceApplication.Create <IOrderService>().GetOrders(orderIds);

            foreach (var o in buyOrders)
            {
                var shopBonus = bonusService.GetByShopId(o.ShopId);
                if (shopBonus == null)
                {
                    continue;
                }
                if (shopBonus.GrantPrice <= o.OrderTotalAmount)
                {
                    long grantid = bonusService.GenerateBonusDetail(shopBonus, o.Id, url);
                    bonusGrantIds.Add(grantid, shopBonus);
                }
            }

            return(bonusGrantIds);
        }
Example #27
0
        public ActionResult Detail(string id)
        {
            LimitTimeBuyDetailModel detailModel = new LimitTimeBuyDetailModel();
            string price = "";

            #region 定义Model和变量

            LimitTimeProductDetailModel model = new LimitTimeProductDetailModel
            {
                MainId = long.Parse(id),
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Product      = new Entities.ProductInfo(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Color        = new CollectionSKU(),
                Size         = new CollectionSKU(),
                Version      = new CollectionSKU()
            };

            FlashSaleModel    market = null;
            Entities.ShopInfo shop   = null;

            long gid = 0, mid = 0;

            #endregion

            #region 商品Id不合法
            if (long.TryParse(id, out mid))
            {
            }
            if (mid == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
            }
            #endregion

            #region 初始化商品和店铺
            //参数是限时购活动ID
            try
            {
                market = _iLimitTimeBuyService.Get(mid);
            }
            catch
            {
                market = null;
            }
            if (market != null)
            {
                switch (market.Status)
                {
                case FlashSaleInfo.FlashSaleStatus.Ended:
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));

                case FlashSaleInfo.FlashSaleStatus.Cancelled:
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
                }

                model.FlashSale = market;
            }
            if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                //可能参数是商品ID
                market = market == null?_iLimitTimeBuyService.GetFlaseSaleByProductId(mid) : market;

                if (market == null)
                {
                    //跳转到404页面
                    return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
                }
                if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
                }
                market = _iLimitTimeBuyService.Get(market.Id);
            }
            model.FlashSale = market;

            if (market != null && (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing || DateTime.Parse(market.EndDate) < DateTime.Now))
            {
                return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
            }

            model.MaxSaleCount = market.LimitCountOfThePeople;
            model.Title        = market.Title;

            shop = _iShopService.GetShop(market.ShopId);

            #endregion

            #region  存在的商品
            if (null == market || market.Id == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            #endregion

            #region 商品描述
            var product = _iProductService.GetProduct(market.ProductId);
            gid = market.ProductId;

            model.Product = product;
            var description = ProductManagerApplication.GetProductDescription(product.Id);
            model.ProductDescription = description.ShowMobileDescription;
            if (description.DescriptionPrefixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(description.DescriptionPrefixId, product.ShopId);
                model.DescriptionPrefix = desc == null ? "" : desc.Content;
            }

            if (description.DescriptiondSuffixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(description.DescriptiondSuffixId, product.ShopId);
                model.DescriptiondSuffix = desc == null ? "" : desc.Content;
            }

            var mark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            model.Shop.Name               = shop.ShopName;
            model.Shop.ProductMark        = CommentApplication.GetProductAverageMark(gid);
            model.Shop.Id                 = product.ShopId;
            model.Shop.FreeFreight        = shop.FreeFreight;
            detailModel.ProductNum        = _iProductService.GetShopOnsaleProducts(product.ShopId);
            detailModel.FavoriteShopCount = _iShopService.GetShopFavoritesCount(product.ShopId);
            if (CurrentUser == null)
            {
                detailModel.IsFavorite     = false;
                detailModel.IsFavoriteShop = false;
            }
            else
            {
                detailModel.IsFavorite = _iProductService.IsFavorite(product.Id, CurrentUser.Id);
                var favoriteShopIds = _iShopService.GetFavoriteShopInfos(CurrentUser.Id).Select(item => item.ShopId).ToArray();//获取已关注店铺
                detailModel.IsFavoriteShop = favoriteShopIds.Contains(product.ShopId);
            }
            #endregion

            #region 店铺分类

            var categories = _iShopCategoryService.GetShopCategory(product.ShopId);
            List <Entities.ShopCategoryInfo> allcate = categories.ToList();
            foreach (var main in allcate.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in allcate.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }

            #endregion

            #region 热门销售

            var sale = _iProductService.GetHotSaleProduct(shop.Id, 5);
            if (sale != null)
            {
                foreach (var item in sale.ToArray())
                {
                    model.HotSaleProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts)
                    });
                }
            }

            #endregion

            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shop.Id, 5);
            if (hot != null)
            {
                foreach (var item in hot.ToArray())
                {
                    model.HotAttentionProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    });
                }
            }
            #endregion

            #region 商品规格

            Entities.TypeInfo typeInfo     = _iTypeService.GetType(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;
            }
            model.ColorAlias   = colorAlias;
            model.SizeAlias    = sizeAlias;
            model.VersionAlias = versionAlias;
            var skus = ProductManagerApplication.GetSKUs(product.Id);
            if (skus.Count > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in skus)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color))
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = skus.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = Core.MallIO.GetImagePath(sku.ShowPic)
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size))
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = skus.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version))
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = skus.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本",
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
                //var min = skus.Where(s => s.Stock >= 0).Min(s => s.SalePrice);
                //var max = skus.Where(s => s.Stock >= 0).Max(s => s.SalePrice);
                //if (min == 0 && max == 0)
                //{
                //    price = product.MinSalePrice.ToString("f2");
                //}
                //else if (max > min)
                //{
                //    price = string.Format("{0}-{1}", min.ToString("f2"), max.ToString("f2"));
                //}
                //else
                //{
                //    price = string.Format("{0}", min.ToString("f2"));
                //}
                price = ProductWebApplication.GetProductPriceStr2(product, skus);//最小价或区间价文本
            }
            detailModel.Price = string.IsNullOrWhiteSpace(price) ? product.MinSalePrice.ToString("f2") : price;
            #endregion

            #region 商品属性
            List <TypeAttributesModel> ProductAttrs = new List <TypeAttributesModel>();
            var prodAttrs = ProductManagerApplication.GetProductAttributes(product.Id);
            foreach (var attr in prodAttrs)
            {
                if (!ProductAttrs.Any(p => p.AttrId == attr.AttributeId))
                {
                    var attribute = _iTypeService.GetAttribute(attr.AttributeId);
                    var values    = _iTypeService.GetAttributeValues(attr.AttributeId);
                    TypeAttributesModel attrModel = new TypeAttributesModel()
                    {
                        AttrId     = attr.AttributeId,
                        AttrValues = new List <TypeAttrValue>(),
                        Name       = attribute.Name
                    };
                    foreach (var attrV in values)
                    {
                        if (prodAttrs.Any(p => p.ValueId == attrV.Id))
                        {
                            attrModel.AttrValues.Add(new TypeAttrValue
                            {
                                Id   = attrV.Id.ToString(),
                                Name = attrV.Value
                            });
                        }
                    }
                    ProductAttrs.Add(attrModel);
                }
                else
                {
                    var attrTemp = ProductAttrs.FirstOrDefault(p => p.AttrId == attr.AttributeId);
                    var values   = _iTypeService.GetAttributeValues(attr.AttributeId);
                    if (!attrTemp.AttrValues.Any(p => p.Id == attr.ValueId.ToString()))
                    {
                        attrTemp.AttrValues.Add(new TypeAttrValue
                        {
                            Id   = attr.ValueId.ToString(),
                            Name = values.FirstOrDefault(a => a.Id == attr.ValueId).Value
                        });
                    }
                }
            }
            detailModel.ProductAttrs = ProductAttrs;
            #endregion

            #region 获取评论、咨询数量

            var comments = CommentApplication.GetCommentsByProduct(product.Id);
            detailModel.CommentCount = comments.Count;

            var consultations = ServiceApplication.Create <IConsultationService>().GetConsultations(gid);

            var total     = comments.Count;
            var niceTotal = comments.Count(item => item.ReviewMark >= 4);
            detailModel.NicePercent   = (int)((niceTotal / (double)total) * 100);
            detailModel.Consultations = consultations.Count();

            if (_iVShopService.GetVShopByShopId(shop.Id) == null)
            {
                detailModel.VShopId = -1;
            }
            else
            {
                detailModel.VShopId = _iVShopService.GetVShopByShopId(shop.Id).Id;
            }
            #endregion

            #region 累加浏览次数、 加入历史记录
            //if (CurrentUser != null)
            //{
            //    BrowseHistrory.AddBrowsingProduct(product.Id, CurrentUser.Id);
            //}
            //else
            //{
            //    BrowseHistrory.AddBrowsingProduct(product.Id);
            //}
            //_iProductService.LogProductVisti(gid);
            #endregion

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(product.ShopId);

            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 && !shop.IsSelf)
            {
                detailModel.ProductAndDescription     = productAndDescription.CommentValue;
                detailModel.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                detailModel.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                detailModel.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                detailModel.ProductAndDescription     = defaultValue;
                detailModel.ProductAndDescriptionPeer = defaultValue;
                detailModel.ProductAndDescriptionMin  = defaultValue;
                detailModel.ProductAndDescriptionMax  = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null && !shop.IsSelf)
            {
                detailModel.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                detailModel.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                detailModel.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                detailModel.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                detailModel.SellerServiceAttitude     = defaultValue;
                detailModel.SellerServiceAttitudePeer = defaultValue;
                detailModel.SellerServiceAttitudeMax  = defaultValue;
                detailModel.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null && !shop.IsSelf)
            {
                detailModel.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                detailModel.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                detailModel.SellerDeliverySpeedMax  = sellerDeliverySpeedMax != null ? sellerDeliverySpeedMax.CommentValue : 0;
                detailModel.sellerDeliverySpeedMin  = sellerDeliverySpeedMin != null ? sellerDeliverySpeedMin.CommentValue : 0;
            }
            else
            {
                detailModel.SellerDeliverySpeed     = defaultValue;
                detailModel.SellerDeliverySpeedPeer = defaultValue;
                detailModel.SellerDeliverySpeedMax  = defaultValue;
                detailModel.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            #region 是否收藏此商品
            if (CurrentUser != null && CurrentUser.Id > 0)
            {
                model.IsFavorite = _iProductService.IsFavorite(product.Id, CurrentUser.Id);
            }
            else
            {
                model.IsFavorite = false;
            }
            #endregion

            long vShopId;
            var  vshopinfo = _iVShopService.GetVShopByShopId(shop.Id);
            if (vshopinfo == null)
            {
                vShopId = -1;
            }
            else
            {
                vShopId = vshopinfo.Id;
            }
            detailModel.VShopId = vShopId;
            model.Shop.VShopId  = vShopId;

            model.VShopLog = _iVShopService.GetVShopLog(model.Shop.VShopId);
            if (string.IsNullOrWhiteSpace(model.VShopLog))
            {
                //throw new Mall.Core.MallException("店铺未开通微店功能");
                model.VShopLog = SiteSettings.WXLogo;
            }
            detailModel.Logined = (null != CurrentUser) ? 1 : 0;
            model.EnabledBuy    = product.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited && DateTime.Parse(market.BeginDate) <= DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now && product.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale;
            int saleCounts = 0;
            saleCounts = market.SaleCount;
            if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) < DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.EndDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                detailModel.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
            }
            else if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.BeginDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                detailModel.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
                saleCounts         = Mall.Core.Helper.TypeHelper.ObjectToInt(product.SaleCounts) + Mall.Core.Helper.TypeHelper.ObjectToInt(product.VirtualSaleCounts);
            }
            ViewBag.DetailModel = detailModel;

            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(market.ShopId);
            ViewBag.CustomerServices = customerServices;

            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            model.IsSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1;                                          //是否显示销量
            model.SaleCount        = saleCounts;                                                                                              //销量
            model.FreightTemplate  = FreightTemplateApplication.GetFreightTemplate(product.FreightTemplateId);
            model.Freight          = FreightTemplateApplication.GetFreightStr(market.ProductId, model.FreightTemplate, CurrentUser, product); //运费或免运费
            model.StockAll         = market.Quantity;

            return(View(model));
        }
        /// <summary>
        /// 拼团活动详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Detail(long id)
        {
            FightGroupActiveModel data = FightGroupApplication.GetActive(id, false);

            if (data == null)
            {
                throw new HimallException("错误的活动信息");
            }
            data.InitProductImages();
            AutoMapper.Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveDetailModel>();

            FightGroupActiveDetailModel model = AutoMapper.Mapper.Map <FightGroupActiveDetailModel>(data);
            decimal discount = 1M;

            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
            }
            ViewBag.Discount = discount;
            var shopInfo = ShopApplication.GetShop(model.ShopId);

            ViewBag.IsSelf = shopInfo.IsSelf;

            //AutoMapper.Mapper.CreateMap<FightGroupActiveModel, FightGroupActiveResult>();
            //var fightGroupData = AutoMapper.Mapper.Map<FightGroupActiveResult>(model);

            model.ShareUrl   = string.Format("{0}/m-{1}/FightGroup/Detail/{2}", CurrentUrlHelper.CurrentUrlNoPort(), "WeiXin", data.Id);
            model.ShareTitle = data.ActiveStatus == FightGroupActiveStatus.WillStart ? "限时限量火拼 即将开始" : "限时限量火拼 正在进行";
            model.ShareImage = data.ProductDefaultImage;
            if (!string.IsNullOrWhiteSpace(model.ShareImage))
            {
                if (model.ShareImage.Substring(0, 4) != "http")
                {
                    model.ShareImage = HimallIO.GetRomoteImagePath(model.ShareImage);
                }
            }

            model.ShareDesc = data.ProductName;
            if (!string.IsNullOrWhiteSpace(data.ProductShortDescription))
            {
                model.ShareDesc += ",(" + data.ProductShortDescription + ")";
            }
            if (model.ProductId > 0)
            {
                //统计商品浏览量、店铺浏览人数
                StatisticApplication.StatisticVisitCount(model.ProductId, model.ShopId);
            }

            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(model.ShopId);

            ViewBag.CustomerServices = customerServices;
            var bonus = ServiceApplication.Create <IShopBonusService>().GetByShopId(model.ShopId);

            if (bonus != null)
            {
                model.BonusCount             = bonus.Count;
                model.BonusGrantPrice        = bonus.GrantPrice;
                model.BonusRandomAmountStart = bonus.RandomAmountStart;
                model.BonusRandomAmountEnd   = bonus.RandomAmountEnd;
            }
            var fullDiscount = FullDiscountApplication.GetOngoingActiveByProductId(id, model.ShopId);

            model.FullDiscount = fullDiscount;

            model.IsSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1;                                //是否显示销量
            model.SaleVolume       = data.ActiveItems.Sum(d => d.BuyCount);                                                         //销量
            model.FreightTemplate  = FreightTemplateApplication.GetFreightTemplate(model.FreightTemplateId);                        //运费模板
            model.FreightStr       = FreightTemplateApplication.GetFreightStr(model.ProductId, model.FreightTemplate, CurrentUser); //运费或免运费

            return(View(model));
        }
        /// <summary>
        /// 获取拼团订单详情
        /// </summary>
        /// <param name="Id">订单Id</param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetFightGroupOrderDetail(long id)
        {
            var userList = new List <FightGroupOrderInfo>();

            var orderDetail = FightGroupApplication.GetFightGroupOrderStatusByOrderId(id);

            //团组活动信息
            orderDetail.UserInfo = new List <UserInfo>();
            var data = FightGroupApplication.GetActive((long)orderDetail.ActiveId, false, true);

            Mapper.CreateMap <FightGroupActiveInfo, FightGroupActiveModel>();
            //规格映射
            Mapper.CreateMap <FightGroupActiveItemInfo, FightGroupActiveItemModel>();

            FightGroupsModel groupsdata = FightGroupApplication.GetGroup(orderDetail.ActiveId, orderDetail.GroupId);

            if (groupsdata == null)
            {
                throw new HimallException("错误的拼团信息");
            }
            if (data != null)
            {
                //商品图片地址修正
                data.ProductDefaultImage = HimallIO.GetRomoteProductSizeImage(data.ProductImgPath, 1, (int)ImageSize.Size_350);
            }
            orderDetail.AddGroupTime = groupsdata.AddGroupTime;
            orderDetail.GroupStatus  = groupsdata.BuildStatus;
            orderDetail.ProductId    = data.ProductId;
            orderDetail.ProductName  = data.ProductName;
            orderDetail.IconUrl      = HimallIO.GetRomoteProductSizeImage(data.ProductImgPath, 1, (int)ImageSize.Size_350);//result.IconUrl;
            orderDetail.thumbs       = HimallIO.GetRomoteProductSizeImage(data.ProductImgPath, 1, (int)ImageSize.Size_100);
            //在使用之后,再修正为绝对路径
            data.ProductImgPath = HimallIO.GetRomoteImagePath(data.ProductImgPath);

            orderDetail.MiniGroupPrice = data.MiniGroupPrice;
            TimeSpan mids = DateTime.Now - (DateTime)orderDetail.AddGroupTime;

            orderDetail.Seconds       = (int)(data.LimitedHour * 3600) - (int)mids.TotalSeconds;
            orderDetail.LimitedHour   = data.LimitedHour.GetValueOrDefault();
            orderDetail.LimitedNumber = data.LimitedNumber.GetValueOrDefault();
            orderDetail.JoinedNumber  = groupsdata.JoinedNumber;
            orderDetail.OverTime      = groupsdata.OverTime.HasValue ? groupsdata.OverTime : orderDetail.AddGroupTime.AddHours((double)orderDetail.LimitedHour);
            if (orderDetail.OverTime.HasValue)
            {
                orderDetail.OverTime = DateTime.Parse(orderDetail.OverTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            //拼装已参团成功的用户
            userList = ServiceProvider.Instance <IFightGroupService> .Create.GetActiveUsers((long)orderDetail.ActiveId, (long)orderDetail.GroupId);

            foreach (var userItem in userList)
            {
                var userInfo = new UserInfo();
                userInfo.Photo    = !string.IsNullOrWhiteSpace(userItem.Photo) ? Core.HimallIO.GetRomoteImagePath(userItem.Photo) : "";
                userInfo.UserName = userItem.UserName;
                userInfo.JoinTime = userItem.JoinTime;
                orderDetail.UserInfo.Add(userInfo);
            }
            //获取团长信息
            var GroupsData = ServiceProvider.Instance <IFightGroupService> .Create.GetGroup(orderDetail.ActiveId, orderDetail.GroupId);

            if (GroupsData != null)
            {
                orderDetail.HeadUserName     = GroupsData.HeadUserName;
                orderDetail.HeadUserIcon     = !string.IsNullOrWhiteSpace(GroupsData.HeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(GroupsData.HeadUserIcon) : "";
                orderDetail.ShowHeadUserIcon = !string.IsNullOrWhiteSpace(GroupsData.ShowHeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(GroupsData.ShowHeadUserIcon) : "";
            }
            //商品评论数
            var product = ServiceProvider.Instance <IProductService> .Create.GetProduct(orderDetail.ProductId);

            var comCount = CommentApplication.GetCommentCountByProduct(product.Id);
            //商品描述

            var ProductDescription = ServiceApplication.Create <IProductService>().GetProductDescription(orderDetail.ProductId);

            if (ProductDescription == null)
            {
                throw new Himall.Core.HimallException("错误的商品编号");
            }

            string description = ProductDescription.ShowMobileDescription.Replace("src=\"/Storage/", "src=\"" + Core.HimallIO.GetRomoteImagePath("/Storage/") + "/");//商品描述

            return(JsonResult <dynamic>(new
            {
                OrderDetail = orderDetail,
                ComCount = comCount,
                ProductDescription = description
            }));
        }
        /// <summary>
        /// 拼团活动商品详情
        /// </summary>
        /// <param name="id">拼团活动ID</param>
        /// /// <param name="grouId">团活动ID</param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetActiveDetail(long id, long grouId = 0, bool isFirst = true, string ids = "")
        {
            var userList = new List <FightGroupOrderInfo>();
            var data     = FightGroupApplication.GetActive(id, true, true);
            FightGroupActiveModel result = data;

            //先初始化拼团商品主图
            result.InitProductImages();
            var imgpath = data.ProductImgPath;

            if (result != null)
            {
                result.IsEnd = true;
                if (data.EndTime.Date >= DateTime.Now.Date)
                {
                    result.IsEnd = false;
                }
                //商品图片地址修正
                result.ProductDefaultImage = HimallIO.GetRomoteProductSizeImage(imgpath, 1, (int)ImageSize.Size_350);
                result.ProductImgPath      = HimallIO.GetRomoteProductSizeImage(imgpath, 1);
            }
            if (result.ProductImages != null)
            {//将主图相对路径处理为绝对路径
                result.ProductImages = result.ProductImages.Select(e => HimallIO.GetRomoteImagePath(e)).ToList();
            }

            if (!string.IsNullOrWhiteSpace(result.IconUrl))
            {
                result.IconUrl = Himall.Core.HimallIO.GetRomoteImagePath(result.IconUrl);
            }
            bool IsUserEnter = false;
            long currentUser = 0;

            if (CurrentUser != null)
            {
                currentUser = CurrentUser.Id;
            }
            if (grouId > 0)//获取已参团的用户
            {
                userList = ServiceProvider.Instance <IFightGroupService> .Create.GetActiveUsers(id, grouId);

                foreach (var item in userList)
                {
                    item.Photo        = !string.IsNullOrWhiteSpace(item.Photo) ? Core.HimallIO.GetRomoteImagePath(item.Photo) : "";
                    item.HeadUserIcon = !string.IsNullOrWhiteSpace(item.HeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(item.HeadUserIcon) : "";
                    if (currentUser.Equals(item.OrderUserId))
                    {
                        IsUserEnter = true;
                    }
                }
            }
            #region 商品规格
            var product = ProductManagerApplication.GetProduct((long)result.ProductId);

            ProductShowSkuInfoModel model = new ProductShowSkuInfoModel();
            model.MinSalePrice     = data.MiniSalePrice;
            model.ProductImagePath = string.IsNullOrWhiteSpace(imgpath) ? "" : HimallIO.GetRomoteProductSizeImage(imgpath, 1, (int)Himall.CommonModel.ImageSize.Size_350);

            List <SKUDataModel> skudata = data.ActiveItems.Where(d => d.ActiveStock > 0).Select(d => new SKUDataModel
            {
                SkuId     = d.SkuId,
                Color     = d.Color,
                Size      = d.Size,
                Version   = d.Version,
                Stock     = (int)d.ActiveStock,
                CostPrice = d.ProductCostPrice,
                SalePrice = d.ProductPrice,
                Price     = d.ActivePrice,
            }).ToList();

            Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(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;
            }
            model.ColorAlias   = colorAlias;
            model.SizeAlias    = sizeAlias;
            model.VersionAlias = versionAlias;

            if (result.ActiveItems != null && result.ActiveItems.Count() > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                var  skus = ProductManagerApplication.GetSKUs((long)result.ProductId);
                foreach (var sku in result.ActiveItems)
                {
                    var specs = sku.SkuId.Split('_');
                    if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color))
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = result.ActiveItems.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.ActiveStock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? " " : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = string.IsNullOrWhiteSpace(sku.ShowPic) ? "" : Core.HimallIO.GetRomoteImagePath(sku.ShowPic)
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size))
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = result.ActiveItems.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.ActiveStock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name          = "选择" + sizeAlias,
                                    EnabledClass  = ss != 0 ? "enabled" : "disabled",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version))
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = result.ActiveItems.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.ActiveStock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择规格",
                                    Name          = "选择" + versionAlias,
                                    EnabledClass  = v != 0 ? "enabled" : "disabled",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
            }
            #endregion

            var cashDepositModel = CashDepositsApplication.GetCashDepositsObligation((long)result.ProductId);//提供服务(消费者保障、七天无理由、及时发货)

            var GroupsData = new List <FightGroupsListModel>();
            List <FightGroupBuildStatus> stlist = new List <FightGroupBuildStatus>();
            stlist.Add(FightGroupBuildStatus.Ongoing);
            GroupsData = FightGroupApplication.GetGroups(id, stlist, null, null, 1, 10).Models.ToList();
            foreach (var item in GroupsData)
            {
                TimeSpan mid = item.AddGroupTime.AddHours((double)item.LimitedHour) - DateTime.Now;
                item.Seconds         = (int)mid.TotalSeconds;
                item.EndHourOrMinute = item.ShowHourOrMinute(item.GetEndHour);
                item.HeadUserIcon    = !string.IsNullOrWhiteSpace(item.HeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(item.HeadUserIcon) : "";
            }

            #region 商品评论
            ProductCommentShowModel modelSay = new ProductCommentShowModel();
            modelSay.ProductId = (long)result.ProductId;
            var productSay = ProductManagerApplication.GetProduct((long)result.ProductId);
            modelSay.CommentList       = new List <ProductDetailCommentModel>();
            modelSay.IsShowColumnTitle = true;
            modelSay.IsShowCommentList = true;

            if (productSay == null)
            {
                //跳转到404页面
                throw new Core.HimallException("商品不存在");
            }
            var comments = CommentApplication.GetCommentsByProduct(product.Id);
            modelSay.CommentCount = comments.Count;
            if (comments.Count > 0)
            {
                var comment   = comments.OrderByDescending(a => a.ReviewDate).FirstOrDefault();
                var orderItem = OrderApplication.GetOrderItem(comment.SubOrderId);
                var order     = OrderApplication.GetOrder(orderItem.OrderId);
                modelSay.CommentList = comments.OrderByDescending(a => a.ReviewDate)
                                       .Take(1)
                                       .Select(c => {
                    var images = CommentApplication.GetProductCommentImagesByCommentIds(new List <long> {
                        c.Id
                    });
                    return(new ProductDetailCommentModel
                    {
                        Sku = ServiceProvider.Instance <IProductService> .Create.GetSkuString(orderItem.SkuId),
                        UserName = c.UserName,
                        ReviewContent = c.ReviewContent,
                        AppendContent = c.AppendContent,
                        AppendDate = c.AppendDate,
                        ReplyAppendContent = c.ReplyAppendContent,
                        ReplyAppendDate = c.ReplyAppendDate,
                        FinshDate = order.FinishDate,
                        Images = images.Where(a => a.CommentType == 0).Select(a => a.CommentImage).ToList(),
                        AppendImages = images.Where(a => a.CommentType == 1).Select(a => a.CommentImage).ToList(),
                        ReviewDate = c.ReviewDate,
                        ReplyContent = string.IsNullOrWhiteSpace(c.ReplyContent) ? "暂无回复" : c.ReplyContent,
                        ReplyDate = c.ReplyDate,
                        ReviewMark = c.ReviewMark,
                        BuyDate = order.OrderDate
                    });
                }).ToList();
                foreach (var citem in modelSay.CommentList)
                {
                    if (citem.Images.Count > 0)
                    {
                        for (var _imgn = 0; _imgn < citem.Images.Count; _imgn++)
                        {
                            citem.Images[_imgn] = Himall.Core.HimallIO.GetRomoteImagePath(citem.Images[_imgn]);
                        }
                    }
                    if (citem.AppendImages.Count > 0)
                    {
                        for (var _imgn = 0; _imgn < citem.AppendImages.Count; _imgn++)
                        {
                            citem.AppendImages[_imgn] = Himall.Core.HimallIO.GetRomoteImagePath(citem.AppendImages[_imgn]);
                        }
                    }
                }
            }
            #endregion

            #region 店铺信息
            VShopShowShopScoreModel modelShopScore = new VShopShowShopScoreModel();
            modelShopScore.ShopId = result.ShopId;
            var shop = ServiceProvider.Instance <IShopService> .Create.GetShop(result.ShopId);

            if (shop == null)
            {
                throw new HimallException("错误的店铺信息");
            }

            modelShopScore.ShopName = shop.ShopName;

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(result.ShopId);

            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;

            modelShopScore.SellerServiceAttitude     = defaultValue;
            modelShopScore.SellerServiceAttitudePeer = defaultValue;
            modelShopScore.SellerServiceAttitudeMax  = defaultValue;
            modelShopScore.SellerServiceAttitudeMin  = defaultValue;

            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null && !shop.IsSelf)
            {
                modelShopScore.ProductAndDescription     = productAndDescription.CommentValue;
                modelShopScore.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                modelShopScore.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                modelShopScore.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                modelShopScore.ProductAndDescription     = defaultValue;
                modelShopScore.ProductAndDescriptionPeer = defaultValue;
                modelShopScore.ProductAndDescriptionMin  = defaultValue;
                modelShopScore.ProductAndDescriptionMax  = defaultValue;
            }

            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null && !shop.IsSelf)
            {
                modelShopScore.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                modelShopScore.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                modelShopScore.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                modelShopScore.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                modelShopScore.SellerServiceAttitude     = defaultValue;
                modelShopScore.SellerServiceAttitudePeer = defaultValue;
                modelShopScore.SellerServiceAttitudeMax  = defaultValue;
                modelShopScore.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null && !shop.IsSelf)
            {
                modelShopScore.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                modelShopScore.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                modelShopScore.SellerDeliverySpeedMax  = sellerDeliverySpeedMax != null ? sellerDeliverySpeedMax.CommentValue : 0;
                modelShopScore.sellerDeliverySpeedMin  = sellerDeliverySpeedMin != null ? sellerDeliverySpeedMin.CommentValue : 0;
            }
            else
            {
                modelShopScore.SellerDeliverySpeed     = defaultValue;
                modelShopScore.SellerDeliverySpeedPeer = defaultValue;
                modelShopScore.SellerDeliverySpeedMax  = defaultValue;
                modelShopScore.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            modelShopScore.ProductNum = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(result.ShopId);

            modelShopScore.IsFavoriteShop    = false;
            modelShopScore.FavoriteShopCount = ServiceProvider.Instance <IShopService> .Create.GetShopFavoritesCount(result.ShopId);

            if (CurrentUser != null)
            {
                modelShopScore.IsFavoriteShop = ServiceProvider.Instance <IShopService> .Create.GetFavoriteShopInfos(CurrentUser.Id).Any(d => d.ShopId == result.ShopId);
            }

            long vShopId;
            var  vshopinfo = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id);

            if (vshopinfo == null)
            {
                vShopId = -1;
            }
            else
            {
                vShopId = vshopinfo.Id;
            }
            modelShopScore.VShopId  = vShopId;
            modelShopScore.VShopLog = ServiceProvider.Instance <IVShopService> .Create.GetVShopLog(vShopId);

            if (!string.IsNullOrWhiteSpace(modelShopScore.VShopLog))
            {
                modelShopScore.VShopLog = Himall.Core.HimallIO.GetRomoteImagePath(modelShopScore.VShopLog);
            }

            // 客服
            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(shop.Id);
            #endregion
            #region 根据运费模板获取发货地址
            var    freightTemplateService = ServiceApplication.Create <IFreightTemplateService>();
            var    template       = freightTemplateService.GetFreightTemplate(product.FreightTemplateId);
            string productAddress = string.Empty;
            if (template != null)
            {
                var fullName = ServiceApplication.Create <IRegionService>().GetFullName(template.SourceAddress);
                if (fullName != null)
                {
                    var ass = fullName.Split(' ');
                    if (ass.Length >= 2)
                    {
                        productAddress = ass[0] + " " + ass[1];
                    }
                    else
                    {
                        productAddress = ass[0];
                    }
                }
            }

            var ProductAddress  = productAddress;
            var FreightTemplate = template;
            #endregion

            #region 获取店铺优惠信息
            VShopShowPromotionModel modelVshop = new VShopShowPromotionModel();
            modelVshop.ShopId = result.ShopId;
            var shopInfo = ServiceProvider.Instance <IShopService> .Create.GetShop(result.ShopId);

            if (shopInfo == null)
            {
                throw new HimallException("错误的店铺编号");
            }

            modelVshop.FreeFreight = shop.FreeFreight;


            var bonus = ServiceApplication.Create <IShopBonusService>().GetByShopId(result.ShopId);
            if (bonus != null)
            {
                modelVshop.BonusCount             = bonus.Count;
                modelVshop.BonusGrantPrice        = bonus.GrantPrice;
                modelVshop.BonusRandomAmountStart = bonus.RandomAmountStart;
                modelVshop.BonusRandomAmountEnd   = bonus.RandomAmountEnd;
            }
            FullDiscountActive fullDiscount = null;
            //var fullDiscount = FullDiscountApplication.GetOngoingActiveByProductId(id, shop.Id);
            #endregion
            //商品描述

            var description = ProductManagerApplication.GetProductDescription(result.ProductId);
            if (description == null)
            {
                throw new HimallException("错误的商品编号");
            }

            string DescriptionPrefix = "", DescriptiondSuffix = "";
            var    iprodestempser = ServiceApplication.Create <IProductDescriptionTemplateService>();
            if (description.DescriptionPrefixId != 0)
            {
                var desc = iprodestempser.GetTemplate(description.DescriptionPrefixId, product.ShopId);
                DescriptionPrefix = desc == null ? "" : desc.MobileContent;
            }

            if (description.DescriptiondSuffixId != 0)
            {
                var desc = iprodestempser.GetTemplate(description.DescriptiondSuffixId, product.ShopId);
                DescriptiondSuffix = desc == null ? "" : desc.MobileContent;
            }
            var productDescription = DescriptionPrefix + description.ShowMobileDescription + DescriptiondSuffix;
            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            AutoMapper.Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveResult>();
            var     fightGroupData = AutoMapper.Mapper.Map <FightGroupActiveResult>(result);
            decimal discount       = 1M;
            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
            }
            var shopItem = ShopApplication.GetShop(result.ShopId);
            fightGroupData.MiniSalePrice = shopItem.IsSelf ? fightGroupData.MiniSalePrice * discount : fightGroupData.MiniSalePrice;

            string loadShowPrice = string.Empty;//app拼团详细页加载时显示的区间价
            loadShowPrice = fightGroupData.MiniSalePrice.ToString("f2");

            if (fightGroupData != null && fightGroupData.ActiveItems.Count() > 0)
            {
                decimal min = fightGroupData.ActiveItems.Min(s => s.ActivePrice);
                decimal max = fightGroupData.ActiveItems.Max(s => s.ActivePrice);
                loadShowPrice = (min < max) ? (min.ToString("f2") + " - " + max.ToString("f2")) : min.ToString("f2");
            }

            var _result = new
            {
                success        = true,
                FightGroupData = fightGroupData,
                ShowSkuInfo    = new
                {
                    ColorAlias       = model.ColorAlias,
                    SizeAlias        = model.SizeAlias,
                    VersionAlias     = model.VersionAlias,
                    MinSalePrice     = model.MinSalePrice,
                    ProductImagePath = model.ProductImagePath,
                    Color            = model.Color.OrderByDescending(p => p.SkuId),
                    Size             = model.Size.OrderByDescending(p => p.SkuId),
                    Version          = model.Version.OrderByDescending(p => p.SkuId)
                },
                ShowPromotion       = modelVshop,
                fullDiscount        = fullDiscount,
                ShowNewCanJoinGroup = GroupsData,
                ProductCommentShow  = modelSay,
                ProductDescription  = productDescription.Replace("src=\"/Storage/", "src=\"" + Core.HimallIO.GetRomoteImagePath("/Storage") + "/"),
                ShopScore           = modelShopScore,
                CashDepositsServer  = cashDepositModel,
                ProductAddress      = ProductAddress,
                //Free = FreightTemplate.IsFree == FreightTemplateType.Free ? "免运费" : "",
                userList              = userList,
                IsUserEnter           = IsUserEnter,
                SkuData               = skudata,
                CustomerServices      = customerServices,
                IsOpenLadder          = product.IsOpenLadder,
                VideoPath             = string.IsNullOrWhiteSpace(product.VideoPath) ? string.Empty : Himall.Core.HimallIO.GetRomoteImagePath(product.VideoPath),
                LoadShowPrice         = loadShowPrice,                                                                                                           //商品时区间价
                ProductSaleCountOnOff = (SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1),                                                        //是否显示销量
                SaleCounts            = data.ActiveItems.Sum(d => d.BuyCount),                                                                                   //销量
                FreightStr            = FreightTemplateApplication.GetFreightStr(product.Id, FreightTemplate, CurrentUser, product),                             //运费多少或免运费
                SendTime              = (FreightTemplate != null && !string.IsNullOrEmpty(FreightTemplate.SendTime) ? (FreightTemplate.SendTime + "h内发货") : ""), //运费模板发货时间
            };
            return(JsonResult <dynamic>(_result));
        }