Пример #1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click);
            this.userId           = this.Page.Request.QueryString["id"].ToInt();
            ManagerInfo currentManager = ManagerHelper.GetCurrentManager();

            this.storeId = currentManager.ClientUserId;
            if (!this.Page.IsPostBack)
            {
                DataTable dtStoreList = WxPoiHelper.GetPoiListInfo();
                DDLStore.Items.Add("请选择");
                foreach (DataRow row in dtStoreList.Rows)
                {
                    ListItem item = new ListItem();
                    item.Text  = row["storeName"].ToString();
                    item.Value = row["storeid"].ToString();
                    DDLStore.Items.Add(item);
                }
                if (storeId > 0)
                {
                    DDLStore.SelectedValue = storeId.ToString();
                    DDLStore.Enabled       = false;
                }

                if (this.userId > 0)
                {
                    this.Bind();
                }
            }
        }
Пример #2
0
 /// <summary>
 /// 单击同步门店按钮事件
 /// </summary>
 protected void btnSyncPoiInfos_Click(object sender, EventArgs e)
 {
     try
     {
         //获取access_token
         string token = Access_token.GetAccess_token(Access_token.Access_Type.weixin, true);
         //门店列表接口提交url
         string url = "https://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=" + token;
         //提交json串,门店列表索引开始:begin,门店列表返回数量限制:limit
         string json = @"{""begin"":0,""limit"":10}";
         //调用post提交方法
         string strPOIList = new Hishop.Weixin.MP.Util.WebUtils().DoPost(url, json);
         //将传回的json字符串转换为json对象
         JObject obj3 = JsonConvert.DeserializeObject(strPOIList) as JObject;
         //将json对象转换为实体类对象
         List <PoiInfoList> poiInfoList = JsonHelper.JsonToList <PoiInfoList>(obj3["business_list"].ToString());
         if (poiInfoList.Count <= 0)
         {
             this.ShowMsg("尚未添加微信门店", false);
             return;
         }
         if (WxPoiHelper.SyncPoiListInfo(poiInfoList))
         {
             this.ShowMsgAndReUrl("同步成功!", true, Request.Url.AbsoluteUri);
         }
         else
         {
             this.ShowMsg("同步失败", false);
         }
     }
     catch (Exception ex)
     {
         this.ShowMsg(ex.Message, false);
     }
 }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.dropCategories.IsTopCategory  = true;
                this.dropCategories.IsUnclassified = false;
                this.dropCategories.DataBind();

                DataTable dtStoreList = WxPoiHelper.GetPoiListInfo();
                DDLStore.Items.Add(new ListItem()
                {
                    Text  = "所有门店",
                    Value = "0"
                });
                foreach (DataRow row in dtStoreList.Rows)
                {
                    ListItem item = new ListItem();
                    item.Text  = row["storeName"].ToString();
                    item.Value = row["storeid"].ToString();
                    DDLStore.Items.Add(item);
                }
                if (storeId > 0)
                {
                    DDLStore.SelectedValue = storeId.ToString();
                    DDLStore.Enabled       = false;
                }
            }
            this.btnAddActivity.Click += new EventHandler(this.AAbiuZJB);
        }
Пример #4
0
        /// <summary>
        /// 获取微信门店信息
        /// </summary>
        private void BindPoiInfo()
        {
            DataTable dtPoiInfo = WxPoiHelper.GetPoiListInfo();

            dlPoiList.DataSource = dtPoiInfo;
            dtPoiInfo.Columns.Add("available_state_name");
            foreach (DataRow row in dtPoiInfo.Rows)
            {
                switch (Convert.ToInt32(row["available_state"]))
                {
                case 1:
                    row["available_state_name"] = "系统错误";
                    break;

                case 2:
                    row["available_state_name"] = "审核中";
                    break;

                case 3:
                    row["available_state_name"] = "审核通过";
                    break;

                case 4:
                    row["available_state_name"] = "审核驳回";
                    break;
                }
            }
            dlPoiList.DataBind();
        }
