public ActionResult Submit(string cartItemIds, long?regionId)
        {
            int                         num;
            int                         num1;
            dynamic                     obj;
            IOrderService               orderService          = ServiceHelper.Create <IOrderService>();
            IMemberIntegralService      memberIntegralService = ServiceHelper.Create <IMemberIntegralService>();
            MemberIntegralExchangeRules integralChangeRule    = memberIntegralService.GetIntegralChangeRule();
            MemberIntegral              memberIntegral        = memberIntegralService.GetMemberIntegral(base.CurrentUser.Id);
            int                         num2    = (integralChangeRule == null ? 0 : integralChangeRule.MoneyPerIntegral);
            dynamic                     viewBag = base.ViewBag;

            num = (integralChangeRule == null ? 0 : integralChangeRule.IntegralPerMoney);
            viewBag.IntegralPerMoney = num;
            dynamic viewBag1 = base.ViewBag;

            num1 = (memberIntegral == null ? 0 : memberIntegral.AvailableIntegrals);
            viewBag1.Integral   = num1;
            ViewBag.Logo        = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings().Logo;
            ViewBag.Step        = 2;
            ViewBag.Member      = base.CurrentUser;
            ViewBag.cartItemIds = cartItemIds;
            GetOrderProductsInfo(cartItemIds, regionId);
            dynamic obj1 = base.ViewBag;

            obj = (num2 == 0 ? 0 : Math.Floor(ViewBag.totalAmount / num2));
            obj1.TotalIntegral       = obj;
            ViewBag.MoneyPerIntegral = num2;
            GetShippingAddress(regionId);
            ViewBag.InvoiceTitle   = orderService.GetInvoiceTitles(base.CurrentUser.Id);
            ViewBag.InvoiceContext = orderService.GetInvoiceContexts();
            return(View());
        }
        public ActionResult InviteRegist(long id = 0L, string openId = "", string serviceProvider = "")
        {
            ViewBag.Introducer = id;
            UserMemberInfo              memberByOpenId     = ServiceHelper.Create <IMemberService>().GetMemberByOpenId(serviceProvider, openId);
            SiteSettingsInfo            siteSettings       = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings();
            InviteRuleInfo              inviteRule         = ServiceHelper.Create <IMemberInviteService>().GetInviteRule();
            MemberIntegralExchangeRules integralChangeRule = ServiceHelper.Create <IMemberIntegralService>().GetIntegralChangeRule();
            int num = (integralChangeRule == null ? 0 : integralChangeRule.IntegralPerMoney);

            ViewBag.WXLogo = siteSettings.WXLogo;
            if (!inviteRule.InviteIntegral.HasValue || num <= 0)
            {
                ViewBag.Money = "0.0";
            }
            else
            {
                dynamic viewBag = base.ViewBag;
                int     value   = inviteRule.InviteIntegral.Value / num;
                viewBag.Money = value.ToString("f1");
            }
            ViewBag.IsRegist = 0;
            if (memberByOpenId != null)
            {
                ViewBag.IsRegist = 1;
            }
            return(View(inviteRule));
        }
        public ActionResult Index()
        {
            string str;

            ViewBag.WeiXin = false;
            if (!string.IsNullOrWhiteSpace(_siteSetting.WeixinAppId) && !string.IsNullOrWhiteSpace(_siteSetting.WeixinAppSecret) && base.PlatformType == ChemCloud.Core.PlatformType.WeiXin)
            {
                ViewBag.WeiXin = true;
                string        empty        = string.Empty;
                IWXApiService wXApiService = ServiceHelper.Create <IWXApiService>();
                empty = wXApiService.GetTicket(_siteSetting.WeixinAppId, _siteSetting.WeixinAppSecret);
                JSSDKHelper jSSDKHelper = new JSSDKHelper();
                string      timestamp   = JSSDKHelper.GetTimestamp();
                string      noncestr    = JSSDKHelper.GetNoncestr();
                string      signature   = jSSDKHelper.GetSignature(empty, noncestr, timestamp, base.Request.Url.AbsoluteUri);
                ViewBag.Timestamp = timestamp;
                ViewBag.NonceStr  = noncestr;
                ViewBag.Signature = signature;
                ViewBag.AppId     = _siteSetting.WeixinAppId;
            }
            long                        id = base.CurrentUser.Id;
            UserInviteModel             memberInviteInfo   = ServiceHelper.Create <IMemberInviteService>().GetMemberInviteInfo(id);
            InviteRuleInfo              inviteRule         = ServiceHelper.Create <IMemberInviteService>().GetInviteRule();
            MemberIntegralExchangeRules integralChangeRule = ServiceHelper.Create <IMemberIntegralService>().GetIntegralChangeRule();

            if (integralChangeRule != null)
            {
                dynamic viewBag = base.ViewBag;
                int     value   = inviteRule.InviteIntegral.Value / integralChangeRule.IntegralPerMoney;
                viewBag.IntergralMoney = value.ToString("f2");
            }
            string host = base.Request.Url.Host;
            string str1 = host;

            if (base.Request.Url.Port != 80)
            {
                int port = base.Request.Url.Port;
                str = string.Concat(":", port.ToString());
            }
            else
            {
                str = "";
            }
            host = string.Concat(str1, str);
            memberInviteInfo.InviteLink = string.Format("http://{0}/Register/index/{1}", host, id);
            inviteRule.ShareIcon        = string.Format("http://{0}{1}", host, inviteRule.ShareIcon);
            Bitmap       bitmap       = QRCodeHelper.Create(memberInviteInfo.InviteLink);
            MemoryStream memoryStream = new MemoryStream();

            bitmap.Save(memoryStream, ImageFormat.Gif);
            string str2 = string.Concat("data:image/gif;base64,", Convert.ToBase64String(memoryStream.ToArray()));

            memoryStream.Dispose();
            memberInviteInfo.QR = str2;
            Tuple <UserInviteModel, InviteRuleInfo, UserMemberInfo> tuple = new Tuple <UserInviteModel, InviteRuleInfo, UserMemberInfo>(memberInviteInfo, inviteRule, base.CurrentUser);

            return(View(tuple));
        }
        public JsonResult Management(IntegralRule rule)
        {
            List <MemberIntegralRule> memberIntegralRules = new List <MemberIntegralRule>();
            MemberIntegralRule        memberIntegralRule  = new MemberIntegralRule()
            {
                Integral = rule.Reg,
                TypeId   = 9
            };

            memberIntegralRules.Add(memberIntegralRule);
            MemberIntegralRule memberIntegralRule1 = new MemberIntegralRule()
            {
                Integral = rule.BindWX,
                TypeId   = 6
            };

            memberIntegralRules.Add(memberIntegralRule1);
            MemberIntegralRule memberIntegralRule2 = new MemberIntegralRule()
            {
                Integral = rule.Login,
                TypeId   = 5
            };

            memberIntegralRules.Add(memberIntegralRule2);
            MemberIntegralRule memberIntegralRule3 = new MemberIntegralRule()
            {
                Integral = rule.Comment,
                TypeId   = 7
            };

            memberIntegralRules.Add(memberIntegralRule3);
            ServiceHelper.Create <IMemberIntegralService>().SetIntegralRule(memberIntegralRules);
            MemberIntegralExchangeRules integralChangeRule = ServiceHelper.Create <IMemberIntegralService>().GetIntegralChangeRule();

            if (integralChangeRule == null)
            {
                integralChangeRule = new MemberIntegralExchangeRules()
                {
                    MoneyPerIntegral = rule.MoneyPerIntegral
                };
            }
            else
            {
                integralChangeRule.MoneyPerIntegral = rule.MoneyPerIntegral;
            }
            ServiceHelper.Create <IMemberIntegralService>().SetIntegralChangeRule(integralChangeRule);
            Result result = new Result()
            {
                success = true,
                msg     = "保存成功"
            };

            return(Json(result));
        }
        public ActionResult Index(int?type, int pageSize = 10, int pageNo = 1)
        {
            int num;
            int num1;
            MemberIntegralExchangeRules integralChangeRule = ServiceHelper.Create <IMemberIntegralService>().GetIntegralChangeRule();
            dynamic viewBag = base.ViewBag;

            num = (integralChangeRule == null ? 0 : integralChangeRule.IntegralPerMoney);
            viewBag.IntegralPerMoney = num;
            MemberIntegral memberIntegral = ServiceHelper.Create <IMemberIntegralService>().GetMemberIntegral(base.CurrentUser.Id);
            dynamic        obj            = base.ViewBag;

            num1         = (memberIntegral == null ? 0 : memberIntegral.AvailableIntegrals);
            obj.Integral = num1;
            MemberIntegral.IntegralType?nullable = null;
            if (type.HasValue)
            {
                nullable = new MemberIntegral.IntegralType?((MemberIntegral.IntegralType)type.Value);
            }
            IntegralRecordQuery integralRecordQuery = new IntegralRecordQuery()
            {
                IntegralType = nullable,
                UserId       = new long?(base.CurrentUser.Id),
                PageNo       = pageNo,
                PageSize     = pageSize
            };
            PageModel <MemberIntegralRecord>   integralRecordList = ServiceHelper.Create <IMemberIntegralService>().GetIntegralRecordList(integralRecordQuery);
            IEnumerable <MemberIntegralRecord> list =
                from item in integralRecordList.Models.ToList()
                select new MemberIntegralRecord()
            {
                Id         = item.Id,
                UserName   = item.UserName,
                RecordDate = item.RecordDate,
                Integral   = item.Integral,
                TypeId     = item.TypeId,
                ReMark     = GetRemarkFromIntegralType(item.TypeId, item.Himall_MemberIntegralRecordAction, item.ReMark)
            };
            PagingInfo pagingInfo = new PagingInfo()
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = integralRecordList.Total
            };

            ViewBag.pageInfo = pagingInfo;
            return(View(list));
        }
