示例#1
0
 public void GetUserIdByOpenId(string OpenId)
 {
     try
     {
         Response.Write("<br/>");
         //Response.Write("获取用户标识");
         string vipId   = string.Empty;
         string status  = "0";
         VipBLL server  = new VipBLL(loggingSessionInfo);
         var    vipObjs = server.QueryByEntity(new VipEntity
         {
             WeiXinUserId = OpenId
         }, null);
         if (vipObjs == null || vipObjs.Length == 0 || vipObjs[0] == null)
         {
             //请求获取用户信息
             //Jermyn20130911 从总部导入vip信息
             bool bReturn  = server.GetVipInfoFromApByOpenId(OpenId, null);
             var  vipObjs1 = server.QueryByEntity(new VipEntity
             {
                 WeiXinUserId = OpenId
             }, null);
             if (vipObjs1 == null || vipObjs1.Length == 0 || vipObjs1[0] == null)
             {
             }
             else
             {
                 vipId  = vipObjs1[0].VIPID;
                 status = vipObjs1[0].Status.ToString();
             }
         }
         else
         {
             vipId  = vipObjs[0].VIPID;
             status = vipObjs[0].Status.ToString();
         }
         //用户不存在或者取消关注,请处理
         if (vipId == null || vipId.Equals("") || status.Equals("0"))
         {
             Response.Redirect(strNoFollowUrl);
         }
         Response.Write("vipId:" + vipId);
         Response.Write("<br/>");
         goUrl = "http://" + HttpUtility.UrlDecode(goUrl) + "?customerId=" + customerId + "&userId=" + vipId + "&openId=" + OpenId + "";
         //goUrl = "http://" + HttpUtility.UrlDecode(goUrl) + "";
         //string strGotoUrl = "/OnlineClothing/go.htm?customerId=" + customerId + "&openId=" + OpenId + "&userId=" + vipId + "&backUrl=" + HttpUtility.UrlEncode(goUrl) + "";
         //Response.Write(goUrl);
         Response.Redirect(goUrl);
     }
     catch (Exception ex)
     {
         Loggers.Debug(new DebugLogInfo()
         {
             Message = string.Format("GetUserIdByOpenId用户用户信息出错: {0}", ex.ToString())
         });
         Response.Write("GetUserIdByOpenId用户用户信息出错:" + ex.ToString());
     }
 }
示例#2
0
 public void GetUserIdByOpenId(string OpenId)
 {
     try
     {
         Response.Write("<br/>");
         //Response.Write("获取用户标识");
         string vipId   = string.Empty;
         VipBLL server  = new VipBLL(loggingSessionInfo);
         var    vipObjs = server.QueryByEntity(new VipEntity
         {
             WeiXinUserId = OpenId
         }, null);
         if (vipObjs == null || vipObjs.Length == 0 || vipObjs[0] == null)
         {
             //请求获取用户信息
             //Jermyn20130911 从总部导入vip信息
             bool bReturn  = server.GetVipInfoFromApByOpenId(OpenId, null);
             var  vipObjs1 = server.QueryByEntity(new VipEntity
             {
                 WeiXinUserId = OpenId
             }, null);
             if (vipObjs1 == null || vipObjs1.Length == 0 || vipObjs1[0] == null)
             {
                 vipId = vipObjs1[0].VIPID;
             }
         }
         else
         {
             vipId = vipObjs[0].VIPID;
         }
         Response.Write("vipId:" + vipId);
         Response.Write("<br/>");
         //goUrl = "http://" + HttpUtility.UrlDecode(goUrl) + "?customerId=" + customerId + "&userId=" + vipId + "&openId=" + OpenId + "";
         goUrl = "http://" + HttpUtility.UrlDecode(goUrl) + "";
         string strGotoUrl = "/OnlineClothing/tmpGoUrl.html?customerId=" + customerId + "&openId=" + OpenId + "&userId=" + vipId + "&backUrl=" + HttpUtility.UrlEncode(goUrl) + "";
         //Response.Write(goUrl);
         Response.Redirect(strGotoUrl);
     }
     catch (Exception ex)
     {
         Loggers.Debug(new DebugLogInfo()
         {
             Message = string.Format("GetUserIdByOpenId用户用户信息出错: {0}", ex.ToString())
         });
         Response.Write("向o2omarketing平台请求用户信息出错,请联系管理员尽快处理.");
         Response.End();
     }
 }
示例#3
0
        /// <summary>
        /// 获取jsapi_ticket
        /// </summary>
        /// <returns></returns>
        public string getJsApiConfig(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <WeiXinConfigRq> >();

            if (string.IsNullOrEmpty(rp.OpenID))//OpenID为空立刻返回空数据,让前端跳转高级auth认证
            {
                return(new SuccessResponse <IAPIResponseData>(new XeiXinJsApiConfig()).ToJSON());
            }
            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");
            var appService         = new WApplicationInterfaceBLL(loggingSessionInfo);
            var wxUserInfoBLL      = new WXUserInfoBLL(loggingSessionInfo);
            var vipService         = new VipBLL(loggingSessionInfo);
            var appEntity          = new WApplicationInterfaceEntity();

            var vipEntitys = vipService.QueryByEntity(new VipEntity {
                WeiXinUserId = rp.OpenID, ClientID = loggingSessionInfo.ClientID
            }, null);

            if (vipEntitys != null && vipEntitys.Length > 0)
            {
                appEntity = appService.QueryByEntity(new WApplicationInterfaceEntity()
                {
                    WeiXinID = vipEntitys[0].WeiXin, CustomerId = rp.CustomerID
                }, null).FirstOrDefault();
            }
            else
            {
                //优先从支持多号运营的表中取
                var wxUserInfo = wxUserInfoBLL.QueryByEntity(new WXUserInfoEntity()
                {
                    CustomerID = loggingSessionInfo.ClientID, WeiXinUserID = rp.OpenID
                }, null).FirstOrDefault();
                if (wxUserInfo != null)
                {
                    appEntity = appService.QueryByEntity(new WApplicationInterfaceEntity()
                    {
                        WeiXinID = wxUserInfo.WeiXin, CustomerId = rp.CustomerID
                    }, null).FirstOrDefault();
                }
            }
            //返回空数据,让前端跳转高级auth认证
            if (string.IsNullOrEmpty(appEntity.AppID))
            {
                return(new SuccessResponse <IAPIResponseData>(new XeiXinJsApiConfig()).ToJSON());
            }
            string            timestamp = ((long)((DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds)).ToString();
            string            nonceStr  = Guid.NewGuid().ToString("N").Substring(0, 16);
            XeiXinJsApiConfig config    = new XeiXinJsApiConfig()
            {
                debug     = rp.Parameters.debug,
                appId     = appEntity.AppID,
                timestamp = timestamp,
                nonceStr  = nonceStr,
                signature = this.getJsApiSignature(this.getJsApiTicket(rp.CustomerID, appEntity.AppID, appEntity.AppSecret), nonceStr, timestamp, rp.Parameters.url),
                jsApiList = new List <string>()
            };

            return(new SuccessResponse <IAPIResponseData>(config).ToJSON());
        }
示例#4
0
        /// <summary>
        /// 根据Id回复图文消息 Jermyn20140512
        /// </summary>
        /// <param name="objectId">对象标识</param>
        /// <param name="KeywordType">1=关键字回复 2=关注回复 3=自动回复</param>
        /// <param name="ObjectDataFrom">1=关键字 2=菜单</param>
        public void ReplyNewsJermyn(string objectId, int KeywordType, int ObjectDataFrom)
        {
            var dsMaterialText = new WMaterialTextDAO(requestParams.LoggingSessionInfo).GetMaterialTextByIDJermyn(objectId, ObjectDataFrom);

            if (dsMaterialText != null && dsMaterialText.Tables.Count > 0 && dsMaterialText.Tables[0].Rows.Count > 0)
            {
                var newsList = new List <WMaterialTextEntity>();

                foreach (DataRow dr in dsMaterialText.Tables[0].Rows)
                {
                    var url = dr["OriginalUrl"].ToString();

                    #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         = dr["Title"].ToString(),
                        Text          = dr["Author"].ToString(),
                        CoverImageUrl = dr["CoverImageUrl"].ToString(),
                        OriginalUrl   = url
                    });
                }

                commonService.ResponseNewsMessage(requestParams.WeixinId, requestParams.OpenId, newsList, httpContext, requestParams);
            }
        }
示例#5
0
        private string GetVipIDByOpenID(LoggingSessionInfo loggingSessionInfo, string openId)
        {
            #region 获取VIPID

            string VipID = "";

            VipBLL vipService = new VipBLL(loggingSessionInfo);
            var    vipList    = vipService.QueryByEntity(new VipEntity()
            {
                WeiXinUserId = openId
            }, null);

            if (vipList != null && vipList.Length > 0)
            {
                VipID = vipList.FirstOrDefault().VIPID;
            }

            return(VipID);

            #endregion
        }
示例#6
0
        //处理图片消息
        public virtual void HandlerImage()
        {
            string picUrl = requestParams.XmlNode.SelectSingleNode("//PicUrl").InnerText; //图片链接
            string msgId  = requestParams.XmlNode.SelectSingleNode("//MsgId").InnerText;  //消息id,64位整型

            BaseService.WriteLogWeixin("图片链接PicUrl:---------------" + picUrl);
            BaseService.WriteLogWeixin("消息id,64位整型MsgId:---------------" + msgId);

            //推送客服消息  qianzhi  2014-03-04
            VipBLL vipService = new VipBLL(requestParams.LoggingSessionInfo);
            var    vipList    = vipService.QueryByEntity(new VipEntity
            {
                WeiXinUserId = requestParams.OpenId,
                WeiXin       = requestParams.WeixinId
            }, null);

            if (vipList != null && vipList.Length > 0)
            {
                var vipEntity          = vipList.FirstOrDefault();
                CSInvokeMessageBLL msg = new CSInvokeMessageBLL(requestParams.LoggingSessionInfo);
                msg.SendMessage(1, vipEntity.VIPID, 0, null, picUrl, null, null, null, 2);
            }
        }
示例#7
0
        /// <summary>
        /// 响应微信平台推送的消息
        /// </summary>
        public void ResponseMsg()
        {
            //获取会员信息
            VipBLL vipService = new VipBLL(requestParams.LoggingSessionInfo);
            var    vipId      = string.Empty;
            var    vipEntity  = vipService.QueryByEntity(new VipEntity
            {
                WeiXinUserId = requestParams.OpenId,
                WeiXin       = requestParams.WeixinId,
                ClientID     = requestParams.LoggingSessionInfo.ClientID
            }, null);
            VipEntity vip = null;

            if (vipEntity != null && vipEntity.Length > 0)
            {
                vipId = vipEntity.FirstOrDefault().VIPID;
                vip   = vipEntity.FirstOrDefault();
            }

            //先排重复的推送信息
            //关于重试的消息排重,有msgid的消息推荐使用msgid排重。事件类型消息推荐使用FromUserName + CreateTime 排重。
            var MsgId        = requestParams.XmlNode.SelectSingleNode("//MsgId") == null?"":requestParams.XmlNode.SelectSingleNode("//MsgId").InnerText.Trim();
            var FromUserName = requestParams.XmlNode.SelectSingleNode("//FromUserName") == null?"":requestParams.XmlNode.SelectSingleNode("//FromUserName").InnerText.Trim();
            var CreateTime   = requestParams.XmlNode.SelectSingleNode("//CreateTime") == null ? "" : requestParams.XmlNode.SelectSingleNode("//CreateTime").InnerText.Trim();

            if (!string.IsNullOrEmpty(MsgId))
            {
                if (JIT.CPOS.BS.BLL.WX.Const.Config.ListMsgId.ContainsKey(MsgId))//是否包含这个键值
                {
                    httpContext.Response.Write("");
                    httpContext.Response.Write("success");
                    return;
                    //  httpContext.Response.End();
                }
                else
                {
                    JIT.CPOS.BS.BLL.WX.Const.Config.ListMsgId.Add(MsgId, CreateTime);
                }
            }
            //else if (!string.IsNullOrEmpty(FromUserName) && !string.IsNullOrEmpty(CreateTime))
            //{
            //    var eventMsgId = FromUserName + CreateTime;
            //    if (JIT.CPOS.BS.BLL.WX.Const.Config.ListMsgId.ContainsKey(eventMsgId))
            //    {
            //        httpContext.Response.Write("");
            //        httpContext.Response.Write("success");
            //        // httpContext.Response.End();
            //        return;
            //    }
            //    else
            //    {
            //        JIT.CPOS.BS.BLL.WX.Const.Config.ListMsgId.Add(eventMsgId, CreateTime);
            //    }
            //}
            ////删除超过十分钟的数据
            // List<string> msgTemp = new List<string>();
            //foreach (var item in JIT.CPOS.BS.BLL.WX.Const.Config.ListMsgId)
            //{
            //      var a=  DateTime.Parse(new CommonBLL().GetRealTime(item.Value));//timestamp转换成的时间
            //    TimeSpan ts = DateTime.Now -  DateTime.Parse(  new CommonBLL().GetRealTime(item.Value));
            //    if (ts.TotalMinutes > 10)
            //    {
            //        msgTemp.Add(item.Key);
            //    }
            //}
            ////遍历删除数据
            //foreach (var item in msgTemp)
            //{
            //    JIT.CPOS.BS.BLL.WX.Const.Config.ListMsgId.Remove(item);
            //}



            //根据不同的消息类型,进行不同的处理操作
            switch (requestParams.MsgType)
            {
            case MsgType.TEXT:        //文本消息
                BaseService.WriteLogWeixin("消息类型:---------------texttext文本消息!");

                var content = requestParams.XmlNode.SelectSingleNode("//Content").InnerText.Trim();       //文本消息内容

                //HandlerText();
                //GetIsMoreCS(content); //多客服
                //StoreRebate(content, vipId);//门店返现推送消息
                #region
                var vipDcodeBll    = new VipDCodeBLL(requestParams.LoggingSessionInfo);
                var vipDcodeEntity = vipDcodeBll.GetByID(content.Replace(" ", ""));
                if (vipDcodeEntity == null)
                {
                    HandlerText();
                    GetIsMoreCS(content);     //多客服     (客服应该不需要加密吧)
                }
                else
                {
                    content = content.Replace(" ", "");    //去空格
                    if (vipDcodeEntity.IsReturn == 1)
                    {
                        if (DateTime.Now > (vipDcodeEntity.LastUpdateTime ?? DateTime.Now).AddSeconds(3))
                        {
                            StoreRebateRepeaterMessage(vipEntity[0], content);
                        }
                    }
                    else if (DateTime.Now > (vipDcodeEntity.CreateTime ?? DateTime.Now).AddDays(1))
                    {
                        StoreRebateByTimeOut(vipEntity[0]);
                    }
                    else
                    {
                        StoreRebate(content, vipId);    //门店返现推送消息
                    }
                }
                #endregion

                new WUserMessageDAO(requestParams.LoggingSessionInfo).Create(new WUserMessageEntity
                {
                    MessageId      = Utils.NewGuid(),
                    VipId          = vipId,
                    MaterialTypeId = "1",
                    Text           = content,
                    ImageUrl       = string.Empty,
                    OpenId         = requestParams.OpenId,
                    WeiXinId       = requestParams.WeixinId,
                    DataFrom       = 1
                });

                break;

            case MsgType.IMAGE:       //图片消息

                BaseService.WriteLogWeixin("消息类型:---------------image图片消息!");

                var picUrl = requestParams.XmlNode.SelectSingleNode("//PicUrl").InnerText.Trim(); //图片链接
                GetIsMoreCS(picUrl);                                                              //多客服
                new WUserMessageDAO(requestParams.LoggingSessionInfo).Create(new WUserMessageEntity
                {
                    MessageId      = Utils.NewGuid(),
                    VipId          = vipId,
                    MaterialTypeId = "2",
                    Text           = string.Empty,
                    ImageUrl       = picUrl,
                    OpenId         = requestParams.OpenId,
                    WeiXinId       = requestParams.WeixinId,
                    DataFrom       = 1
                });

                HandlerImage();

                break;

            case MsgType.LOCATION:        //地理位置
                BaseService.WriteLogWeixin("消息类型:---------------location地理位置!");
                HandlerLocation();
                break;

            case MsgType.EVENT:       //事件
                BaseService.WriteLogWeixin("消息类型:---------------event事件!");
                HandlerEvent(vip);
                break;
            }
        }
