public ResultDTO BindWeChatQrCodeExt(SpreadBindWeChatQrCodeDTO search) { if (search == null || search.Id == Guid.Empty || search.AppId == Guid.Empty) { return new ResultDTO { ResultCode = 1, Message = "参数为空" } } ; try { ContextSession contextSession = ContextFactory.CurrentThreadContext; var spreadInfo = SpreadInfo.ObjectSet().FirstOrDefault(c => c.IsDel != 1 && c.Id == search.Id); if (spreadInfo == null) { return new ResultDTO { ResultCode = 2, Message = "推广主不存在" } } ; var weChatQrCode = WeChatQRCode.ObjectSet().Where(c => c.AppId == search.AppId && c.IsDel != 1 && !c.IsUse && c.QRType.Value == search.QRType && c.QRNo == search.QRNo).FirstOrDefault(); if (weChatQrCode == null) { return new ResultDTO { ResultCode = 3, Message = "没有找到可使用的带参数二维码,请到“App后台-微信公众号”中生成二维码" } } ; weChatQrCode.SpreadInfoId = search.Id; weChatQrCode.IsUse = true; weChatQrCode.Name = getQrCodeName(spreadInfo); weChatQrCode.ModifiedOn = DateTime.Now; weChatQrCode.EntityState = EntityState.Modified; contextSession.SaveChanges(); return(new ResultDTO { isSuccess = true, Message = "success" }); } catch (Exception ex) { LogHelper.Error(string.Format("SpreadInfoBP.BindWeChatQrCodeExt异常,dto={0}", JsonHelper.JsonSerializer(search)), ex); return(new ResultDTO { ResultCode = 1, Message = "Error" }); } }
/// <summary> /// 时间处理 /// </summary> /// <returns></returns> protected virtual void DealEvent() { if (string.IsNullOrEmpty(Log.Ticket)) { return; } var qrcode = WeChatQRCode.ObjectSet().FirstOrDefault(c => c.QRType.Value == (int)QrType.SpreadManager && c.WeChatTicket == Log.Ticket); if (qrcode == null || qrcode.SpreadInfoId == Guid.Empty) { return; } var url = SpreadInfo.ObjectSet().Where(c => c.Id == qrcode.SpreadInfoId).Select(c => c.SpreadUrl).FirstOrDefault(); Jinher.AMP.WCP.Deploy.CustomDTO.CusNewsPushDTO msgDto = new CusNewsPushDTO() { AppId = CustomConfig.WeChatSpreader.AppId.ToString(), Content = getMessageContent(url), }; WCPSV.Instance.PushSysMessageToUsers(msgDto); }
public ResultDTO <ListResult <SpreadInfoShowDTO> > GetSpreadInfoListExt(SpreadSearchDTO search) { if (search == null) { return new ResultDTO <ListResult <SpreadInfoShowDTO> > { ResultCode = 1, Message = "参数为空" } } ; if (search.PageIndex == 0) { search.PageIndex = 1; } if (search.PageSize == 0) { search.PageSize = 20; } var query = SpreadInfo.ObjectSet().Where(c => c.IsDel != 1); if (search.SpreadType.HasValue) { query = query.Where(c => c.SpreadType == search.SpreadType.Value); } if (!string.IsNullOrEmpty(search.UserCode)) { query = query.Where(c => c.UserCode.Contains(search.UserCode)); } if (search.SpreadAppId.HasValue && search.SpreadAppId != Guid.Empty) { query = query.Where(c => c.SpreadAppId == search.SpreadAppId.Value); } if (search.IWId.HasValue) { query = query.Where(c => c.IWId == search.IWId.Value); } ListResult <SpreadInfoShowDTO> data = new ListResult <SpreadInfoShowDTO> { List = new List <SpreadInfoShowDTO>() }; data.Count = query.Count(); data.List = query.OrderByDescending(c => c.SubTime).Skip((search.PageIndex - 1) * search.PageSize). Take(search.PageSize).Select(c => new SpreadInfoShowDTO { Id = c.Id, SpreadId = c.SpreadId, Account = c.UserCode, Name = c.Name, SpreadType = c.SpreadType, SpreadAppId = c.SpreadAppId, HotshopId = c.HotshopId, QrCodeUrl = c.QrCodeUrl, SpreadDesc = c.SpreadDesc, SpreadUrl = c.SpreadUrl, SubTime = c.SubTime, IsDel = c.IsDel, HotshopName = "", IsBindWeChatQrCode = false, SpreadAppName = "", SpreadTypeDesc = "", IWCode = c.IWCode, SubSpreadCount = c.SubSpreadCount, DividendPercent = c.DividendPercent }).ToList(); if (data.List.Any()) { var spreadTypes = data.List.Select(c => c.SpreadType).Distinct().ToList(); var spreadCategoryList = SpreadCategory.ObjectSet() .Where(c => spreadTypes.Contains(c.SpreadType)) .Select(m => new SpreadCategoryDTO { SpreadType = m.SpreadType, CategoryDesc = m.CategoryDesc }).ToList(); var ids = data.List.Select(c => c.Id).ToList(); var bindedIds = WeChatQRCode.ObjectSet().Where(c => ids.Contains(c.SpreadInfoId)).Select(m => m.SpreadInfoId).ToList(); var appIds = data.List.Select(c => c.SpreadAppId).Distinct().ToList(); appIds.AddRange(data.List.Select(c => c.HotshopId)); appIds = appIds.Distinct().ToList(); var appDict = APPSV.GetAppNameListByIds(appIds); foreach (var spreadInfoShowDTO in data.List) { if (appDict.ContainsKey(spreadInfoShowDTO.SpreadAppId)) { spreadInfoShowDTO.SpreadAppName = appDict[spreadInfoShowDTO.SpreadAppId]; } if (appDict.ContainsKey(spreadInfoShowDTO.HotshopId)) { spreadInfoShowDTO.HotshopName = appDict[spreadInfoShowDTO.HotshopId]; } var spreadTypeDto = spreadCategoryList.FirstOrDefault(c => c.SpreadType == spreadInfoShowDTO.SpreadType); if (spreadTypeDto != null) { spreadInfoShowDTO.SpreadTypeDesc = spreadTypeDto.CategoryDesc; } if (bindedIds.Contains(spreadInfoShowDTO.Id)) { spreadInfoShowDTO.IsBindWeChatQrCode = true; } } } return(new ResultDTO <ListResult <SpreadInfoShowDTO> > { isSuccess = true, Message = "success", Data = data }); }
private ResultDTO <ListResult <WeChatQRCodeShowDTO> > GetWechatQrCodeListExt(WeChatQRCodeSearchDTO search) { var result = new ListResult <WeChatQRCodeShowDTO>(); //var query = BE.WeChatQRCode.ObjectSet().Where(c => c.IsDel != 1 && c.AppId == search.AppId); var query = from code in WeChatQRCode.ObjectSet() join type in WeChatQrCodeType.ObjectSet() on code.QRType.Value equals type.Type where code.IsDel != 1 && code.AppId == search.AppId select new { Id = code.Id, WeChatPublicCode = code.WeChatPublicCode, AppId = code.AppId, QRNo = code.QRNo, WeChatTicket = code.WeChatTicket, StoreId = code.StoreId, IsDel = code.IsDel, IsUse = code.IsUse, SpreadInfoId = code.SpreadInfoId, Description = code.Description, QRType = code.QRType, SubTime = code.SubTime, QRTypeDesc = type.Description, QRTypeUseType = type.UseTye, Name = code.Name }; if (search.QRType.HasValue) { query = query.Where(q => q.QRType.Value == search.QRType.Value); } //else if (!search.IsShowCatering) //{ // query = query.Where(c => c.QRTypeUseType != 1); //} if (!string.IsNullOrEmpty(search.WeChatPublicCode)) { query = query.Where(q => q.WeChatPublicCode == search.WeChatPublicCode); } if (search.IsUse.HasValue) { query = query.Where(q => q.IsUse == search.IsUse.Value); } result.Count = query.Count(); result.List = query.OrderByDescending(q => q.SubTime). Skip((search.PageIndex - 1) * search.PageSize). Take(search.PageSize). Select(q => new WeChatQRCodeShowDTO { Id = q.Id, WeChatPublicCode = q.WeChatPublicCode, AppId = q.AppId, QRNo = q.QRNo, WeChatTicket = q.WeChatTicket, StoreId = q.StoreId, IsDel = q.IsDel, IsUse = q.IsUse, SpreadInfoId = q.SpreadInfoId, Description = q.Description, QRType = q.QRType.Value, SubTime = q.SubTime, QrTypeDesc = q.QRTypeDesc, Name = q.Name }). ToList(); if (result.List.Any()) { foreach (var weChatQrCodeShowDTO in result.List) { if (string.IsNullOrEmpty(weChatQrCodeShowDTO.Name)) { weChatQrCodeShowDTO.Name = weChatQrCodeShowDTO.QRNo.ToString(CultureInfo.InvariantCulture); } } } return(new ResultDTO <ListResult <WeChatQRCodeShowDTO> >() { isSuccess = true, Data = result }); }