Exemple #6
0
        public void SetIntegralChangeRule(MemberIntegralExchangeRules info)
        {
            var model = Context.MemberIntegralExchangeRules.FirstOrDefault();

            if (model != null)
            {
                model.IntegralPerMoney = info.IntegralPerMoney;
                model.MoneyPerIntegral = info.MoneyPerIntegral;
            }
            else
            {
                model = new MemberIntegralExchangeRules();
                model.IntegralPerMoney = info.IntegralPerMoney;
                model.MoneyPerIntegral = info.MoneyPerIntegral;
                Context.MemberIntegralExchangeRules.Add(model);
            }
            Context.SaveChanges();
        }
Exemple #7
0
        public JsonResult Change(int IntegralPerMoney)
        {
            var info = _iMemberIntegralService.GetIntegralChangeRule();

            if (info != null)
            {
                info.IntegralPerMoney = IntegralPerMoney;
            }
            else
            {
                info = new MemberIntegralExchangeRules();
                info.IntegralPerMoney = IntegralPerMoney;
            }
            _iMemberIntegralService.SetIntegralChangeRule(info);
            return(Json(new Result()
            {
                success = true, msg = "保存成功"
            }));
        }
Exemple #8
0
        public JsonResult Management(IntegralRule rule)
        {
            List <MemberIntegralRule> rules = new List <MemberIntegralRule>();

            rules.Add(new MemberIntegralRule()
            {
                Integral = rule.Reg, TypeId = (int)MemberIntegral.IntegralType.Reg
            });
            rules.Add(new MemberIntegralRule()
            {
                Integral = rule.BindWX, TypeId = (int)MemberIntegral.IntegralType.BindWX
            });
            rules.Add(new MemberIntegralRule()
            {
                Integral = rule.Login, TypeId = (int)MemberIntegral.IntegralType.Login
            });
            rules.Add(new MemberIntegralRule()
            {
                Integral = rule.Comment, TypeId = (int)MemberIntegral.IntegralType.Comment
            });
            rules.Add(new MemberIntegralRule()
            {
                Integral = rule.Share, TypeId = (int)MemberIntegral.IntegralType.Share
            });
            _iMemberIntegralService.SetIntegralRule(rules);
            var info = _iMemberIntegralService.GetIntegralChangeRule();

            if (info != null)
            {
                info.MoneyPerIntegral = rule.MoneyPerIntegral;
            }
            else
            {
                info = new MemberIntegralExchangeRules();
                info.MoneyPerIntegral = rule.MoneyPerIntegral;
            }
            _iMemberIntegralService.SetIntegralChangeRule(info);
            return(Json(new Result()
            {
                success = true, msg = "保存成功"
            }));
        }