示例#8
0
        //处理文本消息
        public void HandlerTextOld()
        {
            var content = requestParams.XmlNode.SelectSingleNode("//Content").InnerText.Trim();   //文本消息内容

            var keywordDAO = new WKeywordReplyDAO(requestParams.LoggingSessionInfo);
            var ds         = keywordDAO.GetMaterialByKeyword(content);

            #region  星临时代码  以后需要删除  qianzhi  2014-01-16

            //复星临时代码  以后需要删除  qianzhi  2014-01-16
            if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                ds = keywordDAO.GetMaterialByKeyword("任意回复");
            }

            #endregion

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                string typeId     = ds.Tables[0].Rows[0]["MaterialTypeId"].ToString(); //素材类型
                string materialId = ds.Tables[0].Rows[0]["MaterialId"].ToString();     //素材ID

                BaseService.WriteLogWeixin("typeId:" + typeId);
                BaseService.WriteLogWeixin("materialId:" + materialId);

                switch (typeId)
                {
                case MaterialType.TEXT:             //回复文字消息
                    ReplyText(materialId);
                    break;

                case MaterialType.IMAGE_TEXT:       //回复图文消息
                    ReplyNews(materialId);
                    break;

                default:
                    break;
                }
            }
            else//如果取不到关键字回复或者自动回复,就使用客服信息程序
            {
                //推送客服消息  qianzhi  2014-03-04
                VipBLL vipService = new VipBLL(requestParams.LoggingSessionInfo);
                var    vipList    = vipService.QueryByEntity(new VipEntity
                {
                    WeiXinUserId = requestParams.OpenId,
                    WeiXin       = requestParams.WeixinId
                }, null);

                if (vipList != null && vipList.Length > 0)
                {
                    var vipEntity          = vipList.FirstOrDefault();
                    CSInvokeMessageBLL msg = new CSInvokeMessageBLL(requestParams.LoggingSessionInfo);//调用客服信息

                    /// <summary>
                    /// 发送消息
                    /// </summary>
                    /// <param name="csPipelineId">消息通道ID1:微信2:短信3:IOS4:Android</param>
                    /// <param name="userId">发送者ID</param>
                    /// <param name="isCS">是否是客服1:是0:否</param>
                    /// <param name="messageId">要回复的消息ID,如果为首次请求,请传NULL</param>
                    /// <param name="messageContent">消息内容</param>
                    /// <param name="serviceTypeId">服务类型,用于特殊类型的服务,如订单咨询</param>
                    /// <param name="objectId">服务对象ID,请求对的对象ID,如订单ID</param>
                    /// <param name="messageTypeId">消息类型,默认为NULL,如果是特殊类型的消息,则传特殊类型定义ID,现在暂定=5的ID为 微信优先、短信其次、App再次发送</param>
                    /// <param name="contentTypeId">消息内容类型默认NULL或 1文本 2图片 3语音 4 视频 </param>
                    /// <param name="sign">短信签名</param>
                    /// <param name="mobileNo"></param>
                    msg.SendMessage(1, vipEntity.VIPID, 0, null, content, null, null, null, 1);
                }
            }
        }
示例#9
0
        /// <summary>
        /// 主动给用户推送订单消息
        /// </summary>
        /// <returns></returns>
        public string SetOrderPush()
        {
            var respData = new RespData();

            if (string.IsNullOrEmpty(Request["WeiXinId"]) ||
                string.IsNullOrEmpty(Request["OpenId"]) ||
                string.IsNullOrEmpty(Request["OrdeNo"]))
            {
                respData.Code        = "103";
                respData.Description = "数据库操作错误";
                respData.Exception   = "请求的数据不能为空";
                return(respData.ToJSON());
            }

            string content = string.Empty;

            try
            {
                string vipID              = string.Empty;
                string vipName            = string.Empty;
                var    loggingSessionInfo = Default.GetLjLoggingSession();
                //根据客户标识获取连接字符串  qianzhi  2013-07-30
                if (!string.IsNullOrEmpty(Request["customerId"]))
                {
                    loggingSessionInfo = Default.GetBSLoggingSession(Request["customerId"].Trim(), "");
                }

                #region 获取VIP信息

                VipBLL vipService = new VipBLL(loggingSessionInfo);
                var    vipList    = vipService.QueryByEntity(new VipEntity()
                {
                    WeiXinUserId = Request["OpenId"],
                    WeiXin       = Request["WeiXinId"]
                }, null);

                if (vipList == null || vipList.Length == 0)
                {
                    respData.Code        = "103";
                    respData.Description = "未查找到匹配的VIP信息";
                    return(respData.ToJSON());
                }
                else
                {
                    vipID   = vipList.FirstOrDefault().VIPID;
                    vipName = vipList.FirstOrDefault().VipName;
                }

                #endregion

                // 推送消息
                string msgUrl  = ConfigurationManager.AppSettings["push_weixin_msg_url"].Trim();
                string msgText = string.Format("亲爱的会员{1},您单号为{0}的购买请求我们已经收到,请您到指定渠道下交纳钱款。谢谢再次惠顾!", Request["OrdeNo"], vipName);
                string msgData = "<xml><OpenID><![CDATA[" + Request["OpenId"] + "]]></OpenID><Content><![CDATA[" + msgText + "]]></Content></xml>";

                var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData);
                #region 发送日志
                MarketSendLogBLL    logServer = new MarketSendLogBLL(loggingSessionInfo);
                MarketSendLogEntity logInfo   = new MarketSendLogEntity();
                logInfo.LogId           = BaseService.NewGuidPub();
                logInfo.IsSuccess       = 1;
                logInfo.MarketEventId   = Request["OrdeNo"];
                logInfo.SendTypeId      = "2";
                logInfo.TemplateContent = msgData;
                logInfo.VipId           = vipID;
                logInfo.WeiXinUserId    = Request["OpenId"];
                logInfo.CreateTime      = System.DateTime.Now;
                logServer.Create(logInfo);
                #endregion
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("PushMsgResult:{0}", msgResult)
                });
            }
            catch (Exception ex)
            {
                respData.Code        = "201";
                respData.Description = "操作失败";
                respData.Exception   = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }
示例#10
0
        protected override BeSuperRetailTraderRD ProcessRequest(DTO.Base.APIRequest <BeSuperRetailTraderRP> pRequest)
        {
            var rd   = new BeSuperRetailTraderRD();
            var para = pRequest.Parameters;
            LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID);
            var      vipBll  = new VipBLL(loggingSessionInfo);
            var      userBll = new T_UserBLL(loggingSessionInfo);
            var      T_SuperRetailTraderEntityBll = new T_SuperRetailTraderBLL(loggingSessionInfo);
            var      InnerGroupNewsbll            = new InnerGroupNewsBLL(loggingSessionInfo);//目前还没有针对单对单通知的站内信
            WMenuBLL menuServer   = new WMenuBLL(Default.GetAPLoggingSession(""));
            string   customerCode = menuServer.GetCustomerCodeByCustomerID(loggingSessionInfo.CurrentUser.customer_id);

            if (!string.IsNullOrEmpty(para.BeRYType))
            {
                VipEntity    VipInfo    = null;                           //会员实体
                T_UserEntity T_UserInfo = null;                           //员工实体
                T_SuperRetailTraderEntity T_SuperRetailTraderInfo = null; //超级分销商实体
                T_SuperRetailTraderInfo = T_SuperRetailTraderEntityBll.QueryByEntity(new T_SuperRetailTraderEntity()
                {
                    CustomerId = loggingSessionInfo.CurrentUser.customer_id, SuperRetailTraderFromId = para.SuperRetailTraderFromId
                }, null).FirstOrDefault();
                //判断是否已成为分销商
                if (T_SuperRetailTraderInfo == null)
                {
                    var SuperRetailTraderEntity = new T_SuperRetailTraderEntity();
                    //不是分销商 就判断分销商来源类型
                    if (para.BeRYType == "Vip")
                    {
                        //查询会员信息
                        VipInfo = vipBll.QueryByEntity(new VipEntity()
                        {
                            ClientID = loggingSessionInfo.CurrentUser.customer_id, VIPID = para.SuperRetailTraderFromId
                        }, null).FirstOrDefault();

                        if (VipInfo != null)
                        {
                            try
                            {
                                SuperRetailTraderEntity.SuperRetailTraderID    = Guid.NewGuid();
                                SuperRetailTraderEntity.SuperRetailTraderCode  = VipInfo.VipCode;
                                SuperRetailTraderEntity.SuperRetailTraderName  = VipInfo.VipRealName == null ? VipInfo.VipName : VipInfo.VipRealName;
                                SuperRetailTraderEntity.SuperRetailTraderLogin = VipInfo.Phone;
                                string strSuperPwd = StringUtil.GetRandomStr(6);//生成6位随机数,为超级分销商密码生成使用
                                SuperRetailTraderEntity.SuperRetailTraderPass     = EncryptManager.Hash(strSuperPwd, HashProviderType.MD5);
                                SuperRetailTraderEntity.SuperRetailTraderPassData = strSuperPwd;
                                SuperRetailTraderEntity.SuperRetailTraderMan      = VipInfo.VipRealName == null ? VipInfo.VipName : VipInfo.VipRealName;
                                SuperRetailTraderEntity.SuperRetailTraderPhone    = VipInfo.Phone;
                                SuperRetailTraderEntity.SuperRetailTraderAddress  = "";//目前因为没有填写详细地址的地方,给空值
                                SuperRetailTraderEntity.SuperRetailTraderFrom     = para.BeRYType;
                                SuperRetailTraderEntity.SuperRetailTraderFromId   = VipInfo.VIPID;
                                if (!string.IsNullOrEmpty(para.HigheSuperRetailTraderID))
                                {
                                    SuperRetailTraderEntity.HigheSuperRetailTraderID = new Guid(para.HigheSuperRetailTraderID);
                                }
                                if (!string.IsNullOrEmpty(VipInfo.Col20))
                                {
                                    SuperRetailTraderEntity.HigheSuperRetailTraderID = new Guid(VipInfo.Col20);
                                }
                                SuperRetailTraderEntity.JoinTime       = System.DateTime.Now;
                                SuperRetailTraderEntity.CreateTime     = System.DateTime.Now;
                                SuperRetailTraderEntity.CreateBy       = VipInfo.VIPID;
                                SuperRetailTraderEntity.LastUpdateBy   = VipInfo.VIPID;
                                SuperRetailTraderEntity.LastUpdateTime = System.DateTime.Now;
                                SuperRetailTraderEntity.IsDelete       = 0;
                                SuperRetailTraderEntity.CustomerId     = loggingSessionInfo.CurrentUser.customer_id;
                                SuperRetailTraderEntity.Status         = "00";
                                T_SuperRetailTraderEntityBll.Create(SuperRetailTraderEntity);
                                rd.IsSuperRetailTrader    = 1;
                                rd.SuperRetailTraderLogin = VipInfo.Phone;
                                rd.SuperRetailTraderPass  = strSuperPwd;
                                VipInfo.Col26             = SuperRetailTraderEntity.SuperRetailTraderID.ToString();
                                vipBll.Update(VipInfo, false);
                            }
                            catch
                            {
                                rd.IsSuperRetailTrader = 0;
                            }
                        }
                    }
                    //不是分销商 就判断分销商来源类型
                    if (para.BeRYType == "User")
                    {
                        //查询员工信息
                        T_UserInfo = userBll.QueryByEntity(new T_UserEntity()
                        {
                            customer_id = loggingSessionInfo.CurrentUser.customer_id, user_id = para.SuperRetailTraderFromId
                        }, null).FirstOrDefault();
                        if (T_UserInfo != null)
                        {
                            try
                            {
                                SuperRetailTraderEntity.SuperRetailTraderID      = Guid.NewGuid();
                                SuperRetailTraderEntity.SuperRetailTraderCode    = T_UserInfo.user_code;
                                SuperRetailTraderEntity.SuperRetailTraderName    = T_UserInfo.user_name;
                                SuperRetailTraderEntity.SuperRetailTraderLogin   = T_UserInfo.user_code;
                                SuperRetailTraderEntity.SuperRetailTraderPass    = T_UserInfo.user_password;
                                SuperRetailTraderEntity.SuperRetailTraderMan     = T_UserInfo.user_name;
                                SuperRetailTraderEntity.SuperRetailTraderPhone   = T_UserInfo.user_telephone != null ? T_UserInfo.user_telephone : T_UserInfo.user_cellphone;
                                SuperRetailTraderEntity.SuperRetailTraderAddress = T_UserInfo.user_address;
                                SuperRetailTraderEntity.SuperRetailTraderFrom    = para.BeRYType;
                                SuperRetailTraderEntity.SuperRetailTraderFromId  = T_UserInfo.user_id;
                                if (!string.IsNullOrEmpty(para.HigheSuperRetailTraderID))
                                {
                                    SuperRetailTraderEntity.HigheSuperRetailTraderID = new Guid(para.HigheSuperRetailTraderID);
                                }
                                SuperRetailTraderEntity.JoinTime       = System.DateTime.Now;
                                SuperRetailTraderEntity.CreateTime     = System.DateTime.Now;
                                SuperRetailTraderEntity.CreateBy       = T_UserInfo.user_id;
                                SuperRetailTraderEntity.LastUpdateBy   = T_UserInfo.user_id;
                                SuperRetailTraderEntity.LastUpdateTime = System.DateTime.Now;
                                SuperRetailTraderEntity.IsDelete       = 0;
                                SuperRetailTraderEntity.CustomerId     = loggingSessionInfo.CurrentUser.customer_id;
                                SuperRetailTraderEntity.Status         = "00";
                                T_SuperRetailTraderEntityBll.Create(SuperRetailTraderEntity);
                                rd.IsSuperRetailTrader = 1;//成功成为分销商
                            }
                            catch
                            {
                                rd.IsSuperRetailTrader = 0;//成为分销商失败
                            }
                        }
                    }
                    //如果成为分销商 则需要增加站内信通知
                    if (rd.IsSuperRetailTrader == 1)
                    {
                    }
                }
                else
                {
                    rd.IsSuperRetailTrader    = 2;//已成为分销商
                    rd.SuperRetailTraderLogin = T_SuperRetailTraderInfo.SuperRetailTraderLogin;
                    rd.SuperRetailTraderPass  = T_SuperRetailTraderInfo.SuperRetailTraderPassData;
                }
            }
            if (!string.IsNullOrEmpty(customerCode))
            {
                rd.CustomerCode = customerCode;
            }
            return(rd);
        }
