apiCaiYingTong.cs 29 KB

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