Пример #5
0
        protected override void AttachChildControls()
        {
            litRequireStoreInfo = (Literal)this.FindControl("litRequireStoreInfo");
            btnAddInfo          = (Button)this.FindControl("btnAddInfo");
            locationText        = (HtmlInputText)this.FindControl("locationText");
            litStoreName        = (Literal)this.FindControl("litStoreName");

            string    listHtml = string.Empty;
            DataTable dtInfo   = WxPoiHelper.GetRequireStoreInfo();

            foreach (DataRow row in dtInfo.Rows)
            {
                listHtml += "<li>";
                listHtml += string.Format("<img src='{0}'>", row["UserHead"]);
                listHtml += string.Format("<div><p><span>{0}</span>", row["UserName"]);
                listHtml += string.Format("<span>{0}</span></p>", row["addTime"]);
                listHtml += string.Format("<p><span>{0}</span></p></div>", row["location"]);
                listHtml += "</li>";
            }
            litRequireStoreInfo.Text = listHtml;

            litStoreName.Text = CustomConfigHelper.Instance.BusinessName;

            btnAddInfo.Click += this.btnAddInfo_Click;
        }
Пример #6
0
        private void getStoreName(System.Web.HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string    storeId    = context.Request["storeId"].ToString();
            DataTable dtNames    = WxPoiHelper.GetStoreName(storeId);
            string    storeNames = "";

            foreach (DataRow row in dtNames.Rows)
            {
                storeNames += row["storeName"];
            }

            context.Response.Write("{\"success\":true,\"storeName\":\"" + storeNames + "\"}");
        }
Пример #7
0
        public static string bindSender(string poi_id, string sender)
        {
            string result = string.Empty;

            if (WxPoiHelper.BindSender(poi_id, sender))
            {
                result = "ok";
            }
            else
            {
                result = "err";
            }
            return(result);
        }
Пример #8
0
        protected void btnAddInfo_Click(object sender, EventArgs e)
        {
            string     locationText  = "希望在<span style='color:orange'>" + GetText(this.locationText.Value) + "</span>开设新门店";
            MemberInfo currentMember = MemberProcessor.GetCurrentMember();

            if (currentMember == null)
            {
                this.GotoResourceNotFound("请登录");
                return;
            }
            if (WxPoiHelper.AddRequireStoreInfo(currentMember.UserId, locationText))
            {
                this.Page.Response.Redirect(this.Page.Request.Url.ToString());
            }
        }
Пример #9
0
 /// <summary>
 /// 获取门店信息,以json串返回
 /// 后期可扩充传递userid匹配最佳门店等功能
 /// </summary>
 /// <param name="context"></param>
 private void GetStoreInfoList(System.Web.HttpContext context)
 {
     try
     {
         context.Response.ContentType = "application/json";
         DataTable dtStoreList = WxPoiHelper.GetPoiListInfo();
         //输出JSON
         string result = string.Format("{{\"state\":{0},\r\"count\":{1},\r\"data\":"
                                       , (dtStoreList.Rows.Count > 0) ? 0 : 1, dtStoreList.Rows.Count);
         result += JsonConvert.SerializeObject(dtStoreList, Newtonsoft.Json.Formatting.Indented);
         result += "}";
         context.Response.Write(result);
     }
     catch (Exception ex)
     {
         context.Response.Write("{\"state\":2,\"errMsg\":\"" + ex.Message + "\"}");
     }
 }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.m_ActivitiesId         = base.GetUrlIntParam("activitiesid");
            this.btnEditActivity.Click += new EventHandler(this.btnEditActivity_Click);
            if (!this.Page.IsPostBack)
            {
                DataTable dtStoreList = WxPoiHelper.GetPoiListInfo();
                DDLStore.Items.Add(new ListItem()
                {
                    Text  = "所有门店",
                    Value = "0"
                });
                foreach (DataRow row in dtStoreList.Rows)
                {
                    ListItem item = new ListItem();
                    item.Text  = row["storeName"].ToString();
                    item.Value = row["storeid"].ToString();
                    DDLStore.Items.Add(item);
                }
                if (storeId > 0)
                {
                    DDLStore.SelectedValue = storeId.ToString();
                    DDLStore.Enabled       = false;
                }


                if (this.m_ActivitiesId == 0)
                {
                    this.Page.Response.Redirect("ActivitiesList.aspx");
                    return;
                }
                this.dropCategories.IsTopCategory  = true;
                this.dropCategories.IsUnclassified = false;
                this.dropCategories.DataBind();
                this.AAbiuZJB(this.m_ActivitiesId);
            }
        }
