Exemplo n.º 1
0
        public object GetShopBranchs()
        {
            CheckUserLogin();
            var branchs = ShopBranchApplication.GetShopBranchByShopId(CurrentUser.ShopId);

            return(Json(new { success = true, branchs = branchs }));
        }
Exemplo n.º 2
0
        public JsonResult DaDaConfig(ShopBranchDaDaConfigModel model)
        {
            long   shopId = CurrentShop.Id;
            Result result = new Result
            {
                success = false,
                msg     = "未知错误"
            };

            if (ModelState.IsValid)
            {
                if (model.IsEnable)
                {
                    if (string.IsNullOrWhiteSpace(model.app_key) || string.IsNullOrWhiteSpace(model.app_secret) || string.IsNullOrWhiteSpace(model.source_id))
                    {
                        result.success = false;
                        result.msg     = "数据错误,请填写必填信息";
                        return(Json(result));
                    }
                }
                var data = CityExpressConfigApplication.GetDaDaCityExpressConfig(shopId);
                data.IsEnable   = model.IsEnable;
                data.app_key    = model.app_key;
                data.app_secret = model.app_secret;
                data.source_id  = model.source_id;
                CityExpressConfigApplication.Update(CurrentShop.Id, data);
                result.msg = "";
                //同步开通达达门店
                var sblist = ShopBranchApplication.GetShopBranchByShopId(shopId).Where(d => string.IsNullOrWhiteSpace(d.DaDaShopId));
                foreach (var item in sblist)
                {
                    var    dada_shop_id = GetNewDadaStoreId(CurrentShop.Id, item.Id);
                    var    _area        = RegionApplication.GetRegion(item.AddressId);
                    var    _city        = GetCity(_area);
                    var    json         = ExpressDaDaHelper.shopAdd(shopId, item.ShopBranchName, 5, _city.ShortName, _area.Parent.Name, item.AddressDetail, item.Longitude, item.Latitude, item.ContactUser, item.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)
                    {
                        result.msg = "但部份同步门店失败,可能所在城市达达不支持";
                    }
                    if (string.IsNullOrWhiteSpace(item.DaDaShopId) && (status == "success" || code == 7718))
                    {
                        item.DaDaShopId = dada_shop_id;
                        ShopBranchApplication.UpdateShopBranch(item);
                    }
                }
                result.success = true;
            }
            else
            {
                result.success = false;
                result.msg     = "数据错误,请填写必填信息";
            }

            return(Json(result));
        }
Exemplo n.º 3
0
        public JsonResult List(ShopQuery query, string type = "")
        {
            if (type == "Auditing")
            {
                query.Status = ShopInfo.ShopAuditStatus.WaitAudit;
                query.MoreStatus.Add(ShopInfo.ShopAuditStatus.WaitConfirm);
            }
            var shops        = ShopApplication.GetShops(query);
            var shopGrades   = ShopApplication.GetShopGrades();
            var shopAccounts = ShopApplication.GetShopAccounts(shops.Models.Select(p => p.Id).ToList());
            var models       = shops.Models.Select(item =>
            {
                var shopGrade        = shopGrades.FirstOrDefault(p => p.Id == item.GradeId);
                var shopAccountModel = shopAccounts.FirstOrDefault(p => p.ShopId == item.Id);
                var shopbranchs      = ShopBranchApplication.GetShopBranchByShopId(item.Id);
                return(new ShopModel()
                {
                    Id = item.Id,
                    Account = item.ShopAccount,
                    EndDate = type == "Auditing" ? "--" : item.EndDate.HasValue ? item.EndDate.Value.ToString("yyyy-MM-dd") : "",
                    Name = item.ShopName,
                    ShopGrade = shopGrade != null ? shopGrade.Name : "",
                    Status = (item.EndDate < DateTime.Now && item.ShowShopAuditStatus == ShopInfo.ShopAuditStatus.Open) ? "已过期" : item.ShowShopAuditStatus.ToDescription(),
                    IsSelf = item.IsSelf,
                    BusinessType = item.BusinessType == null ? CommonModel.ShopBusinessType.Enterprise : item.BusinessType.Value,
                    Balance = shopAccountModel != null ? shopAccountModel.Balance : 0,
                    ShopBranchCount = shopbranchs.Count()
                });
            });

            var dataGrid = new DataGridModel <ShopModel>()
            {
                rows = models, total = shops.Total
            };

            return(Json(dataGrid));
        }