示例#11
0
        /// <summary>
        /// 获取活动奖项信息
        /// </summary>
        public string getEventPrizes()
        {
            string content = string.Empty;

            var respData = new getEventPrizesRespData();

            try
            {
                string reqContent = Request["ReqContent"];
                var    reqObj     = reqContent.DeserializeJSONTo <getEventPrizesReqData>();

                string openId    = reqObj.common.openId;
                string weixinId  = reqObj.common.weiXinId ?? reqObj.common.openId;
                string eventId   = reqObj.special.eventId;  //活动ID
                string vipId     = reqObj.common.userId;
                string vipName   = string.Empty;
                string longitude = reqObj.special.longitude;   //经度
                string latitude  = reqObj.special.latitude;    //纬度

                if (string.IsNullOrEmpty(eventId))
                {
                    eventId = "E5A304D716D14CD2B96560EBD2B6A29C";
                }

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("getEventPrizes: {0}", reqContent)
                });

                //判断客户ID是否传递
                if (!string.IsNullOrEmpty(reqObj.common.customerId))
                {
                    customerId = reqObj.common.customerId;
                }
                var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");

                respData.content           = new getEventPrizesRespContentData();
                respData.content.prizeList = new List <PrizesEntity>();

                var eventList = new LEventsBLL(loggingSessionInfo).QueryByEntity(new LEventsEntity {
                    EventID = eventId
                }, null);

                if (eventList != null && eventList.Length > 0)
                {
                    var eventEntity = eventList.FirstOrDefault();

                    if (Convert.ToDateTime(eventEntity.EndTime).AddDays(1) > DateTime.Now)  //当天还是有效的   updated by Willie Yan on 2014-04-28
                    {
                        #region 获取VIPID

                        VipBLL vipService = new VipBLL(loggingSessionInfo);
                        var    vipList    = vipService.QueryByEntity(new VipEntity()
                        {
                            WeiXinUserId = openId
                        }, null);

                        if (vipList == null || vipList.Length == 0)
                        {
                            respData.code        = "103";
                            respData.description = "未查找到匹配的VIP信息";
                            return(respData.ToJSON());
                        }
                        else
                        {
                            vipId   = vipList.FirstOrDefault().VIPID;
                            vipName = vipList.FirstOrDefault().VipName;
                        }

                        #endregion

                        //查询抽奖日志
                        LLotteryLogBLL lotteryService = new LLotteryLogBLL(loggingSessionInfo);
                        var            lotteryList    = lotteryService.QueryByEntity(new LLotteryLogEntity()
                        {
                            EventId = eventId, VipId = vipId
                        }, null);

                        #region 奖品信息

                        LPrizesBLL prizesService = new LPrizesBLL(loggingSessionInfo);

                        var prizesList = prizesService.QueryByEntity(new LPrizesEntity()
                        {
                            EventId = eventId
                        },
                                                                     new OrderBy[] { new OrderBy {
                                                                                         FieldName = " DisplayIndex ", Direction = OrderByDirections.Asc
                                                                                     } });

                        if (prizesList != null && prizesList.Length > 0)
                        {
                            foreach (var item in prizesList)
                            {
                                var entity = new PrizesEntity()
                                {
                                    prizesID     = item.PrizesID,
                                    prizeName    = item.PrizeName,
                                    prizeDesc    = item.PrizeDesc,
                                    displayIndex = item.DisplayIndex.ToString(),
                                    countTotal   = item.CountTotal.ToString(),
                                    imageUrl     = item.ImageUrl
                                };

                                respData.content.prizeList.Add(entity);
                            }
                        }

                        #endregion

                        #region 抽奖信息

                        //respData.content.lotteryCount = eventEntity.PrizesCount.ToString();
                        respData.content.lotteryNumber = "0";
                        respData.content.validTime     = ConfigurationManager.AppSettings["ValidTime"];
                        int totalLotteryCount = 0;

                        //获取剩余抽奖次数
                        VwVipCenterInfoBLL vwVipCenterInfoBLL = new VwVipCenterInfoBLL(loggingSessionInfo);
                        var vwVipCenterInfo = vwVipCenterInfoBLL.GetByID(vipId);
                        totalLotteryCount = vwVipCenterInfo.LotteryCount ?? 0;

                        //获取已抽奖次数
                        if (lotteryList != null && lotteryList.Length > 0)
                        {
                            respData.content.lotteryNumber = lotteryList.FirstOrDefault().LotteryCount.ToString();
                        }
                        else
                        {
                            totalLotteryCount++; //如果未抽奖,活动默认有一次抽奖机会
                        }
                        //判断抽奖次数是否有效
                        if (Convert.ToInt32(respData.content.lotteryNumber) >= totalLotteryCount)
                        {
                            respData.content.isLottery   = "0";
                            respData.content.lotteryDesc = "您已经没有抽奖机会了,想得到更多抽奖机会,请在对话栏内发送中文“分享”给我们,获得图文消息后多多转发。详情关注“推荐有礼”菜单。";
                        }
                        else
                        {
                            //判断之前是否已经中奖
                            LPrizeWinnerBLL winnerService = new LPrizeWinnerBLL(loggingSessionInfo);
                            var             prize         = winnerService.GetWinnerInfo(vipId, eventId);

                            if (!prize.Read())
                            {
                                //抽奖
                                LPrizePoolsBLL poolsServer   = new LPrizePoolsBLL(loggingSessionInfo);
                                var            returnDataObj = poolsServer.SetShakeOffLottery(vipName, vipId, eventId, ToFloat(longitude), ToFloat(latitude));

                                if (returnDataObj.Params.result_code.Equals("1"))   //中奖
                                {
                                    //获取奖品信息
                                    prize = winnerService.GetWinnerInfo(vipId, eventId);
                                    if (prize.Read())
                                    {
                                        var prizeValue = GetPrizeValue(prize["PrizeShortDesc"].ToString());

                                        respData.content.isLottery    = "1";
                                        respData.content.lotteryDesc  = returnDataObj.Params.result_message;// "恭喜您中奖了";
                                        respData.content.isWinning    = "1";
                                        respData.content.winningValue = prizeValue;
                                    }
                                    //added by zhangwei 中奖后绑定推荐关系,设置奖项
                                    BindRecommender();
                                    setEventPrizes();
                                }
                                else    //没有中奖,一直能抽奖
                                {
                                    respData.content.isLottery    = "1";
                                    respData.content.isWinning    = "0";
                                    respData.content.winningValue = "0";
                                    respData.content.lotteryDesc  = "恭喜您中奖了";//张伟,为泸州老窖新人有礼前台判断使用
                                }
                            }
                            else
                            {
                                var prizeValue = GetPrizeValue(prize["PrizeShortDesc"].ToString());

                                respData.content.isLottery    = "1";
                                respData.content.lotteryDesc  = "恭喜您中奖了";
                                respData.content.isWinning    = "1";
                                respData.content.winningValue = prizeValue;
                            }
                            prize.Close();
                            respData.content.lotteryCount = totalLotteryCount.ToString();
                        }

                        #endregion
                    }
                    else
                    {
                        respData.content.isLottery   = "0";
                        respData.content.lotteryDesc = "活动已经结束";
                    }
                }
                else
                {
                    respData.content.isLottery   = "0";
                    respData.content.lotteryDesc = "指定的活动不存在";
                }
            }
            catch (Exception ex)
            {
                respData.code        = "103";
                respData.description = "数据库操作错误";
                //respData.exception = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }
示例#12
0
        protected override GetMemberInfoRD ProcessRequest(DTO.Base.APIRequest <GetMemberInfoRP> pRequest)
        {
            GetMemberInfoRD rd = new GetMemberInfoRD();

            rd.MemberInfo = new MemberInfo();
            var vipLoginBLL = new VipBLL(base.CurrentUserInfo);

            //如果有一个查询标识非空,就用查询标识查,发现没有会员就报错
            if (!string.IsNullOrEmpty(pRequest.Parameters.SearchFlag))
            {
                List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                };
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "ClientID", Value = CurrentUserInfo.ClientID
                });
                var cond1 = new LikeCondition()
                {
                    FieldName = "VipName", Value = "%" + pRequest.Parameters.SearchFlag + "%"
                };
                var cond2 = new LikeCondition()
                {
                    FieldName = "VipRealName", Value = "%" + pRequest.Parameters.SearchFlag + "%"
                };
                var com1 = new ComplexCondition()
                {
                    Left = cond1, Right = cond2, Operator = LogicalOperators.Or
                };

                var cond3 = new EqualsCondition()
                {
                    FieldName = "Phone", Value = pRequest.Parameters.SearchFlag
                };
                var com2 = new ComplexCondition()
                {
                    Left = com1, Right = cond3, Operator = LogicalOperators.Or
                };
                complexCondition.Add(com2);
                complexCondition.Add(new DirectCondition("(WeiXinUserId!='' Or WeiXinUserId IS NOT NULL)"));
                var tempVipList = vipLoginBLL.Query(complexCondition.ToArray(), null);
                if (tempVipList != null && tempVipList.Length != 0)
                {
                    pRequest.UserID = pRequest.Parameters.MemberID = tempVipList[0].VIPID;
                }
            }

            string m_MemberID = "";

            if (!string.IsNullOrWhiteSpace(pRequest.Parameters.OwnerVipID))
            {
                m_MemberID = string.IsNullOrWhiteSpace(pRequest.Parameters.OwnerVipID) ? pRequest.UserID : pRequest.Parameters.OwnerVipID;
            }
            else
            {
                m_MemberID = string.IsNullOrWhiteSpace(pRequest.Parameters.MemberID) ? pRequest.UserID : pRequest.Parameters.MemberID;
            }

            string UserID       = m_MemberID;
            var    VipLoginInfo = vipLoginBLL.GetByID(UserID);

            if (VipLoginInfo == null)
            {
                throw new APIException("用户不存在")
                      {
                          ErrorCode = 330
                      }
            }
            ;
            #region 20140909 kun.zou 发现状态为0,改为1
            if (VipLoginInfo.Status.HasValue && VipLoginInfo.Status == 0)
            {
                VipLoginInfo.Status = 1;
                vipLoginBLL.Update(VipLoginInfo, false);
                var log = new VipLogEntity()
                {
                    Action       = "更新",
                    ActionRemark = "vip状态为0的改为1.",
                    CreateBy     = UserID,
                    CreateTime   = DateTime.Now,
                    VipID        = VipLoginInfo.VIPID,
                    LogID        = Guid.NewGuid().ToString("N")
                };
                var logBll = new VipLogBLL(base.CurrentUserInfo);
                logBll.Create(log);
            }
            #endregion
            int couponCount = vipLoginBLL.GetVipCoupon(UserID);

            rd.MemberInfo.Mobile      = VipLoginInfo.Phone;      //手机号码
            rd.MemberInfo.Name        = VipLoginInfo.UserName;   //姓名
            rd.MemberInfo.VipID       = VipLoginInfo.VIPID;      //组标识
            rd.MemberInfo.VipName     = VipLoginInfo.VipName;    //会员名
            rd.MemberInfo.ImageUrl    = VipLoginInfo.HeadImgUrl; //会员头像  add by Henry 2014-12-5
            rd.MemberInfo.VipRealName = VipLoginInfo.VipRealName;
            rd.MemberInfo.VipNo       = VipLoginInfo.VipCode;
            rd.MemberInfo.IsDealer    = VipLoginInfo.Col48 != null?int.Parse(VipLoginInfo.Col48) : 0;

            //超级分销体系配置表 为判断是否存在分销体系使用
            var T_SuperRetailTraderConfigbll = new T_SuperRetailTraderConfigBLL(CurrentUserInfo);
            //获取分销体系信息
            var T_SuperRetailTraderConfigInfo = T_SuperRetailTraderConfigbll.QueryByEntity(new T_SuperRetailTraderConfigEntity()
            {
                IsDelete = 0, CustomerId = CurrentUserInfo.CurrentUser.customer_id
            }, null).FirstOrDefault();
            if (T_SuperRetailTraderConfigInfo != null)
            {
                rd.MemberInfo.CanBeSuperRetailTrader = 1;
            }
            else
            {
                rd.MemberInfo.CanBeSuperRetailTrader = 0;
            }
            rd.MemberInfo.SuperRetailTraderID = VipLoginInfo.Col26;
            //rd.MemberInfo.Integration = VipLoginInfo.Integration ?? 0;//会员积分

            #region 会员有效积分
            var vipIntegralBLL  = new VipIntegralBLL(CurrentUserInfo);
            var vipIntegralInfo = vipIntegralBLL.QueryByEntity(new VipIntegralEntity()
            {
                VipID = UserID, VipCardCode = VipLoginInfo.VipCode
            }, null).FirstOrDefault();
            if (vipIntegralInfo != null)
            {
                rd.MemberInfo.Integration = vipIntegralInfo.ValidIntegral != null ? vipIntegralInfo.ValidIntegral.Value : 0;
            }
            #endregion

            //会员等级
            //rd.MemberInfo.VipLevelName = string.IsNullOrEmpty(vipLoginBLL.GetVipLeave(UserID)) ? null : vipLoginBLL.GetVipLeave(UserID);
            #region 会员卡名称
            var                vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo);
            var                vipCardBLL           = new VipCardBLL(CurrentUserInfo);
            var                vipCardTypeBLL       = new SysVipCardTypeBLL(CurrentUserInfo);
            var                vipCardRuleBLL       = new VipCardRuleBLL(CurrentUserInfo);
            var                vipT_InoutBLL        = new T_InoutBLL(CurrentUserInfo);
            VipAmountBLL       vipAmountBLL         = new VipAmountBLL(CurrentUserInfo);
            ShoppingCartBLL    service     = new ShoppingCartBLL(CurrentUserInfo);
            ShoppingCartEntity queryEntity = new ShoppingCartEntity();
            queryEntity.VipId = UserID;
            int totalQty = service.GetListQty(queryEntity);
            rd.MemberInfo.ShopCartCount = totalQty;
            //定义当前自定义等级
            int?CurVipLevel        = 0;
            var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
            {
                VIPID = UserID, CustomerID = CurrentUserInfo.ClientID
            },
                                                                        new OrderBy[] { new OrderBy()
                                                                                        {
                                                                                            FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                                                                        } }).FirstOrDefault();
            if (vipCardMappingInfo != null)
            {
                var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity()
                {
                    VipCardID = vipCardMappingInfo.VipCardID, VipCardStatusId = 1
                }, null).FirstOrDefault();
                if (vipCardInfo != null)
                {
                    var vipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                    {
                        VipCardTypeID = vipCardInfo.VipCardTypeID
                    }, null).FirstOrDefault();
                    if (vipCardTypeInfo != null)
                    {
                        rd.MemberInfo.VipLevelName     = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : "";
                        rd.MemberInfo.CardTypeImageUrl = vipCardTypeInfo.PicUrl != null ? vipCardTypeInfo.PicUrl : "";
                        rd.MemberInfo.CardTypePrice    = vipCardTypeInfo.Prices != null ? vipCardTypeInfo.Prices.Value : 0;
                        rd.MemberInfo.IsExtraMoney     = vipCardTypeInfo.IsExtraMoney != null ? vipCardTypeInfo.IsExtraMoney : 0;
                        CurVipLevel             = vipCardTypeInfo.VipCardLevel;
                        rd.MemberInfo.IsPrepaid = vipCardTypeInfo.Isprepaid;
                        if (CurVipLevel > 1)
                        {
                            var VipCardTypeSysInfo = vipCardTypeBLL.GetBindVipCardTypeInfo(CurrentUserInfo.ClientID, VipLoginInfo.Phone, pRequest.UserID, CurVipLevel);
                            if (VipCardTypeSysInfo == null || VipCardTypeSysInfo.Tables[0].Rows.Count == 0)
                            {
                                rd.MemberInfo.IsNeedCard = 2;
                            }
                        }
                        else
                        {
                            rd.MemberInfo.IsNeedCard = 1;
                        }
                        //因为卡等级不能重复,知道当前等级后查找相应的下一级是否是自动升级(消费升级)
                        var NextVipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                        {
                            VipCardLevel = CurVipLevel + 1, CustomerID = CurrentUserInfo.ClientID
                        }, null).FirstOrDefault();
                        if (NextVipCardTypeInfo != null)
                        {
                            //获取当前会员的消费金额信息
                            decimal CurVipConsumptionAmount = 0;
                            decimal VipConsumptionInfo      = vipT_InoutBLL.GetVipSumAmount(UserID);
                            if (VipConsumptionInfo > 0)
                            {
                                CurVipConsumptionAmount = Convert.ToDecimal(Convert.ToDecimal(VipConsumptionInfo).ToString("0.00"));
                            }
                            //知道下一等级后要判断,升级条件是否是消费升级
                            //定义累积消费金额
                            decimal AccumulatedAmount      = 0;
                            var     vipCardTypeUpGradeInfo = vipCardTypeBLL.GetVipCardTypeUpGradeInfo(CurrentUserInfo.ClientID, CurVipLevel);
                            if (vipCardTypeUpGradeInfo != null && vipCardTypeUpGradeInfo.Tables[0].Rows.Count > 0)
                            {
                                //判断拉取的所有卡等级里的最近的一级满足条件即可返回提示所需的值
                                int flag = 0;
                                foreach (DataRow dr in vipCardTypeUpGradeInfo.Tables[0].Rows)
                                {
                                    AccumulatedAmount = Convert.ToDecimal(Convert.ToDecimal(dr["BuyAmount"].ToString()).ToString("0.00"));
                                    //获取消费升级还需多少钱
                                    if (AccumulatedAmount > CurVipConsumptionAmount && flag == 0)
                                    {
                                        flag = 1;
                                        rd.MemberInfo.UpGradeNeedMoney = AccumulatedAmount - CurVipConsumptionAmount;
                                        if (rd.MemberInfo.UpGradeNeedMoney > 0)
                                        {
                                            rd.MemberInfo.UpgradePrompt = "还需要消费" + rd.MemberInfo.UpGradeNeedMoney + "元可以升级啦,快点通知会员!";
                                        }
                                    }
                                }
                            }
                        }

                        var VipCardRuleInfo = vipCardRuleBLL.QueryByEntity(new VipCardRuleEntity()
                        {
                            CustomerID = CurrentUserInfo.ClientID, VipCardTypeID = vipCardTypeInfo.VipCardTypeID
                        }, null).FirstOrDefault();
                        if (VipCardRuleInfo != null)
                        {
                            rd.MemberInfo.CardDiscount = Convert.ToDecimal(Convert.ToDecimal((VipCardRuleInfo.CardDiscount / 10)).ToString("0.00"));
                        }
                    }
                }
            }
            else
            {
                //表示需要领卡,并展示等级为1的默认卡
                rd.MemberInfo.IsNeedCard = 0;
                var VipCardTypeData = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                {
                    VipCardLevel = 1, CustomerID = CurrentUserInfo.ClientID
                }, null).FirstOrDefault();
                if (VipCardTypeData != null)
                {
                    rd.MemberInfo.CardTypeImageUrl = VipCardTypeData.PicUrl != null ? VipCardTypeData.PicUrl : "";
                }
            }
            //获取红利/// decimal[0]=总收入(红利) decimal[2]=支出余额 decimal[1]=总提现金额
            decimal[] array = vipAmountBLL.GetVipSumAmountByCondition(UserID, CurrentUserInfo.ClientID, true);
            if (array[0] != null)
            {
                rd.MemberInfo.ProfitAmount = array[0];
            }
            //是否有付费的会员卡
            List <IWhereCondition> freeCardCon = new List <IWhereCondition> {
            };
            freeCardCon.Add(new EqualsCondition()
            {
                FieldName = "CustomerID", Value = CurrentUserInfo.ClientID
            });
            freeCardCon.Add(new DirectCondition("Prices>0"));
            var freeCardTypeInfo = vipCardTypeBLL.Query(freeCardCon.ToArray(), null).FirstOrDefault();
            if (freeCardTypeInfo != null)
            {
                rd.MemberInfo.IsCostCardType = 1;
            }
            else
            {
                rd.MemberInfo.IsCostCardType = 0;
            }

            #endregion

            rd.MemberInfo.Status       = VipLoginInfo.Status.HasValue ? VipLoginInfo.Status.Value : 1;
            rd.MemberInfo.CouponsCount = couponCount;
            rd.MemberInfo.IsActivate   = (VipLoginInfo.IsActivate.HasValue && VipLoginInfo.IsActivate.Value == 1 ? true : false);
            var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo);
            rd.MemberInfo.MemberBenefits = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID);



            //获取标签信息
            TagsBLL TagsBLL = new TagsBLL(base.CurrentUserInfo);


            var dsIdentity = TagsBLL.GetVipTagsList("", UserID);//“车主标签”  传7
            if (dsIdentity != null && dsIdentity.Tables.Count > 0 && dsIdentity.Tables[0].Rows.Count > 0)
            {
                rd.IdentityTagsList = DataTableToObject.ConvertToList <TagsInfo>(dsIdentity.Tables[0]).ToArray(); //“年龄段”  传8
            }


            #region 获取注册表单的列明和值

            var vipEntity = vipLoginBLL.QueryByEntity(new VipEntity()
            {
                VIPID = UserID
            }, null);

            if (vipEntity == null || vipEntity.Length == 0)
            {
                return(rd);
            }
            else
            {
                var ds = vipLoginBLL.GetVipColumnInfo(CurrentUserInfo.ClientID, "online005");

                var vipDs = vipLoginBLL.GetVipInfo(UserID);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    var temp = ds.Tables[0].AsEnumerable().Select(t => new MemberControlInfo()
                    {
                        ColumnName  = t["ColumnName"].ToString(),
                        ControlType = Convert.ToInt32(t["ControlType"]),
                        ColumnValue = vipDs.Tables[0].Rows[0][t["ColumnName"].ToString()].ToString(),
                        ColumnDesc  = t["columnDesc"].ToString()
                    });

                    rd.MemberControlList = temp.ToArray();
                }
            }

            //var vipamountBll = new VipAmountBLL(this.CurrentUserInfo);

            //var vipAmountEntity = vipamountBll.GetByID(UserID);


            var unitBll = new UnitBLL(this.CurrentUserInfo);
            //Hashtable htPara = new Hashtable();
            //htPara["MemberID"] = UserID;
            //htPara["CustomerID"] = CurrentUserInfo.ClientID;
            //htPara["PageIndex"] = 1;
            //htPara["PageSize"] = 10;
            //DataSet dsMyAccount = unitBll.GetMyAccount(htPara);

            //if (dsMyAccount.Tables[0].Rows.Count > 0)
            //{
            //    //rd.AccountList = DataTableToObject.ConvertToList<AccountInfo>(dsMyAccount.Tables[0]);
            //    //rd.MemberInfo.Balance = Convert.ToDecimal(dsMyAccount.Tables[0].Rows[0]["Total"].ToString());
            //    //rd.TotalPageCount = int.Parse(dsMyAccount.Tables[0].Rows[0]["PageCount"].ToString());

            //}
            //else
            //    rd.MemberInfo.Balance = 0;

            //返现 add by Henry 2015-4-15
            var vipAmountBll = new VipAmountBLL(CurrentUserInfo);
            //var vipAmountInfo = vipAmountBll.GetByID(UserID);
            var vipAmountInfo = vipAmountBll.QueryByEntity(new VipAmountEntity()
            {
                VipId = UserID, VipCardCode = VipLoginInfo.VipCode
            }, null).FirstOrDefault();
            decimal returnAmount = 0;
            decimal amount       = 0;
            if (vipAmountInfo != null)
            {
                returnAmount = vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value;
                amount       = vipAmountInfo.EndAmount == null ? 0 : vipAmountInfo.EndAmount.Value;
            }
            rd.MemberInfo.ReturnAmount = returnAmount; //返现
            rd.MemberInfo.Balance      = amount;       //余额
            #endregion


            //获取订单的日期和订单的里的商品名称、商品单价、商品数量
            //先获取订单列表,再获取订单详细信息
            int?         pageSize     = 3; //rp.Parameters.PageSize;,只取三条记录
            int?         pageIndex    = 1; //rp.Parameters.PageIndex;
            string       OrderBy      = "";
            string       OrderType    = "";
            T_InoutBLL   T_InoutBLL   = new T_InoutBLL(CurrentUserInfo);
            InoutService InoutService = new InoutService(CurrentUserInfo);
            //只取状态为700的
            //根据订单列表取订单详情
            DataSet dsOrder = T_InoutBLL.GetOrdersByVipID(rd.MemberInfo.VipID, pageIndex ?? 1, pageSize ?? 15, OrderBy, OrderType);//获取会员信息
            if (dsOrder != null && dsOrder.Tables.Count != 0 && dsOrder.Tables[0].Rows.Count != 0)
            {
                List <JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo> orderList = DataTableToObject.ConvertToList <JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo>(dsOrder.Tables[1]);
                foreach (JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo oi in orderList)
                {
                    IList <InoutDetailInfo> detailList = InoutService.GetInoutDetailInfoByOrderId(oi.order_id);
                    oi.DetailList = detailList;
                }
                rd.OrderList = orderList;
            }

            MessageInfo message = new MessageInfo();


            InnerGroupNewsBLL InnerGroupNewsService = new InnerGroupNewsBLL(CurrentUserInfo);
            SetoffToolsBLL    setofftoolsService    = new SetoffToolsBLL(CurrentUserInfo);

            //1=微信用户 2=APP员工
            int UnReadInnerMessageCount = InnerGroupNewsService.GetVipInnerGroupNewsUnReadCount(CurrentUserInfo.UserID, pRequest.CustomerID, 1, null, Convert.ToDateTime(VipLoginInfo.CreateTime));
            var setofftoolsMessageCount = setofftoolsService.GetUnReadSetoffToolsCount(CurrentUserInfo.UserID, pRequest.CustomerID, 1, 1);
            message.InnerGroupNewsCount = UnReadInnerMessageCount;
            message.SetoffToolsCount    = setofftoolsMessageCount;
            var VipUpNewsInfo = InnerGroupNewsService.GetVipInnerNewsInfo(CurrentUserInfo.ClientID, 2, 1, 3, 0);
            if (VipUpNewsInfo != null && VipUpNewsInfo.Tables[0].Rows.Count > 0)
            {
                message.UpGradeSucess = VipUpNewsInfo.Tables[0].Rows[0]["Text"] != null ? VipUpNewsInfo.Tables[0].Rows[0]["Text"].ToString() : "";
                //获取通知信息 并更新已读状态 数据如果不是一条进行更新所有数据
                var newsUserMappingBLL = new NewsUserMappingBLL(CurrentUserInfo);
                if (VipUpNewsInfo.Tables[0].Rows.Count > 1)//数据如果不是一条进行更新所有数据
                {
                    foreach (DataRow VipNewsdr in VipUpNewsInfo.Tables[0].Rows)
                    {
                        var vipNewsInfo = newsUserMappingBLL.QueryByEntity(new NewsUserMappingEntity()
                        {
                            CustomerId = CurrentUserInfo.ClientID, MappingID = VipNewsdr["MappingID"].ToString()
                        }, null).FirstOrDefault();
                        if (vipNewsInfo != null)
                        {
                            vipNewsInfo.HasRead = 1;
                            newsUserMappingBLL.Update(vipNewsInfo);
                        }
                    }
                }
                else
                {
                    var vipNewsInfo = newsUserMappingBLL.QueryByEntity(new NewsUserMappingEntity()
                    {
                        CustomerId = CurrentUserInfo.ClientID, MappingID = VipUpNewsInfo.Tables[0].Rows[0]["MappingID"].ToString()
                    }, null).FirstOrDefault();
                    if (vipNewsInfo != null)
                    {
                        vipNewsInfo.HasRead = 1;
                        newsUserMappingBLL.Update(vipNewsInfo);
                    }
                }
            }
            else
            {
                message.UpGradeSucess = "";
            }
            rd.MessageInfo = message;
            return(rd);
        }
    }