Пример #11
0
        /// <summary>
        /// 调用微信接口获取所有门店信息
        /// </summary>
        /// <param name="context"></param>
        private void getPoiList(System.Web.HttpContext context)
        {
            context.Response.ContentType = "application/json";
            try
            {
                Thread.Sleep(1000);
                DataTable          dtPoiInfo   = WxPoiHelper.GetPoiListInfo();
                List <PoiInfoList> poiInfoList = new List <PoiInfoList>();
                if (dtPoiInfo.Rows.Count == 0)//如果没有同步,则调用微信接口重新获取
                {
                    //获取access_token
                    string token = Access_token.GetAccess_token(Access_token.Access_Type.weixin, true);
                    //门店列表接口提交url
                    string url = "https://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=" + token;
                    //提交json串,门店列表索引开始:begin,门店列表返回数量限制:limit
                    string json = @"{""begin"":0,""limit"":10}";
                    //调用post提交方法
                    string strPOIList = new Hishop.Weixin.MP.Util.WebUtils().DoPost(url, json);
                    //将传回的json字符串转换为json对象
                    JObject obj3 = JsonConvert.DeserializeObject(strPOIList) as JObject;
                    //将json对象转换为实体类对象
                    poiInfoList = JsonHelper.JsonToList <PoiInfoList>(obj3["business_list"].ToString());

                    //同步微信门店信息
                    if (WxPoiHelper.SyncPoiListInfo(poiInfoList))
                    {
                        dtPoiInfo = WxPoiHelper.GetPoiListInfo();
                    }
                }


                //获取所有门店的坐标
                string offset = string.Empty;
                foreach (DataRow row in dtPoiInfo.Rows)
                {
                    offset += row["longitude"] + "," + row["latitude"] + ";";//增加精度纬度
                }
                offset = offset.TrimEnd(';');
                //将门店坐标放入数组
                string[] offsetList = offset.Split(';');
                /****************根据配送范围将门店的坐标循环匹配用户当前的坐标,误差范围:1公里*******************/
                //允许的误差值(配送范围)
                double range = Convert.ToDouble(context.Request["range"]);
                //获取用户的坐标
                double userLongtitude = Convert.ToDouble(context.Request["userLontitude"]);
                double userLatitude   = Convert.ToDouble(context.Request["userLatitude"]);
                //循环判断获取距离,得到配送范围内的门店poi_id
                List <string> poi_id            = new List <string>();
                List <double> poi_user_distance = new List <double>();
                for (int i = 0; i < offsetList.Length; i++)
                {
                    string[] oa       = offsetList[i].Split(',');//获取门店经度,纬度
                    double   distance = GetDistance(userLatitude, userLongtitude, Convert.ToDouble(oa[1]), Convert.ToDouble(oa[0]));
                    if (distance <= range)
                    {
                        poi_id.Add(dtPoiInfo.Rows[i]["poi_id"].ToString());
                        poi_user_distance.Add(distance);
                    }
                }
                bool   isUserInRange = false;
                string matchIds      = "";
                string matchDistance = "";
                if (poi_id.Count > 0)//如果有配送范围内的用户,则返回第一个匹配到的门店后台id
                {
                    for (int i = 0; i < poi_id.Count; i++)
                    {
                        DataTable dtSender = WxPoiHelper.GetSenderByPoiId(poi_id[i]);
                        foreach (DataRow row in dtSender.Rows)
                        {
                            if (row["clientUserId"].ToString() != "")
                            {
                                matchIds      += row["clientUserId"] + ",";
                                matchDistance += poi_user_distance[i] + ",";
                            }
                        }
                    }
                    isUserInRange = true;
                    //如果匹配到的微信门店还没有绑定至后台账号,给出提示
                    if (matchIds.Length == 0)
                    {
                        context.Response.Write("{\"success\":false,\"errMsg\":\"匹配到了未绑定的门店,或者门店还未通过审核!\"}");
                        return;
                    }
                    //根据门店id匹配到对应的子账号id:sender
                    matchDistance = matchDistance.TrimEnd(',');
                    matchIds      = matchIds.TrimEnd(',');
                    //string[] sender = matchId.Split(',');
                    //string[] clientUserId = matchId.Split(',');

                    /*
                     * //将匹配到的所有门店以门店名字进行展示 (目前更换为街道名)
                     * DataTable dtStoreName = WxPoiHelper.GetStoreName(matchIds);
                     * string storeNameBtns = "";
                     * foreach (DataRow row in dtStoreName.Rows)
                     * {
                     *  storeNameBtns += "<span role='btnStreet' distributorId='" + row["userid"].ToString() + "'>" + row["storeName"].ToString() + "</span>";
                     * }
                     */
                    //将匹配到的所有街道以街道名字进行展示
                    DataTable dtStreetName   = WxPoiHelper.GetStoreStreets(matchIds);
                    string    streetNameBtns = "";
                    foreach (DataRow row in dtStreetName.Rows)
                    {
                        streetNameBtns += "<span role='btnStreet' la='" + row["latitude"] + "' lo='" + row["longitude"] + "'  distributorId='" + row["distributorid"].ToString() + "'>" + row["regionName"].ToString() + "</span>";
                    }


                    context.Response.Write("{\"success\":true,\"isUserInRange\":\"" + isUserInRange + "\",\"distributorId\":\"" + streetNameBtns + "\"}");
                }

                else
                {
                    context.Response.Write("{\"success\":true,\"isUserInRange\":\"" + isUserInRange + "\"}");
                }

                /*
                 * //调试
                 * string[] la0 = offsetList[0].Split(',');
                 * double distance = GetDistance(userLatitude,userLongtitude,Convert.ToDouble(la0[1]),Convert.ToDouble(la0[0]));
                 * context.Response.Write("{\"success\":true,\"userLo\":" + userLongtitude + ",\"userLa\":" + userLatitude + ",\"poiLA\":\"" + offsetList[0] + "\",\"distance\":"+distance+"}");
                 */
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"success\":false,\"errMsg\":\"" + ex.Message + "\"}");
            }
        }
