示例#1
0
        /// <summary>
        /// 更新门店信息、管理员密码
        /// </summary>
        /// <param name="shopBranch"></param>
        public static void UpdateShopBranch(ShopBranch shopBranch)
        {
            if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName))
            {
                throw new MallException("门店名称不能重复!");
            }

            //AutoMapper.Mapper.CreateMap<ShopBranch, ShopBranchInfo>();
            //var shopBranchInfo = AutoMapper.Mapper.Map<ShopBranch, ShopBranchInfo>(shopBranch);

            var shopBranchInfo = shopBranch.Map <ShopBranchInfo>();


            shopBranchInfo.AddressPath = RegionApplication.GetRegionPath(shopBranchInfo.AddressId);
            //默认在结尾增加分隔符
            shopBranchInfo.AddressPath = shopBranchInfo.AddressPath + CommonConst.ADDRESS_PATH_SPLIT;
            Service.UpdateShopBranch(shopBranchInfo);

            if (!string.IsNullOrEmpty(shopBranch.PasswordOne))
            {
                if (shopBranch.PasswordOne != shopBranch.PasswordTwo)
                {
                    throw new MessageException("两次密码输入不一致");
                }
                //设置门店管理密码
                SetShopBranchManagerPassword(shopBranchInfo.Id, shopBranch.PasswordOne);
            }
        }
示例#2
0
        // Methods
        public ActionResult Add()
        {
            List <ShopBranchTagModel> allShopBranchTagInfos = ShopBranchApplication.GetAllShopBranchTagInfos();
            List <SelectListItem>     list2 = new List <SelectListItem>();

            foreach (ShopBranchTagModel model in allShopBranchTagInfos)
            {
                SelectListItem item = new SelectListItem
                {
                    Selected = false,
                    Value    = model.Id.ToString(),
                    Text     = model.Title
                };
                list2.Add(item);
            }
            ((dynamic)base.ViewBag).ShopBranchTags = list2;
            ShopBranch branch = new ShopBranch
            {
                IsStoreDelive  = true,
                ServeRadius    = 0,
                DeliveFee      = 0,
                DeliveTotalFee = 0,
                FreeMailFee    = 0
            };

            return(base.View(branch));
        }
        /// <summary>
        /// 查询门店产品
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public static QueryPageModel <ShopBranch> StoreByProductNearShopBranchs(ShopBranchQuery search)
        {
            QueryPageModel <ShopBranchInfo> queryPageModel = ShopBranchApplication._shopBranchService.StoreByProductNearShopBranchs(search);

            return(new QueryPageModel <ShopBranch>()
            {
                Models = Enumerable.ToList <ShopBranch>(Enumerable.Select <ShopBranchInfo, ShopBranch>((IEnumerable <ShopBranchInfo>)queryPageModel.Models, (Func <ShopBranchInfo, ShopBranch>)(e =>
                {
                    ShopBranch shopBranch1 = new ShopBranch();
                    shopBranch1.AddressDetail = ShopBranchApplication.RenderAddress(e.AddressPath, e.AddressDetail, 1);
                    shopBranch1.ContactPhone = e.ContactPhone;
                    shopBranch1.Id = e.Id;
                    shopBranch1.ShopBranchName = e.ShopBranchName;
                    shopBranch1.Status = e.Status;
                    shopBranch1.DistanceUnit = e.Distance >= 1.0 ? (string)(object)e.Distance + (object)"KM" : (string)(object)(e.Distance * 1000.0) + (object)"M";
                    shopBranch1.Distance = e.Distance;
                    shopBranch1.ServeRadius = e.ServeRadius.HasValue ? e.ServeRadius.Value : 0;
                    ShopBranch shopBranch2 = shopBranch1;
                    float?nullable;
                    double num1;
                    if (!e.Latitude.HasValue)
                    {
                        num1 = 0.0;
                    }
                    else
                    {
                        nullable = e.Latitude;
                        num1 = (double)nullable.Value;
                    }
                    shopBranch2.Latitude = (float)num1;
                    ShopBranch shopBranch3 = shopBranch1;
                    nullable = e.Longitude;
                    double num2;
                    if (!nullable.HasValue)
                    {
                        num2 = 0.0;
                    }
                    else
                    {
                        nullable = e.Longitude;
                        num2 = (double)nullable.Value;
                    }
                    shopBranch3.Longitude = (float)num2;
                    shopBranch1.DeliveFee = e.DeliveFee;
                    shopBranch1.DeliveTotalFee = e.DeliveTotalFee;
                    shopBranch1.IsAboveSelf = e.IsAboveSelf;
                    shopBranch1.IsStoreDelive = e.IsStoreDelive;
                    shopBranch1.ShopImages = HimallIO.GetRomoteImagePath(e.ShopImages, (string)null);
                    shopBranch1.ShopId = e.ShopId;
                    shopBranch1.FreeMailFee = e.FreeMailFee;
                    shopBranch1.IsRecommend = e.IsRecommend;
                    shopBranch1.RecommendSequence = e.RecommendSequence == 0L ? long.MaxValue : e.RecommendSequence;
                    return shopBranch1;
                }))),
                Total = queryPageModel.Total
            });
        }
 public object PostUpdteAutoPrint(ShopBranch info)
 {
     ShopApplication.SetAutoPrint(CurrentUser.ShopId, info.IsAutoPrint);
     string userkey = WebHelper.GetFormString("userkey");
     var currentInfo = PrintHub.ConnectedUsers.FirstOrDefault(p => p.UserKey == userkey);
     if (currentInfo != null)
         currentInfo.IsAutoPrint = info.IsAutoPrint;
     return new { success = true };
 }