示例#13
0
        public string SetSignUp()
        {
            string content  = string.Empty;
            var    respData = new SetSignUpRespData();

            try
            {
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("SetSignUp: {0}", reqContent)
                });

                #region //解析请求字符串 chech
                var reqObj = reqContent.DeserializeJSONTo <SetSignUpReqData>();

                if (reqObj.special == null)
                {
                    respData.code        = "101";
                    respData.description = "没有特殊参数";
                    return(respData.ToJSON().ToString());
                }
                if (reqObj.special.phone == null || reqObj.special.phone.Equals(""))
                {
                    respData.code        = "102";
                    respData.description = "电话不能为空";
                    return(respData.ToJSON().ToString());
                }
                #endregion

                #region //判断客户ID是否传递
                if (!string.IsNullOrEmpty(reqObj.common.customerId))
                {
                    customerId = reqObj.common.customerId;
                }
                var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");
                #endregion

                //#region 判断客户是否扫过活动二维码
                QRCodeScanLogBLL qRCodeScanLogBLL = new QRCodeScanLogBLL(loggingSessionInfo);
                if (!qRCodeScanLogBLL.CheckVipEventQRCode(reqObj.common.userId, reqObj.special.eventId))
                {
                    respData.code        = "2206";
                    respData.description = "请先扫描本次活动的二维码";
                    return(respData.ToJSON().ToString());
                }
                //#endregion

                VipBLL      vipBLL      = new VipBLL(loggingSessionInfo);
                EventVipBLL eventVipBLL = new EventVipBLL(loggingSessionInfo);

                var tmpPhoneVip = vipBLL.GetVipByPhone(reqObj.special.phone, reqObj.common.userId, "2");

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = "tmpPhoneVip: " + tmpPhoneVip.ToJSON()
                });

                if (tmpPhoneVip != null && tmpPhoneVip.VIPID != reqObj.common.userId)
                {
                    respData.code        = "2201";
                    respData.description = "您填写的手机号码已经被其他参会人员认证。如需帮助,请联系现场工作人员。";
                    return(respData.ToJSON().ToString());
                }

                var tmpEventVipList = eventVipBLL.QueryByEntity(new EventVipEntity()
                {
                    Phone   = reqObj.special.phone,
                    EventId = reqObj.special.eventId
                }, null);

                var tmpVipList = vipBLL.QueryByEntity(new VipEntity()
                {
                    VIPID      = reqObj.common.userId
                    , ClientID = customerId
                }, null);

                #region 与会嘉宾中存在该手机号
                if (tmpEventVipList != null && tmpEventVipList.Length > 0)
                {
                    #region 会员表中存在该会员
                    if (tmpVipList != null && tmpVipList.Length > 0)
                    {
                        //签到
                        vipBLL.Update(new VipEntity()
                        {
                            VIPID       = reqObj.common.userId,
                            VipRealName = tmpEventVipList[0].VipName,
                            Phone       = reqObj.special.phone,
                            Status      = 2
                        }, false);

                        respData.code        = "200";
                        respData.description = "恭喜您签到成功!";
                    }
                    #endregion
                }
                #endregion
                else
                {
                    respData.code        = "2202";
                    respData.description = "在参会嘉宾中未查询到您输入的手机号码,请确认您输入是否有误。如需帮助,请联系现场工作人员。";
                    return(respData.ToJSON().ToString());
                }

                if (!string.IsNullOrEmpty(tmpEventVipList[0].Seat))
                {
                    respData.content      = new SetSignUpRespContentData();
                    respData.description += "您的座位是:" + tmpEventVipList[0].Seat + ",请就坐。";
                }

                string error    = "";
                var    sendFlag = eventVipBLL.SetEventVipSeatPush(tmpVipList[0].VIPID, reqObj.special.eventId, out error);
                if (!sendFlag)
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("SetStaffSeatsPush: {0}", error)
                    });
                }
            }
            catch (Exception ex)
            {
                respData.code        = "103";
                respData.description = "数据库操作错误";
                respData.exception   = ex.ToString();

                Loggers.Exception(new ExceptionLogInfo()
                {
                    ErrorMessage = ex.ToJSON()
                });
            }
            content = respData.ToJSON();
            return(content);
        }
