コード例 #1
0
        public void syncwelFareStoreBrandMapping()
        {
            var interfaceName      = "syncwelFareStoreBrandMapping";
            var loggingSessionInfo = BaseService.GetLoggingSession();
            var storeBrandService  = new StoreBrandMappingBLL(loggingSessionInfo);

            var dsStoreBrands = new DataSet();
            var storeBrands   = new StoreBrandMappingList();

            storeBrands.mappinglist = new List <StoreBrandMapping>();

            //更新接口同步表
            var queryList = UpdateInterfaceTimestamp(interfaceName, loggingSessionInfo);

            if (queryList != null && queryList.Length > 0)
            {
                //存在,根据日期条件查询
                dsStoreBrands = storeBrandService.GetSynWelfareStoreBrandMappingList(queryList.FirstOrDefault().LatestTime.ToString());
            }
            else
            {
                //不存在,查询所有数据
                dsStoreBrands = storeBrandService.GetSynWelfareStoreBrandMappingList(string.Empty);
            }

            if (dsStoreBrands != null && dsStoreBrands.Tables.Count > 0 && dsStoreBrands.Tables[0].Rows.Count > 0)
            {
                storeBrands.mappinglist = DataTableToObject.ConvertToList <StoreBrandMapping>(dsStoreBrands.Tables[0]);

                //上传数据
                var content = storeBrands.ToJSON();
                var result  = UploadData(interfaceName, storeBrands.ToJSON());

                //写入接口日志
                var logEntity = new ZInterfaceLogEntity()
                {
                    LogId         = Utils.NewGuid(),
                    InterfaceName = interfaceName,
                    Params        = content,
                    ResultCode    = result.code,
                    ResultDesc    = result.description
                };

                InsertInterfaceLog(logEntity, loggingSessionInfo);
            }
        }
