Example #1
0
        public Result UpdateState(string userId, string shopNo, int state, JArray data)
        {
            Ele_ShopDTO eleShopDto = _shopService.Get(userId, shopNo);

            if (eleShopDto == null)
            {
                return(Tools.ResultErr("未找到此门店"));
            }
            int    num1  = data.Count <JToken>();
            int    count = 50;
            int    num2  = (num1 + count - 1) / count;
            string msg   = "";

            for (int index = 0; index < num2; ++index)
            {
                IEnumerable <JToken> jtokens = data.Skip <JToken>(index * count).Take <JToken>(count);
                System.Collections.Generic.List <long> itemIds = new System.Collections.Generic.List <long>();
                foreach (JToken jtoken in jtokens)
                {
                    itemIds.Add(long.Parse(jtoken[(object)"ProdCode"].ToString().Split(';')[0]));
                }
                EleResult result = new EleResult();
                if (state == 0)
                {
                    result = _foodApiService.BatchListItems(eleShopDto.AccessToken, itemIds);
                }
                else if (state == 1)
                {
                    result = _foodApiService.BatchDelistItems(eleShopDto.AccessToken, itemIds);
                }
                msg += this.Good(result);
            }
            return(string.IsNullOrEmpty(msg) ? Tools.ResultOk() : Tools.ResultErr(msg));
        }
Example #2
0
        public void Update(Ele_ShopDTO dto)
        {
            using (O2OContext context = new O2OContext())
            {
                BaseService <Ele_ShopEntity> service = new BaseService <Ele_ShopEntity>(context);

                var entity = ToolsCommon.EntityToEntity(dto, new Ele_ShopEntity()) as Ele_ShopEntity;

                service.Update(entity);
            }
        }
Example #3
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"
                }));
            }
        }