示例#5
0
 public ActionResult Edit(ShopBranch shopBranch)
 {
     try
     {
         if (!string.Equals(shopBranch.PasswordOne, shopBranch.PasswordTwo))
         {
             throw new HimallException("两次密码输入不一致!");
         }
         if (shopBranch.ShopBranchName.Length > 15)
         {
             throw new HimallException("门店名称不能超过15个字!");
         }
         if (shopBranch.AddressDetail.Length > 50)
         {
             throw new HimallException("详细地址不能超过50个字!");
         }
         if ((shopBranch.Latitude <= 0f) || (shopBranch.Longitude <= 0f))
         {
             throw new HimallException("请搜索地址地图定位!");
         }
         shopBranch.ShopId = base.CurrentSellerManager.ShopId;
         ShopBranch shopBranchById = ShopBranchApplication.GetShopBranchById(shopBranch.Id);
         if ((shopBranchById != null) && (shopBranchById.ShopId != shopBranch.ShopId))
         {
             throw new HimallException("不能修改其他商家的门店!");
         }
         try
         {
             string[] strs      = new string[] { shopBranch.Id.ToString() };
             string[] strArray2 = (shopBranch.ShopBranchTagId == null) ? new string[0] : shopBranch.ShopBranchTagId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
             ShopBranchApplication.SetShopBrandTagInfos(this.convertLongs(strs), this.convertLongs(strArray2));
         }
         catch
         {
         }
         ShopBranchApplication.UpdateShopBranch(shopBranch);
     }
     catch (Exception exception)
     {
         BaseController.Result result = new BaseController.Result
         {
             success = false,
             msg     = exception.Message
         };
         return(base.Json(result));
     }
     BaseController.Result data = new BaseController.Result
     {
         success = true
     };
     return(base.Json(data));
 }
        public object GetSubmitByCartModel(string cartItemIds = "")
        {
            this.CheckUserLogin();
            MobileOrderDetailConfirmModel mobileSubmiteByCart = OrderApplication.GetMobileSubmiteByCart(this.CurrentUserId, cartItemIds);

            if (mobileSubmiteByCart.shopBranchInfo == null)
            {
                throw new HimallException("获取门店信息失败,不可提交非门店商品");
            }
            ShopBranch shopBranchById = ShopBranchApplication.GetShopBranchById(mobileSubmiteByCart.shopBranchInfo.Id);
            object     obj1           = (object)new ExpandoObject();
            object     obj2;

            if (mobileSubmiteByCart.Address != null)
            {
                string str = mobileSubmiteByCart.Address.AddressDetail ?? "";
                var    fAnonymousType30 = new
                {
                    Id       = mobileSubmiteByCart.Address.Id,
                    ShipTo   = mobileSubmiteByCart.Address.ShipTo,
                    Phone    = mobileSubmiteByCart.Address.Phone,
                    Address  = mobileSubmiteByCart.Address.RegionFullName + " " + mobileSubmiteByCart.Address.Address + " " + str,
                    RegionId = mobileSubmiteByCart.Address.RegionId
                };
                obj2 = (object)fAnonymousType30;
            }
            else
            {
                obj2 = (object)null;
            }
            return((object)this.Json(new
            {
                Success = "true",
                Address = obj2,
                IsCashOnDelivery = mobileSubmiteByCart.IsCashOnDelivery,
                InvoiceContext = mobileSubmiteByCart.InvoiceContext,
                InvoiceTitle = OrderApplication.GetInvoiceTitles(this.CurrentUserId),
                products = mobileSubmiteByCart.products,
                integralPerMoney = mobileSubmiteByCart.integralPerMoney,
                userIntegrals = mobileSubmiteByCart.userIntegrals,
                TotalAmount = mobileSubmiteByCart.totalAmount,
                Freight = mobileSubmiteByCart.Freight,
                orderAmount = mobileSubmiteByCart.orderAmount,
                shopBranchInfo = shopBranchById,
                IsOpenStore = SiteSettingApplication.GetSiteSettings() != null && SiteSettingApplication.GetSiteSettings().IsOpenStore,
                capitalAmount = mobileSubmiteByCart.capitalAmount
            }));
        }