コード例 #2
0
        public static void WXLocation(HttpContext httpContext, CommonBLL commonService, RequestParams requestParams, string locationX, string locationY)
        {
            WMenuDAO wMenuDAO = new WMenuDAO(requestParams.LoggingSessionInfo);
            var      custId   = wMenuDAO.GetCustomerIdByWx(requestParams.WeixinId);

            if (requestParams.LoggingSessionInfo.CurrentUser == null)
            {
                requestParams.LoggingSessionInfo.CurrentUser = new Entity.User.UserInfo();
            }
            requestParams.LoggingSessionInfo.CurrentUser.customer_id = custId;

            BaseService.WriteLogWeixin("customerId:---------------" + custId);
            BaseService.WriteLogWeixin("openID:---------------" + requestParams.OpenId);
            BaseService.WriteLogWeixin("weixinID:---------------" + requestParams.WeixinId);

            string HandlerLocation_xyds = ConfigurationManager.AppSettings["HandlerLocation_xyds"];

            BaseService.WriteLogWeixin("HandlerLocation_xyds:---------------" + HandlerLocation_xyds);
            if (HandlerLocation_xyds != null && HandlerLocation_xyds.Length > 0 && HandlerLocation_xyds.Contains(requestParams.WeixinId))
            {
                BaseService.WriteLogWeixin("xyds:---------------");
                VipBLL server  = new VipBLL(requestParams.LoggingSessionInfo);
                var    vipInfo = server.SearchVipInfoLocation(new VipSearchEntity()
                {
                    RoleCode  = "CampusAmbassadors",
                    Longitude = locationY,
                    Latitude  = locationX,
                    OrderBy   = " a.Distance asc ",
                    Page      = 1,
                    PageSize  = 1,
                });

                if (vipInfo != null && vipInfo.vipInfoList != null && vipInfo.vipInfoList.Count > 0)
                {
                    var vip = vipInfo.vipInfoList[0];
                    if (vip != null)
                    {
                        var content = "";
                        content += "目前离你最近的校园产品专家是{0},电话:{1},{2},距离{3}米。如有任何疑问也可直接回复消息与我们联系,我们将尽快答复。";
                        content  = string.Format(
                            content,
                            vip.VipName,
                            vip.Phone,
                            vip.DeliveryAddress,
                            vip.Distance * 1000
                            );

                        BaseService.WriteLogWeixin("发送微信消息:---------------");
                        commonService.ResponseTextMessage(requestParams.WeixinId, requestParams.OpenId, content, httpContext, requestParams);
                        BaseService.WriteLogWeixin("发送微信消息完成:---------------");

                        MarketSendLogBLL marketSendLogBLL = new BLL.MarketSendLogBLL(requestParams.LoggingSessionInfo);
                        var logObj = new MarketSendLogEntity()
                        {
                            LogId           = Common.Utils.NewGuid(),
                            VipId           = vip.VIPID,
                            MarketEventId   = "华硕校园大使推介活动",
                            TemplateContent = content,
                            SendTypeId      = "1",
                            WeiXinUserId    = vip.WeiXinUserId,
                            Phone           = vip.Phone,
                            IsSuccess       = 0
                        };
                        marketSendLogBLL.Create(logObj);

                        VipVipMappingBLL vipVipMappingBLL = new VipVipMappingBLL(requestParams.LoggingSessionInfo);
                        var vipMapObj = new VipVipMappingEntity()
                        {
                            MappingId = Guid.NewGuid(),
                            VipIdSrc  = vip.VIPID,
                            VipIdDst  = requestParams.OpenId
                        };
                        vipVipMappingBLL.Create(vipMapObj);

                        logObj.IsSuccess = 1;
                        marketSendLogBLL.Update(logObj, false);
                    }
                }
            }
            else
            {
                string strError             = "";
                StoreBrandMappingBLL server = new StoreBrandMappingBLL(requestParams.LoggingSessionInfo);
                var storeInfo = server.GetStoreListByItem(null
                                                          , 1
                                                          , 10
                                                          , locationY
                                                          , locationX
                                                          , out strError);

                if (storeInfo != null && storeInfo.StoreBrandList != null && storeInfo.StoreBrandList.Count > 0)
                {
                    var newsList     = new List <WMaterialTextEntity>();
                    var original_url = ConfigurationManager.AppSettings["website_WWW"].ToString();
                    if (!original_url.EndsWith("/"))
                    {
                        original_url += "/";
                    }
                    foreach (var store in storeInfo.StoreBrandList)
                    {
                        var url = original_url + "HtmlApps/Auth.html?pageName=Map&customerId=" + requestParams.LoggingSessionInfo.CurrentUser.customer_id;
                        url += "&lng=" + store.Longitude + "&lat=" + store.Latitude;
                        url += "&storeId=" + store.StoreId;
                        url += "&addr=" + HttpUtility.UrlEncode(store.Address);
                        url += "&store=" + HttpUtility.UrlEncode(store.StoreName);

                        #region 分享业务 链接后面加上openId和userId

                        //if (url.IndexOf("ParAll=") != -1)
                        //{
                        //    var vipId = string.Empty;

                        //    VipBLL vipService = new VipBLL(requestParams.LoggingSessionInfo);
                        //    var vipEntity = vipService.QueryByEntity(new VipEntity { WeiXinUserId = requestParams.OpenId, WeiXin = requestParams.WeixinId }, null);
                        //    if (vipEntity != null && vipEntity.Length > 0)
                        //    {
                        //        vipId = vipEntity.FirstOrDefault().VIPID;
                        //    }

                        //    url += "&openId=" + requestParams.OpenId + "&userId=" + vipId;
                        //}

                        #endregion

                        newsList.Add(new WMaterialTextEntity()
                        {
                            Title         = store.StoreName + "(" + store.Distance.ToString("f1") + "公里)", // Title
                            Text          = store.StoreName + "(" + store.Distance.ToString("f1") + "公里)", // Author
                            CoverImageUrl = store.ImageUrl,                                                // CoverImageUrl
                            OriginalUrl   = url
                        });
                    }

                    commonService.ResponseNewsMessage(requestParams.WeixinId, requestParams.OpenId, newsList, httpContext, requestParams);
                }
            }
        }