Exemple #9
0
        public void SetIntegralChangeRule(MemberIntegralExchangeRules info)
        {
            MemberIntegralExchangeRules memberIntegralExchangeRule = context.MemberIntegralExchangeRules.FirstOrDefault();

            if (memberIntegralExchangeRule == null)
            {
                memberIntegralExchangeRule = new MemberIntegralExchangeRules()
                {
                    IntegralPerMoney = info.IntegralPerMoney,
                    MoneyPerIntegral = info.MoneyPerIntegral
                };
                context.MemberIntegralExchangeRules.Add(memberIntegralExchangeRule);
            }
            else
            {
                memberIntegralExchangeRule.IntegralPerMoney = info.IntegralPerMoney;
                memberIntegralExchangeRule.MoneyPerIntegral = info.MoneyPerIntegral;
            }
            context.SaveChanges();
        }
Exemple #10
0
        public ActionResult Management()
        {
            IEnumerable <MemberIntegralRule> integralRule = ServiceHelper.Create <IMemberIntegralService>().GetIntegralRule();
            IntegralRule       moneyPerIntegral           = new IntegralRule();
            MemberIntegralRule memberIntegralRule         = integralRule.FirstOrDefault((MemberIntegralRule a) => a.TypeId == 6);
            MemberIntegralRule memberIntegralRule1        = integralRule.FirstOrDefault((MemberIntegralRule a) => a.TypeId == 9);
            MemberIntegralRule memberIntegralRule2        = integralRule.FirstOrDefault((MemberIntegralRule a) => a.TypeId == 5);
            MemberIntegralRule memberIntegralRule3        = integralRule.FirstOrDefault((MemberIntegralRule a) => a.TypeId == 7);

            moneyPerIntegral.BindWX  = (memberIntegralRule == null ? 0 : memberIntegralRule.Integral);
            moneyPerIntegral.Reg     = (memberIntegralRule1 == null ? 0 : memberIntegralRule1.Integral);
            moneyPerIntegral.Comment = (memberIntegralRule3 == null ? 0 : memberIntegralRule3.Integral);
            moneyPerIntegral.Login   = (memberIntegralRule2 == null ? 0 : memberIntegralRule2.Integral);
            MemberIntegralExchangeRules integralChangeRule = ServiceHelper.Create <IMemberIntegralService>().GetIntegralChangeRule();

            if (integralChangeRule != null)
            {
                moneyPerIntegral.MoneyPerIntegral = integralChangeRule.MoneyPerIntegral;
            }
            return(View(moneyPerIntegral));
        }
        public ActionResult SubmitByProductId(string skuIds, string counts, long?regionId, string collpids = null)
        {
            int           num;
            int           num1;
            int           num2;
            dynamic       obj;
            IOrderService orderService = ServiceHelper.Create <IOrderService>();

            ViewBag.Logo   = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings().Logo;
            ViewBag.Member = base.CurrentUser;
            GetOrderProductsInfo(skuIds, counts, collpids);
            GetShippingAddress(regionId);
            IMemberIntegralService      memberIntegralService = ServiceHelper.Create <IMemberIntegralService>();
            MemberIntegralExchangeRules integralChangeRule    = memberIntegralService.GetIntegralChangeRule();
            MemberIntegral memberIntegral = memberIntegralService.GetMemberIntegral(base.CurrentUser.Id);
            dynamic        viewBag        = base.ViewBag;

            num = (integralChangeRule == null ? 0 : integralChangeRule.IntegralPerMoney);
            viewBag.IntegralPerMoney = num;
            dynamic viewBag1 = base.ViewBag;

            num1 = (integralChangeRule == null ? 0 : integralChangeRule.MoneyPerIntegral);
            viewBag1.MoneyPerIntegral = num1;
            dynamic obj1 = base.ViewBag;

            num2          = (memberIntegral == null ? 0 : memberIntegral.AvailableIntegrals);
            obj1.Integral = num2;
            dynamic viewBag2 = base.ViewBag;

            obj = (ViewBag.MoneyPerIntegral == 0 ? 0 : Math.Floor(ViewBag.totalAmount / ViewBag.MoneyPerIntegral));
            viewBag2.TotalIntegral = obj;
            ViewBag.collIds        = collpids;
            ViewBag.skuIds         = skuIds;
            ViewBag.counts         = counts;
            ViewBag.InvoiceTitle   = orderService.GetInvoiceTitles(base.CurrentUser.Id);
            ViewBag.InvoiceContext = orderService.GetInvoiceContexts();
            return(View("Submit"));
        }