示例#7
0
        public object PostUpdtePrintCount(ShopBranch info)
        {
            var shopBranchInfo = ShopBranchApplication.GetShopBranchById(CurrentShopBranch.Id);

            if (shopBranchInfo != null)
            {
                shopBranchInfo.PrintCount = info.PrintCount;
                ShopBranchApplication.UpdateShopBranch(shopBranchInfo);
                string userkey     = WebHelper.GetFormString("userkey");
                var    currentInfo = PrintHub.ConnectedUsers.FirstOrDefault(p => p.UserKey == userkey);
                if (currentInfo != null)
                {
                    currentInfo.PrintCount = info.PrintCount;
                }
            }
            return(new { success = true });
        }
示例#8
0
        public ActionResult Edit(long id)
        {
            ShopBranch shopBranchById = ShopBranchApplication.GetShopBranchById(id);
            List <ShopBranchTagModel> allShopBranchTagInfos = ShopBranchApplication.GetAllShopBranchTagInfos();
            List <SelectListItem>     list2 = new List <SelectListItem>();

            foreach (ShopBranchTagModel model in allShopBranchTagInfos)
            {
                SelectListItem item = new SelectListItem
                {
                    Selected = (shopBranchById.ShopBranchTagId == null) ? false : (shopBranchById.ShopBranchTagId.Split(new char[] { ',' }).Contains <string>(model.Id.ToString()) ? true : false),
                    Value    = model.Id.ToString(),
                    Text     = model.Title
                };
                list2.Add(item);
            }
            ((dynamic)base.ViewBag).ShopBranchTags = list2;
            return(base.View(shopBranchById));
        }
        /// <summary>
        /// 更新门店信息、管理员密码
        /// </summary>
        /// <param name="shopBranch"></param>
        public static void UpdateShopBranch(ShopBranch shopBranch)
        {
            if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName))
            {
                throw new HimallException("门店名称不能重复!");
            }
            Mapper.CreateMap <ShopBranch, ShopBranchInfo>();
            ShopBranchInfo info = Mapper.Map <ShopBranch, ShopBranchInfo>(shopBranch);

            info.AddressPath = RegionApplication.GetRegionPath(info.AddressId);
            info.AddressPath = info.AddressPath + ",";
            _shopBranchService.UpdateShopBranch(info);
            if (!(string.IsNullOrWhiteSpace(shopBranch.PasswordOne) || string.IsNullOrWhiteSpace(shopBranch.PasswordTwo)))
            {
                string salt           = GetSalt();
                string passwrodEncode = GetPasswrodEncode(shopBranch.PasswordOne, salt);
                _shopBranchService.UpdateShopBranchManagerPwd(shopBranch.Id, shopBranch.UserName, passwrodEncode, salt);
            }
        }
