Example #1
0
        public ActionResult Cancel(string token, long shopId)
        {
            EleShopApiService service = new EleShopApiService();

            var obj = new
            {
                openId = ""
            };

            var res = service.UpdateShop(token, shopId, obj);

            if (res.error == null)
            {
                _serviceShop.Delete(shopId);

                return(Json(new AjaxResult()
                {
                    state = "ok"
                }));
            }
            else
            {
                return(Json(new AjaxResult()
                {
                    state = "no", msg = res.error.message
                }));
            }
        }
Example #2
0
        public ActionResult Map()
        {
            var stream = new StreamReader(Request.InputStream);
            var str    = stream.ReadToEnd();

            var list = JsonConvert.DeserializeObject <List <ShopMap> >(str);

            EleShopApiService service = new EleShopApiService();

            string msg = "";

            foreach (var item in list)
            {
                var obj = new
                {
                    openId = item.ShopNo
                };

                var res = service.UpdateShop(item.AccessToken, item.ShopId, obj);

                if (res.error == null)
                {
                    //保存门店到数据库
                    var dto = _serviceShop.GetByShopId(item.ShopId);
                    if (dto == null)
                    {
                        Ele_ShopDTO dtoNew = new Ele_ShopDTO()
                        {
                            AccountId = item.AccountId,
                            ShopId    = item.ShopId,
                            ShopNo    = item.ShopNo,
                        };
                        _serviceShop.Add(dtoNew);
                    }
                    else
                    {
                        dto.ShopNo = item.ShopNo;
                        _serviceShop.Update(dto);
                    }
                }
                else
                {
                    msg = "【" + item.ShopId + "】" + res.error.message;
                }
            }

            if (msg != "")
            {
                return(Json(new AjaxResult()
                {
                    state = "no", msg = msg
                }));
            }
            else
            {
                return(Json(new AjaxResult()
                {
                    state = "ok"
                }));
            }
        }