/// <summary> /// 添加用户微信群 /// </summary> /// <param name="model">The model.</param> /// <returns>System.Int32.</returns> public int AddUserWeChatGroup(weChatGroupModel model) { var data = FindByUserWeChatGroup(model.title, model.userid); string strSql = ""; long id = 0; if (data == null) { strSql = @"INSERT INTO user_wechat_group (userid,title,pid) VALUES(@userid,@title,@pid);select last_insert_rowid(); "; } else { id = data.id; strSql = @"UPDATE user_wechat_group SET title=@title, pid =@pid WHERE id = @id and userid=@userid;"; } var param = new[] { new SQLiteParameter("@userid", model.userid), new SQLiteParameter("@title", model.title), new SQLiteParameter("@pid", model.pid), new SQLiteParameter("@id", id) }; return(DBHelper.ExecuteSql(strSql, param)); }
/// <summary> /// 修改微信群 /// </summary> /// <param name="model">The model.</param> /// <returns>true if XXXX, false otherwise.</returns> public bool UpdateUserWeChatGroup(weChatGroupModel model) { string strSql = @"UPDATE user_wechat_group SET title=@title, pid =@pid WHERE id = @id and userid=@userid;"; var param = new[] { new SQLiteParameter("@userid", model.userid), new SQLiteParameter("@title", model.title), new SQLiteParameter("@pid", model.pid), new SQLiteParameter("@id", model.id) }; return(DBHelper.ExecuteSql(strSql, param) > 0); }
public bool UpdateUserWeChatTitle(int userid, int groupid, string title, string pid) { weChatGroupModel model = new weChatGroupModel() { id = groupid, pid = pid, title = title, userid = userid }; if (groupid > 0) { return(UpdateUserWeChatGroup(model)); } else { return(AddUserWeChatGroup(model) > 0); } }
/// <summary> /// 修改微信群 /// </summary> /// <param name="model">The model.</param> /// <returns>true if XXXX, false otherwise.</returns> public bool UpdateUserWeChatGroup(weChatGroupModel model) { return(dal.UpdateUserWeChatGroup(model)); }
/// <summary> /// 添加用户微信群 /// </summary> /// <param name="model">The model.</param> /// <returns>System.Int32.</returns> public int AddUserWeChatGroup(weChatGroupModel model) { return(dal.AddUserWeChatGroup(model)); }
/// <summary> ///生成商品文案 /// </summary> /// <param name="userid">The userid.</param> /// <param name="taskid">The taskid.</param> /// <param name="templateText">The template text.</param> /// <param name="data">The data.</param> /// <param name="group">The group.</param> /// <returns>true if XXXX, false otherwise.</returns> private bool BuildShareText(string loginToken, int userid, int taskid, string templateText, List <GoodsModel> data, weChatGroupModel group, string appkey, string appsecret, Action <weChatShareTextModel> result = null) { if (data == null) { return(false); } weChatShareTextModel share = new weChatShareTextModel() { userid = userid, taskid = taskid, status = -1, title = group.title }; foreach (var item in data) { if (item.goodsPrice - item.couponPrice <= 0) { continue; } string url = GlobalConfig.couponUrl; url += "?src=ht_hot&activityId=" + item.couponId; url += "&itemId=" + item.goodsId.Replace("=", ""); url += "&pid=" + (string.IsNullOrEmpty(group.pid) ? "mm_33648229_22032774_73500078" : group.pid); item.shareLink = url; string shortUrl = string.Empty; //将淘口令改成pid,2017-04-07 修改,淘口令改到分享时生产 string tpwd = (string.IsNullOrEmpty(group.pid) ? "mm_33648229_22032774_73500078" : group.pid);// "[二合一淘口令]";// HotTaoApiService.Instance.taobao_wireless_share_tpwd_create(item.goodsMainImgUrl, item.shareLink, item.goodsName, appkey, appsecret); string text = templateText; //if (text.Contains("[短链接]")) //{ // shortUrl = HotTaoApiService.Instance.buildShortUrl(loginToken, tpwd, url, item.goodsName, item.goodsMainImgUrl); // if (string.IsNullOrEmpty(shortUrl)) // shortUrl = HotTaoApiService.Instance.taobao_tbk_spread_get(item.shareLink, appkey, appsecret); //} if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(tpwd)) { if (text.Contains("[商品标题]")) { text = text.Replace("[商品标题]", item.goodsName); } if (text.Contains("[商品价格]")) { text = text.Replace("[商品价格]", item.goodsPrice.ToString()); } if (text.Contains("[券后价格]")) { text = text.Replace("[券后价格]", (item.goodsPrice - item.couponPrice).ToString()); } //while (text.Contains("[二合一淘口令]")) // text = text.Replace("[二合一淘口令]", tpwd); //while (text.Contains("[短链接]")) // text = text.Replace("[短链接]", shortUrl); if (text.Contains("[来源]")) { text = text.Replace("[来源]", item.goodsSupplier); } if (text.Contains("[销量]")) { text = text.Replace("[销量]", item.goodsSalesAmount.ToString()); } if (text.Contains("[优惠券价格]")) { text = text.Replace("[优惠券价格]", item.couponPrice.ToString()); } if (text.Contains("[分隔符]")) { text = text.Replace("[分隔符]", "-----------------"); } if (text.Contains("[简介描述]")) { text = text.Replace("[简介描述]", string.IsNullOrEmpty(item.goodsIntro) ? "" : item.goodsIntro); } } else { share.status = 2; } share.goodsid = Convert.ToInt32(item.id); share.text = text; share.tpwd = tpwd; AddUserWechatSharetext(share); result?.Invoke(share); } return(true); }
/// <summary> /// 自动合成图片 /// </summary> /// <param name="loginToken"></param> /// <param name="wechatlist"></param> /// <param name="appkey"></param> /// <param name="appsecret"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <param name="JoinImageCount"></param> /// <returns></returns> public bool AutoJoinImage(string loginToken, List <UserWechatListModel> wechatlist, string appkey, string appsecret, DateTime startTime, DateTime endTime, int JoinImageCount) { string templateText = "[二合一淘口令]"; List <UserPidTaskModel> pidList = new List <UserPidTaskModel>(); List <UserPidTaskModel> goodsList = new List <UserPidTaskModel>(); //判断群是否存在 if (wechatlist == null || wechatlist.Count() <= 0) { return(false); } else { foreach (var item in wechatlist) { if (!pidList.Exists(r => r.id == item.id)) { pidList.Add(new UserPidTaskModel() { id = item.id }); } } } //获取需要合成图片的商品数据 var goodslist = FindByUserGoodsListThree(JoinImageCount); List <int> ids = new List <int>(); if (goodslist != null && goodslist.Count() == JoinImageCount) { foreach (var item in goodslist) { if (!goodsList.Exists(r => r.id == Convert.ToInt32(item.id))) { goodsList.Add(new UserPidTaskModel() { id = Convert.ToInt32(item.id) }); } ids.Add(Convert.ToInt32(item.id)); } } else { return(false); } string goodsText = JsonConvert.SerializeObject(goodsList); string pidsText = JsonConvert.SerializeObject(pidList); TaskPlanModel model = new TaskPlanModel() { userid = uid, title = "【合成图片转发】", startTime = startTime, endTime = endTime, pidsText = pidsText, goodsText = goodsText, id = 0, status = 0, isTpwd = 0 }; TaskPlanModel data = AddUserTaskPlan(model); if (data == null) { return(false); } List <JoinGoodsList> joinLists = new List <JoinGoodsList>(); foreach (var group in wechatlist) { weChatGroupModel g = new weChatGroupModel() { id = group.id, title = group.wechattitle, pid = group.pid, userid = group.userid }; JoinGoodsList joinList = new JoinGoodsList(); //生成商品分享文本 BuildShareText(loginToken, uid, Convert.ToInt32(data.id), templateText, goodslist, g, appkey, appsecret, out joinList, null, true); if (joinList != null) { joinLists.Add(joinList); } } int flag = BuildJoinImage(loginToken, joinLists, data.title, Convert.ToInt32(data.id), JoinImageCount); if (flag == 0) { UpdateUserTaskPlanIsTpwd(Convert.ToInt32(data.id)); UpdateGoodsJoinImageStatusByIds(uid, ids); } else { DeleteUserTaskPlan(flag); } return(false); }
/// <summary> ///生成商品文案 /// </summary> /// <param name="userid">The userid.</param> /// <param name="taskid">The taskid.</param> /// <param name="templateText">The template text.</param> /// <param name="data">The data.</param> /// <param name="group">The group.</param> /// <returns>true if XXXX, false otherwise.</returns> private bool BuildShareText(string loginToken, int userid, int taskid, string templateText, List <GoodsModel> data, weChatGroupModel group, string appkey, string appsecret, out JoinGoodsList joinList, Action <weChatShareTextModel> result = null, bool isJoinImage = false) { joinList = null; if (data == null) { return(false); } weChatShareTextModel share = new weChatShareTextModel() { userid = userid, taskid = taskid, status = -1, title = group.title }; if (isJoinImage) { joinList = new JoinGoodsList(); } List <int> ids = new List <int>(); List <JoinGoodsInfo> imageList = new List <JoinGoodsInfo>(); foreach (var item in data) { if (item.goodsPrice - item.couponPrice <= 0) { continue; } string url = GlobalConfig.couponUrl; url += "?src=ht_hot&activityId=" + item.couponId; url += "&itemId=" + item.goodsId.Replace("=", ""); url += "&pid=" + (string.IsNullOrEmpty(group.pid) ? "mm_33648229_22032774_73500078" : group.pid); item.shareLink = url; string shortUrl = string.Empty; //将淘口令改成pid,2017-04-07 修改,淘口令改到分享时生产 string tpwd = (string.IsNullOrEmpty(group.pid) ? "mm_33648229_22032774_73500078" : group.pid);// "[二合一淘口令]";// HotTaoApiService.Instance.taobao_wireless_share_tpwd_create(item.goodsMainImgUrl, item.shareLink, item.goodsName, appkey, appsecret); string text = templateText; if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(tpwd)) { if (text.Contains("[商品标题]")) { text = text.Replace("[商品标题]", item.goodsName); } if (text.Contains("[商品价格]")) { text = text.Replace("[商品价格]", item.goodsPrice.ToString()); } if (text.Contains("[券后价格]")) { text = text.Replace("[券后价格]", (item.goodsPrice - item.couponPrice).ToString()); } if (text.Contains("[来源]")) { text = text.Replace("[来源]", item.goodsSupplier); } if (text.Contains("[销量]")) { text = text.Replace("[销量]", item.goodsSalesAmount.ToString()); } if (text.Contains("[优惠券价格]")) { text = text.Replace("[优惠券价格]", item.couponPrice.ToString()); } if (text.Contains("[分隔符]")) { text = text.Replace("[分隔符]", "-----------------"); } if (text.Contains("[简介描述]")) { text = text.Replace("[简介描述]", string.IsNullOrEmpty(item.goodsIntro) ? "" : item.goodsIntro); } if (text.Contains("[商品地址]")) { text = text.Replace("[商品地址]", item.goodsDetailUrl); } if (text.Contains("[优惠券地址]")) { text = text.Replace("[优惠券地址]", item.couponUrl); } } else { share.status = 2; } share.goodsid = Convert.ToInt32(item.id); share.text = text; share.tpwd = tpwd; share.field1 = item.goodslocatImgPath; if (isJoinImage) { string _url = GlobalConfig.couponUrl; _url += "?src=ht_hot&activityId=" + item.couponId; _url += "&itemId=" + item.goodsId.Replace("=", ""); _url += "&pid=" + tpwd; var _tpwd = ""; share.field2 = _tpwd; bool isLogin = true; Tuple <string, string> resultTuple = TaobaoHelper.GetGaoYongToken(item.goodsDetailUrl, item.goodsId, tpwd, MyUserInfo.GetTbToken(), MyUserInfo.cookies, out isLogin); string shareText = ""; if (resultTuple != null) { if (isLogin) { shareText = resultTuple.Item1; } } //商品数据 joinList.collectionGoodsList.Add(new CollectionGoods() { goodsId = item.goodsId, goodsName = item.goodsName, price = item.goodsPrice, discountAmount = item.couponPrice, goodsPromotionUrl = _url, goodsPrimaryImg = item.goodsMainImgUrl, shareText = shareText }); //图片 joinList.ImageList.Add(new JoinGoodsInfo() { GoodsName = item.goodsName, GoodsPrice = item.goodsPrice, CouponPrice = item.couponPrice, imagePath = item.goodslocatImgPath, GoodsIntro = item.goodsIntro }); } share.field6 = isJoinImage ? 1 : 0; share.field3 = group.id.ToString(); AddUserWechatSharetext(share); result?.Invoke(share); } if (isJoinImage) { joinList.TaskId = taskid; joinList.id = Convert.ToInt32(group.id); } return(true); }