示例#14
0
        /// <summary>
        /// 验证真伪得积分
        /// </summary>
        public string SetCheckReal()
        {
            string content  = string.Empty;
            var    respData = new SetCheckRealRespData();

            try
            {
                string openId = Request["openID"];
                //openId = "o8Y7Ejl1zl5RHXDvPONCNqoC5Md8";

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format(
                        "OpenID:{0}", openId)
                });

                var currentUser = Default.GetLoggingSession();

                VipBLL               vipBLL               = new VipBLL(currentUser);
                IntegralRuleBLL      integralRuleBLL      = new IntegralRuleBLL(currentUser);
                VipIntegralDetailBLL vipIntegralDetailBLL = new VipIntegralDetailBLL(currentUser);
                VipIntegralBLL       vipIntegralBLL       = new VipIntegralBLL(currentUser);

                string vipId = null;
                if (true)
                {
                    VipEntity vipIdData     = null;
                    var       vipIdDataList = vipBLL.QueryByEntity(new VipEntity()
                    {
                        WeiXinUserId = openId
                    }, null);
                    if (vipIdDataList == null || vipIdDataList.Length == 0 || vipIdDataList[0] == null ||
                        vipIdDataList[0].VIPID == null)
                    {
                        respData.Code        = "103";
                        respData.Description = "数据库操作错误";
                        respData.Exception   = "未查询到Vip会员";
                        return(respData.ToJSON());
                    }
                    else
                    {
                        vipIdData = vipIdDataList[0];
                        vipId     = vipIdData.VIPID;
                    }
                }

                // SysIntegralSource: 10
                string integralSourceId = "10";
                int    integralValue    = 0;
                if (true)
                {
                    IntegralRuleEntity integralRuleData = null;
                    var integralRuleDataList            = integralRuleBLL.QueryByEntity(new IntegralRuleEntity()
                    {
                        IntegralSourceID = integralSourceId
                    }, null);
                    if (integralRuleDataList == null || integralRuleDataList.Length == 0 || integralRuleDataList[0] == null)
                    {
                        respData.Code        = "103";
                        respData.Description = "数据库操作错误";
                        respData.Exception   = "未查询到积分规则";
                        return(respData.ToJSON());
                    }
                    else
                    {
                        integralRuleData = integralRuleDataList[0];
                        integralValue    = int.Parse(integralRuleData.Integral);
                    }
                }

                #region 保存积分
                if (true)
                {
                    string tmpVipId            = vipId;
                    int    tmpIntegralValue    = integralValue;
                    string tmpIntegralSourceId = integralSourceId;
                    string tmpOpenId           = openId;
                    string msgModel            = "【验真品,送积分】活动,您本次验证赢得{0}点积分。您当前的总积分是{1}点。";

                    // 插入积分明细
                    VipIntegralDetailEntity vipIntegralDetailEntity = new VipIntegralDetailEntity();
                    vipIntegralDetailEntity.VipIntegralDetailID = CPOS.Common.Utils.NewGuid();
                    vipIntegralDetailEntity.VIPID            = tmpVipId;
                    vipIntegralDetailEntity.FromVipID        = tmpVipId;
                    vipIntegralDetailEntity.SalesAmount      = 0;
                    vipIntegralDetailEntity.Integral         = tmpIntegralValue;
                    vipIntegralDetailEntity.IntegralSourceID = tmpIntegralSourceId;
                    vipIntegralDetailEntity.IsAdd            = 1;
                    //vipIntegralDetailBLL.Create(vipIntegralDetailEntity);

                    // 更新积分
                    VipIntegralEntity vipIntegralEntity = new VipIntegralEntity();
                    var vipIntegralDataList             = vipIntegralBLL.QueryByEntity(
                        new VipIntegralEntity()
                    {
                        VipID = vipId
                    }, null);
                    if (vipIntegralDataList == null || vipIntegralDataList.Length == 0 || vipIntegralDataList[0] == null)
                    {
                        vipIntegralEntity.VipID           = tmpVipId;
                        vipIntegralEntity.BeginIntegral   = 0;                // 期初积分
                        vipIntegralEntity.InIntegral      = tmpIntegralValue; // 增加积分
                        vipIntegralEntity.OutIntegral     = 0;                //消费积分
                        vipIntegralEntity.EndIntegral     = tmpIntegralValue; //积分余额
                        vipIntegralEntity.InvalidIntegral = 0;                // 累计失效积分
                        vipIntegralEntity.ValidIntegral   = tmpIntegralValue; // 当前有效积分
                        //vipIntegralBLL.Create(vipIntegralEntity);
                    }
                    else
                    {
                        vipIntegralEntity.VipID      = tmpVipId;
                        vipIntegralEntity.InIntegral = vipIntegralDataList[0].InIntegral + tmpIntegralValue;;      // 增加积分
                        //vipIntegralEntity.OutIntegral = 0; //消费积分
                        vipIntegralEntity.EndIntegral = vipIntegralDataList[0].EndIntegral + tmpIntegralValue;     //积分余额
                        //vipIntegralEntity.InvalidIntegral = 0; // 累计失效积分
                        vipIntegralEntity.ValidIntegral = vipIntegralDataList[0].ValidIntegral + tmpIntegralValue; // 当前有效积分
                        //vipIntegralBLL.Update(vipIntegralEntity, false);
                    }

                    // 更新VIP
                    VipEntity vipEntity         = new VipEntity();
                    var       vipEntityDataList = vipBLL.QueryByEntity(
                        new VipEntity()
                    {
                        VIPID = tmpVipId
                    }, null);
                    if (vipEntityDataList == null || vipEntityDataList.Length == 0 || vipEntityDataList[0] == null)
                    {
                        vipEntity.VIPID       = tmpVipId;
                        vipEntity.Integration = vipIntegralEntity.ValidIntegral;
                        //vipEntity.HigherVipID = highOpenId;
                        vipEntity.ClientID = currentUser.CurrentUser.customer_id;
                        vipEntity.Status   = 1;
                        vipBLL.Create(vipEntity);
                    }
                    else
                    {
                        vipEntity.VIPID       = tmpVipId;
                        vipEntity.Integration = vipIntegralEntity.ValidIntegral;
                        //vipEntity.HigherVipID = highOpenId;
                        vipEntity.ClientID = currentUser.CurrentUser.customer_id;
                        vipBLL.Update(vipEntity, false);
                    }

                    // 推送消息
                    string msgUrl  = ConfigurationManager.AppSettings["push_weixin_msg_url"].Trim();
                    string msgText = string.Format(msgModel, tmpIntegralValue, vipEntity.Integration);
                    string msgData = "<xml><OpenID><![CDATA[" + tmpOpenId + "]]></OpenID><Content><![CDATA[" + msgText + "]]></Content></xml>";

                    var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData);
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("PushMsgResult:{0}", msgResult)
                    });

                    respData.Data = tmpIntegralValue.ToString();
                }
                #endregion
            }
            catch (Exception ex)
            {
                respData.Code        = "103";
                respData.Description = "数据库操作错误";
                respData.Exception   = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }
