Test.aspx.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using SiteCore;
  4. using SiteCore.nuonuo;
  5. using SiteCore.taoObj;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Runtime.InteropServices;
  10. using System.Text;
  11. public partial class Test : System.Web.UI.Page
  12. {
  13. static HttpHelper tb_http = new HttpHelper();
  14. public void createExcel()
  15. {
  16. //FileStream file = new FileStream(fname, FileMode.Open, FileAccess.Read);
  17. CeErpUser entity = CeErpUser.Get(1);
  18. //XSSFWorkbook xssfworkbook = new XSSFWorkbook();
  19. //DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
  20. //dsi.Company = SiteName;
  21. //xssfworkbook.DocumentSummaryInformation = dsi;
  22. //SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
  23. //si.Subject = excelName;
  24. //xssfworkbook.SummaryInformation = si;
  25. // xssfworkbook.CreateSheet("Sheet1");
  26. }
  27. [DllImport("Iphlpapi.dll")]
  28. private static extern int SendARP(Int32 dest, Int32 host, ref Int64 mac, ref Int32 length);
  29. [DllImport("Ws2_32.dll")]
  30. private static extern Int32 inet_addr(string ip);
  31. protected void Page_Load(object sender, EventArgs e)
  32. {
  33. CeErpTradeCell trade = CeErpTradeCell.GetByCtid("3091342752291422636");
  34. int iiii = commonHelper.autoDistributeToSupplier(trade);
  35. return;
  36. //int count = 0;
  37. //string sc ="300张";
  38. //int needSc = commonHelper.handleProductCount(sc);
  39. //return;
  40. //HttpCookie cookie = new HttpCookie("erp_df_cookie");
  41. //cookie.Values.Add("fileDownload", "true");
  42. //cookie.Path = "/";
  43. //cookie.Expires = DateTime.Now.AddDays(2);
  44. //HttpContext.Current.Response.Cookies.Add(cookie);
  45. //int billCount = (int)Math.Floor(Convert.ToDouble(650.00) / 1000.00);
  46. //if (Convert.ToDouble(1000.00) % 1000.00 > 0.000001)
  47. //{
  48. // billCount += 1;
  49. //}
  50. //billCount = billCount + 0;
  51. //commonHelper.setDeliveryUnusualOrder();
  52. //return;
  53. //commonHelper.setDeliveryUnusualOrder();
  54. //commonHelper.saveErpDesignerGather();
  55. //return;
  56. //string xx= commonHelper.changeCountFromChiness("1.3万张");
  57. //commonHelper.saveErpDesignerGather();
  58. //string tid = "2187050186665953601";
  59. //CeErpTradeCell main = CeErpTradeCell.GetByCtid(tid);
  60. //int idddd = commonHelper.autoDistributeToSupplier(main);
  61. //return;
  62. ////StringBuilder sql = new StringBuilder();
  63. ////sql.AppendFormat("select * from ce_erptradecell where datalength(othermemo)>0 and pay_time<CONVERT(datetime,'2021-09-27 09:30:00')");
  64. ////DataTable dt = CeErpUser.ExecuteDataset(sql.ToString()).Tables[0];
  65. ////foreach(DataRow dr in dt.Rows)
  66. ////{
  67. //// CeErpTrade father = CeErpTrade.Get(dr["tid"].ToString());
  68. //// if (father!=null)
  69. //// {
  70. //// tmcHelper.createCellOrder(father, father.tid, father.seller_memo, father.buyer_nick, true);
  71. //// }
  72. ////}
  73. //return;
  74. //string sc = "1000张";
  75. //string needSc = System.Text.RegularExpressions.Regex.Replace(sc, @"[^0-9]+", "");
  76. //return;
  77. //string pData_str = apiHelper.API_GetPrintData_SF("SF1331407611984");
  78. //return;
  79. //string msg = "{\"content\":{\"buyerMemo\":\"\",\"createTime\":1652169317000,\"discountFee\":5.0,\"finishTime\":1653240783000,\"flag\":\"NONE\",\"lines\":[{\"num\":4,\"outerId\":\"\",\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/784102056/O1CN015JMFcy1R3gz00jqy1_!!784102056.jpg\",\"price\":30.0,\"refOlId\":\"2623127259034339132\",\"refSkuId\":\"4438824914900\",\"refSpuId\":\"556635919506\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":28.75,\"singleFee\":28.75,\"standards\":\"定制专拍\",\"status\":\"COMPLETE\",\"title\":\"花店标签定做商标印logo外卖不干胶奶茶二维码蛋糕烘焙贴纸定制作\",\"totalFee\":115.0,\"totalPrice\":120.0,\"totalSellPrice\":115.0}],\"modifyTime\":1653240796000,\"openBuyerNick\":\"张娇娇202659\",\"openSellerNick\":\"kevin_boz\",\"orderTime\":1652169285000,\"payTime\":1652169314000,\"payment\":115.0,\"posCode\":\"yujia\",\"postFee\":0.0,\"receivedPayment\":115.0,\"receiverCity\":\"南通市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"如东县\",\"receiverId\":\"a5b2392a6dafabb757bf2ba58464e064\",\"receiverState\":\"江苏省\",\"receiverTown\":\"长沙镇\",\"refOid\":\"2623127259034339132\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"85x54mm-2000张-卡片-300克铜板纸-卡片双面印刷覆哑膜-大佐\",\"serviceFee\":0.0,\"shippingTime\":1652376771000,\"status\":\"COMPLETE\",\"totalFee\":115.0,\"totalPrice\":120.0,\"totalSellPrice\":115.0}}";
  80. //tmcHelper.Api_TmcTradeMsg(msg);
  81. //return;
  82. ////CeErpTradeCell entity = null;
  83. ////entity = CeErpTradeCell.GetByCtid_M("2038003957105948755");
  84. ////string en = entity.seller_memo;
  85. //return;
  86. //CeErpTradeCell.UpdateRelationOrder("123");
  87. //CeErpTradeCell enti = CeErpTradeCell.GetByCtid("2091930303202747015");
  88. //commonHelper.autoDistributeToSupplier(enti);
  89. //return;
  90. //CeErpShop nShop = CeErpShop.GetShopIdByName("琳19890725");
  91. //int shopId = 0;
  92. //if (nShop != null)
  93. //{
  94. // shopId = nShop.ID;
  95. //}
  96. //createExcel();
  97. //return;
  98. //StringBuilder sql = new StringBuilder();
  99. //sql.AppendFormat("select * from ce_erpuser");
  100. //DataTable dt = CeErpUser.ExecuteDataset(sql.ToString()).Tables[0];
  101. //Response.Write(dt.Rows.Count);
  102. //SqlParameter[] sqlParameter ={
  103. // new SqlParameter("@mainctids", SqlDbType.VarChar,100),
  104. // new SqlParameter("@res", SqlDbType.VarChar, 4000)
  105. // };
  106. //sqlParameter[0].Value = "1782296064444052131,1781979878135270634"; //1781979878135270634
  107. //sqlParameter[1].Direction = ParameterDirection.Output;
  108. //DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_set_download", sqlParameter);
  109. //string xxx = "1963426392010756507";
  110. //string[] tArr = xxx.Split(',');
  111. //string tids ="'"+ xxx+"'";
  112. //StringBuilder sql = new StringBuilder();
  113. //sql.AppendFormat("update ce_erptradecell set FinishPlaceTime=getdate(),OrderState={0},IsReturn=0 where ctid in ({1}) and orderstate={2} and IsReturn<>2 and seller_memo not like '%电子稿%' ;", (int)OrderState.下单完成, tids, (int)OrderState.设计完成);
  114. //sql.AppendFormat("update ce_erptradecell set FinishPlaceTime=getdate(),OrderState={0},IsReturn=0 where ctid in ({1}) and orderstate={2} and IsReturn<>2 and seller_memo like '%电子稿%' ;", (int)OrderState.已发货, tids, (int)OrderState.设计完成);
  115. //sql.AppendFormat("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", tids, (int)OrderState.下单完成, 0, "下载设计文件");
  116. //CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  117. //foreach (string ctid in tArr)
  118. //{
  119. // CeErpTradeCell entrade = CeErpTradeCell.GetByCtid(ctid);
  120. // if (entrade != null)
  121. // {
  122. // CeErpTradeCell.UpdateRelationOrder(entrade);
  123. // }
  124. //}
  125. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("1977497175893223014");
  126. //Response.Write(entity.ctid + "<br>");
  127. //string ctid = "S_S_24242342342342";
  128. //string postFile = "(S_S_24242342342342)[C2]";
  129. //int lastIndex = ctid.LastIndexOf("S_"); //最后一个S_的位置
  130. //string sPre = ctid.Substring(0, lastIndex + 2); //S_S_
  131. //string initTid = ctid.Substring(lastIndex + 2, ctid.Length - lastIndex - 2); //1962772776865084101
  132. //string pre_ctid = MidStrEx(postFile, "[", "]"); //C1
  133. //ctid = sPre + pre_ctid + "_" + initTid; //S_S_ + C1 + _ +1962772776865084101
  134. //return;
  135. //string sqlstr = "select * from view_erptradecell where ptid<>'' and WaitDesignTime>'2021-07-01' and OrderState>2 and seller_nick='kevin_boz';";
  136. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sqlstr).Tables[0];
  137. //if (dt.Rows.Count > 0)
  138. //{
  139. // foreach (DataRow dr in dt.Rows)
  140. // {
  141. // string upd = "update ce_erptradecell set orderstate=(select top 1 orderstate from ce_erptradecell where ctid not like 'S_%' and tid='" + dr["ptid"].ToString() + "') where ctid='" + dr["tid"].ToString() + "'";
  142. // }
  143. //}
  144. //Response.Write(HttpUtility.UrlDecode("lcf1020"));
  145. //string res = apiHelper.API_TradeFullinfoGet("","2021-06-29 00:00:00", "2021-06-29 23:00:00");
  146. //tmcHelper.Api_Tmc_CreateNewOrder(res);
  147. //apiHelper.API_TradeMemoUpdate("1330123692176573884", "YWDP001", "PURPLE", "拿样订单测试");
  148. //apiHelper.API_LogisticsOnlineSend("1330123692176573884", "YWDP001", "ZTO", "123123123123131");
  149. //apiHelper.API_PrintTemplate();
  150. //apiHelper.API_GetWaybill();
  151. //string xxx = apiHelper.API_GetPrintPage();
  152. //return;
  153. //cainiaoLink.TMS_WAYBILL_SUBSCRIPTION_QUERY("STO");
  154. ////taobaoHelper.TaobaoWlbWaybillISearch();
  155. //return;
  156. //string xxx = "{\"buyer_nick\":\"走着看看着走\",\"post_fee\":\"0.00\",\"iid\":645096826899,\"end_time\":1621470351000,\"payment\":\"100.00\",\"oid\":1808895853378936731,\"seller_nick\":\"睿恒博旗舰店\",\"type\":\"guarantee_trade\",\"tid\":1808895853378936731,\"status\":\"WAIT_SELLER_SEND_GOODS\"}";
  157. //tmcHelper.erp_TradeBuyerPay(xxx);
  158. //CeErpTradeCell cell = new CeErpTradeCell();
  159. //cell.ctid = "123456456456456";
  160. //cell.tid = "123456456456456";
  161. //cell.seller_memo = "123456456456456";
  162. //cell.Create();
  163. //return;
  164. //CeErpTradeCell cell = CeErpTradeCell.GetByCtid("1779238586365178663");
  165. //int k = 1;
  166. //Response.Write("OK");
  167. //invoicing_test();
  168. //taobaoHelper.GetAndHandleRefunds();
  169. //Response.Write(DateTime.Now.ToString() + "," + taobaoHelper.GetSign());
  170. //return;
  171. //bendi_test();
  172. //taobaoTmcTest.getInfo();
  173. //return;
  174. //string res = taobaoHelper.LogisticsCompaniesGet();//taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  175. //Console.WriteLine(res);
  176. //return;
  177. //string sessionKey = "62011121cc9403ccc4a9ZZ0aaZZ369f224369206db001f02201404768885";
  178. //Response.Write(taobaoHelper.cainiao_test(sessionKey));
  179. //DateTime stime = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00"));
  180. //DateTime etime = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59"));
  181. //string res = taobaoHelper.RefundsReceiveGet(sessionKey, stime,etime);
  182. //Console.WriteLine(res);
  183. //Refunds_receive_get_response_Obj reObj = null;
  184. //string res = taobaoHelper.test();
  185. //if (res == "") return;
  186. //try
  187. //{
  188. // res = GetUTF8String(Encoding.UTF8.GetBytes(res));
  189. // //res = res.Replace(" ", "");
  190. // reObj = JsonConvert.DeserializeObject<Refunds_receive_get_response_Obj>(res);
  191. // Response.Write(reObj);
  192. //}
  193. //catch (Exception ex)
  194. //{
  195. //}
  196. //return;
  197. //DataTable dt = tmcTest("taobao_trade_TradeBuyerPay");
  198. //if(dt!=null && dt.Rows.Count > 0)
  199. //{
  200. // DataRow dr = dt.Rows[0];
  201. // tmcHelper.erp_TradeBuyerPay(dr["con"].ToString());
  202. //}
  203. }
  204. public static string MidStrEx(string sourse, string startstr, string endstr)
  205. {
  206. string result = string.Empty;
  207. int startindex, endindex;
  208. try
  209. {
  210. startindex = sourse.IndexOf(startstr);
  211. if (startindex == -1)
  212. return result;
  213. string tmpstr = sourse.Substring(startindex + startstr.Length);
  214. endindex = tmpstr.IndexOf(endstr);
  215. if (endindex == -1)
  216. return result;
  217. result = tmpstr.Remove(endindex);
  218. }
  219. catch (Exception ex)
  220. {
  221. Console.WriteLine("MidStrEx Err:" + ex.Message);
  222. }
  223. return result;
  224. }
  225. //public static string invoicing_test()
  226. //{
  227. // string order = "{\"identity\":\"2329CC5F90EDAA8208F1F3C72A0CE72A713A9D425CD50CDE\",\"order\":{\"buyername\":\"浙江爱信诺\",\"taxnum\":\"124511234993295177\",\"phone\":\"0\",\"address\":\"浙江省杭州市万塘路\",\"account\":\"\",\"telephone\":\"0\",\"orderno\":\"nuonuo12345\",\"invoicedate\":\"2018-10-31 19:16:51\",\"clerk\":\"黄芝\",\"saleaccount\":\"宇宙行442612010103507108\",\"salephone\":\"0774-7893911\",\"saleaddress\":\"富川瑶族自治县新永路138号\",\"saletaxnum\":\"339901999999142\",\"kptype\":\"1\",\"message\":\"\",\"payee\":\"林莉苏\",\"checker\":\"林莉苏\",\"tsfs\":\"-1\",\"email\":\"502192347@qq.com\",\"qdbz\":\"0\",\"qdxmmc\":\"\",\"dkbz\":\"0\",\"deptid\":\"\",\"clerkid\":\"\",\"invoiceLine\":\"p\",\"cpybz\":\"\",\"detail\":[{\"goodsname\":\"苹果\",\"num\":\"1\",\"price\":\"1\",\"hsbz\":\"1\",\"taxrate\":\"0.13\",\"spec\":\"\",\"unit\":\"吨\",\"spbm\":\"10101150101\",\"zxbm\":\"\",\"fphxz\":\"0\",\"yhzcbs\":\"0\",\"zzstsgl\":\"\",\"lslbs\":\"\",\"kce\":\"\"}]}}";
  228. // //post参数
  229. // order = DESDZFP.Encrypt(order);
  230. // //post参数
  231. // List<string> postLst = new List<string>();
  232. // postLst.Add("order=" + order);
  233. // HttpItem item = new HttpItem()
  234. // {
  235. // URL = "http://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action",
  236. // Method = "POST",
  237. // ContentType = "application/x-www-form-urlencoded",
  238. // Postdata = string.Join("&", postLst.ToArray())
  239. // };
  240. // item.PostEncoding
  241. // HttpResult hResult = tb_http.GetHtml(item);
  242. // return hResult.Html;
  243. //}
  244. public static string get_invoicing_test()
  245. {
  246. string order = "{\"identity\":\"2329CC5F90EDAA8208F1F3C72A0CE72A713A9D425CD50CDE\",\"fpqqlsh\":[\"20170104160449979446\"]}";
  247. order = DESDZFP.Encrypt(order);
  248. //post参数
  249. List<string> postLst = new List<string>();
  250. postLst.Add("order=" + order);
  251. HttpItem item = new HttpItem()
  252. {
  253. URL = "http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action",
  254. Method = "POST",
  255. ContentType = "application/x-www-form-urlencoded",
  256. Postdata = string.Join("&", postLst.ToArray())
  257. };
  258. HttpResult hResult = tb_http.GetHtml(item);
  259. return hResult.Html;
  260. }
  261. private DataTable tmcTest(string topic)
  262. {
  263. string sql = string.Format("select * from S_TaoBaoTmc where topic='{0}' order by id asc",topic);
  264. DataTable dt = SqlHelper.ExecuteDataSet(sql).Tables[0];
  265. return dt;
  266. }
  267. private DataTable tmcTestAll()
  268. {
  269. string sql = string.Format("select * from S_TaoBaoTmc");
  270. DataTable dt = SqlHelper.ExecuteDataSet(sql).Tables[0];
  271. return dt;
  272. }
  273. private void test()
  274. {
  275. string sessionKey = "6100309b522c174d816e5218e193dd3ac90a91c452f96bc2201404768885";
  276. string orderId = "";
  277. string res = taobaoHelper.TradeFullinfoGet(sessionKey, "1628803047475600773");
  278. Console.WriteLine(res);
  279. if (res == "") return;
  280. try
  281. {
  282. res = GetUTF8String(Encoding.UTF8.GetBytes(res));
  283. Trades_sold_get_response_Obj jobj2 = JsonConvert.DeserializeObject<Trades_sold_get_response_Obj>(res);
  284. }
  285. catch (Exception ex)
  286. {
  287. Response.Write("发生错误" + res);
  288. }
  289. }
  290. private void bendi_test()
  291. {
  292. string sessionKey = "6100309b522c174d816e5218e193dd3ac90a91c452f96bc2201404768885";
  293. string orderId = "";
  294. //string res = taobaoHelper.TradesSoldGet(sessionKey);
  295. string res = taobaoHelper.test();
  296. if (res == "") return;
  297. try
  298. {
  299. //"{\"trades_sold_get_response\":{\"bbc\":\"456\"}"
  300. //Response.Write(res);
  301. //"{\"trades_sold_get_response\": {\"total_results\": 2036}}"
  302. res = GetUTF8String(Encoding.UTF8.GetBytes(res));
  303. //JObject jobj = (JObject)JsonConvert.DeserializeObject(res);//.TrimStart('{').TrimEnd('}')
  304. Trade_fullinfo_get_response_Obj jobj2 = JsonConvert.DeserializeObject<Trade_fullinfo_get_response_Obj>(res);
  305. //int k = 1;
  306. }
  307. catch (Exception ex)
  308. {
  309. Response.Write("发生错误" + ex.Message);
  310. }
  311. }
  312. public static string GetUTF8String(byte[] buffer)
  313. {
  314. if (buffer == null)
  315. return null;
  316. if (buffer.Length <= 3)
  317. {
  318. return Encoding.UTF8.GetString(buffer);
  319. }
  320. byte[] bomBuffer = new byte[] { 0xef, 0xbb, 0xbf };
  321. if (buffer[0] == bomBuffer[0] && buffer[1] == bomBuffer[1] && buffer[2] == bomBuffer[2])
  322. {
  323. return new UTF8Encoding(false).GetString(buffer, 3, buffer.Length - 3);
  324. }
  325. return Encoding.UTF8.GetString(buffer);
  326. }
  327. }