/// <summary>
        /// 批量设置门店标签
        /// </summary>
        /// <returns></returns>
        public JsonResult SetShopBranchTags(string shopIds, string tagIds)
        {
            var branchs = shopIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(p => long.Parse(p)).ToList();
            var tags    = tagIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(p => long.Parse(p)).ToList();

            ShopBranchApplication.SetShopBrandTagInfos(branchs, tags);
            return(Json(new { success = true }));
        }
Beispiel #2
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));
 }
 /// <summary>
 /// 设置门店标签
 /// </summary>
 /// <param name="shopIds"></param>
 /// <param name="tagIds"></param>
 /// <returns></returns>
 public JsonResult SetShopBranchTags(string shopIds, string tagIds)
 {
     try
     {
         string[] strs1 = shopIds.Split(new char[1]
         {
             ','
         }, StringSplitOptions.RemoveEmptyEntries);
         string[] strArray;
         if (!string.IsNullOrEmpty(tagIds))
         {
             strArray = tagIds.Split(new char[1]
             {
                 ','
             }, StringSplitOptions.RemoveEmptyEntries);
         }
         else
         {
             strArray = new string[0];
         }
         string[] strs2 = strArray;
         ShopBranchApplication.SetShopBrandTagInfos(this.convertLongs(strs1), this.convertLongs(strs2));
         return(this.Json((object)new
         {
             success = true
         }));
     }
     catch (Exception ex)
     {
         return(this.Json((object)new
         {
             success = false,
             msg = ex.Message
         }));
     }
 }
Beispiel #4
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));
 }
        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 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
            }));
        }