示例#15
0
        public VipEntity GetUserIdByOpenId(LoggingSessionInfo loggingSessionInfo, string OpenId)
        {
            VipEntity vipInfo = new VipEntity();

            try
            {
                string        vipId         = string.Empty;
                string        status        = "0";
                VipBLL        server        = new VipBLL(loggingSessionInfo);
                WXUserInfoBLL wxUserInfoBLL = new WXUserInfoBLL(loggingSessionInfo);
                //var vipObjs = server.QueryByEntityAbsolute(new VipEntity
                //{
                //    WeiXinUserId = OpenId
                //}, null);
                var vipObjs = server.QueryByEntity(new VipEntity   //先从会员表里取
                {
                    WeiXinUserId = OpenId,
                    ClientID     = loggingSessionInfo.ClientID
                }, null);

                if (vipObjs == null || vipObjs.Length == 0 || vipObjs[0] == null)//找不到会员信息
                {
                    //优先从支持多号运营的表中取
                    var wxUserInfo = wxUserInfoBLL.QueryByEntity(new WXUserInfoEntity()
                    {
                        CustomerID = loggingSessionInfo.ClientID, WeiXinUserID = OpenId
                    }, null).FirstOrDefault();
                    if (wxUserInfo != null)
                    {
                        var vipEntity = server.QueryByEntity(new VipEntity()
                        {
                            ClientID = loggingSessionInfo.ClientID, UnionID = wxUserInfo.UnionID
                        }, null).FirstOrDefault();                                                                                                                            //从会员表里取
                        if (vipEntity != null)
                        {
                            vipId   = vipEntity.VIPID;
                            status  = vipEntity.Status.ToString();
                            vipInfo = vipEntity;
                        }
                        else
                        {
                            vipInfo = null;
                        }
                    }
                    else
                    {
                        //请求获取用户信息
                        //Jermyn20130911 从总部导入vip信息
                        bool bReturn  = server.GetVipInfoFromApByOpenId(OpenId, null);
                        var  vipObjs1 = server.QueryByEntityAbsolute(new VipEntity
                        {
                            WeiXinUserId = OpenId
                        }, null);
                        if (vipObjs1 == null || vipObjs1.Length == 0 || vipObjs1[0] == null)
                        {
                            vipInfo = null;
                        }
                        else
                        {
                            vipId   = vipObjs1[0].VIPID;
                            status  = vipObjs1[0].Status.ToString();
                            vipInfo = vipObjs1[0];
                        }
                    }
                }
                else  //查到会员信息了
                {
                    vipId   = vipObjs[0].VIPID;
                    status  = vipObjs[0].Status.ToString();
                    vipInfo = vipObjs[0];
                    //获取UnionID
                    if (string.IsNullOrEmpty(vipInfo.UnionID))
                    {
                        var vipService  = new VipBLL(loggingSessionInfo);
                        var vipEntity   = new VipEntity();
                        var commonBll   = new CommonBLL();
                        var application = new WApplicationInterfaceDAO(loggingSessionInfo);
                        var appEntity   = application.QueryByEntity(new WApplicationInterfaceEntity()
                        {
                            WeiXinID = vipInfo.WeiXin, CustomerId = loggingSessionInfo.ClientID
                        }, null).FirstOrDefault();
                        if (appEntity != null)
                        {
                            //获取调用微信接口的凭证(普通的获取accestoken的地方)
                            var accessToken = commonBll.GetAccessTokenByCache(appEntity.AppID, appEntity.AppSecret, loggingSessionInfo);
                            //通过openID获取用户信息
                            //  (这种情况下,因为已经有会员信息了,并且已经关注了,才能获取到会员信息)
                            var userInfo = commonBll.GetUserInfo(accessToken.access_token, vipInfo.WeiXinUserId);
                            if (!string.IsNullOrEmpty(userInfo.unionid))
                            {
                                var vipEntitys = vipService.QueryByEntity(new VipEntity {
                                    UnionID = userInfo.unionid, ClientID = loggingSessionInfo.ClientID
                                }, null);
                                if (vipEntitys != null && vipEntitys.Length > 0)//已经存在有UnionID的数据
                                {
                                    var wxUserInfo = wxUserInfoBLL.QueryByEntity(new WXUserInfoEntity()
                                    {
                                        CustomerID = loggingSessionInfo.ClientID, VipID = vipEntitys[0].VIPID, WeiXinUserID = OpenId, UnionID = userInfo.unionid
                                    }, null).FirstOrDefault();
                                    if (wxUserInfo == null)
                                    {
                                        var wxuiEntity = new WXUserInfoEntity()
                                        {
                                            WXUserID     = Guid.NewGuid(),
                                            VipID        = vipEntitys[0].VIPID,//vipInfo.VIPID,
                                            WeiXin       = vipInfo.WeiXin,
                                            WeiXinUserID = vipInfo.WeiXinUserId,
                                            UnionID      = userInfo.unionid,
                                            CustomerID   = vipInfo.ClientID,
                                            CreateBy     = "auth",
                                            LastUpdateBy = "auth"
                                        };
                                        wxUserInfoBLL.Create(wxuiEntity);
                                    }

                                    //删除冗余vip记录
                                    vipInfo.LastUpdateBy = "auth-delete";
                                    vipService.Delete(vipInfo);
                                }
                                else
                                {
                                    //更新微信用户信息
                                    vipInfo.VipName    = userInfo.nickname;
                                    vipInfo.City       = userInfo.city;
                                    vipInfo.Gender     = Convert.ToInt32(userInfo.sex);
                                    vipInfo.HeadImgUrl = userInfo.headimgurl;
                                    vipInfo.UnionID    = userInfo.unionid;
                                    server.Update(vipInfo);
                                }
                            }
                        }
                    }
                }
                return(vipInfo);
            }
            catch (Exception ex)
            {
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("GetUserIdByOpenId用户用户信息出错: {0}", ex.ToString())
                });
                //Response.Write("GetUserIdByOpenId用户用户信息出错:" + ex.ToString());
                return(vipInfo);
            }
        }
示例#16
0
        /// <summary>
        /// 处理文本消息 Jermyn20140512
        /// </summary>
        public virtual void HandlerText()
        {
            var content    = requestParams.XmlNode.SelectSingleNode("//Content").InnerText.Trim(); //文本消息内容
            var weixinId   = requestParams.WeixinId;
            var keywordDAO = new WKeywordReplyDAO(requestParams.LoggingSessionInfo);
            //var ds = keywordDAO.GetMaterialByKeyword(content);
            var ds          = keywordDAO.GetMaterialByKeywordJermyn(content, weixinId, 1);
            int keywordType = 1;

            #region 如果没有关键字回复,给予自动回复内容

            if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                ds          = keywordDAO.GetMaterialByKeywordJermyn(content, weixinId, 3);
                keywordType = 3;
            }

            #endregion

            #region 如果回复,调用老的接口

            if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                HandlerTextOld();
                return;//执行 完老的发送信息的方法,就直接跳出请去,不往下走了****
            }

            #endregion

            //#region 复星临时代码  以后需要删除  qianzhi  2014-01-16

            ////复星临时代码  以后需要删除  qianzhi  2014-01-16
            //if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            //{
            //    ds = keywordDAO.GetMaterialByKeyword("任意回复");
            //}

            //#endregion

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                string Text    = ds.Tables[0].Rows[0]["Text"].ToString();      //素材类型
                string ReplyId = ds.Tables[0].Rows[0]["ReplyId"].ToString();   //素材ID
                string typeId  = ds.Tables[0].Rows[0]["ReplyType"].ToString(); //素材ID

                BaseService.WriteLogWeixin("ReplyId:" + ReplyId);
                BaseService.WriteLogWeixin("typeId:" + typeId);

                switch (typeId)
                {
                case MaterialType.TEXT:             //回复文字消息
                    //ReplyText(materialId);
                    ReplyTextJermyn(Text);
                    break;

                case MaterialType.IMAGE_TEXT:       //回复图文消息
                    //ReplyNews(materialId);
                    ReplyNewsJermyn(ReplyId, keywordType, 1);
                    break;

                default:
                    break;
                }
            }
            else
            {
                //推送客服消息  qianzhi  2014-03-04
                VipBLL vipService = new VipBLL(requestParams.LoggingSessionInfo);
                var    vipList    = vipService.QueryByEntity(new VipEntity
                {
                    WeiXinUserId = requestParams.OpenId,
                    WeiXin       = requestParams.WeixinId
                }, null);

                if (vipList != null && vipList.Length > 0)
                {
                    var vipEntity          = vipList.FirstOrDefault();
                    CSInvokeMessageBLL msg = new CSInvokeMessageBLL(requestParams.LoggingSessionInfo);
                    msg.SendMessage(1, vipEntity.VIPID, 0, null, content, null, null, null, 1);
                }
            }
        }
示例#17
0
        public void GetUserIdByOpenId(string OpenId)
        {
            try
            {
                Response.Write("<br/>");
                //Response.Write("获取用户标识");
                string vipId   = string.Empty;
                VipBLL server  = new VipBLL(loggingSessionInfo);
                var    vipObjs = server.QueryByEntity(new VipEntity
                {
                    WeiXinUserId = OpenId
                }, null);
                if (vipObjs == null || vipObjs.Length == 0)
                {
                    //请求获取用户信息
                    //Jermyn20130911 从总部导入vip信息
                    bool bReturn  = server.GetVipInfoFromApByOpenId(OpenId, null);
                    var  vipObjs1 = server.QueryByEntity(new VipEntity
                    {
                        WeiXinUserId = OpenId
                    }, null);
                    if (vipObjs1 == null || vipObjs1.Length == 0)
                    {
                        vipId = vipObjs1[0].VIPID;
                    }
                    else
                    {
                        Response.Write("系统找不到你关注公众号的记录,请尝试取消关注公众号,然后重新关注该公众号!</br>给您带来不便,尽请谅解,谢谢!");
                        Response.End();
                    }
                }
                else
                {
                    vipId = vipObjs[0].VIPID;
                }
                Response.Write("vipId:" + vipId);
                Response.Write("<br/>");
                //goUrl = "http://" + HttpUtility.UrlDecode(goUrl) + "?customerId=" + customerId + "&userId=" + vipId + "&openId=" + OpenId + "";
                goUrl = "http://" + HttpUtility.UrlDecode(goUrl) + "";
                if (goUrl.IndexOf("lj/register.html") > 0)
                {
                    goUrl = goUrl.Replace("lj/register.html", "HtmlApps/auth.html?pageName=Register&eventId=BFC41A8BF8564B6DB76AE8A8E43557BA");
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("[OAuthWX.aspx]url替换:old={0};new={1};", "lj/register.html?customerId=e703dbedadd943abacf864531decdac1", "HtmlApps/auth.html?pageName=Register&eventId=BFC41A8BF8564B6DB76AE8A8E43557BA")
                    });
                }
                string strGotoUrl = string.Empty;
                if (goUrl.IndexOf("Fuxing") > 0 || goUrl.IndexOf("HtmlApp") > 0)
                {
                    if (goUrl.IndexOf("?") > 0)
                    {
                        strGotoUrl = goUrl + "&customerId=" + customerId + "&openId=" + OpenId + "&userId=" + vipId + "";//&backUrl=" + HttpUtility.UrlEncode(goUrl) + "
                    }
                    else
                    {
                        strGotoUrl = goUrl + "?customerId=" + customerId + "&openId=" + OpenId + "&userId=" + vipId + "";//&backUrl=" + HttpUtility.UrlEncode(goUrl) + "
                    }
                }
                else
                {
                    if (goUrl.IndexOf("20131217") > 0)
                    {
                        strGotoUrl = "/OnlineClothing20131217/go.htm?customerId=" + customerId + "&openId=" + OpenId + "&userId=" + vipId + "&backUrl=" + HttpUtility.UrlEncode(goUrl) + "";
                    }
                    else
                    {
                        strGotoUrl = "/OnlineClothing/go.htm?customerId=" + customerId + "&openId=" + OpenId + "&userId=" + vipId + "&backUrl=" + HttpUtility.UrlEncode(goUrl) + "";
                    }
                }
                //Response.Write(goUrl);
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("GetUserIdByOpenId: strGotoUrl = {0}", strGotoUrl)
                });
                Response.Redirect(strGotoUrl, false);
            }
            catch (Exception ex) {
                Loggers.Exception(new ExceptionLogInfo()
                {
                    ErrorMessage = string.Format("GetUserIdByOpenId用户用户信息出错: {0}", ex.ToString())
                });

                Response.Write("向o2omarketing平台请求用户信息出错,请联系管理员尽快处理.");
                Response.End();
            }
        }
