public ActionResult GetShareQRCode(int id = 0) { CustomPage pageModel = CustomPageBLL.SingleModel.GetModel(id); if (pageModel == null) { return(ApiResult(false, "页面不存在")); } if (!string.IsNullOrEmpty(pageModel.qrcode)) { return(ApiResult(true, pageModel.qrcode)); } string scene = $"{id}"; string postData = JsonConvert.SerializeObject(new { scene = scene, page = "pages/index/pagePreview", width = 210, auto_color = true, line_color = new { r = "0", g = "0", b = "0" } }); string appid = WebConfigurationManager.AppSettings["xiaowei_appid"]; string appsecret = WebConfigurationManager.AppSettings["xiaowei_appsecret"]; string access_token = WxHelper.GetToken(appid, appsecret, false); string errorMessage = ""; string qrCode = CommondHelper.HttpPostSaveImg("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + access_token, postData, ref errorMessage); if (string.IsNullOrEmpty(qrCode)) { return(ApiResult(false, $"获取二维码失败!{errorMessage}")); } pageModel.qrcode = qrCode; CustomPageBLL.SingleModel.Update(pageModel, "qrcode"); return(ApiResult(true, qrCode)); }
/// <summary> /// 发送验证码修改密码 /// </summary> /// <returns></returns> public ActionResult GetVaildCode() { Return_Msg data = new Return_Msg(); string phoneNum = Context.GetRequest("phonenum", ""); //修改密码 type=0 注册type=1 int type = Context.GetRequestInt("type", 0); Account account = AccountBLL.SingleModel.GetModelByPhone(phoneNum); //代理分销,判断是否已开通过代理,开通过代理就不给他开通 int agentqrcodeid = Context.GetRequestInt("agentqrcodeid", 0); if (agentqrcodeid > 0 && account != null) { Agentinfo agentmodel = AgentinfoBLL.SingleModel.GetModelByAccoundId(account.Id.ToString(), -1); if (agentmodel != null) { data.Msg = "该手机号已经绑定了代理商账号"; return(Json(data, JsonRequestBehavior.AllowGet)); } } data = CommondHelper.GetVaildCode(agentqrcodeid, phoneNum, account, type); return(Json(data)); }
/// <summary> /// 获取快速支付码 /// </summary> /// <param name="xcxrelation"></param> /// <param name="platStore"></param> public void GetQuicklyPayQrCode(XcxAppAccountRelation xcxrelation, ref PlatStore platStore) { if (string.IsNullOrEmpty(platStore.SwitchModel.StorePayQrcode)) { string token = ""; if (XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token)) { qrcodeclass qrcodeModel = CommondHelper.GetMiniAppQrcode(token, "pages/home/shop-detail/pay", "", 500); if (!string.IsNullOrEmpty(qrcodeModel.url)) { platStore.SwitchModel.StorePayQrcode = qrcodeModel.url; platStore.SwitchConfig = JsonConvert.SerializeObject(platStore.SwitchModel); base.Update(platStore, "SwitchConfig"); } else { log4net.LogHelper.WriteInfo(this.GetType(), $"生成快速支付码失败:msg:{qrcodeModel.msg},aid:{xcxrelation.Id}"); } } else { log4net.LogHelper.WriteInfo(this.GetType(), $"获取生成快速支付码的token失败:msg:{token},aid:{xcxrelation.Id}"); } } }
public List <CityUserMsg> getListByUserId(int aid, int userId, out int totalCount, int pageSize = 10, int pageIndex = 1, string appId = "") { string strWhere = $"aid={aid} and toUserId={userId}"; base.ExecuteNonQuery($"update CityUserMsg set state=1 where aid={aid} and toUserId={userId}");//将该用户未读消息全部标记为已读 totalCount = base.GetCount(strWhere); OpenAuthorizerConfig openAuthorizerConfig = OpenAuthorizerConfigBLL.SingleModel.GetModelByAppids(appId); List <CityUserMsg> list = base.GetList(strWhere, pageSize, pageIndex, "*", "addTime desc"); string userIds = string.Join(",", list?.Select(s => s.fromUserId).Distinct()); List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds); list.ForEach(x => { //获取用户头像 昵称 C_UserInfo c_UserInfo = userInfoList?.FirstOrDefault(f => f.Id == x.fromUserId); if (c_UserInfo != null) { x.fromUserName = c_UserInfo.NickName; x.fromUseImg = c_UserInfo.HeadImgUrl; } else { x.fromUserName = "******"; x.fromUseImg = openAuthorizerConfig.head_img; } x.addTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.addTime); }); return(list); }
/// <summary> /// 获取店铺列表 /// </summary> /// <returns></returns> public ActionResult GetStoreList(double lat = 0.00, double lng = 0.00) { returnObj = new Return_Msg_APP(); returnObj.code = "200"; string appId = Context.GetRequest("appId", string.Empty); if (string.IsNullOrEmpty(appId)) { returnObj.Msg = "参数错误"; return(Json(returnObj)); } XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId); if (r == null) { returnObj.Msg = "小程序未授权"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } string keyMsg = Utility.IO.Context.GetRequest("keyMsg", string.Empty); int orderType = Utility.IO.Context.GetRequestInt("orderType", 0); //默认为0 1表示按照距离由近到远 2表示默认按照时间降序 int categoryId = Utility.IO.Context.GetRequestInt("categoryId", 0); //默认为0 表示获取所有 其它表示获取某个类别 int pageSize = Utility.IO.Context.GetRequestInt("pageSize", 10); int pageIndex = Utility.IO.Context.GetRequestInt("pageIndex", 1); int isBigType = Utility.IO.Context.GetRequestInt("isBigType", 0); //点击的是否为大类,如果为1则表示点击大类获取其下的小类 int cityCode = Utility.IO.Context.GetRequestInt("cityCode", 0); //哪个地区 默认为0 获取全部地区 //表示按照距离最近的 //表示没有传坐标 通过客户端IP获取经纬度 if (lat == 0 || lng == 0) { string IP = Utility.WebHelper.GetIP(); IPToPoint iPToPoint = CommondHelper.GetLoctionByIP(IP); if (iPToPoint != null) { lat = iPToPoint.result.location.lat; lng = iPToPoint.result.location.lng; //log4net.LogHelper.WriteInfo(this.GetType(), $"IP={IP};{lat},{lng}"); } } int totalCount = 0; List <PlatStore> list = PlatStoreBLL.SingleModel.GetListStore(r.Id, out totalCount, categoryId, keyMsg, lat, lng, cityCode, orderType, pageSize, pageIndex, isBigType, r.AppId); returnObj.dataObj = new { totalCount = totalCount, list = list }; returnObj.isok = true; returnObj.Msg = "获取成功"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 商品一物一码 /// </summary> /// <param name="goodsId">商品ID</param> /// <param name="pageUrl">小程序商品详情页路径</param> /// <param name="type">0:子模板小程序,1:平台版小程序</param> /// <param name="msg"></param> /// <returns></returns> public string GetGoodsCodeUrl(int goodsId, string pageUrl, int type, ref string msg) { PlatChildGoods goods = base.GetModel(goodsId); if (goods == null) { msg = "商品二维码:找不到商品数据"; return(""); } string url = RedisUtil.Get <string>(string.Format(_redis_PlatChildGoodsCodeUrlKey, type, goodsId)); if (!string.IsNullOrEmpty(url)) { return(url); } XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(goods.AId); if (xcxrelation == null || string.IsNullOrEmpty(xcxrelation.AppId)) { msg = "商品二维码:店铺没绑定小程序"; return(""); } string token = ""; if (!XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token)) { msg = token; return(""); } //小程序二维码 string scen = $"goodsId={goodsId}"; qrcodeclass result = CommondHelper.GetMiniAppQrcode(token, pageUrl, scen); if (result != null && result.isok > 0) { url = result.url; if (string.IsNullOrEmpty(url)) { return(""); } url = url.Replace("http:", "https:"); RedisUtil.Set <string>(string.Format(_redis_PlatChildGoodsCodeUrlKey, type, goodsId), url, TimeSpan.FromDays(1)); return(url); } msg = "商品二维码:获取失败"; return(""); }
/// <summary> /// 获取用户收藏帖子列表 /// </summary> /// <param name="aid"></param> /// <param name="userId"></param> /// <param name="totalCount"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <returns></returns> public List <CityMsg> getListMyFavoriteMsg(int aid, int userId, out int totalCount, int pageSize = 10, int pageIndex = 1) { string strWhere = $"f.aid={aid} and f.userId={userId} and f.state=0 and f.actionType=0 and msg.state=1"; string sql = $"select msg.*,f.Id as FavoriteId from CityUserFavoriteMsg f left join CityMsg msg on f.msgId=msg.Id where {strWhere} order by addTime desc LIMIT {(pageIndex - 1) * pageSize},{pageSize}"; totalCount = GetMyFavoriteMsgCount(strWhere); List <CityMsg> listCity_Msg = new List <CityMsg>(); using (var dr = SqlMySql.ExecuteDataReader(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, sql)) { while (dr.Read()) { CityMsg x = CityMsgBLL.SingleModel.GetModel(dr); if (x != null && x.Id > 0) { //获取用户头像 C_UserInfo c_UserInfo = C_UserInfoBLL.SingleModel.GetModel(x.userId); if (c_UserInfo != null) { x.userName = c_UserInfo.NickName; x.userHeaderImg = c_UserInfo.HeadImgUrl; } //获取帖子类别 CityStoreMsgType city_StoreMsgType = CityStoreMsgTypeBLL.SingleModel.GetModel(x.msgTypeId); if (city_StoreMsgType != null) { x.msgTypeName = city_StoreMsgType.name; } //根据帖子ID获取其浏览量-收藏量-分享量数据 CityMsgViewFavoriteShare city_MsgViewFavoriteShare = CityMsgViewFavoriteShareBLL.SingleModel.getModelByMsgId(x.Id); if (city_MsgViewFavoriteShare != null) { x.ViewCount = city_MsgViewFavoriteShare.ViewCount; x.FavoriteCount = city_MsgViewFavoriteShare.FavoriteCount; x.ShareCount = city_MsgViewFavoriteShare.ShareCount; x.DzCount = city_MsgViewFavoriteShare.DzCount; } x.msgDetail = HttpUtility.HtmlDecode(x.msgDetail); x.showTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.addTime); x.FavoriteId = (dr["FavoriteId"] != DBNull.Value?Convert.ToInt32(dr["FavoriteId"]):0);//收藏记录ID listCity_Msg.Add(x); } } } return(listCity_Msg); }
/// <summary> /// 根据用户Id也就是myCardId 获取该用户发布的帖子列表 /// </summary> /// <param name="aid"></param> /// <param name="myCardId"></param> /// <param name="totalCount"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <returns></returns> public List <PlatMsg> GetListByUserId(int aid, int myCardId, out int totalCount, int pageSize = 10, int pageIndex = 1) { string strWhere = $"aid={aid} and state<>-1 and PayState=1 and MyCardId={myCardId}"; List <PlatMsg> listPlatMsg = base.GetList(strWhere, pageSize, pageIndex, "*", " addTime desc"); int commentTotalCount = 0; if (listPlatMsg != null && listPlatMsg.Count > 0) { string cardIds = string.Join(",", listPlatMsg.Select(s => s.MyCardId).Distinct()); List <PlatMyCard> platMyCardList = PlatMyCardBLL.SingleModel.GetListByIds(cardIds); string msgTypeIds = string.Join(",", listPlatMsg.Select(s => s.MsgTypeId).Distinct()); List <PlatMsgType> platMsgTypeList = PlatMsgTypeBLL.SingleModel.GetListByIds(msgTypeIds); listPlatMsg.ForEach(x => { //获取用户头像 PlatMyCard platMyCard = platMyCardList?.FirstOrDefault(f => f.Id == x.MyCardId); if (platMyCard != null) { x.UserName = platMyCard.Name; x.UserHeaderImg = platMyCard.ImgUrl; } //获取帖子类别 PlatMsgType platMsgType = platMsgTypeList?.FirstOrDefault(f => f.Id == x.MsgTypeId); if (platMsgType != null) { x.MsgTypeName = platMsgType.Name; } //根据帖子ID获取其浏览量-收藏量-分享量数据 PlatMsgviewFavoriteShare _platMsgviewFavoriteShare = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(x.Aid, x.Id, (int)PointsDataType.帖子); if (_platMsgviewFavoriteShare != null) { x.ViewCount = _platMsgviewFavoriteShare.ViewCount; x.FavoriteCount = _platMsgviewFavoriteShare.FavoriteCount; x.ShareCount = _platMsgviewFavoriteShare.ShareCount; x.DzCount = _platMsgviewFavoriteShare.DzCount; } x.Comments = PlatMsgCommentBLL.SingleModel.GetPlatMsgComment(x.Aid, out commentTotalCount, 0, string.Empty, 1000, 1, x.Id, 0); x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime); x.MsgDetail = HttpUtility.HtmlDecode(x.MsgDetail); }); } totalCount = base.GetCount(strWhere); return(listPlatMsg); }
/// <summary> /// 获取平台店铺二维码 /// </summary> /// <param name="aid"></param> /// <param name="pageurl"></param> /// <param name="scene"></param> /// <returns></returns> public string GetStoreCode(int storeid, string pageurl, ref string msg) { PlatStore store = base.GetModel(storeid); if (store == null) { msg = "店铺二维码:找不到店铺数据"; return(""); } XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(store.BindPlatAid); if (xcxrelation == null) { msg = "平台店铺二维码:模板过期"; return(""); } XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId); if (xcxTemplate == null) { msg = "无效模板"; return(""); } string token = ""; if (!XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token)) { msg = token; return(""); } //店铺没有开通小程序 //平台小程序二维码 string scen = $"{storeid}"; qrcodeclass qrcodemodel = CommondHelper.GetMiniAppQrcode(token, pageurl, scen); if (qrcodemodel == null || string.IsNullOrEmpty(qrcodemodel.url)) { msg = qrcodemodel != null ? qrcodemodel.msg : "生成名片码失败"; return(""); } return(qrcodemodel.url); }
/// <summary> /// 获取邀请拼团分享小程序码 /// </summary> /// <param name="buid">参团ID</param> /// <param name="AppId"></param> /// <param name="UserId">分享者ID</param> /// <returns></returns> public ActionResult GetShareCutPrice(int guid, string AppId, int UserId) { if (guid <= 0 || string.IsNullOrEmpty(AppId) || UserId <= 0) { return(Json(new { isok = false, msg = "参数错误", JsonRequestBehavior.AllowGet })); } C_UserInfo loginCUser = C_UserInfoBLL.SingleModel.GetModel(UserId); if (loginCUser == null) { return(Json(new { isok = false, msg = "登录过期!", JsonRequestBehavior.AllowGet })); } XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModelByAppid(AppId); if (xcxrelation == null) { return(Json(new { isok = false, msg = "模板权限无效!", JsonRequestBehavior.AllowGet })); } string token = ""; if (!XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token)) { return(Json(new { isok = false, msg = token, JsonRequestBehavior.AllowGet })); } // log4net.LogHelper.WriteInfo(GetType(), r.AppId+"===token:"+access_token); //表示新增 string scene = $"{guid}"; string postData = Newtonsoft.Json.JsonConvert.SerializeObject(new { scene = scene, path = "pages/bargaindetail/bargaindetail", width = 200, auto_color = true, line_color = new { r = "0", g = "0", b = "0" } }); string errorMessage = ""; string qrCode = CommondHelper.HttpPostSaveImg("https://api.weixin.qq.com/wxa/getwxacode?access_token=" + token, postData, ref errorMessage); if (string.IsNullOrEmpty(qrCode)) { return(Json(new { isok = false, msg = $"获取失败!{errorMessage}", JsonRequestBehavior.AllowGet })); } return(Json(new { isok = true, msg = "获取二维码成功!", qrcode = qrCode, JsonRequestBehavior.AllowGet })); }
/// <summary> /// 获取指定帖子详情 包含了 点赞数 分享数 收藏数 浏览量等... /// </summary> /// <param name="aid"></param> /// <param name="msgId"></param> /// <returns></returns> public PlatMsg GetMsg(int aid, int msgId) { PlatMsg x = base.GetModel($"aid={aid} and Id={msgId}"); if (x != null) { //获取用户头像 PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModel(x.MyCardId); if (platMyCard != null) { x.UserName = platMyCard.Name; x.UserHeaderImg = platMyCard.ImgUrl; x.UserId = platMyCard.UserId; } //获取帖子类别 PlatMsgType platMsgType = PlatMsgTypeBLL.SingleModel.GetModel(x.MsgTypeId); if (platMsgType != null) { x.MsgTypeName = platMsgType.Name; } //根据帖子ID获取其浏览量-收藏量-分享量数据 PlatMsgviewFavoriteShare _platMsgviewFavoriteShare = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(x.Aid, x.Id, (int)PointsDataType.帖子); if (_platMsgviewFavoriteShare != null) { x.ViewCount = _platMsgviewFavoriteShare.ViewCount; x.FavoriteCount = _platMsgviewFavoriteShare.FavoriteCount; x.ShareCount = _platMsgviewFavoriteShare.ShareCount; x.DzCount = _platMsgviewFavoriteShare.DzCount; } x.MsgDetail = HttpUtility.HtmlDecode(x.MsgDetail); x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime); } return(x); }
public CityMsg getMsg(int aid, int msgId) { CityMsg x = base.GetModel($"aid={aid} and Id={msgId}"); if (x != null) { //获取用户头像 C_UserInfo c_UserInfo = C_UserInfoBLL.SingleModel.GetModel(x.userId); if (c_UserInfo != null) { x.userName = c_UserInfo.NickName; x.userHeaderImg = c_UserInfo.HeadImgUrl; } //获取帖子类别 CityStoreMsgType city_StoreMsgType = CityStoreMsgTypeBLL.SingleModel.GetModel(x.msgTypeId); if (city_StoreMsgType != null) { x.msgTypeName = city_StoreMsgType.name; } //根据帖子ID获取其浏览量-收藏量-分享量数据 CityMsgViewFavoriteShare city_MsgViewFavoriteShare = CityMsgViewFavoriteShareBLL.SingleModel.getModelByMsgId(x.Id); if (city_MsgViewFavoriteShare != null) { x.ViewCount = city_MsgViewFavoriteShare.ViewCount; x.FavoriteCount = city_MsgViewFavoriteShare.FavoriteCount; x.ShareCount = city_MsgViewFavoriteShare.ShareCount; x.DzCount = city_MsgViewFavoriteShare.DzCount; } x.showTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.addTime); x.msgDetail = HttpUtility.HtmlDecode(x.msgDetail); } return(x); }
public ActionResult SaveUserInfo() { string password = Utility.IO.Context.GetRequest("password", string.Empty); string phone = Utility.IO.Context.GetRequest("phone", string.Empty); string code = Utility.IO.Context.GetRequest("code", string.Empty); string address = Utility.IO.Context.GetRequest("address", string.Empty); string sourcefrom = Utility.IO.Context.GetRequest("sourcefrom", ""); int agentqrcodeid = Utility.IO.Context.GetRequestInt("agentqrcodeid", 0); int opentype = Utility.IO.Context.GetRequestInt("opentype", 0); string username = Utility.IO.Context.GetRequest("username", ""); _msg.isok = false; //if (agentqrcodeid>0 && string.IsNullOrEmpty(username)) //{ // _msg.Msg = "请输入姓名"; // return Json(_msg, JsonRequestBehavior.AllowGet); //} if (string.IsNullOrEmpty(phone)) { _msg.Msg = "请输入手机号"; return(Json(_msg, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(code)) { _msg.Msg = "请输入验证码"; return(Json(_msg, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(password)) { _msg.Msg = "请输入密码"; return(Json(_msg, JsonRequestBehavior.AllowGet)); } if (sourcefrom.Length > 20) { _msg.Msg = "无效来源"; return(Json(_msg, JsonRequestBehavior.AllowGet)); } if (!string.IsNullOrEmpty(phone)) { Account tempaccout = AccountBLL.SingleModel.GetModelByPhone(phone); if (tempaccout != null) { _msg.Msg = "该手机号已被注册"; return(Json(_msg, JsonRequestBehavior.AllowGet)); } } //是否校验手机号,0检验,1不校验 //校验验证码 _msg = CommondHelper.CheckVaildCode(phone, code); if (!_msg.isok) { return(Json(_msg, JsonRequestBehavior.AllowGet)); } Account account = null; //如果是代理分销扫描注册,测判断绑定的手机号是否已经注册过账号,如果没有则注册一个账号 if (agentqrcodeid > 0) { sourcefrom = "代理分销推广"; account = AccountBLL.SingleModel.GetModelByPhone(phone); } if (account == null) { account = AccountBLL.SingleModel.WeiXinRegister("", 0, "", true, address, phone, sourcefrom, password); } else { //修改已经注册过的用户信息 AccountBLL.SingleModel.UpdateUserInfo(account.Id.ToString(), phone, password, address); } if (account != null) { //用户已绑定手机号,判断是否有单页版 XcxAppAccountRelation usertemplate = XcxAppAccountRelationBLL.SingleModel.GetModelByaccound(account.Id.ToString()); if (usertemplate == null) { //免费开通单页版 XcxAppAccountRelationBLL.SingleModel.AddFreeTemplate(account); } //如果是扫分销代理码注册,则开通代理, if (agentqrcodeid > 0) { //判断是否是代理商 Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(account.Id.ToString(), -1); if (agentinfo != null) { _msg.isok = true; _msg.Msg = "注册失败,该号码已绑定了代理商账号"; return(Json(_msg, JsonRequestBehavior.AllowGet)); } _msg.Msg = _agentDistributionRelationBLL.CreateDistributionAgent(account.Id.ToString(), agentqrcodeid, opentype, username); if (_msg.Msg != "") { return(Json(_msg, JsonRequestBehavior.AllowGet)); } } _msg.isok = true; _msg.Msg = "注册成功"; } else { _msg.isok = false; _msg.Msg = "注册失败"; } string key = string.Format(_resetPasswordkey, phone); RedisUtil.Remove(key); return(Json(_msg, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 子模版获取小程序二维码 /// </summary> /// <param name="storeid"></param> /// <param name="msg"></param> /// <returns></returns> public string GetStoreCode(int storeid, ref string msg) { PlatStore store = base.GetModel(storeid); if (store == null) { msg = "店铺二维码:找不到店铺数据"; return(""); } string url = RedisUtil.Get <string>(string.Format(_redis_PlatStoreCodeUrlKey, storeid)); if (!string.IsNullOrEmpty(url)) { return(url); } XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(store.Aid); if (xcxrelation == null || string.IsNullOrEmpty(xcxrelation.AppId)) { msg = "店铺二维码:店铺没绑定小程序"; return(""); } //OpenAuthorizerConfig XUserList = openAuthorizerConfigBLL.GetModelByAppids(xcxrelation.AppId); //if (XUserList == null) //{ // msg = "店铺二维码:店铺小程序还未授权"; // return ""; //} XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId); if (xcxTemplate == null) { msg = "店铺二维码:无效模板"; return(""); } string token = ""; if (!XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token)) { msg = token; return(""); } //小程序二维码 qrcodeclass result = CommondHelper.GetMiniAppQrcode(token, xcxTemplate.Address); if (result != null && result.isok > 0) { url = result.url; if (string.IsNullOrEmpty(url)) { return(""); } url = url.Replace("http:", "https:"); RedisUtil.Set <string>(string.Format(_redis_PlatStoreCodeUrlKey, storeid), url, TimeSpan.FromSeconds(5)); return(url); } msg = "店铺二维码:获取失败"; return(""); }
/// <summary> /// 获取帖子列表 /// </summary> /// <returns></returns> public ActionResult GetMsgList() { returnObj = new Return_Msg_APP(); returnObj.code = "200"; int userId = Context.GetRequestInt("userId", 0); string appId = Context.GetRequest("appId", string.Empty); string keyMsg = Context.GetRequest("keyMsg", string.Empty); int orderType = Context.GetRequestInt("orderType", 0); //默认为0 表示最新发布 1表示距离最近 int msgTypeId = Context.GetRequestInt("msgTypeId", 0); //类别默认为0 表示获取所有 int pageSize = Context.GetRequestInt("pageSize", 10); int pageIndex = Context.GetRequestInt("pageIndex", 1); string latStr = Context.GetRequest("lat", string.Empty); string lngStr = Context.GetRequest("lng", string.Empty); if (string.IsNullOrEmpty(appId)) { returnObj.Msg = "参数错误"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId); if (r == null) { returnObj.Msg = "小程序未授权"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } int totalCount = 0; int commentTotalCount = 0; //帖子对应的评论条数 int count = 0; //帖子对应的点赞用户数 List <PlatMsg> list = new List <PlatMsg>(); if (orderType == 1) { double lat = 0.00; double lng = 0.00; //表示按照距离最近的 //表示没有传坐标 通过客户端IP获取经纬度 // log4net.LogHelper.WriteInfo(this.GetType(), $"!!!!orderType={orderType};{lat},{lng}"); if (!double.TryParse(latStr, out lat) || !double.TryParse(lngStr, out lng) || lat == 0 || lng == 0) { string IP = WebHelper.GetIP(); IPToPoint iPToPoint = CommondHelper.GetLoctionByIP(IP); if (iPToPoint != null) { lat = iPToPoint.result.location.lat; lng = iPToPoint.result.location.lng; //log4net.LogHelper.WriteInfo(this.GetType(), $"IP={IP};{lat},{lng}"); } } //log4net.LogHelper.WriteInfo(this.GetType(),$"orderType={orderType};{lat},{lng}" ); list = PlatMsgBLL.SingleModel.GetListMsg(r.Id, out totalCount, keyMsg, msgTypeId, pageSize, pageIndex, 1, lat, lng); list.ForEach(x => { PlatUserFavoriteMsg _userFavoriteMsg = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsg(r.Id, x.Id, userId, (int)PointsActionType.收藏); x.IsFavorited = (_userFavoriteMsg != null && _userFavoriteMsg.State != -1); _userFavoriteMsg = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsg(r.Id, x.Id, userId, (int)PointsActionType.点赞); x.IsDzed = (_userFavoriteMsg != null && _userFavoriteMsg.State != -1); PlatMsgReport _platMsgReport = PlatMsgReportBLL.SingleModel.GetMsgReport(userId, x.Id); x.IsReported = (_platMsgReport != null); x.Comments = PlatMsgCommentBLL.SingleModel.GetPlatMsgComment(r.Id, out commentTotalCount, 0, string.Empty, 1000, 1, x.Id, 0); x.DzUsers = PlatUserFavoriteMsgBLL.SingleModel.GetMsgUserFavoriteList(0, x.Aid, x.Id, (int)PointsActionType.点赞, (int)PointsDataType.帖子, 1, 1000, ref count); }); } else { list = PlatMsgBLL.SingleModel.GetListMsg(r.Id, out totalCount, keyMsg, msgTypeId, pageSize, pageIndex); list.ForEach(x => { PlatUserFavoriteMsg _userFavoriteMsg = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsg(r.Id, x.Id, userId, (int)PointsActionType.收藏); x.IsFavorited = (_userFavoriteMsg != null && _userFavoriteMsg.State != -1); _userFavoriteMsg = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsg(r.Id, x.Id, userId, (int)PointsActionType.点赞); x.IsDzed = (_userFavoriteMsg != null && _userFavoriteMsg.State != -1); PlatMsgReport _platMsgReport = PlatMsgReportBLL.SingleModel.GetMsgReport(userId, x.Id); x.IsReported = (_platMsgReport != null); x.Comments = PlatMsgCommentBLL.SingleModel.GetPlatMsgComment(r.Id, out commentTotalCount, 0, string.Empty, 1000, 1, x.Id, 0); x.DzUsers = PlatUserFavoriteMsgBLL.SingleModel.GetMsgUserFavoriteList(0, x.Aid, x.Id, (int)PointsActionType.点赞, (int)PointsDataType.帖子, 1, 1000, ref count); }); } returnObj.isok = true; returnObj.Msg = "获取成功"; returnObj.dataObj = new { totalCount = totalCount, list = list }; return(Json(returnObj, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 保存注册信息 /// </summary> /// <returns></returns> public ActionResult SaveUserInfo() { Return_Msg data = new Return_Msg(); string password = Utility.IO.Context.GetRequest("password", string.Empty); string phone = Utility.IO.Context.GetRequest("phone", string.Empty); string code = Utility.IO.Context.GetRequest("code", string.Empty); string address = Utility.IO.Context.GetRequest("address", string.Empty); string sourcefrom = Utility.IO.Context.GetRequest("sourcefrom", "代理分销推广"); int agentqrcodeid = Utility.IO.Context.GetRequestInt("agentqrcodeid", 0); int opentype = Utility.IO.Context.GetRequestInt("opentype", 0); string username = Utility.IO.Context.GetRequest("username", ""); string appid = Utility.IO.Context.GetRequest("appid", ""); data.isok = false; //if (agentqrcodeid>0 && string.IsNullOrEmpty(username)) //{ // _msg.Msg = "请输入姓名"; // return Json(_msg, JsonRequestBehavior.AllowGet); //} if (string.IsNullOrEmpty(phone)) { data.Msg = "请输入手机号"; return(Json(data)); } if (string.IsNullOrEmpty(code)) { data.Msg = "请输入验证码"; return(Json(data)); } if (string.IsNullOrEmpty(password)) { data.Msg = "请输入密码"; return(Json(data)); } if (agentqrcodeid <= 0) { data.Msg = "参数错误"; return(Json(data)); } //是否校验手机号,0检验,1不校验 //校验验证码 data = CommondHelper.CheckVaildCode(phone, code); if (!data.isok) { return(Json(data)); } Account account = AccountBLL.SingleModel.GetModelByPhone(phone); //如果是代理分销扫描注册,则判断绑定的手机号是否已经注册过账号,如果没有则注册一个账号 if (account == null) { account = AccountBLL.SingleModel.WeiXinRegister("", 0, "", true, address, phone, sourcefrom, password); } else { //修改已经注册过的用户信息 AccountBLL.SingleModel.UpdateUserInfo(account.Id.ToString(), phone, password, address); } if (account != null) { //用户已绑定手机号,判断是否有单页版 XcxAppAccountRelation usertemplate = XcxAppAccountRelationBLL.SingleModel.GetModelByaccound(account.Id.ToString()); if (usertemplate == null) { //免费开通单页版 XcxAppAccountRelationBLL.SingleModel.AddFreeTemplate(account); } //如果是扫分销代理码注册,则开通代理, AgentDistributionRelationBLL agentDistributionRelationBLL = new AgentDistributionRelationBLL(); data.Msg = agentDistributionRelationBLL.CreateDistributionAgent(account.Id.ToString(), agentqrcodeid, opentype, username); if (data.Msg != "") { return(Json(data)); } data.isok = true; data.Msg = "注册成功"; } else { data.isok = false; data.Msg = "注册失败"; } string key = string.Format(_resetPasswordkey, phone); RedisUtil.Remove(key); return(Json(data, JsonRequestBehavior.AllowGet)); }
public ActionResult getMsgDetail() { returnObj = new Return_Msg_APP(); string appId = Context.GetRequest("appId", string.Empty); int msgId = Context.GetRequestInt("msgId", 0); //帖子信息Id int userId = Context.GetRequestInt("userId", 0); //用户Id string latStr = Context.GetRequest("lat", string.Empty); string lngStr = Context.GetRequest("lng", string.Empty); if (string.IsNullOrEmpty(appId) || msgId <= 0) { returnObj.code = "200"; returnObj.Msg = "参数错误"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId); if (r == null) { returnObj.code = "200"; returnObj.Msg = "小程序未授权"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } CityMsg model = CityMsgBLL.SingleModel.getMsg(r.Id, msgId); if (model == null) { returnObj.code = "200"; returnObj.Msg = "找不到数据"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } double lat = 0.00; double lng = 0.00; //表示按照距离最近的 //表示没有传坐标 通过客户端IP获取经纬度 // log4net.LogHelper.WriteInfo(this.GetType(), $"!!!!orderType={orderType};{lat},{lng}"); if (!double.TryParse(latStr, out lat) || !double.TryParse(lngStr, out lng) || lat <= 0 || lng <= 0) { string IP = WebHelper.GetIP(); IPToPoint iPToPoint = CommondHelper.GetLoctionByIP(IP); if (iPToPoint != null) { lat = iPToPoint.result.location.lat; lng = iPToPoint.result.location.lng; // log4net.LogHelper.WriteInfo(this.GetType(), $"IP={IP};{lat},{lng}"); } } model.distance = CityMsgBLL.SingleModel.GetDistance(Convert.ToDouble(model.lat), Convert.ToDouble(model.lng), lat, lng); CityUserFavoriteMsg _userFavoriteMsg = CityUserFavoriteMsgBLL.SingleModel.getCity_UserFavoriteMsg(r.Id, msgId, userId); model.isFavorited = (_userFavoriteMsg != null); _userFavoriteMsg = CityUserFavoriteMsgBLL.SingleModel.getCity_UserFavoriteMsg(r.Id, msgId, userId, 1); model.isDzed = (_userFavoriteMsg != null); CityMsgReport city_MsgReport = CityMsgReportBLL.SingleModel.GetCityMsgReport(userId, msgId); model.isReported = (city_MsgReport != null); int commentTotalCount = 0; model.Comments = CityMsgCommentBLL.SingleModel.GetCityMsgComment(r.Id, out commentTotalCount, string.Empty, 1000, 1, model.Id); returnObj.isok = true; returnObj.Msg = "获取成功"; returnObj.dataObj = new { msg = model }; return(Json(returnObj, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取帖子评论列表 /// </summary> /// <param name="aid"></param> /// <param name="totalCount"></param> /// <param name="keyMsg"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="Id"></param> /// <param name="userId"></param> /// <returns></returns> public List <CityMsgComment> GetCityMsgComment(int aid, out int totalCount, string keyMsg = "", int pageSize = 10, int pageIndex = 1, int Id = 0, int userId = 0) { string strWhere = $"aid={aid} and State=0 "; List <MySqlParameter> parameters = new List <MySqlParameter>(); if (userId > 0) { strWhere += $" and FromUserId={userId} "; } if (Id > 0) { strWhere += $" and MsgId={Id}"; } if (!string.IsNullOrEmpty(keyMsg)) { strWhere += $" and CommentDetail like @keyMsg "; parameters.Add(new MySqlParameter("keyMsg", $"%{keyMsg}%")); } totalCount = base.GetCount(strWhere, parameters.ToArray()); List <CityMsgComment> listCityMsgComment = base.GetListByParam(strWhere, parameters.ToArray(), pageSize, pageIndex, "*", " AddTime Desc"); if (listCityMsgComment != null && listCityMsgComment.Count > 0) { string fuserIds = string.Join(",", listCityMsgComment.Select(s => s.FromUserId)); string tuserIds = string.Join(",", listCityMsgComment.Select(s => s.ToUserId)); if (!string.IsNullOrEmpty(tuserIds)) { if (!string.IsNullOrEmpty(fuserIds)) { fuserIds += "," + tuserIds; } else { fuserIds = tuserIds; } } List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(fuserIds); string cityMsgIds = string.Join(",", listCityMsgComment.Select(s => s.MsgId)); List <CityMsg> cityMsgList = CityMsgBLL.SingleModel.GetListByIds(cityMsgIds); listCityMsgComment.ForEach(x => { C_UserInfo c_userInfo = userInfoList?.FirstOrDefault(f => f.Id == x.FromUserId); if (c_userInfo != null) { x.NickName = c_userInfo.NickName; x.HeaderImg = c_userInfo.HeadImgUrl; } else { x.NickName = "匿名"; } C_UserInfo to_userInfo = userInfoList?.FirstOrDefault(f => f.Id == x.ToUserId); if (to_userInfo != null) { x.ToNickName = to_userInfo.NickName; x.ToHeaderImg = to_userInfo.HeadImgUrl; } CityMsg cityMsg = cityMsgList?.FirstOrDefault(f => f.Id == x.MsgId); if (cityMsg != null) { x.MsgTxt = cityMsg.msgDetail.Length > 20 ? cityMsg.msgDetail.Substring(0, 20) + "..." : cityMsg.msgDetail; x.MsgFirstImg = cityMsg.imgList.FirstOrDefault(); } x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime); }); } return(listCityMsgComment); }
public CreateCardResult AddWxCoupons(Coupons coupons, XcxAppAccountRelation xcx, string accountId) { //默认专业版的 string center_app_brand_pass = "******"; //专业版 个人中心 string custom_app_brand_pass = "******"; //首页 专业版 string logo_url = string.Empty; string brand_name = string.Empty; string appOriginalId = string.Empty; CreateCardResult _createCardResult = new CreateCardResult(); XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={xcx.TId}"); if (xcxTemplate == null) { _createCardResult.errcode = 1; _createCardResult.errmsg = "小程序模板不存在"; return(_createCardResult); } List <OpenAuthorizerConfig> listOpenAuthorizerConfig = OpenAuthorizerConfigBLL.SingleModel.GetListByaccoundidAndRid(accountId, xcx.Id, 4); if (listOpenAuthorizerConfig == null) { _createCardResult.errcode = 1; _createCardResult.errmsg = "请先绑定认证服务号才有生成卡券权限"; return(_createCardResult); } OpenAuthorizerConfig umodel = listOpenAuthorizerConfig[0]; switch (xcxTemplate.Type) { case (int)TmpType.小程序专业模板: EntSetting ent = EntSettingBLL.SingleModel.GetModel(coupons.appId); if (ent == null) { _createCardResult.errcode = 1; _createCardResult.errmsg = "该专业版信息找不到"; return(_createCardResult); } OpenAuthorizerConfig XUserList = OpenAuthorizerConfigBLL.SingleModel.GetModelByAppids(xcx.AppId); if (XUserList == null) { _createCardResult.errcode = 1; _createCardResult.errmsg = "请先授权给平台"; return(_createCardResult); } ConfParam imginfo = ConfParamBLL.SingleModel.GetModelByParamappid("logoimg", xcx.AppId); if (imginfo == null) { _createCardResult.errcode = 1; _createCardResult.errmsg = "请先到小程序管理配置底部Logo"; return(_createCardResult); } logo_url = imginfo.Value; brand_name = XUserList.nick_name; break; case (int)TmpType.小程序电商模板: center_app_brand_pass = "******"; //个人中心页面 Store store = StoreBLL.SingleModel.GetModelByAId(xcx.Id); if (store == null) { _createCardResult.errcode = 1; _createCardResult.errmsg = "电商版店铺不存在"; return(_createCardResult); } logo_url = store.logo; brand_name = store.name; break; case (int)TmpType.小程序餐饮模板: center_app_brand_pass = "******"; //个人中心页面 custom_app_brand_pass = "******"; //首页 Food miAppFood = FoodBLL.SingleModel.GetModel($"appId={xcx.Id}"); if (miAppFood == null) { _createCardResult.errcode = 1; _createCardResult.errmsg = "餐饮版店铺不存在"; return(_createCardResult); } logo_url = miAppFood.Logo; brand_name = miAppFood.FoodsName; break; case (int)TmpType.小程序足浴模板: case (int)TmpType.小程序多门店模板: int t = 0; if ((int)TmpType.小程序足浴模板 == xcxTemplate.Type) { center_app_brand_pass = "******"; //个人中心页面 custom_app_brand_pass = "******"; //首页 } else { center_app_brand_pass = "******"; //个人中心页面 t = 1; } FootBath storeModel = FootBathBLL.SingleModel.GetModel($"appId={xcx.Id}"); if (storeModel == null) { _createCardResult.errcode = 1; _createCardResult.errmsg = "找不到该足浴版"; return(_createCardResult); } brand_name = storeModel.StoreName; List <C_Attachment> LogoList = C_AttachmentBLL.SingleModel.GetListByCache(storeModel.Id, t == 0 ? (int)AttachmentItemType.小程序足浴版店铺logo : (int)AttachmentItemType.小程序多门店版门店logo); if (LogoList != null && LogoList.Count > 0) { logo_url = LogoList[0].filepath; } break; case (int)TmpType.小未平台子模版: center_app_brand_pass = "******"; //个人中心页面 custom_app_brand_pass = "******"; //首页 PlatStore platStore = PlatStoreBLL.SingleModel.GetPlatStore(xcx.Id, 2); if (platStore == null) { _createCardResult.errcode = 1; _createCardResult.errmsg = "平台版店铺不存在"; return(_createCardResult); } brand_name = platStore.Name; logo_url = platStore.StoreHeaderImg; break; } if (string.IsNullOrEmpty(logo_url) || string.IsNullOrEmpty(brand_name)) { _createCardResult.errcode = 1; _createCardResult.errmsg = "请先配置Logo以及名称"; return(_createCardResult); } //这里可能会出现token失效 个人发布的未授权给我们第三方平台的卡券会生成不了 string xcxapiurl = XcxApiBLL.SingleModel.GetOpenAuthodModel(umodel.user_name); string authorizer_access_token = CommondHelper.GetAuthorizer_Access_Token(xcxapiurl); string uploadImgResult = CommondHelper.WxUploadImg(authorizer_access_token, logo_url); if (!uploadImgResult.Contains("url")) { _createCardResult.errcode = 1; _createCardResult.errmsg = $"上传Logo到微信失败uploadImgResult={uploadImgResult}"; return(_createCardResult); } if (brand_name.Length >= 12) { brand_name = brand_name.Substring(0, 12); } WxUploadImgResult wxUploadImgResult = JsonConvert.DeserializeObject <WxUploadImgResult>(uploadImgResult); logo_url = wxUploadImgResult.url; base_info _base_info = new base_info(); _base_info.logo_url = logo_url; _base_info.code_type = "CODE_TYPE_TEXT"; _base_info.brand_name = brand_name; _base_info.title = coupons.CouponName.Length > 9 ? Utility.StringHelper.strSubstring(coupons.CouponName, 0, 8) : coupons.CouponName; _base_info.color = "Color010"; _base_info.center_title = "立即使用"; _base_info.center_app_brand_user_name = $"{appOriginalId}@app"; _base_info.center_app_brand_pass = center_app_brand_pass; _base_info.custom_url_name = "小程序"; _base_info.custom_app_brand_user_name = $"{appOriginalId}@app"; _base_info.custom_app_brand_pass = custom_app_brand_pass; _base_info.custom_url_sub_title = "点击进入"; _base_info.description = coupons.Desc.Length > 1024 ? Utility.StringHelper.strSubstring(coupons.Desc, 0, 1023) : coupons.Desc; _base_info.notice = "使用时向服务员出示此券"; _base_info.sku.quantity = coupons.CreateNum; if (coupons.LimitReceive > 0) { //大于0表示限制,0表示无限制 _base_info.get_limit = coupons.LimitReceive; } if (coupons.ValType == 0) { //表示固定日期 _base_info.date_info = new Firstdate_infoItem() { begin_timestamp = WxUtils.GetWeixinDateTime(coupons.StartUseTime), end_timestamp = WxUtils.GetWeixinDateTime(coupons.EndUseTime) }; } if (coupons.ValType == 2 || coupons.ValType == 1) { //fixed_begin_term=0表示领取后当天开始生效 1表示次日后开始生效 领取当日N天内有效 _base_info.date_info = new Seconddate_infoItem() { fixed_begin_term = coupons.ValType == 2?0:1, fixed_term = coupons.ValDay }; } string json = string.Empty; if (coupons.CouponWay == 0) { //表示是需要生成微信代金券 WxCashCoupons wxCashCoupons = new WxCashCoupons(); Cash cash = new Cash(); cash.base_info = _base_info;//基础字段信息 Use_condition use_condition = new Use_condition(); use_condition.accept_category = coupons.GoodsType == 0 ? "全部产品" : "部分产品"; if (coupons.LimitMoney > 0) { cash.least_cost = coupons.LimitMoney; //满减门槛 use_condition.least_cost = coupons.LimitMoney; } use_condition.can_use_with_other_discount = coupons.discountType == 0; cash.reduce_cost = coupons.Money; cash.advanced_info = new Advanced_info() { use_condition = use_condition }; wxCashCoupons.cash = cash; json = JsonConvert.SerializeObject(new { card = wxCashCoupons }); } else { //表示是需要生成微信折扣券 WxDiscountCoupons wxDiscountCoupons = new WxDiscountCoupons(); Discount discount = new Discount(); discount.base_info = _base_info; discount.discount = (int)(100 - coupons.Money * 0.1); wxDiscountCoupons.discount = discount; json = JsonConvert.SerializeObject(new { card = wxDiscountCoupons }); } string result = Utility.IO.Context.PostData($"https://api.weixin.qq.com/card/create?access_token={authorizer_access_token}", json); if (string.IsNullOrEmpty(result)) { return(_createCardResult); } _createCardResult = JsonConvert.DeserializeObject <CreateCardResult>(result); return(_createCardResult); }
public ActionResult getMsgList() { returnObj = new Return_Msg_APP(); returnObj.code = "200"; int userId = Context.GetRequestInt("userId", 0); string appId = Context.GetRequest("appId", string.Empty); string keyMsg = Context.GetRequest("keyMsg", string.Empty); int orderType = Context.GetRequestInt("orderType", 0); //默认为0 表示最新发布 1表示距离最近 int msgTypeId = Context.GetRequestInt("msgTypeId", 0); //默认为0 表示获取所有 int pageSize = Context.GetRequestInt("pageSize", 10); int pageIndex = Context.GetRequestInt("pageIndex", 1); string latStr = Context.GetRequest("lat", string.Empty); string lngStr = Context.GetRequest("lng", string.Empty); if (string.IsNullOrEmpty(appId)) { returnObj.Msg = "参数错误"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId); if (r == null) { returnObj.Msg = "小程序未授权"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } int commentTotalCount = 0; int totalCount = 0; List <CityMsg> list = new List <CityMsg>(); if (orderType == 1) { double lat = 0.00; double lng = 0.00; //表示按照距离最近的 //表示没有传坐标 通过客户端IP获取经纬度 // log4net.LogHelper.WriteInfo(this.GetType(), $"!!!!orderType={orderType};{lat},{lng}"); if (!double.TryParse(latStr, out lat) || !double.TryParse(lngStr, out lng) || lat == 0 || lng == 0) { string IP = WebHelper.GetIP(); IPToPoint iPToPoint = CommondHelper.GetLoctionByIP(IP); if (iPToPoint != null && iPToPoint.result != null) { lat = iPToPoint.result.location.lat; lng = iPToPoint.result.location.lng; //log4net.LogHelper.WriteInfo(this.GetType(), $"IP={IP};{lat},{lng}"); } } //log4net.LogHelper.WriteInfo(this.GetType(),$"orderType={orderType};{lat},{lng}" ); list = CityMsgBLL.SingleModel.getListCity_Msg(r.Id, out totalCount, pageSize, pageIndex, msgTypeId, keyMsg, 1, lat, lng); list.ForEach(x => { x.distance = CityMsgBLL.SingleModel.GetDistance(Convert.ToDouble(x.lat), Convert.ToDouble(x.lng), lat, lng); if (x.distance < 1) { x.distanceStr = (x.distance * 1000).ToString("0.00") + "m"; } else { x.distanceStr = x.distance.ToString("0.00") + "km"; } CityUserFavoriteMsg _userFavoriteMsg = CityUserFavoriteMsgBLL.SingleModel.getCity_UserFavoriteMsg(r.Id, x.Id, userId, 1); x.isDzed = (_userFavoriteMsg != null); CityMsgReport city_MsgReport = CityMsgReportBLL.SingleModel.GetCityMsgReport(userId, x.Id); x.isReported = (city_MsgReport != null); x.Comments = CityMsgCommentBLL.SingleModel.GetCityMsgComment(x.aid, out commentTotalCount, string.Empty, 1000, 1, x.Id); }); } else { list = CityMsgBLL.SingleModel.getListCity_Msg(r.Id, out totalCount, pageSize, pageIndex, msgTypeId, keyMsg); list.ForEach(x => { CityUserFavoriteMsg _userFavoriteMsg = CityUserFavoriteMsgBLL.SingleModel.getCity_UserFavoriteMsg(r.Id, x.Id, userId, 1); x.isDzed = (_userFavoriteMsg != null); CityMsgReport city_MsgReport = CityMsgReportBLL.SingleModel.GetCityMsgReport(userId, x.Id); x.isReported = (city_MsgReport != null); x.Comments = CityMsgCommentBLL.SingleModel.GetCityMsgComment(x.aid, out commentTotalCount, string.Empty, 1000, 1, x.Id); }); } returnObj.isok = true; returnObj.Msg = "获取成功"; returnObj.dataObj = new { totalCount = totalCount, list = list }; return(Json(returnObj, JsonRequestBehavior.AllowGet)); }
public List <CityMsg> getListCity_Msg(int aid, out int totalCount, int pageSize = 10, int pageIndex = 1, int msgTypeId = 0, string keyMsg = "", int orderType = 0, double ws_lat = 0, double ws_lng = 0) { string strWhere = $" aid={aid} and state=1 "; string strWhereCount = $" aid={aid} and state=1 "; if (msgTypeId > 0) { strWhere += $" and msgTypeId={msgTypeId}"; strWhereCount += $" and msgTypeId={msgTypeId}"; } List <MySqlParameter> parameters = new List <MySqlParameter>(); if (!string.IsNullOrEmpty(keyMsg)) { strWhere += $" and msgDetail like @keyMsg "; strWhereCount += $" and msgDetail like @keyMsg "; parameters.Add(new MySqlParameter("keyMsg", $"%{keyMsg}%")); } //TODO 测试时的时间单位为分钟MINUTE 线上为天DAY string sql = $@"SELECT * FROM( SELECT * FROM (SELECT *,(DATE_ADD(addtime,INTERVAL topDay DAY)-now()) as tspan from CityMsg where (DATE_ADD(addtime,INTERVAL topDay DAY)-now())>0 and { strWhere} ORDER BY addtime desc LIMIT 100000)t1 UNION SELECT* FROM( SELECT*, (DATE_ADD(addtime, INTERVAL topDay DAY)-now()) as tspan from CityMsg where (DATE_ADD(addtime, INTERVAL topDay DAY) - now()) <= 0 and { strWhere} ORDER BY addtime desc LIMIT 100000) t2 ) t3 limit {(pageIndex - 1) * pageSize},{pageSize}"; if (orderType > 0) {//表示附近 sql = $@"SELECT * FROM( SELECT * FROM (SELECT *,(DATE_ADD(addtime,INTERVAL topDay DAY)-now()) as tspan,ROUND(6378.138*2*ASIN(SQRT(POW(SIN(({ws_lat}*PI()/180-lat*PI()/180)/2),2)+COS({ws_lat}*PI()/180)*COS(lat*PI()/180)*POW(SIN(({ws_lng}*PI()/180-lng*PI()/180)/2),2)))*1000) AS distance from CityMsg where (DATE_ADD(addtime,INTERVAL topDay DAY)-now())>0 and { strWhere} ORDER BY distance asc,addtime desc LIMIT 100000)t1 UNION SELECT* FROM( SELECT*, (DATE_ADD(addtime, INTERVAL topDay DAY)-now()) as tspan,ROUND(6378.138*2*ASIN(SQRT(POW(SIN(({ws_lat}*PI()/180-lat*PI()/180)/2),2)+COS({ws_lat}*PI()/180)*COS(lat*PI()/180)*POW(SIN(({ws_lng}*PI()/180-lng*PI()/180)/2),2)))*1000) AS distance from CityMsg where (DATE_ADD(addtime, INTERVAL topDay DAY) - now()) <= 0 and { strWhere} ORDER BY distance asc, addtime desc LIMIT 100000) t2 ) t3 limit {(pageIndex - 1) * pageSize},{pageSize}"; } List <CityMsg> listCity_Msg = base.GetListBySql(sql, parameters.ToArray()); if (listCity_Msg != null && listCity_Msg.Count > 0) { string userIds = string.Join(",", listCity_Msg.Select(s => s.userId).Distinct()); List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds); string cityMsgIds = string.Join(",", listCity_Msg.Select(s => s.msgTypeId)); List <CityStoreMsgType> cityStoreMsgTypeList = CityStoreMsgTypeBLL.SingleModel.GetListByIds(cityMsgIds); string msgShareIds = string.Join(",", listCity_Msg.Select(s => s.Id)); List <CityMsgViewFavoriteShare> cityMsgViewFavoriteShareList = CityMsgViewFavoriteShareBLL.SingleModel.GetListByMsgIds(msgShareIds); listCity_Msg.ForEach(x => { //获取用户头像 昵称 C_UserInfo c_UserInfo = userInfoList?.FirstOrDefault(f => f.Id == x.userId); if (c_UserInfo != null) { x.userName = c_UserInfo.NickName; x.userHeaderImg = c_UserInfo.HeadImgUrl; } //获取帖子类别 CityStoreMsgType city_StoreMsgType = cityStoreMsgTypeList?.FirstOrDefault(f => f.Id == x.msgTypeId); if (city_StoreMsgType != null) { x.msgTypeName = city_StoreMsgType.name; } //根据帖子ID获取其浏览量-收藏量-分享量数据 CityMsgViewFavoriteShare city_MsgViewFavoriteShare = cityMsgViewFavoriteShareList?.FirstOrDefault(f => f.Id == x.Id); if (city_MsgViewFavoriteShare != null) { x.ViewCount = city_MsgViewFavoriteShare.ViewCount; x.FavoriteCount = city_MsgViewFavoriteShare.FavoriteCount; x.ShareCount = city_MsgViewFavoriteShare.ShareCount; x.DzCount = city_MsgViewFavoriteShare.DzCount; } x.showTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.addTime); x.msgDetail = HttpUtility.HtmlDecode(x.msgDetail); }); } totalCount = base.GetCount(strWhereCount, parameters.ToArray()); return(listCity_Msg); }
/// <summary> /// 根据用户Id获取该用户的帖子信息 /// </summary> /// <param name="aid"></param> /// <param name="totalCount"></param> /// <param name="userId"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="orderType">帖子排序字段 默认为0表示按照时间降序排列 1表示先按照置顶排序 然后再按照时间</param> /// <returns></returns> public List <CityMsg> getListByUserId(int aid, out int totalCount, int userId, int pageSize = 10, int pageIndex = 1, int orderType = 0) { List <string> listMsgId = new List <string>(); List <CityMorders> listCityMorder = new CityMordersBLL().GetList($"MinisnsId={aid} and payment_status=1 and Status=1"); if (listCityMorder != null && listCityMorder.Count > 0) { foreach (CityMorders item in listCityMorder) { listMsgId.Add(item.CommentId.ToString()); } } else { listMsgId.Add("0"); } string strWhere = $"aid={aid} and userId={userId} and ( (state<>-1 and topDay=0) or (state<>-1 and Id in({string.Join(",",listMsgId)}))) "; string orderWhere = " addTime desc";//默认按照时间降序排序 //if (orderType == 1) //{ // orderWhere = " topDay desc,addTime desc";//先按照置顶排序 然后再按照时间 // strWhere += ""; //} totalCount = base.GetCount(strWhere); List <CityMsg> listCity_Msg = base.GetList(strWhere, pageSize, pageIndex, "*", orderWhere); if (listCity_Msg != null && listCity_Msg.Count > 0) { string userIds = string.Join(",", listCity_Msg.Select(s => s.userId).Distinct()); List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds); string cityMsgIds = string.Join(",", listCity_Msg.Select(s => s.msgTypeId)); List <CityStoreMsgType> cityStoreMsgTypeList = CityStoreMsgTypeBLL.SingleModel.GetListByIds(cityMsgIds); string msgShareIds = string.Join(",", listCity_Msg.Select(s => s.Id)); List <CityMsgViewFavoriteShare> cityMsgViewFavoriteShareList = CityMsgViewFavoriteShareBLL.SingleModel.GetListByMsgIds(msgShareIds); listCity_Msg.ForEach(x => { //获取用户头像 C_UserInfo c_UserInfo = userInfoList?.FirstOrDefault(f => f.Id == x.userId); if (c_UserInfo != null) { x.userName = c_UserInfo.NickName; x.userHeaderImg = c_UserInfo.HeadImgUrl; } //获取帖子类别 CityStoreMsgType city_StoreMsgType = cityStoreMsgTypeList?.FirstOrDefault(f => f.Id == x.msgTypeId); if (city_StoreMsgType != null) { x.msgTypeName = city_StoreMsgType.name; } //根据帖子ID获取其浏览量-收藏量-分享量数据 CityMsgViewFavoriteShare city_MsgViewFavoriteShare = cityMsgViewFavoriteShareList?.FirstOrDefault(f => f.Id == x.Id); if (city_MsgViewFavoriteShare != null) { x.ViewCount = city_MsgViewFavoriteShare.ViewCount; x.FavoriteCount = city_MsgViewFavoriteShare.FavoriteCount; x.ShareCount = city_MsgViewFavoriteShare.ShareCount; x.DzCount = city_MsgViewFavoriteShare.DzCount; } x.showTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.addTime); x.msgDetail = HttpUtility.HtmlDecode(x.msgDetail); }); } return(listCity_Msg); }
/// <summary> /// 谁看过我,谁关注我,谁收藏我,谁点赞我列表数据 /// </summary> /// <returns></returns> public ActionResult GetOtherFavoriteList() { returnObj = new Return_Msg_APP(); int actionType = Context.GetRequestInt("actiontype", (int)PointsActionType.收藏); int myCardId = Context.GetRequestInt("mycardid", 0); int userId = Context.GetRequestInt("userid", 0); int aid = Context.GetRequestInt("aid", 0); int dataType = Context.GetRequestInt("datatype", (int)PointsDataType.片); int pageIndex = Context.GetRequestInt("pageindex", 1); int pageSize = Context.GetRequestInt("pagesize", 10); int type = Context.GetRequestInt("type", 0); string lng = Context.GetRequest("lng", "0"); string lat = Context.GetRequest("lat", "0"); int ver = Context.GetRequestInt("ver", 0); if (myCardId <= 0) { returnObj.Msg = "我的名片ID不能小于0"; return(Json(returnObj)); } if (userId <= 0) { returnObj.Msg = "userid不能小于0"; return(Json(returnObj)); } if (aid <= 0) { returnObj.Msg = "aid不能小于0"; return(Json(returnObj)); } PlatMyCard myCard = PlatMyCardBLL.SingleModel.GetModelByUserId(userId, aid); if (myCard != null) { lng = myCard.Lng.ToString(); lat = myCard.Lat.ToString(); } int count = 0; switch (dataType) { case (int)PointsDataType.片: if (actionType == (int)PointsActionType.私信) { List <PlatUserFavoriteMsg> myCardList = PlatUserFavoriteMsgBLL.SingleModel.GetMyCardUserFavoriteList(ver, myCard.Id, userId, aid, pageIndex, pageSize, ref count); returnObj.dataObj = new { list = myCardList, count = count }; } else { List <PlatUserFavoriteMsg> mycardlist = PlatUserFavoriteMsgBLL.SingleModel.GetMyCardUserFavoriteList(myCard.AppId, lng, lat, userId, type, aid, myCardId, actionType, dataType, pageIndex, pageSize, ref count); returnObj.dataObj = new { list = mycardlist, count = count }; } break; case (int)PointsDataType.帖子: List <PlatUserFavoriteMsg> msgList = PlatUserFavoriteMsgBLL.SingleModel.GetMsgUserFavoriteList(type, aid, myCardId, actionType, dataType, pageIndex, pageSize, ref count); returnObj.dataObj = new { list = msgList, count = count }; break; case (int)PointsDataType.店铺: List <PlatStore> storeList = PlatUserFavoriteMsgBLL.SingleModel.GetListMyFavoriteStore(aid, userId, out count, pageSize, pageIndex); //表示没有传坐标 通过客户端IP获取经纬度 IPToPoint iPToPoint = new IPToPoint(); if (lng == "0" || lat == "0") { string IP = WebHelper.GetIP(); iPToPoint = CommondHelper.GetLoctionByIP(IP); if (iPToPoint != null && iPToPoint.result != null) { lat = iPToPoint.result.location.lat.ToString(); lng = iPToPoint.result.location.lng.ToString(); } } double distance = 0.00; storeList.ForEach(x => { distance = CommondHelper.GetDistance(x.Lat, x.Lng, Convert.ToDouble(lat), Convert.ToDouble(lng)); if (distance < 1) { x.Distance = (distance * 1000).ToString() + "m"; } else { x.Distance = distance.ToString() + "km"; } }); returnObj.dataObj = new { list = storeList, count = count }; break; } returnObj.isok = true; return(Json(returnObj)); }
public ExchangePlayCardRelation GetExchangePlayCardRelation(int userId, int appId, out int resultCode) { bool blackout = false;//是否断签 resultCode = 200; Store storeModel = StoreBLL.SingleModel.GetModelByAId(appId); if (storeModel == null || string.IsNullOrEmpty(storeModel.configJson)) { resultCode = 404;//店铺配置信息没有找到 return(null); } ExchangePlayCardConfig exchangePlayCardConfig = new ExchangePlayCardConfig(); storeModel.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(storeModel.configJson); if (string.IsNullOrEmpty(storeModel.funJoinModel.ExchangePlayCardConfig)) { resultCode = 403;//签到配置信息没有找到 return(null); } exchangePlayCardConfig = JsonConvert.DeserializeObject <ExchangePlayCardConfig>(storeModel.funJoinModel.ExchangePlayCardConfig); if (exchangePlayCardConfig.State == 0) { resultCode = 302;//签到开关关闭 return(null); } #region 表示空白从未打卡过 ExchangePlayCardRelation exchangePlayCardRelation = base.GetModel($"userId={userId} and Aid={appId}"); if (exchangePlayCardRelation == null) { exchangePlayCardRelation = new ExchangePlayCardRelation() { Aid = appId, UserId = userId, UpdateTime = DateTime.Now }; for (int i = 0; i < 7; i++) { exchangePlayCardRelation.listPlayCardLog.Add(new ExchangePlayCardLog() { Aid = appId, UserId = userId, AddTime = DateTime.Now.AddMinutes(i), Played = false, Points = exchangePlayCardConfig.DayGivePoints }); } return(exchangePlayCardRelation); } #endregion ExchangePlayCardLog exchangePlayCardLog = ExchangePlayCardLogBLL.SingleModel.GetModel($"userId={userId} and Aid={appId}"); if (exchangePlayCardLog != null) { //判断是否断签 double day = CommondHelper.DateDiff(Convert.ToDateTime(exchangePlayCardLog.AddTime.ToString("yyyy-MM-dd")), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))).TotalDays; if (day > 1)//大于1表示断签了隔了至少一天没有签到 { blackout = true; } } if (blackout) { //断签则将连续签到天数归零以及上次赠送积分的连续签到的天数归零 exchangePlayCardRelation.ConnectDay = 0; exchangePlayCardRelation.LastConnectDay = 0; exchangePlayCardRelation.UpdateTime = DateTime.Now; if (!base.Update(exchangePlayCardRelation, "ConnectDay,LastConnectDay,UpdateTime")) { resultCode = 500;//说明异常 } for (int i = 0; i < 7; i++) { exchangePlayCardRelation.listPlayCardLog.Add(new ExchangePlayCardLog() { Aid = appId, UserId = userId, AddTime = DateTime.Now.AddMinutes(i), Played = false, Points = exchangePlayCardConfig.DayGivePoints }); } return(exchangePlayCardRelation); } //没有断签 返回连续签到信息 int tempDay = exchangePlayCardRelation.ConnectDay; if (tempDay > 7) { tempDay = exchangePlayCardRelation.ConnectDay % 7; } exchangePlayCardRelation.listPlayCardLog = ExchangePlayCardLogBLL.SingleModel.GetList($"userId={userId} and Aid={appId}", tempDay, 1, "*", "AddTime desc"); if (tempDay < 7) { exchangePlayCardRelation.listPlayCardLog = exchangePlayCardRelation.listPlayCardLog.OrderBy(x => x.AddTime).ToList(); for (int i = 0; i < 7 - tempDay; i++) { exchangePlayCardRelation.listPlayCardLog.Add(new ExchangePlayCardLog() { Aid = appId, UserId = userId, AddTime = DateTime.Now.AddMinutes(i), Played = false, Points = exchangePlayCardConfig.DayGivePoints }); } } ExchangePlayCardLog todayPlayCardLog = ExchangePlayCardLogBLL.SingleModel.GetModel($"userId={userId} and Aid={appId} and to_days(AddTime) = to_days(now())"); //测试用 ExchangePlayCardLog todayPlayCardLog = _exchangePlayCardLogBLL.GetModel($"userId={userId} and Aid={appId} and AddTime>NOW()-INTERVAL 2 MINUTE");// if (todayPlayCardLog != null)//2分钟之内 { //今天已经签到 exchangePlayCardRelation.TodayPlayCard = true; } return(exchangePlayCardRelation); }
/// <summary> /// 获取名片码 /// </summary> /// <returns></returns> public ActionResult GetMyCardCodeUrl() { returnObj = new Return_Msg_APP(); int userId = Context.GetRequestInt("userid", 0); int aid = Context.GetRequestInt("aid", 0); string pageUrl = Context.GetRequest("pageurl", ""); if (userId <= 0) { returnObj.Msg = "userid不能为空"; return(Json(returnObj)); } if (aid <= 0) { returnObj.Msg = "aid不能为空"; return(Json(returnObj)); } if (string.IsNullOrEmpty(pageUrl)) { returnObj.Msg = "名片路径不能为空"; return(Json(returnObj)); } PlatMyCard myCard = PlatMyCardBLL.SingleModel.GetModelByUserId(userId); if (myCard == null) { returnObj.Msg = "名片过期"; return(Json(returnObj)); } //判断是否已有名片码 if (!string.IsNullOrEmpty(myCard.QrCodeImgUrl)) { returnObj.dataObj = myCard.QrCodeImgUrl; returnObj.isok = true; return(Json(returnObj)); } XcxAppAccountRelation xcxrelation = _xcxAppAccountRelationBLL.GetModel(aid); if (xcxrelation == null) { returnObj.Msg = "模板过期"; return(Json(returnObj)); } //XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId); //if (xcxTemplate == null) //{ // returnObj.Msg = "无效模板"; // return Json(returnObj); //} string token = ""; if (!XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token)) { returnObj.Msg = token; return(Json(returnObj)); } string scen = $"{userId}"; qrcodeclass qrCodeModel = CommondHelper.GetMiniAppQrcode(token, pageUrl, scen); if (qrCodeModel == null || string.IsNullOrEmpty(qrCodeModel.url)) { returnObj.Msg = qrCodeModel == null?"生成名片码失败": qrCodeModel.msg + "失败"; return(Json(returnObj)); } myCard.QrCodeImgUrl = qrCodeModel.url; myCard.UpdateTime = DateTime.Now; PlatMyCardBLL.SingleModel.Update(myCard, "QrCodeImgUrl,UpdateTime"); returnObj.dataObj = myCard.QrCodeImgUrl; returnObj.isok = true; return(Json(returnObj)); }
/// <summary> /// 获取帖子评论列表 /// </summary> /// <param name="aid"></param> /// <param name="totalCount"></param> /// <param name="DataType"></param> /// <param name="keyMsg"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="Id">帖子Id 可空 如果大于0则表示是获取某条帖子的</param> /// <param name="userId">用户Id 获取用户帖子所属评论</param> /// <returns></returns> public List <PlatMsgComment> GetPlatMsgComment(int aid, out int totalCount, int DataType = 0, string keyMsg = "", int pageSize = 10, int pageIndex = 1, int Id = 0, int userId = 0) { string strWhere = $"aid={aid} and State=0 and DataType={DataType} "; List <MySqlParameter> parameters = new List <MySqlParameter>(); if (userId > 0) { strWhere += $" and UserId={userId} "; } if (Id > 0) { strWhere += $" and MsgId={Id}"; } if (!string.IsNullOrEmpty(keyMsg)) { strWhere += $" and CommentDetail like @keyMsg "; parameters.Add(new MySqlParameter("keyMsg", $"%{keyMsg}%")); } // log4net.LogHelper.WriteInfo(this.GetType(),strWhere); totalCount = base.GetCount(strWhere, parameters.ToArray()); List <PlatMsgComment> listPlatMsgComment = base.GetListByParam(strWhere, parameters.ToArray(), pageSize, pageIndex, "*", " AddTime Desc"); if (listPlatMsgComment != null && listPlatMsgComment.Count > 0) { listPlatMsgComment.ForEach(x => { PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModelByUserId(x.UserId, aid); if (platMyCard != null) { x.NickName = platMyCard.Name; x.HeaderImg = platMyCard.ImgUrl; } else { C_UserInfo c_UserInfoFrom = C_UserInfoBLL.SingleModel.GetModel(x.UserId); if (c_UserInfoFrom != null) { x.NickName = c_UserInfoFrom.NickName; x.HeaderImg = c_UserInfoFrom.HeadImgUrl; } } PlatMyCard platMyCardTo = PlatMyCardBLL.SingleModel.GetModel(x.ToUserId); if (platMyCardTo != null) { x.ToNickName = platMyCardTo.Name; x.ToHeaderImg = platMyCardTo.ImgUrl; } else { C_UserInfo c_UserInfo = C_UserInfoBLL.SingleModel.GetModel(x.ToUserId); if (c_UserInfo != null) { x.NickName = c_UserInfo.NickName; x.HeaderImg = c_UserInfo.HeadImgUrl; } } PlatMsg platMsg = PlatMsgBLL.SingleModel.GetModel(x.MsgId); if (platMsg != null) { x.MsgTxt = platMsg.MsgDetail.Length > 20 ? platMsg.MsgDetail.Substring(0, 20) + "..." : platMsg.MsgDetail; x.MsgFirstImg = platMsg.Imgs == null ? "" : platMsg.ImgList.FirstOrDefault(); } x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime); }); } return(listPlatMsgComment); }
/// <summary> /// 获取首页轮播图以及推荐商家 /// </summary> /// <returns></returns> public ActionResult GetConfig() { returnObj = new Return_Msg_APP(); returnObj.code = "200"; string appId = Context.GetRequest("appId", string.Empty); if (string.IsNullOrEmpty(appId)) { returnObj.Msg = "参数错误"; return(Json(returnObj)); } int pageIndexAdImg = Context.GetRequestInt("pageIndexAdImg", 1); int pageSizeAdImg = Context.GetRequestInt("pageSizeAdImg", 10); int pageIndexTjStore = Context.GetRequestInt("pageIndexTjStore", 1); int pageSizeTjStore = Context.GetRequestInt("pageSizeTjStore", 20); XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId); if (r == null) { returnObj.Msg = "小程序未授权"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } string appname = ""; OpenAuthorizerConfig openonfigmodel = OpenAuthorizerConfigBLL.SingleModel.GetModelByAppids(r.AppId); if (openonfigmodel != null) { appname = openonfigmodel.nick_name; } else { UserXcxTemplate userXcxModel = UserXcxTemplateBLL.SingleModel.GetModelByAppId(r.AppId); appname = userXcxModel?.Name; } int adImgCount, tjStoreCount = 0; List <PlatConfig> listADImg = PlatConfigBLL.SingleModel.getListByaid(r.Id, out adImgCount, 0, pageSizeAdImg, pageIndexAdImg); List <PlatConfig> listTjStore = PlatConfigBLL.SingleModel.getListByaid(r.Id, out tjStoreCount, 1, pageSizeTjStore, pageIndexTjStore); string lngStr = Context.GetRequest("lng", string.Empty); string latStr = Context.GetRequest("lat", string.Empty); double lng = 0.00; double lat = 0.00; string curLocation = "未知城市"; int curCityCode = 0; if (!double.TryParse(lngStr, out lng) || !double.TryParse(latStr, out lat)) { string IP = WebHelper.GetIP(); IPToPoint iPToPoint = CommondHelper.GetLoctionByIP(IP); if (iPToPoint != null) { lat = iPToPoint.result.location.lat; lng = iPToPoint.result.location.lng; lngStr = lng.ToString(); latStr = lat.ToString(); //log4net.LogHelper.WriteInfo(this.GetType(), $"IP={IP};{lat},{lng}"); } } AddressApi addressinfo = AddressHelper.GetAddressByApi(lngStr, latStr); // log4net.LogHelper.WriteInfo(this.GetType(), Newtonsoft.Json.JsonConvert.SerializeObject(addressinfo)); if (addressinfo != null && addressinfo.result != null && addressinfo.result.address_component != null) { curLocation = addressinfo.result.address_component.city; curCityCode = C_AreaBLL.SingleModel.GetCodeByName(curLocation); } listTjStore.ForEach(x => { x.ObjName = x.ObjName.Length > 6 ? (x.ObjName.Substring(0, 5) + "...") : x.ObjName; }); PlatConfig platConfigRemark = PlatConfigBLL.SingleModel.GetPlatConfig(r.Id, 3); var remarkObj = new { haveRemark = false, remark = string.Empty, remarkOpenFrm = false }; if (platConfigRemark != null && !string.IsNullOrEmpty(platConfigRemark.ADImg)) { remarkObj = new { haveRemark = true, remark = platConfigRemark.ADImg, remarkOpenFrm = platConfigRemark.ObjId == 0 }; } PlatConfig platOther = PlatConfigBLL.SingleModel.GetPlatConfig(r.Id, 5);//获取平台其它设置 if (platOther == null) { platOther = new PlatConfig() { Aid = r.Id, AddTime = DateTime.Now, ConfigType = 5 }; } PlatOtherConfig platOtherConfig = new PlatOtherConfig(); platOtherConfig.VirtualPV = platOther.ADImgType; platOtherConfig.VirtualPlatMsgCount = platOther.ObjId; platOtherConfig.PlatMsgCount = PlatMsgBLL.SingleModel.GetCountByAId(r.Id); platOtherConfig.PV = PlatStatisticalFlowBLL.SingleModel.GetPVCount(r.Id); int totalPV = platOtherConfig.VirtualPV + platOtherConfig.PV; int totalMsgCout = platOtherConfig.PlatMsgCount + platOtherConfig.VirtualPlatMsgCount; PlatConfig platOfficialAccount = PlatConfigBLL.SingleModel.GetPlatConfig(r.Id, 6);//获取关注公众号设置 if (platOfficialAccount == null) { platOfficialAccount = new PlatConfig() { Aid = r.Id, AddTime = DateTime.Now, ConfigType = 6 }; } returnObj.dataObj = new { appname = appname, ADImgs = new { totalCount = adImgCount, list = listADImg }, TjStores = new { totalCount = tjStoreCount, list = listTjStore }, Location = new { curLocation = curLocation, curCityCode = curCityCode }, platConfigRemark = remarkObj, platOtherConfig = new { TotalPV = totalPV > 100000?Convert.ToInt32(totalPV * 0.0001).ToString() + "万+": totalPV.ToString(), TotalMsgCount = totalMsgCout > 100000? Convert.ToInt32(totalMsgCout * 0.0001).ToString() + "万+": totalMsgCout.ToString() }, platOfficialAccount = platOfficialAccount }; returnObj.isok = true; returnObj.Msg = "获取成功"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); }
public ActionResult SaveUserInfo() { Return_Msg_APP result = new Return_Msg_APP(); string password = Utility.IO.Context.GetRequest("password", string.Empty); string phone = Utility.IO.Context.GetRequest("phone", string.Empty); string code = Utility.IO.Context.GetRequest("code", string.Empty); string address = Utility.IO.Context.GetRequest("address", string.Empty); string sourcefrom = Utility.IO.Context.GetRequest("sourcefrom", ""); int agentqrcodeid = Utility.IO.Context.GetRequestInt("agentqrcodeid", 0); result.isok = false; if (string.IsNullOrEmpty(phone)) { result.Msg = "请输入手机号"; return(Json(result, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(code)) { result.Msg = "请输入验证码"; return(Json(result, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(password)) { result.Msg = "请输入密码"; return(Json(result, JsonRequestBehavior.AllowGet)); } if (sourcefrom.Length > 20) { result.Msg = "无效来源"; return(Json(result, JsonRequestBehavior.AllowGet)); } if (!string.IsNullOrEmpty(phone)) { Account tempaccout = AccountBLL.SingleModel.GetModelByPhone(phone); if (tempaccout != null) { result.Msg = "该手机号已被注册"; return(Json(result, JsonRequestBehavior.AllowGet)); } } //是否校验手机号,0检验,1不校验 //校验验证码 Return_Msg _msg = CommondHelper.CheckVaildCode(phone, code); result.isok = _msg.isok; result.Msg = _msg.Msg; result.code = _msg.code; result.dataObj = _msg.dataObj; if (!result.isok) { return(Json(result, JsonRequestBehavior.AllowGet)); } Account account = null; //如果是代理分销扫描注册,测判断绑定的手机号是否已经注册过账号,如果没有则注册一个账号 if (agentqrcodeid > 0) { account = AccountBLL.SingleModel.GetModelByPhone(phone); } if (account == null) { account = AccountBLL.SingleModel.WeiXinRegister("", 0, "", true, address, phone, sourcefrom, password); } else { //修改已经注册过的用户信息 AccountBLL.SingleModel.UpdateUserInfo(account.Id.ToString(), phone, password, address); } if (account != null) { //用户已绑定手机号,判断是否有单页版 XcxAppAccountRelation usertemplate = _xcxAppAccountRelationBLL.GetModelByStringId(account.Id.ToString()); if (usertemplate == null) { //免费开通单页版 _xcxAppAccountRelationBLL.AddFreeTemplate(account); } //如果是扫分销代理码注册,则开通代理, if (agentqrcodeid > 0) { result.Msg = _agentDistributionRelationBLL.CreateDistributionAgent(account.Id.ToString(), agentqrcodeid); if (result.Msg.ToString() != "") { return(Json(result, JsonRequestBehavior.AllowGet)); } } result.isok = true; result.Msg = "注册成功"; } else { result.isok = false; result.Msg = "注册失败"; } string key = string.Format(_resetPasswordkey, phone); RedisUtil.Remove(key); return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取帖子列表 排列顺序为 置顶未失效>时间降序 /// 然后再到前端进行排序 如果时间按照最近则不需要排序 /// 如果是按距离则再排一次先是置顶的然后 距离有限 再按时间降序 /// </summary> /// <param name="aid"></param> /// <param name="totalCount"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <returns></returns> public List <PlatMsg> GetListMsg(int aid, out int totalCount, string keyMsg = "", int msgTypeId = 0, int pageSize = 10, int pageIndex = 1, int orderType = 0, double ws_lat = 0, double ws_lng = 0) { string strWhere = $" aid={aid} and state=1 and PayState=1 "; if (msgTypeId > 0) { strWhere += $" and MsgTypeId={msgTypeId} "; } List <MySqlParameter> parameters = new List <MySqlParameter>(); if (!string.IsNullOrEmpty(keyMsg)) { strWhere += $" and msgDetail like @keyMsg "; parameters.Add(new MySqlParameter("keyMsg", $"%{keyMsg}%")); } totalCount = base.GetCount(strWhere, parameters.ToArray()); string sql = $@"SELECT * FROM( SELECT * FROM (SELECT *,(DATE_ADD(ReviewTime,INTERVAL topDay DAY)-now()) as tspan from platmsg where (DATE_ADD(ReviewTime,INTERVAL topDay DAY)-now())>0 and { strWhere} ORDER BY addtime desc LIMIT 100000)t1 UNION SELECT* FROM( SELECT*, (DATE_ADD(ReviewTime, INTERVAL topDay DAY)-now()) as tspan from platmsg where (DATE_ADD(ReviewTime, INTERVAL topDay DAY) - now()) <= 0 and { strWhere} ORDER BY addtime desc LIMIT 100000) t2 ) t3 limit {(pageIndex - 1) * pageSize},{pageSize}"; if (orderType > 0) {//表示附近 sql = $@"SELECT * FROM( SELECT * FROM (SELECT *,(DATE_ADD(ReviewTime,INTERVAL topDay DAY)-now()) as tspan,ROUND(6378.138*2*ASIN(SQRT(POW(SIN(({ws_lat}*PI()/180-lat*PI()/180)/2),2)+COS({ws_lat}*PI()/180)*COS(lat*PI()/180)*POW(SIN(({ws_lng}*PI()/180-lng*PI()/180)/2),2)))*1000) AS distance from platmsg where (DATE_ADD(ReviewTime,INTERVAL topDay DAY)-now())>0 and { strWhere} ORDER BY distance asc,addtime desc LIMIT 100000)t1 UNION SELECT* FROM( SELECT*, (DATE_ADD(ReviewTime, INTERVAL topDay DAY)-now()) as tspan,ROUND(6378.138*2*ASIN(SQRT(POW(SIN(({ws_lat}*PI()/180-lat*PI()/180)/2),2)+COS({ws_lat}*PI()/180)*COS(lat*PI()/180)*POW(SIN(({ws_lng}*PI()/180-lng*PI()/180)/2),2)))*1000) AS distance from platmsg where (DATE_ADD(ReviewTime, INTERVAL topDay DAY) - now()) <= 0 and { strWhere} ORDER BY distance asc, addtime desc LIMIT 100000) t2 ) t3 limit {(pageIndex - 1) * pageSize},{pageSize}"; } // log4net.LogHelper.WriteInfo(this.GetType(),sql); List <PlatMsg> listPlatMsg = base.GetListBySql(sql, parameters.ToArray()); if (listPlatMsg != null && listPlatMsg.Count > 0) { string cardIds = string.Join(",", listPlatMsg.Select(s => s.MyCardId).Distinct()); List <PlatMyCard> platMyCardList = PlatMyCardBLL.SingleModel.GetListByIds(cardIds); string msgTypeIds = string.Join(",", listPlatMsg.Select(s => s.MsgTypeId).Distinct()); List <PlatMsgType> platMsgTypeList = PlatMsgTypeBLL.SingleModel.GetListByIds(msgTypeIds); listPlatMsg.ForEach(x => { //获取用户头像 PlatMyCard platMyCard = platMyCardList?.FirstOrDefault(f => f.Id == x.MyCardId); if (platMyCard != null) { x.UserName = platMyCard.Name; x.UserHeaderImg = platMyCard.ImgUrl; x.UserId = platMyCard.UserId; } //获取帖子类别 PlatMsgType platMsgType = platMsgTypeList?.FirstOrDefault(f => f.Id == x.MsgTypeId); if (platMsgType != null) { x.MsgTypeName = platMsgType.Name; } //根据帖子ID获取其浏览量-收藏量-分享量数据 PlatMsgviewFavoriteShare _platMsgviewFavoriteShare = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(x.Aid, x.Id, (int)PointsDataType.帖子); if (_platMsgviewFavoriteShare != null) { x.ViewCount = _platMsgviewFavoriteShare.ViewCount; x.FavoriteCount = _platMsgviewFavoriteShare.FavoriteCount; x.ShareCount = _platMsgviewFavoriteShare.ShareCount; x.DzCount = _platMsgviewFavoriteShare.DzCount; } x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime); x.MsgDetail = HttpUtility.HtmlDecode(x.MsgDetail); }); } totalCount = base.GetCount(strWhere, parameters.ToArray()); return(listPlatMsg); }
/// <summary> /// 获取用户收藏帖子列表 /// </summary> /// <param name="aid"></param> /// <param name="userId"></param> /// <param name="totalCount"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <returns></returns> public List <PlatMsg> GetListMyFavoriteMsg(int aid, int myCardId, out int totalCount, int pageSize = 10, int pageIndex = 1) { string strWhere = $"aid={aid} and userId={myCardId} and state=0 and actionType={(int)PointsActionType.收藏} and Datatype={(int)PointsDataType.帖子}"; totalCount = base.GetCount(strWhere); List <PlatMsg> listPlatMsg = new List <PlatMsg>(); List <PlatUserFavoriteMsg> listPlatUserFavoriteMsg = base.GetList(strWhere, pageSize, pageIndex, "*", "addTime desc"); if (listPlatUserFavoriteMsg != null && listPlatUserFavoriteMsg.Count > 0) { List <string> listMsgId = new List <string>(); foreach (var item in listPlatUserFavoriteMsg) { listMsgId.Add(item.MsgId.ToString());//获取到需要获取帖子的Id } if (listMsgId != null && listMsgId.Count > 0) { listPlatMsg = PlatMsgBLL.SingleModel.GetListByIds(aid, string.Join(",", listMsgId.ToArray())); if (listPlatMsg != null && listPlatMsg.Count > 0) { string cardIds = string.Join(",", listPlatMsg.Select(s => s.MyCardId).Distinct()); List <PlatMyCard> platMyCardList = PlatMyCardBLL.SingleModel.GetListByIds(cardIds); string msgTypeIds = string.Join(",", listPlatMsg.Select(s => s.MsgTypeId).Distinct()); List <PlatMsgType> platMsgTypeList = PlatMsgTypeBLL.SingleModel.GetListByIds(msgTypeIds); listPlatMsg.ForEach(x => { //获取用户头像 PlatMyCard platMyCard = platMyCardList?.FirstOrDefault(f => f.Id == x.MyCardId); if (platMyCard != null) { x.UserName = platMyCard.Name; x.UserHeaderImg = platMyCard.ImgUrl; } //获取帖子类别 PlatMsgType platMsgType = platMsgTypeList?.FirstOrDefault(f => f.Id == x.MsgTypeId); if (platMsgType != null) { x.MsgTypeName = platMsgType.Name; } //根据帖子ID获取其浏览量-收藏量-分享量数据 PlatMsgviewFavoriteShare _platMsgviewFavoriteShare = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(x.Aid, x.Id, (int)PointsDataType.帖子); if (_platMsgviewFavoriteShare != null) { x.ViewCount = _platMsgviewFavoriteShare.ViewCount; x.FavoriteCount = _platMsgviewFavoriteShare.FavoriteCount; x.ShareCount = _platMsgviewFavoriteShare.ShareCount; x.DzCount = _platMsgviewFavoriteShare.DzCount; } x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime); x.FavoriteId = listPlatUserFavoriteMsg.FirstOrDefault(y => y.MsgId == x.Id).Id;//收藏记录ID }); } } } return(listPlatMsg); }