Exemple #12
0
        public JsonResult Change(int IntegralPerMoney)
        {
            MemberIntegralExchangeRules integralChangeRule = ServiceHelper.Create <IMemberIntegralService>().GetIntegralChangeRule();

            if (integralChangeRule == null)
            {
                integralChangeRule = new MemberIntegralExchangeRules()
                {
                    IntegralPerMoney = IntegralPerMoney
                };
            }
            else
            {
                integralChangeRule.IntegralPerMoney = IntegralPerMoney;
            }
            ServiceHelper.Create <IMemberIntegralService>().SetIntegralChangeRule(integralChangeRule);
            Result result = new Result()
            {
                success = true,
                msg     = "保存成功"
            };

            return(Json(result));
        }
Exemple #13
0
        private void GetOrderProductsInfo(string cartItemIds)
        {
            CartHelper cartHelper = new CartHelper();
            IEnumerable <ShoppingCartItem> cartItems = null;

            if (!string.IsNullOrWhiteSpace(cartItemIds))
            {
                char[]             chrArray = new char[] { ',' };
                IEnumerable <long> nums     =
                    from t in cartItemIds.Split(chrArray)
                    select long.Parse(t);

                cartItems = ServiceHelper.Create <ICartService>().GetCartItems(nums);
            }
            else
            {
                cartItems = cartHelper.GetCart(base.CurrentUser.Id).Items;
            }
            int cityId = 0;
            ShippingAddressInfo defaultUserShippingAddressByUserId = ServiceHelper.Create <IShippingAddressService>().GetDefaultUserShippingAddressByUserId(base.CurrentUser.Id);

            if (defaultUserShippingAddressByUserId != null)
            {
                cityId = Instance <IRegionService> .Create.GetCityId(defaultUserShippingAddressByUserId.RegionIdPath);
            }
            IProductService      productService = ServiceHelper.Create <IProductService>();
            IShopService         shopService    = ServiceHelper.Create <IShopService>();
            List <CartItemModel> list           = cartItems.Select <ShoppingCartItem, CartItemModel>((ShoppingCartItem item) => {
                ProductInfo product = productService.GetProduct(item.ProductId);
                SKUInfo sku         = productService.GetSku(item.SkuId);
                return(new CartItemModel()
                {
                    skuId = item.SkuId,
                    id = product.Id,
                    imgUrl = product.GetImage(ProductInfo.ImageSize.Size_100, 1),
                    name = product.ProductName,
                    price = sku.SalePrice,
                    shopId = product.ShopId,
                    count = item.Quantity
                });
            }).ToList();
            IEnumerable <IGrouping <long, CartItemModel> > groupings =
                from a in list
                group a by a.shopId;
            List <ShopCartItemModel> shopCartItemModels = new List <ShopCartItemModel>();

            foreach (IGrouping <long, CartItemModel> nums1 in groupings)
            {
                IEnumerable <long> nums2 =
                    from r in nums1
                    select r.id;
                IEnumerable <int> nums3 =
                    from r in nums1
                    select r.count;
                ShopCartItemModel shopCartItemModel = new ShopCartItemModel()
                {
                    shopId = nums1.Key
                };
                if (ServiceHelper.Create <IVShopService>().GetVShopByShopId(shopCartItemModel.shopId) != null)
                {
                    shopCartItemModel.vshopId = ServiceHelper.Create <IVShopService>().GetVShopByShopId(shopCartItemModel.shopId).Id;
                }
                else
                {
                    shopCartItemModel.vshopId = 0;
                }
                shopCartItemModel.CartItemModels = (
                    from a in list
                    where a.shopId == shopCartItemModel.shopId
                    select a).ToList();
                shopCartItemModel.ShopName = shopService.GetShop(shopCartItemModel.shopId, false).ShopName;
                if (cityId > 0)
                {
                    shopCartItemModel.Freight = ServiceHelper.Create <IProductService>().GetFreight(nums2, nums3, cityId);
                }
                List <ShopBonusReceiveInfo> detailToUse = ServiceHelper.Create <IShopBonusService>().GetDetailToUse(shopCartItemModel.shopId, base.CurrentUser.Id, nums1.Sum <CartItemModel>((CartItemModel a) => a.price * a.count));
                List <CouponRecordInfo>     userCoupon  = ServiceHelper.Create <ICouponService>().GetUserCoupon(shopCartItemModel.shopId, base.CurrentUser.Id, nums1.Sum <CartItemModel>((CartItemModel a) => a.price * a.count));
                if (detailToUse.Count() > 0 && userCoupon.Count() > 0)
                {
                    ShopBonusReceiveInfo shopBonusReceiveInfo = detailToUse.FirstOrDefault();
                    CouponRecordInfo     couponRecordInfo     = userCoupon.FirstOrDefault();
                    decimal?price = shopBonusReceiveInfo.Price;
                    decimal num   = couponRecordInfo.ChemCloud_Coupon.Price;
                    if ((price.GetValueOrDefault() <= num ? true : !price.HasValue))
                    {
                        shopCartItemModel.Coupon = new CouponModel()
                        {
                            CouponName  = couponRecordInfo.ChemCloud_Coupon.CouponName,
                            CouponId    = couponRecordInfo.Id,
                            CouponPrice = couponRecordInfo.ChemCloud_Coupon.Price,
                            Type        = 0
                        };
                    }
                    else
                    {
                        shopCartItemModel.Coupon = new CouponModel()
                        {
                            CouponName  = shopBonusReceiveInfo.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.Name,
                            CouponId    = shopBonusReceiveInfo.Id,
                            CouponPrice = shopBonusReceiveInfo.Price.Value,
                            Type        = 1
                        };
                    }
                }
                else if (detailToUse.Count() <= 0 && userCoupon.Count() <= 0)
                {
                    shopCartItemModel.Coupon = null;
                }
                else if (detailToUse.Count() <= 0 && userCoupon.Count() > 0)
                {
                    CouponRecordInfo couponRecordInfo1 = userCoupon.FirstOrDefault();
                    shopCartItemModel.Coupon = new CouponModel()
                    {
                        CouponName  = couponRecordInfo1.ChemCloud_Coupon.CouponName,
                        CouponId    = couponRecordInfo1.Id,
                        CouponPrice = couponRecordInfo1.ChemCloud_Coupon.Price,
                        Type        = 0
                    };
                }
                else if (detailToUse.Count() > 0 && userCoupon.Count() <= 0)
                {
                    ShopBonusReceiveInfo shopBonusReceiveInfo1 = detailToUse.FirstOrDefault();
                    shopCartItemModel.Coupon = new CouponModel()
                    {
                        CouponName  = shopBonusReceiveInfo1.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.Name,
                        CouponId    = shopBonusReceiveInfo1.Id,
                        CouponPrice = shopBonusReceiveInfo1.Price.Value,
                        Type        = 1
                    };
                }
                decimal num1        = shopCartItemModel.CartItemModels.Sum <CartItemModel>((CartItemModel d) => d.price * d.count);
                decimal num2        = num1 - (shopCartItemModel.Coupon == null ? new decimal(0) : shopCartItemModel.Coupon.CouponPrice);
                decimal freeFreight = shopService.GetShop(shopCartItemModel.shopId, false).FreeFreight;
                shopCartItemModel.isFreeFreight = false;
                if (freeFreight > new decimal(0))
                {
                    shopCartItemModel.shopFreeFreight = freeFreight;
                    if (num2 >= freeFreight)
                    {
                        shopCartItemModel.Freight       = new decimal(0);
                        shopCartItemModel.isFreeFreight = true;
                    }
                }
                shopCartItemModels.Add(shopCartItemModel);
            }
            decimal num3 = (
                from a in shopCartItemModels
                where a.Coupon != null
                select a).Sum <ShopCartItemModel>((ShopCartItemModel b) => b.Coupon.CouponPrice);

            ViewBag.products         = shopCartItemModels;
            base.ViewBag.totalAmount = list.Sum <CartItemModel>((CartItemModel item) => item.price * item.count);
            base.ViewBag.Freight     = shopCartItemModels.Sum <ShopCartItemModel>((ShopCartItemModel a) => a.Freight);
            dynamic viewBag = base.ViewBag;
            dynamic obj     = ViewBag.totalAmount;

            viewBag.orderAmount = obj + ViewBag.Freight - num3;
            IMemberIntegralService memberIntegralService = ServiceHelper.Create <IMemberIntegralService>();
            MemberIntegral         memberIntegral        = memberIntegralService.GetMemberIntegral(base.CurrentUser.Id);
            int num4 = (memberIntegral == null ? 0 : memberIntegral.AvailableIntegrals);

            ViewBag.userIntegrals      = num4;
            ViewBag.integralPerMoney   = 0;
            ViewBag.memberIntegralInfo = memberIntegral;
            MemberIntegralExchangeRules integralChangeRule = memberIntegralService.GetIntegralChangeRule();
            decimal num5     = new decimal(0);
            decimal num6     = new decimal(0);
            decimal viewBag1 = (decimal)ViewBag.totalAmount;

            if (integralChangeRule == null || integralChangeRule.IntegralPerMoney <= 0)
            {
                num5 = new decimal(0);
                num6 = new decimal(0);
            }
            else
            {
                if (((viewBag1 - num3) - Math.Round((decimal)num4 / integralChangeRule.IntegralPerMoney, 2)) <= new decimal(0))
                {
                    num5 = Math.Round(viewBag1 - num3, 2);
                    num6 = Math.Round((viewBag1 - num3) * integralChangeRule.IntegralPerMoney);
                }
                else
                {
                    num5 = Math.Round((decimal)num4 / integralChangeRule.IntegralPerMoney, 2);
                    num6 = num4;
                }
                if (num5 <= new decimal(0))
                {
                    num5 = new decimal(0);
                    num6 = new decimal(0);
                }
            }
            ViewBag.integralPerMoney = num5;
            ViewBag.userIntegrals    = num6;
        }
