Exemplo n.º 1
0
        /// <summary>
        /// 门店同步
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public static dt_GetMd_res GetMd(dt_GetMd_req req)
        {
            try
            {
                si_GetMd_obService dyn = new si_GetMd_obService();

                string   reqStr    = js.Serialize(req);
                DateTime timeStart = DateTime.Now;
                logger.Info("门店同步接口si_GetMd_obService请求信息:" + reqStr);

                dt_GetMd_res pis = dyn.si_GetMd_ob(req);

                string   resStr  = js.Serialize(pis);
                DateTime timeEnd = DateTime.Now;
                logger.Info("响应信息" + resStr + "\r\n");

                datalog.DataInfo(reqStr, resStr, timeStart, timeEnd, 0, "si_GetMd_obService", "门店同步接口");
                return(pis);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 插入门店
        /// </summary>
        /// <returns></returns>
        public int InsertStore()
        {
            try
            {
                dt_GetMd_req req = new dt_GetMd_req();

                TVKO[] ko = new TVKO[]
                {
                    new TVKO()
                    {
                        VKORG = "C004"
                    },
                    new TVKO()
                    {
                        VKORG = "C024"
                    }
                };

                req.ZTVKO = ko;

                dt_GetMd_res resStore = WebApiHelp.GetMd(req);

                JavaScriptSerializer js = new JavaScriptSerializer();

                foreach (ZSAL_MD stroeModel in resStore.INFO_MD)
                {
                    Thread.Sleep(100);
                    //如果门店是激活状态
                    if (stroeModel.VTWEG != "28" && stroeModel.VTWEG != "11")
                    {
                        int id = _repo.CheckStore(stroeModel.ZMD_ID);
                        if (id < 1)
                        {
                            TenAPI api = null;

                            if (!string.IsNullOrEmpty(stroeModel.STRAS))
                            {
                                string json = NetHelper.HttpRequest("http://apis.map.qq.com/ws/geocoder/v1/?key=MYVBZ-AO3R3-KVS3G-3OBPF-VNHE5-7VF7M&address=" +
                                                                    stroeModel.STRAS + "", "",
                                                                    "GET", 2000, Encoding.UTF8, "application/json");

                                if (!json.Contains("查询无结果"))
                                {
                                    api = js.Deserialize <TenAPI>(json);

                                    if (api.status != 0)
                                    {
                                        api = null;
                                    }
                                }
                            }

                            BCJ_STORES model = new BCJ_STORES()
                            {
                                ADDRESS    = stroeModel.STRAS,
                                CITY       = stroeModel.CITY_CODE,
                                CITY_CATE  = stroeModel.ZCITY_TYPE,
                                NAME       = stroeModel.ZMD_MC,
                                POS_CODE   = stroeModel.ZMD_ID,
                                KUNNR_SH   = stroeModel.ZKUNNR_SH,
                                TEL        = stroeModel.TELF1,
                                STORE_TYPE = stroeModel.ZMD_TYPE,
                                LONGITUDE  = api == null ? "无" : api.result.location.lng,
                                LATITUDE   = api == null ? "无" : api.result.location.lat,
                                STATUS     = string.IsNullOrEmpty(stroeModel.ZSTATUS) ? -1 : int.Parse(stroeModel.ZSTATUS)
                            };

                            _repo.Insert(model);
                        }
                        //更新门店信息
                        else
                        {
                            BCJ_STORES model = new BCJ_STORES()
                            {
                                ID        = id,
                                ADDRESS   = stroeModel.STRAS,
                                CITY      = stroeModel.CITY_CODE,
                                CITY_CATE = stroeModel.ZCITY_TYPE,
                                NAME      = stroeModel.ZMD_MC,
                                POS_CODE  = stroeModel.ZMD_ID,
                                KUNNR_SH  = stroeModel.ZKUNNR_SH,
                                TEL       = stroeModel.TELF1,
                                STATUS    = string.IsNullOrEmpty(stroeModel.ZSTATUS) ? -1 : int.Parse(stroeModel.ZSTATUS)
                            };
                            _repo.Update(model);
                        }
                    }
                }

                return(1);
            }
            catch (Exception ex)
            {
                throw;
            }
        }