///// <summary> ///// 清除店铺活动图片 ///// </summary> ///// <param name="sender"></param> ///// <param name="e"></param> //protected void Button2_Click(object sender, EventArgs e) //{ //} /// <summary> /// 增加活动图片到宝贝描述 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button3_Click(object sender, EventArgs e) { string appkey = "12159997"; string secret = "614e40bfdb96e9063031d1a9e56fbed5"; //保存到数据库 string name = utils.NewRequest("detail", utils.RequestType.Form); string istop = utils.NewRequest("detailimgistop", utils.RequestType.Form); string sql = "UPDATE TCS_ShopConfig SET detailimgname = '" + name + "', detailimgistop = '" + istop + "' WHERE nick = '" + nick + "'"; StringBuilder builder = new StringBuilder(); utils.ExecuteNonQuery(sql); //上传到宝贝描述 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); for (int j = 1; j <= 500; j++) { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid"; request.PageSize = 200; request.PageNo = j; PageList <Item> product = client.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { try { //获取商品详细 ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc"; requestItem.NumIid = product.Content[i].NumIid; Item item = client.ItemGet(requestItem, session); //判断是否增加过该图片 string newcontent = CreateDesc(item.Desc, istop); //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", product.Content[i].NumIid.ToString()); param.Add("desc", newcontent); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update", session, param); builder.Append("宝贝ID:" + product.Content[i].NumIid.ToString() + "\r\n" + resultpro + "\r\n"); } catch { } } if (product.Content.Count < 200) { break; } } File.WriteAllText(Server.MapPath("htmlLog/" + DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + nick + ".txt"), builder.ToString()); Response.Write("<script>alert('同步成功!');window.location.href='html.aspx';</script>"); Response.End(); return; }
private string GetItemHtml(string itemid) { string str = string.Empty; string appkey = "12159997"; string secret = "614e40bfdb96e9063031d1a9e56fbed5"; List <Item> itemList = new List <Item>(); TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); try { ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.NumIid = long.Parse(itemid); Item product = client.ItemGet(request); itemList.Add(product); //团购需要的商品数据 for (int i = 0; i < itemList.Count; i++) { str = "<div id=item_" + itemList[i].NumIid.ToString() + " style=\"float:left;width:46px;border:solid 1px #ccc;padding:2px;margin:2px;\"><A href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\"><IMG src=\"" + itemList[i].PicUrl + "_40x40.jpg\" border=0 title=\"" + itemList[i].Title + "\" /></A><br>" + itemList[i].Price + "<input type=\"hidden\" id=\"productid\" name=\"productid\" value=\"" + itemList[i].NumIid.ToString() + "\"><input type=\"hidden\" id=\"price\" name=\"price\" value=\"" + itemList[i].Price.ToString() + "\"><br><a href=\"javascript:delitem(" + itemList[i].NumIid.ToString() + ")\">删除</a></div>"; } } catch { } return(str); }
private string BindData(string items, string adsid) { string html = string.Empty; string total = string.Empty; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); string itemId = items; ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url,desc"; request.NumIid = long.Parse(itemId); Item product = client.ItemGet(request); //获取商品详细描述 html = product.Desc; //获取广告代码 string adsHtml = getAdsContent(ads); if (!Regex.IsMatch(html, @"<img alt=""tetesoft-area-start"" width=""0"" height=""0"">([\s\S]*)<img alt=""tetesoft-area-end"" width=""0"" height=""0"">")) { html += @"<img alt=""tetesoft-area-start"" width=""0"" height=""0"">" + adsHtml + @"<img alt=""tetesoft-area-end"" width=""0"" height=""0"">"; } else { html = Regex.Replace(html, @"<img alt=""tetesoft-area-start"" width=""0"" height=""0"">([\s\S]*)<img alt=""tetesoft-area-end"" width=""0"" height=""0"">", @"<img alt=""tetesoft-area-start"" width=""0"" height=""0"">" + adsHtml + @"<img alt=""tetesoft-area-end"" width=""0"" height=""0"">"); } return(html); }
private void DeleteTaobaAutoOld(string session) { string appkey = "12132145"; string secret = "1fdd2aadd5e2ac2909db2967cbb71e7f"; //上传到宝贝描述 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); for (int j = 1; j <= 3; j++) { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid"; request.PageSize = 200; request.PageNo = j; PageList <Item> product = client.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { try { //获取商品详细 ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc"; requestItem.NumIid = product.Content[i].NumIid; Item item = client.ItemGet(requestItem, session); //判断是否增加过该图片 string newcontent = CreateDescDel(item.Desc); //Response.Write(newcontent); if (newcontent == "") { continue; } //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", product.Content[i].NumIid.ToString()); param.Add("desc", newcontent); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update", session, param); Response.Write(product.Content[i].NumIid.ToString() + "----" + resultpro + "<br>"); //return; //return; } catch (Exception e) { Response.Write(e.Message); } } //Response.Write(product.Content.Count.ToString() + "<br>"); if (product.Content.Count < 200) { break; } } Response.Write("<script>alert('清除成功!');</script>"); Response.End(); }
/// <summary> /// 加入首页展示的评价信息 /// </summary> /// <param name="id"></param> private void InitTradeRateData(string id) { //根据商品ID获取商品详细信息 string sql = "SELECT itemid FROM TCS_TradeRate WHERE orderid = '" + id + "' AND nick = '" + nick + "'"; string itemid = utils.ExecuteString(sql); //发送请求获取 string appkey = "12690738"; string secret = "66d488555b01f7b85f93d33bc2a1c001"; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); ItemGetRequest request = new ItemGetRequest(); request.Fields = "title,price,pic_url"; request.NumIid = long.Parse(itemid); Item product = new Item(); try { product = client.ItemGet(request, session); } catch { } //获取最近30天商品售出数量 sql = "SELECT COUNT(*) FROM TCS_TradeRate WHERE itemid = '" + itemid + "'"; string sale = utils.ExecuteString(sql); ////获取优惠券赠送信息 //sql = "SELECT * FROM TCS_Coupon WHERE guid = (SELECT couponid FROM TCS_ShopConfig WHERE nick = '" + nick + "')"; string showcontent = string.Empty; //DataTable dt = utils.ExecuteDataTable(sql); //if (dt.Rows.Count != 0) //{ // showcontent = "恭喜该用户获得本店送出的满" + dt.Rows[0]["condition"].ToString() + "减" + dt.Rows[0]["num"].ToString() + "元的优惠券!"; //} //获取用户等级 sql = "SELECT buynick FROM TCS_TradeRate WHERE orderid = '" + id + "' AND nick = '" + nick + "'"; string buynick = utils.ExecuteString(sql); sql = "SELECT buyerlevel FROM TCS_Customer WHERE buynick = '" + buynick + "'"; string userlevel = utils.ExecuteString(sql); sql = "UPDATE TCS_TradeRate SET isshow = 1,itemname='" + product.Title + "',itemsrc='" + product.PicUrl + "',price='" + product.Price + "',sale='" + sale + "',showcontent = '" + showcontent + "',userlevel='" + userlevel + "',showindex=100 WHERE orderid = '" + id + "' AND nick = '" + nick + "'"; //Response.Write(sql); utils.ExecuteNonQuery(sql); Response.Redirect("reviewindexnew.aspx"); }
protected void Page_Load(object sender, EventArgs e) { Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_sessionblog"); Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick = encode.Decrypt(taobaoNick); //获取参数 string q = utils.NewRequest("query", utils.RequestType.QueryString); string page = utils.NewRequest("p", utils.RequestType.QueryString); if (page == "") { page = "1"; } string catid = utils.NewRequest("catid", utils.RequestType.QueryString); string isradio = utils.NewRequest("isradio", utils.RequestType.QueryString); string act = utils.NewRequest("act", utils.RequestType.QueryString); TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12159997", "614e40bfdb96e9063031d1a9e56fbed5"); int pageSizeNow = 15; if (act == "get") { //获取用户店铺商品列表 ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = pageSizeNow; request.PageNo = int.Parse(page); request.Q = q; if (catid != "0") { request.SellerCids = catid; } PageList <Item> product = client.ItemsOnsaleGet(request, session); //输出页面HTML for (int i = 0; i < product.Content.Count; i++) { if (isradio == "1") { Response.Write("<input type='radio' name='items' id='item_" + product.Content[i].NumIid + "' title='" + product.Content[i].Title + "' value='" + product.Content[i].NumIid + "' onclick=\"InitArea(this)\"><label onMouseOver=\"javascript:ddrivetip('<img src=" + product.Content[i].PicUrl + "_80x80.jpg>','#ffffff',100)\" onMouseOut=\"hideddrivetip()\" for='item_" + product.Content[i].NumIid + "'>" + product.Content[i].Title + "</label><br>"); } else { Response.Write("<input type='checkbox' name='items' id='item_" + product.Content[i].NumIid + "' title='" + product.Content[i].Title + "' value='" + product.Content[i].NumIid + "' onclick=\"InitArea(this)\"><label onMouseOver=\"javascript:ddrivetip('<img src=" + product.Content[i].PicUrl + "_80x80.jpg>','#ffffff',100)\" onMouseOut=\"hideddrivetip()\" for='item_" + product.Content[i].NumIid + "'>" + product.Content[i].Title + "</label><br>"); } } Response.Write("<br>"); long totalPage = (product.TotalResults % pageSizeNow == 0) ? (product.TotalResults / pageSizeNow) : (product.TotalResults / pageSizeNow + 1); //输出分页HTML for (int i = 1; i <= totalPage; i++) { if (page == i.ToString()) { Response.Write(i.ToString() + " "); } else { Response.Write("<a href=\"javascript:spreadStat(" + i.ToString() + ")\">[" + i.ToString() + "]</a> "); } } } else if (act == "getCat") { //记录店铺分类信息 SellercatsListGetRequest request1 = new SellercatsListGetRequest(); request1.Fields = "cid,parent_cid,name,is_parent"; request1.Nick = taobaoNick; PageList <SellerCat> cat = client.SellercatsListGet(request1); //清除老分类 string sql = "DELETE FROM TopTaobaoShopCat WHERE nick = '" + taobaoNick + "'"; utils.ExecuteNonQuery(sql); //插入新分类 for (int i = 0; i < cat.Content.Count; i++) { sql = "INSERT INTO TopTaobaoShopCat (" + "cid, " + "parent_cid, " + "name, " + "pic_url, " + "sort_order, " + "created, " + "nick, " + "modified " + " ) VALUES ( " + " '" + cat.Content[i].Cid + "', " + " '" + cat.Content[i].ParentCid + "', " + " '" + cat.Content[i].Name + "', " + " '" + cat.Content[i].PicUrl + "', " + " '" + cat.Content[i].SortOrder + "', " + " '" + cat.Content[i].Created + "', " + " '" + taobaoNick + "', " + " '" + cat.Content[i].Modified + "' " + ") "; utils.ExecuteNonQuery(sql); } //输出页面HTML Response.Write("<select id=\"shopcat\" name=\"shopcat\"><option value=\"0\"></option>"); for (int i = 0; i < cat.Content.Count; i++) { Response.Write("<option value='" + cat.Content[i].Cid + "'>" + cat.Content[i].Name + "</option>"); } Response.Write("</select>"); } else if (act == "getResultStr") { string items = utils.NewRequest("ids", utils.RequestType.QueryString); string[] arr = items.Split(','); List <Item> itemList = new List <Item>(); //标志 int flag = 1; if (arr.Length == 1) { flag = 0; } for (int i = flag; i < arr.Length; i++) { ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.NumIid = long.Parse(arr[i]); Item product = client.ItemGet(request); itemList.Add(product); } string str = string.Empty; //根据不同样式显示不同的字符串 string style = utils.NewRequest("style", utils.RequestType.QueryString); string sqlNew = "SELECT sid FROM TopTaobaoShop WHERE nick = '" + taobaoNick + "'"; DataTable dtNew = utils.ExecuteDataTable(sqlNew); string nickid = string.Empty; if (dtNew.Rows.Count != 0) { nickid = "http://shop" + dtNew.Rows[0]["sid"].ToString() + ".taobao.com/"; } else { nickid = "http://www.taobao.com/"; } if (isradio == "1") { //团购需要的商品数据 for (int i = 0; i < itemList.Count; i++) { str = "<A href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\"><IMG src=\"" + itemList[i].PicUrl + "_160x160.jpg\" border=0 /></A><br>" + itemList[i].Title + "<br>" + itemList[i].Price + "<input type=\"hidden\" id=\"productid\" name=\"productid\" value=\"" + itemList[i].NumIid.ToString() + "\"><input type=\"hidden\" id=\"price\" name=\"price\" value=\"" + itemList[i].Price.ToString() + "\">"; } } else { if (style == "1") { str += "<table background=\"http://www.7fshop.com/top/show1/4.gif\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"30\" style=\"border-right: #999999 1px solid; border-top: #999999 1px solid;border-left: #999999 1px solid; border-bottom: #999999 1px solid\" width=\"580\"><tr><td> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"30\"><tr><td width=\"10\"></td><td background=\"http://www.7fshop.com/top/show1/1.gif\" width=\"24\"></td><td background=\"http://www.7fshop.com/top/show1/2.gif\"><font color=\"white\" style=\"font-size: 13px\"><strong>掌柜推荐商品</strong></font></td><td><img src=\"http://www.7fshop.com/top/show1/3.gif\" /></td></tr></table></td><td align=\"right\"></td></tr></table></td></tr></table> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-right: #999999 1px solid;border-top: #999999 1px solid; overflow: hidden; border-left: #999999 1px solid;border-bottom: #999999 1px solid\" width=\"578\"><tr><td valign=\"top\"><TABLE cellSpacing=0 cellPadding=0 width=578 border=0><TBODY><TR><TD align=\"middle\"><TABLE cellSpacing=8 cellPadding=0 align=center border=0><TBODY><TR>"; for (int i = 0; i < itemList.Count; i++) { str += "<TD vAlign=top align=\"middle\" width=175 bgColor=white><TABLE cellSpacing=0 cellPadding=0 align=center border=0><TBODY><TR><TD vAlign=top align=\"middle\" width=175 bgColor=white><TABLE cellSpacing=0 cellPadding=0 align=center border=0><TBODY><TR><TD align=\"middle\"><DIV style=\"BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; MARGIN-TOP: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 160px; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 160px\"><DIV style=\"OVERFLOW: hidden; WIDTH: 160px; HEIGHT: 160px\"><A href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\"><IMG src=\"" + itemList[i].PicUrl + "_160x160.jpg\" border=0 /></A></DIV></DIV></TD></TR><TR><TD align=\"middle\"><DIV style=\"PADDING-RIGHT: 4px; PADDING-LEFT: 4px; FONT-SIZE: 12px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px\"><A style=\"FONT-SIZE: 12px; COLOR: #3f3f3f; TEXT-DECORATION: none\" href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\">" + itemList[i].Title + "</A><BR /><FONT style=\"COLOR: #fe596a\"><B>¥ " + itemList[i].Price + "元</B></FONT> </DIV><A href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\"><IMG src=\"http://www.7fshop.com/top/show1/buy1.gif\" border=0 /></A> <DIV></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>"; if ((i + 1) % 3 == 0) { str += "</tr><tr>"; } } str += "</TR></TBODY></TABLE></td></tr><tr><td align=\"right\" height=\"24\" style=\"border-bottom: #999999 1px solid\" valign=\"center\"><a href=\"" + nickid + "\" style=\"text-decoration: none\" target=\"_blank\"><font style=\"font-size: 13px; color: #ff6600\"><strong>更多详情请见 " + nickid + "</strong> </font></a></td></tr></table></td></tr></table>"; } else { for (int i = 0; i < itemList.Count; i++) { str += "<a href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\"><img src=\"" + itemList[i].PicUrl + "\" border=\"0\" /></a><br />"; str += "<a href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\">" + itemList[i].Title + "</a> 售价:" + itemList[i].Price + "元<br><br>"; } } } Response.Write(str); } }
/// <summary> /// 完成创建 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnsubmit_Click(object sender, EventArgs e) { Common.Cookie cookie = new Common.Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_session"); Rijndael_ encode = new Rijndael_("tetesoft"); nick = encode.Decrypt(taobaoNick); //判断人群数不得超过4个 if (ActCountJudge()) { ShowErr("您最多只能创建4个活动"); return; } //后端判断数据但是否合法 if (DataJudge()) { ShowErr("录入数据不合法"); return; } //插入数据库 string groupbuyname = utils.NewRequest("groupbuyname", utils.RequestType.Form).Replace("'", "''"); string starttime = utils.NewRequest("starttime", utils.RequestType.Form) + " " + utils.NewRequest("startSelect", utils.RequestType.Form).Replace("'", "''") + ":00"; string endtime = utils.NewRequest("endtime", utils.RequestType.Form) + " " + utils.NewRequest("endSelect", utils.RequestType.Form).Replace("'", "''") + ":00"; string groupbuyprice = utils.NewRequest("groupbuyprice", utils.RequestType.Form); string productid = utils.NewRequest("productid", utils.RequestType.Form); string maxcount = utils.NewRequest("maxcount", utils.RequestType.Form); string zhekou = utils.NewRequest("zhekou", utils.RequestType.Form); string mintime = utils.NewRequest("mintime", utils.RequestType.Form); //通过借口获取淘宝相关数据 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.NumIid = long.Parse(productid); Item product = client.ItemGet(request, session); string newprice = Math.Round(decimal.Parse(product.Price) - decimal.Parse(zhekou), 2).ToString(); //创建活动及相关人群 string appkey = "12132145"; string secret = "1fdd2aadd5e2ac2909db2967cbb71e7f"; ////创建活动相关人群 //string guid = Guid.NewGuid().ToString().Substring(0, 4); IDictionary <string, string> param = new Dictionary <string, string>(); //param.Add("tag_name", nick + "_活动人群_" + guid); //param.Add("description", nick + "_活动人群描述_" + guid); //string result = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.marketing.tag.add", session, param); //string tagid = new Regex(@"<tag_id>([^<]*)</tag_id>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString(); //Response.Write(result + "<br><br>"); //目前针对全部商城会员 string tagid = "1"; //创建活动 param = new Dictionary <string, string>(); param.Add("num_iids", productid); param.Add("discount_type", "PRICE"); param.Add("discount_value", newprice); param.Add("start_date", starttime); param.Add("end_date", endtime); param.Add("promotion_title", groupbuyname); param.Add("tag_id", tagid); string result = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.marketing.promotion.add", session, param); if (result.IndexOf("Insufficient session permissions") != -1) { Response.Write("<b>优惠券创建失败,错误原因:</b><br><font color='red'>您的session已经失效,需要重新授权</font><br><a href='http://container.api.taobao.com/container?appkey=12132145&scope=promotion' target='_parent'>重新授权</a>"); Response.End(); return; } if (result.IndexOf("error_response") != -1) { string err = new Regex(@"<sub_msg>([^<]*)</sub_msg>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString(); Response.Write("<b>活动创建失败,错误原因:</b><br><font color='red'>" + err + "</font><br><a href='groupbuyadd.aspx'>重新添加</a>"); Response.End(); return; } string promotionid = new Regex(@"<promotion_id>([^<]*)</promotion_id>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString(); //Response.Write(result + "<br><br>"); string productname = product.Title; string productprice = product.Price; string productimg = product.PicUrl; string producturl = "http://item.taobao.com/item.htm?id=" + productid; string sql = "INSERT INTO TopGroupBuy (" + "name," + "starttime," + "endtime," + "productname," + "productprice," + "productimg," + "producturl," + "productid," + "nick," + "maxcount," + "buycount," + "tagid," + "promotionid," + "mintime," + "zhekou," + "groupbuyprice" + " ) VALUES ( " + " '" + groupbuyname + "'," + " '" + starttime + "'," + " '" + endtime + "'," + " '" + productname + "'," + " '" + productprice + "'," + " '" + productimg + "'," + " '" + producturl + "'," + " '" + productid + "'," + " '" + nick + "'," + " '" + maxcount + "'," + " '0'," + " '" + tagid + "'," + " '" + promotionid + "'," + " '" + mintime + "'," + " '" + newprice + "'," + " '" + zhekou + "'" + ") "; //Response.Write(sql); //Response.End(); //return; utils.ExecuteNonQuery(sql); //将测试用户加入该活动关联人群组 //IDictionary<string, string> param = new Dictionary<string, string>(); //param.Add("tag_id", tagid); //param.Add("nick", "美杜莎之心"); //string result = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.marketing.taguser.add", session, param); //Response.Write(result); //查询活动详细 //IDictionary<string, string> param = new Dictionary<string, string>(); //param.Add("fields", "num_iids,discount_type,discount_value,start_date,end_date,promotion_title,tag_id"); //param.Add("num_iid", "7591980225"); //string result = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.marketing.promotions.get", session, param); //Response.Write(result); //更新商品描述关联的广告图片 CreateGroupbuyImg(); Response.Redirect("grouplist.aspx"); }
protected void Button2_Click(object sender, EventArgs e) { nick = this.TextBox1.Text; session = this.TextBox2.Text; string appkey = "12132145"; string secret = "1fdd2aadd5e2ac2909db2967cbb71e7f"; //上传到宝贝描述 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); for (int j = 1; j <= 500; j++) { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid"; request.PageSize = 200; request.PageNo = j; PageList <Item> product = client.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { try { //获取商品详细 ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc"; requestItem.NumIid = product.Content[i].NumIid; Item item = client.ItemGet(requestItem, session); //判断是否增加过该图片 string newcontent = CreateDescDelHaoping(item.Desc); //if (product.Content[i].NumIid.ToString() == "10002247109") //{ // Response.Write(item.Desc); // Response.Write("**************************************************"); // Response.Write(newcontent); // return; //} if (newcontent == "") { continue; } //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", product.Content[i].NumIid.ToString()); param.Add("desc", newcontent); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update", session, param); } catch { } } if (product.Content.Count < 200) { break; } } Response.Write("<script>alert('清除成功!');</script>"); Response.End(); }
private void DeleteTaobao(string nick2) { //try //{ //获取正在进行中的宝贝同步任务 string appkey = "12287381"; string secret = "d3486dac8198ef01000e7bd4504601a4"; string session = string.Empty; string id = string.Empty; string missionid = string.Empty; string html = string.Empty; string shopcat = "0"; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); string sql = "SELECT top 300 t.*, s.sessiongroupbuy,s.sid FROM TopMission t INNER JOIN TopTaobaoShop s ON s.nick = t.nick WHERE t.isok = 0 AND t.typ = 'delete' and s.nick='" + nick2 + "' ORDER BY t.id ASC"; DataTable dt = utils.ExecuteDataTable(sql); DataTable dtWrite = null; for (int i = 0; i < dt.Rows.Count; i++) { id = dt.Rows[i]["groupbuyid"].ToString(); session = dt.Rows[i]["sessiongroupbuy"].ToString(); missionid = dt.Rows[i]["id"].ToString(); html = ""; sql = "SELECT DISTINCT itemid FROM TopWriteContent WHERE groupbuyid = '" + dt.Rows[i]["groupbuyid"].ToString() + "' AND isok = 1"; dtWrite = utils.ExecuteDataTable(sql); if (dtWrite == null || dtWrite.Rows.Count < 1) { for (int j = 1; j <= 500; j++) { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = 200; request.PageNo = j; string taobaoNick = dt.Rows[i]["nick"].ToString(); try { PageList <Item> product = client.ItemsOnsaleGet(request, session); WriteLog(taobaoNick + "INGCount:" + product.Content.Count.ToString(), "1", nick2, ""); for (int num = 0; num < product.Content.Count; num++) { RecordMissionDetail(id, missionid, product.Content[num].NumIid.ToString(), html); } if (product.Content.Count < 200) { break; } } catch (Exception e) { WriteLog(e.StackTrace, "1", nick2, ""); WriteLog(e.Message, "1", nick2, ""); sql = "UPDATE TopMission SET fail = fail + 1,isok = -1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); break; } } sql = "SELECT DISTINCT itemid FROM TopWriteContent WHERE groupbuyid = '" + dt.Rows[i]["groupbuyid"].ToString() + "' AND isok = 1"; dtWrite = utils.ExecuteDataTable(sql); } WriteLog("ING:" + dtWrite.Rows.Count.ToString(), "1", nick2, ""); for (int j = 0; j < dtWrite.Rows.Count; j++) { try { //获取原宝贝描述 ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc"; requestItem.NumIid = long.Parse(dtWrite.Rows[j]["itemid"].ToString()); WriteLog("更新删除准备中", "1", nick2, ""); Item product = client.ItemGet(requestItem, session); WriteLog("更新删除准备中。。。。", "1", nick2, ""); string newContent2 = string.Empty; string groupid = dt.Rows[i]["groupbuyid"].ToString(); string tetegroupbuyGuid = groupid; string sqltemp = "SELECT * FROM TopGroupBuy WHERE id = '" + groupid + "'"; DataTable dttemp = utils.ExecuteDataTable(sqltemp); if (dttemp == null) { continue; } //判断团购是多模板 if (dttemp.Rows[0]["groupbuyGuid"].ToString() != "") { tetegroupbuyGuid = dttemp.Rows[0]["groupbuyGuid"].ToString(); } if (!Regex.IsMatch(product.Desc, @"<div>[\s]*<a name=""tetesoft-area-start-" + tetegroupbuyGuid + @""">[\s]*</a>[\s]*</div>[\s]*([\s\S]*)<div>[\s]*<a name=""tetesoft-area-end-" + tetegroupbuyGuid + @""">[\s]*</a>[\s]*</div>")) { //更新状态 WriteLog(DateTime.Now.ToString() + "http://item.taobao.com/item.htm?id=" + dtWrite.Rows[j]["itemid"].ToString() + " 不含需要清除的代码", "", nick2, ""); sql = "UPDATE TopMission SET success = success + 1,isok = 1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); continue; } else { newContent2 = Regex.Replace(product.Desc, @"<div>[\s]*<a name=""tetesoft-area-start-" + tetegroupbuyGuid + @""">[\s]*</a>[\s]*</div>[\s]*([\s\S]*)<div>[\s]*<a name=""tetesoft-area-end-" + tetegroupbuyGuid + @""">[\s]*</a>[\s]*</div>", @""); } //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", dtWrite.Rows[j]["itemid"].ToString()); param.Add("desc", newContent2); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update", session, param); //插入宝贝错误日志 if (resultpro.ToLower().IndexOf("ITEM_PROPERTIES_ERROR") != -1) { WriteLog("删除活动更新宝贝描述:宝贝ID:" + dtWrite.Rows[j]["itemid"].ToString() + "返回的错误信息" + resultpro.Replace("<?xml version=\"1.0\" encoding=\"utf-8\" ?>", ""), "1", nick2, ""); } else { WriteLog("删除活动更新宝贝描述:宝贝ID:" + dtWrite.Rows[j]["itemid"].ToString() + "返回的成功信息" + resultpro.Replace("<?xml version=\"1.0\" encoding=\"utf-8\" ?>", ""), "", nick2, ""); } if (resultpro.IndexOf("ITEM_PROPERTIES_ERROR") != -1) { WriteLog("删除宝贝更新宝贝描述结果:宝贝ID:" + dtWrite.Rows[j]["itemid"].ToString() + "返回的错误信息" + resultpro, "", nick2, ""); //更新宝贝错误数 sql = "UPDATE TopMission SET fail = fail + 1,isok = -1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } else { //更新状态 sql = "UPDATE TopWriteContent SET isok = 1 WHERE id = " + dtWrite.Rows[j]["itemid"].ToString(); utils.ExecuteNonQuery(sql); //更新状态 sql = "UPDATE TopMission SET success = success + 1,isok = 1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } } catch (Exception e) { WriteLog("删除宝贝" + e.StackTrace, "1", nick2, ""); WriteLog("删除宝贝" + e.Message, "1", nick2, ""); sql = "UPDATE TopMission SET fail = fail + 1,isok = -1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); continue; } } dtWrite.Dispose(); } dt.Dispose(); WriteLog("**********************************************************", "", nick2, ""); }
/// <summary> /// 清除宝贝描述里面的活动页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button4_Click(object sender, EventArgs e) { string appkey = "12159997"; string secret = "614e40bfdb96e9063031d1a9e56fbed5"; //上传到宝贝描述 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); for (int j = 1; j <= 500; j++) { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid"; request.PageSize = 200; request.PageNo = j; PageList <Item> product = client.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { try { //获取商品详细 ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc"; requestItem.NumIid = product.Content[i].NumIid; Item item = client.ItemGet(requestItem, session); //判断是否增加过该图片 string newcontent = CreateDescDel(item.Desc); //if (product.Content[i].NumIid.ToString() == "10002247109") //{ // Response.Write(item.Desc); // Response.Write("**************************************************"); // Response.Write(newcontent); // return; //} if (newcontent == "") { continue; } //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", product.Content[i].NumIid.ToString()); param.Add("desc", newcontent); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update", session, param); } catch { } } if (product.Content.Count < 200) { break; } } Response.Write("<script>alert('清除成功!');window.location.href='html.aspx';</script>"); Response.End(); }
/// <summary> /// 清除宝贝描述里面的活动页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button4_Click(object sender, EventArgs e) { string appkey = "12690738"; string secret = "66d488555b01f7b85f93d33bc2a1c001"; session = utils.NewRequest("session", utils.RequestType.QueryString); StringBuilder builder = new StringBuilder(); //上传到宝贝描述 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); for (int j = 1; j <= 500; j++) { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid"; request.PageSize = 200; request.PageNo = j; PageList <Item> product = client.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { try { //获取商品详细 ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc"; requestItem.NumIid = product.Content[i].NumIid; Item item = client.ItemGet(requestItem, session); //判断是否增加过该图片 string newcontent = CreateDescDel(item.Desc); //if (product.Content[i].NumIid.ToString() == "10002247109") //{ // Response.Write(item.Desc); // Response.Write("**************************************************"); // Response.Write(newcontent); // return; //} if (newcontent == "") { continue; } //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", product.Content[i].NumIid.ToString()); param.Add("desc", newcontent); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update", session, param); builder.Append(resultpro + "\r\n"); //Response.Write(resultpro + "<br>\r\n"); } catch { } } if (product.Content.Count < 200) { break; } } File.WriteAllText(Server.MapPath("htmlLog/" + DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + nick + ".txt"), builder.ToString()); Response.Write("<script>alert('清除成功!');</script>"); Response.End(); }
/// <summary> /// 清除宝贝描述 /// </summary> private void DeleteTaobaoitmes(string nick2) { WriteLog("活动清除进行", "1", "err", ""); //获取正在进行中的宝贝同步任务 string appkey = "12287381"; string secret = "d3486dac8198ef01000e7bd4504601a4"; string session = string.Empty; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); string sql = "SELECT top 100 t.*, s.sessiongroupbuy FROM Tete_ActivityMission t INNER JOIN TopTaobaoShop s ON s.nick = t.nick WHERE t.isok = 0 AND t.typ = 'delete' and s.nick='" + nick2 + "' ORDER BY t.id ASC"; DataTable dt = utils.ExecuteDataTable(sql); DataTable dtWrite = null; if (dt != null) { WriteLog("活动清除进行中", "1", "err", ""); for (int i = 0; i < dt.Rows.Count; i++) { session = dt.Rows[i]["sessiongroupbuy"].ToString(); sql = "SELECT * FROM Tete_ActivityWriteContent WHERE shoptempletID= '" + dt.Rows[i]["shoptempletID"].ToString() + "' and ActivityID = '" + dt.Rows[i]["ActivityID"].ToString() + "'"; WriteLog(sql, "1", "err", ""); dtWrite = utils.ExecuteDataTable(sql); if (dtWrite != null) { WriteLog("商品总数" + dtWrite.Rows.Count.ToString(), "1", "err", ""); for (int j = 0; j < dtWrite.Rows.Count; j++) { try { //获取原宝贝描述 ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc"; requestItem.NumIid = long.Parse(dtWrite.Rows[j]["itemid"].ToString()); Item product = client.ItemGet(requestItem, session); string newContent = string.Empty; string ActivityMissionID = dtWrite.Rows[j]["ActivityMissionID"].ToString(); string tetegroupbuyGuid = ActivityMissionID; string sqltemp = "SELECT * FROM Tete_ActivityMission WHERE id = '" + ActivityMissionID + "'"; DataTable dttemp = utils.ExecuteDataTable(sqltemp); if (dttemp == null) { return; } newContent = product.Desc; if (!Regex.IsMatch(product.Desc, @"<div>[\s]*<a name=""tetesoft-area-start-" + tSaid + @""">[\s]*</a>[\s]*</div>[\s]*([\s\S]*)<div>[\s]*<a name=""tetesoft-area-end-" + tSaid + @""">[\s]*</a>[\s]*</div>")) { //如果没有代码 tetegroupbuyGuid = dtWrite.Rows[j]["ActivityID"].ToString(); if (!Regex.IsMatch(product.Desc, @"<div>[\s]*<a name=""tetesoft-area-start-" + tSaid + @""">[\s]*</a>[\s]*</div>[\s]*([\s\S]*)<div>[\s]*<a name=""tetesoft-area-end-" + tSaid + @""">[\s]*</a>[\s]*</div>")) { //更新状态 // WriteDeleteLog2("http://item.taobao.com/item.htm?id=" + dtWrite.Rows[j]["itemid"].ToString() + " 不含需要清除的代码", ""); //更新状态 WriteLog("http://item.taobao.com/item.htm?id=" + dtWrite.Rows[j]["itemid"].ToString() + " 不含需要清除的代码" + dtWrite.Rows.Count.ToString(), "1", "err", ""); sql = "UPDATE Tete_ActivityWriteContent SET isok = 1 WHERE id = " + dtWrite.Rows[j]["id"].ToString(); utils.ExecuteNonQuery(sql); //更新状态 sql = "UPDATE Tete_ActivityMission SET success = success + 1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); continue; } else { newContent = Regex.Replace(product.Desc, @"<div>[\s]*<a name=""tetesoft-area-start-" + tSaid + @""">[\s]*</a>[\s]*</div>[\s]*([\s\S]*)<div>[\s]*<a name=""tetesoft-area-end-" + tSaid + @""">[\s]*</a>[\s]*</div>", @""); //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", dtWrite.Rows[j]["itemid"].ToString()); param.Add("desc", newContent); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update ", session, param); //插入宝贝错误日志 if (resultpro.IndexOf("ITEM_PROPERTIES_ERROR") != -1) { WriteLog("errID:" + dtWrite.Rows[j]["itemid"].ToString() + "errinfo" + resultpro, "", dt.Rows[i]["nick"].ToString(), dtWrite.Rows[j]["ActivityMissionID"].ToString()); //更新宝贝错误数 sql = "UPDATE Tete_ActivityMission SET fail = fail + 1,isok = -1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } else { WriteLog("删除itemid:" + dtWrite.Rows[j]["itemid"].ToString() + resultpro, "", dt.Rows[i]["nick"].ToString(), dtWrite.Rows[j]["ActivityMissionID"].ToString()); //更新状态 sql = "UPDATE Tete_ActivityWriteContent SET isok = 1 WHERE id = " + dtWrite.Rows[j]["id"].ToString(); utils.ExecuteNonQuery(sql); //更新状态 sql = "UPDATE Tete_ActivityMission SET success = success + 1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } } } else { newContent = Regex.Replace(product.Desc, @"<div>[\s]*<a name=""tetesoft-area-start-" + tSaid + @""">[\s]*</a>[\s]*</div>[\s]*([\s\S]*)<div>[\s]*<a name=""tetesoft-area-end-" + tSaid + @""">[\s]*</a>[\s]*</div>", @""); //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", dtWrite.Rows[j]["itemid"].ToString()); param.Add("desc", newContent); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update ", session, param); //插入宝贝错误日志 if (resultpro.IndexOf("ITEM_PROPERTIES_ERROR") != -1) { WriteLog("errID:" + dtWrite.Rows[j]["itemid"].ToString() + "errinfo" + resultpro, "", dt.Rows[i]["nick"].ToString(), dtWrite.Rows[j]["ActivityMissionID"].ToString()); //更新宝贝错误数 sql = "UPDATE Tete_ActivityMission SET fail = fail + 1,isok = -1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } else { WriteLog("删除itemid:" + dtWrite.Rows[j]["itemid"].ToString() + resultpro, "", dt.Rows[i]["nick"].ToString(), dtWrite.Rows[j]["ActivityMissionID"].ToString()); //更新状态 sql = "UPDATE Tete_ActivityWriteContent SET isok = 1 WHERE id = " + dtWrite.Rows[j]["id"].ToString(); utils.ExecuteNonQuery(sql); //更新状态 sql = "UPDATE Tete_ActivityMission SET success = success + 1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } } } catch (Exception e) { WriteLog("失败" + e.Message, "1", dt.Rows[i]["nick"].ToString(), dtWrite.Rows[j]["ActivityMissionID"].ToString()); WriteLog("失败" + e.StackTrace, "1", dt.Rows[i]["nick"].ToString(), dtWrite.Rows[j]["ActivityMissionID"].ToString()); sql = "UPDATE Tete_ActivityMission SET fail = fail + 1,isok = -1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); continue; } } dtWrite.Dispose(); } sql = "UPDATE Tete_ActivityMission SET isok = 1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } dt.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { try { id = utils.NewRequest("id", Common.utils.RequestType.QueryString); if (id != "" && !utils.IsInt32(id)) { Response.Write("非法参数1"); Response.End(); return; } style = utils.NewRequest("style", Common.utils.RequestType.Form); size = utils.NewRequest("size", Common.utils.RequestType.Form); type = utils.NewRequest("type", Common.utils.RequestType.Form); orderby = utils.NewRequest("orderby", Common.utils.RequestType.Form); query = utils.NewRequest("query", Common.utils.RequestType.Form); shopcat = utils.NewRequest("shopcat", Common.utils.RequestType.Form); name = utils.NewRequest("name", Common.utils.RequestType.Form); items = utils.NewRequest("items", Common.utils.RequestType.Form); string act = utils.NewRequest("act", Common.utils.RequestType.Form); if (act == "save") { Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_session"); Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick = encode.Decrypt(taobaoNick); //记录到本地数据库 string sql = "INSERT INTO TopIdea (" + "name, " + "showtype, " + "nick, " + "size, " + "style, " + "orderby, " + "shopcategoryid, " + "query " + " ) VALUES ( " + " '" + name + "', " + " '" + type + "', " + " '" + taobaoNick + "', " + " '" + size + "', " + " '" + style + "', " + " '" + orderby + "', " + " '" + shopcat + "', " + " '" + query + "' " + ") "; //如果为编辑模式 if (id != "" && id != "0") { //更新广告 sql = "UPDATE TopIdea SET " + "name = '" + name + "', " + "showtype = '" + type + "', " + "size = '" + size + "', " + "style = '" + style + "', " + "orderby = '" + orderby + "', " + "shopcategoryid = '" + shopcat + "', " + "query = '" + query + "' " + " WHERE id = " + id; utils.ExecuteNonQuery(sql); //如果是自动更新模式,需要更新店铺商品数据 sql = "SELECT shopcategoryid,query,nick,showtype FROM TopIdea WHERE nick = '" + taobaoNick + "' AND id = " + id; DataTable dt1 = utils.ExecuteDataTable(sql); if (dt1.Rows[0]["showtype"].ToString() == "0") { //更新下架商品数据 shopcat = dt1.Rows[0][0].ToString(); query = dt1.Rows[0][1].ToString(); taobaoNick = dt1.Rows[0][2].ToString(); //获取新商品列表 TopXmlRestClient clientaa = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = 12; request.OrderBy = "list_time:desc"; request.OrderBy = "volume:desc"; if (shopcat != "0") { request.SellerCids = shopcat; } request.Q = query; //清理关联商品 sql = "DELETE FROM TopIdeaProduct WHERE ideaid = " + id; utils.ExecuteNonQuery(sql); //未登录用户不能获取小二下架或删除的商品-错误过滤,原因未知 try { PageList <Item> product = clientaa.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { sql = "INSERT INTO TopIdeaProduct (" + "itemid, " + "itemname, " + "itemprice, " + "itempicurl, " + "ideaid " + " ) VALUES ( " + " '" + product.Content[i].NumIid + "', " + " '" + product.Content[i].Title + "', " + " '" + product.Content[i].Price + "', " + " '" + product.Content[i].PicUrl + "', " + " '" + id + "' " + ") "; utils.ExecuteNonQuery(sql); } } catch { } } //清理关联商品 sql = "DELETE FROM TopIdeaProduct WHERE ideaid = " + id; utils.ExecuteNonQuery(sql); //清理广告缓存 CacheManager testcaching1 = CacheFactory.GetCacheManager(); if (testcaching1.Contains("cache_1_" + id)) { testcaching1.Remove("cache_1_" + id); } //更新广告图片 string folderPath = Server.MapPath("\\show\\folder\\" + MD5(taobaoNick) + "\\result_" + id + ".jpg"); if (File.Exists(folderPath)) { File.Delete(folderPath); } } utils.ExecuteNonQuery(sql); if (id != "" && id != "0") { //编辑模式,ID不变 } else { //插入模式,获取最新ID sql = "SELECT TOP 1 id FROM TopIdea WHERE nick = '" + taobaoNick + "' ORDER BY id DESC"; id = utils.ExecuteString(sql); } //获取符合结果集的相关商品并记录到本地数据库 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); //如果为自动选择模式 if (type == "0") { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = 12; if (orderby == "new") { request.OrderBy = "list_time:desc"; } else if (orderby == "sale") { request.OrderBy = "volume:desc"; } if (shopcat != "0") { request.SellerCids = shopcat; } if (query != "0") { request.Q = query; } //未登录用户不能获取小二下架或删除的商品-错误过滤,原因未知 try { PageList <Item> product = client.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { sql = "INSERT INTO TopIdeaProduct (" + "itemid, " + "itemname, " + "itemprice, " + "itempicurl, " + "ideaid " + " ) VALUES ( " + " '" + product.Content[i].NumIid + "', " + " '" + product.Content[i].Title + "', " + " '" + product.Content[i].Price + "', " + " '" + product.Content[i].PicUrl + "', " + " '" + id + "' " + ") "; utils.ExecuteNonQuery(sql); } } catch { } } else { string[] arr = items.Split(','); List <Item> itemList = new List <Item>(); for (int i = 0; i < arr.Length; i++) { ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.NumIid = long.Parse(arr[i]); Item product = client.ItemGet(request); itemList.Add(product); } for (int i = 0; i < itemList.Count; i++) { sql = "INSERT INTO TopIdeaProduct (" + "itemid, " + "itemname, " + "itemprice, " + "itempicurl, " + "ideaid " + " ) VALUES ( " + " '" + itemList[i].NumIid + "', " + " '" + itemList[i].Title + "', " + " '" + itemList[i].Price + "', " + " '" + itemList[i].PicUrl + "', " + " '" + id + "' " + ") "; utils.ExecuteNonQuery(sql); } } } //获取NICK的淘宝ID Cookie cookieNew = new Cookie(); string taobaoNickNew = cookieNew.getCookie("nick"); Rijndael_ encodeaa = new Rijndael_("tetesoft"); taobaoNickNew = encodeaa.Decrypt(taobaoNickNew); md5nick = MD5(taobaoNickNew); string sqlNew = "SELECT sid FROM TopTaobaoShop WHERE nick = '" + taobaoNickNew + "'"; DataTable dtNew = utils.ExecuteDataTable(sqlNew); if (dtNew.Rows.Count != 0) { nickid = "http://shop" + dtNew.Rows[0]["sid"].ToString() + ".taobao.com/"; } else { nickid = "http://www.taobao.com/"; } nickidEncode = "http://www.7fshop.com/click/?s=" + EncodeStr(new string[] { id, "0", nickid }); string sql112 = "SELECT * FROM TopIdea WHERE id = " + id; DataTable newdt1 = utils.ExecuteDataTable(sql112); if (newdt1.Rows.Count != 0) { tabletitle = newdt1.Rows[0]["name"].ToString(); size = newdt1.Rows[0]["size"].ToString(); } string num = string.Empty; string row = string.Empty; switch (size) { case "514*160": num = "5"; row = "5"; break; case "514*288": num = "10"; row = "5"; break; case "664*160": num = "6"; row = "6"; break; case "312*288": num = "6"; row = "3"; break; case "336*280": num = "4"; row = "2"; break; case "714*160": num = "7"; row = "7"; break; case "114*418": num = "3"; row = "1"; break; case "218*286": num = "4"; row = "2"; break; case "743*308": num = "4"; row = "4"; break; default: num = "4"; row = "4"; break; } //绑定商品列表 string sql11 = "SELECT TOP " + num + " *,'' AS html FROM TopIdeaProduct WHERE ideaid = " + id; DataTable newdt = utils.ExecuteDataTable(sql11); //加换行符 for (int i = 0; i < newdt.Rows.Count; i++) { if ((i + 1) % int.Parse(row) == 0) { newdt.Rows[i]["html"] = "</tr><tr>"; } } if (size != "743*308") { panel1.Visible = true; panel2.Visible = false; rptProduct.DataSource = newdt; rptProduct.DataBind(); } else { panel1.Visible = false; panel2.Visible = true; rptProduct2.DataSource = newdt; rptProduct2.DataBind(); } string[] arrNew = size.Split('*'); width = arrNew[0]; height = arrNew[1]; } catch { } }
protected void Page_Load(object sender, EventArgs e) { //TopXmlRestClient client = new TopXmlRestClient("http://gw.api.tbsandbox.com/router/rest", "test", "test"); id = utils.NewRequest("id", utils.RequestType.QueryString); string itemid = utils.NewRequest("itemid", utils.RequestType.QueryString); string ideaid = utils.NewRequest("idea", utils.RequestType.QueryString); string act = utils.NewRequest("act", utils.RequestType.QueryString); url = utils.NewRequest("url", utils.RequestType.QueryString); width = utils.NewRequest("width", utils.RequestType.QueryString); height = utils.NewRequest("height", utils.RequestType.QueryString); num = utils.NewRequest("num", utils.RequestType.QueryString); string size = string.Empty; if (id != "" && !utils.IsInt32(id)) { Response.Write("非法参数1"); Response.End(); return; } if (num != "" && !utils.IsInt32(id)) { Response.Write("非法参数0"); Response.End(); return; } if (itemid != "" && !IsLong(itemid)) { Response.Write("非法参数2"); Response.End(); return; } if (ideaid != "" && !utils.IsInt32(ideaid)) { Response.Write("非法参数3"); Response.End(); return; } string sql = string.Empty; //只有正式模式下才统计相关信息 if (id != "0") { if (act == "hit") { return; //记录广告点击 sql = "UPDATE TopIdea SET hitcount = hitcount + 1 WHERE id = " + ideaid; utils.ExecuteNonQuery(sql); //记录点击日志 sql = "INSERT INTO TopIdeaHitLog (ideaid, itemid, url) VALUES ('" + ideaid + "', '" + itemid + "', '" + url + "')"; utils.ExecuteNonQuery(sql); Response.End(); return; } else // if (act == "view") { //记录广告浏览次数 sql = "UPDATE TopIdea SET viewcount = viewcount + 1 WHERE id = " + id; utils.ExecuteNonQuery(sql); //记录浏览日志 sql = "INSERT INTO TopIdeaLog (ideaid, url) VALUES ('" + id + "', '" + url + "')"; utils.ExecuteNonQuery(sql); //Response.End(); //return; } } //开启缓存 CacheManager testcaching1 = CacheFactory.GetCacheManager(); if (testcaching1.Contains("cache_1_" + id) && id != "3972") { Response.Write(testcaching1.GetData("cache_1_" + id)); Response.End(); return; } TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); //如果为0则为调试模式,自动按照参数进行调用 if (id == "0") { Cookie cookie1 = new Cookie(); string taobaoNick1 = cookie1.getCookie("nick"); //COOKIE过期判断 if (taobaoNick1 == "") { //SESSION超期 跳转到登录页 Response.Write("<script>parent.location.href='http://container.open.taobao.com/container?appkey=12132145'</script>"); Response.End(); } Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick1 = encode.Decrypt(taobaoNick1); string sqlNew = "SELECT sid FROM TopTaobaoShop WHERE nick = '" + taobaoNick1 + "'"; DataTable dtNew = utils.ExecuteDataTable(sqlNew); if (dtNew.Rows.Count != 0) { nickid = "http://shop" + dtNew.Rows[0]["sid"].ToString() + ".taobao.com/"; } else { nickid = "http://www.taobao.com/"; } width = (int.Parse(width) - 10).ToString(); Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_session"); string style = utils.NewRequest("style", utils.RequestType.QueryString); size = utils.NewRequest("size", utils.RequestType.QueryString); string type = utils.NewRequest("type", utils.RequestType.QueryString); string orderby = utils.NewRequest("orderby", utils.RequestType.QueryString); string query = utils.NewRequest("query", utils.RequestType.QueryString); string shopcat = utils.NewRequest("shopcat", utils.RequestType.QueryString); string items = utils.NewRequest("items", utils.RequestType.QueryString); title = utils.NewRequest("title", utils.RequestType.QueryString); //如果为自动选择模式 if (type == "0") { //如果没有选择具体商品 ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = int.Parse(num); if (orderby == "new") { request.OrderBy = "list_time:desc"; } else if (orderby == "sale") { request.OrderBy = "volume:desc"; } if (shopcat != "0") { request.SellerCids = shopcat; } if (query != "0") { request.Q = query; } try { PageList <Item> product = client.ItemsOnsaleGet(request, session); if (size == "743*308") { panel1.Visible = false; panel2.Visible = true; Repeater2.DataSource = product.Content; Repeater2.DataBind(); } else { Repeater1.DataSource = product.Content; Repeater1.DataBind(); } } catch { Response.Write(session + "- miss session!!"); Response.End(); } } //如果选择了具体商品 else { if (items == "") { return; } string[] arr = items.Split(','); List <Item> itemList = new List <Item>(); //过滤可能发生的错误 try { for (int i = 0; i < arr.Length; i++) { if (i >= int.Parse(num)) { break; } ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.NumIid = long.Parse(arr[i]); Item product = client.ItemGet(request); itemList.Add(product); } } catch { } if (size == "743*308") { panel1.Visible = false; panel2.Visible = true; Repeater2.DataSource = itemList; Repeater2.DataBind(); } else { Repeater1.DataSource = itemList; Repeater1.DataBind(); } } return; } //获取广告标题 sql = "SELECT name,size FROM TopIdea WHERE id = " + id; DataTable dt = utils.ExecuteDataTable(sql); if (dt.Rows.Count != 0) { title = dt.Rows[0]["name"].ToString(); size = dt.Rows[0]["size"].ToString(); string[] arr = size.Split('*'); width = arr[0]; height = arr[1]; switch (size) { case "514*160": num = "5"; break; case "514*288": num = "10"; break; case "664*160": num = "6"; break; case "312*288": num = "6"; break; case "336*280": num = "4"; break; case "714*160": num = "7"; break; case "114*418": num = "3"; break; case "218*286": num = "4"; break; case "743*308": num = "4"; break; default: num = "4"; break; } } //获取数据库中保存的商品 sql = "SELECT TOP " + num + " * FROM TopIdeaProduct WHERE ideaid = " + id + "";// ORDER BY NEWID()"; dt = utils.ExecuteDataTable(sql); test.DataSource = dt; test.DataBind(); //获取店铺地址 sql = "SELECT name,size,nick FROM TopIdea WHERE id = " + id; DataTable dt22 = utils.ExecuteDataTable(sql); if (dt22.Rows.Count != 0) { string taobaoNick = dt22.Rows[0]["nick"].ToString(); string sqlNew = "SELECT sid FROM TopTaobaoShop WHERE nick = '" + taobaoNick + "'"; DataTable dtNew = utils.ExecuteDataTable(sqlNew); if (dtNew.Rows.Count != 0) { nickid = "http://shop" + dtNew.Rows[0]["sid"].ToString() + ".taobao.com/"; } else { nickid = "http://www.taobao.com/"; } } //生成HTML缓存 string cache = string.Empty; if (size == "743*308") { cache += "<table background=\"/top/show1/4.gif\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"30\" style=\"border-right: #999999 1px solid; border-top: #999999 1px solid;border-left: #999999 1px solid; border-bottom: #999999 1px solid\" width=\"740\"><tr><td> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"30\"><tr><td width=\"10\"></td><td background=\"/top/show1/1.gif\" width=\"24\"></td><td background=\"/top/show1/2.gif\"><font color=\"white\" style=\"font-size: 13px\"><strong>" + title + "</strong></font></td><td><img src=\"/top/show1/3.gif\" /></td></tr></table></td><td align=\"right\"></td></tr></table></td></tr></table> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-right: #999999 1px solid;border-top: #999999 1px solid; overflow: hidden; border-left: #999999 1px solid;border-bottom: #999999 1px solid\" width=\"740\"><tr><td valign=\"top\"><TABLE cellSpacing=0 cellPadding=0 width=730 border=0><TBODY><TR><TD align=\"middle\"><TABLE cellSpacing=8 cellPadding=0 align=center border=0><TBODY><TR>"; for (int i = 0; i < dt.Rows.Count; i++) { cache += "<TD vAlign=top align=\"middle\" width=175 bgColor=white><TABLE cellSpacing=0 cellPadding=0 align=center border=0><TBODY><TR><TD vAlign=top align=\"middle\" width=175 bgColor=white><TABLE cellSpacing=0 cellPadding=0 align=center border=0><TBODY><TR><TD align=\"middle\"><DIV style=\"BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; MARGIN-TOP: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 160px; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 160px\"><DIV style=\"OVERFLOW: hidden; WIDTH: 160px; HEIGHT: 160px\"><A href=\"/click/?s=" + EncodeStr(new string[] { id, dt.Rows[i]["itemid"].ToString(), "http://item.taobao.com/item.htm?id=" + dt.Rows[i]["itemid"].ToString() }) + "\" onclick=\"javascript:spreadStat('" + id + "','" + dt.Rows[i]["itemid"].ToString() + "');\" target=\"_blank\"><IMG alt=\"" + dt.Rows[i]["itemname"].ToString() + "\" src=\"" + dt.Rows[i]["itempicurl"].ToString() + "_160x160.jpg\" border=0 /></A></DIV></DIV></TD></TR><TR><TD align=\"middle\"><DIV style=\"PADDING-RIGHT: 4px; PADDING-LEFT: 4px; FONT-SIZE: 12px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px\"><A style=\"FONT-SIZE: 12px; COLOR: #3f3f3f; TEXT-DECORATION: none\" href=\"/click/?s=" + EncodeStr(new string[] { id, dt.Rows[i]["itemid"].ToString(), "http://item.taobao.com/item.htm?id=" + dt.Rows[i]["itemid"].ToString() }) + "\" onclick=\"javascript:spreadStat('" + id + "','" + dt.Rows[i]["itemid"].ToString() + "');\" target=\"_blank\" title=\"" + dt.Rows[i]["itemname"].ToString() + "\">" + dt.Rows[i]["itemname"].ToString() + "</A><BR /><FONT style=\"COLOR: #fe596a\"><B>¥ " + dt.Rows[i]["itemprice"].ToString() + "元</B></FONT> </DIV><A href=\"/click/?s=" + EncodeStr(new string[] { id, dt.Rows[i]["itemid"].ToString(), "http://item.taobao.com/item.htm?id=" + dt.Rows[i]["itemid"].ToString() }) + "\" onclick=\"javascript:spreadStat('" + id + "','" + dt.Rows[i]["itemid"].ToString() + "');\" target=\"_blank\"><IMG src=\"/top/show1/buy1.gif\" border=0 /></A> <DIV></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>"; } cache += "</TR></TBODY></TABLE></td></tr><tr><td align=\"right\" height=\"24\" style=\"border-bottom: #999999 1px solid\" valign=\"center\"><a href=\"/click/?s=" + EncodeStr(new string[] { id, "0", nickid }) + "\" style=\"text-decoration: none\" target=\"_blank\"><font style=\"font-size: 13px; color: #ff6600\"><strong>更多详情请见 " + nickid + "</strong> </font></a></td></tr></table>"; cache += "<script type=\"text/javascript\" language=\"javascript\" src=\"css/common.js\"></script>"; cache += "<script type=\"text/javascript\">"; cache += "var xmlHttp;"; cache += "var url = '" + url + "';"; cache += "if(\"0\" != \"" + id + "\" && url != \"\"){"; cache += "createxmlHttpRequest();"; cache += "var queryString = \"http://www.7fshop.com/show/plist.aspx?act=view&id=" + id + "&url=\"+escape(url)+\"&t=\"+new Date().getTime();"; cache += "xmlHttp.open(\"GET\",queryString);"; cache += "xmlHttp.send(null); }"; cache += "</script>"; } else { cache = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; cache += "<html xmlns=\"http://www.w3.org/1999/xhtml\">"; cache += "<head>"; cache += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; cache += "<title>特特推广</title>"; cache += "<link type=\"text/css\" href=\"css/css.css\" rel=\"stylesheet\"/>"; cache += "</head>"; cache += "<body>"; cache += "<div id=\"container\" style=\"width:" + width + "px; height:" + height + "px; overflow:hidden\">"; cache += "<div class=\"navigation\">" + title + "</div>"; cache += "<div class=\"outer\">"; cache += "<div class=\"inner\">"; for (int i = 0; i < dt.Rows.Count; i++) { cache += "<dl>"; cache += "<dt><a href='/click/?s=" + EncodeStr(new string[] { id, dt.Rows[i]["itemid"].ToString(), "http://item.taobao.com/item.htm?id=" + dt.Rows[i]["itemid"].ToString() }) + "' title='" + dt.Rows[i]["itemname"].ToString() + "' onclick='javascript:spreadStat('" + id + "','" + dt.Rows[i]["itemid"].ToString() + "');' target='_blank'><img src='" + dt.Rows[i]["itempicurl"].ToString() + "_80x80.jpg' border='0' /></a></dt>"; cache += "<dd><a href='/click/?s=" + EncodeStr(new string[] { id, dt.Rows[i]["itemid"].ToString(), "http://item.taobao.com/item.htm?id=" + dt.Rows[i]["itemid"].ToString() }) + "' onclick='javascript:spreadStat('" + id + "','" + dt.Rows[i]["itemid"].ToString() + "');' target='_blank'>" + left(dt.Rows[i]["itemname"].ToString(), 16) + "</a></dd>"; cache += "</dl>"; } cache += "<br class=\"clearfloat\"/>"; cache += "</div>"; cache += "</div>"; cache += "</div>"; cache += "<script type=\"text/javascript\" language=\"javascript\" src=\"css/common.js\"></script>"; cache += "<script type=\"text/javascript\">"; cache += "var xmlHttp;"; cache += "var url = '" + url + "';"; cache += "if(\"0\" != \"" + id + "\" && url != \"\"){"; cache += "createxmlHttpRequest();"; cache += "var queryString = \"http://www.7fshop.com/show/plist.aspx?act=view&id=" + id + "&url=\"+escape(url)+\"&t=\"+new Date().getTime();"; cache += "xmlHttp.open(\"GET\",queryString);"; cache += "xmlHttp.send(null); }"; cache += "</script>"; } CacheManager testcaching = CacheFactory.GetCacheManager(); if (!testcaching.Contains("cache_1_" + id)) { testcaching.Add("cache_1_" + id, cache); } //如果是743*308,则直接显示 Response.Write(cache); Response.End(); }
private void DoMyJob(string topMissionID) { //获取正在进行中的宝贝同步任务 string appkey = "12287381"; string secret = "d3486dac8198ef01000e7bd4504601a4"; string session = string.Empty; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); string sql = "SELECT t.*, s.sessiongroupbuy FROM TopMission t INNER JOIN TopTaobaoShop s ON s.nick = t.nick WHERE t.isok = 0 AND t.typ = 'write' AND t.id=" + topMissionID + " ORDER BY t.id ASC"; DataTable dt = utils.ExecuteDataTable(sql); DataTable dtWrite = null; string styleHtml = string.Empty; if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { session = dt.Rows[i]["sessiongroupbuy"].ToString(); sql = "SELECT * FROM TopWriteContent WHERE missionid = '" + dt.Rows[i]["id"].ToString() + "' AND isok = 0"; //WriteLog("sql1:" + sql, ""); dtWrite = utils.ExecuteDataTable(sql); if (dtWrite != null) { for (int j = 0; j < dtWrite.Rows.Count; j++) { styleHtml = CreateGroupbuyHtml(dtWrite.Rows[j]["groupbuyid"].ToString()); try { //获取原宝贝描述 ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc"; requestItem.NumIid = long.Parse(dtWrite.Rows[j]["itemid"].ToString()); Item product = client.ItemGet(requestItem, session); string newContent = string.Empty; string groupid = dtWrite.Rows[j]["groupbuyid"].ToString(); string tetegroupbuyGuid = groupid; string sqltemp = "SELECT * FROM TopGroupBuy WHERE id = '" + groupid + "'"; DataTable dttemp = utils.ExecuteDataTable(sqltemp); if (dttemp == null) { Response.Write("<script>alert('更新宝贝描述失败,该团购不存在!');window.location.href='missionlist.aspx';</script>"); Response.End(); } //判断团购是多模板 if (dttemp.Rows[0]["groupbuyGuid"].ToString() != "") { tetegroupbuyGuid = dttemp.Rows[0]["groupbuyGuid"].ToString(); } //WriteLog("html:" + styleHtml.Length.ToString(), ""); if (!Regex.IsMatch(product.Desc, @"<div><a name=""tetesoft-area-start-" + tetegroupbuyGuid + @"""></a></div>([\s\S]*)<div><a name=""tetesoft-area-end-" + tetegroupbuyGuid + @"""></a></div>")) { newContent = @"<div><a name=""tetesoft-area-start-" + tetegroupbuyGuid + @"""></a></div>" + styleHtml + @"<div><a name=""tetesoft-area-end-" + tetegroupbuyGuid + @"""></a></div>" + product.Desc; } else { newContent = Regex.Replace(product.Desc, @"<div><a name=""tetesoft-area-start-" + tetegroupbuyGuid + @"""></a></div>([\s\S]*)<div><a name=""tetesoft-area-end-" + tetegroupbuyGuid + @"""></a></div>", @"<div><a name=""tetesoft-area-start-" + tetegroupbuyGuid + @"""></a></div>" + styleHtml + @"<div><a name=""tetesoft-area-end-" + tetegroupbuyGuid + @"""></a></div>"); } //WriteLog("html2:" + newContent.Length.ToString(), ""); //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", dtWrite.Rows[j]["itemid"].ToString()); param.Add("desc", newContent); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update ", session, param); //插入宝贝错误日志 if (resultpro.IndexOf("ITEM_PROPERTIES_ERROR") != -1) { //WriteLog("更新宝贝描述:宝贝ID:" + dtWrite.Rows[j]["itemid"].ToString() + "返回的错误信息" + resultpro, "", dt.Rows[i]["nick"].ToString()); ////插入宝贝错误日志 //sql = "insert TopMissionErrDetail (TopMissionID,itemid,nick,ErrDetail) values('" + dt.Rows[i]["id"].ToString() + "','" + dtWrite.Rows[j]["itemid"].ToString() + "','" + dt.Rows[i]["nick"].ToString() + "','" + resultpro + "')"; //utils.ExecuteNonQuery(sql); //更新宝贝错误数 sql = "UPDATE TopMission SET fail = fail + 1,isok = -1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } else { WriteLog("itemid:" + dtWrite.Rows[j]["itemid"].ToString() + resultpro, "", dt.Rows[i]["nick"].ToString()); //更新状态 sql = "UPDATE TopWriteContent SET isok = 1 WHERE id = " + dtWrite.Rows[j]["id"].ToString(); utils.ExecuteNonQuery(sql); //更新状态 sql = "UPDATE TopMission SET success = success + 1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } } catch (Exception e) { WriteLog(e.Message, "1", dt.Rows[i]["nick"].ToString()); WriteLog(e.StackTrace, "1", dt.Rows[i]["nick"].ToString()); sql = "UPDATE TopMission SET fail = fail + 1,isok = -1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); continue; } } dtWrite.Dispose(); } sql = "UPDATE TopMission SET isok = 1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } dt.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_sessiongroupbuy"); Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick = encode.Decrypt(taobaoNick); string appkey = "12159997"; string secret = "614e40bfdb96e9063031d1a9e56fbed5"; //获取参数 string q = utils.NewRequest("query", utils.RequestType.QueryString); string page = utils.NewRequest("p", utils.RequestType.QueryString); if (page == "") { page = "1"; } string catid = utils.NewRequest("catid", utils.RequestType.QueryString); string isradio = utils.NewRequest("isradio", utils.RequestType.QueryString); string act = utils.NewRequest("act", utils.RequestType.QueryString); TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); int pageSizeNow = 15; if (act == "get") { //获取用户店铺商品列表 ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = pageSizeNow; request.PageNo = int.Parse(page); request.Q = q; if (catid != "0") { request.SellerCids = catid; } PageList <Item> product = client.ItemsOnsaleGet(request, session); //输出页面HTML for (int i = 0; i < product.Content.Count; i++) { if (isradio == "1") { Response.Write("<input type='radio' name='items' id='item_" + product.Content[i].NumIid + "' title='" + product.Content[i].Title.Replace("%", "") + "' value='" + product.Content[i].NumIid + "' onclick=\"InitArea(this)\"><label onMouseOver=\"javascript:ddrivetip('<img src=" + product.Content[i].PicUrl + "_80x80.jpg>','#ffffff',100)\" onMouseOut=\"hideddrivetip()\" for='item_" + product.Content[i].NumIid + "'>" + product.Content[i].Title.Replace("%", "") + "</label><br>"); } else { Response.Write("<input type='checkbox' name='items' id='item_" + product.Content[i].NumIid + "' title='" + product.Content[i].Title.Replace("%", "") + "' value='" + product.Content[i].NumIid + "' onclick=\"InitArea(this)\"><label onMouseOver=\"javascript:ddrivetip('<img src=" + product.Content[i].PicUrl + "_80x80.jpg>','#ffffff',100)\" onMouseOut=\"hideddrivetip()\" for='item_" + product.Content[i].NumIid + "'>" + product.Content[i].Title.Replace("%", "") + "</label><br>"); } } Response.Write("<br>"); long totalPage = (product.TotalResults % pageSizeNow == 0) ? (product.TotalResults / pageSizeNow) : (product.TotalResults / pageSizeNow + 1); //输出分页HTML for (int i = 1; i <= totalPage; i++) { if (page == i.ToString()) { Response.Write(i.ToString() + " "); } else { Response.Write("<a href=\"javascript:spreadStat(" + i.ToString() + ")\">[" + i.ToString() + "]</a> "); } } } else if (act == "getCat") { //记录店铺分类信息 SellercatsListGetRequest request1 = new SellercatsListGetRequest(); request1.Fields = "cid,parent_cid,name,is_parent"; request1.Nick = taobaoNick; PageList <SellerCat> cat = client.SellercatsListGet(request1); //清除老分类 string sql = "DELETE FROM TopTaobaoShopCat WHERE nick = '" + taobaoNick + "'"; utils.ExecuteNonQuery(sql); //插入新分类 for (int i = 0; i < cat.Content.Count; i++) { sql = "INSERT INTO TopTaobaoShopCat (" + "cid, " + "parent_cid, " + "name, " + "pic_url, " + "sort_order, " + "created, " + "nick, " + "modified " + " ) VALUES ( " + " '" + cat.Content[i].Cid + "', " + " '" + cat.Content[i].ParentCid + "', " + " '" + cat.Content[i].Name + "', " + " '" + cat.Content[i].PicUrl + "', " + " '" + cat.Content[i].SortOrder + "', " + " '" + cat.Content[i].Created + "', " + " '" + taobaoNick + "', " + " '" + cat.Content[i].Modified + "' " + ") "; utils.ExecuteNonQuery(sql); } //输出页面HTML Response.Write("<select id=\"shopcat\" name=\"shopcat\"><option value=\"0\"></option>"); for (int i = 0; i < cat.Content.Count; i++) { Response.Write("<option value='" + cat.Content[i].Cid + "'>" + cat.Content[i].Name + "</option>"); } Response.Write("</select>"); } else if (act == "getResultStr") { string items = utils.NewRequest("ids", utils.RequestType.QueryString); string[] arr = items.Split(','); List <Item> itemList = new List <Item>(); //标志 int flag = 1; if (arr.Length == 1) { flag = 0; } for (int i = flag; i < arr.Length; i++) { ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.NumIid = long.Parse(arr[i]); Item product = client.ItemGet(request); itemList.Add(product); } string str = string.Empty; //根据不同样式显示不同的字符串 string style = utils.NewRequest("style", utils.RequestType.QueryString); //string sqlNew = "SELECT sid FROM TopTaobaoShop WHERE nick = '" + taobaoNick + "'"; //DataTable dtNew = utils.ExecuteDataTable(sqlNew); //string nickid = string.Empty; //if (dtNew.Rows.Count != 0) //{ // nickid = "http://shop" + dtNew.Rows[0]["sid"].ToString() + ".taobao.com/"; //} //else //{ // nickid = "http://www.taobao.com/"; //} if (isradio == "1") { //团购需要的商品数据 for (int i = 0; i < itemList.Count; i++) { str = "<div id=item_" + itemList[i].NumIid.ToString() + " style=\"float:left;width:46px;border:solid 1px #ccc;padding:2px;margin:2px;\"><A href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\"><IMG src=\"" + itemList[i].PicUrl + "_40x40.jpg\" border=0 title=\"" + itemList[i].Title + "\" /></A><br>" + itemList[i].Price + "<input type=\"hidden\" id=\"productid\" name=\"productid\" value=\"" + itemList[i].NumIid.ToString() + "\"><input type=\"hidden\" id=\"price\" name=\"price\" value=\"" + itemList[i].Price.ToString() + "\"><br><a href=\"javascript:delitem(" + itemList[i].NumIid.ToString() + ")\">删除</a></div>"; } } Response.Write(str); } }
/// <summary> /// 添加活动 /// </summary> public void addactivity() { Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_sessiongroupbuy"); Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick = encode.Decrypt(taobaoNick); //获取原宝贝 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12287381", "d3486dac8198ef01000e7bd4504601a4"); ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc,num_iid,title,price,pic_url "; requestItem.NumIid = long.Parse(iid); Item product = client.ItemGet(requestItem, session); sql = "select * from tete_activity where id=" + actionId; DataTable dt = utils.ExecuteDataTable(sql); if (dt != null && dt.Rows.Count > 0) { discountType = Request.QueryString["discountType"].ToString(); //DISCOUNT 或PRICE discountValue = Request.QueryString["discountValue"].ToString(); //促销力度 discountValue = Request.QueryString["discountValue"].ToString(); //促销力度 if (discountType == "") { discountType = "DISCOUNT"; if (discountValue == "") { discountValue = "10"; } } else { if (discountValue == "") { discountValue = "0"; } } decreaseNum = Request.QueryString["decreaseNum"].ToString(); //是否优惠限制 string rcounts = Request.QueryString["rcounts"].ToString(); //团购人数 //创建活动及相关人群 string appkey = "12287381"; string secret = "d3486dac8198ef01000e7bd4504601a4"; //创建活动相关人群 string guid = Guid.NewGuid().ToString().Substring(0, 4); IDictionary <string, string> param = new Dictionary <string, string>(); string tagid = "1"; //new Regex(@"<tag_id>([^<]*)</tag_id>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString(); //创建活动 param = new Dictionary <string, string>(); param.Add("num_iids", iid); param.Add("discount_type", discountType); param.Add("discount_value", discountValue); param.Add("start_date", DateTime.Parse(dt.Rows[0]["startDate"].ToString()).ToString("yyyy-MM-dd hh:mm:ss")); param.Add("end_date", DateTime.Parse(dt.Rows[0]["endDate"].ToString()).ToString("yyyy-MM-dd hh:mm:ss")); param.Add("promotion_title", dt.Rows[0]["Name"].ToString()); param.Add("decrease_num", decreaseNum); param.Add("tag_id", tagid); string result = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.marketing.promotion.add", session, param); WriteLog(result, "1", taobaoNick, iid); if (result.IndexOf("error_response") != -1) { // sql = "delete from [tete_activitylist] WHERE ActivityID = " + actionId + " and ProductID=" + iid; // utils.ExecuteNonQuery(sql); string err = new Regex(@"<sub_msg>([^<]*)</sub_msg>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString(); if (err == "") { Response.Write("<b>活动创建失败,错误原因:</b><br><font color='red'>您的session已经失效,需要重新授权</font><br><a href='http://container.api.taobao.com/container?appkey=12287381&scope=promotion' target='_parent'>重新授权</a>"); Response.End(); } Response.Write("<b>活动创建失败,错误原因:</b><br><font color='red'>" + err + "</font><br><a href='activityadd.aspx'>重新添加</a>"); Response.End(); return; } string promotionid = new Regex(@"<promotion_id>([^<]*)</promotion_id>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString(); sql = "INSERT [tete_activitylist] ([ActivityID] ,[Productname] ,[Productprice] ,[ProductImg] ,[ProductUrl] ,[ProductID] ,[promotionID] ,[Name] ,[Description] ,[Remark] ,[startDate] ,[endDate] ,[itemType] ,[discountType] ,[discountValue] ,[tagId] ,[Status] ,[Rcount] ,[Nick] ,[decreaseNum] ,[isOK]) VALUES(" + actionId + ",'" + product.Title + "','" + product.Price + "','" + product.PicUrl + "','http://item.taobao.com/item.htm?id=" + product.NumIid.ToString() + "','" + iid + "','" + promotionid + "','" + dt.Rows[0]["Name"].ToString() + "','" + dt.Rows[0]["Description"].ToString() + "','" + dt.Rows[0]["Remark"].ToString() + "','" + dt.Rows[0]["startDate"].ToString() + "','" + dt.Rows[0]["endDate"].ToString() + "','" + dt.Rows[0]["itemType"].ToString() + "','" + discountType + "','" + discountValue + "','" + dt.Rows[0]["tagId"].ToString() + "',0," + rcounts + ",'" + taobaoNick + "'," + decreaseNum + ",0)"; utils.ExecuteNonQuery(sql); Response.Write("true"); Response.End(); } else { Response.Write("null"); Response.End(); } }
private void BindData(string items, string adsid) { string html = string.Empty; string total = string.Empty; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12287381", "d3486dac8198ef01000e7bd4504601a4");//d3486dac8198ef01000e7bd4504601a4 if (type != "1") { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = 1; if (orderby == "new") { request.OrderBy = "list_time:desc"; } else if (orderby == "sale") { request.OrderBy = "volume:desc"; } if (shopcat != "0") { request.SellerCids = shopcat; } if (query != "0") { request.Q = query; } Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_sessiongroupbuy"); PageList <Item> product = client.ItemsOnsaleGet(request, session); ItemGetRequest request1 = new ItemGetRequest(); request1.Fields = "num_iid,title,price,pic_url,desc"; request1.NumIid = product.Content[0].NumIid; Item product1 = client.ItemGet(request1); html = product1.Desc; } else { string itemId = items.Split(',')[0]; ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url,desc"; request.NumIid = long.Parse(itemId); Item product = client.ItemGet(request); //获取商品详细描述 html = product.Desc; } //获取广告代码 string adsHtml = "团购的HTML代码";// getAdsContent(ads); if (!Regex.IsMatch(html, @"<img alt=""tetesoft-area-start"" width=""0"" height=""0"">([\s\S]*)<img alt=""tetesoft-area-end"" width=""0"" height=""0"">")) { html += @"<img alt=""tetesoft-area-start"" width=""0"" height=""0"">" + adsHtml + @"<img alt=""tetesoft-area-end"" width=""0"" height=""0"">"; } else { html = Regex.Replace(html, @"<img alt=""tetesoft-area-start"" width=""0"" height=""0"">([\s\S]*)<img alt=""tetesoft-area-end"" width=""0"" height=""0"">", @"<img alt=""tetesoft-area-start"" width=""0"" height=""0"">" + adsHtml + @"<img alt=""tetesoft-area-end"" width=""0"" height=""0"">"); } lbView.InnerHtml = html; //Response.Write("搜索结果共计" + total + "个商品...<br>"); }
protected void Page_Load(object sender, EventArgs e) { Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_sessiongroupbuy"); Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick = encode.Decrypt(taobaoNick); //获取参数 string q = utils.NewRequest("query", utils.RequestType.QueryString); string page = utils.NewRequest("p", utils.RequestType.QueryString); if (page == "") { page = "1"; } string catid = utils.NewRequest("catid", utils.RequestType.QueryString); string isradio = utils.NewRequest("isradio", utils.RequestType.QueryString); string act = utils.NewRequest("act", utils.RequestType.QueryString); TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12287381", "d3486dac8198ef01000e7bd4504601a4"); int pageSizeNow = 15; if (act == "get") { //获取用户店铺商品列表 ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = pageSizeNow; request.PageNo = int.Parse(page); request.Q = q; if (catid != "0") { request.SellerCids = catid; } PageList <Item> product = client.ItemsOnsaleGet(request, session); //输出页面HTML for (int i = 0; i < product.Content.Count; i++) { string tempstr = "未参加促销活动"; string sql = "select * from Tete_activitylist where Status<>4 and Status<>3 and Status<>2 and ProductID=" + product.Content[i].NumIid.ToString().Trim(); DataTable dt = utils.ExecuteDataTable(sql); if (dt != null && dt.Rows.Count > 0) { tempstr = " <font color=green> 已参加促销活动</font><br/><a href=\"javascript:delItemAction(" + product.Content[i].NumIid.ToString().Trim() + "," + dt.Rows[0]["ActivityID"].ToString() + ")\">删除此促销活动</a><div id='del" + product.Content[i].NumIid.ToString().Trim() + "'></div>"; } string str = " <table width=\"800px;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"margin:0px; padding:0px\"> <tr><td style=\" width:100px;\"><img width=50px src=" + product.Content[i].PicUrl + "_80x80.jpg></td><td style=\" width:300px;\"><a href=\"http://item.taobao.com/item.htm?id=" + product.Content[i].NumIid.ToString() + "\" target=\"_blank\">" + product.Content[i].Title + "</a></td><td style=\" width:150px;\">" + product.Content[i].Price.ToString() + "</td><td style=\" width:250px;\">" + tempstr + "</td></tr> </table><hr/>"; Response.Write(str); } Response.Write("<br>"); long totalPage = (product.TotalResults % pageSizeNow == 0) ? (product.TotalResults / pageSizeNow) : (product.TotalResults / pageSizeNow + 1); //输出分页HTML for (int i = 1; i <= totalPage; i++) { if (page == i.ToString()) { Response.Write(i.ToString() + " "); } else { Response.Write("<a href=\"javascript:spreadStat(" + i.ToString() + ")\">[" + i.ToString() + "]</a> "); } } Response.End(); } else if (act == "getCat") { //记录店铺分类信息 SellercatsListGetRequest request1 = new SellercatsListGetRequest(); request1.Fields = "cid,parent_cid,name,is_parent"; request1.Nick = taobaoNick; PageList <SellerCat> cat = client.SellercatsListGet(request1); //清除老分类 string sql = "DELETE FROM TopTaobaoShopCat WHERE nick = '" + taobaoNick + "'"; utils.ExecuteNonQuery(sql); //插入新分类 for (int i = 0; i < cat.Content.Count; i++) { sql = "INSERT INTO TopTaobaoShopCat (" + "cid, " + "parent_cid, " + "name, " + "pic_url, " + "sort_order, " + "created, " + "nick, " + "modified " + " ) VALUES ( " + " '" + cat.Content[i].Cid + "', " + " '" + cat.Content[i].ParentCid + "', " + " '" + cat.Content[i].Name + "', " + " '" + cat.Content[i].PicUrl + "', " + " '" + cat.Content[i].SortOrder + "', " + " '" + cat.Content[i].Created + "', " + " '" + taobaoNick + "', " + " '" + cat.Content[i].Modified + "' " + ") "; utils.ExecuteNonQuery(sql); } //输出页面HTML Response.Write("<select id=\"shopcat\" name=\"shopcat\"><option value=\"0\"></option>"); for (int i = 0; i < cat.Content.Count; i++) { Response.Write("<option value='" + cat.Content[i].Cid + "'>" + cat.Content[i].Name + "</option>"); } Response.Write("</select>"); Response.End(); } else if (act == "getResultStr") { string items = utils.NewRequest("ids", utils.RequestType.QueryString); string[] arr = items.Split(','); List <Item> itemList = new List <Item>(); //标志 int flag = 1; if (arr.Length == 1) { flag = 0; } for (int i = flag; i < arr.Length; i++) { ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.NumIid = long.Parse(arr[i]); Item product = client.ItemGet(request); itemList.Add(product); } string str = string.Empty; //根据不同样式显示不同的字符串 string style = utils.NewRequest("style", utils.RequestType.QueryString); string sqlNew = "SELECT sid FROM TopTaobaoShop WHERE nick = '" + taobaoNick + "'"; DataTable dtNew = utils.ExecuteDataTable(sqlNew); string nickid = string.Empty; if (dtNew.Rows.Count != 0) { nickid = "http://shop" + dtNew.Rows[0]["sid"].ToString() + ".taobao.com/"; } else { nickid = "http://www.taobao.com/"; } for (int i = 0; i < itemList.Count; i++) { str += "<div id='div" + itemList[i].NumIid.ToString() + "' width=\"800px\"><table width=\"800px\"><tr width=\"800px\"><td width=\"90px\"><a href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\"><img src=\"" + itemList[i].PicUrl + "_80x80.jpg\" border=\"0\" /></a></td>"; str += "<td width=\"140px\"><a href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\">" + itemList[i].Title + "</a> </td><td width=\"200px\"><input type=\"text\" size=\"27\" id=\"groupbuylistname" + itemList[i].NumIid.ToString() + "\" name=\"groupbuylistname\" maxlength=\"30\" value=\"\" /></td><td width=\"100px\"> " + itemList[i].Price + "元 <input type=\"hidden\" id=\"productid" + itemList[i].NumIid.ToString() + "\" name=\"productid\" value=\"" + itemList[i].NumIid.ToString() + "\"><input type=\"hidden\" id=\"price" + itemList[i].NumIid.ToString() + "\" name=\"price\" value=\"" + itemList[i].Price.ToString() + "\"></td><td width=\"100px\"> <input type=\"text\" id=\"zhekou" + itemList[i].NumIid.ToString() + "\" size=\"10\" name=\"zhekou\" onblur=\"setzekou(this)\" /> 元 <br /> 打<input type=\"text\" size=\"8\" id=\"zhekou1" + itemList[i].NumIid.ToString() + "\" name=\"zhekou1\" onblur=\"setprice(this)\"/> 折 <br />限购:<select id=\"xiangou" + itemList[i].NumIid.ToString() + "\" name=\"xiangou\"> <OPTION selected value=0>否</OPTION> <OPTION value=1>是</OPTION> </select> <span id=\"errmsg" + i + "\" style=\"color:Red\"></span> </td><td width=\"90px\"> <input type=\"text\" size=\"8\" name=\"rcount\" value=\"300\" /> </td><td width=\"80px\"><a onclick=\"deleteDIV('del1" + itemList[i].NumIid.ToString() + "')\" style=\"cursor:hand;\">删除</a></td></tr></table><input id=\"del1" + itemList[i].NumIid.ToString() + "\" name=\"del\" value='' type=\"hidden\" ></div>"; } Response.Write(str); Response.End(); } else if (act == "getactivityitem") { //获取用户店铺商品列表 ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = pageSizeNow; request.PageNo = int.Parse(page); request.Q = q; if (catid != "0") { request.SellerCids = catid; } PageList <Item> product = client.ItemsOnsaleGet(request, session); string str = string.Empty; string discountType = string.Empty; //促销方式(打折:DISCOUNT,减价:PRICE) string discountValue = string.Empty; //促销力度(7折限制) string Rcount = "300"; //已参团人数(只在对设置团购模板时有用) string newPrice2 = string.Empty; //促销价 string price2 = string.Empty; //商品价格 string itemtype2 = string.Empty; string itemtypevalue2 = string.Empty; string yhCount = string.Empty; string hdstr = string.Empty; string aid = Request.QueryString["aid"].ToString(); string yuanitemtype = ""; string yuandiscountType = ""; string yuandiscountValue = ""; string yuandecreaseNum = ""; string sql2 = "select * from tete_activity where id=" + aid; DataTable dt33 = utils.ExecuteDataTable(sql2); if (dt33 != null) { yuanitemtype = dt33.Rows[0]["itemType"].ToString(); yuandiscountType = dt33.Rows[0]["discountType"].ToString(); yuandiscountValue = dt33.Rows[0]["discountValue"].ToString(); yuandecreaseNum = dt33.Rows[0]["decreaseNum"].ToString(); } //输出页面HTML for (int i = 0; i < product.Content.Count; i++) { //先判断该商品是否已经参团(状态为:进行中和暂停中) string sql = "SELECT * FROM tete_activitylist where ProductID=" + product.Content[i].NumIid.ToString() + " and (Status=3 or Status=1 or Status=0) and nick='" + taobaoNick + "'"; DataTable dtNew2 = utils.ExecuteDataTable(sql); // 取得促销价格 if (dtNew2 != null && dtNew2.Rows.Count > 0) { Rcount = dtNew2.Rows[0]["Rcount"].ToString(); discountValue = dtNew2.Rows[0]["discountValue"].ToString(); discountType = dtNew2.Rows[0]["discountType"].ToString(); price2 = product.Content[i].Price; hdstr = "<div id=\"del" + product.Content[i].NumIid.ToString() + "\">已参加活动:" + dtNew2.Rows[0]["name"].ToString() + " <br><a href=\"javascript:delItemAction(" + product.Content[i].NumIid.ToString() + ")\">删除此促销活动</a></div> <div style=\"display:none\" id=\"add" + product.Content[i].NumIid.ToString() + "\"><a href=\"javascript:addItemAction(" + product.Content[i].NumIid.ToString() + ")\">参加活动</a></div> "; if (discountType.Trim() == "DISCOUNT") { itemtype2 = "<select onchange=\"changeSelect(" + product.Content[i].NumIid.ToString() + ")\" id=\"discountType" + product.Content[i].NumIid.ToString() + "\" name=\"discountType\" > <option selected=\"selected\" value=\"DISCOUNT\">打折</option><option value=\"PRICE\">减价</option> </select>"; itemtypevalue2 = " <div id=\"zheDiv" + product.Content[i].NumIid.ToString() + "\" style=\"display: block;\"><input type=\"text\" onkeyup=\"blurValue(" + product.Content[i].NumIid.ToString() + ")\" id=\"changeZhe" + product.Content[i].NumIid.ToString() + "\" value=\"" + discountValue + "\" name=\"discountValue\" style=\"width:30px\">折</div><div style=\"display: none;\" id=\"jianDiv" + product.Content[i].NumIid.ToString() + "\">减<input type=\"text\" onkeyup=\"blurValue(" + product.Content[i].NumIid.ToString() + ")\" id=\"changeJian" + product.Content[i].NumIid.ToString() + "\" name=\"discountValue\" style=\"width:30px\" >元</div>"; if (discountValue != "") { newPrice2 = (decimal.Parse(price2) * decimal.Parse(discountValue) * 0.1m).ToString(); } else { newPrice2 = price2; } yhCount = " <span id=\"duojian" + product.Content[i].NumIid.ToString() + "\" style=\"display: inline;\">多件<input type=\"hidden\" id=\"decreaseNumHiden" + product.Content[i].NumIid.ToString() + "\" value=\"0\" name=\"decreaseNumHiden\"></span> <span style=\"display: none;\" id=\"yijian" + product.Content[i].NumIid.ToString() + "\"><select onchange=\"decreaseNumChange(" + product.Content[i].NumIid.ToString() + ")\" id=\"decreaseNumSel" + product.Content[i].NumIid.ToString() + "\" name=\"decreaseNumSel\"> <option selected=\"selected\" value=\"0\">多件</option> <option value=\"1\">一件</option> </select></span>"; } else { itemtype2 = "<select onchange=\"changeSelect(" + product.Content[i].NumIid.ToString() + ")\" id=\"discountType" + product.Content[i].NumIid.ToString() + "\" name=\"discountType\" > <option value=\"DISCOUNT\">打折</option><option selected=\"selected\" value=\"PRICE\">减价</option> </select>"; if (dtNew2.Rows[0]["decreaseNum"].ToString() == "0") { yhCount = " <span id=\"duojian" + product.Content[i].NumIid.ToString() + "\" style=\"display: none;\">多件<input type=\"hidden\" id=\"decreaseNumHiden" + product.Content[i].NumIid.ToString() + "\" value=\"0\" name=\"decreaseNumHiden\"></span> <span style=\"display: inline;\" id=\"yijian" + product.Content[i].NumIid.ToString() + "\"><select onchange=\"decreaseNumChange(" + product.Content[i].NumIid.ToString() + ")\" id=\"decreaseNumSel" + product.Content[i].NumIid.ToString() + "\" name=\"decreaseNumSel\"> <option selected=\"selected\" value=\"0\">多件</option> <option value=\"1\">一件</option> </select></span>"; } else { yhCount = " <span id=\"duojian" + product.Content[i].NumIid.ToString() + "\" style=\"display: none;\">多件<input type=\"hidden\" id=\"decreaseNumHiden" + product.Content[i].NumIid.ToString() + "\" value=\"0\" name=\"decreaseNumHiden\"></span> <span style=\"display: inline;\" id=\"yijian" + product.Content[i].NumIid.ToString() + "\"><select onchange=\"decreaseNumChange(" + product.Content[i].NumIid.ToString() + ")\" id=\"decreaseNumSel" + product.Content[i].NumIid.ToString() + "\" name=\"decreaseNumSel\"> <option value=\"0\">多件</option> <option value=\"1\" selected=\"selected\">一件</option> </select></span>"; } itemtypevalue2 = " <div id=\"zheDiv" + product.Content[i].NumIid.ToString() + "\" style=\"display: none;\" ><input type=\"text\" onkeyup=\"blurValue(" + product.Content[i].NumIid.ToString() + ")\" id=\"changeZhe" + product.Content[i].NumIid.ToString() + "\" value=\"9\" name=\"discountValue\" style=\"width:30px\">折</div><div style=\"display: block;\" id=\"jianDiv" + product.Content[i].NumIid.ToString() + "\">减<input type=\"text\" onkeyup=\"blurValue(" + product.Content[i].NumIid.ToString() + ")\" id=\"changeJian" + product.Content[i].NumIid.ToString() + "\" name=\"discountValue\" style=\"width:30px\" value=\"" + discountValue + "\" >元</div>"; if (discountValue != "") { newPrice2 = (decimal.Parse(price2) - decimal.Parse(discountValue)).ToString(); } else { newPrice2 = price2; } } } else { hdstr = " <div id=\"add" + product.Content[i].NumIid.ToString() + "\"><a href=\"javascript:addItemAction(" + product.Content[i].NumIid.ToString() + ")\">参加活动</a></div>"; if (yuanitemtype == "same") { //same:每个参加活动的宝贝设置相同促销力度,different:每个参加活动的宝贝设置不同促销力度) //decreaseNum 是否优惠限制(0,1) if (yuandiscountType == "PRICE") { itemtype2 = "<select onchange=\"changeSelect(" + product.Content[i].NumIid.ToString() + ")\" id=\"discountType" + product.Content[i].NumIid.ToString() + "\" name=\"discountType\" > <option value=\"DISCOUNT\">打折</option><option selected=\"selected\" value=\"PRICE\">减价</option> </select>"; itemtypevalue2 = " <div id=\"zheDiv" + product.Content[i].NumIid.ToString() + "\" style=\"display: none;\"><input type=\"text\" onkeyup=\"blurValue(" + product.Content[i].NumIid.ToString() + ")\" id=\"changeZhe" + product.Content[i].NumIid.ToString() + "\" value=\"\" name=\"discountValue\" style=\"width:30px\">折</div><div style=\"display:block ;\" id=\"jianDiv" + product.Content[i].NumIid.ToString() + "\">减<input type=\"text\" onkeyup=\"blurValue(" + product.Content[i].NumIid.ToString() + ")\" id=\"changeJian" + product.Content[i].NumIid.ToString() + "\" name=\"discountValue\" style=\"width:30px\" value=\"" + yuandiscountValue + "\" >元</div>"; if (yuandecreaseNum == "0") { yhCount = " <span id=\"duojian" + product.Content[i].NumIid.ToString() + "\" style=\"display: none;\">多件<input type=\"hidden\" id=\"decreaseNumHiden" + product.Content[i].NumIid.ToString() + "\" value=\"0\" name=\"decreaseNumHiden\"></span> <span style=\"display: inline;\" id=\"yijian" + product.Content[i].NumIid.ToString() + "\"><select onchange=\"decreaseNumChange(" + product.Content[i].NumIid.ToString() + ")\" id=\"decreaseNumSel" + product.Content[i].NumIid.ToString() + "\" name=\"decreaseNumSel\"> <option selected=\"selected\" value=\"0\">多件</option> <option value=\"1\">一件</option> </select></span>"; } else { yhCount = " <span id=\"duojian" + product.Content[i].NumIid.ToString() + "\" style=\"display: none;\">多件<input type=\"hidden\" id=\"decreaseNumHiden" + product.Content[i].NumIid.ToString() + "\" value=\"0\" name=\"decreaseNumHiden\"></span> <span style=\"display: inline;\" id=\"yijian" + product.Content[i].NumIid.ToString() + "\"><select onchange=\"decreaseNumChange(" + product.Content[i].NumIid.ToString() + ")\" id=\"decreaseNumSel" + product.Content[i].NumIid.ToString() + "\" name=\"decreaseNumSel\"> <option value=\"0\">多件</option> <option value=\"1\" selected=\"selected\">一件</option> </select></span>"; } if (discountValue != "") { newPrice2 = (decimal.Parse(product.Content[i].Price) - decimal.Parse(yuandiscountValue)).ToString(); } else { newPrice2 = product.Content[i].Price; } } else { itemtype2 = "<select onchange=\"changeSelect(" + product.Content[i].NumIid.ToString() + ")\" id=\"discountType" + product.Content[i].NumIid.ToString() + "\" name=\"discountType\" > <option selected=\"selected\" value=\"DISCOUNT\">打折</option><option value=\"PRICE\">减价</option> </select>"; yhCount = " <span id=\"duojian" + product.Content[i].NumIid.ToString() + "\" style=\"display: inline;\">多件<input type=\"hidden\" id=\"decreaseNumHiden" + product.Content[i].NumIid.ToString() + "\" value=\"0\" name=\"decreaseNumHiden\"></span> <span style=\"display: none;\" id=\"yijian" + product.Content[i].NumIid.ToString() + "\"><select onchange=\"decreaseNumChange(" + product.Content[i].NumIid.ToString() + ")\" id=\"decreaseNumSel" + product.Content[i].NumIid.ToString() + "\" name=\"decreaseNumSel\"> <option selected=\"selected\" value=\"0\">多件</option> <option value=\"1\">一件</option> </select></span>"; itemtypevalue2 = " <div id=\"zheDiv" + product.Content[i].NumIid.ToString() + "\" style=\"display: block;\"><input type=\"text\" onkeyup=\"blurValue(" + product.Content[i].NumIid.ToString() + ")\" id=\"changeZhe" + product.Content[i].NumIid.ToString() + "\" value=\"" + yuandiscountValue + "\" name=\"discountValue\" style=\"width:30px\">折</div><div style=\"display: none;\" id=\"jianDiv" + product.Content[i].NumIid.ToString() + "\">减<input type=\"text\" onkeyup=\"blurValue(" + product.Content[i].NumIid.ToString() + ")\" id=\"changeJian" + product.Content[i].NumIid.ToString() + "\" name=\"discountValue\" style=\"width:30px\" value=\"\" >元</div>"; if (discountValue != "") { newPrice2 = (decimal.Parse(product.Content[i].Price) * decimal.Parse(yuandiscountValue) * 0.1m).ToString(); } else { newPrice2 = product.Content[i].Price; } } } else { itemtype2 = "<select onchange=\"changeSelect(" + product.Content[i].NumIid.ToString() + ")\" id=\"discountType" + product.Content[i].NumIid.ToString() + "\" name=\"discountType\" > <option selected=\"selected\" value=\"DISCOUNT\">打折</option><option value=\"PRICE\">减价</option> </select>"; yhCount = " <span id=\"duojian" + product.Content[i].NumIid.ToString() + "\" style=\"display: inline;\">多件<input type=\"hidden\" id=\"decreaseNumHiden" + product.Content[i].NumIid.ToString() + "\" value=\"0\" name=\"decreaseNumHiden\"></span> <span style=\"display: none;\" id=\"yijian" + product.Content[i].NumIid.ToString() + "\"><select onchange=\"decreaseNumChange(" + product.Content[i].NumIid.ToString() + ")\" id=\"decreaseNumSel" + product.Content[i].NumIid.ToString() + "\" name=\"decreaseNumSel\"> <option selected=\"selected\" value=\"0\">多件</option> <option value=\"1\">一件</option> </select></span>"; itemtypevalue2 = " <div id=\"zheDiv" + product.Content[i].NumIid.ToString() + "\" style=\"display: block;\"><input type=\"text\" onkeyup=\"blurValue(" + product.Content[i].NumIid.ToString() + ")\" id=\"changeZhe" + product.Content[i].NumIid.ToString() + "\" value=\"9\" name=\"discountValue\" style=\"width:30px\">折</div><div style=\"display: none;\" id=\"jianDiv" + product.Content[i].NumIid.ToString() + "\">减<input type=\"text\" onkeyup=\"blurValue(" + product.Content[i].NumIid.ToString() + ")\" id=\"changeJian" + product.Content[i].NumIid.ToString() + "\" name=\"discountValue\" style=\"width:30px\" value=\"\" >元</div>"; newPrice2 = product.Content[i].Price; } } str += "<div id='div" + product.Content[i].NumIid.ToString() + "' width=\"800px\"><table width=\"800px\"><tr width=\"800px\"><td width=\"15px\"><!--<input type=\"checkbox\" id=\"" + product.Content[i].NumIid.ToString() + "\" class=\"selector\" value=\"" + product.Content[i].NumIid.ToString() + "\" name=\"iids\">--></td><td width=\"100px\"> <a href=\"http://item.taobao.com/item.htm?id=" + product.Content[i].NumIid.ToString() + "\" target=\"_blank\"><img src=\"" + product.Content[i].PicUrl + "_80x80.jpg\" width=\"50px\" height=\"50px\" border=\"0\" /></a></td>"; //图片 str += "<td width=\"140px\"><a href=\"http://item.taobao.com/item.htm?id=" + product.Content[i].NumIid.ToString() + "\" target=\"_blank\">" + product.Content[i].Title + "</a> </td>"; //名称 str += "<td width=\"70px\"> " + product.Content[i].Price + " <input type=\"hidden\" id=\"price" + product.Content[i].NumIid.ToString() + "\" name=\"price\" value=\"" + product.Content[i].Price.ToString() + "\"></td>"; //商品原价 str += "<td width=\"70px\" id=\"newPrice" + product.Content[i].NumIid.ToString() + "\"> " + newPrice2 + "</td>"; //促销价 str += "<td width=\"70px\"><div id=\"yhlxDiv" + product.Content[i].NumIid.ToString() + "\"> " + itemtype2 + "</div></td>"; //优惠类型 str += "<td width=\"70px\"> <div id=\"yhhdDiv" + product.Content[i].NumIid.ToString() + "\"> " + itemtypevalue2 + "</div></td>"; //优惠幅度 str += "<td width=\"70px\"> <div id=\"yhslDiv" + product.Content[i].NumIid.ToString() + "\">" + yhCount + "</div></td>"; //优惠数量 str += "<td width=\"70px\"> <input type=\"text\" id=\"Rcount" + product.Content[i].NumIid.ToString() + "\" name=\"Rcount\" style=\"width:30px\" value=\"" + Rcount + "\" ></td>"; //参团人数 str += "<td width=\"140px\">" + hdstr + " </td>"; //操作 str += "</tr></table></div>"; } Response.Write(str); Response.Write("<br>"); long totalPage = (product.TotalResults % pageSizeNow == 0) ? (product.TotalResults / pageSizeNow) : (product.TotalResults / pageSizeNow + 1); //输出分页HTML for (int i = 1; i <= totalPage; i++) { if (page == i.ToString()) { Response.Write(i.ToString() + " "); } else { Response.Write("<a href=\"javascript:spreadStat(" + i.ToString() + ")\">[" + i.ToString() + "]</a> "); } } Response.End(); } }