/// <summary> /// 添加时调用 /// </summary> /// <param name="model">The model.</param> public void SetView(weChatShareTextModel model) { if (dgvShareText.InvokeRequired) { this.Invoke(new Action <weChatShareTextModel>(SetView), new object[] { model }); } else { int i = dgvShareText.Rows.Count; dgvShareText.Rows.Add(); ++i; dgvShareText.Rows[i - 1].Cells["sharetitle"].Value = model.title; dgvShareText.Rows[i - 1].Cells["tpwd"].Value = "[二合一淘口令]"; dgvShareText.Rows[i - 1].Cells["shareText"].Value = model.text.ToString(); if (i % 2 == 0) { dgvShareText.Rows[i - 1].DefaultCellStyle.BackColor = ConstConfig.DataGridViewEvenRowBackColor; dgvShareText.Rows[i - 1].DefaultCellStyle.SelectionBackColor = ConstConfig.DataGridViewEvenRowBackColor; } else { dgvShareText.Rows[i - 1].DefaultCellStyle.BackColor = ConstConfig.DataGridViewOddRowBackColor; dgvShareText.Rows[i - 1].DefaultCellStyle.SelectionBackColor = ConstConfig.DataGridViewOddRowBackColor; } dgvShareText.Rows[i - 1].Height = ConstConfig.DataGridViewRowHeight; dgvShareText.Rows[i - 1].DefaultCellStyle.ForeColor = ConstConfig.DataGridViewRowForeColor; dgvShareText.CurrentCell = dgvShareText.Rows[dgvShareText.Rows.Count - 1].Cells[dgvShareText.CurrentCell.ColumnIndex]; } }
/// <summary> /// 添加微信分享数据 /// </summary> /// <param name="model">The model.</param> /// <returns>System.Int32.</returns> public int AddUserWechatSharetext(weChatShareTextModel model) { string strSql = @"INSERT INTO user_wechat_sharetext (userid,title,text,taskid,goodsid,status,tpwd) VALUES(@userid,@title,@text,@taskid,@goodsid,@status,@tpwd);select last_insert_rowid(); "; var param = new[] { new SQLiteParameter("@userid", model.userid), new SQLiteParameter("@title", model.title), new SQLiteParameter("@text", model.text), new SQLiteParameter("@taskid", model.taskid), new SQLiteParameter("@goodsid", model.goodsid), new SQLiteParameter("@status", model.status), new SQLiteParameter("@tpwd", model.tpwd) }; return(DBHelper.ExecuteSql(strSql, param)); }
/// <summary> /// 添加错误日志 /// </summary> /// <param name="item"></param> /// <param name="errorType">0 图片 1 文本</param> public void AddErrorLog(weChatShareTextModel item, int errorType) { new System.Threading.Thread(() => { //添加错误日志 LogicHotTao.Instance(MyUserInfo.currentUserId).AddUserWeChatError(new weChatUserWechatErrorModel() { userid = item.userid, title = item.title, shareText = item.text, createtime = DateTime.Now, errorType = errorType }); }) { IsBackground = true }.Start(); }
/// <summary> /// 添加微信分享数据 /// </summary> /// <param name="model">The model.</param> /// <returns>System.Int32.</returns> public int AddUserWechatSharetext(weChatShareTextModel model) { string strSql = @"INSERT INTO user_wechat_sharetext (userid,title,text,taskid,goodsid,status,tpwd,field1,field2,field3,field4,field5,field6,field7) VALUES(@userid,@title,@text,@taskid,@goodsid,@status,@tpwd,@field1,@field2,@field3,@field4,@field5,@field6,@field7);select last_insert_rowid(); "; var param = new[] { new SQLiteParameter("@userid", model.userid), new SQLiteParameter("@title", model.title), new SQLiteParameter("@text", model.text), new SQLiteParameter("@taskid", model.taskid), new SQLiteParameter("@goodsid", model.goodsid), new SQLiteParameter("@status", model.status), new SQLiteParameter("@tpwd", model.tpwd), new SQLiteParameter("@field1", model.field1), new SQLiteParameter("@field2", model.field2), new SQLiteParameter("@field3", model.field3), new SQLiteParameter("@field4", model.field4), new SQLiteParameter("@field5", model.field5), new SQLiteParameter("@field6", model.field6), new SQLiteParameter("@field7", model.field7) }; return(DBHelper.ExecuteSql(strSql, param)); }
/// <summary> /// 生产淘口令 /// </summary> /// <param name="currentUserId">The current user identifier.</param> /// <param name="LoginToken">The login token.</param> /// <param name="goods">The goods.</param> /// <param name="item">The item.</param> /// <param name="appkey">The appkey.</param> /// <param name="appsecret">The appsecret.</param> public bool BuildTpwd(int currentUserId, string LoginToken, GoodsModel goods, weChatShareTextModel item, string appkey, string appsecret) { if (item.status == -1) { string url = GlobalConfig.couponUrl; url += "?src=ht_hot&activityId=" + goods.couponId; url += "&itemId=" + goods.goodsId.Replace("=", ""); url += "&pid=" + item.tpwd; string shortUrl = ""; string tpwd = HotTaoApiService.Instance.taobao_wireless_share_tpwd_create(goods.goodsMainImgUrl, url, goods.goodsName, appkey, appsecret); if (!string.IsNullOrEmpty(tpwd)) { if (item.text.Contains("[短链接]")) { shortUrl = HotTaoApiService.Instance.buildShortUrl(LoginToken, tpwd, url, goods.goodsName, goods.goodsMainImgUrl); if (string.IsNullOrEmpty(shortUrl)) { shortUrl = HotTaoApiService.Instance.taobao_tbk_spread_get(url, appkey, appsecret); } } while (item.text.Contains("[二合一淘口令]")) { item.text = item.text.Replace("[二合一淘口令]", tpwd); } while (item.text.Contains("[短链接]")) { item.text = item.text.Replace("[短链接]", shortUrl); } item.status = 0; Instance(currentUserId).UpdateUserShareTextStatus(item.id, item.text, tpwd); return(true); } else { return(false); } } return(true); }
/// <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="model">The model.</param> /// <returns>System.Int32.</returns> public int AddUserWechatSharetext(weChatShareTextModel model) { return(dal.AddUserWechatSharetext(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, 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); }