apiCaiYingTong.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Cfg.MappingSchema;
  5. using NPOI.OpenXmlFormats.Shared;
  6. using NPOI.SS.Formula.Functions;
  7. using SiteCore.taoObj;
  8. using SQLData;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Data;
  12. using System.IO;
  13. using System.Linq;
  14. using System.Net;
  15. using System.Reflection;
  16. using System.Reflection.Emit;
  17. using System.Security.Cryptography;
  18. using System.Text;
  19. using System.Web;
  20. using Utils;
  21. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  22. using static SiteCore.taoObj.work_core_vo;
  23. namespace SiteCore.Handler
  24. {
  25. public class apiCaiYingTong : BaseHandler, IHttpHandler
  26. {
  27. public void ProcessRequest(HttpContext context)
  28. {
  29. if (UrlParmsCheck("t"))
  30. {
  31. String tname = GetString("t");
  32. MethodInfo method;
  33. Type type = this.GetType();
  34. method = type.GetMethod(tname);
  35. con = context;
  36. if (method == null)
  37. {
  38. conError("找不到对应方法,服务器返回错误");
  39. return;
  40. }
  41. successFlag = false;
  42. context.Response.ContentType = "application/json";
  43. context.Response.Headers.Set("Access-Control-Allow-Origin", "*");
  44. try
  45. {
  46. method.Invoke(this, null);
  47. }
  48. catch (Exception ex)
  49. {
  50. conError("处理接口错误,服务器返回错误");
  51. }
  52. finally
  53. {
  54. //AfterInvoke(methodName);
  55. }
  56. //if (!successFlag) returnErrorMsg("服务器返回错误");
  57. }
  58. }
  59. static string appID = "1823193185001";
  60. //***************************************************
  61. //static string signkey = "fed5be35cf5bd04b14dcfff984f861dd";
  62. static HttpHelper tb_http = new HttpHelper();
  63. static string merSecret = "D8FF9498A5A2E6A6B4CB6EF88DB1DC35";
  64. static string pUrl = "https://front.lingtao8.com/designRest.htm";
  65. //static string pUrl = "https://localhost:8999/designRest.htm";
  66. //static string pUrl = "http://yi.yhmwacg.cn/designRest.htm";
  67. public static int DateTimeToUnixTime(DateTime dateTime)
  68. {
  69. return (int)(dateTime - TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1))).TotalSeconds;
  70. }
  71. //public static string ToUrlParams(object jsonObject)
  72. //{
  73. // var queryString = System.Web.HttpUtility.ParseQueryString(string.Empty); // 遍历JSON对象的属性,并添加到查询字符串中
  74. // foreach (var property in jsonObject.GetType().GetProperties())
  75. // {
  76. // queryString[property.Name] = property.GetValue(jsonObject)?.ToString() ?? string.Empty;
  77. // }
  78. // return queryString.ToString();
  79. //}
  80. public static Dictionary<string, object> ToDictionary(object obj)
  81. {
  82. var type = obj.GetType();
  83. var properties = type.GetProperties();
  84. var dictionary = new Dictionary<string, object>();
  85. foreach (var property in properties)
  86. {
  87. var value = property.GetValue(obj);
  88. dictionary.Add(property.Name, value);
  89. }
  90. return dictionary;
  91. }
  92. public static string ToUrlParams(Dictionary<string, object> jsonObject)
  93. {
  94. var queryString = new System.Collections.Specialized.NameValueCollection();
  95. // 遍历JSON对象的属性,并添加到查询字符串中
  96. foreach (var property in jsonObject)
  97. {
  98. var value = property.Value;
  99. if (value != null)
  100. {
  101. // 如果属性值不为null,则添加到查询字符串中
  102. if (value is System.Collections.IEnumerable && !(value is string))
  103. {
  104. // 如果是数组或集合类型,需要进一步处理
  105. var index = 0;
  106. foreach (var item in (System.Collections.IEnumerable)value)
  107. {
  108. queryString.Add(property.Key + "[" + index + "]", item != null ? item.ToString() : string.Empty);
  109. index++;
  110. }
  111. }
  112. else
  113. {
  114. // 普通属性
  115. queryString.Add(property.Key, value.ToString());
  116. }
  117. }
  118. }
  119. // 获取最终的查询字符串
  120. return string.Join("&", queryString.AllKeys.Select(key => key + "=" + queryString[key]));
  121. }
  122. public static string createSignCode(string method, string timeStr, string design_app_id, string design_secret)
  123. {
  124. byte[] use_bytes;
  125. //query.Append(secret);
  126. //预留看一下到时候签名怎么用md5加密;***************************************************
  127. string encryStr = design_secret + method + timeStr + design_app_id + design_secret;
  128. MD5 md5 = MD5.Create();
  129. use_bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(encryStr));
  130. StringBuilder result = new StringBuilder();
  131. for (int i = 0; i < use_bytes.Length; i++)
  132. {
  133. result.Append(use_bytes[i].ToString("x2"));
  134. }
  135. string singResult = result.ToString();
  136. return singResult.Replace("-", "");
  137. //return bytes.ToString();
  138. }
  139. //http://47.114.150.226:88/Handler/apiDesign.ashx?t=DesignSys_AddLog post请求参数(参数放body中):string tid(淘宝订单号)string userName(操作用户)string con(日志内容)int orderState(订单状态)
  140. public void DesignSys_AddLog()
  141. {
  142. if (UrlPostParmsCheck("tid"))
  143. {
  144. try
  145. {
  146. //HttpContext.Current.Request.BinaryRead()
  147. string tid = GetPostString("tid");
  148. string userName = GetPostString("userName");
  149. int orderState = GetPostInt("orderState");
  150. string con = GetPostString("con");
  151. //returnErrorMsg(tid + "," + userName + "," + orderState + "," + con);
  152. //return;
  153. try
  154. {
  155. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  156. if (ceErpTradeCell != null)
  157. {
  158. if (userName != "")
  159. {
  160. CeErpUser ceErpUser = CeErpUser.GetByUserName(userName);
  161. if (ceErpUser != null)
  162. {
  163. LogHelper.addLog(tid, ceErpUser.ID, con, orderState);
  164. return;
  165. }
  166. else
  167. {
  168. returnErrorMsg("找不到对应用户");
  169. return;
  170. }
  171. }
  172. returnErrorMsg("找不到对应用户");
  173. }
  174. else
  175. {
  176. returnErrorMsg("找不到对应订单记录,核对淘宝订单号");
  177. }
  178. }
  179. catch (Exception ex)
  180. {
  181. XLog.SaveLog(0, "xxxxx," + ex.Message);
  182. }
  183. }
  184. catch (Exception ex)
  185. {
  186. XLog.SaveLog(0, ex.Message);
  187. }
  188. return;
  189. }
  190. returnErrorMsg("缺少必要的参数");
  191. }
  192. public void shipments_Api()
  193. {
  194. string tid = GetString("tid");
  195. string comCode = GetString("comCode");
  196. string out_Sid = GetString("out_Sid");
  197. string curUseWayBillCode = out_Sid;
  198. string cpCode = comCode;
  199. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  200. if (entity == null)
  201. {
  202. entity = CeErpTradeCell.GetByCode(tid);
  203. }
  204. if (entity != null)
  205. {
  206. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  207. string posCode = mainEn.posCode;
  208. string apires = API_LogisticsOnlineSend(tid, posCode, comCode, out_Sid);
  209. CeErpMessageAPI ceErpMessageAPI = new CeErpMessageAPI();
  210. JObject jsonObject = new JObject
  211. {
  212. { "tid", tid},
  213. { "pCode", posCode},
  214. { "comCode", comCode },
  215. { "out_Sid", out_Sid }
  216. };
  217. ceErpMessageAPI.ctid = tid;
  218. ceErpMessageAPI.tid = tid;
  219. ceErpMessageAPI.creationtime = DateTime.Now;
  220. ceErpMessageAPI.content = apires;
  221. ceErpMessageAPI.Create();
  222. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  223. {
  224. try
  225. {
  226. entity.OutSid = curUseWayBillCode;
  227. entity.OrderState = 7;
  228. entity.IsUrgency = false;
  229. entity.LastBillCpCode = "";
  230. entity.LastBillWaybillCode = "";
  231. entity.FinishDeliveryTime = DateTime.Now;
  232. entity.IsReturn = 0;
  233. entity.MemoOpt = 0;
  234. entity.Update();
  235. //还要插入快递信息到 快递信息表
  236. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  237. exinfo.tid = entity.ctid;
  238. exinfo.out_sid = entity.OutSid;
  239. exinfo.company_code = cpCode;
  240. exinfo.company_name = cpCode;
  241. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  242. exinfo.deliveryType = "发货成功";
  243. exinfo.print_time = DateTime.Now;
  244. exinfo.printUser = "彩印通接口";
  245. exinfo.Create();
  246. commonHelper.UpdateRelationOrder(entity.ctid);
  247. CeErpSukuraData.createInfo(entity.ctid, 4);
  248. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  249. }
  250. catch (Exception ex)
  251. {
  252. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  253. }
  254. }
  255. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  256. {
  257. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  258. if (entity.OrderState == 6)
  259. {
  260. entity.OrderState = 7;
  261. }
  262. entity.FinishDeliveryTime = DateTime.Now;
  263. entity.Update();
  264. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  265. exinfo.tid = entity.ctid;
  266. exinfo.out_sid = entity.OutSid;
  267. exinfo.company_code = cpCode;
  268. exinfo.company_name = cpCode;
  269. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  270. exinfo.deliveryType = "发货成功";
  271. exinfo.print_time = DateTime.Now;
  272. exinfo.printUser = "彩印通接口";
  273. exinfo.Create();
  274. commonHelper.UpdateRelationOrder(entity.ctid);
  275. //不处理
  276. }
  277. else
  278. {
  279. entity.LastBillCpCode = cpCode;
  280. entity.LastBillWaybillCode = curUseWayBillCode;
  281. entity.Update();
  282. string errmsg = commonHelper.KeepChinese(apires);
  283. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  284. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  285. }
  286. returnSuccessMsg(apires);
  287. LogHelper.addLog(entity.ctid, 0, "彩印通发货-" + comCode + "-" + out_Sid, entity.OrderState);
  288. return;
  289. }
  290. else
  291. {
  292. returnErrorMsg("找不到对应订单记录,核对淘宝订单号");
  293. return;
  294. }
  295. return;
  296. }
  297. public void waybill_Api()
  298. {
  299. string tid = GetString("tid");
  300. string cpCode = GetString("cpCode");
  301. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  302. if (entity == null)
  303. {
  304. entity = CeErpTradeCell.GetByCode(tid);
  305. }
  306. if (entity != null)
  307. {
  308. bool isUseLastWayBillCode = true;
  309. if ((entity.OrderState == 7 || entity.OrderState == 6))
  310. {
  311. isUseLastWayBillCode = false;
  312. }
  313. else
  314. {
  315. returnErrorMsg("订单状态错误无法获取面单");
  316. return;
  317. }
  318. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  319. {
  320. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  321. return;
  322. }
  323. string res = "";
  324. Api_waybill_code_response_Obj fullObj = null;
  325. string pData_str = "";
  326. string curUseWayBillCode = "";
  327. if (isUseLastWayBillCode == false)
  328. {
  329. res = apiHelper.API_GetWaybill(cpCode, tid);
  330. try
  331. {
  332. if (res.IndexOf("failure") != -1)
  333. {
  334. //int idx = res.IndexOf("sub_message");
  335. //int idx2 = res.IndexOf("flag");
  336. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  337. string errMsgNeed = commonHelper.KeepChinese(res);
  338. var res_objd = new
  339. {
  340. restype = 0,
  341. data = "获取面单失败" + errMsgNeed
  342. };
  343. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  344. returnSuccess(ro_jsond);
  345. if (res.IndexOf("停发") != -1)
  346. {
  347. entity.UnusualCon = "物流停发";
  348. entity.Update();
  349. }
  350. //returnErrorMsg("获取面单失败,"+emsg);
  351. XLog.SaveLog(0, "获取面单失败" + res);
  352. return;
  353. }
  354. else if (res.IndexOf("errorMsg") != -1)
  355. {
  356. //int idx = res.IndexOf("errorMsg");
  357. //int idx2 = res.IndexOf("}]}");
  358. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  359. string errMsgNeed = commonHelper.KeepChinese(res);
  360. var res_objf = new
  361. {
  362. restype = 0,
  363. data = "获取面单失败2" + errMsgNeed
  364. };
  365. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  366. if (res.IndexOf("停发") != -1)
  367. {
  368. entity.UnusualCon = "物流停发";
  369. entity.Update();
  370. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  371. if (trade != null)
  372. {
  373. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  374. }
  375. }
  376. returnSuccess(ro_jsonf);
  377. //returnErrorMsg("获取面单失败," + emsg);
  378. XLog.SaveLog(0, "获取面单失败2" + res);
  379. return;
  380. }
  381. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  382. //res = res.Replace(" ", "");
  383. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  384. }
  385. catch (Exception ex)
  386. {
  387. XLog.SaveLog(0, "生成fullObj" + res);
  388. var res_objf = new
  389. {
  390. restype = 0,
  391. data = "生成fullObj发生错误" + ex.Message
  392. };
  393. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  394. returnSuccess(ro_jsonf);
  395. return;
  396. }
  397. if (fullObj.response.data.content.Count > 0)
  398. {
  399. ContentItem codeObj = fullObj.response.data.content[0];
  400. if (cpCode.IndexOf("SFFQ-") != -1)
  401. {
  402. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  403. }
  404. else
  405. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  406. curUseWayBillCode = codeObj.waybillCode;
  407. LogHelper.addLog(entity.ctid, 0, "彩印通获取面单成功-" + cpCode + "-" + curUseWayBillCode, entity.OrderState);
  408. returnSuccess(pData_str);
  409. return;
  410. }
  411. else
  412. {
  413. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  414. var res_objf = new
  415. {
  416. restype = 0,
  417. data = "生成fullObj找不到快递单号waybillCode"
  418. };
  419. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  420. returnSuccess(ro_jsonf);
  421. return;
  422. }
  423. }
  424. else
  425. {
  426. //使用上次打印的快递单号
  427. if (cpCode == "SFFQ-LY")
  428. {
  429. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  430. }
  431. else
  432. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  433. curUseWayBillCode = entity.LastBillWaybillCode;
  434. }
  435. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  436. {
  437. var res_obje = new
  438. {
  439. restype = 0,
  440. data = "获取加密打印数据失败"
  441. };
  442. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  443. returnSuccess(ro_jsone);
  444. entity.LastBillCpCode = cpCode;
  445. entity.LastBillWaybillCode = curUseWayBillCode;
  446. entity.Update();
  447. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  448. //returnErrorMsg("获取加密打印数据失败");
  449. return;
  450. }
  451. }
  452. else
  453. {
  454. returnErrorMsg("找不到对应订单记录,核对淘宝订单号");
  455. return;
  456. }
  457. return;
  458. }
  459. //http://47.114.150.226:88/Handler/apiCaiYingTong.ashx?t=afterCytSale ctid status supmemo
  460. public void afterCytSale()
  461. {
  462. string ctid = GetString("ctid");
  463. int st = GetInt("status");
  464. string afmemo = GetString("supmemo");
  465. string id = "0";
  466. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  467. if (entity == null)
  468. {
  469. entity = CeErpTradeCell.GetByCode(ctid);
  470. if (entity == null)
  471. {
  472. returnErrorMsg("找不到订单记录");
  473. return;
  474. }
  475. }
  476. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserId(entity.ctid, 64, 1, 0);
  477. if (ceErpTradeResponsible == null)
  478. {
  479. ceErpTradeResponsible = CeErpTradeResponsible.GetByUserId(entity.ctid, 80, 1, 0);
  480. }
  481. if (ceErpTradeResponsible == null)
  482. {
  483. ceErpTradeResponsible = CeErpTradeResponsible.GetByUserId(entity.ctid, 126, 1, 0);
  484. }
  485. if (ceErpTradeResponsible != null)
  486. {
  487. id = ceErpTradeResponsible.ID.ToString();
  488. if (ceErpTradeResponsible.VerifyState == 1)
  489. {
  490. returnErrorMsg("已超时自动认可");
  491. return;
  492. }
  493. }
  494. if (entity != null && ceErpTradeResponsible != null)
  495. {
  496. if (entity.AfterSaleState != 3 || ceErpTradeResponsible.VerifyState != 0)
  497. {
  498. returnErrorMsg("此单售后当前状态不可操作!");
  499. return;
  500. }
  501. entity.AfterSaleSupplierState = st;
  502. entity.AfterSaleSupplierMemo = afmemo;
  503. if (st == 1)
  504. {
  505. ceErpTradeResponsible.VerifyState = 1;
  506. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  507. ceErpTradeResponsible.Update();
  508. bool isAll = commonHelper.tradeResponsibleAll(entity);
  509. if (isAll)
  510. {
  511. entity.AfterSaleState = 4;
  512. entity.AfterSaleSupplierState = 1;
  513. }
  514. }
  515. else
  516. {
  517. CeErpTradeResponsible.dateByTid(entity.ctid);
  518. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('彩印通接口供应商不认可')", ceErpTradeResponsible.tid);
  519. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  520. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  521. if (num <= 1)
  522. {
  523. entity.AfterSaleState = 1;
  524. }
  525. else
  526. {
  527. entity.AfterSaleState = 5;
  528. }
  529. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  530. if (ceErpTradeAfterSaleExtend != null)
  531. {
  532. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  533. ceErpTradeAfterSaleExtend.Update();
  534. }
  535. else
  536. {
  537. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  538. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  539. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  540. ceErpTradeAfterSaleExtend.Create();
  541. }
  542. }
  543. if (entity.AfterSaleState == 4)
  544. {
  545. LogHelper.addLog(entity.tid, 0, "彩印通接口完成售后", 0, 3);
  546. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  547. {
  548. LogHelper.addDesignerBillLog(entity.tid, 0, "彩印通接口售后取消设计费", "彩印通接口", 1);
  549. }
  550. ApiVo apiVo = new ApiVo();
  551. apiVo.orderNumber = entity.ctid;
  552. apiVo.actionName = "afterOver";
  553. designHelper.API_WorkCore(apiVo); //afterOver
  554. }
  555. entity.Update();
  556. returnSuccessMsg("操作成功!");
  557. CeErpSukuraData.createInfo(entity.ctid, 8);
  558. LogHelper.addLog(entity.ctid, 0, "彩印通接口供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  559. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "彩印通接口供应商" + (st == 1 ? "认可" : "不认可"), 0, st == 1 ? 0 : 1, afmemo);
  560. return;
  561. }
  562. returnErrorMsg("找不到订单记录");
  563. }
  564. //http://47.114.150.226:88/Handler/apiCaiYingTong.ashx?t=getMergeOrders orderSn
  565. public void getMergeOrders()
  566. {
  567. string orderSn = GetString("orderSn");
  568. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(orderSn);
  569. if (ceErpTradeCell == null)
  570. {
  571. ceErpTradeCell = CeErpTradeCell.GetByCtid(orderSn);
  572. }
  573. if (ceErpTradeCell == null)
  574. {
  575. returnErrorMsg("查无订单!");
  576. return;
  577. }
  578. if (ceErpTradeCell.SupplierId != 64 && ceErpTradeCell.SupplierId != 80 && ceErpTradeCell.SupplierId != 126)
  579. {
  580. returnErrorMsg("查无订单!");
  581. return;
  582. }
  583. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  584. DataTable dt = commonHelper.getSameOrderList(ceErpTradeCell, ceErpTrade);
  585. if (dt != null && dt.Rows.Count > 1)
  586. {
  587. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  588. return;
  589. }
  590. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  591. return;
  592. }
  593. public static string API_LogisticsOnlineSend(string orderid, string pCode, string comCode, string out_Sid)
  594. {
  595. if (string.IsNullOrWhiteSpace(orderid) || string.IsNullOrWhiteSpace(pCode) || string.IsNullOrWhiteSpace(comCode) || string.IsNullOrWhiteSpace(out_Sid))
  596. {
  597. return "参数不完整";
  598. }
  599. List<string> postLst = new List<string>();
  600. var res_obj = new
  601. {
  602. refOid = orderid,
  603. posCode = pCode,
  604. packages = new[]
  605. {
  606. new{ outSid=out_Sid,companyCode=comCode}
  607. }
  608. };
  609. string ro_json = JsonConvert.SerializeObject(res_obj);
  610. string res = apiHelper.Base_Request(ro_json, "ds.omni.erp.third.order.send");
  611. return res;
  612. }
  613. }
  614. }