示例#10
0
 private string GetLinkName(string url)
 {
     string[] strArray = url.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
     if (strArray.Length == 2)
     {
         string s      = strArray[1].Substring(strArray[1].LastIndexOf('/') + 1);
         long   result = 0L;
         long.TryParse(s, out result);
         string str3 = strArray[0];
         if (str3 != null)
         {
             if (!(str3 == "1"))
             {
                 if (str3 == "2")
                 {
                     ShopBranch shopBranchById = ShopBranchApplication.GetShopBranchById(result);
                     if (null != shopBranchById)
                     {
                         return(shopBranchById.ShopBranchName);
                     }
                 }
                 else if (str3 == "3")
                 {
                     TopicInfo topicInfo = this._iTopicService.GetTopicInfo(result);
                     if (null != topicInfo)
                     {
                         return(topicInfo.Name);
                     }
                 }
             }
             else
             {
                 ShopBranchTagModel shopBranchTagInfo = ShopBranchApplication.GetShopBranchTagInfo(result);
                 if (null != shopBranchTagInfo)
                 {
                     return(shopBranchTagInfo.Title);
                 }
             }
         }
     }
     return("");
 }
示例#11
0
        /// <summary>
        /// 更新门店信息、管理员密码
        /// </summary>
        /// <param name="shopBranch"></param>
        public static void UpdateShopBranch(ShopBranch shopBranch)
        {
            if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName))
            {
                throw new HimallException("门店名称不能重复!");
            }
            AutoMapper.Mapper.CreateMap <ShopBranch, ShopBranchInfo>();
            var shopBranchInfo = AutoMapper.Mapper.Map <ShopBranch, ShopBranchInfo>(shopBranch);

            shopBranchInfo.AddressPath = RegionApplication.GetRegionPath(shopBranchInfo.AddressId);
            //默认在结尾增加分隔符
            shopBranchInfo.AddressPath = shopBranchInfo.AddressPath + CommonConst.ADDRESS_PATH_SPLIT;
            _shopBranchService.UpdateShopBranch(shopBranchInfo);
            if (!string.IsNullOrWhiteSpace(shopBranch.PasswordOne) && !string.IsNullOrWhiteSpace(shopBranch.PasswordTwo))
            {                              //编辑时可以不输入密码
                var salt      = GetSalt(); //取salt
                var encodePwd = GetPasswrodEncode(shopBranch.PasswordOne, salt);

                _shopBranchService.UpdateShopBranchManagerPwd(shopBranch.Id, shopBranch.UserName, encodePwd, salt);
            }
        }
示例#12
0
        /// <summary>
        /// 新增门店
        /// </summary>
        public static void AddShopBranch(ShopBranch shopBranch, out long shopBranchId)
        {
            if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName))
            {
                throw new MallException("此门店名称已存在,请设置其他名称!");
            }
            var branchManangerInfo = Service.GetShopBranchManagersByName(shopBranch.UserName);

            if (branchManangerInfo != null)
            {
                throw new MallException("此门店管理员账号已存在,请设置其他名称!");
            }
            if (ManagerApplication.CheckUserNameExist(shopBranch.UserName))
            {
                throw new MallException("此门店管理员账号已存在,请设置其他名称!");
            }
            // AutoMapper.Mapper.CreateMap<ShopBranch, Entities.ShopBranchInfo>();
            //  var shopBranchInfo = AutoMapper.Mapper.Map<ShopBranch, Entities.ShopBranchInfo>(shopBranch);

            var shopBranchInfo = shopBranch.Map <Entities.ShopBranchInfo>();

            shopBranchInfo.AddressPath = RegionApplication.GetRegionPath(shopBranchInfo.AddressId);
            //默认在结尾增加分隔符
            shopBranchInfo.AddressPath = shopBranchInfo.AddressPath + CommonConst.ADDRESS_PATH_SPLIT;
            Service.AddShopBranch(shopBranchInfo);
            shopBranchId = shopBranchInfo.Id;
            var salt = GetSalt();
            var shopBranchManagerInfo = new Entities.ShopBranchManagerInfo
            {
                CreateDate   = DateTime.Now,
                UserName     = shopBranch.UserName,
                ShopBranchId = shopBranchInfo.Id,
                PasswordSalt = salt,
                Password     = GetPasswrodEncode(shopBranch.PasswordOne, salt)
            };

            Service.AddShopBranchManagers(shopBranchManagerInfo);
            shopBranch.Id = shopBranchInfo.Id;
        }