示例#18
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetSharePersonLogRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var t_LEventsSharePersonLogBLL = new T_LEventsSharePersonLogBLL(CurrentUserInfo);
            var SharePersonLogEntity       = new T_LEventsSharePersonLogEntity();//通用分享实体实例化

            SharePersonLogEntity.SharePersonLogId = Guid.NewGuid();
            string objectType = string.Empty;

            if (!string.IsNullOrEmpty(para.ToolType))//para.ToolType.ToLower() == "material"
            {
                objectType = para.ToolType;
                switch (para.ToolType.ToLower())
                {
                case "ctw":
                    para.ToolType = "CTW";
                    break;

                case "coupon":
                    para.ToolType = "Coupon";
                    break;

                case "setoffposter":
                    para.ToolType = "SetoffPoster";
                    break;

                case "goods":
                    para.ToolType = "Goods";
                    break;

                case "material":
                    para.ToolType = "SuperRetailTraderFToT";
                    break;

                default:
                    para.ToolType = "SuperRetailTraderFToT";
                    break;
                }
            }
            SharePersonLogEntity.BusTypeCode = para.ToolType;
            SharePersonLogEntity.ObjectId    = para.ObjectID;
            if (string.IsNullOrEmpty(para.ShareVipType))
            {
                para.ShareVipType = "4";
            }
            SharePersonLogEntity.ShareVipType = Convert.ToInt32(para.ShareVipType);
            SharePersonLogEntity.ShareVipID   = CurrentUserInfo.CurrentUser.User_Id;
            var vipbll  = new VipBLL(CurrentUserInfo);
            var vipInfo = vipbll.QueryByEntity(new VipEntity()
            {
                VIPID = CurrentUserInfo.CurrentUser.User_Id
            }, null).FirstOrDefault();

            if (vipInfo != null && !string.IsNullOrEmpty(vipInfo.VIPID))
            {
                SharePersonLogEntity.ShareOpenID = vipInfo.WeiXinUserId;
            }
            SharePersonLogEntity.BeShareVipID = "1";
            SharePersonLogEntity.CreateTime   = System.DateTime.Now;
            SharePersonLogEntity.CreateBy     = CurrentUserInfo.CurrentUser.User_Id;
            SharePersonLogEntity.CustomerId   = CurrentUserInfo.CurrentUser.customer_id;
            SharePersonLogEntity.IsDelete     = 0;
            t_LEventsSharePersonLogBLL.Create(SharePersonLogEntity);
            var setoffToolUserViewBLL = new SetoffToolUserViewBLL(CurrentUserInfo);
            var setOffToolInfo        = new SetoffToolsBLL(CurrentUserInfo).QueryByEntity(new SetoffToolsEntity()
            {
                SetoffToolID = new Guid(para.SetOffToolID)
            }, null).FirstOrDefault();
            var UserViewData = setoffToolUserViewBLL.QueryByEntity(new SetoffToolUserViewEntity()
            {
                ObjectId = para.ObjectID, UserID = CurrentUserInfo.CurrentUser.User_Id
            }, null);

            if (!string.IsNullOrEmpty(para.ObjectID))
            {
                UserViewData = setoffToolUserViewBLL.QueryByEntity(new SetoffToolUserViewEntity()
                {
                    ObjectId = para.ObjectID, UserID = CurrentUserInfo.CurrentUser.User_Id, SetoffToolID = new Guid(para.ObjectID)
                }, null);
            }
            //如果不存在已读数据则在推送之前 进行已读数据入库
            if (UserViewData.Length == 0 && !string.IsNullOrEmpty(para.ObjectID) && setOffToolInfo != null)
            {
                var SetoffToolUserView = new SetoffToolUserViewEntity();
                SetoffToolUserView.SetoffToolUserViewID = Guid.NewGuid();
                SetoffToolUserView.SetoffEventID        = setOffToolInfo.SetoffEventID;
                SetoffToolUserView.ObjectId             = para.ObjectID;
                SetoffToolUserView.SetoffToolID         = new Guid(para.SetOffToolID);
                SetoffToolUserView.ToolType             = objectType;
                SetoffToolUserView.NoticePlatformType   = 3;
                SetoffToolUserView.UserID         = CurrentUserInfo.CurrentUser.User_Id;
                SetoffToolUserView.IsOpen         = 1;
                SetoffToolUserView.OpenTime       = System.DateTime.Now;
                SetoffToolUserView.CustomerId     = CurrentUserInfo.CurrentUser.customer_id;
                SetoffToolUserView.CreateTime     = System.DateTime.Now;
                SetoffToolUserView.CreateBy       = CurrentUserInfo.CurrentUser.User_Id;
                SetoffToolUserView.LastUpdateTime = System.DateTime.Now;
                SetoffToolUserView.LastUpdateBy   = CurrentUserInfo.CurrentUser.User_Id;
                SetoffToolUserView.IsDelete       = 0;
                setoffToolUserViewBLL.Create(SetoffToolUserView);
            }
            return(rd);
        }
示例#19
0
        /// <summary>
        /// 获取图片与评论信息
        /// </summary>
        public string GetImageComment()
        {
            string content  = string.Empty;
            var    respData = new GetImageCommentRespData();

            try
            {
                string openId = Request["openID"];
                string id     = Request["id"];

                //openId = "o8Y7Ejl1zl5RHXDvPONCNqoC5Md8";
                //id = "1";

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format(
                        "openId:{0}, id:{1}", openId, id)
                });

                var currentUser = Default.GetLoggingSession();

                VipBLL             vipBLL             = new VipBLL(currentUser);
                VIPImageCommentBLL vipImageCommentBLL = new VIPImageCommentBLL(currentUser);

                string vipId = null;
                if (true)
                {
                    VipEntity vipIdData     = null;
                    var       vipIdDataList = vipBLL.QueryByEntity(new VipEntity()
                    {
                        WeiXinUserId = openId
                    }, null);
                    if (vipIdDataList == null || vipIdDataList.Length == 0 || vipIdDataList[0] == null ||
                        vipIdDataList[0].VIPID == null)
                    {
                        respData.Code        = "103";
                        respData.Description = "数据库操作错误";
                        respData.Exception   = "未查询到Vip会员";
                        return(respData.ToJSON());
                    }
                    else
                    {
                        vipIdData = vipIdDataList[0];
                        vipId     = vipIdData.VIPID;
                    }
                }

                VIPImageCommentEntity vipImageCommentData = null;
                var vipImageCommentDataList = vipImageCommentBLL.QueryByEntity(new VIPImageCommentEntity()
                {
                    VipImageCommentID = id
                }, null);
                if (vipImageCommentDataList == null || vipImageCommentDataList.Length == 0 || vipImageCommentDataList[0] == null)
                {
                    respData.Code        = "103";
                    respData.Description = "数据库操作错误";
                    respData.Exception   = "未查询到数据";
                    return(respData.ToJSON());
                }
                else
                {
                    vipImageCommentData = vipImageCommentDataList[0];

                    respData.Content          = new GetImageCommentContentRespData();
                    respData.Content.ImageUrl = vipImageCommentData.ImageURL;
                    respData.Content.Comment  = vipImageCommentData.Comment;
                }
            }
            catch (Exception ex)
            {
                respData.Code        = "103";
                respData.Description = "数据库操作错误";
                respData.Exception   = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }
示例#20
0
        public static bool Send(string customerId, string pPhone, string pContent, string pSign, out string msg)
        {
            try
            {
                string url             = ConfigurationManager.AppSettings["SMSURL"];
                var    currentUserInfo = Default.GetBSLoggingSession(customerId, "1");
                if (string.IsNullOrEmpty(url))
                {
                    throw new Exception("未配置短信服务URL");
                }
                //var para = new { MobileNO = pPhone, SMSContent = string.Format(@"您的验证码是:【{0}】", pContent), Sign = pSign };
                string str = "";

                var para    = new { MobileNO = pPhone, SMSContent = pContent, Sign = pSign };
                var request = new { Action = "SendMessage", Parameters = para };
                str = string.Format("request={0}", request.ToJSON());//请求参数


                //var para = new { MobileNO = pPhone, SMSContent = string.Format(@"您的验证码是:{1},请不要把验证码泄露给其他人。", currentUserInfo.ClientName, pContent), Sign = pSign };
                //var request = new { Action = "SendMessage", Parameters = para };
                //string str = string.Format("request={0}", request.ToJSON());//请求参数


                Loggers.Debug(new DebugLogInfo()
                {
                    Message = "发送短信:" + str
                });
                var res = HttpClient.PostQueryString(url, str);    //发送请求,开始发送短信

                var response = res.DeserializeJSONTo <Response>(); //解析发送短信后,返回的内容
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = "收到返回信息:" + response.ToJSON()
                });


                //var currentUserInfo = Default.GetBSLoggingSession(customerId, "1");//放到方法头使用
                var vipBll = new VipBLL(currentUserInfo);

                var vipEntity = vipBll.QueryByEntity(new VipEntity()
                {
                    Phone = pPhone
                }, null);
                string vipId = Common.Utils.NewGuid();
                if (vipEntity != null && vipEntity.Length > 0)
                {
                    vipId = vipEntity[0].VIPID;
                }

                (new MarketSendLogBLL(currentUserInfo)).Create(new MarketSendLogEntity()
                {
                    LogId           = Common.Utils.NewGuid(),
                    VipId           = vipId,
                    MarketEventId   = vipId,
                    TemplateContent = response.ToJSON(),
                    SendTypeId      = "1",
                    Phone           = pPhone,
                    IsSuccess       = response.ResultCode < 100 ? 1 : 0
                });

                if (response.ResultCode < 100)
                {
                    msg = "短信发送成功";
                    return(true);
                }
                else
                {
                    msg = "短信发送失败:" + response.Message;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Loggers.Exception(new ExceptionLogInfo(ex));
                msg = ex.Message;
                return(false);
            }
        }
