Ejemplo n.º 1
0
        public string GetLinkUrl(Enumeration.ProductType type, int id)
        {
            string index   = ((int)type).ToString().Substring(0, 1);
            string linkUrl = "";

            switch (index)
            {
            case "1":
                linkUrl = "http://112.74.179.185:8084/App/Product/GoodsDetails/" + id;
                break;

            default:
                break;
            }

            return(linkUrl);
        }
Ejemplo n.º 2
0
        public APIResponse GetDetails(int userId, int merchantId, int orderId, Enumeration.ProductType productType)
        {
            if (productType == Enumeration.ProductType.InsureForCarForInsure || productType == Enumeration.ProductType.InsureForCarForRenewal)
            {
                OrderCarInsureDetailsModel model = new OrderCarInsureDetailsModel();
                var orderToCarInsure             = CurrentDb.OrderToCarInsure.Where(m => m.Id == orderId).FirstOrDefault();
                if (orderToCarInsure != null)
                {
                    model.Id = orderToCarInsure.Id;
                    model.Sn = orderToCarInsure.Sn;

                    #region 报价公司
                    var orderToCarInsureOfferCompany = CurrentDb.OrderToCarInsureOfferCompany.Where(m => m.OrderId == orderToCarInsure.Id).ToList();
                    foreach (var m in orderToCarInsureOfferCompany)
                    {
                        OrderCarInsureOfferCompanyModel orderCarInsureOfferCompanyModel = new OrderCarInsureOfferCompanyModel();
                        orderCarInsureOfferCompanyModel.InsuranceOfferId     = m.Id;
                        orderCarInsureOfferCompanyModel.InsuranceCompanyId   = m.InsuranceCompanyId;
                        orderCarInsureOfferCompanyModel.InsuranceCompanyName = m.InsuranceCompanyName;
                        orderCarInsureOfferCompanyModel.InsureImgUrl         = m.InsureImgUrl;

                        if (m.CommercialPrice != null && m.TravelTaxPrice != null)
                        {
                            orderCarInsureOfferCompanyModel.CommercialAndTravelTaxPrice = m.CompulsoryPrice.Value + m.TravelTaxPrice.Value;
                        }

                        if (m.CompulsoryPrice != null)
                        {
                            orderCarInsureOfferCompanyModel.CompulsoryPrice = m.CommercialPrice.Value;
                        }

                        if (m.InsureTotalPrice != null)
                        {
                            orderCarInsureOfferCompanyModel.InsureTotalPrice = m.InsureTotalPrice.Value;
                        }

                        model.OfferCompany.Add(orderCarInsureOfferCompanyModel);
                    }
                    #endregion

                    #region 险种
                    var orderToCarInsureOfferKind = CurrentDb.OrderToCarInsureOfferKind.Where(m => m.OrderId == orderToCarInsure.Id).ToList();
                    var carKinds = CurrentDb.CarKind.ToList();
                    if (orderToCarInsureOfferKind != null)
                    {
                        foreach (var m in orderToCarInsureOfferKind)
                        {
                            var carKind = carKinds.Where(q => q.Id == m.KindId).FirstOrDefault();
                            if (carKind != null)
                            {
                                OrderToCarInsureOfferKindModel orderToCarInsureOfferKindModel = new OrderToCarInsureOfferKindModel();
                                orderToCarInsureOfferKindModel.Field = carKind.Name;
                                orderToCarInsureOfferKindModel.Value = m.KindValue + carKind.InputUnit;
                                model.OfferKind.Add(orderToCarInsureOfferKindModel);
                            }
                        }
                    }
                    #endregion


                    #region 车主
                    model.CarOwner         = orderToCarInsure.CarOwner.NullToEmpty();
                    model.CarPlateNo       = orderToCarInsure.CarPlateNo.NullToEmpty();
                    model.CarOwnerIdNumber = orderToCarInsure.CarOwnerIdNumber.NullToEmpty();
                    #endregion

                    model.InsuranceCompanyId   = orderToCarInsure.InsuranceCompanyId;
                    model.InsuranceCompanyName = orderToCarInsure.InsuranceCompanyName;
                    model.InsureImgUrl         = orderToCarInsure.InsureImgUrl;

                    model.ShippingAddress = orderToCarInsure.ShippingAddress.NullToEmpty();

                    model.CommercialAndTravelTaxPrice = orderToCarInsure.CommercialPrice + orderToCarInsure.TravelTaxPrice;
                    model.CompulsoryPrice             = orderToCarInsure.CompulsoryPrice;
                    model.Price = orderToCarInsure.Price;

                    #region 证件

                    if (orderToCarInsure.CZ_CL_XSZ_ImgUrl != null)
                    {
                        model.ZJ.Add(new ZjModel("行驶证", orderToCarInsure.CZ_CL_XSZ_ImgUrl));
                    }

                    if (orderToCarInsure.CZ_SFZ_ImgUrl != null)
                    {
                        model.ZJ.Add(new ZjModel("身份证", orderToCarInsure.CZ_SFZ_ImgUrl));
                    }

                    if (orderToCarInsure.CCSJM_WSZM_ImgUrl != null)
                    {
                        model.ZJ.Add(new ZjModel("车船税减免/完税证明", orderToCarInsure.CCSJM_WSZM_ImgUrl));
                    }

                    if (orderToCarInsure.YCZ_CLDJZ_ImgUrl != null)
                    {
                        model.ZJ.Add(new ZjModel("验车照/车辆登记证", orderToCarInsure.YCZ_CLDJZ_ImgUrl));
                    }

                    if (orderToCarInsure.ZJ1_ImgUrl != null)
                    {
                        model.ZJ.Add(new ZjModel("其它", orderToCarInsure.ZJ1_ImgUrl));
                    }

                    if (orderToCarInsure.ZJ2_ImgUrl != null)
                    {
                        model.ZJ.Add(new ZjModel("其它", orderToCarInsure.ZJ2_ImgUrl));
                    }

                    if (orderToCarInsure.ZJ3_ImgUrl != null)
                    {
                        model.ZJ.Add(new ZjModel("其它", orderToCarInsure.ZJ3_ImgUrl));
                    }

                    if (orderToCarInsure.ZJ4_ImgUrl != null)
                    {
                        model.ZJ.Add(new ZjModel("其它", orderToCarInsure.ZJ4_ImgUrl));
                    }
                    #endregion

                    model.SubmitTime   = orderToCarInsure.SubmitTime;
                    model.CompleteTime = orderToCarInsure.CompleteTime;
                    model.PayTime      = orderToCarInsure.PayTime;
                    model.CancleTime   = orderToCarInsure.CancleTime;
                    model.Status       = orderToCarInsure.Status;
                    model.StatusName   = orderToCarInsure.Status.GetCnName();
                    model.FollowStatus = orderToCarInsure.FollowStatus;
                    model.Remarks      = orderToCarInsure.Remarks.NullToEmpty();

                    model.ShippingAddressList.Add("地址1");
                    model.ShippingAddressList.Add("地址2");
                }

                APIResult result = new APIResult()
                {
                    Result = ResultType.Success, Code = ResultCode.Success, Message = "获取成功", Data = model
                };
                return(new APIResponse(result));
            }
            else if (productType == Enumeration.ProductType.InsureForCarForClaim)
            {
                OrderCarClaimDetailsModel model = new OrderCarClaimDetailsModel();
                var orderToCarEstimate          = CurrentDb.OrderToCarClaim.Where(m => m.Id == orderId).FirstOrDefault();
                if (orderToCarEstimate != null)
                {
                    model.Id                   = orderToCarEstimate.Id;
                    model.Sn                   = orderToCarEstimate.Sn;
                    model.CarOwner             = orderToCarEstimate.CarOwner;
                    model.CarPlateNo           = orderToCarEstimate.CarPlateNo;
                    model.RepairsType          = orderToCarEstimate.RepairsType.GetCnName();
                    model.HandPerson           = orderToCarEstimate.HandPerson;
                    model.HandPersonPhone      = orderToCarEstimate.HandPersonPhone;
                    model.InsuranceCompanyName = orderToCarEstimate.InsuranceCompanyName;
                    model.InsuranceCompanyId   = orderToCarEstimate.InsuranceCompanyId;
                    model.EstimateListImgUrl   = orderToCarEstimate.EstimateListImgUrl;
                    model.SubmitTime           = orderToCarEstimate.SubmitTime;
                    model.CompleteTime         = orderToCarEstimate.CompleteTime;
                    model.PayTime              = orderToCarEstimate.PayTime;
                    model.CancleTime           = orderToCarEstimate.CancleTime;
                    model.AccessoriesPrice     = orderToCarEstimate.AccessoriesPrice;
                    model.WorkingHoursPrice    = orderToCarEstimate.WorkingHoursPrice;
                    model.EstimatePrice        = orderToCarEstimate.EstimatePrice;
                    model.Price                = orderToCarEstimate.Price;
                    model.Status               = orderToCarEstimate.Status;
                    model.FollowStatus         = orderToCarEstimate.FollowStatus;
                    model.StatusName           = orderToCarEstimate.Status.GetCnName();
                    model.Remark               = orderToCarEstimate.Remarks;

                    if (orderToCarEstimate.HandMerchantId != null)
                    {
                        var handMerchant = CurrentDb.Merchant.Where(m => m.Id == orderToCarEstimate.HandMerchantId.Value).FirstOrDefault();
                        if (handMerchant != null)
                        {
                            MerchantModel merchantModel = new MerchantModel();
                            merchantModel.Id             = handMerchant.Id;
                            merchantModel.Name           = handMerchant.YYZZ_Name;
                            merchantModel.Contact        = handMerchant.ContactName;
                            merchantModel.ContactAddress = handMerchant.YYZZ_Address;
                            merchantModel.ContactPhone   = handMerchant.ContactPhoneNumber;
                            model.EstimateMerchant       = merchantModel;
                        }
                    }
                }

                APIResult result = new APIResult()
                {
                    Result = ResultType.Success, Code = ResultCode.Success, Message = "获取成功", Data = model
                };
                return(new APIResponse(result));
            }
            else
            {
                APIResult result = new APIResult()
                {
                    Result = ResultType.Failure, Code = ResultCode.Failure, Message = "未知产品类型"
                };
                return(new APIResponse(result));
            }
        }
        public APIResponse GetList(int userId, int merchantId, int posMachineId, int pageIndex, Enumeration.ProductType type, int categoryId, int kindId, string name)
        {
            var query = (from o in CurrentDb.Product
                         where
                         o.Status == Enumeration.ProductStatus.OnLine
                         select new { o.Id, o.BriefIntro, o.Name, o.IsHot, o.IsMultiSpec, o.ProductCategoryId, o.ProductKindIds, o.DispalyImgs, o.CreateTime }
                         );

            if (name != null && name.Length > 0)
            {
                query = query.Where(p => p.Name.Contains(name));
            }

            if (type != Enumeration.ProductType.Unknow)
            {
                //query = query.Where(p => p.ProductCategoryId.ToString().StartsWith(categoryId.ToString()));
            }

            if (categoryId != 0)
            {
                query = query.Where(p => p.ProductCategoryId.ToString().StartsWith(categoryId.ToString()));
            }

            if (kindId != 0)
            {
                string strkindId = BizFactory.Product.BuildProductKindIdForSearch(kindId.ToString());

                query = query.Where(p => SqlFunctions.CharIndex(strkindId, p.ProductKindIds) > 0);
            }

            int pageSize = 4;

            query = query.OrderByDescending(r => r.CreateTime).Skip(pageSize * (pageIndex)).Take(pageSize);

            var list = query.ToList();
            List <ProductModel> model = new List <ProductModel>();


            foreach (var m in list)
            {
                var productSku = CurrentDb.ProductSku.Where(q => q.ProductId == m.Id).FirstOrDefault();
                if (productSku != null)
                {
                    ProductModel productModel = new ProductModel();
                    productModel.Id          = m.Id;
                    productModel.SkuId       = productSku.Id;
                    productModel.Name        = m.Name;
                    productModel.BriefIntro  = m.BriefIntro;
                    productModel.IsHot       = m.IsHot;
                    productModel.Price       = productSku.Price;
                    productModel.ShowPrice   = productSku.ShowPrice.ToF2Price();
                    productModel.DispalyImgs = BizFactory.Product.GetDispalyImgs(productSku.DispalyImgs);
                    productModel.MainImg     = BizFactory.Product.GetMainImg(m.DispalyImgs);
                    productModel.DetailsUrl  = BizFactory.Product.GetDetailsUrl(m.Id);
                    model.Add(productModel);
                }
            }

            APIResult result = new APIResult()
            {
                Result = ResultType.Success, Code = ResultCode.Success, Message = "", Data = model
            };

            return(new APIResponse(result));
        }