示例#1
0
        /// <summary>
        /// 获取微信用户信息
        /// </summary>
        /// <param name="dicPar"></param>
        public void GetUserInfo(Dictionary <string, object> dicPar)
        {
            ///要检测的参数信息
            List <string> pra = new List <string>()
            {
                "GUID", "USER_ID"
            };

            //检测方法需要的参数
            if (!CheckActionParameters(dicPar, pra))
            {
                return;
            }

            string GUID    = dicPar["GUID"].ToString();
            string USER_ID = dicPar["USER_ID"].ToString();

            var sql = string.Format(@"declare @mobile varchar(12) set @mobile='';select @mobile=mobile from wx_members_wx where openid='{0}';select isnull(provinceid,'') as proname,isnull(cityid,'') as cityname,isnull(area,'') as areaname,nickname,sex,isnull(Convert(varchar(10),birthday,120),'') as birthday,isnull(addressdetails,'') as addressdetails,isnull(notpwd,'0') as notpwd,isnull(amount,0) as amount,mobile,headimgurl,memcode from WX_members_wx where openid='{0}';select COUNT(ID) from WX_busDestine where tel=@mobile and status in('0','4') union all select COUNT(bwid) from WX_busWait where tel=@mobile and status in('0') union all select COUNT(memid) from WX_orderdetails where openid='{0}' and payType in('0') and status in('0','1') union all select count(id) from wx_cardinfo where openid='{0}' and isecard='0' union all select count(id) from membercoupon where cardcode in (select cardcode from wx_cardinfo where openid='{0}' and status='1') and cid in (select c.cid from coupon c left join N_sumcoupon sc on c.sumcode=sc.sumcode where sc.ctype not in ('2') and c.status in('','0')) union all select COUNT(id) from WX_usermessage where openid='{0}' and status='0' and isdelete='0' union all select COUNT(actId) from WX_Complaints where openid='{0}' and len(opinion)>0 and isread='0' and status='1' and isdelete='0';select cardcode,erqimg from wx_cardinfo where openid='{0}' and isecard='1';", USER_ID);

            DataSet ds = SQLTool.ExecuteDataset(sql);

            if (ds.Tables.Count == 3)
            {
                string jsonStr = "{\"status\":\"0\",\"mes\":\"获取数据成功\",\"data\":[";
                dt = ds.Tables[0];                //用户基本信息
                DataTable dtCount = ds.Tables[1];
                DataTable dtECard = ds.Tables[2]; //电子卡信息
                if (dt != null && dt.Rows.Count > 0)
                {
                    jsonStr += "{\"proname\":\"" + dt.Rows[0]["proname"].ToString() + "\",\"cityname\":\"" + dt.Rows[0]["cityname"].ToString() + "\",\"areaname\":\"" + dt.Rows[0]["areaname"].ToString() + "\",\"nickname\":\"" + dt.Rows[0]["nickname"].ToString() + "\",\"sex\":\"" + dt.Rows[0]["sex"].ToString() + "\",\"birthday\":\"" + dt.Rows[0]["birthday"].ToString() + "\",\"addressdetails\":\"" + dt.Rows[0]["addressdetails"].ToString() + "\",\"notpwd\":\"" + dt.Rows[0]["notpwd"].ToString() + "\",\"amount\":\"" + dt.Rows[0]["amount"].ToString() + "\",\"mobile\":\"" + dt.Rows[0]["mobile"].ToString() + "\",\"headimgurl\":\"" + dt.Rows[0]["headimgurl"].ToString() + "\",\"memcode\":\"" + dt.Rows[0]["memcode"].ToString() + "\"";
                    if (dtCount != null && dtCount.Rows.Count > 0)
                    {
                        jsonStr += ",\"yycount\":\"" + dtCount.Rows[0][0].ToString() + "\",\"pdcount\":\"" + dtCount.Rows[1][0].ToString() + "\",\"dccount\":\"" + dtCount.Rows[2][0].ToString() + "\",\"cardcount\":\"" + dtCount.Rows[3][0].ToString() + "\",\"yhcount\":\"" + dtCount.Rows[4][0].ToString() + "\",\"messcount\":\"" + dtCount.Rows[5][0].ToString() + "\",\"tscount\":\"" + dtCount.Rows[6][0].ToString() + "\"";
                    }
                    else
                    {
                        //(预约记录,排队记录,点餐记录,会员卡数量,优惠券数量,消息数量,投诉建议数量)
                        jsonStr += ",\"yycount\":\"0\",\"pdcount\":\"0\",\"dccount\":\"0\",\"cardcount\":\"0\",\"yhcount\":\"0\",\"messcount\":\"0\",\"tscount\":\"0\"";
                    }

                    if (dtECard != null && dtECard.Rows.Count > 0)
                    {
                        string cardcode = dtECard.Rows[0]["cardcode"].ToString();
                        string erqimg   = dtECard.Rows[0]["erqimg"].ToString();
                        //生成二维码保存
                        if (string.IsNullOrEmpty(erqimg))
                        {
                            erqimg = DoWaitProcess(cardcode);

                            new bllPaging().ExecuteNonQueryBySQL("update wx_cardinfo set erqimg='" + erqimg + "' where openid='" + USER_ID + "' and cardcode='" + cardcode + "' and isecard='1';");
                        }

                        jsonStr += ",\"ecardcode\":\"" + cardcode + "\",\"erqimg\":\"" + imgurl + erqimg + "\"";
                    }

                    jsonStr += "}]}";
                    ToJsonStr(jsonStr);
                }
                else
                {
                    ToCustomerJson("1", "未找到用户信息");
                }
            }
            else
            {
                ToCustomerJson("1", "未找到用户信息");
            }
        }