designHelper.cs 28 KB

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