sync.initorder.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. using BizCom;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. namespace SiteCore.Handler
  6. {
  7. public partial class sync
  8. {
  9. //订单-原始订单 接口---------------------------------------------
  10. public void get_erp_initorderlist()
  11. {
  12. DataStruct dStruct = GetPostStruct();
  13. List<string> lw = new List<string>();
  14. string tid = GetPostString("tid");
  15. string date1 = GetPostString("date1");
  16. string date2 = GetPostString("date2");
  17. string buyernick = GetPostString("buyer_nick");
  18. if (tid.Length > 0)
  19. {
  20. lw.Add(string.Format("tid = '{0}'", tid));
  21. }
  22. if (date1.Length > 0)
  23. {
  24. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  25. if (dw.Length > 0) lw.Add(dw);
  26. }
  27. if (buyernick.Length > 0)
  28. {
  29. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  30. }
  31. if (tid.Length == 0 && date1.Length == 0 && buyernick.Length == 0)
  32. {
  33. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  34. }
  35. string shopname = GetPostString("shopname");
  36. if (shopname.Length > 0) lw.Add(string.Format("seller_nick like '%{0}%'", shopname));
  37. string address = GetPostString("address");
  38. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  39. string sellermemo = GetPostString("seller_memo");
  40. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  41. string price1 = GetPostString("price1");
  42. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  43. string price2 = GetPostString("price2");
  44. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  45. dStruct.Order = "pay_time desc";
  46. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  47. DataTable dt = WebCache.GetData("ce_erptrade", dStruct);
  48. writeGridDataTableJson(dStruct.TotalCount, dt);
  49. }
  50. //订单管理-备注 接口---------------------------------------------
  51. public void save_erp_initsellermemo()
  52. {
  53. if (UrlPostParmsCheck("seller_memo"))
  54. {
  55. string tid = GetPostString("tid");
  56. CeErpTrade entity = null;
  57. if (tid != "") entity = CeErpTrade.Get(tid);
  58. if (entity != null)
  59. {
  60. entity.seller_memo = GetPostString("seller_memo");
  61. entity.Update();
  62. returnSuccessMsg("保存成功!");
  63. return;
  64. }
  65. returnErrorMsg("找不到记录");
  66. }
  67. }
  68. //手动拆分原订单到订单列表 ,备注只有一个的就一个,2个的就拆分
  69. public void set_erp_splitorder()
  70. {
  71. if (UrlPostParmsCheck("tid"))
  72. {
  73. string tid = GetPostString("tid");
  74. CeErpTrade entity = null;
  75. if (tid != "") entity = CeErpTrade.Get(tid);
  76. if (entity != null)
  77. {
  78. LogHelper.addLog(entity.tid, CurrentUser.UserID, "点击强制生成", 0);
  79. tmcHelper.createCellOrder(entity, entity.tid, entity.seller_memo, entity.buyer_nick, true);//最后加上true跳过阻止直接拆分创建cell子单
  80. returnSuccessMsg("保存成功!");
  81. return;
  82. }
  83. returnErrorMsg("找不到记录");
  84. }
  85. }
  86. //订单-老系统数据---------------------------------------------
  87. public void get_erp_olddatalist()
  88. {
  89. DataStruct dStruct = GetPostStruct();
  90. List<string> lw = new List<string>();
  91. string tid = GetPostString("tid");
  92. string date1 = GetPostString("date1");
  93. string date2 = GetPostString("date2");
  94. if (tid.Length > 0 || date1.Length > 0)
  95. {
  96. lw.Add(string.Format("order_no like '%{0}%'", tid));
  97. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  98. if (dw.Length > 0) lw.Add(dw);
  99. }
  100. //else
  101. //{
  102. // lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  103. //}
  104. string shopname = GetPostString("shopname");
  105. if (shopname.Length > 0) lw.Add(string.Format("company_name like '%{0}%'", shopname));
  106. string buyernick = GetPostString("buyer_nick");
  107. if (buyernick.Length > 0) lw.Add(string.Format("customer_name like '%{0}%'", buyernick));
  108. string sellermemo = GetPostString("seller_memo");
  109. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  110. string price1 = GetPostString("price1");
  111. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  112. string price2 = GetPostString("price2");
  113. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  114. dStruct.Order = "pay_time desc";
  115. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  116. DataTable dt = WebCache.GetData("Sheet2$", dStruct);
  117. writeGridDataTableJson(dStruct.TotalCount, dt);
  118. }
  119. //订单-手提袋列表接口---------------------------------------------
  120. public void get_erp_bagorderlist()
  121. {
  122. DataStruct dStruct = GetPostStruct();
  123. List<string> lw = new List<string>();
  124. string tid = GetPostString("tid");
  125. string date1 = GetPostString("date1");
  126. string date2 = GetPostString("date2");
  127. if (tid.Length > 0 || date1.Length > 0)
  128. {
  129. lw.Add(string.Format("tid like '%{0}%'", tid));
  130. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  131. if (dw.Length > 0) lw.Add(dw);
  132. }
  133. else
  134. {
  135. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  136. }
  137. string shopname = GetPostString("shopname");
  138. if (shopname.Length > 0) lw.Add(string.Format("seller_nick like '%{0}%'", shopname));
  139. string buyernick = GetPostString("buyer_nick");
  140. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  141. string address = GetPostString("address");
  142. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  143. string sellermemo = GetPostString("seller_memo");
  144. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  145. string price1 = GetPostString("price1");
  146. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  147. string price2 = GetPostString("price2");
  148. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  149. lw.Add(string.Format("isBagOrder=1"));
  150. dStruct.Order = "pay_time desc";
  151. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  152. DataTable dt = WebCache.GetData("view_erptradeorder", dStruct);
  153. writeGridDataTableJson(dStruct.TotalCount, dt);
  154. }
  155. //订单-商品列表接口---------------------------------------------
  156. public void get_erp_goodslist()
  157. {
  158. DataStruct dStruct = GetPostStruct();
  159. List<string> lw = new List<string>();
  160. string tid = GetPostString("tid");
  161. string date1 = GetPostString("date1");
  162. string date2 = GetPostString("date2");
  163. string end_time1 = GetPostString("end_time1");
  164. string end_time2 = GetPostString("end_time2");
  165. if (tid.Length > 0)
  166. {
  167. lw.Add(string.Format("tid = '{0}'", tid));
  168. }
  169. if (tid.Length == 0 && date1.Length == 0 && end_time1.Length == 0)
  170. {
  171. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  172. }
  173. if (date1.Length > 0)
  174. {
  175. lw.Add(string.Format("pay_time > '{0}'", date1));
  176. }
  177. if (date2.Length > 0)
  178. {
  179. lw.Add(string.Format("pay_time < '{0}'", date2));
  180. }
  181. if (end_time1.Length > 0)
  182. {
  183. lw.Add(string.Format("end_time > '{0}'", end_time1));
  184. }
  185. if (end_time2.Length > 0)
  186. {
  187. lw.Add(string.Format("end_time < '{0}'", end_time2));
  188. }
  189. string shopname = GetPostString("shopname");
  190. if (shopname.Length > 0) lw.Add(string.Format("seller_nick like '%{0}%'", shopname));
  191. string buyernick = GetPostString("buyer_nick");
  192. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  193. string address = GetPostString("address");
  194. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  195. //string sellermemo = GetPostString("seller_memo");
  196. //if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  197. string price1 = GetPostString("price1");
  198. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  199. string price2 = GetPostString("price2");
  200. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  201. string goodsId = GetPostString("goodsId");
  202. bool tradeOrder = false;
  203. if (goodsId.Length > 0)
  204. {
  205. lw.Add(string.Format("spu_id like '%{0}%'", goodsId));
  206. tradeOrder = true;
  207. }
  208. //lw.Add(string.Format("isBagOrder=1"));
  209. dStruct.Order = "pay_time desc";
  210. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  211. string tableName = "view_ErpTradeOrder_trade";
  212. if (tradeOrder)
  213. {
  214. tableName = "view_ErpTradeOrder";
  215. }
  216. DataTable dt = WebCache.GetData(tableName, dStruct);
  217. writeGridDataTableJson(dStruct.TotalCount, dt);
  218. }
  219. //修改地址
  220. public void ins_erp_modifyaddress()
  221. {
  222. if (UrlPostParmsCheck("tid"))
  223. {
  224. string eid = GetPostString("tid");
  225. CeErpTrade entity = null;
  226. if (eid != "") entity = CeErpTrade.Get(eid);
  227. if (entity != null)
  228. {
  229. entity.receiver_name = GetPostString("receiver_name");
  230. entity.receiver_mobile = GetPostString("receiver_mobile");
  231. entity.receiver_state = GetPostString("receiver_state");
  232. entity.receiver_city = GetPostString("receiver_city");
  233. entity.receiver_district = GetPostString("receiver_district");
  234. entity.receiver_address = GetPostString("receiver_address");
  235. if (entity.receiver_state == "" || entity.receiver_city == "" || entity.receiver_name == "" || entity.receiver_mobile == "" || entity.receiver_address == "")
  236. {
  237. returnErrorMsg("不能为空");
  238. return;
  239. }
  240. entity.Update();
  241. returnSuccessMsg("修改成功!");
  242. return;
  243. }
  244. returnErrorMsg("找不到记录");
  245. }
  246. }
  247. //管理员强制修改数据接口
  248. public void save_admin_info()
  249. {
  250. string optype = GetPostString("optype");
  251. if (optype == "1")
  252. {
  253. string orderstate = GetPostString("orderstate");
  254. string eid = GetPostString("ctid");
  255. CeErpTradeCell entity = null;
  256. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  257. if (entity != null)
  258. {
  259. entity.OrderState = Convert.ToInt32(orderstate);
  260. entity.Update();
  261. returnSuccessMsg("操作成功!");
  262. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "强制修改状态为:" + orderstate, entity.OrderState, 0);
  263. return;
  264. }
  265. returnErrorMsg("找不到订单记录");
  266. }
  267. else if (optype == "2")
  268. {
  269. string isdianzi = GetPostString("isdianzi");
  270. string eid = GetPostString("ctid");
  271. CeErpTradeCell entity = null;
  272. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  273. if (entity != null)
  274. {
  275. entity.isDianziOrder = Convert.ToInt32(isdianzi);
  276. entity.Update();
  277. returnSuccessMsg("操作成功!");
  278. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "强制修改是否电子稿:" + isdianzi, entity.OrderState, 0);
  279. return;
  280. }
  281. returnErrorMsg("找不到订单记录");
  282. }
  283. else if (optype == "3")
  284. {
  285. string issample = GetPostString("issample");
  286. string eid = GetPostString("ctid");
  287. CeErpTradeCell entity = null;
  288. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  289. if (entity != null)
  290. {
  291. entity.IsSample = Convert.ToInt32(issample);
  292. entity.Update();
  293. returnSuccessMsg("操作成功!");
  294. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "强制修改是否补差价:" + issample, entity.OrderState, 0);
  295. return;
  296. }
  297. returnErrorMsg("找不到订单记录");
  298. }
  299. else if (optype == "4")
  300. {
  301. string eid = GetPostString("ctid");
  302. CeErpTradeCell entity = null;
  303. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  304. if (entity != null)
  305. {
  306. string outsid = entity.OutSid;
  307. string[] outList = outsid.Split(',');
  308. if (outList.Length > 0)
  309. {
  310. if (outList[outList.Length - 1] != "")
  311. {
  312. entity.OutSid = outList[outList.Length - 1];
  313. }
  314. }
  315. entity.Update();
  316. returnSuccessMsg("操作成功!");
  317. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "强制修改快递单号记录outsid:" + entity.OutSid, entity.OrderState, 0);
  318. return;
  319. }
  320. returnErrorMsg("找不到订单记录");
  321. }
  322. else if (optype == "5")
  323. {
  324. string eid = GetPostString("ctid");
  325. string productId = GetPostString("productId");
  326. CeErpTradeCell entity = null;
  327. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  328. if (entity != null)
  329. {
  330. entity.ProductId = Convert.ToInt32(productId);
  331. entity.Update();
  332. returnSuccessMsg("操作成功!");
  333. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "强制修改商品ProductId:" + entity.ProductId, entity.OrderState, 0);
  334. return;
  335. }
  336. returnErrorMsg("找不到订单记录");
  337. }
  338. }
  339. }
  340. }