示例#21
0
        protected override GetOrderDetailRD ProcessRequest(DTO.Base.APIRequest <GetOrderDetailRP> pRequest)
        {
            GetOrderDetailRD rd      = new GetOrderDetailRD();
            string           orderId = pRequest.Parameters.OrderId;

            rd.OrderListInfo = new OrderListInfo();

            #region 获取订单列表

            T_InoutBLL orderBll  = new T_InoutBLL(this.CurrentUserInfo);
            var        orderList = orderBll.QueryByEntity(new T_InoutEntity()
            {
                order_id = orderId
            }, null);

            #endregion

            #region 获取会员信息

            string vipNo  = orderList[0].vip_no;
            VipBLL vipBll = new VipBLL(this.CurrentUserInfo);

            var vipList = vipBll.QueryByEntity(new VipEntity()
            {
                VIPID = vipNo
            }, null);

            #endregion

            #region 获取配方式

            //Bear 20160928 注释 更具商品信息获取对应配送
            string deliveryId = orderList[0].Field8;


            DeliveryBLL deliverBll = new DeliveryBLL(this.CurrentUserInfo);

            var deliverList = deliverBll.QueryByEntity(new DeliveryEntity()
            {
                DeliveryId = deliveryId
            }, null);



            #endregion

            #region 获取门店信息

            string storeId = orderList[0].sales_unit_id;
            if (!string.IsNullOrEmpty(orderList[0].purchase_unit_id))//如果有发货门店,则显示发货门店信息
            {
                storeId = orderList[0].purchase_unit_id;
            }
            TInoutBLL tInoutBll = new TInoutBLL(this.CurrentUserInfo);
            //string storeName = tInoutBll.GetStoreName(storeId);
            DataSet storeDs = tInoutBll.GetStoreInfo(storeId);
            rd.OrderListInfo.StoreID = storeId;

            #endregion

            //配送商
            string carrierId = orderList[0].carrier_id;

            //DataSet carrierDs = tInoutBll.GetStoreInfo(carrierId);
            //if (carrierDs.Tables[0].Rows.Count > 0)
            //{
            //    rd.OrderListInfo.CarrierID = carrierId;
            //    rd.OrderListInfo.CarrierName = carrierDs.Tables[0].Rows[0]["unit_name"].ToString();
            //}
            if (!string.IsNullOrEmpty(carrierId))
            {
                //配送方式 1.送货到家;2.到店提货
                if (deliveryId == "1")
                {
                    var  logisticsCompanyBLL = new T_LogisticsCompanyBLL(this.CurrentUserInfo);
                    Guid m_carrierId         = Guid.Parse(carrierId);
                    var  logCompInfo         = logisticsCompanyBLL.GetByID(m_carrierId);
                    if (logCompInfo != null)
                    {
                        rd.OrderListInfo.CarrierID   = carrierId;
                        rd.OrderListInfo.CarrierName = logCompInfo.LogisticsName;
                    }
                }
                else if (deliveryId == "2")
                {
                    var unitBLL  = new t_unitBLL(this.CurrentUserInfo);
                    var unitInfo = unitBLL.GetByID(carrierId);
                    if (unitInfo != null)
                    {
                        rd.OrderListInfo.CarrierID   = carrierId;
                        rd.OrderListInfo.CarrierName = unitInfo.unit_name;
                    }
                }
                else if (deliveryId == "4")
                {
                    var unitBLL  = new t_unitBLL(this.CurrentUserInfo);
                    var unitInfo = unitBLL.GetByID(carrierId);
                    if (unitInfo != null)
                    {
                        rd.OrderListInfo.CarrierID   = carrierId;
                        rd.OrderListInfo.CarrierName = unitInfo.unit_name;
                    }
                }
            }
            rd.OrderListInfo.CourierNumber = orderList[0].Field2;                                      //配送单号
            rd.OrderListInfo.Invoice       = orderList[0].Field19 == null ? "" : orderList[0].Field19; //发票信息
            if (vipList.Count() > 0)
            {
                rd.OrderListInfo.VipID        = vipList[0].VIPID;
                rd.OrderListInfo.Phone        = vipList[0].Phone;
                rd.OrderListInfo.UserName     = vipList[0].VipName;
                rd.OrderListInfo.VipRealName  = vipList[0].VipRealName;
                rd.OrderListInfo.VipLevelDesc = vipList[0].VipLevelDesc;
                rd.OrderListInfo.VipCode      = vipList[0].VipCode;
                rd.OrderListInfo.Email        = vipList[0].Email;
                rd.OrderListInfo.VipLevel     = Convert.ToInt32(vipList[0].VipLevel);
            }

            if (storeDs.Tables[0].Rows.Count > 0)
            {
                rd.OrderListInfo.StoreName    = storeDs.Tables[0].Rows[0]["unit_name"].ToString();
                rd.OrderListInfo.StoreAddress = storeDs.Tables[0].Rows[0]["unit_address"].ToString();
                rd.OrderListInfo.StoreTel     = storeDs.Tables[0].Rows[0]["unit_tel"].ToString();
            }

            if (orderList.Count() > 0)
            {
                rd.OrderListInfo.discount_rate = orderList[0].discount_rate ?? 100;//订单折扣
                rd.OrderListInfo.OrderID       = orderList[0].order_id;
                rd.OrderListInfo.OrderCode     = orderList[0].order_no;
                rd.OrderListInfo.OrderDate     = orderList[0].order_date;
                rd.OrderListInfo.ReceiverName  = orderList[0].Field14; //收件人
                rd.OrderListInfo.TotalQty      = Convert.ToDecimal(orderList[0].total_qty);

                string TotalAmount = String.Format("{0:F}", orderList[0].total_amount ?? 0);

                rd.OrderListInfo.TotalAmount = TotalAmount;

                rd.OrderListInfo.Total_Retail      = Convert.ToDecimal(orderList[0].total_retail);
                rd.OrderListInfo.Remark            = orderList[0].remark;
                rd.OrderListInfo.Status            = orderList[0].status;
                rd.OrderListInfo.OrderStatus       = int.Parse(orderList[0].Field7);
                rd.OrderListInfo.StatusDesc        = orderList[0].status_desc;
                rd.OrderListInfo.DeliveryAddress   = orderList[0].Field4;
                rd.OrderListInfo.DeliveryTime      = orderList[0].Field9;
                rd.OrderListInfo.ClinchTime        = orderList[0].create_time;
                rd.OrderListInfo.ReceiptTime       = orderList[0].accpect_time;
                rd.OrderListInfo.CouponsPrompt     = orderList[0].Field16;
                rd.OrderListInfo.DeliveryID        = orderList[0].Field8;
                rd.OrderListInfo.IsPayment         = orderList[0].Field1;
                rd.OrderListInfo.ReceivePoints     = orderList[0].receive_points;
                rd.OrderListInfo.PaymentTime       = orderList[0].Field1 == "1" ? orderList[0].complete_date : null;
                rd.OrderListInfo.OrderReasonTypeId = orderList[0].order_reason_id;
                rd.OrderListInfo.ActualDecimal     = orderList[0].actual_amount ?? 0;



                rd.OrderListInfo.PaymentTypeCode = orderList[0].Payment_Type_Code;
                rd.OrderListInfo.PaymentTypeName = orderList[0].Payment_Type_Name;

                rd.OrderListInfo.ReserveTime = orderList[0].reserveDay + " " + orderList[0].reserveQuantum;

                var deliveryBll = new TOrderCustomerDeliveryStrategyMappingBLL(this.CurrentUserInfo);
                rd.OrderListInfo.DeliveryAmount = deliveryBll.GetDeliverAmount(orderId);        //配送费 add by henry***

                if (!string.IsNullOrEmpty(orderList[0].Field15) && orderList[0].Field15 != "0") //是否是团购商品 add by Henry 2014-12-22
                {
                    rd.OrderListInfo.IsEvent = 1;                                               //团购商品
                }
                else
                {
                    rd.OrderListInfo.IsEvent = 0;   //普通商品
                }
                #region update by changjian.tian

                rd.OrderListInfo.Mobile         = orderList[0].Field6; //配送联系电话
                rd.OrderListInfo.DeliveryRemark = orderList[0].remark;

                rd.OrderListInfo.IsEvaluation = orderList[0].IsEvaluation == null ? 0 : orderList[0].IsEvaluation.Value;//评论
                #endregion
            }

            if (deliverList.Count() > 0)
            {
                rd.OrderListInfo.DeliveryName = deliverList[0].DeliveryName;
            }


            T_Inout_DetailBLL orderDetailBll = new T_Inout_DetailBLL(this.CurrentUserInfo);
            //退换货Bll实例化
            T_SalesReturnBLL salesReturnBll = new T_SalesReturnBLL(this.CurrentUserInfo);

            var orderDetailList = orderDetailBll.QueryByEntity(new T_Inout_DetailEntity()
            {
                order_id = orderId
            }, null);

            var inoutService = new InoutService(this.CurrentUserInfo);

            #region 根据订单ID获取订单明细

            var ds = inoutService.GetOrderDetailByOrderId(orderId);

            #endregion

            #region 获取订单详细列表中的商品规格

            var ggDs = inoutService.GetInoutDetailGgByOrderId(orderId);

            #endregion

            if (ds.Tables[0].Rows.Count > 0)
            {
                string ItemIdList =
                    ds.Tables[0].AsEnumerable().Aggregate("", (x, j) =>
                {
                    x += string.Format("'{0}',", j["item_id"].ToString());
                    return(x);
                }).Trim(',');

                TInoutDetailBLL tInoutDetailBll = new TInoutDetailBLL(this.CurrentUserInfo);
                //获取商品的图片
                DataSet imageDs = tInoutDetailBll.GetOrderDetailImageList(ItemIdList);



                var tmp = ds.Tables[0].AsEnumerable().Select(t => new OrderDetailEntity()
                {
                    ItemID          = t["item_id"].ToString(),
                    ItemName        = t["item_name"].ToString(),
                    SkuID           = t["sku_id"].ToString(),
                    SalesReturnFlag = salesReturnBll.CheckSalesReturn(orderId, t["sku_id"].ToString()),//是否可申请退换货
                    //GG = t["prop_1_detail_name"].ToString()+t["prop_2_detail_name"].ToString()+t["prop_3_detail_name"].ToString()
                    //+t["prop_4_detail_name"].ToString()+t["prop_5_detail_name"].ToString(),
                    Field9 = t["Field9"].ToString(),
                    isGB   = Convert.ToInt32(t["isGB"]),
                    GG     =
                        ggDs.Tables[0].AsEnumerable()
                        .Where(tt => tt["sku_id"].ToString() == t["sku_id"].ToString())
                        .Select(tt => new GuiGeInfo
                    {
                        PropName1       = tt["prop_1_name"].ToString(),
                        PropDetailName1 = tt["prop_1_detail_name"].ToString(),
                        PropName2       = tt["prop_2_name"].ToString(),
                        PropDetailName2 = tt["prop_2_detail_name"].ToString(),
                        PropName3       = tt["prop_3_name"].ToString(),
                        PropDetailName3 = tt["prop_3_detail_name"].ToString(),
                        PropName4       = tt["prop_4_name"].ToString(),
                        PropDetailName4 = tt["prop_4_detail_name"].ToString(),
                        PropName5       = tt["prop_5_name"].ToString(),
                        PropDetailName5 = tt["prop_5_detail_name"].ToString()
                    }).FirstOrDefault(),
                    SalesPrice = Convert.ToDecimal(t["enter_price"]),
                    //DiscountRate = Convert.ToDecimal(t["discount_rate"]),
                    DiscountRate     = Convert.ToDecimal(t["order_discount_rate"]),
                    ItemCategoryName = t["itemCategoryName"].ToString(),
                    BeginDate        = t["Field1"].ToString(),
                    EndDate          = t["Field2"].ToString(),
                    DayCount         = Convert.ToInt32(t["DayCount"]),
                    Qty       = Convert.ToDecimal(t["enter_qty"]),
                    ImageInfo =
                        imageDs.Tables[0].AsEnumerable()
                        .Where(c => c["ObjectId"].ToString() == t["item_id"].ToString())
                        .OrderBy(c => c["displayIndex"])
                        .Select(c => new OrderDetailImage
                    {
                        ImageID  = c["imageId"].ToString(),
                        ImageUrl = ImagePathUtil.GetImagePathStr(c["imageUrl"].ToString(), "240")
                    }).ToArray(),
                    IfService = Convert.ToInt32(t["IfService"])
                });

                int tempCount = 0;
                foreach (var i in tmp)
                {
                    if (i.IfService == 0)
                    {
                        tempCount++;
                    }
                }
                if (tempCount == 0)
                {
                    rd.OrderListInfo.IsAllService = 3; // 3-全部为虚拟商品
                }
                else if (tempCount == tmp.Count())
                {
                    rd.OrderListInfo.IsAllService = 1; // 1-全部为实物商品
                }
                else
                {
                    rd.OrderListInfo.IsAllService = 2; // 2-包含实物商品和虚拟商品
                }

                #region 根据商品获取配送方式

                var deliveryIds = new List <int?>();
                if (rd.OrderListInfo.IsAllService == 3)
                {
                    deliveryIds.Add(1);
                    deliveryIds.Add(2);
                    deliveryIds.Add(4);
                    rd.OrderListInfo.CanUseDeliveryIDs = deliveryIds;
                }
                else
                {
                    T_Item_Delivery_MappingBLL mappingBll = new T_Item_Delivery_MappingBLL(this.CurrentUserInfo);

                    var complexCondition = new List <IWhereCondition> {
                    };
                    var itemIdArray      = ItemIdList.Replace("'", "").Split(',');
                    complexCondition.Add(new InCondition <string>()
                    {
                        FieldName = "Item_Id", Values = itemIdArray
                    });

                    var itemDeliveryList = mappingBll.Query(complexCondition.ToArray(), null);

                    bool needAddDelivery4 = false;
                    bool needAddDelivery2 = false;
                    if (itemDeliveryList.ToList().Find(d => d.DeliveryId == 4) != null)
                    {
                        needAddDelivery4 = true;
                    }
                    else
                    {
                        if (itemDeliveryList.ToList().Find(d => d.DeliveryId == 2) != null)
                        {
                            needAddDelivery2 = true;
                        }
                    }

                    var itemDeliveryGroupList = itemDeliveryList.GroupBy(d => d.Item_Id);

                    var index = 0;
                    foreach (var info in itemDeliveryGroupList)
                    {
                        var tmpList = info.ToList <T_Item_Delivery_MappingEntity>(); //分组后的集合
                        if (index == 0)
                        {
                            deliveryIds.AddRange(tmpList.Select(d => d.DeliveryId));
                            index++;
                            continue;
                        }
                        deliveryIds = deliveryIds.Intersect(tmpList.Select(d => d.DeliveryId)).ToList();
                        if (deliveryIds.Count <= 0)
                        {
                            break; // 后面的不用求了
                        }
                        index++;
                    }

                    if (!deliveryIds.Contains(4) && needAddDelivery4)
                    {
                        deliveryIds.Add(4);
                    }

                    if (!deliveryIds.Contains(2) && needAddDelivery2)
                    {
                        deliveryIds.Add(2);
                    }

                    rd.OrderListInfo.CanUseDeliveryIDs = deliveryIds.OrderBy(t => t.Value).ToList();
                }

                #endregion

                rd.OrderListInfo.OrderDetailInfo = tmp.ToArray();
            }


            var vipIntegralDetailBll = new VipIntegralDetailBLL(this.CurrentUserInfo);
            // var integral = vipIntegralDetailBll.GetVipIntegralByOrder(orderId, pRequest.UserID);
            //使用积分
            rd.OrderListInfo.OrderIntegral = Math.Abs(vipIntegralDetailBll.GetVipIntegralByOrder(orderId, vipNo));
            //积分抵扣金额 add by Henry 2014-10-8
            //decimal integralAmountPre = vipBll.GetIntegralAmountPre(this.CurrentUserInfo.ClientID);//获取积分金额比例
            //rd.OrderListInfo.UseIntegralToAmount =rd.OrderListInfo.OrderIntegral*(integralAmountPre>0?integralAmountPre:0.01M);
            rd.OrderListInfo.UseIntegralToAmount = vipBll.GetAmountByIntegralPer(CurrentUserInfo.ClientID, rd.OrderListInfo.OrderIntegral);

            var couponUseBll = new CouponUseBLL(this.CurrentUserInfo);

            var couponParValue = couponUseBll.GetCouponParValue(orderId);
            rd.OrderListInfo.CouponAmount = couponParValue;


            var vipAmountDetailBll = new VipAmountDetailBLL(this.CurrentUserInfo);
            //使用的账户余额
            rd.OrderListInfo.VipEndAmount = Math.Abs(vipAmountDetailBll.GetVipAmountByOrderId(orderId, vipNo, 1));
            //使用余额,将余额从实付款中分开
            if (rd.OrderListInfo.VipEndAmount != 0)
            {
                rd.OrderListInfo.ActualDecimal = rd.OrderListInfo.ActualDecimal - rd.OrderListInfo.VipEndAmount;
            }
            //使用的返现金额
            rd.OrderListInfo.ReturnAmount = Math.Abs(vipAmountDetailBll.GetVipAmountByOrderId(orderId, vipNo, 13));
            //使用阿拉币和阿拉币抵扣 add by Henry 2014-10-13
            if (pRequest.ChannelId == "4")//阿拉丁APP调用
            {
                decimal aldAmount = Math.Abs(vipAmountDetailBll.GetVipAmountByOrderId(orderId, vipNo, 11));
                rd.OrderListInfo.ALDAmount      = aldAmount;
                rd.OrderListInfo.ALDAmountMoney = aldAmount * 0.01M;
            }
            #region 获取订单积分,优惠券金额,使用余额


            //var vipIntegralDetailBll = new VipIntegralDetailBLL(this.CurrentUserInfo);

            //var vipIntegralList = vipIntegralDetailBll.QueryByEntity(new VipIntegralDetailEntity()
            //{
            //    VIPID = pRequest.UserID,
            //    ObjectId = orderId
            //}, null);
            //if (vipIntegralList != null && vipIntegralList.Length > 0)
            //{
            //    rd.OrderListInfo.OrderIntegral = Math.Abs(vipIntegralList[0].Integral??0);
            //}

            //var tOrderCouponMappingBll = new TOrderCouponMappingBLL(this.CurrentUserInfo);

            //var tOrderCouponMappingList = tOrderCouponMappingBll.QueryByEntity(new TOrderCouponMappingEntity()
            //{
            //    OrderId = orderId
            //}, null);
            //if (tOrderCouponMappingList != null && tOrderCouponMappingList.Length > 0)
            //{
            //    var couponId = tOrderCouponMappingList[0].CouponId;

            //    var couponBll = new CouponBLL(this.CurrentUserInfo);
            //    var couponEntity = couponBll.GetByID(couponId);

            //    if (couponEntity != null)
            //    {
            //        var couponTypeId = couponEntity.CouponTypeID;

            //        var couponTypeBll = new CouponTypeBLL(this.CurrentUserInfo);
            //        var couponTypeEntity = couponTypeBll.GetByID(couponTypeId);
            //        if (couponTypeEntity != null)
            //        {
            //            rd.OrderListInfo.CouponAmount = couponTypeEntity.ParValue ?? 0;
            //        }
            //    }
            //}
            //var vipAmountDetailBll = new VipAmountDetailBLL(this.CurrentUserInfo);
            //var vipAmountDetailList = vipAmountDetailBll.QueryByEntity(new VipAmountDetailEntity()
            //{
            //    VipId = pRequest.UserID,
            //    ObjectId = orderId
            //}, null);

            //if (vipAmountDetailList != null && vipAmountDetailList.Length > 0)
            //{
            //    rd.OrderListInfo.VipEndAmount = Math.Abs(vipAmountDetailList[0].Amount ?? 0);
            //}

            #endregion
            return(rd);
        }