noti.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. using BizCom;
  2. using Microsoft.SqlServer.Server;
  3. using Newtonsoft.Json;
  4. using NPOI.OpenXmlFormats.Shared;
  5. using NPOI.SS.Formula.Functions;
  6. using SiteCore.taoObj;
  7. using SQLData;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Reflection;
  12. using System.Text;
  13. using System.Web;
  14. namespace SiteCore.Handler
  15. {
  16. public class noti : BaseHandler, IHttpHandler
  17. {
  18. public void ProcessRequest(HttpContext context)
  19. {
  20. if (UrlParmsCheck("t"))
  21. {
  22. String tname = GetString("t");
  23. MethodInfo method;
  24. Type type = this.GetType();
  25. method = type.GetMethod(tname);
  26. con = context;
  27. if (method == null)
  28. {
  29. conError("服务器返回错误");
  30. return;
  31. }
  32. successFlag = false;
  33. context.Response.ContentType = "application/json";
  34. context.Response.Headers.Set("Access-Control-Allow-Origin", "*");
  35. try
  36. {
  37. method.Invoke(this, null);
  38. }
  39. catch (Exception ex)
  40. {
  41. conError("服务器返回错误");
  42. }
  43. finally
  44. {
  45. //AfterInvoke(methodName);
  46. }
  47. //if (!successFlag) returnErrorMsg("服务器返回错误");
  48. }
  49. }
  50. public void sendNotify()
  51. {
  52. if (UrlPostParmsCheck("title,oid"))
  53. {
  54. string title = GetPostString("title");
  55. string openid = GetPostString("oid");
  56. WxPush.sendMonitorMsg(title, openid);
  57. conSuccess("已发送");
  58. return;
  59. }
  60. conError("没有发送成功!");
  61. }
  62. public void LT_ERP_delivery_push()
  63. {
  64. if (UrlPostParmsCheck("tbtid"))
  65. {
  66. string tbtid = GetPostString("tbtid");
  67. string outsid = GetPostString("outsid");
  68. string cpCode = GetPostString("cpcode");
  69. tbtid = tbtid.Trim();
  70. CeErpTrade mainEn = CeErpTrade.Get(tbtid);
  71. if (mainEn != null || tbtid.IndexOf("N") != -1 || tbtid.IndexOf("S") != -1)
  72. {
  73. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  74. //cpcode是 YTO-CAINIAO
  75. //string comCode = cpCode.Split('-')[0].ToString();
  76. string apires = "";
  77. if (tbtid.IndexOf("N") != -1 || tbtid.IndexOf("S") != -1)
  78. {
  79. apires = "发货成功";
  80. }
  81. else
  82. {
  83. string dcomcode = commonHelper.GetD3ComCode(cpCode, cpCode);
  84. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outsid);
  85. }
  86. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  87. //打单后发货
  88. if (apires.IndexOf("发货成功") != -1)
  89. {
  90. try
  91. {
  92. //还要插入快递信息到 快递信息表
  93. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  94. exinfo.tid = tbtid;
  95. exinfo.out_sid = outsid;
  96. exinfo.company_code = cpCode;
  97. exinfo.company_name = cpCode;
  98. //exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  99. exinfo.deliveryType = "发货成功";
  100. exinfo.print_time = DateTime.Now;
  101. exinfo.printUser = "裕恒";
  102. exinfo.Create();
  103. if (mainEn != null)
  104. {
  105. commonHelper.UpdateRelationOrder(mainEn.tid);
  106. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, outsid);
  107. }
  108. LogHelper.addLog(tbtid, 0, "裕恒接口-发货成功-" + cpCode + "-" + outsid);
  109. StringBuilder sql = new StringBuilder();
  110. sql.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, tbtid);
  111. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  112. returnSuccessMsg("记录及同步成功");
  113. return;
  114. }
  115. catch (Exception ex)
  116. {
  117. XLog.SaveLog(0, "裕恒接口发货成功后更新数据失败," + ex.Message);
  118. }
  119. }
  120. else
  121. {
  122. string errmsg = commonHelper.KeepChinese(apires);
  123. //returnErrorMsg("同步淘宝发货失败!" + errmsg);
  124. XLog.SaveLog(0, "裕恒接口-打单后发货失败," + tbtid + "," + outsid + "," + apires);
  125. try
  126. {
  127. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  128. exinfo.tid = tbtid;
  129. exinfo.out_sid = outsid;
  130. exinfo.company_code = cpCode;
  131. exinfo.company_name = cpCode;
  132. //exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  133. exinfo.deliveryType = "发货成功";
  134. exinfo.print_time = DateTime.Now;
  135. exinfo.printUser = "裕恒";
  136. exinfo.Create();
  137. returnSuccessMsg("记录成功!");
  138. }
  139. catch (Exception ex)
  140. {
  141. XLog.SaveLog(0, "裕恒接口记录快递号,失败," + ex.Message);
  142. }
  143. return;
  144. }
  145. //else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED") //已发货的不处理直接返回面单
  146. //{
  147. // entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  148. // if (entity.OrderState == 6)
  149. // {
  150. // entity.OrderState = 7;
  151. // }
  152. // btnType = "已发货";
  153. // entity.Update();
  154. // commonHelper.UpdateRelationOrder(entity.ctid);
  155. // //不处理
  156. //}
  157. //else
  158. //{
  159. // entity.LastBillCpCode = cpCode;
  160. // entity.LastBillWaybillCode = curUseWayBillCode;
  161. // entity.Update();
  162. // string errmsg = commonHelper.KeepChinese(apires);
  163. // var res_objz = new
  164. // {
  165. // restype = 0,
  166. // data = "打单后发货失败"
  167. // };
  168. // string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  169. // returnSuccess(ro_jsonz);
  170. // //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  171. // XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  172. // return;
  173. //}
  174. return;
  175. }
  176. returnErrorMsg("找不到对应订单记录,核对淘宝订单号");
  177. return;
  178. }
  179. returnErrorMsg("缺少必要的参数");
  180. }
  181. public void LT_ERP_order_err_report()
  182. {
  183. if (UrlPostParmsCheck("tbtid"))
  184. {
  185. string tbtid = GetPostString("tbtid");
  186. string errdis = GetPostString("errdis");
  187. tbtid = tbtid.Trim();
  188. CeErpTradeCell entity = null;
  189. if (tbtid != "") entity = CeErpTradeCell.GetByCtid(tbtid);
  190. if (entity != null)
  191. {
  192. entity.IsVerifyToSupplier = false;
  193. entity.IsReturn = 1;
  194. entity.ReturnTime = DateTime.Now;
  195. entity.ReturnReason = errdis;
  196. if (entity.OrderState == 6)
  197. {
  198. entity.OrderState = 5;
  199. }
  200. entity.Update();
  201. LogHelper.addLog(entity.ctid, 0, "裕恒接口-供应商退回下单", entity.OrderState);
  202. returnSuccessMsg("操作成功!");
  203. return;
  204. }
  205. else
  206. {
  207. StringBuilder sql = new StringBuilder();
  208. sql.AppendFormat("select * from CE_ErpTradeCell where tid='{0}' and orderstate=6 and SupplierId=8", tbtid);
  209. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  210. if (dt.Rows.Count > 1)
  211. {
  212. returnErrorMsg("匹配不到对应的淘宝单号,请直接发给领淘");
  213. return;
  214. }
  215. else
  216. {
  217. StringBuilder sqlbac = new StringBuilder();
  218. sqlbac.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsVerifyToSupplier=0,IsReturn=1,ReturnTime=getdate(),ReturnReason={1},OrderState=5 where ctid='{0}' and orderstate=6 and SupplierId=8;", dt.Rows[0]["ctid"].ToString(), errdis);
  219. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  220. LogHelper.addLog(dt.Rows[0]["ctid"].ToString(), 0, "裕恒接口-供应商退回下单", 0);
  221. returnSuccessMsg("操作成功");
  222. return;
  223. }
  224. }
  225. }
  226. returnErrorMsg("缺少必要的参数");
  227. }
  228. //印艺发货
  229. public void LT_ERP_YY_DELIVERY_PUSH()
  230. {
  231. if (UrlPostParmsCheck("tbtid"))
  232. {
  233. string tbtid = GetPostString("tbtid");
  234. string outsid = GetPostString("outsid");
  235. string cpCode = GetPostString("cpcode");
  236. tbtid = tbtid.Trim();
  237. CeErpTrade mainEn = CeErpTrade.Get(tbtid);
  238. if (mainEn != null || tbtid.IndexOf("N") != -1 || tbtid.IndexOf("S") != -1)
  239. {
  240. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  241. //cpcode是 YTO-CAINIAO
  242. //string comCode = cpCode.Split('-')[0].ToString();
  243. string apires = "";
  244. if (tbtid.IndexOf("N") != -1 || tbtid.IndexOf("S") != -1)
  245. {
  246. apires = "发货成功";
  247. }
  248. else
  249. {
  250. string dcomcode = commonHelper.GetD3ComCode(cpCode, cpCode);
  251. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outsid);
  252. }
  253. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  254. //打单后发货
  255. if (apires.IndexOf("发货成功") != -1)
  256. {
  257. try
  258. {
  259. //还要插入快递信息到 快递信息表
  260. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  261. exinfo.tid = tbtid;
  262. exinfo.out_sid = outsid;
  263. exinfo.company_code = cpCode;
  264. exinfo.company_name = cpCode;
  265. //exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  266. exinfo.deliveryType = "发货成功";
  267. exinfo.print_time = DateTime.Now;
  268. exinfo.printUser = "印艺";
  269. exinfo.Create();
  270. if (mainEn != null)
  271. {
  272. commonHelper.UpdateRelationOrder(mainEn.tid);
  273. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, outsid);
  274. }
  275. LogHelper.addLog(tbtid, 0, "印艺接口-发货成功-" + cpCode + "-" + outsid);
  276. StringBuilder sql = new StringBuilder();
  277. sql.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, tbtid);
  278. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  279. returnSuccessMsg("记录及同步成功");
  280. return;
  281. }
  282. catch (Exception ex)
  283. {
  284. XLog.SaveLog(0, "印艺接口发货成功后更新数据失败," + ex.Message);
  285. }
  286. }
  287. else
  288. {
  289. string errmsg = commonHelper.KeepChinese(apires);
  290. //returnErrorMsg("同步淘宝发货失败!" + errmsg);
  291. XLog.SaveLog(0, "印艺接口-打单后发货失败," + tbtid + "," + outsid + "," + apires);
  292. try
  293. {
  294. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  295. exinfo.tid = tbtid;
  296. exinfo.out_sid = outsid;
  297. exinfo.company_code = cpCode;
  298. exinfo.company_name = cpCode;
  299. //exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  300. exinfo.deliveryType = "发货成功";
  301. exinfo.print_time = DateTime.Now;
  302. exinfo.printUser = "印艺";
  303. exinfo.Create();
  304. returnSuccessMsg("记录成功!");
  305. }
  306. catch (Exception ex)
  307. {
  308. XLog.SaveLog(0, "印艺接口记录快递号,失败," + ex.Message);
  309. }
  310. return;
  311. }
  312. return;
  313. }
  314. returnErrorMsg("找不到对应订单记录,核对淘宝订单号");
  315. return;
  316. }
  317. returnErrorMsg("缺少必要的参数");
  318. }
  319. //智韬发货
  320. public void LT_ERP_ZT_DELIVERY_PUSH()
  321. {
  322. if (UrlPostParmsCheck("tbtid"))
  323. {
  324. string tbtid = GetPostString("tbtid");
  325. string outsid = GetPostString("outsid");
  326. string cpCode = GetPostString("cpcode");
  327. tbtid = tbtid.Trim();
  328. CeErpTrade mainEn = CeErpTrade.Get(tbtid);
  329. if (mainEn != null || tbtid.IndexOf("N") != -1 || tbtid.IndexOf("S") != -1)
  330. {
  331. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  332. //cpcode是 YTO-CAINIAO
  333. //string comCode = cpCode.Split('-')[0].ToString();
  334. string apires = "";
  335. if (tbtid.IndexOf("N") != -1 || tbtid.IndexOf("S") != -1)
  336. {
  337. apires = "发货成功";
  338. }
  339. else
  340. {
  341. string dcomcode = commonHelper.GetD3ComCode(cpCode, cpCode);
  342. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outsid);
  343. }
  344. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  345. //打单后发货
  346. if (apires.IndexOf("发货成功") != -1)
  347. {
  348. try
  349. {
  350. //还要插入快递信息到 快递信息表
  351. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  352. exinfo.tid = tbtid;
  353. exinfo.out_sid = outsid;
  354. exinfo.company_code = cpCode;
  355. exinfo.company_name = cpCode;
  356. //exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  357. exinfo.deliveryType = "发货成功";
  358. exinfo.print_time = DateTime.Now;
  359. exinfo.printUser = "智韬";
  360. exinfo.Create();
  361. if (mainEn != null)
  362. {
  363. commonHelper.UpdateRelationOrder(mainEn.tid);
  364. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, outsid);
  365. }
  366. LogHelper.addLog(tbtid, 0, "智韬接口-发货成功-" + cpCode + "-" + outsid);
  367. StringBuilder sql = new StringBuilder();
  368. sql.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, tbtid);
  369. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  370. returnSuccessMsg("记录及同步成功");
  371. return;
  372. }
  373. catch (Exception ex)
  374. {
  375. XLog.SaveLog(0, "智韬接口发货成功后更新数据失败," + ex.Message);
  376. }
  377. }
  378. else
  379. {
  380. string errmsg = commonHelper.KeepChinese(apires);
  381. //returnErrorMsg("同步淘宝发货失败!" + errmsg);
  382. XLog.SaveLog(0, "智韬接口-打单后发货失败," + tbtid + "," + outsid + "," + apires);
  383. try
  384. {
  385. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  386. exinfo.tid = tbtid;
  387. exinfo.out_sid = outsid;
  388. exinfo.company_code = cpCode;
  389. exinfo.company_name = cpCode;
  390. //exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  391. exinfo.deliveryType = "发货成功";
  392. exinfo.print_time = DateTime.Now;
  393. exinfo.printUser = "智韬";
  394. exinfo.Create();
  395. returnSuccessMsg("记录成功!");
  396. }
  397. catch (Exception ex)
  398. {
  399. XLog.SaveLog(0, "智韬接口记录快递号,失败," + ex.Message);
  400. }
  401. return;
  402. }
  403. return;
  404. }
  405. returnErrorMsg("找不到对应订单记录,核对淘宝订单号");
  406. return;
  407. }
  408. returnErrorMsg("缺少必要的参数");
  409. }
  410. //chy补差价单发货接口
  411. public void LT_ERP_CHY_DELIVERY_PUSH()
  412. {
  413. if (UrlPostParmsCheck("tbtid"))
  414. {
  415. string tbtid = GetPostString("tbtid").Trim();
  416. string outsid = GetPostString("outsid").Trim();
  417. string cpCode = GetPostString("cpcode").Trim();
  418. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tbtid);
  419. if (entity != null && entity.isAfterSaleOrder == 1)
  420. {
  421. entity.OrderState = 7;
  422. entity.Update();
  423. LogHelper.addLog(tbtid, 0, "chy发货售后单-" + cpCode + "-" + outsid);
  424. return;
  425. }
  426. string sql = "select top 1 * from view_erptradecell where ptid='" + tbtid + "';";
  427. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  428. if (dt.Rows.Count <= 0) return;
  429. string tid = dt.Rows[0]["tid"].ToString();
  430. string posCode = dt.Rows[0]["posCode"].ToString();
  431. string status = dt.Rows[0]["status"].ToString();
  432. string comCode = cpCode;
  433. string sqlstr = "select * from CE_ErpMailInfo";
  434. DataTable dtstr = DbHelper.DbConn.ExecuteDataset(sqlstr.ToString()).Tables[0];
  435. foreach (DataRow dr in dtstr.Rows)
  436. {
  437. if (dr["cpCode"].ToString().IndexOf(cpCode) != -1)
  438. {
  439. comCode = dr["cpCode"].ToString();
  440. }
  441. }
  442. if (status == "SHIPPED" || status == "PART_SHIPPED" || status == "COMPLETE" || status == "CLOSE") //已发货的不处理直接返回面单
  443. {
  444. return;
  445. //不处理
  446. }
  447. string apires = apiHelper.API_LogisticsDummySend(tid, posCode);
  448. if (apires.IndexOf("发货成功") == -1)
  449. {
  450. //XLog.SaveLog(0, "补差价单虚拟发货失败," + tid + "," + posCode + "," + apires);
  451. string wures = apiHelper.API_LogisticsOnlineSend(tid, posCode, comCode, outsid);
  452. if (wures.IndexOf("发货成功") == -1)
  453. {
  454. XLog.SaveLog(0, "chy补差价单实物发货失败," + tid + "," + posCode + "," + wures);
  455. return;
  456. }
  457. else
  458. {
  459. LogHelper.addLog(tid, 0, "chy补差价发货-" + comCode + "-" + outsid);
  460. }
  461. return;
  462. }
  463. else
  464. {
  465. LogHelper.addLog(tbtid, 0, "chy补差价发货-" + comCode + "-" + outsid);
  466. }
  467. }
  468. }
  469. //印艺快递停发
  470. public void LT_ERP_YY_STOP_DELIVERY()
  471. {
  472. if (UrlPostParmsCheck("tbtid"))
  473. {
  474. string tbtid = GetPostString("tbtid");
  475. tbtid = tbtid.Trim();
  476. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tbtid);
  477. if (entity != null)
  478. {
  479. if (entity.IsRefund <= 0 && entity.OrderState == 6)
  480. {
  481. entity.IsVerifyToSupplier = false;
  482. entity.UnusualTag = 5;
  483. entity.UnusualCon = "快递停发";
  484. entity.Update();
  485. LogHelper.addLog(entity.ctid, 0, "印艺接口-快递停发", entity.OrderState);
  486. returnSuccessMsg("操作成功!");
  487. return;
  488. }
  489. else
  490. {
  491. returnSuccessMsg("订单非下单完成状态或已退款!");
  492. return;
  493. }
  494. }
  495. else
  496. {
  497. returnErrorMsg("匹配不到对应的淘宝单号,请直接发给领淘");
  498. return;
  499. }
  500. }
  501. returnErrorMsg("缺少必要的参数");
  502. }
  503. public void get_product_form_data()
  504. {
  505. string tid = GetPostString("tid");
  506. if (tid != null && tid != "0")
  507. {
  508. tid = tid.Trim();
  509. CeErpTradeCell tradeCell = CeErpTradeCell.GetByCtid(tid);
  510. CeErpProduct entity = null;
  511. if (tradeCell != null)
  512. {
  513. entity = CeErpProduct.Get(tradeCell.ProductId);
  514. }
  515. CeErpOrderFormData formData = CeErpOrderFormData.GetByTid(tid);
  516. StringBuilder str = new StringBuilder();
  517. str.Append("{");
  518. str.Append("\"success\":true,");
  519. str.AppendFormat("\"tradeCell\":{0},", JsonConvert.SerializeObject(tradeCell));
  520. str.AppendFormat("\"product\":{0},", JsonConvert.SerializeObject(entity));
  521. str.AppendFormat("\"CeErpOrderFormData\":{0},", JsonConvert.SerializeObject(formData));
  522. str.AppendFormat("\"code\":200,");
  523. str.AppendFormat("\"msg\":\"成功\"");
  524. str.Append("}");
  525. con.Response.Write(str.ToString());
  526. }
  527. }
  528. public void save_product_form_data()
  529. {
  530. string tid = GetPostString("tid");
  531. if (tid != null && tid != "0")
  532. {
  533. tid = tid.Trim();
  534. CeErpTradeCell tradeCell = CeErpTradeCell.GetByCtid(tid);
  535. if (tradeCell == null)
  536. {
  537. returnErrorMsg("单号查无订单");
  538. return;
  539. }
  540. string info_sql = string.Format("SELECT ctid FROM [dbo].[CE_ErpTradeCell] WHERE tid ='{0}'", tradeCell.tid);
  541. DataTable data = DbHelper.DbConn.ExecuteDataset(info_sql).Tables[0];
  542. string content = GetPostString("content");
  543. int eid = GetPostInt("id");
  544. CeErpOrderFormData formData = null;
  545. if (data.Rows.Count > 0)
  546. {
  547. List<CeErpTradeCell> cell_list = new List<CeErpTradeCell>();
  548. foreach (DataRow row in data.Rows)
  549. {
  550. string ctid = row["ctid"].ToString();
  551. CeErpTradeCell cell = CeErpTradeCell.GetByCtid(ctid);
  552. cell_list.Add(cell);
  553. formData = CeErpOrderFormData.GetByTid(ctid);
  554. if (formData == null)
  555. {
  556. formData = new CeErpOrderFormData();
  557. }
  558. formData.tid = ctid;
  559. formData.content = content;
  560. if (formData.ID > 0)
  561. {
  562. formData.Update();
  563. }
  564. else
  565. {
  566. formData.userId = GetPostInt("userId");
  567. formData.Create();
  568. }
  569. }
  570. if (tradeCell.OrderState >= 5)
  571. {
  572. LogHelper.addLog(tradeCell.ctid, formData.userId > 0 ? formData.userId : 3542, "外链派单:订单状态不正确!", tradeCell.OrderState);
  573. returnSuccessMsg("保存成功!");
  574. return;
  575. }
  576. //能进来并且没有设计师
  577. foreach (CeErpTradeCell entity in cell_list)
  578. {
  579. try
  580. {
  581. if (entity != null && entity.seller_memo.Length > 0)
  582. {
  583. if (entity.OrderState >= 5)
  584. {
  585. LogHelper.addLog(entity.ctid, formData.userId > 0 ? formData.userId : 3542, "外链派单:订单状态不正确!", entity.OrderState);
  586. continue;
  587. }
  588. //判断能不能推送
  589. designApiResponseVo result = commonHelper.checkOrderListDesignInfo(entity.tid);
  590. if (result != null && result.code == 200)
  591. {
  592. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, "SysAdmin");
  593. if (response.code == 200)
  594. {
  595. if (response.msg == "设计共创:成功")
  596. {
  597. entity.OrderState = Convert.ToInt32(OrderState.待设计);
  598. entity.DesignUserId = 3542;
  599. entity.WaitDesignTime = DateTime.Now;
  600. entity.DispatchSort = 2;
  601. entity.Update();
  602. }
  603. }
  604. LogHelper.addLog(entity.ctid, formData.userId > 0 ? formData.userId : 3542, "外链派单:" + response.msg, Convert.ToInt32(OrderState.待设计));
  605. }
  606. else
  607. {
  608. LogHelper.addLog(entity.ctid, formData.userId > 0 ? formData.userId : 3542, "外链派单:" + result.msg, Convert.ToInt32(OrderState.待设计));
  609. }
  610. }
  611. }
  612. catch (Exception ex)
  613. {
  614. XLog.SaveLog(0, "外链派单:" + ex.Message);
  615. }
  616. }
  617. }
  618. returnSuccessMsg("保存成功!");
  619. }
  620. }
  621. //http://47.114.150.226:88/Handler/noti.ashx?t=LT_ERP_CHY_DELIVERY_PUSH post请求参数(参数放body中): tbtid(淘宝订单号) outsid(快递单号) cpcode(快递公司编码,如:圆通的是 YTO)
  622. }
  623. }