Пример #12
0
        private HtmlInputHidden hidUserStoreName; //隐藏域,当前匹配的门店名


        protected override void AttachChildControls()
        {
            this.litOrderAlert     = (Literal)this.FindControl("litOrderAlert");//公告栏
            this.litStoreList      = (Literal)this.FindControl("litStoreList");
            this.litDefaultAddress = (Literal)this.FindControl("litDefaultAddress");
            this.hidMinPrice       = (HtmlInputHidden)this.FindControl("hidMinPrice");
            this.hidFromUserId     = (HtmlInputHidden)this.FindControl("hidFromUserId");
            this.hidUserDistance   = (HtmlInputHidden)this.FindControl("hidUserDistance");
            this.hidUserStoreId    = (HtmlInputHidden)this.FindControl("hidUserStoreId");
            this.hidUserStoreName  = (HtmlInputHidden)this.FindControl("hidUserStoreName");

            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
            MemberInfo   currentMember  = MemberProcessor.GetCurrentMember();

            this.litOrderAlert.Text = masterSettings.orderAlert;

            this.hidMinPrice.Value = masterSettings.roadPriceInfo;

            //获取我的推广人id
            try
            {
                string VisitFromMemberId = HiCache.Get(string.Format("DataCache-FromMemberId-{0}", currentMember.OpenId)) as string;
                if (!string.IsNullOrEmpty(VisitFromMemberId))
                {
                    this.hidFromUserId.Value = VisitFromMemberId;
                }
            }
            catch (Exception ex) {
                //WriteLog(ex.Message);
            }

            //获取用户默认配送地址,如果没有填写,则跳转到新增地址页面
            ShippingAddressInfo shippingAddress = MemberProcessor.GetDefaultShippingAddress();

            if (shippingAddress == null)
            {
                this.Page.Response.Redirect("AddShippingAddressPro.aspx?returnUrl=picOrder.aspx"); return;
            }

            this.litDefaultAddress.Text = MemberProcessor.GetDefaultShippingAddress().Address;


            //如果填写了地址,获取所有门店坐标,并且匹配用户的默认配送地址,获取最近门店,并计算出相应的配送费和配送距离等
            DataTable          dtPoiInfo   = WxPoiHelper.GetPoiListInfo();
            List <PoiInfoList> poiInfoList = new List <PoiInfoList>();

            if (dtPoiInfo.Rows.Count == 0)//如果没有同步,则调用微信接口重新获取
            {
                //获取access_token
                string token = Access_token.GetAccess_token(Access_token.Access_Type.weixin, true);
                //门店列表接口提交url
                string url = "https://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=" + token;
                //提交json串,门店列表索引开始:begin,门店列表返回数量限制:limit
                string json = @"{""begin"":0,""limit"":10}";
                //调用post提交方法
                string strPOIList = new Hishop.Weixin.MP.Util.WebUtils().DoPost(url, json);
                //将传回的json字符串转换为json对象
                JObject obj3 = JsonConvert.DeserializeObject(strPOIList) as JObject;
                //将json对象转换为实体类对象
                poiInfoList = JsonHelper.JsonToList <PoiInfoList>(obj3["business_list"].ToString());

                //同步微信门店信息
                if (WxPoiHelper.SyncPoiListInfo(poiInfoList))
                {
                    dtPoiInfo = WxPoiHelper.GetPoiListInfo();
                }
            }


            //拼装门店列表
            string storelisthtml = "<div class='storeNow'><p><span class='switch' onclick='chooseStore()'>选择门店</span></p></div>";

            storelisthtml += "<ul class='chooseStore'>";
            foreach (DataRow row in dtPoiInfo.Rows)
            {
                DataTable dtSender = WxPoiHelper.GetSenderByPoiId(row["poi_id"].ToString());
                storelisthtml += string.Format("<li poi_id='{0}'>{1}</li>", row["poi_id"].ToString(), DistributorsBrower.GetDistributorInfo(int.Parse(dtSender.Rows[0]["clientuserid"].ToString())).StoreName);
            }
            storelisthtml += "</ul>";

            litStoreList.Text = storelisthtml;


            //如果手动选择了门店,那么门店列表除了该门店的一律删除
            DataTable dtt = new DataTable();

            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["poi_id"]))
            {
                dtt = dtPoiInfo.Clone();
                DataRow[] dr = dtPoiInfo.Select("poi_id = '" + this.Page.Request.QueryString["poi_id"] + "'   ");
                for (int i = 0; i < dr.Length; i++)
                {
                    dtt.ImportRow((DataRow)dr[i]);
                }
                dtPoiInfo = dtt;
            }



            //获取所有门店的坐标
            string offset = string.Empty;

            foreach (DataRow row in dtPoiInfo.Rows)
            {
                offset += row["latitude"] + "," + row["longitude"] + ";";//增加精度纬度
            }
            offset = offset.TrimEnd(';');
            //将门店坐标放入数组
            string[] offsetList = offset.Split(';');
            //循环判断获取距离,得到配送范围内的门店poi_id
            List <string> poi_id            = new List <string>();
            List <double> poi_user_distance = new List <double>();

            for (int i = 0; i < offsetList.Length; i++)
            {
                string[] oa       = offsetList[i].Split(',');//获取门店经度,纬度
                double   distance = GetDistance(shippingAddress.lat, shippingAddress.lng, Convert.ToDouble(oa[0]), Convert.ToDouble(oa[1]));
                poi_id.Add(dtPoiInfo.Rows[i]["poi_id"].ToString());
                poi_user_distance.Add(distance);
            }

            string matchIds      = "";
            string matchDistance = "";

            if (poi_id.Count > 0)
            {
                for (int i = 0; i < poi_id.Count; i++)
                {
                    DataTable dtSender = WxPoiHelper.GetSenderByPoiId(poi_id[i]);
                    foreach (DataRow row in dtSender.Rows)
                    {
                        if (row["clientUserId"].ToString() != "")
                        {
                            matchIds      += row["clientUserId"] + ",";
                            matchDistance += poi_user_distance[i] + ",";
                        }
                    }
                }
                matchDistance = matchDistance.TrimEnd(',');
                matchIds      = matchIds.TrimEnd(',');
            }

            string[] matchDistanceArrStr = matchDistance.Split(',');
            if (matchDistanceArrStr.Length <= 0)
            {
                return;
            }
            double[] matchDistanceArr = new double[matchDistanceArrStr.Length];
            for (int i = 0; i < matchDistanceArrStr.Length; i++)
            {
                matchDistanceArr[i] = Convert.ToDouble(matchDistanceArrStr[i]);
            }
            string[] matchIdsArr = matchIds.Split(',');
            int      minIndex    = GetMinAndIndex(matchDistanceArr);

            hidUserDistance.Value   = matchDistanceArr[minIndex].ToString(); //获取距离最小的值
            this.litOrderAlert.Text = this.litOrderAlert.Text + "当前配送距离:" + hidUserDistance.Value + "公里";
            hidUserStoreId.Value    = matchIdsArr[minIndex].ToString();      //获取距离最小的值的门店id
            if (matchIdsArr.Length > 0)
            {
                hidUserStoreName.Value = DistributorsBrower.GetDistributorInfo(int.Parse(matchIdsArr[minIndex])).StoreName;
            }
        }