Exemple #14
0
        private void GetOrderProductsInfo(IEnumerable <string> skuIds, IEnumerable <int> counts)
        {
            IProductService     productService = ServiceHelper.Create <IProductService>();
            IShopService        shopService    = ServiceHelper.Create <IShopService>();
            int                 num3           = 0;
            int                 cityId         = 0;
            ShippingAddressInfo defaultUserShippingAddressByUserId = ServiceHelper.Create <IShippingAddressService>().GetDefaultUserShippingAddressByUserId(base.CurrentUser.Id);

            if (defaultUserShippingAddressByUserId != null)
            {
                cityId = Instance <IRegionService> .Create.GetCityId(defaultUserShippingAddressByUserId.RegionIdPath);
            }
            List <CartItemModel> list = skuIds.Select <string, CartItemModel>((string item) => {
                SKUInfo sku            = productService.GetSku(item);
                IEnumerable <int> nums = counts;
                int num  = num3;
                int num1 = num;
                num3     = num + 1;
                int num2 = nums.ElementAt <int>(num1);
                LimitTimeMarketInfo limitTimeMarketItemByProductId = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItemByProductId(sku.ProductInfo.Id);
                if (limitTimeMarketItemByProductId != null && num2 > limitTimeMarketItemByProductId.MaxSaleCount)
                {
                    throw new HimallException(string.Concat("超过最大限购数量:", limitTimeMarketItemByProductId.MaxSaleCount.ToString()));
                }
                return(new CartItemModel()
                {
                    skuId = item,
                    id = sku.ProductInfo.Id,
                    imgUrl = sku.ProductInfo.GetImage(ProductInfo.ImageSize.Size_100, 1),
                    name = sku.ProductInfo.ProductName,
                    shopId = sku.ProductInfo.ShopId,
                    price = (limitTimeMarketItemByProductId == null ? sku.SalePrice : limitTimeMarketItemByProductId.Price),
                    count = num2,
                    productCode = sku.ProductInfo.ProductCode
                });
            }).ToList();
            IEnumerable <IGrouping <long, CartItemModel> > groupings =
                from a in list
                group a by a.shopId;
            List <ShopCartItemModel> shopCartItemModels = new List <ShopCartItemModel>();

            foreach (IGrouping <long, CartItemModel> nums1 in groupings)
            {
                IEnumerable <long> nums2 =
                    from r in nums1
                    select r.id;
                IEnumerable <int> nums3 =
                    from r in nums1
                    select r.count;
                ShopCartItemModel shopCartItemModel = new ShopCartItemModel()
                {
                    shopId = nums1.Key
                };
                shopCartItemModel.CartItemModels = (
                    from a in list
                    where a.shopId == shopCartItemModel.shopId
                    select a).ToList();
                shopCartItemModel.ShopName = shopService.GetShop(shopCartItemModel.shopId, false).ShopName;
                if (cityId != 0)
                {
                    shopCartItemModel.Freight = ServiceHelper.Create <IProductService>().GetFreight(nums2, nums3, cityId);
                }
                List <ShopBonusReceiveInfo> detailToUse = ServiceHelper.Create <IShopBonusService>().GetDetailToUse(shopCartItemModel.shopId, base.CurrentUser.Id, nums1.Sum <CartItemModel>((CartItemModel a) => a.price * a.count));
                List <CouponRecordInfo>     userCoupon  = ServiceHelper.Create <ICouponService>().GetUserCoupon(shopCartItemModel.shopId, base.CurrentUser.Id, nums1.Sum <CartItemModel>((CartItemModel a) => a.price * a.count));
                if (detailToUse.Count() > 0 && userCoupon.Count() > 0)
                {
                    ShopBonusReceiveInfo shopBonusReceiveInfo = detailToUse.FirstOrDefault();
                    CouponRecordInfo     couponRecordInfo     = userCoupon.FirstOrDefault();
                    decimal?price  = shopBonusReceiveInfo.Price;
                    decimal price1 = couponRecordInfo.ChemCloud_Coupon.Price;
                    if ((price.GetValueOrDefault() <= price1 ? true : !price.HasValue))
                    {
                        shopCartItemModel.Coupon = new CouponModel()
                        {
                            CouponName  = couponRecordInfo.ChemCloud_Coupon.CouponName,
                            CouponId    = couponRecordInfo.Id,
                            CouponPrice = couponRecordInfo.ChemCloud_Coupon.Price,
                            Type        = 0
                        };
                    }
                    else
                    {
                        shopCartItemModel.Coupon = new CouponModel()
                        {
                            CouponName  = shopBonusReceiveInfo.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.Name,
                            CouponId    = shopBonusReceiveInfo.Id,
                            CouponPrice = shopBonusReceiveInfo.Price.Value,
                            Type        = 1
                        };
                    }
                }
                else if (detailToUse.Count() <= 0 && userCoupon.Count() <= 0)
                {
                    shopCartItemModel.Coupon = null;
                }
                else if (detailToUse.Count() <= 0 && userCoupon.Count() > 0)
                {
                    CouponRecordInfo couponRecordInfo1 = userCoupon.FirstOrDefault();
                    shopCartItemModel.Coupon = new CouponModel()
                    {
                        CouponName  = couponRecordInfo1.ChemCloud_Coupon.CouponName,
                        CouponId    = couponRecordInfo1.Id,
                        CouponPrice = couponRecordInfo1.ChemCloud_Coupon.Price,
                        Type        = 0
                    };
                }
                else if (detailToUse.Count() > 0 && userCoupon.Count() <= 0)
                {
                    ShopBonusReceiveInfo shopBonusReceiveInfo1 = detailToUse.FirstOrDefault();
                    shopCartItemModel.Coupon = new CouponModel()
                    {
                        CouponName  = shopBonusReceiveInfo1.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.Name,
                        CouponId    = shopBonusReceiveInfo1.Id,
                        CouponPrice = shopBonusReceiveInfo1.Price.Value,
                        Type        = 1
                    };
                }
                decimal num4        = shopCartItemModel.CartItemModels.Sum <CartItemModel>((CartItemModel d) => d.price * d.count);
                decimal num5        = num4 - (shopCartItemModel.Coupon == null ? new decimal(0) : shopCartItemModel.Coupon.CouponPrice);
                decimal freeFreight = shopService.GetShop(shopCartItemModel.shopId, false).FreeFreight;
                shopCartItemModel.isFreeFreight = false;
                if (freeFreight > new decimal(0))
                {
                    shopCartItemModel.shopFreeFreight = freeFreight;
                    if (num5 >= freeFreight)
                    {
                        shopCartItemModel.Freight       = new decimal(0);
                        shopCartItemModel.isFreeFreight = true;
                    }
                }
                shopCartItemModels.Add(shopCartItemModel);
            }
            decimal num6 = (
                from a in shopCartItemModels
                where a.Coupon != null
                select a).Sum <ShopCartItemModel>((ShopCartItemModel b) => b.Coupon.CouponPrice);

            ViewBag.products         = shopCartItemModels;
            base.ViewBag.totalAmount = list.Sum <CartItemModel>((CartItemModel item) => item.price * item.count);
            base.ViewBag.Freight     = shopCartItemModels.Sum <ShopCartItemModel>((ShopCartItemModel a) => a.Freight);
            dynamic viewBag = base.ViewBag;
            dynamic obj     = ViewBag.totalAmount;

            viewBag.orderAmount = obj + ViewBag.Freight - num6;
            IMemberIntegralService memberIntegralService = ServiceHelper.Create <IMemberIntegralService>();
            MemberIntegral         memberIntegral        = memberIntegralService.GetMemberIntegral(base.CurrentUser.Id);
            int num7 = (memberIntegral == null ? 0 : memberIntegral.AvailableIntegrals);

            ViewBag.userIntegrals      = num7;
            ViewBag.integralPerMoney   = 0;
            ViewBag.memberIntegralInfo = memberIntegral;
            MemberIntegralExchangeRules integralChangeRule = memberIntegralService.GetIntegralChangeRule();
            decimal viewBag1 = new decimal(0);
            decimal viewBag2 = new decimal(0);

            if (integralChangeRule == null || integralChangeRule.IntegralPerMoney <= 0)
            {
                viewBag1 = new decimal(0);
                viewBag2 = new decimal(0);
            }
            else
            {
                if (ViewBag.totalAmount - num6 - Math.Round((decimal)num7 / integralChangeRule.IntegralPerMoney, 2) <= 0)
                {
                    viewBag1 = Math.Round(ViewBag.totalAmount - num6, 2);
                    viewBag2 = Math.Round((ViewBag.totalAmount - num6) * integralChangeRule.IntegralPerMoney);
                }
                else
                {
                    viewBag1 = Math.Round((decimal)num7 / integralChangeRule.IntegralPerMoney, 2);
                    viewBag2 = num7;
                }
                if (viewBag1 <= new decimal(0))
                {
                    viewBag1 = new decimal(0);
                    viewBag2 = new decimal(0);
                }
            }
            ViewBag.integralPerMoney = viewBag1;
            ViewBag.userIntegrals    = viewBag2;
        }