示例#13
0
 public ActionResult Add(ShopBranch shopBranch)
 {
     try
     {
         long num;
         if (!string.Equals(shopBranch.PasswordOne, shopBranch.PasswordTwo))
         {
             throw new HimallException("两次密码输入不一致!");
         }
         if (string.IsNullOrWhiteSpace(shopBranch.PasswordOne) || string.IsNullOrWhiteSpace(shopBranch.PasswordTwo))
         {
             throw new HimallException("密码不能为空!");
         }
         if (shopBranch.ShopBranchName.Length > 15)
         {
             throw new HimallException("门店名称不能超过15个字!");
         }
         if (shopBranch.AddressDetail.Length > 50)
         {
             throw new HimallException("详细地址不能超过50个字!");
         }
         if ((shopBranch.Latitude <= 0f) || (shopBranch.Longitude <= 0f))
         {
             throw new HimallException("请搜索地址地图定位!");
         }
         shopBranch.ShopId     = base.CurrentSellerManager.ShopId;
         shopBranch.CreateDate = DateTime.Now;
         ShopBranchApplication.AddShopBranch(shopBranch, out num);
         try
         {
             string[] strs      = new string[] { num.ToString() };
             string[] strArray2 = string.IsNullOrEmpty(shopBranch.ShopBranchTagId) ? new string[0] : shopBranch.ShopBranchTagId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
             ShopBranchApplication.SetShopBrandTagInfos(this.convertLongs(strs), this.convertLongs(strArray2));
         }
         catch
         {
         }
         List <ShopBranchTagModel> allShopBranchTagInfos = ShopBranchApplication.GetAllShopBranchTagInfos();
         List <SelectListItem>     list2 = new List <SelectListItem>();
         foreach (ShopBranchTagModel model in allShopBranchTagInfos)
         {
             SelectListItem item = new SelectListItem
             {
                 Selected = (shopBranch.ShopBranchTagId == null) ? false : (shopBranch.ShopBranchTagId.Split(new char[] { ',' }).Contains <string>(model.Id.ToString()) ? true : false),
                 Value    = model.Id.ToString(),
                 Text     = model.Title
             };
             list2.Add(item);
         }
         ((dynamic)base.ViewBag).ShopBranchTags = list2;
     }
     catch (Exception exception)
     {
         BaseController.Result result = new BaseController.Result
         {
             success = false,
             msg     = exception.Message
         };
         return(base.Json(result));
     }
     BaseController.Result data = new BaseController.Result
     {
         success = true
     };
     return(base.Json(data));
 }
