designHelper.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using NPOI.POIFS.Properties;
  4. using NPOI.SS.Formula.Functions;
  5. using SiteCore.Handler;
  6. using SiteCore.taoObj;
  7. using SQLData;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Collections.Specialized;
  11. using System.Data;
  12. using System.Linq;
  13. using System.Net;
  14. using System.Net.Http;
  15. using System.Reflection;
  16. using System.Runtime.Remoting.Messaging;
  17. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  18. using System.Security.Policy;
  19. using System.Text;
  20. using System.Text.RegularExpressions;
  21. using System.Threading.Tasks;
  22. using System.Web;
  23. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  24. using static SiteCore.taoObj.work_core_vo;
  25. namespace SiteCore.Handler
  26. {
  27. public class designHelper : BaseHandler, IHttpHandler
  28. {
  29. public void ProcessRequest(HttpContext context)
  30. {
  31. if (UrlParmsCheck("t"))
  32. {
  33. String tname = GetString("t");
  34. MethodInfo method;
  35. Type type = this.GetType();
  36. method = type.GetMethod(tname);
  37. con = context;
  38. if (method == null)
  39. {
  40. conError("找不到对应方法,服务器返回错误");
  41. return;
  42. }
  43. successFlag = false;
  44. context.Response.ContentType = "application/json";
  45. context.Response.Headers.Set("Access-Control-Allow-Origin", "*");
  46. try
  47. {
  48. method.Invoke(this, null);
  49. }
  50. catch (Exception ex)
  51. {
  52. conError("处理接口错误,服务器返回错误");
  53. }
  54. finally
  55. {
  56. }
  57. }
  58. }
  59. static string baseUrl = "http://api.lingtao8.com/";
  60. static string test_baseUrl = "https://sj.lingtao8.com/";
  61. //static string test_baseUrl = "http://47.122.40.91:8181/";
  62. //static string baseUrl = "http://47.122.40.91:8099/";
  63. static string pUrl = baseUrl + "api/manager/";
  64. static HttpHelper tb_http = new HttpHelper();
  65. public static designApiResponseVo API_GetPrintData_CreateOrder(CeErpTradeCell ceErpTradeCell, string post = "")
  66. {
  67. if (ceErpTradeCell.IsSample == 2)
  68. {
  69. return new designApiResponseVo(-1, "补差价订单不需要过设计系统");
  70. }
  71. string post_url = pUrl + "createOrder";
  72. CeErpOrderFormData formData = null;
  73. if (!ceErpTradeCell.ctid.Contains("S_") && ceErpTradeCell.ShopId != 136 && ceErpTradeCell.ShopId != 95)
  74. {
  75. formData = CeErpOrderFormData.GetByTid(ceErpTradeCell.ctid.ToString());
  76. if (formData == null)
  77. {
  78. return new designApiResponseVo(-1, "请填写订单的手机号或者微信号才可指派到设计系统");
  79. }
  80. }
  81. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell, post);
  82. if (response.code != 200)
  83. {
  84. return response;
  85. }
  86. WebClient wc = new WebClient();
  87. wc.Encoding = Encoding.GetEncoding("utf-8");
  88. //json参数
  89. NameValueCollection PostVars = getParams(ceErpTradeCell);
  90. if (ceErpTradeCell.CustomerUserId > 0)
  91. {
  92. string sql = "select top 1 Name,Mobile from view_ErpUser where ID = '" + ceErpTradeCell.CustomerUserId + "'";
  93. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  94. PostVars.Add("customerName", dt.Rows[0]["Name"].ToString());
  95. PostVars.Add("customerTel", dt.Rows[0]["Mobile"].ToString());
  96. }
  97. //{"msg":"推送成功","code":200,"success":true}
  98. string result = "";
  99. try
  100. {
  101. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  102. string remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  103. response = JsonConvert.DeserializeObject<designApiResponseVo>(remoteInfo);
  104. result = "设计共创:失败-" + response.msg;
  105. if (response.code == 200)
  106. {
  107. result = "设计共创:成功";
  108. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 2);
  109. //commonHelper.updateDataTradeCellDesignInfo(ceErpTradeCell.ctid);
  110. }
  111. }
  112. catch (Exception ex)
  113. {
  114. XLog.SaveLog(0, "API_GetPrintData_CreateOrder:" + ex.Message);
  115. }
  116. return new designApiResponseVo(200, result);
  117. }
  118. public static designApiResponseVo API_GetPrintData_CreateAfterOrder(CeErpTradeCell ceErpTradeCell, string post = "")
  119. {
  120. if (ceErpTradeCell.IsSample == 2)
  121. {
  122. return new designApiResponseVo(-1, "补差价订单不需要过设计系统");
  123. }
  124. string post_url = pUrl + "createAfterOrder";
  125. CeErpOrderFormData formData = null;
  126. if (!ceErpTradeCell.ctid.Contains("S_") && ceErpTradeCell.ShopId != 136 && ceErpTradeCell.ShopId != 95)
  127. {
  128. formData = CeErpOrderFormData.GetByTid(ceErpTradeCell.ctid.ToString());
  129. if (formData == null)
  130. {
  131. return new designApiResponseVo(-1, "请填写订单的手机号或者微信号才可指派到设计系统");
  132. }
  133. }
  134. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell, post);
  135. if (response.code != 200)
  136. {
  137. return response;
  138. }
  139. WebClient wc = new WebClient();
  140. wc.Encoding = Encoding.GetEncoding("utf-8");
  141. //json参数
  142. NameValueCollection PostVars = getParams(ceErpTradeCell);
  143. if (ceErpTradeCell.CustomerUserId > 0)
  144. {
  145. string sql = "select top 1 Name,Mobile from view_ErpUser where ID = '" + ceErpTradeCell.CustomerUserId + "'";
  146. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  147. PostVars.Add("customerName", dt.Rows[0]["Name"].ToString());
  148. PostVars.Add("customerTel", dt.Rows[0]["Mobile"].ToString());
  149. }
  150. //{"msg":"推送成功","code":200,"success":true}
  151. string result = "";
  152. try
  153. {
  154. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  155. string remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  156. response = JsonConvert.DeserializeObject<designApiResponseVo>(remoteInfo);
  157. result = "设计共创:失败-" + response.msg;
  158. if (response.code == 200)
  159. {
  160. result = "设计共创:成功";
  161. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 2);
  162. //commonHelper.updateDataTradeCellDesignInfo(ceErpTradeCell.ctid);
  163. }
  164. }
  165. catch (Exception ex)
  166. {
  167. XLog.SaveLog(0, "API_GetPrintData_CreateOrder:" + ex.Message);
  168. }
  169. return new designApiResponseVo(200, result);
  170. }
  171. public static designApiResponseVo API_update_order(CeErpTradeCell ceErpTradeCell)
  172. {
  173. string post_url = pUrl + "workCore";
  174. WebClient wc = new WebClient();
  175. wc.Encoding = Encoding.GetEncoding("utf-8");
  176. NameValueCollection PostVars = getParams(ceErpTradeCell);
  177. PostVars.Add("actionName", "orderRemarks");
  178. PostVars.Add("orderNumber", ceErpTradeCell.ctid);
  179. string result = "";
  180. try
  181. {
  182. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  183. string remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  184. designApiResponseVo response = JsonConvert.DeserializeObject<designApiResponseVo>(remoteInfo);
  185. result = "设计共创:失败-" + response.msg;
  186. if (response.code == 200)
  187. {
  188. result = "设计共创:成功";
  189. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 2);
  190. //commonHelper.updateDataTradeCellDesignInfo(ceErpTradeCell.ctid);
  191. }
  192. }
  193. catch (Exception ex)
  194. {
  195. XLog.SaveLog(0, "API_GetPrintData_CreateOrder:" + ex.Message);
  196. }
  197. return new designApiResponseVo(200, result);
  198. }
  199. public static designApiResponseVo API_update_renewOrder(CeErpTradeCell ceErpTradeCell)
  200. {
  201. string post_url = pUrl + "renewOrder";
  202. WebClient wc = new WebClient();
  203. wc.Encoding = Encoding.GetEncoding("utf-8");
  204. NameValueCollection PostVars = getParams(ceErpTradeCell);
  205. PostVars.Add("actionName", "orderRemarks");
  206. PostVars.Add("orderNumber", ceErpTradeCell.ctid);
  207. string result = "";
  208. try
  209. {
  210. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  211. string remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  212. designApiResponseVo response = JsonConvert.DeserializeObject<designApiResponseVo>(remoteInfo);
  213. result = "设计共创:失败-" + response.msg;
  214. if (response.code == 200)
  215. {
  216. result = "设计共创:成功";
  217. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 2);
  218. //commonHelper.updateDataTradeCellDesignInfo(ceErpTradeCell.ctid);
  219. }
  220. }
  221. catch (Exception ex)
  222. {
  223. XLog.SaveLog(0, "API_update_renewOrder:" + ex.Message);
  224. }
  225. return new designApiResponseVo(200, result);
  226. }
  227. private static NameValueCollection getParams(CeErpTradeCell ceErpTradeCell)
  228. {
  229. Boolean isOldCustomerText = false;
  230. Boolean isReturn = false;
  231. Boolean isGai = false;
  232. if (ceErpTradeCell.IsOldCustomer == 1)
  233. {
  234. isOldCustomerText = true;
  235. }
  236. if (ceErpTradeCell.IsReturn > 0)
  237. {
  238. isReturn = true;
  239. }
  240. if (ceErpTradeCell.MemoOpt == 1)
  241. {
  242. isGai = true;
  243. }
  244. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  245. CeErpShop ceErpShop = CeErpShop.Get(ceErpTradeCell.ShopId);
  246. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  247. //Dictionary<string, object> dataDic = ToDictionary(ro_json);
  248. //string urlData = ToUrlParams(dataDic);
  249. //string sql_pay = "INSERT INTO CE_ErpToDesignLog (ctid, ctime) VALUES ('" + ceErpTradeCell.ctid + "', '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
  250. //CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  251. NameValueCollection PostVars = new NameValueCollection();
  252. PostVars.Add("outId", ceErpTradeCell.ID.ToString());
  253. PostVars.Add("productId", ceErpTradeCell.ProductId.ToString());
  254. PostVars.Add("payment", ceErpTradeCell.payment.ToString());
  255. PostVars.Add("isUrgent", ceErpTradeCell.IsUrgency.ToString());
  256. PostVars.Add("customerMemo", ceErpTradeCell.CustomerMemo);
  257. PostVars.Add("shopName", ceErpShop.ShopName);
  258. PostVars.Add("buyerNick", ceErpTrade.buyer_nick != "" ? ceErpTrade.buyer_nick : "lingtao");
  259. PostVars.Add("receiverName", ceErpTrade.receiver_name);
  260. PostVars.Add("receiverMobile", ceErpTrade.receiver_mobile);
  261. PostVars.Add("receiverState", ceErpTrade.receiver_state);
  262. PostVars.Add("receiverCity", ceErpTrade.receiver_city);
  263. PostVars.Add("receiverDistrict", ceErpTrade.receiver_district);
  264. PostVars.Add("receiverAddress", ceErpTrade.receiver_address);
  265. PostVars.Add("tids", ceErpTradeCell.ctid);
  266. PostVars.Add("isOldUser", isOldCustomerText.ToString());
  267. PostVars.Add("sellerMemo", ceErpTradeCell.seller_memo);
  268. PostVars.Add("orderRemarks", ceErpTradeCell.seller_memo);
  269. PostVars.Add("isChange", isGai.ToString());
  270. PostVars.Add("isBack", isReturn.ToString());
  271. PostVars.Add("tid", ceErpTradeCell.tid);
  272. PostVars.Add("isDianziOrder", ceErpTradeCell.isDianziOrder.ToString());
  273. PostVars.Add("orderUnique", ceErpTradeCell.OrderSn);
  274. PostVars.Add("ptid", ceErpTradeCell.ptid);
  275. PostVars.Add("SplitTag", ceErpTradeCell.SplitTag);
  276. PostVars.Add("remarkSign", ceErpTradeCell.MemoOpt.ToString());
  277. PostVars.Add("otherMemo", ceErpTradeCell.OtherMemo);
  278. PostVars.Add("parentSplitNo", ceErpTradeCell.ParentSplitNo);
  279. if (ceErpTradeCellExtend != null)
  280. {
  281. PostVars.Add("productFirName", ceErpTradeCellExtend.cate1);/// 分类1
  282. PostVars.Add("productFirId", ceErpTradeCellExtend.cate1Id);/// 分类id
  283. PostVars.Add("productSecName", ceErpTradeCellExtend.cate2);/// 分类2
  284. PostVars.Add("productSecId", ceErpTradeCellExtend.cate2Id);/// 分类id
  285. PostVars.Add("productThirdId", ceErpTradeCellExtend.cate3Id);/// 分类id
  286. PostVars.Add("sceneName", ceErpTradeCellExtend.scene); /// 场景
  287. PostVars.Add("sceneId", ceErpTradeCellExtend.sceneId); /// 场景id
  288. PostVars.Add("productSizeW", ceErpTradeCellExtend.length.ToString()); /// 长
  289. PostVars.Add("productSizeH", ceErpTradeCellExtend.height.ToString()); /// 高
  290. PostVars.Add("productSizeL", ceErpTradeCellExtend.width.ToString()); /// 宽
  291. PostVars.Add("productCraftName", ceErpTradeCellExtend.craft); /// 工艺
  292. PostVars.Add("offerAmount", ceErpTradeCellExtend.offerAmount.ToString()); /// 报价金额
  293. PostVars.Add("styleCount", ceErpTradeCellExtend.numbers.ToString()); /// 款数
  294. PostVars.Add("materialName", ceErpTradeCellExtend.material); /// 材质
  295. PostVars.Add("materialId", ceErpTradeCellExtend.materialId); /// 材质id
  296. PostVars.Add("stylePricing", ceErpTradeCellExtend.numberType); /// 多款类型
  297. PostVars.Add("productSceneName", ceErpTradeCellExtend.typeScene); /// 品类场景
  298. PostVars.Add("productSceneId", ceErpTradeCellExtend.typeSceneId); /// 品类场景id
  299. PostVars.Add("opScene", ceErpTradeCellExtend.opScene); /// 运营场景
  300. PostVars.Add("opSceneId", ceErpTradeCellExtend.opSceneId); /// 运营场景id
  301. PostVars.Add("quantity", ceErpTradeCellExtend.quantity.ToString()); /// 数量
  302. PostVars.Add("productUnit", ceErpTradeCellExtend.numberUnit); /// 数量单位
  303. PostVars.Add("spuId", ceErpTradeCellExtend.spu_id); /// spuid
  304. PostVars.Add("recSize", ceErpTradeCellExtend.recSize); /// 推荐尺寸
  305. PostVars.Add("productSizeUnit", ceErpTradeCellExtend.sizeUnit); /// 尺寸单位
  306. PostVars.Add("orderFrom", ceErpTradeCellExtend.orderFrom.ToString()); /// 【订单来源】"10":第三方平台"15":私域电商"20":ERP"30":售前系统
  307. PostVars.Add("orderType", ceErpTradeCellExtend.orderType.ToString()); /// 【订单类型】"10":线上单"15":线下单"20":补差单"30":售后单
  308. PostVars.Add("discountAmount", ceErpTradeCellExtend.discountAmount.ToString());//折扣金额
  309. PostVars.Add("differentAmount", ceErpTradeCellExtend.differentAmount.ToString());//补差金额
  310. PostVars.Add("differentSplitNo", ceErpTradeCellExtend.differentSplitNo);//补差识别号
  311. }
  312. return PostVars;
  313. }
  314. /**
  315. *actionName:
  316. * followRemarks 跟单备注
  317. * orderRemarks 修改订单备注
  318. * rebutDesign 下单部打回设计单
  319. * afterDesign 售后设计单
  320. * changeDesign 改稿/定稿/加急
  321. * remarkSign 1改稿2定稿3加急
  322. * closeDesign 关闭订单
  323. * resetDesign 重置订单
  324. * packageDesign 顺丰状态
  325. * finishDesign 顺丰状态
  326. * approveDesign 下单部通过
  327. **/
  328. public static void API_WorkCore(string orderNumber, string actionName, string orderRemarks = "", int remarkSign = 0, string reasonRemarks = "", string isSf = "", int demandExamine = 0)
  329. {
  330. string post_url = pUrl + "workCore";
  331. WebClient wc = new WebClient();
  332. wc.Encoding = Encoding.GetEncoding("utf-8");
  333. NameValueCollection PostVars = new NameValueCollection();
  334. PostVars.Add("orderNumber", orderNumber);
  335. PostVars.Add("actionName", actionName);
  336. if (remarkSign > 0)
  337. {
  338. PostVars.Add("remarkSign", remarkSign.ToString());
  339. }
  340. if (orderRemarks != "")
  341. {
  342. PostVars.Add("orderRemarks", orderRemarks);
  343. }
  344. if (reasonRemarks != "")
  345. {
  346. PostVars.Add("reasonRemarks", reasonRemarks);
  347. }
  348. if (isSf != "")
  349. {
  350. PostVars.Add("packageSign", isSf);
  351. }
  352. if (demandExamine != 0)
  353. {
  354. PostVars.Add("demandExamine", demandExamine.ToString());
  355. }
  356. string remoteInfo = "";
  357. try
  358. {
  359. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  360. remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  361. }
  362. catch (Exception ex)
  363. {
  364. XLog.SaveLog(0, "API_WorkCore:" + ex.Message);
  365. }
  366. }
  367. /**
  368. *actionName:
  369. * followRemarks 跟单备注
  370. * orderRemarks 修改订单备注
  371. * rebutDesign 下单部打回设计单
  372. * afterDesign 售后设计单
  373. * changeDesign 改稿/定稿/加急
  374. * remarkSign 1改稿2定稿3加急
  375. * closeDesign 关闭订单
  376. * resetDesign 重置订单
  377. * packageDesign 顺丰状态
  378. * finishDesign 上传设计
  379. * repairDesign 补差金额
  380. * approveDesign 下单部通过
  381. * afterOver 售后结束
  382. **/
  383. public static void API_WorkCore(ApiVo vo)
  384. {
  385. string post_url = pUrl + "workCore";
  386. WebClient wc = new WebClient();
  387. wc.Encoding = Encoding.GetEncoding("utf-8");
  388. NameValueCollection PostVars = new NameValueCollection();
  389. PostVars.Add("orderNumber", vo.orderNumber);
  390. PostVars.Add("actionName", vo.actionName);
  391. PostVars.Add("isDesign", vo.isDesign.ToString());
  392. PostVars.Add("isOriginal", vo.isOriginal.ToString());
  393. if (vo.remarkSign > 0)
  394. {
  395. PostVars.Add("remarkSign", vo.remarkSign.ToString());
  396. }
  397. if (vo.orderRemarks != "")
  398. {
  399. PostVars.Add("orderRemarks", vo.orderRemarks);
  400. }
  401. if (vo.reasonRemarks != "")
  402. {
  403. PostVars.Add("reasonRemarks", vo.reasonRemarks);
  404. }
  405. if (vo.isSf != "")
  406. {
  407. PostVars.Add("packageSign", vo.isSf);
  408. }
  409. if (vo.demandExamine != 0)
  410. {
  411. PostVars.Add("demandExamine", vo.demandExamine.ToString());
  412. }
  413. if (vo.payment != 0)
  414. {
  415. PostVars.Add("payment", vo.payment.ToString());
  416. }
  417. if (vo.designFree != 0)
  418. {
  419. PostVars.Add("designFree", vo.designFree.ToString());
  420. }
  421. if (vo.responsibleId != 0)
  422. {
  423. PostVars.Add("responsibleId", vo.responsibleId.ToString());
  424. }
  425. if (!string.IsNullOrEmpty(vo.afterFiles))
  426. {
  427. PostVars.Add("afterFiles", vo.afterFiles);
  428. }
  429. string remoteInfo = "";
  430. try
  431. {
  432. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  433. remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  434. if ("orderRemarks".Equals(vo.actionName))
  435. {
  436. XLog.SaveLog(0, "API_WorkCore:" + remoteInfo + vo.actionName);
  437. }
  438. }
  439. catch (Exception ex)
  440. {
  441. XLog.SaveLog(0, "API_WorkCore:" + ex.Message);
  442. }
  443. }
  444. public static void api_approveDesign(string orderNumber)
  445. {
  446. string post_url = pUrl + "approveDesign";
  447. WebClient wc = new WebClient();
  448. wc.Encoding = Encoding.GetEncoding("utf-8");
  449. NameValueCollection PostVars = new NameValueCollection();
  450. PostVars.Add("orderNumber", orderNumber);
  451. string remoteInfo = "";
  452. try
  453. {
  454. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  455. remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  456. }
  457. catch (Exception ex)
  458. {
  459. XLog.SaveLog(0, "api_approveDesign:" + ex.Message);
  460. }
  461. }
  462. /**
  463. *actionName:
  464. * refundIng 退款申请
  465. * refundEd 已退款
  466. * refundCancel 取消退款
  467. **/
  468. public static void API_refundOrder(string orderNumber, string actionName, string remark)
  469. {
  470. string post_url = pUrl + "refundOrder";
  471. WebClient wc = new WebClient();
  472. wc.Encoding = Encoding.GetEncoding("utf-8");
  473. NameValueCollection PostVars = new NameValueCollection();
  474. PostVars.Add("orderNumber", orderNumber);
  475. PostVars.Add("actionName", actionName);
  476. PostVars.Add("orderRemarks", remark);
  477. string remoteInfo = "";
  478. try
  479. {
  480. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  481. remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  482. }
  483. catch (Exception ex)
  484. {
  485. XLog.SaveLog(0, "API_refundOrder:" + ex.Message);
  486. }
  487. }
  488. public static string API_CheckOrderTo(string orderNumber, string spuId, int shopId)
  489. {
  490. List<int> shopIds = new List<int>() { 5, 6, 8, 10, 11, 12, 14, 15, 16, 17, 18, 21, 23, 24, 27, 28, 31, 32, 56, 61, 63, 64, 66, 124, 126, 127, 128 };
  491. string result = "无";
  492. if (!shopIds.Contains(shopId))
  493. {
  494. return result;
  495. }
  496. string post_url = test_baseUrl + "api/originalOrder/discernOrder";
  497. System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // 根据需要选择合适的协议版本
  498. WebClient wc = new WebClient();
  499. wc.Encoding = Encoding.GetEncoding("utf-8");
  500. NameValueCollection PostVars = new NameValueCollection();
  501. PostVars.Add("orderNumber", orderNumber);
  502. PostVars.Add("spuId", spuId);
  503. try
  504. {
  505. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  506. string remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  507. designApiResponseVo designApiResponseVo = JsonConvert.DeserializeObject<designApiResponseVo>(remoteInfo);
  508. if (designApiResponseVo.code == 200)
  509. {
  510. result = designApiResponseVo.msg;
  511. }
  512. }
  513. catch (Exception ex)
  514. {
  515. XLog.SaveLog(0, "API_refundOrder:" + ex.Message);
  516. }
  517. return result;
  518. }
  519. public static string API_GetPrintData_Refund(CeErpTradeCell ceErpTradeCell)
  520. {
  521. string post_url = pUrl + "refund";
  522. //json参数
  523. List<string> postLst = new List<string>();
  524. Boolean isOldCustomerText = false;
  525. Boolean isReturn = false;
  526. Boolean isGai = false;
  527. if (ceErpTradeCell.IsOldCustomer == 1)
  528. {
  529. isOldCustomerText = true;
  530. }
  531. if (ceErpTradeCell.IsReturn > 0)
  532. {
  533. isReturn = true;
  534. }
  535. if (ceErpTradeCell.MemoOpt == 1)
  536. {
  537. isGai = true;
  538. }
  539. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  540. CeErpShop ceErpShop = CeErpShop.Get(ceErpTradeCell.ShopId);
  541. var res_obj = new
  542. {
  543. outId = ceErpTradeCell.ID,
  544. productId = ceErpTradeCell.ProductId,
  545. payment = ceErpTradeCell.payment,
  546. isUrgent = ceErpTradeCell.IsUrgency,
  547. customerMemo = ceErpTradeCell.CustomerMemo,
  548. shopName = ceErpShop.ShopName,
  549. buyerNick = ceErpTrade.buyer_nick != "" ? ceErpTrade.buyer_nick : "lingtao",
  550. receiverName = ceErpTrade.receiver_name,
  551. receiverMobile = ceErpTrade.receiver_mobile,
  552. receiverState = ceErpTrade.receiver_state,
  553. receiverCity = ceErpTrade.receiver_city,
  554. receiverDistrict = ceErpTrade.receiver_district,
  555. receiverAddress = ceErpTrade.receiver_address,
  556. tids = ceErpTradeCell.ctid,
  557. isOldUser = isOldCustomerText,
  558. sellerMemo = ceErpTradeCell.seller_memo,
  559. isChange = isGai,
  560. isBack = isReturn,
  561. tid = ceErpTradeCell.tid
  562. };
  563. string ro_json = JsonConvert.SerializeObject(res_obj);
  564. //;***************************************************
  565. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
  566. HttpItem item = new HttpItem()
  567. {
  568. URL = post_url,
  569. Method = "POST",
  570. Postdata = ro_json
  571. };
  572. item.PostEncoding = Encoding.UTF8;
  573. HttpResult hResult = tb_http.GetHtml(item);
  574. return hResult.Html;
  575. }
  576. public static string API_GetPrintData_ModifyOrder(string tid, string seller_memo, Boolean isGai, Boolean isReturn, string returnReason = "")
  577. {
  578. string post_url = pUrl + "modify";
  579. //json参数
  580. List<string> postLst = new List<string>();
  581. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  582. CeErpShop ceErpShop = null;
  583. if (ceErpTradeCell != null)
  584. {
  585. ceErpShop = CeErpShop.Get(ceErpTradeCell.ShopId);
  586. }
  587. var res_obj = new
  588. {
  589. outId = tid,
  590. orderText = seller_memo,
  591. isChange = isGai,
  592. isBack = isReturn,
  593. returnReason = returnReason,
  594. };
  595. string ro_json = JsonConvert.SerializeObject(res_obj);
  596. //***************************************************
  597. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
  598. HttpItem item = new HttpItem()
  599. {
  600. URL = post_url,
  601. Method = "POST",
  602. Postdata = ro_json
  603. };
  604. item.PostEncoding = Encoding.UTF8;
  605. HttpResult hResult = tb_http.GetHtml(item);
  606. return hResult.Html;
  607. }
  608. }
  609. }