Exemple #15
0
        public void ConfirmRefund(long refundId, string managerRemark, string managerName)
        {
            decimal?        nullable;
            OrderRefundInfo now = context.OrderRefundInfo.FindById <OrderRefundInfo>(refundId);

            if (now.RefundPayType.HasValue)
            {
                switch (now.RefundPayType.Value)
                {
                case OrderRefundInfo.OrderRefundPayType.BackOut:
                {
                    if (now.RefundPayStatus.HasValue && now.RefundPayStatus.Value == OrderRefundInfo.OrderRefundPayStatus.PaySuccess)
                    {
                        break;
                    }
                    string paymentTypeGateway = now.OrderItemInfo.OrderInfo.PaymentTypeGateway;
                    IEnumerable <Plugin <IPaymentPlugin> > plugins =
                        from item in PluginsManagement.GetPlugins <IPaymentPlugin>(true)
                        where item.PluginInfo.PluginId == paymentTypeGateway
                        select item;
                    if (plugins.Count <Plugin <IPaymentPlugin> >() <= 0)
                    {
                        throw new HimallException("退款时,未找到支付方式!");
                    }
                    OrderPayInfo      orderPayInfo = context.OrderPayInfo.FirstOrDefault((OrderPayInfo e) => e.PayState && e.OrderId == now.OrderId);
                    IQueryable <long> nums         =
                        from item in context.OrderPayInfo
                        where item.PayId == orderPayInfo.PayId && item.PayState
                        select item into e
                        select e.OrderId;
                    decimal num = (
                        from o in context.OrderInfo
                        where nums.Contains(o.Id)
                        select o).ToList().Sum <OrderInfo>((OrderInfo e) => e.OrderTotalAmount);
                    if (orderPayInfo == null)
                    {
                        throw new HimallException("退款时,未找到原支付订单信息!");
                    }
                    PaymentPara paymentPara = new PaymentPara()
                    {
                        out_refund_no = now.Id.ToString(),
                        out_trade_no  = orderPayInfo.PayId.ToString(),
                        refund_fee    = now.Amount,
                        total_fee     = num
                    };
                    PaymentPara paymentPara1 = paymentPara;
                    PaymentInfo paymentInfo  = plugins.FirstOrDefault <Plugin <IPaymentPlugin> >().Biz.ProcessRefundFee(paymentPara1);
                    if (paymentInfo.OrderIds == null || paymentInfo.OrderIds.Count() <= 0)
                    {
                        break;
                    }
                    now.RefundPayStatus = new OrderRefundInfo.OrderRefundPayStatus?(OrderRefundInfo.OrderRefundPayStatus.PaySuccess);
                    context.SaveChanges();
                    break;
                }

                case OrderRefundInfo.OrderRefundPayType.BackCapital:
                {
                    if (now.RefundPayStatus.HasValue && now.RefundPayStatus.Value == OrderRefundInfo.OrderRefundPayStatus.PaySuccess)
                    {
                        break;
                    }
                    CapitalInfo capitalInfo = context.CapitalInfo.FirstOrDefault((CapitalInfo e) => e.MemId == now.UserId);
                    OrderBO     orderBO     = new OrderBO();
                    if (capitalInfo != null)
                    {
                        CapitalDetailInfo capitalDetailInfo = new CapitalDetailInfo()
                        {
                            Amount     = now.Amount,
                            CapitalID  = capitalInfo.Id,
                            CreateTime = new DateTime?(DateTime.Now),
                            SourceType = CapitalDetailInfo.CapitalDetailType.Refund,
                            SourceData = now.Id.ToString(),
                            Id         = orderBO.GenerateOrderNumber()
                        };
                        CapitalDetailInfo capitalDetailInfo1 = capitalDetailInfo;
                        CapitalInfo       capitalInfo1       = capitalInfo;
                        decimal?          balance            = capitalInfo1.Balance;
                        decimal           amount             = now.Amount;
                        if (balance.HasValue)
                        {
                            nullable = new decimal?(balance.GetValueOrDefault() + amount);
                        }
                        else
                        {
                            nullable = null;
                        }
                        capitalInfo1.Balance = nullable;
                        context.CapitalDetailInfo.Add(capitalDetailInfo1);
                    }
                    else
                    {
                        CapitalInfo capitalInfo2 = new CapitalInfo()
                        {
                            Balance      = new decimal?(now.Amount),
                            MemId        = now.UserId,
                            FreezeAmount = new decimal?(new decimal(0)),
                            ChargeAmount = new decimal?(new decimal(0))
                        };
                        List <CapitalDetailInfo> capitalDetailInfos = new List <CapitalDetailInfo>();
                        CapitalDetailInfo        capitalDetailInfo2 = new CapitalDetailInfo()
                        {
                            Amount     = now.Amount,
                            CreateTime = new DateTime?(DateTime.Now),
                            SourceData = now.Id.ToString(),
                            SourceType = CapitalDetailInfo.CapitalDetailType.Refund,
                            Id         = orderBO.GenerateOrderNumber()
                        };
                        capitalDetailInfos.Add(capitalDetailInfo2);
                        capitalInfo2.ChemCloud_CapitalDetail = capitalDetailInfos;
                        capitalInfo = capitalInfo2;
                        context.CapitalInfo.Add(capitalInfo);
                    }
                    now.RefundPayStatus = new OrderRefundInfo.OrderRefundPayStatus?(OrderRefundInfo.OrderRefundPayStatus.PaySuccess);
                    context.SaveChanges();
                    break;
                }
                }
            }
            if (now.ManagerConfirmStatus != OrderRefundInfo.OrderRefundConfirmStatus.UnConfirm)
            {
                throw new HimallException("只有未确认状态的退款/退货才能进行确认操作");
            }
            now.ManagerConfirmStatus = OrderRefundInfo.OrderRefundConfirmStatus.Confirmed;
            now.ManagerConfirmDate   = DateTime.Now;
            now.ManagerRemark        = managerRemark;
            OrderOperationLogInfo orderOperationLogInfo = new OrderOperationLogInfo()
            {
                Operator       = managerName,
                OrderId        = now.OrderId,
                OperateDate    = DateTime.Now,
                OperateContent = "确认退款/退货"
            };

            context.OrderOperationLogInfo.Add(orderOperationLogInfo);
            UserMemberInfo userMemberInfo   = context.UserMemberInfo.FindById <UserMemberInfo>(now.UserId);
            OrderInfo      orderInfo        = context.OrderInfo.FindById <OrderInfo>(now.OrderId);
            decimal        orderTotalAmount = orderInfo.OrderTotalAmount - orderInfo.Freight;
            decimal        amount1          = now.Amount - (orderInfo.IntegralDiscount * (now.Amount / orderTotalAmount));

            amount1 = Math.Round(amount1, 2);
            if (amount1 > new decimal(0))
            {
                OrderInfo refundTotalAmount = orderInfo;
                refundTotalAmount.RefundTotalAmount = refundTotalAmount.RefundTotalAmount + amount1;
                if (orderInfo.RefundTotalAmount > orderTotalAmount)
                {
                    orderInfo.RefundTotalAmount = orderTotalAmount;
                }
            }
            if (now.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund)
            {
                MemberIntegralExchangeRules integralChangeRule = Instance <IMemberIntegralService> .Create.GetIntegralChangeRule();

                if (integralChangeRule != null)
                {
                    int            moneyPerIntegral = integralChangeRule.MoneyPerIntegral;
                    int            num1             = (int)Math.Floor(now.Amount / moneyPerIntegral);
                    MemberIntegral memberIntegral   = userMemberInfo.ChemCloud_MemberIntegral.FirstOrDefault();
                    int            num2             = (memberIntegral == null ? 0 : memberIntegral.AvailableIntegrals);
                    if (num1 > 0 && num2 > 0 && orderInfo.OrderStatus == OrderInfo.OrderOperateStatus.Finish)
                    {
                        MemberIntegralRecord memberIntegralRecord = new MemberIntegralRecord()
                        {
                            UserName   = userMemberInfo.UserName,
                            MemberId   = userMemberInfo.Id,
                            RecordDate = new DateTime?(DateTime.Now),
                            TypeId     = MemberIntegral.IntegralType.Others
                        };
                        object[] id = new object[] { "售后编号【", now.Id, "】退款应扣除积分", num1.ToString() };
                        memberIntegralRecord.ReMark = string.Concat(id);
                        num1 = (num1 > num2 ? num2 : num1);
                        num1 = -num1;
                        IConversionMemberIntegralBase conversionMemberIntegralBase = Instance <IMemberIntegralConversionFactoryService> .Create.Create(MemberIntegral.IntegralType.Others, num1);

                        Instance <IMemberIntegralService> .Create.AddMemberIntegral(memberIntegralRecord, conversionMemberIntegralBase);
                    }
                }
            }
            context.SaveChanges();
            MessageOrderInfo messageOrderInfo = new MessageOrderInfo()
            {
                OrderId     = orderInfo.Id.ToString(),
                ShopId      = orderInfo.ShopId,
                ShopName    = orderInfo.ShopName,
                RefundMoney = now.Amount,
                SiteName    = Instance <ISiteSettingService> .Create.GetSiteSettings().SiteName,
                TotalMoney  = orderInfo.OrderTotalAmount
            };

            Task.Factory.StartNew(() => Instance <IMessageService> .Create.SendMessageOnOrderRefund(orderInfo.UserId, messageOrderInfo));
            if (orderInfo.PayDate.HasValue)
            {
                UpdateShopVisti(now, orderInfo.PayDate.Value);
                UpdateProductVisti(now, orderInfo.PayDate.Value);
            }
        }
 /// <summary>
 /// 设置积分兑换规则
 /// </summary>
 public static void SetIntegralChangeRule(MemberIntegralExchangeRules info)
 {
     _iMemberIntegralService.SetIntegralChangeRule(info);
 }