示例#14
0
        public ActionResult Edit(ShopBranch shopBranch)
        {
            try
            {
                if (!string.Equals(shopBranch.PasswordOne, shopBranch.PasswordTwo))
                {
                    throw new MallException("两次密码输入不一致!");
                }
                if (shopBranch.ShopBranchName.Length > 15)
                {
                    throw new MallException("门店名称不能超过15个字!");
                }
                if (shopBranch.AddressDetail.Length > 50)
                {
                    throw new MallException("详细地址不能超过50个字!");
                }
                if (shopBranch.Latitude <= 0 || shopBranch.Longitude <= 0)
                {
                    throw new MallException("请搜索地址地图定位!");
                }
                if (!shopBranch.IsAboveSelf && !shopBranch.IsStoreDelive)
                {
                    throw new MallException("至少需要选择一种配送方式!");
                }
                if (shopBranch.IsStoreDelive && shopBranch.IsFreeMail && shopBranch.FreeMailFee <= 0)
                {
                    throw new MallException("满额包邮金额必须大于0!");
                }
                if (!shopBranch.IsStoreDelive)
                {
                    shopBranch.IsFreeMail = false;
                }
                if (!shopBranch.IsFreeMail)
                {
                    shopBranch.FreeMailFee = 0;
                }
                //判断是否编辑自己的门店
                shopBranch.ShopId = CurrentSellerManager.ShopId;//当前登录商家
                //门店所属商家
                var oldBranch = ShopBranchApplication.GetShopBranchById(shopBranch.Id);
                if (oldBranch != null && oldBranch.ShopId != shopBranch.ShopId)
                {
                    throw new MallException("不能修改其他商家的门店!");
                }

                if (!shopBranch.IsFreeMail)
                {
                    shopBranch.FreeMailFee = 0;
                }

                if (!string.IsNullOrWhiteSpace(shopBranch.ShopBranchTagId))
                {
                    var tags = shopBranch.ShopBranchTagId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(p => long.Parse(p)).ToList();
                    ShopBranchApplication.SetShopBrandTagInfos(new List <long> {
                        shopBranch.Id
                    }, tags);
                }

                ShopBranchApplication.UpdateShopBranch(shopBranch);

                if (CityExpressConfigApplication.GetDaDaCityExpressConfig(CurrentShop.Id).IsEnable)
                {
                    var    _area        = RegionApplication.GetRegion(shopBranch.AddressId);
                    var    _city        = GetCity(_area);
                    string json         = "";
                    var    dada_shop_id = GetNewDadaStoreId(CurrentShop.Id, shopBranch.Id);
                    if (string.IsNullOrWhiteSpace(shopBranch.DaDaShopId))
                    {
                        json = ExpressDaDaHelper.shopAdd(CurrentShop.Id, shopBranch.ShopBranchName, 5, _city.ShortName, _area.Parent.Name, shopBranch.AddressDetail, shopBranch.Longitude, shopBranch.Latitude, shopBranch.ContactUser, shopBranch.ContactPhone, dada_shop_id);
                    }
                    else
                    {
                        json = ExpressDaDaHelper.shopUpdate(CurrentShop.Id, shopBranch.DaDaShopId, shopBranch.ShopBranchName, 5, _city.ShortName, _area.Parent.Name, shopBranch.AddressDetail, shopBranch.Longitude, shopBranch.Latitude, shopBranch.ContactUser, shopBranch.ContactPhone);
                    }
                    var    resultObj = JsonConvert.DeserializeObject(json) as JObject;
                    string status    = resultObj["status"].ToString();
                    int    code      = int.Parse(resultObj["code"].ToString());
                    if (status == "fail" && code != 7718)
                    {
                        return(Json(new Result()
                        {
                            success = true, msg = "但同步门店至达达物流失败,可能所在城市达达不支持"
                        }));
                    }
                    if (string.IsNullOrWhiteSpace(shopBranch.DaDaShopId) && (status == "success" || code == 7718))
                    {
                        shopBranch.DaDaShopId = dada_shop_id;
                        ShopBranchApplication.UpdateShopBranch(shopBranch);
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(new Result()
                {
                    success = false, msg = ex.Message
                }));
            }
            return(Json(new Result()
            {
                success = true
            }));
        }
示例#15
0
        public ActionResult Add(ShopBranch shopBranch)
        {
            try
            {
                if (!string.Equals(shopBranch.PasswordOne, shopBranch.PasswordTwo))
                {
                    throw new MallException("两次密码输入不一致!");
                }
                if (string.IsNullOrWhiteSpace(shopBranch.PasswordOne) || string.IsNullOrWhiteSpace(shopBranch.PasswordTwo))
                {
                    throw new MallException("密码不能为空!");
                }
                if (shopBranch.ShopBranchName.Length > 15)
                {
                    throw new MallException("门店名称不能超过15个字!");
                }
                if (shopBranch.AddressDetail.Length > 50)
                {
                    throw new MallException("详细地址不能超过50个字!");
                }
                if (shopBranch.Latitude <= 0 || shopBranch.Longitude <= 0)
                {
                    throw new MallException("请搜索地址地图定位!");
                }
                if (!shopBranch.IsAboveSelf && !shopBranch.IsStoreDelive)
                {
                    throw new MallException("至少需要选择一种配送方式!");
                }
                if (shopBranch.IsStoreDelive && shopBranch.IsFreeMail && shopBranch.FreeMailFee <= 0)
                {
                    throw new MallException("满额包邮金额必须大于0!");
                }
                if (!shopBranch.IsStoreDelive)
                {
                    shopBranch.IsFreeMail = false;
                }
                if (!shopBranch.IsFreeMail)
                {
                    shopBranch.FreeMailFee = 0;
                }
                shopBranch.ShopId     = CurrentSellerManager.ShopId;
                shopBranch.CreateDate = DateTime.Now;
                long shopBranchId;
                ShopBranchApplication.AddShopBranch(shopBranch, out shopBranchId);

                if (!string.IsNullOrWhiteSpace(shopBranch.ShopBranchTagId))
                {
                    var tags = shopBranch.ShopBranchTagId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(p => long.Parse(p)).ToList();
                    ShopBranchApplication.SetShopBrandTagInfos(new List <long> {
                        shopBranch.Id
                    }, tags);
                }

                //门店标签
                var shopBranchTagInfos        = ShopBranchApplication.GetAllShopBranchTagInfos();
                List <SelectListItem> tagList = new List <SelectListItem>();
                foreach (var item in shopBranchTagInfos)
                {
                    tagList.Add(new SelectListItem
                    {
                        Selected = (shopBranch.ShopBranchTagId == null ? false : shopBranch.ShopBranchTagId.Split(',').Contains(item.Id.ToString()) ? true : false),
                        Value    = item.Id.ToString(),
                        Text     = item.Title
                    });
                }
                ViewBag.ShopBranchTags = tagList;

                if (CityExpressConfigApplication.GetDaDaCityExpressConfig(CurrentShop.Id).IsEnable)
                {
                    var    dada_shop_id = GetNewDadaStoreId(CurrentShop.Id, shopBranch.Id);
                    var    _area        = RegionApplication.GetRegion(shopBranch.AddressId);
                    var    _city        = GetCity(_area);
                    var    json         = ExpressDaDaHelper.shopAdd(CurrentShop.Id, shopBranch.ShopBranchName, 5, _city.ShortName, _area.Parent.Name, shopBranch.AddressDetail, shopBranch.Longitude, shopBranch.Latitude, shopBranch.ContactUser, shopBranch.ContactPhone, dada_shop_id);
                    var    resultObj    = JsonConvert.DeserializeObject(json) as JObject;
                    string status       = resultObj["status"].ToString();
                    int    code         = int.Parse(resultObj["code"].ToString());
                    if (status == "fail" && code != 7718)
                    {
                        return(Json(new Result()
                        {
                            success = true, msg = "但同步门店至达达物流失败,可能所在城市达达不支持"
                        }));
                    }
                    if (string.IsNullOrWhiteSpace(shopBranch.DaDaShopId) && (status == "success" || code == 7718))
                    {
                        shopBranch.DaDaShopId = dada_shop_id;
                        ShopBranchApplication.UpdateShopBranch(shopBranch);
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(new Result()
                {
                    success = false, msg = ex.Message
                }));
            }
            return(Json(new Result()
            {
                success = true
            }));
        }
        public ActionResult Add(ShopBranch shopBranch)
        {
            try
            {
                if (!string.Equals(shopBranch.PasswordOne, shopBranch.PasswordTwo))
                {
                    throw new HimallException("两次密码输入不一致!");
                }
                if (string.IsNullOrWhiteSpace(shopBranch.PasswordOne) || string.IsNullOrWhiteSpace(shopBranch.PasswordTwo))
                {
                    throw new HimallException("密码不能为空!");
                }
                if (shopBranch.ShopBranchName.Length > 15)
                {
                    throw new HimallException("门店名称不能超过15个字!");
                }
                if (shopBranch.AddressDetail.Length > 50)
                {
                    throw new HimallException("详细地址不能超过50个字!");
                }
                if (shopBranch.Latitude <= 0 || shopBranch.Longitude <= 0)
                {
                    throw new HimallException("请搜索地址地图定位!");
                }
                string   regionIDList   = Request.Form["txtRegionScop"];
                string   regionNameList = Request.Form["txtRegionScopName"];
                string[] regionIdArr    = regionIDList.Split(',');
                string[] regionNameArr  = regionNameList.Split(',');

                if (shopBranch.ServeRadius <= 0 && string.IsNullOrWhiteSpace(regionIDList.Trim()))
                {
                    throw new HimallException("配送半径和配送范围不能同时为空!");
                }
                shopBranch.ShopId     = CurrentSellerManager.ShopId;
                shopBranch.CreateDate = DateTime.Now;
                long shopBranchId;
                ShopBranchApplication.AddShopBranch(shopBranch, out shopBranchId);
                if (shopBranchId > 0)
                {
                    #region 添加门店配送范围
                    List <DeliveryScope> deliveryScopList = new List <DeliveryScope>();
                    List <int>           regionIdList     = new List <int>();
                    DeliveryScope        info             = null;
                    for (int i = 0; i < regionIdArr.Length; i++)
                    {
                        int tempRegionId = 0;
                        if (int.TryParse(regionIdArr[i], out tempRegionId) && regionNameArr.Length >= i)
                        {
                            regionIdList.Add(tempRegionId);
                            if (!ShopBranchApplication.ExistsShopDeliveryScope(new ShopDeliveryScopeQuery()
                            {
                                ShopBranchId = shopBranchId, RegionId = tempRegionId
                            }))
                            {
                                info                = new DeliveryScope();
                                info.RegionId       = tempRegionId;
                                info.RegionName     = regionNameArr[i];
                                info.FullRegionPath = RegionApplication.GetRegionPath(tempRegionId);
                                info.FullRegionPath = CommonConst.ADDRESS_PATH_SPLIT + info.FullRegionPath + CommonConst.ADDRESS_PATH_SPLIT;//默认在结尾增加分隔符
                                info.ShopBranchId   = shopBranchId;
                                deliveryScopList.Add(info);
                            }
                        }
                    }
                    if (deliveryScopList.Count > 0)
                    {
                        ShopBranchApplication.AddShopDeliveryScope(deliveryScopList);
                    }
                    if (regionIdList.Count > 0)
                    {
                        ShopBranchApplication.DeleteShopDeliveryScope(new ShopDeliveryScopeQuery()
                        {
                            RegionIdList = regionIdList, ShopBranchId = shopBranchId
                        });                                                                                                                                      //清除旧数据
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                return(Json(new Result()
                {
                    success = false, msg = ex.Message
                }));
            }
            return(Json(new Result()
            {
                success = true
            }));
        }
示例#17
0
        public object GetOrderDetail(long orderId)
        {
            CheckUserLogin();
            var orderService       = ServiceProvider.Instance <IOrderService> .Create;
            var order              = orderService.GetOrder(orderId, CurrentUser.Id);
            var orderitems         = orderService.GetOrderItemsByOrderId(order.Id);
            var orderRefundService = ServiceProvider.Instance <IRefundService> .Create;
            var productService     = ServiceProvider.Instance <IProductService> .Create;
            var coupon             = ServiceProvider.Instance <ICouponService> .Create.GetCouponRecordInfo(order.UserId, order.Id);

            string  couponName  = "";
            decimal couponAmout = 0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            return(Json(orderModel));
        }