designHelper.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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. //Dictionary<string, object> dataDic = ToDictionary(ro_json);
  246. //string urlData = ToUrlParams(dataDic);
  247. //string sql_pay = "INSERT INTO CE_ErpToDesignLog (ctid, ctime) VALUES ('" + ceErpTradeCell.ctid + "', '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
  248. //CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  249. NameValueCollection PostVars = new NameValueCollection();
  250. PostVars.Add("outId", ceErpTradeCell.ID.ToString());
  251. PostVars.Add("productId", ceErpTradeCell.ProductId.ToString());
  252. PostVars.Add("payment", ceErpTradeCell.payment.ToString());
  253. PostVars.Add("isUrgent", ceErpTradeCell.IsUrgency.ToString());
  254. PostVars.Add("customerMemo", ceErpTradeCell.CustomerMemo);
  255. PostVars.Add("shopName", ceErpShop.ShopName);
  256. PostVars.Add("buyerNick", ceErpTrade.buyer_nick != "" ? ceErpTrade.buyer_nick : "lingtao");
  257. PostVars.Add("receiverName", ceErpTrade.receiver_name);
  258. PostVars.Add("receiverMobile", ceErpTrade.receiver_mobile);
  259. PostVars.Add("receiverState", ceErpTrade.receiver_state);
  260. PostVars.Add("receiverCity", ceErpTrade.receiver_city);
  261. PostVars.Add("receiverDistrict", ceErpTrade.receiver_district);
  262. PostVars.Add("receiverAddress", ceErpTrade.receiver_address);
  263. PostVars.Add("tids", ceErpTradeCell.ctid);
  264. PostVars.Add("isOldlser", isOldCustomerText.ToString());
  265. PostVars.Add("sellerMemo", ceErpTradeCell.seller_memo);
  266. PostVars.Add("orderRemarks", ceErpTradeCell.seller_memo);
  267. PostVars.Add("isChange", isGai.ToString());
  268. PostVars.Add("isBack", isReturn.ToString());
  269. PostVars.Add("tid", ceErpTradeCell.tid);
  270. PostVars.Add("isDianziOrder", ceErpTradeCell.isDianziOrder.ToString());
  271. PostVars.Add("orderUnique", ceErpTradeCell.OrderSn);
  272. PostVars.Add("ptid", ceErpTradeCell.ptid);
  273. PostVars.Add("SplitTag", ceErpTradeCell.SplitTag);
  274. PostVars.Add("remarkSign", ceErpTradeCell.MemoOpt.ToString());
  275. PostVars.Add("otherMemo", ceErpTradeCell.OtherMemo);
  276. PostVars.Add("parentSplitNo", ceErpTradeCell.ParentSplitNo);
  277. if (ceErpTradeCellExtend != null)
  278. {
  279. PostVars.Add("productFirName", ceErpTradeCellExtend.cate1);/// 分类1
  280. PostVars.Add("productFirId", ceErpTradeCellExtend.cate1Id);/// 分类id
  281. PostVars.Add("productSecName", ceErpTradeCellExtend.cate2);/// 分类2
  282. PostVars.Add("productSecId", ceErpTradeCellExtend.cate2Id);/// 分类id
  283. PostVars.Add("productThirdId", ceErpTradeCellExtend.cate3Id);/// 分类id
  284. PostVars.Add("sceneName", ceErpTradeCellExtend.scene); /// 场景
  285. PostVars.Add("sceneId", ceErpTradeCellExtend.sceneId); /// 场景id
  286. PostVars.Add("productSizeW", ceErpTradeCellExtend.length.ToString()); /// 长
  287. PostVars.Add("productSizeH", ceErpTradeCellExtend.height.ToString()); /// 高
  288. PostVars.Add("productSizeL", ceErpTradeCellExtend.width.ToString()); /// 宽
  289. PostVars.Add("productCraftName", ceErpTradeCellExtend.craft); /// 工艺
  290. PostVars.Add("offerAmount", ceErpTradeCellExtend.offerAmount.ToString()); /// 报价金额
  291. PostVars.Add("styleCount", ceErpTradeCellExtend.numbers.ToString()); /// 款数
  292. PostVars.Add("materialName", ceErpTradeCellExtend.material); /// 材质
  293. PostVars.Add("materialId", ceErpTradeCellExtend.materialId); /// 材质id
  294. PostVars.Add("stylePricing", ceErpTradeCellExtend.numberType); /// 多款类型
  295. PostVars.Add("productSceneName", ceErpTradeCellExtend.typeScene); /// 品类场景
  296. PostVars.Add("productSceneId", ceErpTradeCellExtend.typeSceneId); /// 品类场景id
  297. PostVars.Add("opScene", ceErpTradeCellExtend.opScene); /// 运营场景
  298. PostVars.Add("opSceneId", ceErpTradeCellExtend.opSceneId); /// 运营场景id
  299. PostVars.Add("quantity", ceErpTradeCellExtend.quantity.ToString()); /// 数量
  300. PostVars.Add("productUnit", ceErpTradeCellExtend.numberUnit); /// 数量单位
  301. PostVars.Add("spuId", ceErpTradeCellExtend.spu_id); /// spuid
  302. PostVars.Add("recSize", ceErpTradeCellExtend.recSize); /// 推荐尺寸
  303. PostVars.Add("productSizeUnit", ceErpTradeCellExtend.sizeUnit); /// 尺寸单位
  304. PostVars.Add("orderFrom", ceErpTradeCellExtend.orderFrom.ToString()); /// 【订单来源】"10":第三方平台"15":私域电商"20":ERP"30":售前系统
  305. PostVars.Add("orderType", ceErpTradeCellExtend.orderType.ToString()); /// 【订单类型】"10":线上单"15":线下单"20":补差单"30":售后单
  306. PostVars.Add("discountAmount", ceErpTradeCellExtend.discountAmount.ToString());//折扣金额
  307. PostVars.Add("differentAmount", ceErpTradeCellExtend.differentAmount.ToString());//补差金额
  308. PostVars.Add("differentSplitNo", ceErpTradeCellExtend.differentSplitNo);//补差识别号
  309. }
  310. return PostVars;
  311. }
  312. /**
  313. *actionName:
  314. * followRemarks 跟单备注
  315. * orderRemarks 修改订单备注
  316. * rebutDesign 下单部打回设计单
  317. * afterDesign 售后设计单
  318. * changeDesign 改稿/定稿/加急
  319. * remarkSign 1改稿2定稿3加急
  320. * closeDesign 关闭订单
  321. * resetDesign 重置订单
  322. * packageDesign 顺丰状态
  323. * finishDesign 顺丰状态
  324. * approveDesign 下单部通过
  325. **/
  326. public static void API_WorkCore(string orderNumber, string actionName, string orderRemarks = "", int remarkSign = 0, string reasonRemarks = "", string isSf = "", int demandExamine = 0)
  327. {
  328. string post_url = pUrl + "workCore";
  329. WebClient wc = new WebClient();
  330. wc.Encoding = Encoding.GetEncoding("utf-8");
  331. NameValueCollection PostVars = new NameValueCollection();
  332. PostVars.Add("orderNumber", orderNumber);
  333. PostVars.Add("actionName", actionName);
  334. if (remarkSign > 0)
  335. {
  336. PostVars.Add("remarkSign", remarkSign.ToString());
  337. }
  338. if (orderRemarks != "")
  339. {
  340. PostVars.Add("orderRemarks", orderRemarks);
  341. }
  342. if (reasonRemarks != "")
  343. {
  344. PostVars.Add("reasonRemarks", reasonRemarks);
  345. }
  346. if (isSf != "")
  347. {
  348. PostVars.Add("packageSign", isSf);
  349. }
  350. if (demandExamine != 0)
  351. {
  352. PostVars.Add("demandExamine", demandExamine.ToString());
  353. }
  354. string remoteInfo = "";
  355. try
  356. {
  357. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  358. remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  359. }
  360. catch (Exception ex)
  361. {
  362. XLog.SaveLog(0, "API_WorkCore:" + ex.Message);
  363. }
  364. }
  365. /**
  366. *actionName:
  367. * followRemarks 跟单备注
  368. * orderRemarks 修改订单备注
  369. * rebutDesign 下单部打回设计单
  370. * afterDesign 售后设计单
  371. * changeDesign 改稿/定稿/加急
  372. * remarkSign 1改稿2定稿3加急
  373. * closeDesign 关闭订单
  374. * resetDesign 重置订单
  375. * packageDesign 顺丰状态
  376. * finishDesign 上传设计
  377. * repairDesign 补差金额
  378. * approveDesign 下单部通过
  379. * afterOver 售后结束
  380. **/
  381. public static void API_WorkCore(ApiVo vo)
  382. {
  383. string post_url = pUrl + "workCore";
  384. WebClient wc = new WebClient();
  385. wc.Encoding = Encoding.GetEncoding("utf-8");
  386. NameValueCollection PostVars = new NameValueCollection();
  387. PostVars.Add("orderNumber", vo.orderNumber);
  388. PostVars.Add("actionName", vo.actionName);
  389. PostVars.Add("isDesign", vo.isDesign.ToString());
  390. PostVars.Add("isOriginal", vo.isOriginal.ToString());
  391. if (vo.remarkSign > 0)
  392. {
  393. PostVars.Add("remarkSign", vo.remarkSign.ToString());
  394. }
  395. if (vo.orderRemarks != "")
  396. {
  397. PostVars.Add("orderRemarks", vo.orderRemarks);
  398. }
  399. if (vo.reasonRemarks != "")
  400. {
  401. PostVars.Add("reasonRemarks", vo.reasonRemarks);
  402. }
  403. if (vo.isSf != "")
  404. {
  405. PostVars.Add("packageSign", vo.isSf);
  406. }
  407. if (vo.demandExamine != 0)
  408. {
  409. PostVars.Add("demandExamine", vo.demandExamine.ToString());
  410. }
  411. if (vo.payment != 0)
  412. {
  413. PostVars.Add("payment", vo.payment.ToString());
  414. }
  415. if (vo.designFree != 0)
  416. {
  417. PostVars.Add("designFree", vo.designFree.ToString());
  418. }
  419. if (vo.responsibleId != 0)
  420. {
  421. PostVars.Add("responsibleId", vo.responsibleId.ToString());
  422. }
  423. if (!string.IsNullOrEmpty(vo.afterFiles))
  424. {
  425. PostVars.Add("afterFiles", vo.afterFiles);
  426. }
  427. string remoteInfo = "";
  428. try
  429. {
  430. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  431. remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  432. if ("orderRemarks".Equals(vo.actionName))
  433. {
  434. XLog.SaveLog(0, "API_WorkCore:" + vo.orderNumber + "—" + remoteInfo + vo.actionName);
  435. }
  436. }
  437. catch (Exception ex)
  438. {
  439. XLog.SaveLog(0, "API_WorkCore:" + ex.Message);
  440. }
  441. }
  442. public static void api_approveDesign(string orderNumber)
  443. {
  444. string post_url = pUrl + "approveDesign";
  445. WebClient wc = new WebClient();
  446. wc.Encoding = Encoding.GetEncoding("utf-8");
  447. NameValueCollection PostVars = new NameValueCollection();
  448. PostVars.Add("orderNumber", orderNumber);
  449. string remoteInfo = "";
  450. try
  451. {
  452. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  453. remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  454. }
  455. catch (Exception ex)
  456. {
  457. XLog.SaveLog(0, "api_approveDesign:" + ex.Message);
  458. }
  459. }
  460. /**
  461. *actionName:
  462. * refundIng 退款申请
  463. * refundEd 已退款
  464. * refundCancel 取消退款
  465. **/
  466. public static void API_refundOrder(string orderNumber, string actionName, string remark)
  467. {
  468. string post_url = pUrl + "refundOrder";
  469. WebClient wc = new WebClient();
  470. wc.Encoding = Encoding.GetEncoding("utf-8");
  471. NameValueCollection PostVars = new NameValueCollection();
  472. PostVars.Add("orderNumber", orderNumber);
  473. PostVars.Add("actionName", actionName);
  474. PostVars.Add("orderRemarks", remark);
  475. string remoteInfo = "";
  476. try
  477. {
  478. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  479. remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  480. }
  481. catch (Exception ex)
  482. {
  483. XLog.SaveLog(0, "API_refundOrder:" + ex.Message);
  484. }
  485. }
  486. public static string API_CheckOrderTo(string orderNumber, string spuId, int shopId)
  487. {
  488. 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 };
  489. string result = "无";
  490. if (!shopIds.Contains(shopId))
  491. {
  492. return result;
  493. }
  494. string post_url = pUrl + "discernOrder";
  495. System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // 根据需要选择合适的协议版本
  496. WebClient wc = new WebClient();
  497. wc.Encoding = Encoding.GetEncoding("utf-8");
  498. NameValueCollection PostVars = new NameValueCollection();
  499. PostVars.Add("orderNumber", orderNumber);
  500. PostVars.Add("spuId", spuId);
  501. try
  502. {
  503. byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
  504. string remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
  505. designApiResponseVo designApiResponseVo = JsonConvert.DeserializeObject<designApiResponseVo>(remoteInfo);
  506. if (designApiResponseVo != null && designApiResponseVo.code == 200)
  507. {
  508. result = designApiResponseVo.msg;
  509. }
  510. }
  511. catch (Exception ex)
  512. {
  513. XLog.SaveLog(0, "discernOrder:" + ex.Message);
  514. }
  515. return result;
  516. }
  517. public static string API_GetPrintData_Refund(CeErpTradeCell ceErpTradeCell)
  518. {
  519. string post_url = pUrl + "refund";
  520. //json参数
  521. List<string> postLst = new List<string>();
  522. Boolean isOldCustomerText = false;
  523. Boolean isReturn = false;
  524. Boolean isGai = false;
  525. if (ceErpTradeCell.IsOldCustomer == 1)
  526. {
  527. isOldCustomerText = true;
  528. }
  529. if (ceErpTradeCell.IsReturn > 0)
  530. {
  531. isReturn = true;
  532. }
  533. if (ceErpTradeCell.MemoOpt == 1)
  534. {
  535. isGai = true;
  536. }
  537. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  538. CeErpShop ceErpShop = CeErpShop.Get(ceErpTradeCell.ShopId);
  539. var res_obj = new
  540. {
  541. outId = ceErpTradeCell.ID,
  542. productId = ceErpTradeCell.ProductId,
  543. payment = ceErpTradeCell.payment,
  544. isUrgent = ceErpTradeCell.IsUrgency,
  545. customerMemo = ceErpTradeCell.CustomerMemo,
  546. shopName = ceErpShop.ShopName,
  547. buyerNick = ceErpTrade.buyer_nick != "" ? ceErpTrade.buyer_nick : "lingtao",
  548. receiverName = ceErpTrade.receiver_name,
  549. receiverMobile = ceErpTrade.receiver_mobile,
  550. receiverState = ceErpTrade.receiver_state,
  551. receiverCity = ceErpTrade.receiver_city,
  552. receiverDistrict = ceErpTrade.receiver_district,
  553. receiverAddress = ceErpTrade.receiver_address,
  554. tids = ceErpTradeCell.ctid,
  555. isOldUser = isOldCustomerText,
  556. sellerMemo = ceErpTradeCell.seller_memo,
  557. isChange = isGai,
  558. isBack = isReturn,
  559. tid = ceErpTradeCell.tid
  560. };
  561. string ro_json = JsonConvert.SerializeObject(res_obj);
  562. //;***************************************************
  563. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
  564. HttpItem item = new HttpItem()
  565. {
  566. URL = post_url,
  567. Method = "POST",
  568. Postdata = ro_json
  569. };
  570. item.PostEncoding = Encoding.UTF8;
  571. HttpResult hResult = tb_http.GetHtml(item);
  572. return hResult.Html;
  573. }
  574. public static string API_GetPrintData_ModifyOrder(string tid, string seller_memo, Boolean isGai, Boolean isReturn, string returnReason = "")
  575. {
  576. string post_url = pUrl + "modify";
  577. //json参数
  578. List<string> postLst = new List<string>();
  579. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  580. CeErpShop ceErpShop = null;
  581. if (ceErpTradeCell != null)
  582. {
  583. ceErpShop = CeErpShop.Get(ceErpTradeCell.ShopId);
  584. }
  585. var res_obj = new
  586. {
  587. outId = tid,
  588. orderText = seller_memo,
  589. isChange = isGai,
  590. isBack = isReturn,
  591. returnReason = returnReason,
  592. };
  593. string ro_json = JsonConvert.SerializeObject(res_obj);
  594. //***************************************************
  595. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
  596. HttpItem item = new HttpItem()
  597. {
  598. URL = post_url,
  599. Method = "POST",
  600. Postdata = ro_json
  601. };
  602. item.PostEncoding = Encoding.UTF8;
  603. HttpResult hResult = tb_http.GetHtml(item);
  604. return hResult.Html;
  605. }
  606. }
  607. }